Skip to content

Commit

Permalink
tests - more coverage in request data mappers
Browse files Browse the repository at this point in the history
  • Loading branch information
mustapayev committed Sep 7, 2024
1 parent 5011dd4 commit 2b18be7
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,34 @@ public function testCreateRefundRequestData(array $order, string $txType, array
$this->assertSame($expectedData, $actual);
}

public function testCreateRefundRequestDataWithoutRefundCredentials(): void
{
$this->account = AccountFactory::createGarantiPosAccount(
'garanti',
'7000679',
'PROVAUT',
'123qweASD/',
'30691298',
PosInterface::MODEL_3D_SECURE,
'12345678',
);
$order = [
'id' => '2020110828BC',
'ip' => '127.15.15.1',
'currency' => PosInterface::CURRENCY_TRY,
'amount' => 123.1,
'ref_ret_num' => '831803579226',
'installment' => 0,
];

$this->expectException(\LogicException::class);
$this->requestDataMapper->createRefundRequestData(
$this->account,
$order,
PosInterface::TX_TYPE_REFUND
);
}

/**
* @param GarantiPosAccount $posAccount
* @param $order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,25 @@ public function testCreate3DFormData(array $ooTxSuccessData, array $order, strin
$ooTxSuccessData['oosRequestDataResponse']
);

$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

/**
* @dataProvider threeDFormDataDataProvider
*/
public function testCreate3DFormDataWithMissingData(): void
{
$this->dispatcher->expects(self::never())
->method('dispatch');

$this->expectException(InvalidArgumentException::class);
$this->requestDataMapper->create3DFormData(
$this->account,
[],
PosInterface::MODEL_3D_SECURE,
PosInterface::TX_TYPE_PAY_AUTH,
'/api',
);
}

/**
Expand Down Expand Up @@ -307,10 +325,10 @@ public static function threeDFormDataDataProvider(): array
'gateway' => 'https://setmpos.ykb.com/3DSWebService/YKBPaymentService',
'method' => 'POST',
'inputs' => [
'posnetData' => 'AEFE78BFC852867FF57078B723E284D1BD52EED8264C6CBD110A1A9EA5EAA7533D1A82EFD614032D686C507738FDCDD2EDD00B22DEFEFE0795DC4674C16C02EBBFEC9DF0F495D5E23BE487A798BF8293C7C1D517D9600C96CBFD8816C9D8F8257442906CB9B10D8F1AABFBBD24AA6FB0E5533CDE67B0D9EA5ED621B91BF6991D5362182302B781241B56E47BAE1E86BC3D5AE7606212126A4E97AFC2',
'posnetData2' => '69D04861340091B7014B15158CA3C83413031B406F08B3792A0114C9958E6F0F216966C5EE32EAEEC7158BFF59DFCB77E20CD625',
'mid' => '6706598320',
'posnetID' => '27426',
'posnetData' => 'AEFE78BFC852867FF57078B723E284D1BD52EED8264C6CBD110A1A9EA5EAA7533D1A82EFD614032D686C507738FDCDD2EDD00B22DEFEFE0795DC4674C16C02EBBFEC9DF0F495D5E23BE487A798BF8293C7C1D517D9600C96CBFD8816C9D8F8257442906CB9B10D8F1AABFBBD24AA6FB0E5533CDE67B0D9EA5ED621B91BF6991D5362182302B781241B56E47BAE1E86BC3D5AE7606212126A4E97AFC2',
'posnetData2' => '69D04861340091B7014B15158CA3C83413031B406F08B3792A0114C9958E6F0F216966C5EE32EAEEC7158BFF59DFCB77E20CD625',
'digest' => '9998F61E1D0C0FB6EC5203A748124F30',
'merchantReturnURL' => 'https://domain.com/success',
'url' => '',
Expand Down Expand Up @@ -389,6 +407,25 @@ public static function cancelDataProvider(): array
],
],
],
'with_auth_code' => [
'order' => [
'id' => '2020110828BC',
'auth_code' => '901477',
'payment_model' => PosInterface::MODEL_3D_SECURE,
'amount' => 50,
'currency' => PosInterface::CURRENCY_TRY,
],
'expected' => [
'mid' => '6706598320',
'tid' => '67005551',
'tranDateRequired' => '1',
'reverse' => [
'transaction' => 'sale',
'authCode' => '901477',
'orderID' => 'TDSC000000002020110828BC',
],
],
],
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,41 @@ public static function nonSecurePostPaymentDataProvider(): iterable
'MAC' => 'wgyfAJPbEPtTtce/+HRlXajSRfYA0J6mUcH+16EbB78=',
],
];

yield 'with_installment' => [
'order' => [
'id' => '123',
'installment' => 2,
'amount' => 12.3,
'currency' => PosInterface::CURRENCY_TRY,
'ref_ret_num' => '159044932490000231',
],
'expected' => [
'ApiType' => 'JSON',
'ApiVersion' => 'V100',
'MACParams' => 'MerchantNo:TerminalNo',
'MerchantNo' => '6700950031',
'TerminalNo' => '67540050',
'CipheredData' => null,
'DealerData' => null,
'IsEncrypted' => null,
'PaymentFacilitatorData' => null,
'Amount' => 1230,
'CurrencyCode' => 'TL',
'ReferenceCode' => '159044932490000231',
'InstallmentCount' => '2',
'InstallmentType' => 'Y',
'MAC' => 'wgyfAJPbEPtTtce/+HRlXajSRfYA0J6mUcH+16EbB78=',
],
];
}

public static function create3DPaymentRequestDataProvider(): \Generator
{
$order = [
'id' => '2020110828BC',
'amount' => 100.01,
'installment' => '0',
'installment' => 0,
'currency' => PosInterface::CURRENCY_TRY,
];
yield [
Expand Down Expand Up @@ -484,6 +511,45 @@ public static function create3DPaymentRequestDataProvider(): \Generator
'MAC' => 'kAKxvbwXvmrM6lapGx1UcRTs454tsSuPrBXV7oA7L7w=',
],
];

$order['installment'] = 2;

yield 'with_installment' => [
'order' => $order,
'txType' => PosInterface::TX_TYPE_PAY_AUTH,
'responseData' => [
'SecureTransactionId' => '1010028947569644',
'CAVV' => 'jKOBaLBL3hQ+CREBPu1HBQQAAAA=',
'ECI' => '02',
'MdStatus' => '1',
'MD' => '9998F61E1D0C0FB6EC5203A748124F30',
],
'expected' => [
'ApiType' => 'JSON',
'ApiVersion' => 'V100',
'MerchantNo' => '6700950031',
'TerminalNo' => '67540050',
'PaymentInstrumentType' => 'CARD',
'IsEncrypted' => 'N',
'IsTDSecureMerchant' => 'Y',
'IsMailOrder' => 'N',
'ThreeDSecureData' => [
'SecureTransactionId' => '1010028947569644',
'CavvData' => 'jKOBaLBL3hQ+CREBPu1HBQQAAAA=',
'Eci' => '02',
'MdStatus' => 1,
'MD' => '9998F61E1D0C0FB6EC5203A748124F30',
],
'MACParams' => 'MerchantNo:TerminalNo:SecureTransactionId:CavvData:Eci:MdStatus',
'Amount' => 10001,
'CurrencyCode' => 'TL',
'PointAmount' => 0,
'OrderId' => '000000002020110828BC',
'InstallmentCount' => '2',
'InstallmentType' => 'Y',
'MAC' => 'kAKxvbwXvmrM6lapGx1UcRTs454tsSuPrBXV7oA7L7w=',
],
];
}

public static function createRefundRequestDataDataProvider(): iterable
Expand Down Expand Up @@ -514,6 +580,33 @@ public static function createRefundRequestDataDataProvider(): iterable
],
];

yield 'refund_non_secure_order' => [
'order' => [
'id' => '000000002020110828BC',
'amount' => 112,
'payment_model' => PosInterface::MODEL_NON_SECURE,
'transaction_type' => PosInterface::TX_TYPE_PAY_AUTH,
],
'tx_type' => PosInterface::TX_TYPE_REFUND,
'expected' => [
'ApiType' => 'JSON',
'ApiVersion' => 'V100',
'MerchantNo' => '6700950031',
'TerminalNo' => '67540050',
'MACParams' => 'MerchantNo:TerminalNo:ReferenceCode:OrderId',
'MAC' => '9Ffy2cgMphKFSg2nyXr38gKXJhC8HL+L6X3KEkpt0AQ=',
'CipheredData' => null,
'DealerData' => null,
'IsEncrypted' => null,
'PaymentFacilitatorData' => null,
'ReferenceCode' => null,
'OrderId' => '0000000000002020110828BC',
'TransactionType' => 'Sale',
'Amount' => 11200,
'CurrencyCode' => 'TL',
],
];

yield 'withOrderId' => [
'order' => [
'id' => '000000002020110828BC',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,17 @@ public static function threeDFormDataProvider(): array
],
'tx_type' => PosInterface::TX_TYPE_PAY_AUTH,
'payment_model' => PosInterface::MODEL_3D_PAY,
'is_with_card' => false,
'is_with_card' => true,
'gateway' => 'https://ent.akodepos.com/api/Payment/ProcessCardForm',
'expected' => [
'expected' => [
'gateway' => 'https://ent.akodepos.com/api/Payment/ProcessCardForm',
'method' => 'POST',
'inputs' => [
'ThreeDSessionId' => 'P6D383818909442128AB50AB1EC7A4B83080874341688447DA74B90150C8857F2',
'CardHolderName' => 'ahmet',
'CardNo' => '5555444433332222',
'ExpireDate' => '01/22',
'Cvv' => '123',
],
],
],
Expand Down

0 comments on commit 2b18be7

Please sign in to comment.