Skip to content

Commit

Permalink
GarantiPos - implement history request
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed Jun 3, 2024
1 parent 6f330de commit e202b3e
Show file tree
Hide file tree
Showing 16 changed files with 1,035 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ sistemlerinin kullanılabilmesidir.
| EST V3 POS<br/><br/><sup>EstPos altyapının<br/>daha güvenli<br/>(sha512) hash<br/>algoritmasıyla<br/>uygulaması.</sup> | -----"----- | -----"----- | -----"----- |
| PayFlex MPI VPOS V4 | Ziraat<br/>Vakıfbank VPOS 7/24<br/>İşbank | NonSecure<br/>3DSecure<br/>Tekrarlanan Ödeme | İptal<br/>İade<br/>Durum sorgulama |
| PayFlex<br/>Common Payment V4<br/><sup>(Ortak Ödeme)</sup> | Ziraat<br/>Vakıfbank<br/>İşbank | NonSecure<br/>3DPay<br/>3DHost | İptal<br/>İade |
| Garanti Virtual POS | Garanti | NonSecure<br/>3DSecure<br/>3DPay<br/>3DHost<br/>Tekrarlanan Ödeme | İptal<br/>İade<br/>Durum sorgulama<br/>Sipariş Tarihçesini sorgulama |
| Garanti Virtual POS | Garanti | NonSecure<br/>3DSecure<br/>3DPay<br/>3DHost<br/>Tekrarlanan Ödeme | İptal<br/>İade<br/>Durum sorgulama<br/>Sipariş Tarihçesini sorgulama<br/>Geçmiş İşlemleri sorgulama |
| PosNet | YapıKredi | NonSecure<br/>3DSecure<br/> | İptal<br/>İade<br/>Durum sorgulama |
| PosNetV1<br/><sup>(JSON API)</sup> | Albaraka Türk | NonSecure<br/>3DSecure | İptal<br/>İade<br/>Durum sorgulama |
| PayFor | Finansbank<br/>Enpara | NonSecure<br/>3DSecure<br/>3DPay<br/>3DHost | İptal<br/>İade<br/>Durum sorgulama<br/>Sipariş Tarihçesini sorgulama<br/>Geçmiş İşlemleri sorgulama |
Expand Down
12 changes: 10 additions & 2 deletions docs/HISTORY-EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ try {

require 'config.php';

function createHistoryOrder(string $gatewayClass, array $extraData): array
function createHistoryOrder(string $gatewayClass, array $extraData, string $ip): array
{
$order = [];
$txTime = new \DateTimeImmutable();
Expand All @@ -60,6 +60,14 @@ function createHistoryOrder(string $gatewayClass, array $extraData): array
'start_date' => $txTime->modify('-1 day'),
'end_date' => $txTime->modify('+1 day'),
];
} elseif (\Mews\Pos\Gateways\GarantiPos::class === $gatewayClass) {
$order = [
'ip' => $ip,
'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 = [
// Gün aralığı 1 günden fazla girilemez
Expand All @@ -75,7 +83,7 @@ function createHistoryOrder(string $gatewayClass, array $extraData): array
return $order;
}

$order = createHistoryOrder(get_class($pos), []);
$order = createHistoryOrder(get_class($pos), [], '127.0.0.1');

$pos->history($order);
$response = $pos->getResponse();
Expand Down
13 changes: 11 additions & 2 deletions examples/_common-codes/regular/history.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

require '../../_templates/_header.php';

function createHistoryOrder(string $gatewayClass, array $extraData): array
function createHistoryOrder(string $gatewayClass, array $extraData, string $ip): array
{
$order = [];
$txTime = new \DateTimeImmutable();
Expand All @@ -27,6 +27,15 @@ function createHistoryOrder(string $gatewayClass, array $extraData): array
'start_date' => $txTime->modify('-1 day'),
'end_date' => $txTime->modify('+1 day'),
];
} elseif (\Mews\Pos\Gateways\GarantiPos::class === $gatewayClass) {
$order = [
'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 = [
// Gün aralığı 1 günden fazla girilemez
Expand All @@ -42,7 +51,7 @@ function createHistoryOrder(string $gatewayClass, array $extraData): array
return $order;
}

$order = createHistoryOrder(get_class($pos), []);
$order = createHistoryOrder(get_class($pos), [], $ip);
dump($order);

$transaction = \Mews\Pos\PosInterface::TX_TYPE_HISTORY;
Expand Down
3 changes: 3 additions & 0 deletions examples/garanti/regular/history.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_common-codes/regular/history.php';
68 changes: 65 additions & 3 deletions src/DataMapper/RequestDataMapper/GarantiPosRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Mews\Pos\Entity\Account\GarantiPosAccount;
use Mews\Pos\Entity\Card\CreditCardInterface;
use Mews\Pos\Event\Before3DFormHashCalculatedEvent;
use Mews\Pos\Exceptions\NotImplementedException;
use Mews\Pos\Gateways\GarantiPos;
use Mews\Pos\PosInterface;

Expand All @@ -32,7 +31,12 @@ class GarantiPosRequestDataMapper extends AbstractRequestDataMapper
/** @var string */
public const CREDIT_CARD_EXP_YEAR_FORMAT = 'y';

/** @var string */
/**
* MotoInd; işlemin MAilOrder bir işlem olup olmadığı bilgisinin gönderildiği alandır.
* Y (also E) ise işlem mail order bir işlemdir.
* N (also H) ise işlem ecommerce işlemidir.
* @var string
*/
private const MOTO = 'N';

/**
Expand All @@ -53,6 +57,7 @@ class GarantiPosRequestDataMapper extends AbstractRequestDataMapper
PosInterface::TX_TYPE_CANCEL => 'void',
PosInterface::TX_TYPE_REFUND => 'refund',
PosInterface::TX_TYPE_ORDER_HISTORY => 'orderhistoryinq',
PosInterface::TX_TYPE_HISTORY => 'orderlistinq',
PosInterface::TX_TYPE_STATUS => 'orderinq',
];

Expand Down Expand Up @@ -319,11 +324,45 @@ public function createOrderHistoryRequestData(AbstractPosAccount $posAccount, ar
}

/**
* @param GarantiPosAccount $posAccount
* {@inheritDoc}
*/
public function createHistoryRequestData(AbstractPosAccount $posAccount, array $data = []): array
{
throw new NotImplementedException();
$order = $this->prepareHistoryOrder($data);

$result = [
'Mode' => $this->getMode(),
'Version' => self::API_VERSION,
'Terminal' => $this->getTerminalData($posAccount),
'Customer' => [
'IPAddress' => $order['ip'],
],
'Order' => [
'OrderID' => null,
'GroupID' => null,
'Description' => null,
// Başlangıç ve bitiş tarihleri arasında en fazla 30 gün olabilir
'StartDate' => $this->formatRequestDateTime($order['start_date']),
'EndDate' => $this->formatRequestDateTime($order['end_date']),
/**
* 500 adetten fazla işlem olması durumunda ListPageNum alanında diğer 500 lü grupların görüntülenmesi
* için sayfa numarası yazılır.
*/
'ListPageNum' => $order['page'],
],
'Transaction' => [
'Type' => $this->mapTxType(PosInterface::TX_TYPE_HISTORY),
'Amount' => $this->formatAmount(1), //sabit olarak amount 100 gonderilecek
'CurrencyCode' => $this->mapCurrency(PosInterface::CURRENCY_TRY),
'CardholderPresentCode' => '0',
'MotoInd' => self::MOTO,
],
];

$result['Terminal']['HashData'] = $this->crypt->createHash($posAccount, $result);

return $result;
}


Expand Down Expand Up @@ -462,6 +501,19 @@ protected function prepareOrderHistoryOrder(array $order): array
return $this->prepareStatusOrder($order);
}

/**
* @inheritDoc
*/
protected function prepareHistoryOrder(array $data): array
{
return [
'start_date' => $data['start_date'],
'end_date' => $data['end_date'],
'page' => $data['page'] ?? 1,
'ip' => $data['ip'],
];
}

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -573,4 +625,14 @@ private function createRecurringData(array $recurringData): array
'StartDate' => isset($recurringData['startDate']) ? $recurringData['startDate']->format('Ymd') : '',
];
}

/**
* @param \DateTimeInterface $dateTime
*
* @return string example 01/12/2010 11:11
*/
private function formatRequestDateTime(\DateTimeInterface $dateTime): string
{
return $dateTime->format('d/m/Y H:i');
}
}
Loading

0 comments on commit e202b3e

Please sign in to comment.