#mboras_webhook-payments-subscriptions
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/1222224242033033378
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi ๐
Whether or not to create a new webhook endpoint is up to you. However, as long as you can build logic to handle multiple types of events there is nothing wrong with listening to multiple events on a single webhook endpoint.
As long as you are able to return a 200 status response quickly
Is event
invoice.payment_succeeded
legit for listening on succesfful payment in stripe checkout?
I'll see in my logs difference between subscription and one-time payment and I'll handle that logic
Only if you have configured Stripe Checkout to generate invoices
where I can see that?
Otherwise you should listen to payment_intent.succeeded
I've been assigned this project and I'm now checking
It's specified when you create the Checkout Session here: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-invoice_creation
In some of my other projects I was listening on checkout.session.completed
Is that wrong or?
No. But that simply indicates the customer completed the checkout session
So I just enable it and what I pass for customer_email he'll get email after successful payment?
For asynchronous payment methods they can still fail after the customer has cmpleted the session
Correct
aah I'm good then
I've disabled SEPA and SOFORT payments for that reason
Okay but I would still recommend listening to payment_intent.succeeded
So just to check one more time?
payment_intent.succeeded is trigerred only on success of payment in one-time payment mode?
To summarize
I'll then create another webhook to listen on payment_intent.succeeded and in creation of checkout I'll pass send of invoice and that's it
You can create another webhook or simply add logic to handle events with the different type to your current webhook
payment_intent.succeeded is triggered both from successful one-time and subscription payments
I'll create another one and I'll ignore in that one subscription payments.
How can I differentiate one-tiome a
one-time and subscription payment
export const paymentSuccessEndpoint = functions.https.onRequest(
async (request, response) => {
response.set('Access-Control-Allow-Origin', '*');
response.set('Access-Control-Allow-Credentials', 'true'); // vital
if (request.method === 'OPTIONS') {
// Send response to OPTIONS requests
response.set('Access-Control-Allow-Methods', 'GET');
response.set('Access-Control-Allow-Headers', 'Content-Type');
response.set('Access-Control-Max-Age', '3600');
response.status(204).send('');
return;
}
try {
console.log('Data', request.body.data.object);
response
.set('Access-Control-Allow-Origin', '*')
.status(200)
.send();
return;
} catch (e) {
console.error(e);
response
.set('Access-Control-Allow-Origin', '*')
.status(500)
.send();
return;
}
},
);
if you have that information prepared somewhere?
before I manually check in logs ๐
Subscription payments will come from a Invoice and the Invoice object will include the ID of a subscription
"data": {
"object": {
"id": "in_xxx",
"object": "invoice",
Like this?
The data object will be an invoice only for invoice.* events
"data": {
"object": {
"id": "cs_live_123",
"object": "checkout.session",
and this for one-time paymnet
Only if your integration only uses Checkout Sessions in mode payment
If you use them for mode subscription then it could contain payments for subscriptions
Great ๐ Happy to help ๐