From dcf9304f0add9aaceb00e9720b52e7047407581f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89bano=20Lopes?= Date: Thu, 15 Feb 2024 20:42:18 +0000 Subject: [PATCH] MS-272: Panini America - Multiple Transaction API calls --- lib/Models/Payment/Authorizenet.php | 16 ++++++++-------- lib/Models/Payment/Braintree.php | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/Models/Payment/Authorizenet.php b/lib/Models/Payment/Authorizenet.php index 7285430..950978f 100644 --- a/lib/Models/Payment/Authorizenet.php +++ b/lib/Models/Payment/Authorizenet.php @@ -6,7 +6,7 @@ class Authorizenet extends AbstractGateway { - protected $response = ''; + protected $response = []; /** * @var string[] @@ -22,7 +22,7 @@ class Authorizenet extends AbstractGateway */ public function fetchData($transactionId, $orderId) { - if (empty($this->response)) { + if (isset($this->response[$orderId]) === false) { $request = [ "getTransactionDetailsRequest" => [ "merchantAuthentication" => [ @@ -52,7 +52,7 @@ public function fetchData($transactionId, $orderId) $response = curl_exec($curl); $info = json_decode(preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $response), true); - $this->response = new \Signifyd\Models\Payment\Response\Authorizenet(); + $this->response[$orderId] = new \Signifyd\Models\Payment\Response\Authorizenet(); if (isset($info['transaction']) && isset($info['transaction']['billTo']) && @@ -60,7 +60,7 @@ public function fetchData($transactionId, $orderId) isset($info['transaction']['billTo']['lastName']) ) { $holderName = $info['transaction']['billTo']['firstName'] . " " . $info['transaction']['billTo']['lastName']; - $this->response->setCardholder($holderName); + $this->response[$orderId]->setCardholder($holderName); } if (isset($info['transaction']) && @@ -69,24 +69,24 @@ public function fetchData($transactionId, $orderId) isset($info['transaction']['payment']['creditCard']['cardNumber']) ) { $last4 = substr($info['transaction']['payment']['creditCard']['cardNumber'], -4); - $this->response->setLast4($last4); + $this->response[$orderId]->setLast4($last4); } if (isset($info['transaction']) && isset($info['transaction']['AVSResponse']) ) { $avs = $info['transaction']['AVSResponse']; - $this->response->setAvs($avs); + $this->response[$orderId]->setAvs($avs); } if (isset($info['transaction']) && isset($info['transaction']['cardCodeResponse']) ) { $cvv = $info['transaction']['cardCodeResponse']; - $this->response->setCvv($cvv); + $this->response[$orderId]->setCvv($cvv); } } - return $this->response; + return $this->response[$orderId]; } } diff --git a/lib/Models/Payment/Braintree.php b/lib/Models/Payment/Braintree.php index f68caa3..902e125 100644 --- a/lib/Models/Payment/Braintree.php +++ b/lib/Models/Payment/Braintree.php @@ -6,7 +6,7 @@ class Braintree extends \Signifyd\Models\Payment\AbstractGateway { - protected $response = ''; + protected $response = []; /** * @var string[] @@ -23,7 +23,7 @@ class Braintree extends \Signifyd\Models\Payment\AbstractGateway */ public function fetchData($transactionId, $orderId) { - if (empty($this->response)) { + if (isset($this->response[$orderId]) === false) { $requestArr = [ 'query' => 'query Search($input: PaymentSearchInput!) { search { @@ -93,7 +93,7 @@ public function fetchData($transactionId, $orderId) curl_close($ch); $info = json_decode(preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $serverOutput), true); - $this->response = new BraintreeResponse(); + $this->response[$orderId] = new BraintreeResponse(); if (isset($info['data']) && isset($info['data']['search']) && @@ -105,7 +105,7 @@ public function fetchData($transactionId, $orderId) isset($info['data']['search']['payments']['edges'][0]['node']['paymentMethodSnapshot']['last4']) ) { $last4 = $info['data']['search']['payments']['edges'][0]['node']['paymentMethodSnapshot']['last4']; - $this->response->setLast4($last4); + $this->response[$orderId]->setLast4($last4); } if (isset($info['data']) && @@ -119,7 +119,7 @@ public function fetchData($transactionId, $orderId) ) { $bin = $info['data']['search']['payments']['edges'][0]['node']['paymentMethodSnapshot']['bin']; - $this->response->setBin($bin); + $this->response[$orderId]->setBin($bin); } if (isset($info['data']) && @@ -133,7 +133,7 @@ public function fetchData($transactionId, $orderId) ) { $expirationMonth = $info['data']['search']['payments']['edges'][0]['node']['paymentMethodSnapshot']['expirationMonth']; - $this->response->setExpiryMonth($expirationMonth); + $this->response[$orderId]->setExpiryMonth($expirationMonth); } if (isset($info['data']) && @@ -147,7 +147,7 @@ public function fetchData($transactionId, $orderId) ) { $expirationYear = $info['data']['search']['payments']['edges'][0]['node']['paymentMethodSnapshot']['expirationYear']; - $this->response->setExpiryYear($expirationYear); + $this->response[$orderId]->setExpiryYear($expirationYear); } if (isset($info['data']) && @@ -160,7 +160,7 @@ public function fetchData($transactionId, $orderId) isset($info['data']['search']['payments']['edges'][0]['node']['paymentMethodSnapshot']['cardholderName']) ) { $cardholderName = $info['data']['search']['payments']['edges'][0]['node']['paymentMethodSnapshot']['cardholderName']; - $this->response->setCardholder($cardholderName); + $this->response[$orderId]->setCardholder($cardholderName); } if (isset($info['data']) && @@ -175,7 +175,7 @@ public function fetchData($transactionId, $orderId) isset($info['data']['search']['payments']['edges'][0]['node']['statusHistory'][0]['processorResponse']['cvvResponse']) ) { $cvvResponse = $info['data']['search']['payments']['edges'][0]['node']['statusHistory'][0]['processorResponse']['cvvResponse']; - $this->response->setCvv($cvvResponse); + $this->response[$orderId]->setCvv($cvvResponse); } if (isset($info['data']) && @@ -193,10 +193,10 @@ public function fetchData($transactionId, $orderId) $avsPostalCodeResponse = $info['data']['search']['payments']['edges'][0]['node']['statusHistory'][0]['processorResponse']['avsPostalCodeResponse']; $avsStreetAddressResponse = $info['data']['search']['payments']['edges'][0]['node']['statusHistory'][0]['processorResponse']['avsStreetAddressResponse']; - $this->response->setAvsResponse($avsPostalCodeResponse, $avsStreetAddressResponse); + $this->response[$orderId]->setAvsResponse($avsPostalCodeResponse, $avsStreetAddressResponse); } } - return $this->response; + return $this->response[$orderId]; } }