Как решить контрольную сумму не удалось в Django с интеграцией платежей PayU? - PullRequest
0 голосов
/ 03 февраля 2020

Я отправляю все обязательные поля платежному шлюзу Payu, но при этом отображается ошибка с контрольной суммой, как я могу решить эту проблему.

В django я добавляю интеграцию платежного шлюза Payu с использованием paywix библиотека и отправка всех обязательных полей в платежный шлюз payu, но он показывает мне ошибку контрольной суммы. Я проверил последовательность значений ha sh, но все еще показывает ошибку контрольной суммы.

views.py
@csrf_exempt
def checkout(request):
    carts = Cart.objects.filter(user=request.user)
    orders = Order.objects.filter(user=request.user, ordered=False)
    order = orders[0]
    amount = int(order.get_totals())
    # if request.method == 'POST':
    email = request.user.email
    first_name = request.user.first_name
    data = {'amount': amount,
            'firstname': first_name,
            'email': email,
            'productinfo': 'Exam-India',
            'txnid': payu.generate_txnid()}
    # data = dict(zip(request.POST.keys(), request.POST.values()))
    data['txnid'] = payu.generate_txnid()
    # hashSequence = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10"
    data['hashh']: self.generate_hash(hash_string)
    payu_data = payu.initiate_transaction(data)
    print("This is the payu values")
    print(payu_data)
    context = {}
    context['carts'] = carts
    context['order'] = order
    context['posted'] = payu_data
    # context['hash_value'] = hash_value
    return render(request, 'checkout.html', context)
checkout. html
<form action="https://sandboxsecure.payu.in/_payment" method="POST" name="payuForm">
  <input type="text" name="key" value={{ posted.key }} />
  <input type="text" name="hash_string" value={{ posted.hash_string }} />
  <input type="text" name="hash" value={{ posted.hashh }}/>
  <input type="text" name="posted" value="{{ posted }}"/>
  <input type="text" name="txnid" value={{ posted.txnid }} />
  <input type="text" name="amount" value={{ order.get_totals | floatformat }} /></td>
  <input type="text" name="firstname" id="firstname" value={{ posted.firstname }} /></td>
  <input type="text" name="email" id="email" value={{ posted.email }} /></td>
  <input type="tel" name="phone" placeholder="Enter Your phone number" /></td>
  <textarea type="text" name="productinfo" style="display:none;">{{ posted.productinfo }}</textarea></td>
  <input type="text" name="surl" value={{ posted.surl }} size="64" /></td>
  <input type="text" name="furl" value={{ posted.furl }} size="64" /></td>
  <input type="text" name="service_provider" value={{ posted.service_provider }} size="64" />
  <input type="hidden" name="udf1" value="{{ posted.udf1 }}" /></td>
  <input type="hidden" name="udf2" value="{{ posted.udf2 }}" /></td>
  <input type="hidden" name="udf3" value="{{ posted.udf3 }}" /></td>
  <input type="hidden" name="udf4" value="{{ posted.udf4 }}" /></td>
  <input  type="hidden" name="udf5" value="{{ posted.udf5 }}" /></td>
  <input type="submit" value="Pay">
</form>
...