如何为PayUMoney android生成Live哈希密钥

时间:2017-08-09 09:52:15

标签: android payumoney

我正在尝试在我的应用程序中集成PayUmoney android SDK,我成功集成但我面临一个问题。

在测试模式下,他们提供url来生成hask密钥但是他们不会提供

测试模式:https://test.payumoney.com/payment/op/calculateHashForTest

对于实时模式:???

i am trying below Code to generate  Live Hash key 

   String salt="saltkey";
            String hashSequence=key+"|"+txnid+"|"+amount+"|"+productinfo+"|"

+firstname+"|"+email+"|"+""+"|"+"|"+""+"|"+""+"|"+""+"|"+salt;

            String serverCalculatedHash= hashCal("SHA-512", hashSequence);
            paymentParam.setMerchantHash(serverCalculatedHash);
            PayUmoneySdkInitilizer.startPaymentActivityForResult((Activity) 
context, paymentParam);  

  BUt i got  below response from sdk

 {"status":-1,"message":"key is not valid","result":null,"errorCode":null,"responseCode":null}

{"status":-1,"message":"payment status for :1111322345","result":"PP1 not updated till now from P2","errorCode":null,"responseCode":null}


 please give solution to:
1. generate live hash key using url,  
2.why above mention response return from PayUMoney SDk

Expecting your valuble answer.

2 个答案:

答案 0 :(得分:0)

您可以使用此功能为PayUMoney android

生成实时哈希密钥
 public static String hashCal(String type, String str) {
        byte[] hashseq = str.getBytes();
        StringBuffer hexString = new StringBuffer();
        try {
            MessageDigest algorithm = MessageDigest.getInstance(type);
            algorithm.reset();
            algorithm.update(hashseq);
            byte messageDigest[] = algorithm.digest();
            for (int i = 0; i<messageDigest.length; i++) {
                String hex = Integer.toHexString(0xFF &messageDigest[i]);
                if (hex.length() == 1) {
                    hexString.append("0");
                }
                hexString.append(hex);
            }
        } catch (NoSuchAlgorithmException nsae) {

        }
        return hexString.toString();
    }

并打电话给

  String serverCalculatedHash = hashCal("SHA-512",MERCHANT_KEY+"|"+txnId+"|"+Double.parseDouble(totalPrices)+"|"+productName+"|"
                +userName+"|"+userEmail+"|"+udf1+"|"+udf2+"|"+udf3+"|"+udf4+"|"+udf5+"|"+MERCHANT_SALT);

serverCalculatedHash包含PayUMoney的哈希键

答案 1 :(得分:0)

在“集成凭据”中检查您的payu仪表板:可以使用商户密钥和商户盐。

还要检查.setIsDebug(true)//对于集成环境-true,对于生产环境-false。

您指定了哈希 字符串hashSequence = key +“ |” + txnid +“ |” + amount +“ |” + productinfo +“ |” + firstname +“ |” + email +“ |” +“” +“ |” +“ |” +“” +“ |” +“” +“ |” +“” +“ |” +盐;

应该是:

hashSequence = key +“ |” + txnid +“ |” +金额+“ |” + productinfo +“ |” +名字+“ |” +电子邮件+“ |” + udf1 +“ |” + udf2 +“ |” + udf3 +“ |” + udf4 +“ |” + udf5 +“ |” + udf6 +“ |” + udf7 +“ |” + udf8 +“ |” + udf9 +“ |” + udf10 +“ |” + salt;

用户定义字符串可以为空,但必须以哈希顺序传递。