Simple Membership Plugin › Forums › Simple Membership Plugin › BILLING.SUBSCRIPTION.PAYMENT.FAILED is subscribed but never handled
- This topic has 1 reply, 2 voices, and was last updated 1 month ago by
admin.
-
AuthorPosts
-
October 16, 2026 at 10:43 am #32381
freetiermorioka555
Participant## Summary
The plugin subscribes to the PayPal webhook event
BILLING.SUBSCRIPTION.PAYMENT.FAILED, but the webhook handler has no code path for it. As a result, a failed subscription payment is never reflected on the site, and members on “No Expiry” levels keep paid access indefinitely unless a cancel or suspend event arrives.## Environment
– Plugin: Simple Membership
– Versions checked: 4.4.3 (in production) and 4.7.2 (source reviewed; the same code is present)
– Gateway: PayPal, PPCP subscriptions (button typepp_subscription_new), REST webhooks## What happens
1.
get_event_types()includesBILLING.SUBSCRIPTION.PAYMENT.FAILEDin the list of webhook events the plugin registers.
2. Inhandle_paypal_webhook(), theswitch ( $event_type )has nocasefor this event. It falls through todefault: break;and nothing is done.
3. So when PayPal fails to collect a recurring payment, the site is never told in any usable way.
4. The member stays on the paid level. If the membership level’ssubscription_duration_typeis “No Expiry”,SwpmCronJob::update_account_status()cannot expire the account either, becauseSwpmUtils::get_expiration_timestamp()returnsPHP_INT_MAXfor such levels.
5. In practice, unless a cancel or suspend webhook eventually arrives, there is no mechanism that ends access.A related point:
handle_subscription_status_update()uses thelast_webhook_statusvalue in the member’s extra info to avoid processing the same status twice. I could not find any code in the plugin that clears this value. If a member cancels, re-subscribes, and later a second event of the same kind arrives, it appears to be treated as already processed and ignored. I may be missing something, but I did not find a reset path.## Where in the code (line numbers are for 4.7.2)
–
lib/paypal/class-swpm-paypal-webhook.php,get_event_types()— the event is listed at line 287.
–lib/paypal/class-swpm-paypal-webhook-event-handler.php,handle_paypal_webhook()— theswitch ( $event_type )has no matchingcase.
–lib/paypal/class-swpm-paypal-webhook-event-handler.php,handle_subscription_status_update()— reads and writeslast_webhook_status.
–SwpmCronJob::update_account_status()andSwpmUtils::get_expiration_timestamp()— No Expiry handling.## Why this matters
Site owners can end up giving paid access to members whose payments are failing, with no signal on the WordPress side. Since the event is already subscribed to, this looks more like an unintended gap than a design decision.
## Suggested fix
– Add a
caseforBILLING.SUBSCRIPTION.PAYMENT.FAILEDinhandle_paypal_webhook().
– Because immediate cancellation is not always desirable (a temporary card error often recovers within a few days), it would be helpful to provide a filter or action hook so each site can decide the policy, for example based on the number of consecutive failures or the days since the last successful payment.
– Clearlast_webhook_statuswhen a payment succeeds (PAYMENT.SALE.COMPLETED), so later status events are not wrongly skipped.
– A few other subscribed events also appear to be unhandled:BILLING.SUBSCRIPTION.CREATED,BILLING.SUBSCRIPTION.UPDATED,PAYMENT.SALE.REVERSED, andPAYMENT.CAPTURE.REVERSED. If that is intentional, no problem. ForPAYMENT.FAILED, it looks like an oversight.Happy to share sanitized log excerpts if useful. Thank you for maintaining the plugin, and I would be glad to help test a fix.
October 17, 2026 at 6:48 am #32387admin
KeymasterThank you. I will apply a fix for this. It will go out with the next release.
-
AuthorPosts
- You must be logged in to reply to this topic.