Hi everyone
We all know PayPal is mostly using for transaction in recent days. The following is explain you how to add PayPal payment from your android application
Ready to get started with a simple payment? These steps will walk you through integrating the PayPal library and submitting it to x.com
Step 1 – Set up your sandbox accounts if you haven't already. You can create sandbox accounts by going to developer.paypal.com.
Step 2 – Add the PayPal library (a .jar file) into your Eclipse project, and then add the jar file to the build path. You can right click on the jar file to do this.
Step 3 – Update the AndroidManifest. The manifest will need to include the new activity "com.paypal.android.MEP.PayPalActivity". It will also need to declare the two permissions for Internet and Read-Phone-State.
Step 4 – Import the classes. Open the java file where you are adding the PayPal functionality. You will need to declare the various PayPal classes to use in your project.
Import com.paypal.android.CheckoutButton
Step 5 – Initialize the library by using the initWithAppId method. You'll pass in your App ID and the environment. The environment can either point to Live, Sandbox, or None. The "None" environment puts the library in a demo mode which makes no server calls so that you can continue coding even if you don't have a connection. You can also set the language here.
Step 6 – Place a PayPal button on the screen. You can choose from several different button sizes in the integration guide. You'll also pass the type of payment (hard goods, service, donation, personal payment). Then set the onClick listener for the button.
Step 7 – Implement the onClick function. This is where the actual checkout call happens. You'll specify all of the payment parameters (amount, currency, tax, shipping, recipient's email). You can also use some optional methods to recalculate the amount based on an address. You'll then create a new intent based on the PayPalActivity class and add the payment you just created.
Step 8 – Handle the response. You will receive the results through the onActivityResult method. It will either return OK, Cancelled, or Failure based on how the payment ended. When you receive these calls, you can continue in your app by thanking the buyer or asking them to try later.
Step 9 – Complete your project. Once you've finished your application, you can submit it to x.com (under the "My Apps" tab). In order for us to test it, you will need to attach a .zip file containing your .apk. PayPal will review the app in 1 business day (for apps using simple payments) and send you a valid App ID for the live environment. You"ll just need to update init method to point to Live with this new ID. (Don't forget to update the recipient to your live email address).
To read more click Here
We all know PayPal is mostly using for transaction in recent days. The following is explain you how to add PayPal payment from your android application
Ready to get started with a simple payment? These steps will walk you through integrating the PayPal library and submitting it to x.com
Step 1 – Set up your sandbox accounts if you haven't already. You can create sandbox accounts by going to developer.paypal.com.
Step 2 – Add the PayPal library (a .jar file) into your Eclipse project, and then add the jar file to the build path. You can right click on the jar file to do this.
Step 3 – Update the AndroidManifest. The manifest will need to include the new activity "com.paypal.android.MEP.PayPalActivity". It will also need to declare the two permissions for Internet and Read-Phone-State.
Code: |
|
Step 4 – Import the classes. Open the java file where you are adding the PayPal functionality. You will need to declare the various PayPal classes to use in your project.
Import com.paypal.android.CheckoutButton
Code: |
|
Step 5 – Initialize the library by using the initWithAppId method. You'll pass in your App ID and the environment. The environment can either point to Live, Sandbox, or None. The "None" environment puts the library in a demo mode which makes no server calls so that you can continue coding even if you don't have a connection. You can also set the language here.
Code: |
PayPal pp = PayPal.initWithAppID(this, "APP-80W284485P519543T", PayPal.ENV_SANDBOX); |
Step 6 – Place a PayPal button on the screen. You can choose from several different button sizes in the integration guide. You'll also pass the type of payment (hard goods, service, donation, personal payment). Then set the onClick listener for the button.
Code: |
|
Step 7 – Implement the onClick function. This is where the actual checkout call happens. You'll specify all of the payment parameters (amount, currency, tax, shipping, recipient's email). You can also use some optional methods to recalculate the amount based on an address. You'll then create a new intent based on the PayPalActivity class and add the payment you just created.
Code: |
|
Step 8 – Handle the response. You will receive the results through the onActivityResult method. It will either return OK, Cancelled, or Failure based on how the payment ended. When you receive these calls, you can continue in your app by thanking the buyer or asking them to try later.
Code: |
|
Step 9 – Complete your project. Once you've finished your application, you can submit it to x.com (under the "My Apps" tab). In order for us to test it, you will need to attach a .zip file containing your .apk. PayPal will review the app in 1 business day (for apps using simple payments) and send you a valid App ID for the live environment. You"ll just need to update init method to point to Live with this new ID. (Don't forget to update the recipient to your live email address).
To read more click Here
Nice tutorial help me lot
ReplyDeletecan you tell how to get Application ID
ReplyDelete@sravan
ReplyDeleteHi sravan
1.you must create a account in developer.paypal.com and select Myapp and give some information about your app .Paypal will give the Live Id for your app
2.For using sandbox please give this one
APP-80W284485P519543T for testing purpose
This is one of the good clarity post.your blog is doing an important role In internet marketing field.
ReplyDeleteAndroid app developers
This is such a abounding ability that you are accoutrement and you accord it abroad for changeless and I will actually adorable it and I'll advance to my friends.I appreceive they will actually be benefited from this site.
ReplyDeletehi, i get classNotFoundException in this line
ReplyDeletePayPal pp = PayPal.initWithAppID(this, "APP-80W284485P519543T", PayPal.ENV_SANDBOX);
i have already add the PayPal_MPL.jar in the Referenced Liberary folder in our project.....
great tutorial, very helpfull, keep it up!!
ReplyDeletesmall typo
onActivityResults() method should be renamed to onActivityResult()
I have did as same as your's....Then i run the application in my device After logged in It's move to Next Page with Pay Button and i hit the button then it shows "Processing Payment" on that time if any network failure it's not notify anything it's keep on loading some time and ask to "Force close" the application.How to handle the network failure..
ReplyDeleteThanks in advance....
Hi! How do I add aPayPal button to each page of a jQuery mobile site that I have "wrapped" within Java in the Android SDK?
ReplyDeleteThanks in advance,
David
thanks a lot...saved me from lots of confusion...
ReplyDeletecoder
Thank you Thank sooo much..
ReplyDeleteVery clear.
could you please tell me what is difference between MPL,MECL.
Nice information shared in this post. thanks for this very effective and valuable article. keep it up......
ReplyDeleteHi these is very nice tutorial.I have done these paypal integration successfully.here how can i add the product name,price and quantity to paypal server.
ReplyDeletehello is it possible with back-end API ? i mean without paypal dialog ?
ReplyDeleteou est le PayPal_MPL.jar svp ???
ReplyDeleteNice Tutorial....
ReplyDeleteNice Tutorial....
ReplyDeletehmm... really confuse..
ReplyDeleteis our default paypal account is different from this developer/sandbox account?
do we must register again using our address etc like we are register first time in paypal?
Very nice tutorial, thanks!!
ReplyDeleteNice tutorial THANKS!!!
ReplyDeleteI am getting
error code = 10004
error message = please make sure all fields have been entered
Please help me.
I am getting error while login to paypal from android .Following is the error message:
ReplyDeleteError Message:Login failed. Go to www.paypal.com to resolve this issue.
Error Code:10804
i am getting error
ReplyDeleteStep 7 how to set onclick event
I am getting error in step 6.. :'( I am sorry but I am new to this
ReplyDeleteHeres what I did
import java.math.BigDecimal;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.LinearLayout;
import com.paypal.android.MEP.CheckoutButton;
import com.paypal.android.MEP.PayPal;
import com.paypal.android.MEP.PayPalActivity;
import com.paypal.android.MEP.PayPalPayment;
import com.paypal.android.MEP.PayPalAdvancedPayment;
import com.paypal.android.MEP.PayPalInvoiceData;
import com.paypal.android.MEP.PayPalInvoiceItem;
import com.paypal.android.MEP.PayPalReceiverDetails;
public class MainActivity extends Activity {
PayPal pp = PayPal.initWithAppID(this, "APP-80W284485P519543T", PayPal.ENV_SANDBOX);
LinearLayout layoutSimplePayment = new LinearLayout(this);
layoutSimplePayment.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
layoutSimplePayment.setOrientation(LinearLayout.VERTICAL);
CheckoutButton launchSimplePayment = pp.getCheckoutButton(this, PayPal.BUTTON_194x37, CheckoutButton.TEXT_PAY);
launchSimplePayment.setOnClickListener(this);
layoutSimplePayment.addView(launchSimplePayment);
content.addView(layoutSimplePayment);
public void onClick (View v) {
PayPalPayment payment = new PayPalPayment();
payment.setSubtotal(new BigDecimal("8.25"));
payment.setCurrencyType("PHP");
payment.setRecipient("mksob@gmail.com");
payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);
Intent checkoutIntent = PayPal.getInstance().checkout(payment, this);
startActivityForResult(checkoutIntent, 1);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(resultCode) {
case Activity.RESULT_OK:
break;
case Activity.RESULT_CANCELED:
break;
case PayPalActivity.RESULT_FAILURE:
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Please help me what to do :'(
Nice tutorial, which helps for lot of people...
ReplyDeleteAndroid Development
Great work, but it does not work now, because Paypal sdk was updated 2.13.0 version. :(
ReplyDeleteis it possible to transfer balance in multiple account at a time? suppose I send 20 dollar in a@gmail.com to 10 dollar and b@gmail.com 10 dollar. If possible how to recipent?
ReplyDeleteThese ways are very simple and very much useful, as a beginner level these helped me a lot thanks fore sharing these kinds of useful
ReplyDeleteand knowledgeable information.
Mobile App Development Company
Mobile App Development Company in India
Mobile App Development Companies
This article is very much helpful and i hope this will be an useful information for the needed one.Keep on updating these kinds of informative things...
ReplyDeletePSD to Wordpress
wordpress website development