[Note]: Archiving in favour of official sdk and lack of time to maintain, see #63
Make sure to remove existing package first.
Install package:
$ npm i react-native-payumoney --save
$ react-native link react-native-payumoney
Add following line in Podfile
pod 'PayUmoney_PnP'
Then, run the following command:
$ pod install
No need to do anything
Import PayuMoney module to your component:
import PayuMoney from 'react-native-payumoney';
Call PayuMoney()
method with the payment options
. Method
returns a Promise
const payData = {
amount: '10.0',
txnId: '1594976828726',
productName: 'product_info',
firstName: 'firstname',
email: 'xyz@gmail.com',
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
```js
import {HashGenerator} from 'react-native-payumoney';
HashGenerator({
key: "QylhKRVd",
amount: "10.0",
email: "xyz@gmail.com",
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;
}
}
{ 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
Edit android/app/proguard-rules.pro
and add
-keep class com.surajtiwari.reactnativepayumoney.** { *; }
see issue #43
Add jcenter()
in your android/build.gradle
see example
$ cd ./example && npm install
$ cd ./example && npm run android