From 3d22e522cd63f75d9da5c053dafbdc24d7c386d8 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" <mjw@mjwconsult.co.uk> Date: Wed, 20 Mar 2019 15:07:31 +0000 Subject: [PATCH] Add a system check for invalid API key --- CRM/Stripe/Utils/Check/Webhook.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/CRM/Stripe/Utils/Check/Webhook.php b/CRM/Stripe/Utils/Check/Webhook.php index 8d076981..27c277b0 100644 --- a/CRM/Stripe/Utils/Check/Webhook.php +++ b/CRM/Stripe/Utils/Check/Webhook.php @@ -25,7 +25,23 @@ class CRM_Stripe_Utils_Check_Webhook { $webhook_path = str_replace('NN', $pp['id'], $webhook_path); \Stripe\Stripe::setApiKey($sk); - $webhooks = \Stripe\WebhookEndpoint::all(["limit" => 100]); + try { + $webhooks = \Stripe\WebhookEndpoint::all(["limit" => 100]); + } + catch (\Stripe\Error\Authentication $e) { + $messages[] = new CRM_Utils_Check_Message( + 'stripe_webhook', + E::ts('The %1 (%2) Payment Processor has an invalid API key', [ + 1 => $pp['name'], + 2 => $pp['id'], + ]), + E::ts('Stripe - API Key'), + \Psr\Log\LogLevel::ERROR, + 'fa-money' + ); + + continue; + } if (empty($webhooks->data)) { $messages[] = new CRM_Utils_Check_Message( -- GitLab