cordova-paytm-allinonesdk
v1.2.1
Published
A starting point for all in one sdk
Downloads
85
Readme
Paytm All-in-One SDK ionic cordova
Paytm All-in-One SDK provides a swift, secure and seamless payment experience to your users by invoking the Paytm app (if installed on your user’s smartphone) to complete payment for your order.
Paytm All-in-One SDK enables payment acceptance via Paytm wallet, Paytm Payments Bank, saved Debit/Credit cards, Net Banking, BHIM UPI and EMI as available in your customer’s Paytm account. If Paytm app is not installed on a customer's device, the transaction will be processed via web view within the All-in-One SDK.
This Cordova plugin helps you to be able to use the All-in-One SDK with your ionic application. This plugin supports both Android and iOS.
Installation:
Step 1: Add the plugin in your ionic application with the following command.
ionic cordova plugin add cordova-paytm-allinonesdk
It is also possible to install the plugin via repo url directly
ionic cordova plugin add https://github.com/paytm/paytm-allinonesdk-ionic-cordova.git
Step 2: Add an ionic wrapper for All In One SDK.
npm install @ionic-native/all-in-one-sdk --save
For iOS:
Add iOS platform to you application.
ionic cordova platform add ios
This will create an iOS platform for your application at the following path: applicationName/platforms/ios/applicationName.xcworkspace
Make the following changes in your iOS project.
- In case merchant don’t have callback URL, Add an entry into Info.plist LSApplicationQueriesSchemes(Array) Item 0 (String)-> paytm
- Add a URL Scheme “paytm”+”MID”
Usage:
Add the plugin to your app's provider list
import { AllInOneSDK } from '@ionic-native/all-in-one-sdk/ngx'
@NgModule({
declarations: [...],
entryComponents: [...],
imports: [...],
providers: [..., AllInOneSDK],
bootstrap: [...]
})
export class AppModule {}
In your page from where you want to invoke the All-in-One SDK, add the following code:
import { AllInOneSDK } from '@ionic-native/all-in-one-sdk/ngx'
constructor(private allInOneSDK : AllInOneSDK) {}
//Call Initiate Transaction API from your backend to generate Transaction Token.
let paymentIntent = { mid : "<Merchant ID>",
orderId: "<Order ID>",
txnToken: "<Transaction Token generated by Initiate Transaction API from your backend>",
amount: "<Amount>",
isStaging: "<Environment(true/false)>",
callbackUrl: "<Callback URL>",
restrictAppInvoke: "<Restrict(true/false)>" };
// OR
//let paymentIntent = { mid : "<Merchant ID>",
// orderId: "<Order ID>",
// txnToken: "<Transaction Token generated by Initiate Transaction API from your backend>",
// amount: "<Amount>",
// isStaging: "<Environment(true/false)>",
// callbackUrl: "<Callback URL>",
// restrictAppInvoke: "<Restrict(true/false)>"
// enableAssist : <Restrict(true/false)>};
this.allInOneSDK.startTransaction(paymentIntent).then(
resp => {
// The response recieved after the transaction is completed will be an object containing `message` and `response`. You can parse both and use them as required in your application
if(resp.response != '')alert(JSON.parse(resp.response));
else alert(resp.message);
}).catch(error => {
alert(error);
})
All-In-One API & SDK reference
https://developer.paytm.com/docs/all-in-one-sdk/