laravel / cashier-mollie

MIT License
375 stars 63 forks source link

Overwriting redirect_url in config in runtime #308

Closed jstam89 closed 3 years ago

jstam89 commented 3 years ago

My website has 2 flows when it comes to subscriptions, one is for completely new users and one for allready exsisting users. At this moment when a new user subscribes the user will be redirected to "/registration?payment_success=true".

For allready subscribed users I want to redirect to a different url but as far as I can see that requires to completely overwrite the config file. Is this correct of is there another way to accomplish this?

I currently use:

$result = $user->newSubscription('monthly', 'pro')->create();

sandervanhooft commented 3 years ago

Good question. One trick I've learned that may help here is to set the redirectUrl to a route attached to a RedirectedFromMollieController and decide there where to ultimately redirect the customer to. It's also convenient for displaying the right payment status message etc.. In your case you could check the user's history before redirecting to the appropriate page.

jstam89 commented 3 years ago

Thanks I will try that.