Skip to content

Commit

Permalink
MS-272: Panini America - Multiple Transaction API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ebanolopes committed Feb 15, 2024
1 parent fef02ef commit dcf9304
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions lib/Models/Payment/Authorizenet.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Authorizenet extends AbstractGateway
{
protected $response = '';
protected $response = [];

/**
* @var string[]
Expand All @@ -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" => [
Expand Down Expand Up @@ -52,15 +52,15 @@ 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']) &&
isset($info['transaction']['billTo']['firstName']) &&
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']) &&
Expand All @@ -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];
}
}
22 changes: 11 additions & 11 deletions lib/Models/Payment/Braintree.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Braintree extends \Signifyd\Models\Payment\AbstractGateway
{
protected $response = '';
protected $response = [];

/**
* @var string[]
Expand All @@ -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 {
Expand Down Expand Up @@ -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']) &&
Expand All @@ -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']) &&
Expand All @@ -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']) &&
Expand All @@ -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']) &&
Expand All @@ -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']) &&
Expand All @@ -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']) &&
Expand All @@ -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']) &&
Expand All @@ -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];
}
}

0 comments on commit dcf9304

Please sign in to comment.