#Jonah Librach
1 messages · Page 1 of 1 (latest)
Usually no, though it will depend on if the API call was successful or not. If the API call was successful despite the exception, then a charge could be created. Otherwise, no.
Obviously if it's a card error, no charge is created, so you can't get the Charge object
If its a card error a charge is created....
Hence the example
import stripe, logging
def example_function(**kwargs):
try:
stripe.PaymentIntent.create(**kwargs)
except stripe.error.CardError as e:
charge = stripe.Charge.retrieve(e.error.payment_intent.latest_charge)
if charge.outcome.type == 'blocked':
logging.error("Payment blocked for suspected fraud.")
elif e.code == 'card_declined':
logging.error("Payment declined by the issuer.")
elif e.code == 'expired_card':
logging.error("Card expired.")
else:
logging.error("Other card error.")
I don't think that's the case for Invoice payments, but let me check