Created
April 8, 2020 05:29
-
-
Save mrsaicharan1/52c395836b5fc41eb18db59d9718ac4c to your computer and use it in GitHub Desktop.
AliPay - After AliPay authorization, the order is saved and payment is completed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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