5👍
Here’s what we use in our project, hope it helps!!
try:
charge = stripe.Charge.create(
amount={{amount}},
currency="usd",
customer={{customer}},
description={{description}},
metadata={{this.id}}
)
except stripe.error.CardError as e:
# Problem with the card
pass
except stripe.error.RateLimitError as e:
# Too many requests made to the API too quickly
pass
except stripe.error.InvalidRequestError as e:
# Invalid parameters were supplied to Stripe API
pass
except stripe.error.AuthenticationError as e:
# Authentication Error: Authentication with Stripe API failed (maybe you changed API keys recently)
pass
except stripe.error.APIConnectionError as e:
# Network communication with Stripe failed
pass
except stripe.error.StripeError as e:
# Stripe Error
pass
else:
#success
- [Django]-Why am getting a MultipleObjectsReturned error inside a try block?
- [Django]-How can I use separate database for every application in django
- [Django]-Redirect to admin for login
- [Django]-InlineModelAdmin not showing up on admin page
- [Django]-Pyapns Fault 500: 'Connection to the APNS server could not be made
Source:stackexchange.com