pronamic / wp-pay-core

Core components for the WordPress payment processing library. This library is used in the WordPress plugin Pronamic Pay: https://www.pronamicpay.com/, but also allows other plugin developers to set up a payment plugin.
https://www.wp-pay.org/
GNU General Public License v3.0
27 stars 3 forks source link

cURL timeout resulting in failed recurring payment #170

Closed rvdsteege closed 7 months ago

rvdsteege commented 7 months ago

In internal Help Scout ticket https://secure.helpscout.net/conversation/2482719794/26765 it came to our attention that the status of a recurring payment can be set to Failure in WordPress, while the actual payment has been paid successfully.

The cause seems to be a cURL timeout on payment start, which is converted from WP_Error to an exception in the pronamic/wp-http library, resulting in the Failure payment status.

https://github.com/pronamic/wp-http/blob/2b0ce3ca663103b8a30101ff5bff9254ee4da093/src/Facades/Http.php#L37-L43

https://github.com/pronamic/wp-pay-core/blob/e484e55c656cec8af3bd9a8ef34914549202cd2e/src/Plugin.php#L1110-L1125

remcotolsma commented 7 months ago

As discussed @pronamic HQ we may want to increase the WordPress HTTP API timeout when dealing with an "Action Scheduler" background task:

$args = [
    'method'     => $method,
    'user-agent' => $this->get_user_agent(),
    'headers'    => [
        'Authorization' => 'Bearer ' . $this->api_key,
    ],
    'timeout'    => \wp_doing_cron() ? 30 : 5,
];

https://github.com/pronamic/wp-mollie/blob/19f65f82ea9ffd3cc9eb71412c5ae7bfd0a93525/src/Client.php#L113-L128

Let us wait a moment for a possible response to the following issue:

remcotolsma commented 7 months ago

Fixed with: