From fa43a29ce9d428b5831eb7d51c0b3081ba49f36f Mon Sep 17 00:00:00 2001 From: Elias Luhr Date: Wed, 5 Mar 2025 15:02:36 +0100 Subject: [PATCH] Prevent null access when setting special params The old version only checks if getTransactionParams() is null but not if $paymentType itself is null. If $paymentType is null, the old code would have caused an error (calling method on null). The new version first checks if $paymentType is set and returns an empty array if not. --- src/Services/PaymentService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/PaymentService.php b/src/Services/PaymentService.php index c59cd819..2986f5ca 100755 --- a/src/Services/PaymentService.php +++ b/src/Services/PaymentService.php @@ -150,7 +150,7 @@ public function performCharge(Charge $charge, $paymentType, $customer = null, Me $paymentType = $payment->getPaymentType(); /** @var Charge $charge */ - $charge->setSpecialParams($paymentType->getTransactionParams() ?? []); + $charge->setSpecialParams(is_null($paymentType) ? [] : $paymentType->getTransactionParams()); $payment->addCharge($charge)->setCustomer($customer)->setMetadata($metadata)->setBasket($basket); $this->getResourceService()->createResource($charge);