1

我需要在我的 android 应用程序中集成 payU 支付网关。但是当应用程序试图获取哈希键时,它给了我一个错误说

缺少哈希参数

在演示应用程序中,有两个选项可以生成哈希

if(null == salt) 
        generateHashFromServer(mPaymentParams);
    else 
        generateHashFromSDK(mPaymentParams, intent.getStringExtra(PayuConstants.SALT));

在演示应用程序中有注释说哈希密钥生成应该在服务器端完成

所以我将盐作为空值传递

但现在的问题是我必须使用哪个服务器 url 来生成哈希?演示应用正在使用此网址 https://payu.herokuapp.com/get_hash

4

4 回答 4

0

您必须使用自己的服务器 URL 来生成哈希键。在 android 应用程序中,您必须设置 3 个强制散列键,否则您将收到错误“缺少强制散列键”。

确保您已将这 3 个键设置为 payuHashes 对象。

  1. payuHashes.setPaymentHash(response.getString("payment_hash"));
  2. payuHashes.setVasForMobileSdkHash(response.getString("vas_for_mobile_sdk_hash"));
  3. payuHashes.setPaymentRelatedDetailsForMobileSdkHash(response.getString("payment_related_details_for_mobile_sdk_hash"));

以下三个哈希是支付流程的强制哈希,需要在商户服务器生成: 1. 支付哈希是需要从商户服务器端生成的强制哈希之一。下面是生成payment_hash的公式 - sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||SALT)

  1. vas_for_mobile_sdk_hash 是需要从商家服务器端生成的强制哈希之一。下面是生成 vas_for_mobile_sdk_hash 的公式 -

sha512(key|command|var1|salt)
在这里,var1 将是“默认”

  1. payment_related_details_for_mobile_sdk_hash 是需要从商家服务器端生成的强制哈希之一。以下是生成 payment_related_details_for_mobile_sdk_hash 的公式 -

sha512(key|command|var1|salt) 在这里,var1 将是用户凭据。如果您不使用 user_credentials,则使用“default”。

从这里参考示例 sdk: https ://github.com/payu-intrepos/Android-SDK-Sample-App/releases/

对于服务器端代码,请参阅: https ://github.com/payu-intrepos/Documentations/wiki/4.-Server-Side

于 2017-07-10T10:35:01.197 回答
0

我通过很少的搜索得到了解决方案。

只需使用自己的服务器生成所有必需的哈希。在获得所有必需的哈希值后,我们需要使用这个哈希值来制作 PayuHashes Obj 并像这样传递这个 Obj

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 将负责休息

于 2015-09-10T11:14:41.170 回答
0

PayU money 不提供任何类型的 API,因此,人们使用 webview 代替。

于 2015-09-03T12:31:27.070 回答
0

我希望它对其他人有用我在下面的链接中找到了一个用于生成哈希的 php 脚本

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);

?>

复制 php 代码并编辑密钥和盐。

于 2017-09-29T18:28:55.607 回答