#carbonara_code
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/1437737649577394188
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
đź‘‹ Hi there! Let me take a look
If you're not able to just ignore the invoice on your backend, then I believe you could use a Subscription Schedule to update the billing_cycle_anchor
Are you setting proration_behavior: none when adding the trial days? https://docs.stripe.com/billing/subscriptions/billing-cycle#change-the-billing-period-using-a-trial-period
Would that solve my problem?
From what the documentation says there, I believe it should
I'll give it a try, thanks a lot for your help
I checked on that, and it still generates a $0 invoice
damn
Yeah this isn't really possible. You're effective moving the b_c_a date which always requires a new invoice
Thanks for testing it for me.
Is there a way to check if the invoice was generated for extending a subscription’s duration? That way, I can ignore it in the code and solve the problem at the root.
You mean a way to check if you used a trial period?
Let me explain: we sell dog food through subscriptions, and we send the right amount to cover exactly 28 days. For medical reasons, some dogs need to go through a transition period from kibble to our food. Since the duration of this transition is determined case by case, if someone tells us they still have food left, we need to postpone the subscription payment just that one time. After consulting with other companies in the same field that use Stripe, they suggested adding trial days.
Unfortunately, it’s a situation we only discovered after launching the product, and this system based on subscriptions and trial periods is already in production.
Not easily, no. My recommendation would be to pass metadata in your Subscription update call that sets the trial period which will then be set on the resulting invoice (here). You can use that to ignore the invoice/related events in your code
Just remember to unset it when the trial/extended period ends
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Something like this?
$updatedSubscription = \Stripe\Subscription::update($subscriptionId, [
'trial_end' => $newTrialEnd,
'proration_behavior' => 'none',
]);
$invoices = \Stripe\Invoice::all([
'subscription' => $subscriptionId,
'limit' => 1,
]);
\Stripe\Invoice::update($invoiceId, [
'metadata' => [
'reason' => 'Trial extension',
'extended_days' => $additionalDays,
],
]);
Well it depends on when you app logic that 'breaks your database' is running? Is that triggering on receipt of a webhook event or something?
Ah well, of course, that way it doesn’t work. We’re using webhooks, so the invoice would arrive directly without the added metadata.
invoice.paid I assume?
Then what I described here should work. You set metdata on the subscription:
$updatedSubscription = \Stripe\Subscription::update($subscriptionId, [
'trial_end' => $newTrialEnd,
'proration_behavior' => 'none',
'metadata' => [ ... ]
]);
That'll be included in the invoice.paid event
Ok, so I set the metadata on update, retrieve them from the webhook, and then, of course, delete them.
Should work yes
Can unset it on the Subscription via an update with an empty string
top