我已经通过Laravel的Cashier软件包为用户订阅了订阅计划。现在,我想显示用户下一次计费的日期,但是通过Billable特性似乎不可用。
如何获得下一个帐单日期?
谢谢!
最佳答案
解决方案是使用asStripeCustomer
方法:
// Retrieve the timestamp from Stripe
$timestamp = $user -> asStripeCustomer()["subscriptions"] -> data[0]["current_period_end"];
// Cast to Carbon instance and return
return \Carbon\Carbon::createFromTimeStamp($timestamp) -> toFormattedDateString();
请注意,我仅对具有单个订阅-
data[0]
的用户进行了测试。您可能需要为多个订阅更改此代码,或者如果用户已取消并开始另一个订阅,则可能需要更改此代码。
关于laravel - 从Laravel Cashier获取下一个账单日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41576568/