WordPress EDD and pending payments

Hi there. I have a Wordpress website running Easy Digital Downloads with payments taken via Stripe. I have the Cloudflare plugin active and APO switched on.

THE ISSUE
My issue is that the first someone hits the ‘place order’ button on the website they are shown an error message saying the payment didn’t go through, even though the money IS taken by Stripe. The second time they hit the button, despite nothing else changing, they are sent to order confirmation page and a second amount is taken by Stripe.

DEBUGGING
On inspection in the console window I can see the flurry of network requests to /wp-admin/admin-ajax.php when the ‘place order’ button is pressed. However one of these calls is returning a 500 error, hence why an error message is show.

The transaction is recorded in EDD and marked as ‘pending’ but not completed.

I disabled Cloudflare entirely (using the switch to debugging mode in the Cloudflare interface) and the issue goes away - payments come through first time.

So I thought, let’s just create a page rule in Cloudflare to disable caching for that entire section of the website and admin-ajax.php. Sadly this had no impact, and the first payment failed again.

QUESTIONS

  • Why would the site return a 500 error when caching is turned on? There must be something in Cloudflare blocking this admin-ajax.php call and causing to site to return a 500 error.

  • Why would a page rule to prevent caching not solve this?

  • Why does it work the second time someone presses the place order button?

I’ve spent days debugging this but it just feels like it must be something at Cloudflare’s end because when I disable Cloudflare entirely it works fine.

Any help much appreciated and right now I’m having to refund every single customer but still paying Stripe fees for the transactions.

1 Like

Hi. Please could any members of Cloudflare support help with this? Stripe are threatening to freeze my account due to the high number of refunds.

Please help me understand why the payment pages on my website in a subfolder are causing issues even when I have a page rule set up like so:

my domain.com/subfolder/*

As a reminder, when I disable Cloudflare entirely this issue goes away. I’ve checked my Wordpress error logs and they don’t give any indication why an error is being returned.

Can the Cloudflare logs we check at all?

Thanks

Check your firewall rules and logs of cloudflare. Like is there any block for the /wp-admin/admin-ajax.php

Thanks for the respond but sadly not. admin-ajax.php not only has a rule to disable security for it, but the confirmation page sends a couple of requests to it during checkout. It’s only one which gets blocked.

Added to this, mydomain.com/subfolder/* should be stopping any pages in the subfolder being cached, including mydomain.com/subfolder/wp-admin/admin-ajax.php (wordpress is installed in the subdirectory.

Below is a screenshot of the call to admin-ajax.php. The cf-cache-status: DYNAMIC would indicate this request is bypassing the cache, correct? But the 500 error response is ‘There has been a critical error on this website’. I’m not sure where I can go to get more information about this error message, as nothing is showing in the logs.

I have the following in wp-config.php so errors should appear in the error log if there were any.

@ini_set(‘log_errors’, ‘On’);

@ini_set(‘display_errors’, 0);
define(‘WP_DEBUG’, true);
define(‘WP_DEBUG_LOG’, true);
define(‘WP_DEBUG_DISPLAY’, false);

Further update. I created a Worker to add the following header to all requests going through mydomain.com/subfolder

response.headers.set("cf-edge-cache", "no-cache");

This has fixed the issue.

So it appears that APO and edge caching does not play nicely with Wordpress. I thought my page rules would stop edge caching as the cf-cache-status was set to DYNAMIC, but the edge was still in some way blocking this call and resulting in the error.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.