如何解决Cashfree付款网关签名错配错误?

问题描述

我已经尝试了多种方法,并且还推荐了他们的文档来解决此签名不匹配错误。我已经在生成校验和的JAVA代码下面附加了代码。我从他们的“无缝专业”集成文档中复制了此逻辑。

    Map<String,String> postData = new HashMap<String,String>();

    postData.put("appId",cashfreeAppId);
    postData.put("orderId",orderId);
    postData.put("orderAmount",orderAmount.toString());
    postData.put("orderCurrency",orderCurrency);
    postData.put("orderNote",orderNote);
    postData.put("customerName",customerName);
    postData.put("customerEmail",customerEmail);
    postData.put("customerPhone",customerPhone);
    postData.put("returnUrl",returnUrl);
    postData.put("notifyUrl",notifyUrl);
    
    String data = "";
    SortedSet<String> keys = new TreeSet<String>(postData.keySet());

    for (String key : keys) {
        data = data + key + postData.get(key);
    }

    Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
    SecretKeySpec secret_key_spec = new SecretKeySpec(cashfreeSecretkey.getBytes(),"HmacSHA256");
    sha256_HMAC.init(secret_key_spec);

    return Base64.getEncoder().encodeToString(sha256_HMAC.doFinal(data.getBytes()));

如果有人拥有此校验和生成的有效示例,请提供代码段。

解决方法

如果您使用的是无缝专业集成,请确保在生成签名时使用完整的请求参数,即付款方式和其他详细信息。

,

我在集成 Cashfree 时遇到了类似的问题。 您可以确保验证以下几点:

  1. 您可以访问以下链接 https://docs.cashfree.com/docs/checksum/ 并尝试为一组特定值生成校验和。然后看看这里生成的签名是否和你生成的一样。
  2. 如果签名不匹配,那么您的签名生成逻辑有问题。您可以前往 https://github.com/cashfree,因为有许多包含签名逻辑的集成工具包可用。
  3. 如果签名匹配,请检查所有参数是否都正确传递给 cashfree。

希望这对你有用。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...