Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

239 ziraat estpos mderrormsg bulunmadi #240

Merged
merged 7 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ij_php_align_phpdoc_comments = true
ij_php_space_after_type_cast = true
ij_php_concat_spaces = false
ij_php_phpdoc_param_spaces_between_tag_and_type = 1
ij_php_comma_after_last_array_element = true

[*.md]
max_line_length = 80
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ class KuveytPosRequestDataMapper extends AbstractRequestDataMapper
PosInterface::CURRENCY_TRY => '0949',
PosInterface::CURRENCY_USD => '0840',
PosInterface::CURRENCY_EUR => '0978',
PosInterface::CURRENCY_GBP => '0826',
PosInterface::CURRENCY_JPY => '0392',
PosInterface::CURRENCY_RUB => '0810',
];

/** @var KuveytPosCrypt */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ public function mapTxType($txType): ?string
}

/**
* @param string|int $txType
* @param string|int $securityType
*
* @return PosInterface::MODEL_*|null
*/
public function mapSecurityType($txType): ?string
public function mapSecurityType($securityType): ?string
{
return $this->secureTypeMappings[$txType] ?? null;
return $this->secureTypeMappings[$securityType] ?? null;
}


Expand Down
13 changes: 11 additions & 2 deletions src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,25 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen
'masked_number' => $raw3DAuthResponseData['maskedCreditCard'],
'month' => $raw3DAuthResponseData['Ecom_Payment_Card_ExpDate_Month'],
'year' => $raw3DAuthResponseData['Ecom_Payment_Card_ExpDate_Year'],
'amount' => $this->formatAmount($raw3DAuthResponseData['amount']),
'amount' => null !== $raw3DAuthResponseData['amount'] ? $this->formatAmount($raw3DAuthResponseData['amount']) : null,
'currency' => $this->mapCurrency($raw3DAuthResponseData['currency']),
'installment_count' => $this->mapInstallment($raw3DAuthResponseData['taksit']),
'eci' => null,
'tx_status' => null,
'cavv' => null,
'md_error_message' => $this->is3dAuthSuccess($mdStatus) ? null : $raw3DAuthResponseData['mdErrorMsg'],
'md_error_message' => null,
'3d_all' => $raw3DAuthResponseData,
];

if (null !== $mdStatus) {
if (!$this->is3dAuthSuccess($mdStatus)) {
$threeDResponse['md_error_message'] = $raw3DAuthResponseData['mdErrorMsg'];
}
} else {
$threeDResponse['error_code'] = $raw3DAuthResponseData['ErrorCode'];
$threeDResponse['error_message'] = $raw3DAuthResponseData['ErrMsg'];
}

if ($this->is3dAuthSuccess($mdStatus)) {
$threeDResponse['eci'] = $raw3DAuthResponseData['eci'];
$threeDResponse['cavv'] = $raw3DAuthResponseData['cavv'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function mapPaymentResponse(array $rawPaymentResponseData, string $txType
$result['order_id'] = $rawPaymentResponseData['OrderId'];
$result['transaction_id'] = $rawPaymentResponseData['TransId'];
$result['auth_code'] = $rawPaymentResponseData['AuthCode'];
$result['ref_ret_num'] = $rawPaymentResponseData['HostRefNum'];
$result['error_code'] = $rawPaymentResponseData['ErrorCode'];
$result['error_message'] = $rawPaymentResponseData['ErrorMessage'];
$result['currency'] = $order['currency'];
Expand Down Expand Up @@ -118,7 +117,7 @@ public function mapRefundResponse(array $rawResponseData): array
'order_id' => $rawResponseData['OrderId'],
'group_id' => null,
'auth_code' => null,
'ref_ret_num' => $rawResponseData['HostRefNum'],
'ref_ret_num' => null,
'proc_return_code' => $procReturnCode,
'transaction_id' => $rawResponseData['TransId'],
'error_code' => $rawResponseData['ErrorCode'],
Expand All @@ -145,7 +144,7 @@ public function mapCancelResponse($rawResponseData): array
'order_id' => $rawResponseData['OrderId'],
'group_id' => null,
'auth_code' => $rawResponseData['AuthCode'],
'ref_ret_num' => $rawResponseData['HostRefNum'],
'ref_ret_num' => null,
'proc_return_code' => $procReturnCode,
'transaction_id' => $rawResponseData['TransId'],
'error_code' => $rawResponseData['ErrorCode'],
Expand Down Expand Up @@ -180,7 +179,6 @@ public function mapStatusResponse(array $rawResponseData): array
$defaultResponse['refund_amount'] = $rawResponseData['RefundedAmount'] > 0 ? $this->formatAmount($rawResponseData['RefundedAmount']) : null;

// todo success cevap ornegi bulundugunda guncellenecek:
$defaultResponse['ref_ret_num'] = null;
$defaultResponse['order_status'] = null;
$defaultResponse['capture_amount'] = null;
$defaultResponse['capture'] = null;
Expand Down Expand Up @@ -309,7 +307,6 @@ private function map3DPaymentResponse(?array $rawPaymentResponseData, string $tx
$result['order_id'] = $rawPaymentResponseData['OrderId'];
$result['transaction_id'] = $rawPaymentResponseData['TransId'];
$result['auth_code'] = $rawPaymentResponseData['AuthCode'];
$result['ref_ret_num'] = $rawPaymentResponseData['HostRefNum'];
$result['error_code'] = $rawPaymentResponseData['ErrorCode'];
$result['error_message'] = $rawPaymentResponseData['ErrorMessage'];
$result['all'] = $rawPaymentResponseData;
Expand Down Expand Up @@ -353,7 +350,6 @@ private function map3DCommonResponseData(array $raw3DAuthResponseData, ?array $r
$threeDResponse = [
'order_id' => $paymentResponseData['order_id'] ?? $raw3DAuthResponseData['OrderId'],
'proc_return_code' => $paymentResponseData['proc_return_code'] ?? $procReturnCode,
'ref_ret_num' => $paymentResponseData['ref_ret_num'] ?? $raw3DAuthResponseData['HostRefNum'],
'transaction_security' => null === $mdStatus ? null : $this->mapResponseTransactionSecurity($mdStatus),
'payment_model' => $paymentModel,
'md_status' => $mdStatus,
Expand Down
3 changes: 1 addition & 2 deletions src/Serializer/EstPosSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Mews\Pos\Gateways\EstV3Pos;
use Symfony\Component\Serializer\Encoder\XmlEncoder;
use Symfony\Component\Serializer\Serializer;
use function in_array;

class EstPosSerializer implements SerializerInterface
{
Expand All @@ -30,7 +29,7 @@ public function __construct()
*/
public static function supports(string $gatewayClass): bool
{
return in_array($gatewayClass, [EstPos::class, EstV3Pos::class]);
return \in_array($gatewayClass, [EstPos::class, EstV3Pos::class]);
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/Serializer/InterPosSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

use Mews\Pos\Gateways\InterPos;
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
use function explode;
use function preg_split;

class InterPosSerializer implements SerializerInterface
{
Expand Down Expand Up @@ -36,14 +34,14 @@ public function encode(array $data, ?string $txType = null): array
public function decode(string $data, ?string $txType = null): array
{
//genelde ;; delimiter kullanilmis, ama bazen arasinda ;;; boyle delimiter de var.
$resultValues = preg_split('/(;;;|;;)/', $data);
$resultValues = \preg_split('/(;;;|;;)/', $data);
if (false === $resultValues) {
throw new NotEncodableValueException();
}

$result = [];
foreach ($resultValues as $val) {
[$key, $value] = explode('=', $val);
[$key, $value] = \explode('=', $val);
$result[$key] = $value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class EstPosRequestDataMapperTest extends TestCase
/** @var EventDispatcherInterface & MockObject */
private EventDispatcherInterface $dispatcher;

private array $order;

protected function setUp(): void
{
parent::setUp();
Expand All @@ -53,16 +51,6 @@ protected function setUp(): void
'TRPS0200'
);

$this->order = [
'id' => 'order222',
'ip' => '127.0.0.1',
'amount' => '100.25',
'installment' => 0,
'currency' => PosInterface::CURRENCY_TRY,
'success_url' => 'https://domain.com/success',
'fail_url' => 'https://domain.com/fail_url',
'lang' => PosInterface::LANG_TR,
];
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$this->crypt = $this->createMock(CryptInterface::class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Mews\Pos\Crypt\CryptInterface;
use Mews\Pos\DataMapper\RequestDataMapper\EstPosRequestDataMapper;
use Mews\Pos\DataMapper\ResponseDataMapper\EstPosResponseDataMapper;
use Mews\Pos\Exceptions\NotImplementedException;
use Mews\Pos\PosInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -197,7 +198,7 @@ public function testMapCancelResponse(array $responseData, array $expectedData):
/**
* @dataProvider orderHistoryTestDataProvider
*/
public function testMapHistoryResponse(array $responseData, array $expectedData): void
public function testMapOrderHistoryResponse(array $responseData, array $expectedData): void
{
$actualData = $this->responseDataMapper->mapOrderHistoryResponse($responseData);
if (count($responseData['Extra']) > 0) {
Expand Down Expand Up @@ -228,6 +229,11 @@ public function testMapHistoryResponse(array $responseData, array $expectedData)
$this->assertSame($expectedData, $actualData);
}

public function testMapHistoryResponse(): void
{
$this->expectException(NotImplementedException::class);
$this->responseDataMapper->mapHistoryResponse([]);
}

public static function paymentTestDataProvider(): iterable
{
Expand Down Expand Up @@ -505,6 +511,64 @@ public static function threeDPaymentDataProvider(): array
'installment_count' => 0,
],
],
'3d_auth_fail_wrong_card_number_format' => [
'order' => [
'currency' => PosInterface::CURRENCY_TRY,
'amount' => 1.01,
],
'txType' => PosInterface::TX_TYPE_PAY_AUTH,
'threeDResponseData' => [
'amount' => 0.01,
'clientid' => '*',
'currency' => '*',
'Ecom_Payment_Card_ExpDate_Month' => 0,
'Ecom_Payment_Card_ExpDate_Year' => 0,
'ErrMsg' => 'Girilen kart numarası doğru formatta değildir. Kart numarasını kontrol ederek tekrar işlem deneyiniz.',
'ErrorCode' => 'HPP-1001',
'failUrl' => 'https://*.com/odeme/f05e81c8-4ea0-44a9-8fe8-d45b854c62d9',
'HASH' => '**/fxNKZvC4E2EbQOgiqNi9FeXBMj636Q==',
'hashAlgorithm' => 'ver3',
'lang' => 'tr',
'maskedCreditCard' => '***',
'MaskedPan' => '**',
'oid' => 'f05e81c8',
'okUrl' => 'https://*.com/odeme/d45b854c62d9',
'Response' => 'Error',
'rnd' => 'MZrcwoSd1+-*',
'storetype' => '3d',
'taksit' => '',
'traceId' => '****',
'TranType' => 'Auth',
],
'paymentData' => [],
'expectedData' => [
'amount' => 0.01,
'auth_code' => null,
'batch_num' => null,
'cavv' => null,
'currency' => '*',
'eci' => null,
'error_code' => 'HPP-1001',
'error_message' => 'Girilen kart numarası doğru formatta değildir. Kart numarasını kontrol ederek tekrar işlem deneyiniz.',
'installment_count' => 0,
'masked_number' => '***',
'md_error_message' => null,
'md_status' => null,
'month' => 0,
'order_id' => 'f05e81c8',
'payment_model' => '3d',
'proc_return_code' => null,
'ref_ret_num' => null,
'status' => 'declined',
'status_detail' => null,
'transaction_id' => null,
'transaction_security' => null,
'transaction_type' => 'pay',
'transaction_time' => null,
'tx_status' => null,
'year' => 0,
],
],
'3d_auth_success_payment_fail' => [
'order' => [
'currency' => PosInterface::CURRENCY_TRY,
Expand Down
Loading