Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact

[Resolved] PAYMENT.SALE.COMPLETED is lost permanently when the PayPal API call fails

Simple Membership Plugin › Forums › Simple Membership Plugin › PAYMENT.SALE.COMPLETED is lost permanently when the PayPal API call fails

  • This topic has 1 reply, 2 voices, and was last updated 1 month ago by admin.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • October 16, 2026 at 10:43 am #32382
    freetiermorioka555
    Participant

    ## Summary

    When a PAYMENT.SALE.COMPLETED webhook arrives, the plugin makes an additional PayPal API call to fetch subscription details. If that call fails, the payment is not recorded, and because the webhook endpoint still returns HTTP 200, PayPal does not retry. The payment record is then lost permanently. The same pattern applies to webhook signature verification.

    ## 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 type pp_subscription_new), REST webhooks

    ## What happens

    1. handle_subscription_payment_received() receives the webhook, then calls the PayPal API (get_paypal_subscription_details()) and builds the payment data from that response.
    2. If this API call fails, the code logs one line and returns. Nothing is written to the payments table.
    3. handle_paypal_webhook() always ends with status_header(200), so PayPal considers the event delivered and does not resend it.
    4. Signature verification has a similar issue. verify_webhook_event_for_given_mode() returns false both when PayPal answers with a verification_status other than SUCCESS, and when the verification API call could not be completed at all. The caller returns 200 and discards the event in both cases. The second case is likely a legitimate notification, and it loses its chance of being redelivered.
    5. SWPM_PayPal_Request_API::get() and post() do not set a timeout, so the WordPress default of 5 seconds applies. By contrast, send_request_by_url_and_args() sets 30 seconds explicitly for token requests. This difference makes the failures above more likely when the PayPal API is slow.
    6. In my observation, during periods when the PayPal API was degraded, signature verification failures and subscription-detail failures occurred together within the same minutes, and payment notifications received in those periods were left unrecorded. This happened on several occasions.
    7. One more point: create_ipn_data_from_paypal_api_subscription_details_data() returns false for invalid data, but I could not find a check of that return value in the caller. I may be missing something, but it looks unchecked.

    ## Where in the code (line numbers are for 4.7.2)

    – lib/paypal/class-swpm-paypal-webhook-event-handler.php, handle_subscription_payment_received() — early return after a failed API call (around lines 203-205).
    – lib/paypal/class-swpm-paypal-webhook-event-handler.php, handle_paypal_webhook() — the verification failure path (lines 38-41) and the final status_header(200).
    – lib/paypal/class-swpm-paypal-webhook-event-handler.php, verify_webhook_event_for_given_mode() — both outcomes collapse to false.
    – lib/paypal/class-swpm-paypal-request-api.php — get() (line 172) and post() (line 237) set no timeout; send_request_by_url_and_args() (line 378) uses 30 seconds.
    – create_ipn_data_from_paypal_api_subscription_details_data() — return value not checked by the caller.

    ## Why this matters

    A temporary network or PayPal API problem is enough to make a real payment disappear from the site’s records, with no retry. This affects payment history and anything that depends on it, including any logic that looks at the date of the last successful payment.

    ## Suggested fix

    – Set an explicit timeout in get() and post(). 30 seconds, as already used for token requests, seems a natural choice.
    – As a fallback when the API lookup fails, it may be possible to store the transaction from the webhook data alone. The resource of PAYMENT.SALE.COMPLETED contains id (the transaction ID), amount.total, and billing_agreement_id, which looks sufficient to record the payment. Member name and email could be filled in by looking up the member record via the subscriber ID.
    – For signature verification, consider distinguishing “PayPal rejected the event” from “verification could not be performed”, and returning a 5xx status in the second case so that PayPal retries delivery.
    – Check the return value of create_ipn_data_from_paypal_api_subscription_details_data() before using it.

    Happy to share sanitized log excerpts if useful. Thank you for your work on the plugin, and I would be glad to help test a fix.

    October 17, 2026 at 6:49 am #32388
    admin
    Keymaster

    Thank you. I have applied a fix. It will go out with the next release.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy