1.0.0 • Published 7 months ago

cordova-paytmpayments-allinonesdk v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

Paytm Payments All-in-One SDK ionic cordova

Paytm Payments 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.

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-paytmpayments-allinonesdk

Step 2: Add an ionic wrapper for All In One SDK. npm install @awesome-cordova-plugins/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.

  1. In case merchant don’t have callback URL, Add an entry into Info.plist LSApplicationQueriesSchemes(Array) Item 0 (String)-> paytm

info.plist

  1. Add a URL Scheme “paytm”+”MID” urlScheme

Usage:

Add the plugin to your app's provider list

import { AllInOneSDK } from '@awesome-cordova-plugins/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 '@awesome-cordova-plugins/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/