Skip to content

Commit

Permalink
issue #159 KuveytPos change PartialDrawback to Drawback
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed Apr 23, 2024
1 parent 63eb8cd commit a0bc982
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class KuveytPosRequestDataMapper extends AbstractRequestDataMapper
PosInterface::TX_TYPE_PAY_AUTH => 'Sale',
PosInterface::TX_TYPE_CANCEL => 'SaleReversal',
PosInterface::TX_TYPE_STATUS => 'GetMerchantOrderDetail',
PosInterface::TX_TYPE_REFUND => 'PartialDrawback', // Also there is a "Drawback"
PosInterface::TX_TYPE_REFUND => 'Drawback', // Also there is a "PartialDrawback"
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ public function mapRefundResponse(array $rawResponseData): array
'all' => $rawResponseData,
];

$drawbackResult = $rawResponseData['PartialDrawbackResult'] ?? $rawResponseData['DrawBackResult'];
$value = $drawbackResult['Value'];

$value = $rawResponseData['PartialDrawbackResult']['Value'];
$procReturnCode = $this->getProcReturnCode($value);

if (null === $procReturnCode) {
Expand All @@ -216,7 +217,7 @@ public function mapRefundResponse(array $rawResponseData): array
$status = self::TX_APPROVED;
}

$responseResults = $rawResponseData['PartialDrawbackResult']['Results'];
$responseResults = $drawbackResult['Results'];
if (self::TX_APPROVED !== $status && isset($responseResults['Result']) && [] !== $responseResults['Result']) {
if (isset($responseResults['Result'][0])) {
$responseResult = $responseResults['Result'][0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public static function createRefundRequestDataProvider(): Generator
'UserName' => 'apiuser',
'CardType' => 'Visa',
'BatchID' => 0,
'TransactionType' => 'PartialDrawback',
'TransactionType' => 'Drawback',
'InstallmentCount' => 0,
'Amount' => 101,
'DisplayAmount' => 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,43 @@ public static function refundTestDataProvider(): iterable
'remote_order_id' => '114293626',
],
];

yield 'tdv2_success_full_refund' => [
'responseData' => [
'DrawBackResult' => [
'Results' => [],
'Success' => true,
'Value' => [
'IsEnrolled' => false,
'IsVirtual' => false,
'ProvisionNumber' => '050823',
'RRN' => '411415539590',
'Stan' => '539590',
'ResponseCode' => '00',
'ResponseMessage' => 'OTORİZASYON VERİLDİ',
'OrderId' => 155767855,
'TransactionTime' => '2024-04-23T15:19:15.7471578',
'MerchantOrderId' => '202404229EAC',
'CurrencyCode' => '0949',
'MerchantId' => null,
'BusinessKey' => '202404239999000000013631520',
],
],
],
'expectedData' => [
'auth_code' => '050823',
'currency' => 'TRY',
'error_code' => null,
'error_message' => null,
'order_id' => '202404229EAC',
'proc_return_code' => '00',
'ref_ret_num' => '411415539590',
'remote_order_id' => '155767855',
'status' => 'approved',
'status_detail' => null,
'transaction_id' => '539590',
],
];
yield 'tdv2_success1' => [
'responseData' => [
'PartialDrawbackResult' => [
Expand Down

0 comments on commit a0bc982

Please sign in to comment.