#bruce-zhang_webhooks
1 messages ¡ Page 1 of 1 (latest)
đ 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/1221646111618367570
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Which webhook event do you expect the metadata to be in?
The metadata will contains some information about the plan that user choose. We know what plan the user choose when checkout session is created at the frontend, and we want to let backend knows it when the webhook event is received.
payment_intent.succeeded
If this is the best event that can let us know user successfully pays for a subscription product in checkout session
For payment_intent.* event, the metadata should be set under payment_intent_data.metadata in the Checkout Session Creation request: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
If this is the best event that can let us know user successfully pays for a subscription product in checkout session
I'd recommend usingcheckout.session.*events for the subscription sign up using Checkout Session. Here's the guide on how to get the payment status in a Checkout Session via these events: https://stripe.com/docs/payments/checkout/fulfill-orders
Do you mean this event?
checkout.session.completed
If you don't configure to use any asynchronous payment methods, then checkout.session.completed event is sufficient.
If you do, then other asynchronous events on checkout session should be considered: https://docs.stripe.com/payments/checkout/fulfill-orders#delayed-notification
If the payment fails, the checkout.session.completed event will still sent to webhook, is that correct?
Because I see that the next steps for checkout.session.completed is waiting for payment success
I think we want to update our database only after payment is successful
If the payment fails, the checkout.session.completed event will still sent to webhook, is that correct?
No.checkout.session.completedevent will only be sent when the customer completes the payment:
- For synchronous payment methods - the payment outcome will be immediate on
checkout.session.completedevent - For asynchronous payment methods -
checkout.session.completedevent will inform you that the payment is still processing. Separate events will be sent for the payment outcome
You'd need to check the payment_status of the checkout.session.* event: https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-payment_status
Alternatively, invoice.paid event is recommended for successful subscription payment: https://docs.stripe.com/billing/subscriptions/overview#subscription-lifecycle
I think invoice paid can be great since it can check first time subscription (at checkout session), recurrent charge (renew subscription), and update subscription (at customer portal) in our case.
will invoice.paid also be sent when subscription plan is updated in customer portal?
We recommend to use invoice.paid events throughout subscriptions
will invoice.paid also be sent when subscription plan is updated in customer portal?
Yes -invoice.paidevent is not integration path dependent. As long as the invoice is paid successfully, this event will be sent
Is there a way to add metadata at the front end when I trigger either the checkout session or customer portal and retrieve the metadata in webhook through invoice.paid event?
Yes! You can set the metadata in subscription_data.metadata: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-subscription_data-metadata
This metadata will be available in subscription_details.metadata on the Invoice object in invoice.paid event: https://docs.stripe.com/api/invoices/object#invoice_object-subscription_details-metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I'd recommend giving it a try in test mode
I have tried the test mode! I will test the metadata. Thanks!