Payment Gateway Integration Through PayPal in iOS and Android Apps
05 Aug. 2014 Mobile App
Today mobile payments are being adopted all over the world in many different ways. A research firm anticipates that the alternate payments industry comprising online, mobile and contactless segments will post a CAGR of 17.6% over the period 2010–15, with revenues increasing from $740bn in 2010 to $2,700bn in 2015. The largest revenue-generating segment of the advanced payments industry is the online payment segment.
Creating a native iOS or Android app for your business is an ideal strategic decision to capture the online payment market. But before creating an enterprise mobile app, you first need to understand how payment gateway integration in android/iOS is executed. To showcase the integration, you need to first decide the payment gateway.
PayPal is one of the widely used payment gateway today and we’ve taken PayPal as the payment gateway for the native mobile app. This article explains a stepwise guide of android payment gateway integration and steps for payment gateway integration in iOS.
The PayPal Mobile SDKs enable native apps to easily accept PayPal and credit card payments. The native libraries of the PayPal Mobile SDKs enable you to build fast, responsive apps for the Single payments and Future payments.
What is a Single Payment?
Single payment is an ideal payment process to execute only one payment at a time. Through single payments, you can receive immediate payment from a customer’s PayPal account or payment card (scanned with card.io). For single payments, your app can accept PayPal and credit-card payments.
Payment Gateway Integration Process Diagram
Executing Single Payment in Android & iOS is made easy through PayPal’s SDK’s. To conduct payment gateway integration first download the SDK from GitHub:
- PayPal Android SDK or PayPal iOS SDK
- Get your credentials, which identify your PayPal account as the payment receiver. Specifically, obtain a client ID and secret
After downloading and installing, to execute Single payment the PayPal SDK will help the native app by providing:
- UI to gather payment information from the user
- Coordinates payment with PayPal
- Returns a proof of payment to your app
And your code will:
- Receive proof of payment from the PayPal SDK
- Sends proof of payment to your servers for verification
- Provides the user their goods or services
Steps for PayPal payment gateway integration in Android
- Add permissions to your AndroidManifest.xml file
- Declare SDK service and activities in your AndroidManifest.xml file
- Create a PayPalConfiguration object
- Start PayPalService when your activity is created and stop it upon destruction:
- Create the payment and launch the payment intent, for example, when a button is pressed
- Implement onActivityResult()
- Send the proof of payment to your servers for verification, as well as any other processing required for your business, such as fulfillment. After this point, the payment has been completed, and the user has been charged. If you can’t reach your server, it is important that you save the proof of payment and try again later.
View Sample Codes Here:
Steps for PayPal payment gateway integration in iOS
- Initialize the SDK and provide your Client IDs. A typical place to do this is in your app delegate’s didFinishLaunchingWithOptions: method
- Create a class (such as a subclass of UIViewController) that conforms to PayPalPaymentDelegate
- Create a PayPalConfiguration object (This object allows you to configure various aspects of the SDK)
- Establish environment and preconnect to PayPal’s servers. We recommend doing this when you first display the view controller from which your users might initiate payment. (Do not preconnect significantly earlier than that, as the connection has a limited lifetime.)
- Create a PayPalPayment with an amount, a currency code, short description, and intent (immediate sale vs. authorization/capture)
- Create and display a PayPalPaymentViewController with your PayPalPayment and PayPalConfiguration objects
- Write delegate methods to receive either the completed payment or a cancellation (These delegate methods are responsible for dismissing the modal view controller)
- Send the payment response to your servers for verification or capture, as well as any other processing required for your business, such as fulfillment (At this point, for an immediate payment, the payment has been completed and the user has been charged. For an authorization/capture payment, your server still must capture the payment to actually charge the user. If you can’t reach your server, it is important that you save the proof of payment and try again later)
View Sample Codes Here:
The steps mentioned above are only for payment gateway integration in Android and iOS PayPal Single payments through credit cards and PayPal account. If you are looking towards multiple payments, then you need to customize the code using the PayPal SDK.
Rishabh Software is a trusted solution provider in integrating mobile payments for native and multi-platform mobile app development.