From 53a56379a235de516a6c055fe1144e6accc8a403 Mon Sep 17 00:00:00 2001
From: Matthew Wire <mjw@mjwconsult.co.uk>
Date: Fri, 23 Jun 2023 12:49:22 +0100
Subject: [PATCH] Fix StripeCheckout error when lineitem label is not set

---
 CRM/Core/Payment/StripeCheckout.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/CRM/Core/Payment/StripeCheckout.php b/CRM/Core/Payment/StripeCheckout.php
index 5e051366..200b9cf1 100644
--- a/CRM/Core/Payment/StripeCheckout.php
+++ b/CRM/Core/Payment/StripeCheckout.php
@@ -266,7 +266,8 @@ class CRM_Core_Payment_StripeCheckout extends CRM_Core_Payment_Stripe {
             'unit_amount' => $this->getAmountFormattedForStripeAPI(PropertyBag::cast(['amount' => $lineItem['unit_price'], 'currency' => $propertyBag->getCurrency()])),
             'product_data' => [
               'name' => $lineItem['field_title'],
-              'description' => $lineItem['label'],
+              // An empty label on a contribution page amounts configuration gives an empty $lineItem['label']. StripeCheckout needs it set.
+              'description' => $lineItem['label'] ?: $lineItem['field_title'],
               //'images' => ['https://example.com/t-shirt.png'],
             ],
           ],
-- 
GitLab