【问题标题】:How we can preview prorations in laravel cashier or what is the logic of calculating prorations on any subscription?我们如何在 laravel 收银员中预览按比例分配,或者在任何订阅上计算按比例分配的逻辑是什么?
【发布时间】:2021-07-02 16:32:23
【问题描述】:

我已经使用 laravel 收银台为任何产品创建了订阅,订阅期为一个月,然后在订阅 ID 中,用户想要播种或升级他的订阅,那么我们如何计算 laravel 收银台现有订阅的未使用时间成本.

我没有使用 stripe/stripe-php 我使用的是 laravel 收银员

我们如何预览按比例分配?或 配给的计算逻辑是什么?

【问题讨论】:

    标签: laravel laravel-5 stripe-payments laravel-cashier


    【解决方案1】:

    Laravel Cashier 使用 stripe/stripe-php 包,所以你可以使用 \Stripe\Invoice::upcoming() 方法。

    从 Cashier v13 Cashier 提供了一个用于预览的包装器:

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

    您可以阅读更多信息:https://laravel.com/docs/8.x/billing#previewing-subscription-invoices

    【讨论】:

      【解决方案2】:

      虽然 Stripe 的 API 有一个 upcoming invoice endpoint 支持预览订阅更改(更改价格、数量等),但 Cashier 似乎不提供此功能。或者至少在their documentation 中没有包含任何听起来像是此功能实现的内容。您可以联系他们询问当前/未来对此功能的支持。

      您可以在文档中阅读有关 Stripe 的按比例分配逻辑here 的所有信息。

      【讨论】:

        猜你喜欢
        • 2020-02-18
        • 2019-09-08
        • 1970-01-01
        • 1970-01-01
        • 2022-11-29
        • 2019-07-09
        • 1970-01-01
        • 2019-11-16
        • 1970-01-01
        相关资源
        最近更新 更多