laravel/cashier-mollie

not being redirected to mollie

Dontorpedo opened this issue · 4 comments

php 7.4
laravel 7

I am testing the checkout proccess but i am not redirected to mollie page..
i tried it in test and livemode..
for both molliepayment are created.
tried also with NewSubscriptionViaMollieCheckout, but no success

this is my code, what am i doing wrong?

` if (tenant()->subscribed('default')) {
tenant()->subscription('default')->swap($this->plan);

        $this->success = 'Plan updated.';
        $this->error = '';
    } else {


        /** @var Carbon $trial_end */
        $trial_end = tenant()->trial_ends_at;

        if (config('saas.trial_days') && $trial_end->isFuture()) {

            $subscription = tenant()->newSubscriptionViaMollieCheckout('default', $this->plan)->trialUntil($trial_end)->create();

        }else{

            $subscription = tenant()->newSubscriptionViaMollieCheckout('default', $this->plan)->create();
        }

        if(is_a($subscription, RedirectToCheckoutResponse::class)) {
            return $subscription; // Redirect to Mollie checkout
        }

       $subscription->create();

        $this->success = 'Subscription created.';
        $this->error = '';
    }

    $this->emit('billingUpdated');`

it works if i do it like this

return redirect($subscription->payment()->getCheckoutUrl());

but is this way also recommended?

@Dontorpedo yes, it is correct.

$subscription represents the subscription object.
The example in the readme returns the entire object but if you want just the redirect URL you can retrieve it with $subscription->payment()->getCheckoutUrl()

Check this issue response from the library author: Issue 89

ok, thanks !