Я пытаюсь интегрировать PayTm-шлюз из Djnago в качестве бэкэнда, но моя программа сталкивается с ошибкой при создании контрольной суммы.
Ниже приведен мой фрагмент кода:
models.py
from django.db import models
class TrxnDetail(models.Model):
MID = models.CharField(max_length=20)
ORDER_ID = models.CharField(max_length=50)
CUST_ID = models.CharField(max_length=64)
TXN_AMOUNT = models.CharField(max_length=10)
CHANNEL_ID = models.CharField(max_length=3)
WEBSITE = models.CharField(max_length=30)
INDUSTRY_TYPE_ID = models.CharField(max_length=20)
MOBILE_NO = models.CharField(max_length=15)
EMAIL = models.CharField(max_length=50)
def __str__(self):
return self.ORDER_ID
views.py
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
from gateway.models import TrxnDetail
from gateway.serializers import TrxnSerializer
from gateway.Checksum import generate_checksum
from django.conf import settings
@api_view(['GET', 'POST'])
def snippet_list(request):
"""
List all code snippets, or create a new snippet.
"""
if request.method == 'GET':
snippets = TrxnDetail.objects.all()
serializer = TrxnSerializer(snippets, many=True)
return Response(serializer.data)
elif request.method == 'POST':
serializer = TrxnSerializer(data=request.data)
if serializer.is_valid():
serializer.save()
sdata=serializer.data
mid,order_id,cust_id,
txn_amount,channel_id,
website,industry_type_id,
mobile_no,email=sdata.get('MID'),sdata.get('ORDER_ID'),
sdata.get('CUST_ID'),sdata.get('TXN_AMOUNT'),
sdata.get('CHANNEL_ID'),sdata.get('WEBSITE'),
sdata.get('INDUSTRY_TYPE_ID'),sdata.get('MOBILE_NO'),
sdata.get('EMAIL'),
param_dict = dict()
param_dict['MID']=mid
param_dict['ORDER_ID']=order_id
param_dict['CUST_ID']=cust_id
param_dict['TXN_AMOUNT']=txn_amount
param_dict['CHANNEL_ID']=channel_id
param_dict['WEBSITE']=website
param_dict['INDUSTRY_TYPE_ID']=industry_type_id
param_dict['MOBILE_NO']=mobile_no
param_dict['EMAIL']=email
print(generate_checksum(param_dict,settings.PAYTM_MERCHANT_KEY))
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors,status=status.HTTP_400_BAD_REQUEST)
Я использую ModelSerializer и CheckSum.py
Я получаю следующую ошибку: Изображение ошибки