Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cURL timeout resulting in failed recurring payment #170

Closed
rvdsteege opened this issue Jan 18, 2024 · 2 comments
Closed

cURL timeout resulting in failed recurring payment #170

rvdsteege opened this issue Jan 18, 2024 · 2 comments
Assignees

Comments

@rvdsteege
Copy link
Member

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

wp-pay-core/src/Plugin.php

Lines 1110 to 1125 in e484e55

$gateway->start( $payment );
} catch ( \Exception $exception ) {
$message = $exception->getMessage();
// Maybe include error code in message.
$code = $exception->getCode();
if ( $code > 0 ) {
$message = \sprintf( '%s: %s', $code, $message );
}
$payment->add_note( $message );
$payment->set_status( PaymentStatus::FAILURE );
throw $exception;

@remcotolsma
Copy link
Member

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 added a commit to pronamic/wp-mollie that referenced this issue Jan 22, 2024
@remcotolsma
Copy link
Member

Fixed with:

  • <?php
    /**
    * Action Scheduler Controller
    *
    * @author Pronamic <[email protected]>
    * @copyright 2005-2023 Pronamic
    * @license GPL-3.0-or-later
    * @package Pronamic\WordPress\Pay
    */
    namespace Pronamic\WordPress\Pay;
    /**
    * Action Scheduler Controller class
    */
    class ActionSchedulerController {
    /**
    * Setup.
    *
    * @return void
    */
    public function setup() {
    \add_action( 'action_scheduler_begin_execute', [ $this, 'begin_execute' ], 10, 2 );
    }
    /**
    * Action scheduler begin execute.
    *
    * @link https://github.com/woocommerce/action-scheduler/blob/3.7.1/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php#L84
    * @param int $action_id Action ID.
    * @param string $context Context.
    * @return void
    */
    public function begin_execute( $action_id, $context ) {
    if ( \defined( 'PRONAMIC_ACTION_SCHEDULER_CONTEXT' ) ) {
    return;
    }
    \define( 'PRONAMIC_ACTION_SCHEDULER_CONTEXT', $context );
    }
    }
  • https://github.com/pronamic/wp-mollie/blob/13bfb8f77bb4333c975e45093b19ffb2771d0c82/src/Client.php#L102-L147

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Status: Done
Development

No branches or pull requests

2 participants