#some1ataplace
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- some1ataplace, 47 minutes ago, 11 messages
Could you elaborate? Event Ids of the 2 events you mentioned? evt_xxx and evt_yyy
First one (success):
evt_1OEQNqIeTJrsS1rea9HwahG3
Second one (failure):
evt_1OEQO1IeTJrsS1reJzig3l89
I think all I would need to do is somehow detect on the first one if it was a failure ACH payment or something
I am also allowing the subscription to be created on the first webhook which is bad
I was thinking about using the 'unpaid' status
checkout_session = stripe.checkout.Session.retrieve(event.data.object.id, expand=["line_items", "customer", "payment_intent.payment_method", "invoice.payment_intent.payment_method", "subscription.latest_invoice.payment_intent.payment_method","payment_link","setup_intent",],)
payment_mode = checkout_session.mode
elif payment_mode == 'subscription':
checkout_session_subscription_payment_method = checkout_session.invoice.payment_intent.payment_method.type
I have this for the second time around:
if checkout_session.invoice.payment_intent.payment_method is None:
print('payment method None')
But I want to prevent the second time if possible
You would want to check the PaymentIntent's status inside the Checkout Session, when you received checkout.session.completed (1st time) or checkout.session.async_payment_failed (2nd time)
okay that is helpful
But it seems like it picks up checkout.session.async_payment_succeeded the first time too?
elif event.type == 'checkout.session.async_payment_succeeded' and checkout_session_subscription_payment_method == 'us_bank_account' and checkout_session.line_items.data[0].price.id == settings.STRIPE_MONTHLY_PRICE_ID:
That is my if statement that gets executed the first time
I think you would want to write down the exact flow you will handle, before jumping in detailed code implementation. ie. in this case you want to do X, then next you want to do Y...
In each case, check the PaymentIntent status inside the CheckoutSession, to decide what to do next
okay thanks will try it
ah interesting it says processing. Does that seem right?
it seems like it is in the invoice object hmm
Yes it is expected to transfer from processing to failed later, for an async payment method