Skip to content

Commit

Permalink
param integration initial
Browse files Browse the repository at this point in the history
  • Loading branch information
mustapayev committed Jan 15, 2025
1 parent ec2c571 commit 436e980
Show file tree
Hide file tree
Showing 7 changed files with 400 additions and 334 deletions.
31 changes: 19 additions & 12 deletions examples/_common-codes/regular/history.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@

function createHistoryOrder(string $gatewayClass, array $extraData, string $ip): array
{
$order = [];
$txTime = new \DateTimeImmutable();
if (\Mews\Pos\Gateways\PayForPos::class === $gatewayClass) {
$order = [
return [
// odeme tarihi
'transaction_date' => $extraData['transaction_date'] ?? $txTime,
];
} elseif (\Mews\Pos\Gateways\VakifKatilimPos::class === $gatewayClass) {
$order = [
}

if (\Mews\Pos\Gateways\VakifKatilimPos::class === $gatewayClass) {
return [
'page' => 1,
'page_size' => 20,
/**
Expand All @@ -28,17 +29,21 @@ function createHistoryOrder(string $gatewayClass, array $extraData, string $ip):
'start_date' => $txTime->modify('-1 day'),
'end_date' => $txTime->modify('+1 day'),
];
} elseif (\Mews\Pos\Gateways\GarantiPos::class === $gatewayClass) {
$order = [
}

if (\Mews\Pos\Gateways\GarantiPos::class === $gatewayClass) {
return [
'ip' => $ip,
'currency' => \Mews\Pos\PosInterface::CURRENCY_USD,
'page' => 1, //optional
// Başlangıç ve bitiş tarihleri arasında en fazla 30 gün olabilir
'start_date' => $txTime,
'end_date' => $txTime->modify('+1 day'),
];
} elseif (\Mews\Pos\Gateways\AkbankPos::class === $gatewayClass) {
$order = [
}

if (\Mews\Pos\Gateways\AkbankPos::class === $gatewayClass) {
return [
// Gün aralığı 1 günden fazla girilemez
'start_date' => $txTime->modify('-23 hour'),
'end_date' => $txTime,
Expand All @@ -47,11 +52,13 @@ function createHistoryOrder(string $gatewayClass, array $extraData, string $ip):
// $order = [
// 'batch_num' => 24,
// ];
} elseif (\Mews\Pos\Gateways\ParamPos::class === $gatewayClass) {
$order = [
}

if (\Mews\Pos\Gateways\ParamPos::class === $gatewayClass) {
return [
// Gün aralığı 7 günden fazla girilemez
'start_date' => $txTime->modify('-23 hour'),
'end_date' => $txTime->modify('+2 days'),
'end_date' => $txTime,

// optional:
// Bu değerler gönderilince API nedense hata veriyor.
Expand All @@ -60,7 +67,7 @@ function createHistoryOrder(string $gatewayClass, array $extraData, string $ip):
];
}

return $order;
return [];
}

$order = createHistoryOrder(get_class($pos), [], $ip);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public function create3DPaymentRequestData(AbstractPosAccount $posAccount, array
* @param ParamPosAccount $posAccount
* @param array<string, int|string|float|null> $order
* @param CreditCardInterface $creditCard
* @param PosInterface::TX_TYPE_PAY_* $txType
* @param PosInterface::MODEL_3D_* $paymentModel
*
* @return array
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public function map3DHostResponseData(array $raw3DAuthResponseData, string $txTy

$response = [
'order_id' => $raw3DAuthResponseData['oid'],
'transaction_security' => null === $mdStatus ? null : $this->mapResponseTransactionSecurity($mdStatus),
'transaction_security' => null,
'md_status' => $mdStatus,
'status' => $status,
'amount' => $this->formatAmount($raw3DAuthResponseData['amount']),
Expand Down
24 changes: 22 additions & 2 deletions tests/Functional/ParamPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class ParamPosTest extends TestCase
/** @var ParamPos */
private PosInterface $pos;

private array $lastResponse;

protected function setUp(): void
{
parent::setUp();
Expand Down Expand Up @@ -397,4 +395,26 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThro
$this->assertArrayHasKey('DT_Bilgi', $response['TP_Ozel_Oran_ListeResponse']['TP_Ozel_Oran_ListeResult']);
$this->assertTrue($eventIsThrown);
}

public function testHistorySuccess(): void
{
$historyOrder = $this->createHistoryOrder(\get_class($this->pos), [], '127.0.0.1');

$eventIsThrown = false;
$this->eventDispatcher->addListener(
RequestDataPreparedEvent::class,
function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void {
$eventIsThrown = true;
$this->assertSame(PosInterface::TX_TYPE_HISTORY, $requestDataPreparedEvent->getTxType());
$this->assertCount(4, $requestDataPreparedEvent->getRequestData());
}
);

$this->pos->history($historyOrder);

$response = $this->pos->getResponse();
$this->assertIsArray($response);
$this->assertTrue($eventIsThrown);
$this->assertNotEmpty($response['transactions']);
}
}
13 changes: 13 additions & 0 deletions tests/Functional/PaymentTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,19 @@ private function createHistoryOrder(string $gatewayClass, array $extraData, stri
// ];
}

if (\Mews\Pos\Gateways\ParamPos::class === $gatewayClass) {
return [
// Gün aralığı 7 günden fazla girilemez
'start_date' => $txTime->modify('-23 hour'),
'end_date' => $txTime,

// optional:
// Bu değerler gönderilince API nedense hata veriyor.
// 'transaction_type' => \Mews\Pos\PosInterface::TX_TYPE_PAY_AUTH, // TX_TYPE_CANCEL, TX_TYPE_REFUND
// 'order_status' => 'Başarılı', // Başarılı, Başarısız
];
}

return [];
}

Expand Down
Loading

0 comments on commit 436e980

Please sign in to comment.