From eccf41b325d1acdfe4f13a2462c2cf8bef552dc8 Mon Sep 17 00:00:00 2001
From: Matthew Wire <mjw@mjwconsult.co.uk>
Date: Wed, 15 Dec 2021 22:52:55 +0000
Subject: [PATCH] Fix message='null' on successful processing of webhook

---
 CRM/Core/Payment/StripeIPN.php | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/CRM/Core/Payment/StripeIPN.php b/CRM/Core/Payment/StripeIPN.php
index 68de92a2..5c0d943b 100644
--- a/CRM/Core/Payment/StripeIPN.php
+++ b/CRM/Core/Payment/StripeIPN.php
@@ -333,13 +333,17 @@ class CRM_Core_Payment_StripeIPN {
     }
 
     // Record that we have processed this webhook (success or error)
-    PaymentprocessorWebhook::update(FALSE)
+    $paymentProcessorWebhookUpdate = PaymentprocessorWebhook::update(FALSE)
       ->addWhere('event_id', '=', $this->getEventID())
       ->addWhere('trigger', '=', $this->getEventType())
       ->addValue('status', $return->ok ? 'success' : 'error')
-      ->addValue('message', preg_replace('/^(.{250}).*/su', '$1 ...', $return->message))
-      ->addValue('processed_date', 'now')
-      ->execute();
+      ->addValue('processed_date', 'now');
+
+    // Only add message if not empty
+    if (!empty($return->message)) {
+      $paymentProcessorWebhookUpdate->addValue('message', preg_replace('/^(.{250}).*/su', '$1 ...', $return->message));
+    }
+    $paymentProcessorWebhookUpdate->execute();
 
     return $return;
   }
-- 
GitLab