#geimsdin-setup-intent
1 messages · Page 1 of 1 (latest)
👋 Happy to help
Can you share the use case why you need to retrieve the Setup Intent from Payment Element?
I create the Setup Intent on php and I pass it as a js var, if the payment form is reloaded I see that the setup intent changes and I need the new one to create a subscription schedule
Setup Intent shouldn't change since Setup Intent client secret is required to create Payment Element (which is always the same underlying Setup Intent)
mmm
You are right... obviously... then I don't understand why I get error:
As the payment form is submitted I create an order that stores the setup_intent_id (useful to me to connect the next events to that specific order). Sometimes it's like the next events are triggered before the order is stored then... can I delay the events somehow?
Why error do you receive?
I create the subscription schedule right before storing the order in DB
The error is that I cannot access an uninitialized property that should be initialized if the order is registered with the correct setupintent
Hi, stepping in for river and catching up
I guess the problem is in my code, I need to investigate more, you can close this please, in case I'll find out is not there I will write again
Ok, I found the problem
the events are triggered sometimes before my order has been registered and some automations fails because cannot bind the stripe data to the order
Is there a way to delay the events?
there is not , order of events can change(https://stripe.com/docs/webhooks/best-practices#event-ordering)
The best approach generally is to treat any webhook as just a 'notification' that something changed, retrieve the related object from the API, and then pass into code on your side that can idempotently either create records if none exist or update existing records depending on what exists. Or push events into a queue and work on that queue.
I basically do that: I gather informations through the webhook, I store locally and I tell stripe to finalize the invoice or to charge the card etc... The problem is that the first event sometimes arrives before the order has been created