diff --git a/api/v3/StripePaymentintent.php b/api/v3/StripePaymentintent.php
index bce18020ceef908cf0fa7f9cec21956980244727..6ce7dd0e9fd44d655ebece1b3d03113745fe0154 100644
--- a/api/v3/StripePaymentintent.php
+++ b/api/v3/StripePaymentintent.php
@@ -171,6 +171,7 @@ function civicrm_api3_stripe_paymentintent_process($params) {
     _civicrm_api3_stripe_paymentintent_returnInvalid();
   }
 
+  $referrer = $_SERVER['HTTP_REFERER'] ?? '';
   $title = CRM_Utils_Type::validate($params['description'], 'String');
   $intentParams['confirm'] = TRUE;
   $currency = CRM_Utils_Type::validate($params['currency'], 'String', CRM_Core_Config::singleton()->defaultCurrency);
@@ -227,7 +228,7 @@ function civicrm_api3_stripe_paymentintent_process($params) {
         'payment_processor_id' => $paymentProcessorID,
         'status' => 'failed',
         'description' => "{$e->getRequestId()};{$e->getMessage()};{$title}",
-        'referrer' => $_SERVER['HTTP_REFERER'],
+        'referrer' => $referrer,
       ];
       isset($params['extra_data']) ? $stripePaymentintentParams['extra_data'] = $params['extra_data'] : NULL;
       CRM_Stripe_BAO_StripePaymentintent::create($stripePaymentintentParams);
@@ -251,7 +252,7 @@ function civicrm_api3_stripe_paymentintent_process($params) {
     'payment_processor_id' => $paymentProcessorID,
     'status' => $intent->status,
     'description' => "{$title}",
-    'referrer' => $_SERVER['HTTP_REFERER'],
+    'referrer' => $referrer,
   ];
   isset($params['extra_data']) ? $stripePaymentintentParams['extra_data'] = $params['extra_data'] : NULL;
   CRM_Stripe_BAO_StripePaymentintent::create($stripePaymentintentParams);
diff --git a/tests/phpunit/CRM/Stripe/BaseTest.php b/tests/phpunit/CRM/Stripe/BaseTest.php
index b9af70ad8f120fbcec909d193b5a1b0aef392d8e..ef2ff98a5ced27543d91a7b86a4d26f07f8bf5cb 100644
--- a/tests/phpunit/CRM/Stripe/BaseTest.php
+++ b/tests/phpunit/CRM/Stripe/BaseTest.php
@@ -197,7 +197,7 @@ class CRM_Stripe_BaseTest extends \PHPUnit\Framework\TestCase implements Headles
     $processor->setAPIParams();
 
     try {
-      $processor->stripeClient->charges->retrieve(["id" => $this->trxn_id]);
+      $processor->stripeClient->charges->retrieve($this->trxn_id);
       $found = TRUE;
     }
     catch (Exception $e) {