#dominikganic_api

1 messages ยท Page 1 of 1 (latest)

west karmaBOT
#

๐Ÿ‘‹ 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.

oak glade
#

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.

vital agate
#

Could you please share the invoice Id ?

#

and the requestId of the update?

oak glade
#

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

oak glade
vital agate
#

Ah you are using the upcoming endpoint...

vital agate
oak glade
#

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.

vital agate
#

Yes that what you should use!

oak glade
#

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?

west karmaBOT
vital agate
oak glade
#

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

torn plinth
#

It doesn't matter whether the invoice is paid or not โ€“ it is always accounted for in proration calculations

oak glade
#

Okay, but this might be a bad behavior in our frontend to display the customer

torn plinth
#

Yeah, maybe. In that case disable prorations

#

i.e. check if they have an unpaid invoice and toggle proration according to that

oak glade
#

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?

torn plinth
#

No we won't cancel any unpaid open invoices automatically. You can manually void them otherwise we'll keep retrying payment

oak glade
#

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? ๐Ÿ™‚

torn plinth
#

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

oak glade
#

Ah okay, that's also fine for me ๐Ÿ™‚

#

Thanks a lot guys, you really explained it well and helped me out, awesome support. Have a great day!