Skip to content
Snippets Groups Projects
Commit 0f779b16 authored by mattwire's avatar mattwire
Browse files

Add check for webhooks stuck in processing status

parent 01432442
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@ class CRM_Mjwshared_Check {
$this->checkIfSeparateMembershipPaymentEnabled();
$this->checkExtensionSweetalert();
$this->checkMultidomainJobs();
$this->checkPaymentprocessorWebhooks();
return $this->messages;
}
......@@ -317,4 +318,43 @@ class CRM_Mjwshared_Check {
}
}
/**
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
private function checkPaymentprocessorWebhooks() {
$paymentprocessorWebhooksProcessingCount = \Civi\Api4\PaymentprocessorWebhook::get(FALSE)
->addSelect('row_count')
->addWhere('status', '=', 'processing')
->addWhere('created_date', '<', 'now-1hour')
->addOrderBy('created_date', 'DESC')
->execute()
->countMatched();
if ($paymentprocessorWebhooksProcessingCount > 0) {
$paymentprocessorWebhookProcessors = \Civi\Api4\PaymentprocessorWebhook::get(FALSE)
->addSelect('id', 'payment_processor_id:label')
->addWhere('status', '=', 'processing')
->addWhere('created_date', '<', 'now-1hour')
->addOrderBy('created_date', 'DESC')
->addGroupBy('payment_processor_id')
->execute()
->indexBy('payment_processor_id:label')
->getArrayCopy();
$message = new CRM_Utils_Check_Message(
__FUNCTION__ . 'mjwshared_paymentprocessorwebhooks',
E::ts('You have %1 payment processor webhooks in "processing" status for %2 payment processors.
This means that the system started processing them but something went wrong that can\'t be fixed automatically.
Please check and identify the problem. Then you can mark them for retry.',
[1 => $paymentprocessorWebhooksProcessingCount, 2 => implode(',', array_keys($paymentprocessorWebhookProcessors))]
),
E::ts('Payment Processor Webhooks: Processing failed'),
\Psr\Log\LogLevel::ERROR,
'fa-code'
);
$message->addAction('Check now', FALSE, 'href', ['path' => 'civicrm/a#/paymentprocessorWebhook']);
$this->messages[] = $message;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment