forked from uncloud/uncloud
Allow for charging customers
This commit is contained in:
parent
94a39ed81d
commit
e0cb6ac670
4 changed files with 32 additions and 20 deletions
|
|
@ -21,7 +21,7 @@ def handle_stripe_error(f):
|
|||
'error': None
|
||||
}
|
||||
|
||||
common_message = "Currently it's not possible to make payments."
|
||||
common_message = "Currently it is not possible to make payments."
|
||||
try:
|
||||
response_object = f(*args, **kwargs)
|
||||
response = {
|
||||
|
|
@ -114,11 +114,15 @@ def get_card(customer_id, card_id):
|
|||
return stripe.Customer.retrieve_source(customer_id, card_id)
|
||||
|
||||
@handle_stripe_error
|
||||
def charge_customer(amount, source):
|
||||
def charge_customer(amount, customer_id, card_id):
|
||||
# Amount is in CHF but stripes requires smallest possible unit.
|
||||
# See https://stripe.com/docs/api/charges/create
|
||||
adjusted_amount = int(amount * 100)
|
||||
return stripe.Charge.create(
|
||||
amount=amount,
|
||||
currenty=CURRENCY,
|
||||
source=source)
|
||||
amount=adjusted_amount,
|
||||
currency=CURRENCY,
|
||||
customer=customer_id,
|
||||
source=card_id)
|
||||
|
||||
@handle_stripe_error
|
||||
def create_customer(name, email):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue