Skip to content

Commit

Permalink
Merge pull request #208 from mewebstudio/207-estpos-undefined-array-k…
Browse files Browse the repository at this point in the history
…ey-authcode

207 estpos undefined array key authcode
  • Loading branch information
nuryagdym authored May 17, 2024
2 parents e173399 + 5d94ebb commit 54a6286
Show file tree
Hide file tree
Showing 5 changed files with 304 additions and 58 deletions.
42 changes: 31 additions & 11 deletions src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function mapPaymentResponse(array $rawPaymentResponseData, string $txType
'group_id' => $rawPaymentResponseData['GroupId'],
'transaction_id' => $rawPaymentResponseData['TransId'],
'transaction_time' => self::TX_APPROVED === $status ? new \DateTimeImmutable($extra['TRXDATE']) : null,
'auth_code' => $rawPaymentResponseData['AuthCode'],
'auth_code' => $rawPaymentResponseData['AuthCode'] ?? null,
'ref_ret_num' => $rawPaymentResponseData['HostRefNum'],
'proc_return_code' => $procReturnCode,
'status' => $status,
Expand Down Expand Up @@ -262,20 +262,30 @@ public function mapRefundResponse(array $rawResponseData): array
$status = self::TX_APPROVED;
}

return [
$result = [
'order_id' => $rawResponseData['OrderId'],
'group_id' => $rawResponseData['GroupId'],
'auth_code' => $rawResponseData['AuthCode'],
'group_id' => null,
'auth_code' => null,
'ref_ret_num' => $rawResponseData['HostRefNum'],
'proc_return_code' => $procReturnCode,
'transaction_id' => $rawResponseData['TransId'],
'num_code' => $rawResponseData['Extra']['NUMCODE'],
'error_code' => $rawResponseData['Extra']['ERRORCODE'],
'num_code' => null,
'error_code' => null,
'error_message' => $rawResponseData['ErrMsg'],
'status' => $status,
'status_detail' => $this->getStatusDetail($procReturnCode),
'all' => $rawResponseData,
];

if (self::TX_APPROVED === $status) {
$result['group_id'] = $rawResponseData['GroupId'];
$result['auth_code'] = $rawResponseData['AuthCode'];
$result['num_code'] = $rawResponseData['Extra']['NUMCODE'];
} else {
$result['error_code'] = $rawResponseData['Extra']['ERRORCODE'] ?? $rawResponseData['ERRORCODE'] ?? null;
}

return $result;
}

/**
Expand Down Expand Up @@ -305,20 +315,30 @@ public function mapCancelResponse(array $rawResponseData): array
];
}

return [
$result = [
'order_id' => $rawResponseData['OrderId'],
'group_id' => $rawResponseData['GroupId'],
'auth_code' => $rawResponseData['AuthCode'],
'group_id' => null,
'auth_code' => null,
'ref_ret_num' => $rawResponseData['HostRefNum'],
'proc_return_code' => $procReturnCode,
'transaction_id' => $rawResponseData['TransId'],
'error_code' => $rawResponseData['Extra']['ERRORCODE'],
'num_code' => $rawResponseData['Extra']['NUMCODE'],
'error_code' => null,
'num_code' => null,
'error_message' => $rawResponseData['ErrMsg'],
'status' => $status,
'status_detail' => $this->getStatusDetail($procReturnCode),
'all' => $rawResponseData,
];

if (self::TX_APPROVED === $status) {
$result['group_id'] = $rawResponseData['GroupId'];
$result['auth_code'] = $rawResponseData['AuthCode'];
$result['num_code'] = $rawResponseData['Extra']['NUMCODE'];
} else {
$result['error_code'] = $rawResponseData['Extra']['ERRORCODE'] ?? $rawResponseData['ERRORCODE'] ?? null;
}

return $result;
}

/**
Expand Down
4 changes: 0 additions & 4 deletions src/Gateways/VakifKatilimPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,6 @@ private function getRequestURIByTransactionType(string $txType, string $paymentM
PosInterface::TX_TYPE_HISTORY => 'SelectOrder',
];

if (!isset($arr[$txType])) {
throw new UnsupportedTransactionTypeException();
}

if (\is_string($arr[$txType])) {
return $arr[$txType];
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/EstV3PosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThro
$this->card
);

$this->assertTrue($this->pos->isSuccess());

$response = $this->pos->getResponse();
$this->assertTrue($this->pos->isSuccess(), $response['error_message'] ?? null);

$this->assertIsArray($response);
$this->assertNotEmpty($response);
$this->assertTrue($eventIsThrown);
Expand Down
Loading

0 comments on commit 54a6286

Please sign in to comment.