1.0.0 • Published 6 years ago

com.payu.custombrowser.react-native v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

PayU CustomBrowser React-Native Wrapper

Getting started

$ npm install com.payu.custombrowser.react-native --save

Mostly automatic installation

$ react-native link com.payu.custombrowser.react-native

Manual installation

Android

The following document focuses on React Native integration of CustomBrowser to know more about integrating CustomBrowser please visit below link https://github.com/payu-intrepos/Documentations/wiki/7.-Android-Custom-Browser

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.cbwrapper.CBPackage; to the imports at the top of the file
  • Add new CBPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':com.payu.custombrowser.react-native'
    project(':com.payu.custombrowser.react-native').projectDir = new File(rootProject.projectDir, 	'../node_modules/cb-wrapper/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
       compile project(':com.payu.custombrowser.react-native')
    	```
    ##Constants
Use below keys for setting various parameters of [CustomBrowserConfig](https://github.com/payu-intrepos/Documentations/wiki/7.-Android-Custom-Browser)
MERCHANT_SMS_PERMISSION(For Android M+): true if permission dialog is to be requested else false 
HTML_DATA: To pass html data to CustomBrowser for S2S calls
SURE_PAY_S2SURL: To pass html response hosted url to CustomBrowser for S2S calls
ENABLE_REVIEW_ORDER: To enable review order
REVIEW_ORDER_BUNDLE: Review order bundle
REVIEW_ORDER_BUTTON_TEXT: Review order button text
VIEW_PORT_WIDE_ENABLE: true if view port should be wide else false
AUTO_APPROVE: true if OTP should be auto approved else false
AUTO_SELECT_OTP: true if OTP should be auto selected else false
MAGIC_RETRY: true if Magic retry is enabled else false
REVIEW_ORDER_BUTTON_TEXT_COLOR: Review order button text color
REVIEW_ORDER_BUNDLE: Review order bundle in JSON format
GMS_PROVIDER_UPDATED_STATUS: If GMS changes are handled for api level 19
SURE_PAY_BACKGROUND_TTL: Surepay background ttl.
INTERNET_RESTORED_WINDOW_TTL: Internet restored timeout
MERCHANT_CHECKOUT_ACTIVITY_PATH: Full cannonical activity path to handle notification click event.
POST_URL: Post url
PAYU_POST_DATA: Post Data as passed to Custom Browser
SURE_PAY_MODE: Sure Pay Mode use among (SURE_PAY_WARN_MODE/SURE_PAY_FAIL_MODE)

Usage

import CBPackage from 'com.payu.custombrowser.react-native';
import {NativeModules} from 'react-native';
var postdata = "device_type=1 & udid=d30128ce3b0b500f&imei=default&key="+merchantKey<YOUR_POST_DATA_HERE>

const params = {
         NativeModules.CbWrapper.PAYU_POST_DATA : postdata.toString(),
         NativeModules.CbWrapper.POST_URL : "https://secure.payu.in/_payment",
         NativeModules.CbWrapper.VIEW_PORT_WIDE_ENABLE : true,
         NativeModules.CbWrapper.AUTO_APPROVE : true,
         NativeModules.CbWrapper.TRANSACTION_ID : txnid,
         NativeModules.CbWrapper.MERCHANT_KEY : merchantKey,
         NativeModules.CbWrapper.MAGIC_RETRY : true,
         NativeModules.CbWrapper.ENABLE_SURE_PAY : 0,
         NativeModules.CbWrapper.SURE_PAY_MODE : NativeModules.CBWrapper.SURE_PAY_WARN_MODE,

      };
NativeModules.CBWrapper.startPayment(params).then(response => {
        Alert.alert(response);
        }).catch(error =>   Alert.alert(error));
        }}

Response

Response Format:


 {
 "PAYMENT_STATUS":"SUCCESS PAYMENT"[Values among [SUCCESS PAYMENT/PAYMENT_CANCELLED/FAILURE_PAYMENT]],
 "PAYU_RESPONSE":"{\"id\":403993715511825499,\"mode\":\"CC\",\"status\":\"success\",...}",
 "MERCHANT_RESPONSE":"{\"id\":403993715511825499,\"mode\":\"CC\",\"status\":\"success\",...}"
 }