Paypal Integration For Android Application By LetsNurture

3,732 views
3,499 views

Published on

Learn How to integrate paypal for Mobile payment in mobile application development.

Published in: Technology, Business
3 Comments
1 Like
Statistics
Notes
  • Check out this tutorial as well http://bit.ly/1YxS1bI for paypal integration ...
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Big thanks for sharing this code !
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • hi ketan your slide share is nice.Am also plan to integrate pay pal in to android app,regarding that i have some question please help me.What i need to integrate Paypal_MPL or PayPal_Android_sdk.If you don't mine can you send some screenshots for step by step for both integration sandbox and live please
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
3,732
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
30
Comments
3
Likes
1
Embeds 0
No embeds

No notes for slide

Paypal Integration For Android Application By LetsNurture

  1. 1. “iOS and Android Mobile application Development Company in India” www.letsnurture.com How to Integrate Paypal for Mobile Payment
  2. 2. “iOS and Android Mobile application Development Company in India” www.letsnurture.com Integrate Paypal for Mobile Payment Follow Simple steps describe below. Note: 1. include PayPal_MPL.jar in your Project you will get this library from sample attached here. 2.Obtain an AppID (for testing purposes, use the PayPal Sandbox AppID). Test id is APP-80W284485P519543T 3.Specify the PayPal environment you're addressing (for example, ENV_SANDBOX or ENV_LIVE) and the business' PayPal Account as the receiver. 4.Calculate the price of the item(s) or service to be purchased and input that value into your MPL call. 5.Set the Payment Type (for example, PAYMENT_TYPE_SERVICE or PAYMENT_TYPE_PERSONAL). 6. Make the MPL payment call. When you make the call, the customer is presented with an in-app PayPal log in screen and the payment processing is completed within your app (there is no browser or webview involved). 7.When the payment flow is complete, MPL returns control to your app.
  3. 3. “iOS and Android Mobile application Development Company in India” www.letsnurture.com Step 1: Add the necessary PayPal header files to your project. Declare both INTERNET and READ_PHONE_STATE permissions in the activity declared in your app's manifest file, like this: add this permission and activity into menifest file of your project. <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <activity android:name="com.paypal.android.MEP.PayPalActivity" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme.Translucent.NoTitleBar" /> Step 2: To add the library .jar file to an eclipse project that you can find it from project attached here . Step 3: Initialize the library with the initWithAppID method. The following code sets the required values needed to initialize the library, as well as setting some optional values. Note that the environment is set to ENV_SANDBOX (the PayPal Sandbox) and the static Sandbox AppID is hard-coded into the call. You can also set the environment to ENV_LIVE or ENV_NONE. When you make app live chane Enviroment to ENV_LIVE and supply live app-id.
  4. 4. “iOS and Android Mobile application Development Company in India” www.letsnurture.com // change it with live app id ppObj = PayPal.getInstance(); if (ppObj == null) { ppObj = PayPal.initWithAppID(MainActivity.this.getBaseContext(), "APP-80W284485P519543T", PayPal.ENV_SANDBOX); } // true = transaction requires shipping ppObj.setShippingEnabled(true); here if we want to use feature of shipping the we just enable setShippingEnabled(true); Step 4: Create the payment. Clicking the PayPal button initiates the checkout call, which can include different payment parameters and optional criteria for shipping, tax, languages, and type of payments. // Create a basic PayPal payment PayPalPayment newPayment = new PayPalPayment(); char val[] = { '5', '0' }; BigDecimal obj_0 = new BigDecimal("50"); // Set the payment amount, excluding tax and shipping costs newPayment.setSubtotal(new BigDecimal("50")); // Set the currency type newPayment.setCurrencyType("USD"); // Set the recipient for the payment (can be a phone number) newPayment.setRecipient("rahul@letsnurture.com");
  5. 5. “iOS and Android Mobile application Development Company in India” www.letsnurture.com // newPayment.setMerchantName("Company Name"); Intent paypalIntent = ppObj.checkout(newPayment, MainActivity.this); MainActivity.this.startActivityForResult(paypalIntent, 1); Step 5: Add a delegate to handle the response returned by the library. The handler will call one of three types (paymentSucceeded, paymentCanceled, paymentFailed) based on the result. Here's an example callback: @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (resultCode) { case Activity.RESULT_OK: // The payment succeeded String payKey = data.getStringExtra(PayPalActivity.EXTRA_PAY_KEY); if (payKey != null) { Toast.makeText(getApplicationContext(),"Successfullly Buy an item.", Toast.LENGTH_LONG).show(); } // // Tell the user their payment succeeded Log.e("Result success", "Result success-true //" + payKey); break; case Activity.RESULT_CANCELED: // The payment was canceled Tell the user their payment was canceled Log.e("Result cancled", "Result cancled-true"); break; case PayPalActivity.RESULT_FAILURE: // The payment failed -- we get the error from the EXTRA_ERROR_ID // and EXTRA_ERROR_MESSAGE String errorID = data.getStringExtra(PayPalActivity.EXTRA_ERROR_ID); String errorMessage = data .getStringExtra(PayPalActivity.EXTRA_ERROR_MESSAGE);
  6. 6. “iOS and Android Mobile application Development Company in India” www.letsnurture.com Log.e("Result failed", "Result failed-true"); Toast.makeText(getApplicationContext(), errorMessage, Toast.LENGTH_LONG).show(); // Tell the user their payment was failed. break; } }

×