#bragma_best-practices
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/1280876758606024747
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello
There's no way to create an invoice for the subscription without creating the subscription.
A workaround would be to create a one-time invoice, send that to the customer. Once they pay the one-time invoice, you can update their credit balance and create the subscription.
The credit balance should auto-apply to first invoice of the subscription - https://docs.stripe.com/billing/customer/balance
The other option would be to use trial period days for the first cycle
Just to elaborate on the 2 solutions I've tried:
Solution 1 has the problem that the first invoice must be paid within few hours, else the subscription will be canceled. Also, it must be created with a start time that is "lost" for the user since the subscription state is inactive.
Solution 2 has the problem to show the subscription as trial, generate a 0 value invoice, also the first invoice is not "related" to the subscription
Ok thanks! So you confirm the is no clean solution to this. Seems incredibile oversight for me
It is not an oversight really. This is just how billing works on Stripe.
I want to "assign" a subscription to a user, and have it activated in my product when the first invoice is paid
You can do that with subscriptions + webhooks. You can listen toinvoice.paidevents and provision your product when the subscription invoice gets paid.. Until then you can keep it "pending"
This is what I do in solution 1, but suppose that I create the subscription in stripe now for 3 months, invoice is sent, paid 5 days later, the subscription in my system will be "misaligned" with stripe start/cancel date
Not very clean. I'd like first invoice to activate the subscrption with start/cancel dates calculated on the payment date.
You can reset the billing cycle date when the invoice gets paid though
which moves the anchor
I also need to change the cancel_at, correct?
Correct
I mean, if I want to provide exatcly "3 months" worth days, correct?
Ok, thanks
Still seems a hack to me for something that I think is quite common ๐
You'd want to make sure that you set proration behavior to none to avoid any prorations
https://docs.stripe.com/billing/subscriptions/billing-cycle#use-billing-cycle-anchor
Right. correct
Also I can't find it right now, but I seem to remeber the first invoice must be paid within 23 hours
This is a bit of a limit, sometimes crew send invoice requests before the weekend and the cusomters forget to check the emails for days
I think you're referring to this: https://docs.stripe.com/api/subscriptions/create#create_subscription-payment_behavior
that behavior only applies to subscriptions with collection_method: charge_automatically
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
My team serves as an eng interface between our users and all of our product teams as well as docs team etc, so we familiarise with pretty much everything ๐
Also we get variety of questions from Stripe users so the knowledge just keeps on adding
Thank you so much, I owe you a coffee
No worries! Happy to help
Ok, I'll abuse you just one last time:
If I want to create a subscription interactively (the user buys via app), I set CollectionMethod="charge_automatically" and PaymentBehavior="default_incomplete", send the invoice/intent data to the app, and wait for the button to be pressed. The subscription will be inactive for max 23 hours and become active when the user presses the damn button.
If I want to create a sub "offline", I create it with CollectionMethod="send_invoice", set a DaysUntilDue appropriately and the subscription will become immediately active. If the user never pays, too bad for me.
Correct, you can use due date as your pointer to cancel/delete the subscription as a cleanup job
Ok, not exactly whay I wanted and my customers preferred, but I suppose they'll have to live with it
There's also payment_behavior = allow_incomplete
if I recall correctly, the invoice won't be voided automatically after 23 hours in this case.
Let me see if I can test this really quick
however though, you'd need to have a saved payment method for the customer already
That's not the case for me. The customer may exist or may not, and not have a savad payment method
Gotcha. In that case, the options you outlined would be ideal