#mboras_api
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/1222515673268359319
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- mboras_webhooks, 1 hour ago, 9 messages
- mboras_webhook-payments-subscriptions, 18 hours ago, 41 messages
In most cases there wouldn't be an Invoice for a one-time payment, so no associated invoice.* events
You'd listen for payment_intent.succeeded in most scenarios, unless you're using Checkout
I am using checkout for one-time payments
and added
const session = await stripe.checkout.sessions.create({
mode: 'payment',
line_items,
success_url: successUrl,
cancel_url: cancelUrl,
invoice_creation: {
enabled: true,
},
Then you want checkout.session.completed: https://docs.stripe.com/payments/checkout/fulfill-orders
ok
and in my invoice.*
I'll check for subscription property from response
if it doesn't exist that event is trigerred from my one-time-payment
other ones are from subscriptions
right?
On which event?
invoice.payment_succeeded
This is one-time-payment
I need to ignore these events on subscriptionSuccessEndpoint
I mean, sure. But that's the wrong event generally for the initial payment
After stripe checkout one-time-payments invoice.payment_succeeded will also be trigerred.
I am using invoice.payment_succeeded for subscriptions
- Use
checkout.session.completedfor both one-time and initial subscription payments - Any subsequent recurring payments with the subscription, use
invoice.paid
- The thing is that I'm new on the project and whole logic and app for subscriptions is already made. I'm seeing that previous developer is using invoice.payment_succeeded for subscriptionChargeSuccessEndpoint
- I don't want to lose time on refactoring his code.
That's why I am asking should I just in invoice.payment_succeeded ignore one-time-payments and use checkout.session_completed for those payments.
invoice.payment_succeededwon't always fire if there isn't an actual payment associated to the invoice (i.e. trial, 100% discount, etc).invoice.paidaccounts for those scenarios and is beter option
I mean sure, but what if you opt-out of one-time invoices at some point?
Nothing will break. Still invoice.payment_succeeded will handle logic for subscriptions.
Correct me please if I'm wrong.
I'll ask you once again because I haven't understand you completely.
If I've set for one-time payments to create invoice every time. Does that mean that after one-time payment every time invoice.payment_succeeded will be fired?
Yes, but if you remove invoice_creation[enabled] from your mode: 'payment' sessions, you won't get any invoice.* events for one-time payments. Seems brittle to me, but your call!
The recommendation is what I described above. If you want to do it differently, then sure you can!
I don't want any invoice.* events for one-time payments beside this checkout.
Yes, but what if down the line you decide you don't want ionvoices for one-time payments and disable the feature/remove the parameter? Your logic will break
That's all I'm saying, something to consider
Otherwise yes, you'll receive invoice.payment_succeeded events
But I still don't understand, sorry. I'm confused.
If I disable the feature/remove the parameter for invoice creation then invoice.payment_succeeded will be trigerred only for subscriptions which is wanted behaviour.
I'll move one-time-payment logic to checkout.session_completed.
In checkout.session_completed:
- I'll ignore subscriptions
In invoice.payment_succeeded:
- I'll ignore one-time-payments
it is confusing maybe but I don't want to touch logic from previous developer who made subscriptions because I don't have much time
sorry for my confusion and if I haven't described good everything.
I don't understand what you're asking me. What you've said above is true
Okay then
I just wanted approval for this part