Skip to content

Instantly share code, notes, and snippets.

@mrsaicharan1
Created April 8, 2020 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrsaicharan1/52c395836b5fc41eb18db59d9718ac4c to your computer and use it in GitHub Desktop.
Save mrsaicharan1/52c395836b5fc41eb18db59d9718ac4c to your computer and use it in GitHub Desktop.
AliPay - After AliPay authorization, the order is saved and payment is completed
@alipay_blueprint.route('/alipay_return_uri/', methods=['GET', 'POST'])
def alipay_return_uri(order_identifier):
"""
Charge Object creation & Order finalization for Alipay payments.
:param order_identifier:
:return: JSON response of the payment status.
"""
try:
charge_response = AliPayPaymentsManager.charge_source(order_identifier)
if charge_response.status == 'succeeded':
order = safe_query(db, Order, 'identifier', order_identifier, 'identifier')
order.status = 'completed'
save_to_db(order)
return redirect(make_frontend_url('/orders/{}/view'.format(order_identifier)))
else:
return jsonify(status=False, error='Charge object failure')
except TypeError:
return jsonify(status=False, error='Source object status error')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment