laravelstripe-paymentslaravel-cashier

Laravel Cashier refund subscription


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?


Solution

  • 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.