[Answered ]-Trying to get the errors from a failed Stripe charge

2👍

✅

The exception that is being thrown does not have the messages attribute. messages attribute is only available for Django’s ValidationErrors type exceptions and its subclasses. To handle Stripe’s errors, see this example:

try:
  # Use Stripe's library to make requests...
  pass
except stripe.error.CardError as e:
  # Since it's a decline, stripe.error.CardError will be caught
  body = e.json_body
  err  = body['error']

https://stripe.com/docs/api/python#errors

Leave a comment