Created
April 8, 2020 05:26
-
-
Save mrsaicharan1/88647100e45d449bce282f188354cdc2 to your computer and use it in GitHub Desktop.
AliPay - Methods to create & charge the source
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
class AliPayPaymentsManager(object): | |
""" | |
Class to manage AliPay Payments | |
""" | |
@staticmethod | |
def create_source(amount, currency, redirect_return_uri): | |
stripe.api_key = get_settings()['alipay_publishable_key'] | |
response = stripe.Source.create(type='alipay', | |
currency=currency, | |
amount=amount, | |
redirect={ | |
'return_url': redirect_return_uri | |
} | |
) | |
return response | |
@staticmethod | |
def charge_source(order_identifier): | |
order = safe_query(db, Order, 'identifier', order_identifier, 'identifier') | |
stripe.api_key = get_settings()['alipay_secret_key'] | |
charge = stripe.Charge.create( | |
amount=int(order.amount), | |
currency=order.event.payment_currency, | |
source=order.order_notes, | |
) | |
return charge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment