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

Webhook fails to find Subscription by reference #47

Closed
AugustMiller opened this issue Jan 2, 2019 · 2 comments
Closed

Webhook fails to find Subscription by reference #47

AugustMiller opened this issue Jan 2, 2019 · 2 comments
Assignees

Comments

@AugustMiller
Copy link
Contributor

AugustMiller commented Jan 2, 2019

When receiving the customer.subscription.deleted event, the lookup by reference fails, as the subscription appears to have been expired, already… at least when using the cancelImmediately option.

2019-01-02 12:45:39 [-][-][-][warning][stripe] Subscription with the reference “sub_EGnwT4PvrrQoXK” not found when processing webhook evt_1DoGanIS4LqbsGJB6YDcCqyb

Trying the same resulting SQL with a non-expired subscription, or explicitly setting isExpired: true or status: 'any' will find the subscription just fine.

What I don't understand though, is how the subscription is marked as expired, before the webhook arrives. Ah, found some evidence re: immediate cancellation that would suggest a subscription can be silently expired, outside the webhook loop.

This was uncovered as a result of a handler for craft\commerce\services\Subscriptions::EVENT_AFTER_EXPIRE_SUBSCRIPTION not firing—it seems as though the subscription is being expired in the database, but the event never fires, because the webhook doesn't find the subscription, and bails…

Re: research, above… I'll submit another issue with craftcms/commerce with this info…

Sorry for the rambling! I may have partially resolved my own question/curiosity, but still believe there is a bug in how the webhook deals with “already-expired” subscriptions. My sense is that the EVENT_AFTER_EXPIRE_SUBSCRIPTION event should always fire, regardless of how the subscription is expired (immediately, or organically, at the period’s end).

@andris-sevcenko
Copy link
Contributor

Fixed via d71dd17

@andris-sevcenko
Copy link
Contributor

Thanks for the in-depth description!

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