Skip to content

Instantly share code, notes, and snippets.

@mrsaicharan1
Created April 8, 2020 05:26
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/88647100e45d449bce282f188354cdc2 to your computer and use it in GitHub Desktop.
Save mrsaicharan1/88647100e45d449bce282f188354cdc2 to your computer and use it in GitHub Desktop.
AliPay - Methods to create & charge the source
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