@mogi/react-native-payumoney
v0.0.2
Published
React native wrapper for payumoney sdk
Downloads
3
Readme
[Note]: Archiving in favour of official sdk and lack of time to maintain, see #63
react-native-payumoney
Installation
If Upgrading from 0.0.3
Make sure to remove existing package first.
Install package:
$ npm i @mogi/react-native-payumoney --save
Only For RN <= 0.59
$ react-native link @mogi/react-native-payumoney
Add following line in Podfile
pod 'PayUmoney_PnP'
Then, run the following command:
$ pod install
RN >= 0.60
No need to do anything
Making Payment Request
Import PayuMoney module to your component:
import PayuMoney from 'react-native-payumoney';
Call
PayuMoney()
method with the paymentoptions
. Method returns a Promise
const payData = {
amount: '10.0',
txnId: '1594976828726',
productName: 'product_info',
firstName: 'firstname',
email: '[email protected]',
phone: '9639999999',
merchantId: '5960507',
key: 'QylhKRVd',
successUrl: 'https://www.payumoney.com/mobileapp/payumoney/success.php',
failedUrl: 'https://www.payumoney.com/mobileapp/payumoney/failure.php',
isDebug: true,
hash:
'461d4002c1432b3393cf2bfaae7acc4c50601c66568fb49a4a125e060c3bfc0e489290e7c902750d5db3fc8be2f180daf4d534d7b9bef46fa0158a4c8a057b61',
}
Payumoney(payData).then((data) => {
// Payment Success
console.log(data)
}).catch((e) => {
// Payment Failed
console.log(e)
})
Validating Hash
Don't use in production just for testing purpose
import {HashGenerator} from 'react-native-payumoney';
HashGenerator({
key: "QylhKRVd",
amount: "10.0",
email: "[email protected]",
txnId: "1594976828726",
productName: "product_info",
firstName: "firstname",
salt: "seVTUgzrgE",
})
// output: 461d4002c1432b3393cf2bfaae7acc4c50601c66568fb49a4a125e060c3bfc0e489290e7c902750d5db3fc8be2f180daf4d534d7b9bef46fa0158a4c8a057b61
Server side function to get Hash Key
function makeHash($key, $txnid, $amount, $productinfo, $firstname, $email){
$salt = "XXXXXX"; //Please change the value with the live salt for production environment
$payhash_str = $key . '|' . checkNull($txnid) . '|' . checkNull($amount) . '|' . checkNull($productinfo) . '|' . checkNull($firstname) . '|' . checkNull($email) . '|||||||||||' . $salt;
$hash = strtolower(hash('sha512', $payhash_str));
return $hash;
}
function checkNull($value)
{
if ($value == null) {
return '';
} else {
return $value;
}
}
Troubleshooting
{ success: 0 } or { success: false }
This is very common error, when your server side hash is calculated in-correctly or
when trying to use Web Merchant KEY + SALT on sandbox in Android
Please use Following KEY, SALT, MERCHANT ID generated by PayU for sandbox usage
Or you can always ask them for new pair of KEY & SLAT for Android usage
MID : 5960507
Key : QylhKRVd
Salt : seVTUgzrgE
Below is the test card details for doing a test transaction in the testing mode.
Card No - 4242 4242 4242 4242
Expiry - 22/2222 // any date in future
CVV - 999 // any 3 digits
Name - Test // anything
Merchant Key missing in release mode
Edit android/app/proguard-rules.pro
and add
-keep class com.surajtiwari.reactnativepayumoney.** { *; }
see issue #43
Could not find com.payumoney.sdkui:plug-n-play:1.6.1.
Add jcenter()
in your android/build.gradle
see example
Running example
1. Install dependencies
$ cd ./example && npm install
2. Run it on Android
$ cd ./example && npm run android