我正在尝试通过paytm在我的网站上付款。但是我不知道如何处理烧瓶中的回调URL。 预先感谢。
我已经尝试过Google多次了。
这是我的代码:-
@app.route('/shop/',methods=['POST'])
def shop():
name=request.form['name']
email=request.form['email']
paytmno=request.form['paytmno']
amount=request.form['amount']
# password1=request.form['password1']
# password2=request.form['password2']
print(name,email,paytmno,amount)
deepak_dict = {
'MID': MERCHANT_ID,
'ORDER_ID': str(12345),
'TXN_AMOUNT': str(amount),
'CUST_ID': email,
'INDUSTRY_TYPE_ID': 'Retail',
'WEBSITE': 'WEBSTAGING',
'CHANNEL_ID': 'WEB',
'CALLBACK_URL':'http://localhost:5000/shop/handlerequest/',
}
deepak_dict['CHECKSUMHASH'] = Checksum.generate_checksum(deepak_dict, MERCHANT_KEY)
return render_template('payment/paytm.html', deepak_dict=deepak_dict)
@app.route('/shop/handlerequest/',methods=['POST'])
def shop_handlerequest():
# what to do
response_dict={}
return render_template('payment/paytm_response.html',response=response_dict)
我想读取其回叫数据。
答案 0 :(得分:0)
根据我从Paytm开发人员Docs中学到的知识:-
import Checksum
import requests
MERCHANT_KEY = 'YourMerchantKeyHere';
@app.route('/shop/handlerequest/',methods=['POST'])
def shop_handlerequest():
respons_dict = {}
for i in request.form.keys():
respons_dict[i]=request.form[i] #Getting all the attributes from form in a dictionary to use it later.
if i=='CHECKSUMHASH':
checksum = request.form[i] #Getting Checksum to verify its authenticity
if 'GATEWAYNAME' in respons_dict:
if respons_dict['GATEWAYNAME'] == 'WALLET':
respons_dict['BANKNAME'] = 'null'; #If Gateway is user's paytm wallet setting bankname to null
verify = Checksum.verify_checksum(respons_dict, MERCHANT_KEY, checksum) # returns true or false based on calculations
print(verify)
if verify:
if respons_dict['RESPCODE'] == '01' # 01 Code means successful transaction
print("order successful")
else:
print("order unsuccessful because"+respons_dict['RESPMSG'])
else:
print("order unsuccessful because"+respons_dict['RESPMSG'])
您可以使用Paytm中的test credentials来测试您的集成