#xzel_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/1337092731733934232
đ 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.
- xzel_api, 18 hours ago, 7 messages
Hey, apologies, have to reask this question. My power went out after asking yesterday
Hello there
Yeah a Coupon with a discount is a totally fine way to do this
No issue with generating $0 Invoices
You can't restrict a Coupon to a Customer however you could create a new Coupon each time with a max_redemptions: 1
Then it couldnt' be used again
Yeah i'm already doing the max_redeptions, just trying to lock it down ever more
so then final part of my question was which hooks should I be using to confirm payment
Ah sorry missed that part
currently using CheckoutSessionCompletedEvent for payments
and InvoicePaidEvent for subs, but now payments are also hitting InvoicePaidEvent
Yep checkout.session.completed is the correct one in general for a one-time payment or starting a Subscription.
so checkout.session.completed is good for subscription start?
I'm currenly pivoting based on the subscriptionID exisiting in our DB in invoicePaid
You basically want to look at the properties on the Checkout Session (and you can retrieve the Checkout Session and expand certain properties as needed) to determine what type of payment (one-time vs. recurring).
It also seems like I could do everything in InvoicePaid, with invoice generation enabled for OT payments` if I do enough filtering
You can also go the invoice.paid route if you so desire.
Yep
It really is up to you.
Awesome. Thanks.
Then finally, best way to complete the process for the old subscription is just to run a await stripeClient.subscriptions.cancel(key.subscriptionId);
After they've complete3d the purchase
If you don't want the Subscription to continue, yeah. Alternatively with a 100% off forever coupon you could just leave it running
But up to you
Hmm I dont see the benefit of the later. Thanks. Appreciate the help.
O wait two final ones lol
Is there a good way to branch / know if the incoming invoice is for a subscription renewal?
Are there values I can use in the Invoice to know the start and end of a subscription? For a renewal are those values also easy to grab?
There are several ways, the safest way is to retrieve the Invoice and expand the Subscription to see info about the Subscription object. But also you could just check the period_start and period_end on the Invoice object.
The first Invoice will have the same date set for those properties
Renewals will have the period_start set in the past.
But yeah that doesn't necessarily indicaate when the Sub would end if you have a cancellation set.
So my recommendation is to expand the Subscription and look at the specific values you care about.
Perfect, thanks