Coding Brains
Coding Brains

Reputation: 13

How we can preview prorations in laravel cashier or what is the logic of calculating prorations on any subscription?

I have created a subscription for any of product using laravel cashier and the subscription is for one month then in id of subscription user wants to sowngrade or upgrade his subscription then how can we calculate unused time on cost on existing subscription in laravel cashier.

I am not using stripe/stripe-php i am using laravel cashier

How we can preview prorations?or What is the logic of calculationg prorations?

Upvotes: 0

Views: 932

Answers (2)

korxz
korxz

Reputation: 176

Laravel Cashier uses stripe/stripe-php package so you could use \Stripe\Invoice::upcoming() method.

From Cashier v13 Cashier offers a wrapper for previewing:

$invoice = $user->subscription('default')->previewInvoice('price_yearly');

You can read more about this: https://laravel.com/docs/8.x/billing#previewing-subscription-invoices.

Upvotes: 3

Nolan H
Nolan H

Reputation: 7459

While Stripe's API has an upcoming invoice endpoint that supports previewing changes to subscriptions (change prices, quantity, etc), it does not look like Cashier offers this functionality. Or at least nothing that sounds like an implementation of this feature is included in their documentation. You could contact them to ask about current/future support for this feature.

You can read all about Stripe's proration logic here in the docs.

Upvotes: 0

Related Questions