react-native-phonepe-pg
A Plugin to integrate with React Native Platform for PhonePe Payment Solutions
Install
npm i react-native-phonepe-pg -f
npm i -f
API
init(...)
init(options: { environment: string; merchantId: string; flowId: string; enableLogging: boolean | false; }) => Promise<Record<string, boolean>>
This method is used to initiate PhonePe Payment sdk.
Provide all the information as requested by the method signature.
Params:
- environment: This signified the environment required for the payment sdk
possible values: SANDBOX, PRODUCTION
if any unknown value is provided, PRODUCTION will be considered as default.
- merchantId: The merchant id provided by PhonePe at the time of onboarding.
- flowId : An alphanumeric string without any special character. It acts as a common ID b/w
your app user journey and PhonePe SDK. This helps to debug prod issue.
Recommended - Pass user-specific information or merchant user-id to track the journey.
- enableLogging: If you want to enable / visualize sdk log @IOS
- enabled = TRUE
- disable = FALSE
- Return: Boolean (TRUE -> SUCCESS).
- SUCCESS: TRUE
- FAILURE: FALSE
- in iOS = False (if AppID missing:-Please provide PhonePe AppId)
- in Android = Error in case of invalid arguments ex: "Invalid environment or merchantId!"
Param | Type |
---|
options | { environment: string; merchantId: string; flowId: string; enableLogging: boolean; } |
Returns: Promise<Record<string, boolean>>
startTransaction(...)
startTransaction(options: { request: string; appSchema: string | null; }) => Promise<Record<string, string>>
This method is used to initiate PhonePe B2B PG Flow.
Provide all the information as requested by the method signature.
Params:
- request : The request body for the transaction as per the developer docs, Make sure the request body is base64encoded.
- appSchema: @Optional(Not need for Android) For iOS, Your custom URL Schemes, as per the developer docs.
Return: Will be returning a dictionary / hashMap
{
status: String, // string value to provide the status of the transaction
// possible values: SUCCESS, FAILURE, INTERRUPTED
error: String // if any error occurs
}
Param | Type |
---|
options | { request: string; appSchema: string | null; } |
Returns: Promise<Record<string, string>>
getUpiAppsForAndroid()
getUpiAppsForAndroid() => Promise<Record<string, string>>
This method is called to get list of upi apps in @Android only.
Return: String
JSON String -> List of UPI App with packageName, applicationName & versionCode
NOTE :- In iOS, it will throw os error at runtime.
Returns: Promise<Record<string, string>>
getUpiAppsForIos()
getUpiAppsForIos() => Promise<Record<string, string>>
This method is called to get list of upi apps in @iOS only.
Return: String
JSON String -> List of UPI App with applicationName that are installed in the device and supported by PhonePe SDK
NOTE :- In Android, it will throw os error at runtime.
Returns: Promise<Record<string, string>>
Type Aliases
Record
Construct a type with a set of properties K of type T
{
[P in K]: T;
}