【问题标题】:Checksum Failed in payumoney in Django?校验和在 Django 中支付失败?
【发布时间】:2019-08-26 03:17:19
【问题描述】:

我已经按照文档https://developer.payumoney.com/redirect/实现了

但我收到错误校验和失败,我正在使用沙盒测试 url

view.py

import hashlib
from random import randint

from django.shortcuts import render


def Home(request):
    MERCHANT_KEY = "KeytCX7l"
    key = "keytCX7l"
    SALT = "salt2TuHze"
    PAYU_BASE_URL = "https://sandboxsecure.payu.in/_payment"
    posted = {}
    # Merchant Key and Salt provided y the PayU.
    for i in request.POST:
        posted[i] = request.POST[i]
    hash_object = hashlib.sha256(str(randint(0,20)).encode('utf-8'))
    txnid = hash_object.hexdigest()[0:20]
    posted['txnid'] = "b17ef6d19c7a5b1ee83b"
    posted['amount'] =  10.00
    posted['firstname'] = "Ravi"
    posted['email'] = "ravibhushan29@gmail.com"
    # posted['phone'] = "70007240543"
    posted["productinfo"] = "new product"
    hashSequence = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5"
    posted['key'] = key

    hash_string = ''
    hashVarsSeq = hashSequence.split('|')
    for i in hashVarsSeq:
        try:
            hash_string += str(posted[i])
        except Exception:
            hash_string += ''
        hash_string += '|'

    hash_string += SALT
    hashh = hashlib.sha512(hash_string.encode('utf-8')).hexdigest().lower()
    return render(request, 'payment.html', {"posted": posted, "hash": hashh,
                                                    "MERCHANT_KEY": MERCHANT_KEY,
                                                    "txnid": txnid,
                                                    "hash_string": hash_string,
                                                    "action": PAYU_BASE_URL})

根据 payumoney 的文档,我有传递值,我检查了 hash 和 hash_sequence 是否与以下内容相同:

hashSequence = key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|||||salt.

payment.html

<html>
  <head onload="submitPayuForm()">
  <script type="text/javascript">
    var hash = "{{ hashh }}";
    function submitPayuForm() {
      if(hash =='') {
        return;
      }
      var payuForm = document.forms.payuForm;
      payuForm.submit();
    }
  </script>
  </head>
  <body>
    <h2>PayU Form</h2>
    <br/>
    {% if error %}

      <span style="color:red">Please fill all mandatory fields.</span>
      <br/>
      <br/>
      {% endif %}

      <form action={{ action }} method="post" name="payuForm">{% csrf_token %}
      <input type="hidden" name="key" value="{{ MERCHANT_KEY }}" />
      <input type="hidden" name="hash_string" value="{{ hash_string }}" />
      <input type="hidden" name="hash" value="{{ hash }}"/>
       <input type="hidden" name="posted" value="{{ posted }}"/>
      <input type="hidden" name="txnid" value="{{ txnid }}" />
      <table>
        <tr>
          <td><b>Mandatory Parameters</b></td>
        </tr>
        <tr>
         <td>Amount: </td>
          <td><input name="amount" value="{{ posted.amount }}" /></td>
          <td>First Name: </td>
          <td><input name="firstname" id="firstname" value="{{ posted.firstname|default:'' }}" /></td>
        </tr>
        <tr>
          <td>Email: </td>
          <td><input name="email" id="email" value="{{ posted.email|default:'' }}" /></td>
        </tr>
        <tr>
          <td>Product Info: </td>
          <td colspan="3"><textarea name="productinfo">{{ posted.productinfo|default:'' }}</textarea></td>
        </tr>
        <tr>
          <td>Success URI: </td>
          <td colspan="3"><input name="surl" value="http://127.0.0.1:8000/Success/" size="64" /></td>
        </tr>
        <tr>
          <td>Failure URI: </td>
          <td colspan="3"><input name="furl" value="http://127.0.0.1:8000/Failure/" size="64" /></td>
        </tr>

        <tr>
          <td colspan="3"><input type="hidden" name="service_provider" value="payu_paisa" size="64" /></td>
        </tr>
             <tr>

     <td colspan="4"><input type="submit" value="Submit" /></td>

        </tr>
      </table>
    </form>
  </body>
</html>

请帮忙找出我犯错的地方

【问题讨论】:

  • livetest payu setup 是否发生错误
  • 在测试支付设置中

标签: django payment-gateway payumoney


【解决方案1】:

对于 payu 测试,请使用此凭据

def Home(request):
    key = "gtKFFx"
    SALT = "eCwWELxi"
    PAYU_BASE_URL = "https://test.payu.in/_payment'"

希望对你有帮助

更多详情请参考this

【讨论】:

  • 我已经发布了 dummy MERCHANT_KEY,并且 key 和 salt,根据 doc test url test.payu.in/_payment 更改为 sandboxsecure.payu.in/_payment
  • 用户 gtKFFx 作为 MERCHANT_KEY 进行 payu 测试
  • 不,现在更改商户密钥和盐后,我收到错误对不起,发生了一些问题
  • 有没有人得到解决方案我仍然得到“抱歉,出现了一些问题。”目前我正在使用测试凭据 key = "gtKFFx" SALT = "eCwWELxi"
【解决方案2】:

首先你不需要在视图中传递任何值,就像你传递给张贴[] 字段一样。 其次,确保您已在 payumoney 个人资料中切换到测试模式。您可以使用此模式下可用的凭据。 最后确保当您的表单呈现在您身上时,您填写了所有必需的详细信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-26
    • 2018-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-05
    相关资源
    最近更新 更多