From c93529d300e136170e0acaab990a4389f0b18a7c Mon Sep 17 00:00:00 2001
From: Matthew Wire <mjw@mjwconsult.co.uk>
Date: Mon, 21 Nov 2022 13:27:46 +0000
Subject: [PATCH] Fix missing error handler

---
 CRM/Stripe/BAO/StripeCustomer.php                      | 6 +++---
 CRM/Stripe/Customer.php                                | 3 ++-
 Civi/Api4/Action/StripePaymentintent/ProcessPublic.php | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/CRM/Stripe/BAO/StripeCustomer.php b/CRM/Stripe/BAO/StripeCustomer.php
index 76c34679..5c81b3ec 100644
--- a/CRM/Stripe/BAO/StripeCustomer.php
+++ b/CRM/Stripe/BAO/StripeCustomer.php
@@ -75,9 +75,9 @@ class CRM_Stripe_BAO_StripeCustomer extends CRM_Stripe_DAO_StripeCustomer {
       $stripeCustomer = $stripe->stripeClient->customers->update($stripeCustomerID, $stripeCustomerParams);
     }
     catch (Exception $e) {
-      $err = CRM_Core_Payment_Stripe::parseStripeException('create_customer', $e, FALSE);
-      $errorMessage = $stripe->handleErrorNotification($err, $params['error_url']);
-      throw new \Civi\Payment\Exception\PaymentProcessorException('Failed to update Stripe Customer: ' . $errorMessage);
+      $err = CRM_Core_Payment_Stripe::parseStripeException('create_customer', $e);
+      \Civi::log('stripe')->error('Failed to create Stripe Customer: ' . $err['message'] . '; ' . print_r($err, TRUE));
+      throw new \Civi\Payment\Exception\PaymentProcessorException('Failed to update Stripe Customer: ' . $err['code']);
     }
     return $stripeCustomer;
   }
diff --git a/CRM/Stripe/Customer.php b/CRM/Stripe/Customer.php
index 443f3d1f..2b1d84ac 100644
--- a/CRM/Stripe/Customer.php
+++ b/CRM/Stripe/Customer.php
@@ -113,7 +113,8 @@ class CRM_Stripe_Customer {
       $stripeCustomer = $stripe->stripeClient->customers->create($stripeCustomerParams);
     }
     catch (Exception $e) {
-      $err = CRM_Core_Payment_Stripe::parseStripeException('create_customer', $e, FALSE);
+      $err = CRM_Core_Payment_Stripe::parseStripeException('create_customer', $e);
+      \Civi::log('stripe')->error('Failed to create Stripe Customer: ' . $err['message'] . '; ' . print_r($err, TRUE));
       throw new PaymentProcessorException('Failed to create Stripe Customer: ' . $err['code']);
     }
 
diff --git a/Civi/Api4/Action/StripePaymentintent/ProcessPublic.php b/Civi/Api4/Action/StripePaymentintent/ProcessPublic.php
index c8034e6a..f6683953 100644
--- a/Civi/Api4/Action/StripePaymentintent/ProcessPublic.php
+++ b/Civi/Api4/Action/StripePaymentintent/ProcessPublic.php
@@ -117,7 +117,7 @@ class ProcessPublic extends \Civi\Api4\Generic\AbstractAction {
       $moneyAmount = Money::of($this->amount, $this->currency, new DefaultContext(), RoundingMode::CEILING);
       $moneyMinAmount = Money::of($minAmount, $this->currency, new DefaultContext(), RoundingMode::CEILING);
       if ($moneyAmount->isLessThan($moneyMinAmount)) {
-        \Civi::log('stripe')->error(__CLASS__ . 'amount: ' . $this->amount . ' is less than min_amount: ' . $minAmount);
+        \Civi::log('stripe')->error('StripeProcessintent: ' . 'amount: ' . $this->amount . ' is less than min_amount: ' . $minAmount);
         throw new \CRM_Core_Exception('Bad request');
       }
     }
-- 
GitLab