Final Lemon Squeezy integration steps

alexmorning

Jul 14th, 2023 11:12 PM

So I got everything working well enough, I just have a few things to do to make it a seamless switch from Paddle so everything works more or less the same. I am just stuck on couple of things that I could use help with.

I'm trying to add a button to change the payment method, and I cannot get the route to work properly for settings/subscription. I can load the button properly on theme::pricing but whenever I try to load the button in settings, I cannot figure out how to write the route for it to work properly. I just get Undefined variable $paymentMethodUrl .

This is in web.php tell me if I have to put this elsewhere for it to work on a livewire route (I think settings is a livewire route?)

Route::get('{SETTINGS/SUBSCRIPTIONS route here}', function (Request $request) {
    $subscription = $request->user()->subscription();

    return view('{SETTINGS/SUBSCRIPTIONS route here}', [
        'paymentMethodUrl' => $subscription->updatePaymentMethodUrl(),
    ]);
});

Secondly, Lemon Squeezy adds 2 new tables for user data. There is one column for subscription status and it has active, cancelled, and expired (cancelled means in grace period of cancellation).

I am trying to figure out the best way for this to interact with the Wave user roles. Do you think it's better to tell the Wave user role to look at the lemon squeezy table and it will use this data to define the role? like it can maybe look and see like

If lemon_squeezy_status = active => wave role = Pro, or whatever.

Or do you think it is maybe better to change the LemonSqueezy code so that whenever it receives a webhook about a subscription changing, this webhook will also modify the Wave role data at the same time?

I hope that makes sense. Maybe there is also a better way to do this, I am open to any ideas you have.

thank you

alexmorning

Jul 15th, 2023 03:17 AM

This is so much more frustrating than I thought. The updatepaymentmethod function is in vendor\lemonsqueezy\laravel\src\subscription.phpwhich uses a totally other namespace than the livewire subscription controller, so i'm struggling to allow livewire to use the function in the lemonsqueezy controller.

@bobbie Since I'm not using paddle, and I don't technically need the livewire subscription controller anymore, if you have any suggestions on how to load that one page as a normal view so I can load the lemonsqueezy script with a route::get for that url, or any other ideas, I would love some help. I am really struggling with how to do this.

superdev

Jul 15th, 2023 11:28 AM

I would suggest not modifying the package. Whenever updating it, your code inside of it will be overwritten. I would reccomend that you read the documentation for proper integration guides.