def paypal_do(token): getexp_response = interface.get_express_checkout_details(token=token) kw = { 'amt': getexp_response['AMT'], 'paymentaction': 'Sale', 'payerid': getexp_response['PAYERID'], 'token': token, 'currencycode': getexp_response['CURRENCYCODE'] } interface.do_express_checkout_payment(**kw) return redirect(url_for('paypal_status', token=kw['token']))
def paypal_status(token): checkout_response = interface.get_express_checkout_details(token=token) if checkout_response['CHECKOUTSTATUS'] == 'PaymentActionCompleted': # Here you would update a database record. return """ Awesome! Thank you for your %s %s purchase. """ % (checkout_response['AMT'], checkout_response['CURRENCYCODE']) else: return """ Oh no! PayPal doesn't acknowledge the transaction. Here's the status: <pre> %s </pre> """ % checkout_response['CHECKOUTSTATUS']
def paypal_confirm(): getexp_response = interface.get_express_checkout_details( token=request.args.get('token', '')) if getexp_response['ACK'] == 'Success': return """ Everything looks good! <br /> <a href="%s">Click here to complete the payment.</a> """ % url_for('paypal_do', token=getexp_response['TOKEN']) else: return """ Oh noes! PayPal returned an error code. <br /> <pre> %s </pre> Click <a href="%s">here</a> to try again. """ % (getexp_response['ACK'], url_for('index'))
def paypal_status(token): checkout_response = interface.get_express_checkout_details(token=token) global vipMember if checkout_response['CHECKOUTSTATUS'] == 'PaymentActionCompleted': # vip=models.User.select().where(models.User.username ** current_user.username) # vip.vip_member='Y' vip = models.User.update(vip_member='Y').where( models.User.id == current_user.id) vip.execute() vipMember = '1' flash("Awesome! You have become a VIP member now.", "success") return redirect(url_for('index')) else: vipMember = '0' return """ Oh no! PayPal doesn't acknowledge the transaction. Here's the status: <pre> %s </pre> """ % checkout_response['CHECKOUTSTATUS']