#dominikganic_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/1334846776762695713
๐ 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.
- dominikganic_best-practices, 4 days ago, 33 messages
My backend receives the following output for prorations.
Here is my code:
"customer" => $Subscription->customer,
"subscription" => $SubscriptionId,
"subscription_items" => [
[
"id" => $Subscription->items->data[0]->id,
"price" => $NewPriceId
]
]
]);```
I have a user in my database, which has one stripe_customer_id (that works fine).
This user can have multiple "restaurants" listed on my platform.
Each restaurant requires a subscription.
When I try to change the subscription of one of these restaurants, I receive this weird calculation.
Sure ๐
Okay I've tried it but I sadly can't find it - where can I find this?
This is the active subscription id: sub_1QmfOVLZihhBkt1cSWizgtQC
And this is the invoice id of this current active subscription which is paid (790โฌ / Year)
in_1QmfOVLZihhBkt1cffo2NKJ1
(Working in test mode btw.)
There is no "update" request-id because I'm just loading a "upcoming invoice" (proration preview)
The user didn't invoke the update yet, first he should see the upcoming invoice
As in this code $this->Stripe->invoices->upcoming() I'm calculating the next amount we will charge for him
Ah you are using the upcoming endpoint...
This is the result of a proration
If you don't want to have proration, then you need to specify that when calling the upcoming endpoint:
https://docs.stripe.com/api/invoices/upcoming#upcoming_invoice-subscription_proration_behavior
But I want to prorate it, I want to display the customer which upcoming amount he should pay, or have I understood something wrong?
Ah okay I have set
"subscription_proration_behavior" => "always_invoice"
And now I receive -298.57โฌ which sounds good.
Yes that what you should use!
Nice thanks a lot you helped me really with this ๐
Just another small question, "subscription_proration_behavior" is deprecated as stated in the docs.
Can I still continue using it or is there any other better way?
Ah yes sorry, the recommended attribute is subscription_details
https://docs.stripe.com/api/invoices/upcoming#upcoming_invoice-subscription_details
Alright. Works fine. I've changed now my code to this:
"customer" => $Subscription->customer,
"subscription" => $SubscriptionId,
"subscription_details" => [
"items" => [
[
"id" => $Subscription->items->data[0]->id,
"price" => $NewPriceId
]
],
"proration_behavior" => "always_invoice"
]
]);```
Now I have another weird case where I need your assistance please.
I have a subscription in state "past_due" with the subscription id: sub_1QlpLoLZihhBkt1cOPQgtCmG (Flayvor Starter 29โฌ / Month)
Now the customer wants to "upgrade" this plan to the next greater plan "Flayvor Plus 49โฌ / Month".
I receive a totally weird amount of proration I can't explain: 17.37โฌ
The customer hasn't paid yet his current plan invoice in total of 29โฌ
How did Stripe calculate 17.37โฌ to be paid
It doesn't matter whether the invoice is paid or not โ it is always accounted for in proration calculations
Okay, but this might be a bad behavior in our frontend to display the customer
Yeah, maybe. In that case disable prorations
i.e. check if they have an unpaid invoice and toggle proration according to that
Ah okay, so when the current subscription state is "past_due" I should disable the proration - this might be a point.
Thats cool yes, now it shows me he has to pay 49โฌ (the full amount of the new plan) which is what I expect from the customer ๐
So, when he pays this subscription intent invoice, the recent invoice of 29โฌ which is in past_due will be canceled and a new one will be created?
No we won't cancel any unpaid open invoices automatically. You can manually void them otherwise we'll keep retrying payment
Oh okay! So when the customer changes the subscription plan which is currently in past_due I should void the current invoice. Stripe will create automatically a new subscription id with a new invoce furthermore for the new plan? ๐
No, there won't be a new sub_xxx ID, you'll just get a new in_xxx ID in the latest_invoice field after your update