#Liam
1 messages · Page 1 of 1 (latest)
I think I can achieve the same result with Stripe using a checkout session and passing the internal order id in the subscription_data.metadata field since that will be sent in every invoice.payment_succeeded webhook to match the successful payments that way.
Not sure if that field persists to Invoice objects. Probably worth testing.
Do you need to handle every recurring payment/event in your webhook or just the initial one?
'm interested in the upsell feature, if a customer decides to add a one-off purchase through upsell to their subscription checkout session, how do you recommend I find out what they have purchased from a webhook as there wouldn't be a row in our internal orders table for the upsold item
Depends on what events you're listening for and your Checkout parameters. Theline_itemsfield on the Checkout Session object contains all items from the payment.
For the upsell there'd be an additional line item on the initial Invoice too
I've tried this with a test clock and the subscription_data.metadata was included in every invoice.payment_succeeded that was sent for the recurring payments so I think that will be ok. Was just wondering if there's perhaps a better way to achieve this result.
We would need to handle every recurring payment as most of our payments (both recurring and one-off) are for credits in our website. For example they can buy 100 credits one-off or setup a recurring payment every 3,7,14,30, etc days. So whenever a payment webhook comes in we match up the
So the upsold product id would be visible as an extra line item in the invoice.payment_succeeded webhook?
You probably won't receive an invoice.payment_succeeded event for one-off payments
Yep
Ok thanks will test that on my end
Thanks for the help, really like this format
In fact you definitely won't unless you're using invoice_creation for one-time invoicing: https://stripe.com/docs/payments/checkout/post-payment-invoices
Also, we generally recommend invoice.paid as opposed to invoice.payment_succeeded – the latter doesn't account for scenarios where there is no payment (i.e. 100% discount etc)
Thanks a lot, we'll swap over to invoice.paid
For one-time payments, you'll just want a checkout.session.completed event
You'll need to retrieve the line items using the cs_xxx ID separately though for the Product/Price data: https://stripe.com/docs/api/checkout/sessions/line_items
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
And internally I assume it's ok to keep a local mapping of Stripe Prices <-> internal products. Then for each price in a line item I would check the mapping and applying the relevant internal product to their account?
Yep, seems logical