Paytm SDK Integration in iOS
Paytm SDK provides a secure and seamless payment experience to the users by invoking the Paytm app (if installed on your user's smartphone) to finish the order.
It facilitates the users to accept payment by using Paytm Wallet, Paytm Payments Bank, Saved Debit/Credit Cards (if any), Net Banking, BHIM UPI, or EMI in the customer's Paytm account. If the Paytm app is not installed on a user's device, the transaction will be processed using web view within the SDK.
Paytm SDK provides the following features.
- OTP-based account linking is not required in case a user is already logged into the Paytm app.
- We don't get redirected to the web page for the payment if the Paytm app is installed on the user's device.
- Users can access the payment sources saved by Paytm.
- It reduces transaction time due to no login requirement.
- Increased the success rate
- Easy integration of SDK with significantly less size
- Support for subscription payments and bank offers
- SDK support for both Native and Hybrid apps
- Supports UPI onboarding if a user wants to link its UPI account for payment
- Complete flexibility with merchants to present single or multiple payments sources to the user on the Paytm app
Overview of payment through Paytm SDK
There are the following steps that are followed by Paytm SDK to complete the payment.
- First of all, the user opens the mobile application and adds items in the cart for which the payment is to be done.
- The Initiate Transaction API gets called by the backend server to get the transaction token.
- Launch Paytm SDK with the transaction token received in step 1.
- If the Paytm app is installed on the user's device, they complete the payment on the Paytm app using their login credentials; else, the transaction will be done using the web view within the SDK (the redirection flow is hosted by Paytm).
- Paytm backend server processes the transaction and returns the transaction response to the app.
- Then, the backend server calls the Transaction Status API for the verification of transaction response.
- After the successful validation of the transaction, the order status will be shown to the app's user.
SDK integration for an All-in-One payment solution facilitates us to integrate the SDK in the applications for both Android and iOS apps. The integration facilitates the customers to make secure payments with Paytm despite the fact that the Paytm app is installed on the device or not.
There are the following flows supported by the Paytm SDK.
- App Invoke Flow: if the Paytm app is installed on the device, it will be launched to finish the transaction and provide the response back to the merchant app.
- Redirection Flow: if the Paytm app is not installed on the device, SDK will launch a web-view to complete the transaction and give the result back to the merchant.
There are the following perquisites before initiating the transaction.
- Create an account on Paytm as a merchant
- Get the merchant ID and merchant key for the integration environment once we create the account.
- Use the checksum logic to generate and validate the checksum.
- Get the staging iOS Paytm app for integration testing on the merchant staging environment.
1. We need to call the Initiate Transaction API from the backend to generate the Transaction Token. If we want to allow/show specific payment sources, we need to pass the enablePaymode param in the Initiate Transaction API, as shown below. This feature enables us to create a cart payment page with multiple payment sources.
For Example, if we want to enable UPI as the only pay mode, we need to pass the below parameters within Initiate Transaction API.
2. Call the openPaytm method with the following mandatory parameters.
3. Delegate is a type of AIDelegate which have two protocols.
4. In case the Paytm app is not installed, redirect the user to Paytm hosted Checkout Page.
- An order is created in your order system, and the transaction token is also generated using Initiate Transaction API.
- In case the Paytm app does not exist, then the user has to implement delegate methods of AIDelegate. openPaymentWebVC will provide the merchant with the controller to present/push, which handles the Paytm hosted checkout page as described below.
5. In case the merchant doesn't have a callback URL, add an entry into Info.plist. LSApplicationQueriesSchemes(Array) Item 0 (String)->paytm.
- Add a URL Scheme "paytm"+"MID".
- Define the app delegate method to handle Paytm response. The client will get the response in Appdelegate Method.