Skip to content

Commit

Permalink
Merge branch 'master' into refactoring-05
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed May 17, 2024
2 parents 4a360fa + bd0d8ec commit ff28db9
Show file tree
Hide file tree
Showing 10 changed files with 304 additions and 78 deletions.
7 changes: 0 additions & 7 deletions examples/payten/_payment_config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

use Mews\Pos\Entity\Card\CreditCardInterface;

require __DIR__.'/../_main_config.php';

$bankTestsUrl = $hostUrl.'/payten';
Expand All @@ -14,31 +12,27 @@
'month' => '12',
'cvv' => '000',
'name' => 'John Doe',
'type' => CreditCardInterface::CARD_TYPE_VISA,
],
'visaZiraat' => [
'number' => '4546711234567894',
'year' => '26',
'month' => '12',
'cvv' => '000',
'name' => 'John Doe',
'type' => CreditCardInterface::CARD_TYPE_VISA,
],
'masterZiraat' => [
'number' => '5401341234567891',
'year' => '26',
'month' => '12',
'cvv' => '000',
'name' => 'John Doe',
'type' => CreditCardInterface::CARD_TYPE_MASTERCARD,
],
'visa1' => [
'number' => '4546711234567894',
'year' => '26',
'month' => '12',
'cvv' => '000',
'name' => 'John Doe',
'type' => CreditCardInterface::CARD_TYPE_VISA,
],
'visa_isbank_imece' => [
/**
Expand All @@ -52,6 +46,5 @@
'month' => '10',
'cvv' => '123',
'name' => 'John Doe',
'type' => CreditCardInterface::CARD_TYPE_VISA,
],
];
9 changes: 0 additions & 9 deletions src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ class EstPosRequestDataMapper extends AbstractRequestDataMapper
PosInterface::TX_TYPE_HISTORY => 'ORDERHISTORY',
];

/**
* {@inheritdoc}
*/
protected array $cardTypeMapping = [
CreditCardInterface::CARD_TYPE_VISA => '1',
CreditCardInterface::CARD_TYPE_MASTERCARD => '2',
];

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -289,7 +281,6 @@ protected function create3DFormDataCommon(AbstractPosAccount $posAccount, array
];

if ($creditCard instanceof CreditCardInterface) {
$inputs['cardType'] = $this->cardTypeMapping[$creditCard->getType()];
$inputs['pan'] = $creditCard->getNumber();
$inputs['Ecom_Payment_Card_ExpDate_Month'] = $creditCard->getExpireMonth(self::CREDIT_CARD_EXP_MONTH_FORMAT);
$inputs['Ecom_Payment_Card_ExpDate_Year'] = $creditCard->getExpireYear(self::CREDIT_CARD_EXP_YEAR_FORMAT);
Expand Down
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
2 changes: 0 additions & 2 deletions src/Gateways/EstPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

/**
* Implementation of Payten Payment Gateway
* todo cardType verisi dokumantasyona gore kontrol edilmesi gerekiyor.
* cardType gondermeden de su an calisiyor.
*
* @deprecated use Mews\Pos\Gateways\EstV3Pos.
* For security reasons this class which uses sha1 hashing algorithm is not recommended to use.
Expand Down
4 changes: 0 additions & 4 deletions src/Gateways/VakifKatilimPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,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
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ public static function threeDFormDataProvider(): array
'taksit' => '',
'islemtipi' => 'Auth',
'hash' => 'TN+2/D8lijFd+5zAUar6SH6EiRY=',
'cardType' => '1',
'pan' => '5555444433332222',
'Ecom_Payment_Card_ExpDate_Month' => '01',
'Ecom_Payment_Card_ExpDate_Year' => '22',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public static function threeDFormDataProvider(): array
'TranType' => 'Auth',
'hashAlgorithm' => 'ver3',
'hash' => '3fvBzh0HT3UiKUTXis0Ke2NG3mAp9eBOwx26bstv+l6L946GrOF2JklXfqTNc6VBeqUSkuLxo4ErtwCWuPCzYw==',
'cardType' => '1',
'pan' => '5555444433332222',
'Ecom_Payment_Card_ExpDate_Month' => '01',
'Ecom_Payment_Card_ExpDate_Year' => '22',
Expand Down
Loading

0 comments on commit ff28db9

Please sign in to comment.