Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancel subscription webhook should mark user as canceled now(), but rather end of billing cycle #32

Closed
merchalex opened this issue Jul 14, 2023 · 4 comments

Comments

@merchalex
Copy link

merchalex commented Jul 14, 2023

I noticed that the cancel subscription webhook immediately marks the user as canceled in the db, but in the Lemon Squeezy subscription settings for each user, when cancel a subscription, there is a note that says the user will actually be set to inactive at the end of the billing cycle (as is default behavior ok 98% of subscription services). Even though Lemon Squeezy does not mark a user inactive until the end of the billing cycle, it still sends the canceled webhook immediately, which now creates a situation where the user is now inactive in the database but active on the Lemon Squeezy website. You will see below that I canceled the user today (14 July 2023) but it will not expire for 1 month.

firefox_2023-07-14-03-35-31

I think by default the canceled webhook should mark the user as canceled at the end of the billing cycle, so that the user's status matches everywhere.

Just my opinion (and hopefully i'm not missing something that makes incorrect about the current configuration).

Thanks!

@driesvints
Copy link
Collaborator

Hi there. I think you misunderstand the status of "canceled" here. "canceled" in lemon squeezy and in this package does not mean the subscription is inactive. It means the customer is on its grace period. When that grace period ends it'll transition the subscription to "expired" which means it's inactive. The ->subscribed() check will still return true when the subscription is canceled.

@merchalex
Copy link
Author

Yes, I apologize, I was misunderstanding. I reviewed the code but obviously I missed some important things that would have told me this, so sorry. I did not know the status would change to expired. Thank you very much for clarifying. And thank you for this repo, it is very, very helpful for me to not have to use Paddle :). And thank you for the fast reply as well.

Cheers

@merchalex
Copy link
Author

Pardon my asking here, but I did not want to create an issue for this as I am not sure that this is not my mistake. I have use the routes properly thus far to create a new subscription and the webhooks/api communicate properly for this. But I am trying to add a link to update payment url, and I have tried to this via link and the button to trigger the modal popup, and both messages receive an error for this function. Can you tell me if there is something I am doing wrong for this?

Route::get('/update-payment', function (Request $request) {
    $subscription = $request->user()->subscription();

    return view('theme::pricing', [
        'paymentMethodUrl' => $subscription->updatePaymentMethodUrl(),
    ]);
});
<a href="/update-payment">update</a>

screenshot

I also get a similar error whenever I add the script for modal edit window. I just cannot figure out if I am making a mistake elsewhere, but I have spent 6 hours trying to solve this 1 button problem, so I thought maybe I should ask you, if it's okay.

screenshot

I am using @lemonJS in my head area, as well as the following code:

<script src="https://app.lemonsqueezy.com/js/lemon.js" defer></script>

<script defer>
    function updatePM() {
        LemonSqueezy.Url.Open('{!! $paymentMethodUrl !!}');
    }
</script>

thank you for your time

@driesvints
Copy link
Collaborator

You're calling the relation instead of the model: $subscription = $request->user()->subscription();

Try $subscription = $request->user()->subscription;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants