This library has been forked from https://github.com/elanic-tech/react-native-paytm Updated it to work with the latest version of react-native and latest PayTM SDK. Improved the documentaion as well.
Alert: Built and tested only for iOS.
react-native link react-native-paytm- In XCode, in the project navigator, right click
Libraries➜Add Files to [your project's name] - Go to
node_modules➜react-native-paytmand addRNPayTm.xcodeproj - In XCode, in the project navigator, select your project. Add
libRNPayTm.ato your project'sBuild Phases➜Link Binary With Libraries - Run your project (
Cmd+R)<
importpaytmfrom'react-native-paytm';import{ ...,Platform,DeviceEventEmitter,NativeModules,NativeEventEmitter, ... }from'react-native';
....// Daat received from PayTMconstpaytmConfig={MID: '...',WEBSITE: '...',CHANNEL_ID: '...',INDUSTRY_TYPE_ID: '...',CALLBACK_URL: 'https://securegw.paytm.in/theia/paytmCallback?ORDER_ID='}componentWillMount(){
...
if(Platform.OS=='ios'){const{ RNPayTm }=NativeModulesconstemitter=newNativeEventEmitter(RNPayTm)emitter.addListener('PayTMResponse',this.onPayTmResponse)}else{DeviceEventEmitter.addListener('PayTMResponse',this.onPayTmResponse)}
...
}onPayTmResponse(response){// Process Response// response.response in case of iOS// reponse in case of Androidconsole.log(response);}runTransaction(amount,customerId,orderId,mobile,email,checkSum){constcallbackUrl=`${paytmConfig.CALLBACK_URL}${orderId}`;constdetails={mode: 'Staging',// 'Staging' or 'Production'mid: paytmConfig.MID,industryType: paytmConfig.INDUSTRY_TYPE_ID,website: paytmConfig.WEBSITE,channel: paytmConfig.CHANNEL_ID,amount: `${amount}`,// StringorderId: orderId,// Stringemail: email,// Stringphone: mobile,// StringcustId: customerId,// Stringchecksumhash: checkSum,//From your server using PayTM Checksum Utility callback: callbackUrl};paytm.startPayment(details);}