英文:
Laravel Cashier refund subscription
问题
我们需要在一定时间内全额退还订阅费用。我已经实施了以下代码来取消订阅并退款:
$subscription = $user->subscription();
$subscription->cancelNow();
$stripe_subscription = $subscription->asStripeSubscription();
$latest_invoice = Cashier::stripe()->invoices->retrieve($stripe_subscription->latest_invoice);
Cashier::stripe()->refunds->create([
'charge' => $latest_invoice->charge
]);
这按预期工作,即立即取消订阅并退还费用。
然而,如果用户决定重新订阅,系统不会向他们收费,而是通过前一个订阅的“信用”为他们提供全额订阅。
我在文档中找不到如何处理这种情况的信息。是否有人可以解释如何取消退款而不留下信用余额?
英文:
We have a need to offer a full refund on a subscription within a certain time period. I've implemented the following to cancel a subscription and refund the charge:
$subscription = $user->subscription();
$subscription->cancelNow();
$stripe_subscription = $subscription->asStripeSubscription();
$latest_invoice = Cashier::stripe()->invoices->retrieve($stripe_subscription->latest_invoice);
Cashier::stripe()->refunds->create([
'charge' => $latest_invoice->charge
]);
This works as expected in that it cancels the subscription immediately and refunds the charge.
However, if this user decides to then start a new subscription it does not charge them and gives them the full subscription paid via a "credit" on the account from the previous subscription.
I can't find anything in the documentation on how to handle this. Can anyone shed any light on how to refund and cancel without leaving a credit behind?
答案1
得分: 1
如果您取消了未使用的订阅时间,Stripe 将把未使用的信用添加到客户的信用余额中。信用余额将自动用于减少下一张发票的应付金额。
如果这不是您想要的,请在取消订阅后,您可以手动更新客户对象,将其信用余额设置为 0
,具体操作请参考此链接。
您可以在这里了解有关信用余额的更多信息。
英文:
If you cancel a Subscription with unused time, then Stripe adds the unused credit to the customer credit balance. And the credit balance will be automatically used to reduce the amount due on the next invoice.
If that's not what you want, you can manually update the customer object to set their credit balance to 0
with this after cancelling the subscription.
You can learn more about the credit balance here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论