#drivelous-python-error
1 messages · Page 1 of 1 (latest)
drivelous-python-error
@frozen canopy I recommend carefully reading https://stripe.com/docs/error-handling?lang=python and making sure you handle all those errors
yeah, we've looked at these. the line of code we have after creating a payment is something like this:
if isinstance(e, StripeError):
failure_code = e.code
failure_message = e.user_message
else:
failure_code = None
failure_message = str(e)
for whatever reason, that stripe error that i posted was still getting to the else block
Try logging that exact error and the exact type it is
yeah that's the next step, i am curious if you would know off the bat
if not it's not a huge deal, currently for ~50 failed payments we just happen to be displaying this long and confusing message. working with my PM now to see what we can do
I do not, I don't really get why your code would use isinstance() exactly in this situation versus catching that specific error type
it's easier? and it wouldn't matter, if this error was indeed a subclass of StripeError then it would've caught it. catching the specific classes would also get to the else block. i did a test of all the errors in the Stripe lib and every one of them was caught by isinstance(e, StripeError)
actually there are 3 errors that we're getting that don't seem to be subclasses of StripeError
295 characters: ”'The provided PaymentMethod was previously used with a PaymentIntent without Customer attachment, shared with a connected account without Customer attachment, or was detached from a Customer. It may not be used again. To use a PaymentMethod multiple times, you must attach it to a Customer first.'“
190 characters: “This PaymentIntent requires a mandate, but no existing mandate was found. Collect mandate acceptance from the customer and try again, providing acceptance data in the mandate_data parameter.”
133 characters: “You've exceeded your weekly ACH volume limit. To request an increased limit, please contact us via https://support.stripe.com/contact”
yeah I'm just wondering if the problem really has to do with your server-side code. So the first step is to reproduce really
got it, got it.
yeah I'll probably add some extra logging and then see what these are
thank you
if you ever do find out what subclasses these should be of then I would appreciate a tag
but i'll go back to the drawing board
stripe.api_key = "sk_test_123"
try:
intent = stripe.PaymentIntent.create(
amount=2000,
currency="usd",
payment_method_types=["card"],
confirm=True,
payment_method='pm_card_visa',
)
stripe.PaymentIntent.create(
amount=2000,
currency="usd",
payment_method_types=["card"],
confirm=True,
payment_method=intent.payment_method,
)
except stripe.error.StripeError as e:
print("inside the catch")
body = e.json_body
err = body.get('error', {})
print("Message is: %s" % err.get('message'))