strangerstudios / paid-memberships-pro

The Trusted Membership Platform That Grows with You: Restrict access to content and charge recurring subscriptions using Stripe, PayPal, and more. Fully open source. 100% GPL.
https://www.paidmembershipspro.com
Other
470 stars 359 forks source link

Feature Request: Have a way to recover "missed" orders from IPN or Web Hook malfunctions #889

Open greathmaster opened 5 years ago

greathmaster commented 5 years ago

Recurring orders are sometimes missed due to IPN or web hook malfunction. This can cause major issues with reporting and statistics. Some gateways such as Stripe do not allow you to resend Webhook notifications to recover the order data. Instead they have a Events API for you can access prior Webhook data. PayPal does allow you to resend the IPN but it is for a limited amount of time. We should also consider adding a check for expected recurring orders, and inform the admin if we don't find them.

ideadude commented 3 years ago
  1. Hook into pmpro_doing_webhook and save an option called pmpro_stripe_webhook_last_processed with the timestamp as the value. (Maybe set that option deeper in the Stripe webhook handler and specifically save info on each event type.)

  2. Add a check on admin_notices that checks if you are on the ?page=pmpro page and looks for a recent order (David to follow with the psuedocode algirthm)

dparker1005 commented 3 years ago

What I'm thinking is that we do a query that counts the PMPro orders that:

  1. Are through Stripe
  2. Have subscription transaction ID
  3. Are older than 1 hour
  4. Happened since the last webhook was received from Stripe (maybe +1 minute to account for recurring orders being created)

If any orders fit that description, show webhook warning

ideadude commented 3 years ago

We are now keeping track of the last webhook time for Stripe in the 2.6 branch.

We'd like to do this for all gateways.

And the original issue here also wanted to find missing orders and synchronize them as well.

I'm going to change this milestone to "future versions" as we continue working on this related work.