laravel / cashier-mollie

MIT License
376 stars 63 forks source link

Change redirect URL on mollie payment page #137

Closed Rainieren closed 4 years ago

Rainieren commented 4 years ago

Currently when a payment is made the user redirects to https://localhost. This can also be seen here

Screenshot 2020-01-21 at 16 37 02

Is there a way to customize this URL? I don't know how to redirect the user to a payment confirmation page? I tried adding 'redirectUrl' to cashier_plans.php but that does not seem to do anything.

public function buy($id)
    {

        $user = Auth::user();
        $plan = Plan::where('token', $id)->firstOrFail();

        if(!$user->subscribed($plan->name, $plan->name)) {

            $result = $user->newSubscription($plan->name, $plan->name)->create();

            if(is_a($result, RedirectToCheckoutResponse::class)) {
                return $result;
            }

            return back();
        }

        return redirect('/');
    }
robindirksen1 commented 4 years ago

How do you access the webpage/application. Is this via localhost or the ngrok url?

Rainieren commented 4 years ago

@robindirksen1 I use Valet and did valet share and used the ngrok url to navigate and make payment etc.

robindirksen1 commented 4 years ago

What is your APP_URL in .env?

Rainieren commented 4 years ago

I would like to reopen this issue and ask the following question. @robindirksen1 I looked at the APP_URL in the .env folder and indeed it said http://localhost I changed it to my current site URL and mollie redirects successfully to that url. But I want the user to be redirected to a url something like this https://www.rainierlaan.test/payment-success or something along those lines. I does not make sense to change the APP_URL in the .env file to a payment confirmation page. Can it be set somewhere else?

robindirksen1 commented 4 years ago

You can configure what the redirect_url is in the configuration (see: https://github.com/laravel/cashier-mollie/blob/develop/config/cashier.php#L60) but that's also the url when the user didn't complete the payment.

If you redirect the user to a general page (for example: /check-payment) you'll have the controle to redirect them to the correct page (payment-success or payment-failed) based on the payment status.

Can this be a solutions for your case?

Rainieren commented 4 years ago

I see. Thank you this is what I was looking for!