我是 django 新手,我正在尝试将 payumoney 与我的 django 项目集成。但我无法整合请任何人都可以给我 payumoney 整合的步骤。
问问题
1851 次
3 回答
2
@app.route('/flaskpayment/<cid>', methods=['GET', 'POST'])
@login_required
def flaskpayment(cid):
try:
with app.app_context():
form = PaymentForm()
if request.method == 'POST':
#read data from previous form
amount = request.form['amount']
firstname = request.form['fname']
email = request.form['email']
phone = request.form['phone']
productinfo = cid
MERCHANT_KEY = "XXXXXXX"
key="XXXXXXX"
SALT = "XXXXXXXX"
PAYU_BASE_URL = "https://test.payu.in/_payment"
posted={}
hash_object = hashlib.sha256(str(random.randint(0,20)))
txnid=hash_object.hexdigest()[0:24]
hashh = ''
posted['txnid']=txnid
hashSequence = key+'|'+txnid+'|'+amount+'|'+productinfo+'|'+firstname+'|'+email+'||||||||||'
posted['key']=key
hash_string = hashSequence
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).hexdigest().lower()
#Payumoney required parameters
form.key.data = MERCHANT_KEY
form.hash_string.data = hash_string
form.hash.data = hashh
form.posted.data = posted
form.firstname.data = firstname
form.email.data = email
form.txnid.data = txnid
form.amount.data = amount
form.phone.data = phone
#service_provider only for secure payment
form.service_provider.data = 'payu_paisa'
form.productinfo.data = cid
form.surl.data = 'https://www.yoursite.com/success/'
form.furl.data = 'https://www.yoursite.com/failure/'
return render_template('paymentform.html',form=form, action = PAYU_BASE_URL)
except Exception as e:
return str(e)
于 2017-05-05T12:35:06.867 回答
0
这是一篇文章,您绝对可以查看它以获取更多信息:- https://makedeveasy.medium.com/payumoney-integration-with-django-rest-framework-and-javascript-19f266a6bad7
于 2021-04-19T17:46:46.107 回答