我是django的新手,我正在努力将payumoney与我的django项目整合在一起。但我无法整合,任何人都可以给我一些payumoney整合的步骤。
答案 0 :(得分:1)
答案 1 :(得分:1)
@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)
答案 2 :(得分:0)