react-native-pg-react-native-sdk
Getting started
$ npm install react-native-pg-react-native-sdk --save
or
$ yarn add react-native-pg-react-native-sdk --save
In case of Manual linking
$ react-native link react-native-pg-react-native-sdk
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜ Add Files to [your project's name]
- Go to
node_modules
➜ react-native-pg-react-native-sdk
and add RNPgReactNativeSdkBridge.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNPgReactNativeSdk.a
to your project's Build Phases
➜ Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNPgReactNativeSdkPackage;
to the imports at the top of the file
- Add
new RNPgReactNativeSdkPackage()
to the list returned by the getPackages()
method
- Append the following lines to
android/settings.gradle
:
include ':react-native-pg-react-native-sdk'
project(':react-native-pg-react-native-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pg-react-native-sdk/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:
compile project(':react-native-pg-react-native-sdk')
Usage
import RNPgReactNativeSdk from 'react-native-pg-react-native-sdk';
/**
* Starts Cashfree's Web Checkout Flow
* @param params A map of <String, String> containing payment params.
* @param env A String value describing environment of the payment('TEST' or 'PROD').
* @param callback A callback to return back the result.
*/
RNPgReactNativeSdk.startPaymentWEB(params: Map<string, string>, env: string, callback: (responseJson: string) => void)
/**
* Starts Cashfree's UPI Payment Flow
* @param params A map of <String, String> containing payment params.
* @param env A String value describing environment of the payment('TEST' or 'PROD').
* @param callback A callback to return back the result.
*/
RNPgReactNativeSdk.startPaymentUPI(params: Map<string, string>, env: string, callback: (responseJson: string) => void)
/**
* Starts Cashfree's Web Checkout Flow
* @return A promise with a result as a JSON array containing upi apps installed in user device.
* @example [
{
“displayName”: “Gpay”,
“id”: “com.google.android.apps.nbu.paisa.user”,
“icon”: “iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAAAXNSR0IArs4c6QAA... (in base64)”
},
{
“displayName”: “PHONEPE”,
“id”: “com.phonepe.app”,
“icon”: “iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAAAXNSR0IArs4c6QAA... (in base64)”
}
]
* NOTE: the "icon" in the JSON is a base64 encoded icon string.
* Use this function in conjunction with 'startPaymentUPI' and add the key as 'appName' in the params with the value as
* 'id' to initiate a Seamless UPI flow.
*/
RNPgReactNativeSdk.getUPIApps()
/**
* @param icon value of a app icon from method 'getUPIApps'
* @return a string of icon which can be used directly to set a image source.
*/
RNPgReactNativeSdk.getIconString(icon: String)