mollie / laravel-cashier-mollie

Official Mollie integration for Laravel Cashier
https://www.cashiermollie.com/
MIT License
136 stars 44 forks source link

Failed Payments #235

Closed Juleshendriks closed 5 months ago

Juleshendriks commented 5 months ago

Hello Everyone,

I am working on a project and I'm stuck at the payment flow..

When a payment fails, what is a logical approach to take? I use the Laravel Cashier Mollie package.

When a payment fails, the subscription gets canceled, this is default behaviour.

I can notify my customer via email.

And then what?

The customer Starts a new subscription? Which wil leave old payments 'open'.

The customer updates his payment method and retries the payment?

I dont know.

Are there tips on how to test recurring failed payments?

Thank you in advance!

Naoray commented 5 months ago

Hi @Juleshendriks,

to handle a failed payment you listen for OrderPaymentFailed and OrderPaymentFailedDueToInvalidMandate events. As you correctly stated, you can use those events to notify the customer to update their payment method..

$updatePaymentMethodUrl = $user
    ->updatePaymentMethod()
    ->skipBalance()
    ->create()
    ->getTargetUrl();

After the customer has changed its payment method, he will be redirected to the cashier. update_payment_method. redirect_url. You can define a controller for this route which then will retry the payment.

// get failed order
$order = $request()->user()->orders->latest()->first();

$order->retryNow();

Hope that helps! Let me know if you need additional information

Juleshendriks commented 5 months ago

@Naoray Thanks for your response! Makes things clear.