Skip to content

Commit

Permalink
Merge branch 'master' into vakifkatilimpos-fix-errors-2
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	tests/Unit/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapperTest.php
  • Loading branch information
nuryagdym committed Jul 2, 2024
2 parents f408f0b + 0f9459a commit 19918e5
Show file tree
Hide file tree
Showing 69 changed files with 1,674 additions and 462 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 @@ -45,7 +45,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 @@ -61,6 +61,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 @@ -76,7 +84,7 @@ function createHistoryOrder(string $gatewayClass, array $extraData): array
return $order;
}

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

try {
$pos->history($order);
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 @@ -9,7 +9,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 @@ -28,6 +28,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 @@ -43,7 +52,7 @@ function createHistoryOrder(string $gatewayClass, array $extraData): array
return $order;
}

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

try {
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';
19 changes: 10 additions & 9 deletions src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,24 @@ class AkbankPosRequestDataMapper extends AbstractRequestDataMapper
* {@inheritDoc}
*/
protected array $txTypeMappings = [
PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_NON_SECURE => '1000',
PosInterface::MODEL_3D_SECURE => '3000',
PosInterface::MODEL_3D_PAY => '3000',
PosInterface::MODEL_3D_HOST => '3000',
],
PosInterface::TX_TYPE_PAY_PRE_AUTH => [
PosInterface::TX_TYPE_PAY_PRE_AUTH => [
PosInterface::MODEL_NON_SECURE => '1004',
PosInterface::MODEL_3D_SECURE => '3004',
PosInterface::MODEL_3D_PAY => '3004',
PosInterface::MODEL_3D_HOST => '3004',
],
PosInterface::TX_TYPE_PAY_POST_AUTH => '1005',
PosInterface::TX_TYPE_REFUND => '1002',
PosInterface::TX_TYPE_CANCEL => '1003',
PosInterface::TX_TYPE_ORDER_HISTORY => '1010',
PosInterface::TX_TYPE_HISTORY => '1009',
PosInterface::TX_TYPE_PAY_POST_AUTH => '1005',
PosInterface::TX_TYPE_REFUND => '1002',
PosInterface::TX_TYPE_REFUND_PARTIAL => '1002',
PosInterface::TX_TYPE_CANCEL => '1003',
PosInterface::TX_TYPE_ORDER_HISTORY => '1010',
PosInterface::TX_TYPE_HISTORY => '1009',
];

/**
Expand Down Expand Up @@ -261,13 +262,13 @@ public function createCancelRequestData(AbstractPosAccount $posAccount, array $o
*
* {@inheritDoc}
*/
public function createRefundRequestData(AbstractPosAccount $posAccount, array $order): array
public function createRefundRequestData(AbstractPosAccount $posAccount, array $order, string $refundTxType): array
{
$order = $this->prepareRefundOrder($order);

$requestData = $this->getRequestAccountData($posAccount) + [
'version' => self::API_VERSION,
'txnCode' => $this->mapTxType(PosInterface::TX_TYPE_REFUND),
'txnCode' => $this->mapTxType($refundTxType),
'requestDateTime' => $this->formatRequestDateTime($order['transaction_time']),
'randomNumber' => $this->crypt->generateRandomString(),
'transaction' => [
Expand Down
19 changes: 10 additions & 9 deletions src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ class EstPosRequestDataMapper extends AbstractRequestDataMapper
* {@inheritDoc}
*/
protected array $txTypeMappings = [
PosInterface::TX_TYPE_PAY_AUTH => 'Auth',
PosInterface::TX_TYPE_PAY_PRE_AUTH => 'PreAuth',
PosInterface::TX_TYPE_PAY_POST_AUTH => 'PostAuth',
PosInterface::TX_TYPE_CANCEL => 'Void',
PosInterface::TX_TYPE_REFUND => 'Credit',
PosInterface::TX_TYPE_STATUS => 'ORDERSTATUS',
PosInterface::TX_TYPE_HISTORY => 'ORDERHISTORY',
PosInterface::TX_TYPE_PAY_AUTH => 'Auth',
PosInterface::TX_TYPE_PAY_PRE_AUTH => 'PreAuth',
PosInterface::TX_TYPE_PAY_POST_AUTH => 'PostAuth',
PosInterface::TX_TYPE_CANCEL => 'Void',
PosInterface::TX_TYPE_REFUND => 'Credit',
PosInterface::TX_TYPE_REFUND_PARTIAL => 'Credit',
PosInterface::TX_TYPE_STATUS => 'ORDERSTATUS',
PosInterface::TX_TYPE_HISTORY => 'ORDERHISTORY',
];

/**
Expand Down Expand Up @@ -199,14 +200,14 @@ public function createCancelRequestData(AbstractPosAccount $posAccount, array $o
* {@inheritDoc}
* @return array{OrderId: string, Currency: string, Type: string, Total?: string, Name: string, Password: string, ClientId: string}
*/
public function createRefundRequestData(AbstractPosAccount $posAccount, array $order): array
public function createRefundRequestData(AbstractPosAccount $posAccount, array $order, string $refundTxType): array
{
$order = $this->prepareRefundOrder($order);

$requestData = [
'OrderId' => (string) $order['id'],
'Currency' => $this->mapCurrency($order['currency']),
'Type' => $this->mapTxType(PosInterface::TX_TYPE_REFUND),
'Type' => $this->mapTxType($refundTxType),
];

if (isset($order['amount'])) {
Expand Down
107 changes: 85 additions & 22 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 @@ -47,13 +51,15 @@ class GarantiPosRequestDataMapper extends AbstractRequestDataMapper
* {@inheritDoc}
*/
protected array $txTypeMappings = [
PosInterface::TX_TYPE_PAY_AUTH => 'sales',
PosInterface::TX_TYPE_PAY_PRE_AUTH => 'preauth',
PosInterface::TX_TYPE_PAY_POST_AUTH => 'postauth',
PosInterface::TX_TYPE_CANCEL => 'void',
PosInterface::TX_TYPE_REFUND => 'refund',
PosInterface::TX_TYPE_HISTORY => 'orderhistoryinq',
PosInterface::TX_TYPE_STATUS => 'orderinq',
PosInterface::TX_TYPE_PAY_AUTH => 'sales',
PosInterface::TX_TYPE_PAY_PRE_AUTH => 'preauth',
PosInterface::TX_TYPE_PAY_POST_AUTH => 'postauth',
PosInterface::TX_TYPE_CANCEL => 'void',
PosInterface::TX_TYPE_REFUND => 'refund',
PosInterface::TX_TYPE_REFUND_PARTIAL => 'refund',
PosInterface::TX_TYPE_ORDER_HISTORY => 'orderhistoryinq',
PosInterface::TX_TYPE_HISTORY => 'orderlistinq',
PosInterface::TX_TYPE_STATUS => 'orderinq',
];

protected array $recurringOrderFrequencyMapping = [
Expand All @@ -79,10 +85,10 @@ public function create3DPaymentRequestData(AbstractPosAccount $posAccount, array
'Version' => self::API_VERSION,
'Terminal' => $this->getTerminalData($posAccount),
'Customer' => [
'IPAddress' => $responseData['customeripaddress'],
'IPAddress' => $responseData['customeripaddress'],
],
'Order' => [
'OrderID' => $responseData['orderid'],
'OrderID' => $responseData['orderid'],
],
'Transaction' => [
'Type' => $responseData['txntype'],
Expand Down Expand Up @@ -123,11 +129,11 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $posAccount
'Version' => self::API_VERSION,
'Terminal' => $this->getTerminalData($posAccount),
'Customer' => [
'IPAddress' => $order['ip'],
'IPAddress' => $order['ip'],
],
'Card' => $this->getCardData($creditCard),
'Order' => [
'OrderID' => $order['id'],
'OrderID' => $order['id'],
],
'Transaction' => [
'Type' => $this->mapTxType($txType),
Expand Down Expand Up @@ -162,7 +168,7 @@ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $po
'Version' => self::API_VERSION,
'Terminal' => $this->getTerminalData($posAccount),
'Customer' => [
'IPAddress' => $order['ip'],
'IPAddress' => $order['ip'],
],
'Order' => [
'OrderID' => $order['id'],
Expand Down Expand Up @@ -194,7 +200,7 @@ public function createStatusRequestData(AbstractPosAccount $posAccount, array $o
'Version' => self::API_VERSION,
'Terminal' => $this->getTerminalData($posAccount),
'Customer' => [
'IPAddress' => $order['ip'],
'IPAddress' => $order['ip'],
],
'Order' => [
'OrderID' => $order['id'],
Expand Down Expand Up @@ -228,7 +234,7 @@ public function createCancelRequestData(AbstractPosAccount $posAccount, array $o
'Version' => self::API_VERSION,
'Terminal' => $this->getTerminalData($posAccount, true),
'Customer' => [
'IPAddress' => $order['ip'],
'IPAddress' => $order['ip'],
],
'Order' => [
'OrderID' => $order['id'],
Expand All @@ -254,7 +260,7 @@ public function createCancelRequestData(AbstractPosAccount $posAccount, array $o
*
* {@inheritDoc}
*/
public function createRefundRequestData(AbstractPosAccount $posAccount, array $order): array
public function createRefundRequestData(AbstractPosAccount $posAccount, array $order, string $refundTxType): array
{
$order = $this->prepareRefundOrder($order);

Expand All @@ -263,13 +269,13 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o
'Version' => self::API_VERSION,
'Terminal' => $this->getTerminalData($posAccount, true),
'Customer' => [
'IPAddress' => $order['ip'],
'IPAddress' => $order['ip'],
],
'Order' => [
'OrderID' => $order['id'],
],
'Transaction' => [
'Type' => $this->mapTxType(PosInterface::TX_TYPE_REFUND),
'Type' => $this->mapTxType($refundTxType),
'InstallmentCnt' => $this->mapInstallment($order['installment']),
'Amount' => $this->formatAmount($order['amount']), //sabit olarak amount 100 gonderilecek,
'CurrencyCode' => $this->mapCurrency($order['currency']),
Expand Down Expand Up @@ -298,13 +304,13 @@ public function createOrderHistoryRequestData(AbstractPosAccount $posAccount, ar
'Version' => self::API_VERSION,
'Terminal' => $this->getTerminalData($posAccount),
'Customer' => [
'IPAddress' => $order['ip'],
'IPAddress' => $order['ip'],
],
'Order' => [
'OrderID' => $order['id'],
],
'Transaction' => [
'Type' => $this->mapTxType(PosInterface::TX_TYPE_HISTORY),
'Type' => $this->mapTxType(PosInterface::TX_TYPE_ORDER_HISTORY),
'InstallmentCnt' => $this->mapInstallment($order['installment']),
'Amount' => $this->formatAmount($order['amount']), //sabit olarak amount 100 gonderilecek
'CurrencyCode' => $this->mapCurrency($order['currency']),
Expand All @@ -319,11 +325,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 +502,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 +626,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 19918e5

Please sign in to comment.