#cristoffer_webhooks
1 messages ยท Page 1 of 1 (latest)
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.
- cristoffer_best-practices, 47 minutes ago, 25 messages
- cristoffer_unexpected, 3 days ago, 22 messages
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1244969818768150539
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
The reason why i need some different way to test webhook is because cli generated events dont have metadata which i assign to every transaction
They should do! But I don't think you setmetadatawhen you created the intent: https://dashboard.stripe.com/test/logs/req_pFwEjTkR044tQW
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Isn't that cli generated one?
Yes, the default fixture don't include metadata so you'll need to set it: https://docs.stripe.com/cli/trigger#trigger-add
oo it can be done, that will be helpful
i guess i should use --add [resource] option
Still there is no way to test it locally without cli?
Well you can use ngrok or something and configure a webhook in your Dashboard that will point to that, and the ngrok points to your localhost
Some service like that where you expose your localhost on the web
Yeah i see the problem now ๐
Copying metadata from generated event by myself and passing it to cli will be good method to provide good data?
I want test data that will be the same as on my website
I want to store in metadata data about products which customer buy
OK, and you're doing that when creating your intents via the API?
yes, exactly. And after a successful payment i want to use webhooks to save this data to my database also. That's why i need to generate events which will include metadata created by me
If you have a working end-to-end integration that creates and confirms intents, then triggering events is redundant. You can just use the CLI to listen and forward the events that natureally fire as part of your payment integration
And assuming you set metadata when you create the intent, it'll be included in the payment_intent.succeeded event that the CLI forwards
Yeah just like in this event. evt_3PLO3mRrtsKOar1b1EzgpIbo
i have created it now
so this event will trigger a webhook /successful-payment and i want to simulate that
With same metadata as in this even
Ok, then just use stripe listen --events=payment_intent.succeeded --forward-to=http://yourendpoint/successful-payment in the CLI
And you'll receieve the events generated by your actual integration code, that'll include the metadata fields
also in test mode? To create that event i have used PaymentElement in React
Yes, CLI defaults to test mode
hm it doesnt work right now. My server only receives event's triggered from CLI, but not from my React App
nevermind, it works now ๐
What does 'doesn't work' mean? Is there an error in your code or the CLI? I would guess that the CLI is signed in to use a different account
stripe listen --forward-to http://localhost:5000/api/payment/successful-payment so this command just forwards event's to my localhost ye?
Yep
Oke, thanks and sorry for my kinda stupid questions ๐ซ
No such thing as a stupid question!
Also i have one about best practices. Should i somehow stop user from creating new payment intents? Right now every refresh on page where my PaymentElement component is creates new request to server and new payment intent
Should i implement some session managed on server so page refresh doesn't cause new payment intent creation?
I'd say that's a detail of your implementation, but it's probably recommended yes. Obviously creating a new intent on each load of the cart/checkout adds latency. If you can persist the client_secret in state somewhere then you can just re-use it and even update the intent if the cart changes