#mboras_api

1 messages ¡ Page 1 of 1 (latest)

warm onyxBOT
#

👋 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.

limpid ruinBOT
#

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.

torn tinsel
#

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

short marten
#

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,
},

torn tinsel
short marten
#

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?

torn tinsel
#

On which event?

short marten
#

invoice.payment_succeeded

#

This is one-time-payment

#

I need to ignore these events on subscriptionSuccessEndpoint

torn tinsel
#

I mean, sure. But that's the wrong event generally for the initial payment

short marten
#

After stripe checkout one-time-payments invoice.payment_succeeded will also be trigerred.

#

I am using invoice.payment_succeeded for subscriptions

torn tinsel
#
  • Use checkout.session.completed for both one-time and initial subscription payments
  • Any subsequent recurring payments with the subscription, use invoice.paid
short marten
#
  • 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.

torn tinsel
#
  • invoice.payment_succeeded won't always fire if there isn't an actual payment associated to the invoice (i.e. trial, 100% discount, etc). invoice.paid accounts for those scenarios and is beter option
torn tinsel
short marten
#

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?

torn tinsel
torn tinsel
short marten
#

I don't want any invoice.* events for one-time payments beside this checkout.

torn tinsel
#

That's all I'm saying, something to consider

#

Otherwise yes, you'll receive invoice.payment_succeeded events

short marten
#

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.

torn tinsel
#

I don't understand what you're asking me. What you've said above is true

short marten
#

Okay then
I just wanted approval for this part

torn tinsel
#

Yep, seems fine

#

But invoice.paid is still better than invoice.payment_succeeded for reasons I explaine earlier

short marten
#

okay great

#

I'll check with previous dev for that

#

tnx @torn tinsel