I need to integrate payU payment gateway in my android app. But when app is trying to to get hash key it gives me error saying that
Hash param is missing
In de
You have to use your own server URL to generate hash keys. In android app there are 3 mandatory hash keys you have to set else you will get error "mandatory hash key is missing".
Make sure you have set this 3 keys to payuHashes object.
Below three hashes are mandatory for payment flow and needs to be generated at merchant server: 1. Payment hash is one of the mandatory hashes that needs to be generated from merchant's server side. Below is formula for generating payment_hash - sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||SALT)
sha512(key|command|var1|salt)
here, var1 will be "default"
sha512(key|command|var1|salt) here, var1 will be user credentials. If you are not using user_credentials then use "default".
Refer sample sdk from here: https://github.com/payu-intrepos/Android-SDK-Sample-App/releases/
For server side code refer this: https://github.com/payu-intrepos/Documentations/wiki/4.-Server-Side
i hope its useful to others i found a php script for generating hash in below link
https://docs.google.com/document/d/1wby1TStudKuOtIRmUIc3ZqDVOg20mks8q5mT40i60qw/edit
<?php
function getHashes($txnid, $amount, $productinfo, $firstname, $email, $user_credentials, $udf1, $udf2, $udf3, $udf4, $udf5,$offerKey,$cardBin)
{
// $firstname, $email can be "", i.e empty string if needed. Same should be sent to PayU server (in request params) also.
$key = 'XXXXXX';
$salt = 'YYYYY';
$payhash_str = $key . '|' . checkNull($txnid) . '|' .checkNull($amount) . '|' .checkNull($productinfo) . '|' . checkNull($firstname) . '|' . checkNull($email) . '|' . checkNull($udf1) . '|' . checkNull($udf2) . '|' . checkNull($udf3) . '|' . checkNull($udf4) . '|' . checkNull($udf5) . '||||||' . $salt;
$paymentHash = strtolower(hash('sha512', $payhash_str));
$arr['payment_hash'] = $paymentHash;
$cmnNameMerchantCodes = 'get_merchant_ibibo_codes';
$merchantCodesHash_str = $key . '|' . $cmnNameMerchantCodes . '|default|' . $salt ;
$merchantCodesHash = strtolower(hash('sha512', $merchantCodesHash_str));
$arr['get_merchant_ibibo_codes_hash'] = $merchantCodesHash;
$cmnMobileSdk = 'vas_for_mobile_sdk';
$mobileSdk_str = $key . '|' . $cmnMobileSdk . '|default|' . $salt;
$mobileSdk = strtolower(hash('sha512', $mobileSdk_str));
$arr['vas_for_mobile_sdk_hash'] = $mobileSdk;
// added code for EMI hash
$cmnEmiAmountAccordingToInterest= 'getEmiAmountAccordingToInterest';
$emi_str = $key . '|' . $cmnEmiAmountAccordingToInterest . '|'.checkNull($amount).'|' . $salt;
$mobileEmiString = strtolower(hash('sha512', $emi_str));
$arr['emi_hash'] = $mobileEmiString;
$cmnPaymentRelatedDetailsForMobileSdk1 = 'payment_related_details_for_mobile_sdk';
$detailsForMobileSdk_str1 = $key . '|' . $cmnPaymentRelatedDetailsForMobileSdk1 . '|default|' . $salt ;
$detailsForMobileSdk1 = strtolower(hash('sha512', $detailsForMobileSdk_str1));
$arr['payment_related_details_for_mobile_sdk_hash'] = $detailsForMobileSdk1;
//used for verifying payment(optional)
$cmnVerifyPayment = 'verify_payment';
$verifyPayment_str = $key . '|' . $cmnVerifyPayment . '|'.$txnid .'|' . $salt;
$verifyPayment = strtolower(hash('sha512', $verifyPayment_str));
$arr['verify_payment_hash'] = $verifyPayment;
if($user_credentials != NULL && $user_credentials != '')
{
$cmnNameDeleteCard = 'delete_user_card';
$deleteHash_str = $key . '|' . $cmnNameDeleteCard . '|' . $user_credentials . '|' . $salt ;
$deleteHash = strtolower(hash('sha512', $deleteHash_str));
$arr['delete_user_card_hash'] = $deleteHash;
$cmnNameGetUserCard = 'get_user_cards';
$getUserCardHash_str = $key . '|' . $cmnNameGetUserCard . '|' . $user_credentials . '|' . $salt ;
$getUserCardHash = strtolower(hash('sha512', $getUserCardHash_str));
$arr['get_user_cards_hash'] = $getUserCardHash;
$cmnNameEditUserCard = 'edit_user_card';
$editUserCardHash_str = $key . '|' . $cmnNameEditUserCard . '|' . $user_credentials . '|' . $salt ;
$editUserCardHash = strtolower(hash('sha512', $editUserCardHash_str));
$arr['edit_user_card_hash'] = $editUserCardHash;
$cmnNameSaveUserCard = 'save_user_card';
$saveUserCardHash_str = $key . '|' . $cmnNameSaveUserCard . '|' . $user_credentials . '|' . $salt ;
$saveUserCardHash = strtolower(hash('sha512', $saveUserCardHash_str));
$arr['save_user_card_hash'] = $saveUserCardHash;
$cmnPaymentRelatedDetailsForMobileSdk = 'payment_related_details_for_mobile_sdk';
$detailsForMobileSdk_str = $key . '|' . $cmnPaymentRelatedDetailsForMobileSdk . '|' . $user_credentials . '|' . $salt ;
$detailsForMobileSdk = strtolower(hash('sha512', $detailsForMobileSdk_str));
$arr['payment_related_details_for_mobile_sdk_hash'] = $detailsForMobileSdk;
}
// if($udf3!=NULL && !empty($udf3)){
$cmnSend_Sms='send_sms';
$sendsms_str=$key . '|' . $cmnSend_Sms . '|' . $udf3 . '|' . $salt;
$send_sms = strtolower(hash('sha512',$sendsms_str));
$arr['send_sms_hash']=$send_sms;
// }
if ($offerKey!=NULL && !empty($offerKey)) {
$cmnCheckOfferStatus = 'check_offer_status';
$checkOfferStatus_str = $key . '|' . $cmnCheckOfferStatus . '|' . $offerKey . '|' . $salt ;
$checkOfferStatus = strtolower(hash('sha512', $checkOfferStatus_str));
$arr['check_offer_status_hash']=$checkOfferStatus;
}
if ($cardBin!=NULL && !empty($cardBin)) {
$cmnCheckIsDomestic = 'check_isDomestic';
$checkIsDomestic_str = $key . '|' . $cmnCheckIsDomestic . '|' . $cardBin . '|' . $salt ;
$checkIsDomestic = strtolower(hash('sha512', $checkIsDomestic_str));
$arr['check_isDomestic_hash']=$checkIsDomestic;
}
return $arr;
}
function checkNull($value) {
if ($value == null) {
return '';
} else {
return $value;
}
}
$output=getHashes($_POST["txnid"], $_POST["amount"], $_POST["productinfo"], $_POST["firstname"], $_POST["email"], $_POST["user_credentials"], $_POST["udf1"], $_POST["udf2"], $_POST["udf3"], $_POST["udf4"], $_POST["udf5"],$_POST["offerKey"],$_POST["cardBin"]);
echo json_encode($output);
?>
copy the php code and edit key and salt.
I got solution by doing little search.
Just generate all required hashes using own server. After getting all required hashes we need to make PayuHashes Obj using this hashes and pass this Obj in intent like this
Intent intent= new Intent(this, PayUBaseActivity.class);
intent.putExtra(PayuConstants.PAYU_CONFIG, payuConfig);
intent.putExtra(PayuConstants.PAYMENT_PARAMS, mPaymentParams);
intent.putExtra(PayuConstants.PAYU_HASHES, payuHashes);
intent.putExtra(PayuConstants.SALT, salt);
PayU SDK will take care of rest
PayU money doesn't give any kind of API, So, people use a webview instead.