Skip to content

Commit

Permalink
fix issue #207 - estpos undefined ERRORCODE index on refund
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed May 17, 2024
1 parent 4defb5b commit a772331
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ public function mapRefundResponse(array $rawResponseData): array
$status = self::TX_APPROVED;
}

$errorCode = $rawResponseData['Extra']['ERRORCODE'] ?? $rawResponseData['ERRORCODE'];
$errorCode = '' !== $errorCode ? $errorCode : null;

return [
'order_id' => $rawResponseData['OrderId'],
'group_id' => $rawResponseData['GroupId'],
Expand All @@ -270,7 +273,7 @@ public function mapRefundResponse(array $rawResponseData): array
'proc_return_code' => $procReturnCode,
'transaction_id' => $rawResponseData['TransId'],
'num_code' => $rawResponseData['Extra']['NUMCODE'],
'error_code' => $rawResponseData['Extra']['ERRORCODE'],
'error_code' => $errorCode,
'error_message' => $rawResponseData['ErrMsg'],
'status' => $status,
'status_detail' => $this->getStatusDetail($procReturnCode),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1691,40 +1691,77 @@ public static function cancelTestDataProvider(): array

public static function refundTestDataProvider(): array
{
return
[
'fail1' => [
'responseData' => [
'OrderId' => '20221030B3FF',
'GroupId' => '20221030B3FF',
'Response' => 'Error',
'AuthCode' => '',
'HostRefNum' => '',
'ProcReturnCode' => '99',
'TransId' => '22303M8rC11328',
'ErrMsg' => 'Iade yapilamaz, siparis gunsonuna girmemis.',
'Extra' => [
'SETTLEID' => '',
'TRXDATE' => '20221030 12:58:42',
'ERRORCODE' => 'CORE-2508',
'NUMCODE' => '992508',
],
return [
'success1' => [
'responseData' => [
'OrderId' => 'df0e',
'GroupId' => 'dfc36f0e',
'Response' => 'Approved',
'AuthCode' => '46',
'HostRefNum' => '41',
'ProcReturnCode' => '00',
'TransId' => '24138',
'ErrMsg' => '',
'ERRORCODE' => '',
'Extra' => [
'KULLANILANPUAN' => '000000000000',
'CARDBRAND' => 'MASTERCARD',
'CARDHOLDERNAME' => 'ME* DE*',
'TRXDATE' => '20240517 13:30:43',
'KULLANILABILIRPUAN' => '000000005450',
'ACQSTAN' => '74',
'KAZANILANPUAN' => '000000000000',
'TRACEID' => 'e7ba2a6',
'NUMCODE' => '00',
'SETTLEID' => '',
],
'expectedData' => [
'order_id' => '20221030B3FF',
'group_id' => '20221030B3FF',
'auth_code' => null,
'ref_ret_num' => null,
'proc_return_code' => '99',
'transaction_id' => '22303M8rC11328',
'num_code' => '992508',
'error_code' => 'CORE-2508',
'error_message' => 'Iade yapilamaz, siparis gunsonuna girmemis.',
'status' => 'declined',
'status_detail' => 'general_error',
],
'expectedData' => [
'order_id' => 'df0e',
'group_id' => 'dfc36f0e',
'auth_code' => '46',
'ref_ret_num' => '41',
'proc_return_code' => '00',
'transaction_id' => '24138',
'num_code' => '00',
'error_code' => null,
'error_message' => null,
'status' => 'approved',
'status_detail' => 'approved',
],
],
'fail1' => [
'responseData' => [
'OrderId' => '20221030B3FF',
'GroupId' => '20221030B3FF',
'Response' => 'Error',
'AuthCode' => '',
'HostRefNum' => '',
'ProcReturnCode' => '99',
'TransId' => '22303M8rC11328',
'ErrMsg' => 'Iade yapilamaz, siparis gunsonuna girmemis.',
'Extra' => [
'SETTLEID' => '',
'TRXDATE' => '20221030 12:58:42',
'ERRORCODE' => 'CORE-2508',
'NUMCODE' => '992508',
],
],
];
'expectedData' => [
'order_id' => '20221030B3FF',
'group_id' => '20221030B3FF',
'auth_code' => null,
'ref_ret_num' => null,
'proc_return_code' => '99',
'transaction_id' => '22303M8rC11328',
'num_code' => '992508',
'error_code' => 'CORE-2508',
'error_message' => 'Iade yapilamaz, siparis gunsonuna girmemis.',
'status' => 'declined',
'status_detail' => 'general_error',
],
],
];
}

public static function orderHistoryTestDataProvider(): array
Expand Down

0 comments on commit a772331

Please sign in to comment.