laravel/cashier-mollie

Subscription renewal

Closed this issue · 1 comments

First of all, thank you for this package.

I'm quit new in the mollie payment and might be going wrong somewhere in my logic, so please correct me if I'm wrong.

My question is about continuing subscription, how to do it correctly?

I have CreateSubscriptionController as shown in the README and plans are loaded from database (this part is working I think). After their subscription ends (or is near end) I want users to be able to update subscription, I found about incrementQuantity() which seems to do what I want to do, but the thing is that it won't redirect users to checkout page, so I am increasing quantity by one but user is not paying, and payment status is set to open. How can I implement it to redirect users to checkout?

Renewal controller:

class RenewSubscriptionController extends Controller
{
    /**
     * Handle the incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function __invoke(Request $request)
    {
        $user = Auth::user();

        if (!$user-> current_subscription) {
            return back()->with('status', 'User does not have program yet');
        }

        $user->current_subscription->incrementQuantity();
        return redirect()->back();
    }
}

current_subscription is custom attribute as shown below.

class User extends Authenticatable implements ProvidesInvoiceInformation, MustVerifyEmail
{
    use HasFactory, Notifiable, CastsEnums, SoftDeletes, Billable;
   
    ...

    public function getCurrentSubscriptionAttribute()
    {
        return $this->subscriptions->sortByDesc(function ($value) {
            return $value->created_at->getTimestamp();
        })->first();
    }   

    ...

Hi,

Subscriptions run until you cancel them. Only for the first payment the customer needs to go through Mollie's checkout. Subsequent payments are triggered and processed automatically by this package.

This package is not intended for having the user go through the checkout each billing cycle to top up his/her subscription.