paytm_allinone_react-native
v1.2.3
Published
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.
Downloads
1,793
Readme
paytm_allinone_react-native
This plugin exposes a single method to perform any transaction
Installation
npm install paytm_allinone_react-native --save
npx react-native link
Usage
startTransaction(
orderId: string,
mid: string,
txnToken: string,
amount: string,
callbackUrl: string,
isStaging: boolean,
restrictAppInvoke: boolean
): Promise<any>;
Configuration
Android
- Add the below line to the ‘repositories’ section of your project-level build.gradle file as below
allprojects {
repositories {
google()
.
.
maven {
url "https://artifactory.paytm.in/libs-release-local"
}
}
}
iOS
1: Open Podfile and Update Platform Version Navigate to the ios folder and open Podfile. You can do this using the following code. $ cd ios && open podfile.
2: Install Pods Using Cocoapods Install pods after updating iOS platform. : pod install && cd .. 3. Add the following in ios project. Open the projectName.workspace in ios folder. Open Info.plist : Add LSApplicationQueriesSchemes. Change its type to Array. Create a new item in it and set its value as "paytm"
Go to Info tab -> URL Types : Add a new URL Type that you’ll be using as the callback from Paytm App (URL Scheme: "paytm"+"MID"). Example: paytmMid123
Open AppDelegate.m: Add following method before the end of the file ended by @end Open AppDelegate.m and Import LinkingManager to the top of the file which has delegate methods for implementing and handling URLScheme(response from Paytm invoke will be received here in this method. Which in turns notifies the Plugin.)
#import <React/RCTLinkingManager.h>
(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
NSString *urlString = url.absoluteString; NSDictionary *userInfo = [NSDictionary dictionaryWithObject:urlString forKey:@"appInvokeNotificationKey"]; [[NSNotificationCenter defaultCenter] postNotificationName: @"appInvokeNotification" object:nil userInfo:userInfo]; return [RCTLinkingManager application:app openURL:url options:options]; }
Usage
- Import top-level package
import AllInOneSDKManager from 'paytm_allinone_react-native';
- Call the startTransaction api
AllInOneSDKManager.startTransaction(
orderId,
mid,
tranxToken,
amount,
callbackUrl,
isStaging,
appInvokeRestricted,
)
.then((result) => {
console.log("result", result);
updateUI(result);
})
.catch((err) => {
handleError(err);
});
For more details, please visit
https://developer.paytm.com/docs/all-in-one-sdk/
License
MIT