diff --git a/examples/_templates/_header.php b/examples/_templates/_header.php
index e6ea1387..1f986eb0 100644
--- a/examples/_templates/_header.php
+++ b/examples/_templates/_header.php
@@ -6,84 +6,137 @@
= $templateTitle; ?>
-
-
+
+
diff --git a/examples/_templates/_payment_secure_response.php b/examples/_templates/_payment_secure_response.php
index a5b65807..8a61886b 100644
--- a/examples/_templates/_payment_secure_response.php
+++ b/examples/_templates/_payment_secure_response.php
@@ -106,11 +106,11 @@
if (window.opener && window.opener !== window) {
// you are in a popup
// send result data to parent window
- window.opener.parent.postMessage(`= json_encode($response); ?>`);
+ window.opener.parent.postMessage(`= base64_encode(json_encode($response)); ?>`);
} else if (window.parent) {
// you are in iframe
// send result data to parent window
- window.parent.postMessage(`= json_encode($response); ?>`);
+ window.parent.postMessage(`= base64_encode(json_encode($response)); ?>`);
}
diff --git a/examples/_templates/_render_payment_response.php b/examples/_templates/_render_payment_response.php
index c6f22679..5ca015c2 100644
--- a/examples/_templates/_render_payment_response.php
+++ b/examples/_templates/_render_payment_response.php
@@ -81,7 +81,7 @@
Cancel payment
-
Payment Status
+
Payment Status
< Click to payment form
diff --git a/examples/posnet-ykb/3d/_config.php b/examples/posnet-ykb/3d/_config.php
index abfc86ce..22cc7214 100644
--- a/examples/posnet-ykb/3d/_config.php
+++ b/examples/posnet-ykb/3d/_config.php
@@ -6,6 +6,9 @@
require '../_payment_config.php';
$baseUrl = $bankTestsUrl.'/3d/';
+// NOT: PosNet testleri lokalde yapilamiyor.
+// Ortam farketmeksizin Yapikrediyle iletisime gecip, sunucu IP adresinize izin verilmesini sağlamanız gerekiyor.
+
//account bilgileri kendi account bilgilerinizle degistiriniz
$account = AccountFactory::createPosNetAccount(
'yapikredi',
diff --git a/src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php
index b070454d..02620c82 100644
--- a/src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php
+++ b/src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php
@@ -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',
];
/**
@@ -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' => [
diff --git a/src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php
index cdd53a23..8a01b4c5 100644
--- a/src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php
+++ b/src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php
@@ -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',
];
/**
@@ -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'])) {
diff --git a/src/DataMapper/RequestDataMapper/GarantiPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/GarantiPosRequestDataMapper.php
index 0ad98f79..21c333ba 100644
--- a/src/DataMapper/RequestDataMapper/GarantiPosRequestDataMapper.php
+++ b/src/DataMapper/RequestDataMapper/GarantiPosRequestDataMapper.php
@@ -51,14 +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_ORDER_HISTORY => 'orderhistoryinq',
- PosInterface::TX_TYPE_HISTORY => 'orderlistinq',
- 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 = [
@@ -259,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);
@@ -274,7 +275,7 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o
'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']),
diff --git a/src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php
index b64e9c7b..fa7219ba 100644
--- a/src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php
+++ b/src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php
@@ -42,12 +42,13 @@ class InterPosRequestDataMapper 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 => 'Refund',
- PosInterface::TX_TYPE_STATUS => 'StatusHistory',
+ 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 => 'Refund',
+ PosInterface::TX_TYPE_REFUND_PARTIAL => 'Refund',
+ PosInterface::TX_TYPE_STATUS => 'StatusHistory',
];
/**
@@ -170,7 +171,7 @@ public function createCancelRequestData(AbstractPosAccount $posAccount, array $o
* {@inheritDoc}
* @return array{OrderId: null, orgOrderId: string, PurchAmount: string, TxnType: string, SecureType: string, Lang: string, MOTO: string, UserCode: string, UserPass: string, ShopCode: string}
*/
- public function createRefundRequestData(AbstractPosAccount $posAccount, array $order): array
+ public function createRefundRequestData(AbstractPosAccount $posAccount, array $order, string $refundTxType): array
{
$order = $this->prepareRefundOrder($order);
@@ -178,7 +179,7 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o
'OrderId' => null,
'orgOrderId' => (string) $order['id'],
'PurchAmount' => (string) $order['amount'],
- 'TxnType' => $this->mapTxType(PosInterface::TX_TYPE_REFUND),
+ 'TxnType' => $this->mapTxType($refundTxType),
'SecureType' => $this->secureTypeMappings[PosInterface::MODEL_NON_SECURE],
'Lang' => $this->getLang($posAccount, $order),
'MOTO' => self::MOTO,
diff --git a/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php
index 739dd145..12ba644e 100644
--- a/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php
+++ b/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php
@@ -40,10 +40,11 @@ class KuveytPosRequestDataMapper extends AbstractRequestDataMapper
* {@inheritDoc}
*/
protected array $txTypeMappings = [
- PosInterface::TX_TYPE_PAY_AUTH => 'Sale',
- PosInterface::TX_TYPE_CANCEL => 'SaleReversal',
- PosInterface::TX_TYPE_STATUS => 'GetMerchantOrderDetail',
- PosInterface::TX_TYPE_REFUND => 'Drawback', // Also there is a "PartialDrawback"
+ PosInterface::TX_TYPE_PAY_AUTH => 'Sale',
+ PosInterface::TX_TYPE_CANCEL => 'SaleReversal',
+ PosInterface::TX_TYPE_STATUS => 'GetMerchantOrderDetail',
+ PosInterface::TX_TYPE_REFUND => 'Drawback',
+ PosInterface::TX_TYPE_REFUND_PARTIAL => 'PartialDrawback',
];
/**
@@ -309,13 +310,10 @@ public function createCancelRequestData(AbstractPosAccount $posAccount, array $o
* @param KuveytPosAccount $posAccount
* {@inheritDoc}
*/
- public function createRefundRequestData(AbstractPosAccount $posAccount, array $order): array
+ public function createRefundRequestData(AbstractPosAccount $posAccount, array $order, string $refundTxType): array
{
$order = $this->prepareRefundOrder($order);
- $isPartialRefund = isset($order['order_amount']) && $order['order_amount'] > $order['amount'];
- $txType = $isPartialRefund ? 'PartialDrawback' : $this->mapTxType(PosInterface::TX_TYPE_REFUND);
-
$result = [
'IsFromExternalNetwork' => true,
'BusinessKey' => 0,
@@ -337,7 +335,7 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o
'SubMerchantId' => 0,
'CardType' => $this->cardTypeMapping[CreditCardInterface::CARD_TYPE_VISA], //Default gönderilebilir.
'BatchID' => 0,
- 'TransactionType' => $txType,
+ 'TransactionType' => $this->mapTxType($refundTxType),
'InstallmentCount' => 0,
'Amount' => $this->formatAmount($order['amount']),
'DisplayAmount' => 0,
@@ -466,7 +464,6 @@ protected function prepareRefundOrder(array $order): array
'auth_code' => $order['auth_code'],
'transaction_id' => $order['transaction_id'],
'amount' => $order['amount'],
- 'order_amount' => $order['order_amount'] ?? null,
'currency' => $order['currency'] ?? PosInterface::CURRENCY_TRY,
]);
}
diff --git a/src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php
index ec53fee0..0ca2d167 100644
--- a/src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php
+++ b/src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php
@@ -24,13 +24,14 @@ class PayFlexCPV4PosRequestDataMapper extends AbstractRequestDataMapper
* {@inheritDoc}
*/
protected array $txTypeMappings = [
- PosInterface::TX_TYPE_PAY_AUTH => 'Sale',
- PosInterface::TX_TYPE_PAY_PRE_AUTH => 'Auth',
- PosInterface::TX_TYPE_PAY_POST_AUTH => 'Capture',
- PosInterface::TX_TYPE_CANCEL => 'Cancel',
- PosInterface::TX_TYPE_REFUND => 'Refund',
- PosInterface::TX_TYPE_HISTORY => 'TxnHistory',
- PosInterface::TX_TYPE_STATUS => 'OrderInquiry',
+ PosInterface::TX_TYPE_PAY_AUTH => 'Sale',
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => 'Auth',
+ PosInterface::TX_TYPE_PAY_POST_AUTH => 'Capture',
+ PosInterface::TX_TYPE_CANCEL => 'Cancel',
+ PosInterface::TX_TYPE_REFUND => 'Refund',
+ PosInterface::TX_TYPE_REFUND_PARTIAL => 'Refund',
+ PosInterface::TX_TYPE_HISTORY => 'TxnHistory',
+ PosInterface::TX_TYPE_STATUS => 'OrderInquiry',
];
/**
@@ -241,12 +242,12 @@ public function createCancelRequestData(AbstractPosAccount $posAccount, array $o
* @return array{MerchantId: string, Password: string, TransactionType: string, ReferenceTransactionId: string,
* ClientIp: string, CurrencyAmount: string}
*/
- public function createRefundRequestData(AbstractPosAccount $posAccount, array $order): array
+ public function createRefundRequestData(AbstractPosAccount $posAccount, array $order, string $refundTxType): array
{
$order = $this->prepareRefundOrder($order);
return $this->getRequestAccountData($posAccount) + [
- 'TransactionType' => $this->mapTxType(PosInterface::TX_TYPE_REFUND),
+ 'TransactionType' => $this->mapTxType($refundTxType),
'ReferenceTransactionId' => (string) $order['transaction_id'],
'ClientIp' => (string) $order['ip'],
'CurrencyAmount' => $this->formatAmount($order['amount']),
diff --git a/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php
index 4c019ee2..c2637081 100644
--- a/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php
+++ b/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php
@@ -28,12 +28,13 @@ class PayFlexV4PosRequestDataMapper extends AbstractRequestDataMapper
* {@inheritDoc}
*/
protected array $txTypeMappings = [
- PosInterface::TX_TYPE_PAY_AUTH => 'Sale',
- PosInterface::TX_TYPE_PAY_PRE_AUTH => 'Auth',
- PosInterface::TX_TYPE_PAY_POST_AUTH => 'Capture',
- PosInterface::TX_TYPE_CANCEL => 'Cancel',
- PosInterface::TX_TYPE_REFUND => 'Refund',
- PosInterface::TX_TYPE_STATUS => 'status',
+ PosInterface::TX_TYPE_PAY_AUTH => 'Sale',
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => 'Auth',
+ PosInterface::TX_TYPE_PAY_POST_AUTH => 'Capture',
+ PosInterface::TX_TYPE_CANCEL => 'Cancel',
+ PosInterface::TX_TYPE_REFUND => 'Refund',
+ PosInterface::TX_TYPE_REFUND_PARTIAL => 'Refund',
+ PosInterface::TX_TYPE_STATUS => 'status',
];
/**
@@ -233,14 +234,14 @@ public function createCancelRequestData(AbstractPosAccount $posAccount, array $o
* @return array{MerchantId: string, Password: string, TransactionType: string, ReferenceTransactionId: string,
* ClientIp: string, CurrencyAmount: string}
*/
- public function createRefundRequestData(AbstractPosAccount $posAccount, array $order): array
+ public function createRefundRequestData(AbstractPosAccount $posAccount, array $order, string $refundTxType): array
{
$order = $this->prepareRefundOrder($order);
return [
'MerchantId' => $posAccount->getClientId(),
'Password' => $posAccount->getPassword(),
- 'TransactionType' => $this->mapTxType(PosInterface::TX_TYPE_REFUND),
+ 'TransactionType' => $this->mapTxType($refundTxType),
'ReferenceTransactionId' => (string) $order['transaction_id'],
'ClientIp' => (string) $order['ip'],
'CurrencyAmount' => $this->formatAmount($order['amount']),
diff --git a/src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php
index 8d60dbcd..7a03c07d 100644
--- a/src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php
+++ b/src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php
@@ -43,13 +43,14 @@ class PayForPosRequestDataMapper 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 => 'Refund',
- PosInterface::TX_TYPE_HISTORY => 'TxnHistory',
- PosInterface::TX_TYPE_STATUS => 'OrderInquiry',
+ 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 => 'Refund',
+ PosInterface::TX_TYPE_REFUND_PARTIAL => 'Refund',
+ PosInterface::TX_TYPE_HISTORY => 'TxnHistory',
+ PosInterface::TX_TYPE_STATUS => 'OrderInquiry',
];
/**
@@ -155,7 +156,7 @@ public function createCancelRequestData(AbstractPosAccount $posAccount, array $o
* {@inheritDoc}
* @return array{MbrId: string, SecureType: string, Lang: string, OrgOrderId: string, TxnType: string, PurchAmount: string, Currency: string, MerchantId: string, UserCode: string, UserPass: string}
*/
- public function createRefundRequestData(AbstractPosAccount $posAccount, array $order): array
+ public function createRefundRequestData(AbstractPosAccount $posAccount, array $order, string $refundTxType): array
{
$order = $this->prepareRefundOrder($order);
@@ -164,7 +165,7 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o
'SecureType' => $this->secureTypeMappings[PosInterface::MODEL_NON_SECURE],
'Lang' => $this->getLang($posAccount, $order),
'OrgOrderId' => (string) $order['id'],
- 'TxnType' => $this->mapTxType(PosInterface::TX_TYPE_REFUND),
+ 'TxnType' => $this->mapTxType($refundTxType),
'PurchAmount' => (string) $order['amount'],
'Currency' => $this->mapCurrency($order['currency']),
];
diff --git a/src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php
index 8a94bf64..d2d5a711 100644
--- a/src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php
+++ b/src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php
@@ -46,12 +46,13 @@ class PosNetRequestDataMapper extends AbstractRequestDataMapper
* {@inheritDoc}
*/
protected array $txTypeMappings = [
- PosInterface::TX_TYPE_PAY_AUTH => 'Sale',
- PosInterface::TX_TYPE_PAY_PRE_AUTH => 'Auth',
- PosInterface::TX_TYPE_PAY_POST_AUTH => 'Capt',
- PosInterface::TX_TYPE_CANCEL => 'reverse',
- PosInterface::TX_TYPE_REFUND => 'return',
- PosInterface::TX_TYPE_STATUS => 'agreement',
+ PosInterface::TX_TYPE_PAY_AUTH => 'Sale',
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => 'Auth',
+ PosInterface::TX_TYPE_PAY_POST_AUTH => 'Capt',
+ PosInterface::TX_TYPE_CANCEL => 'reverse',
+ PosInterface::TX_TYPE_REFUND => 'return',
+ PosInterface::TX_TYPE_REFUND_PARTIAL => 'return',
+ PosInterface::TX_TYPE_STATUS => 'agreement',
];
/**
@@ -201,11 +202,11 @@ 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);
- $txType = $this->mapTxType(PosInterface::TX_TYPE_REFUND);
+ $txType = $this->mapTxType($refundTxType);
$requestData = [
'mid' => $posAccount->getClientId(),
'tid' => $posAccount->getTerminalId(),
diff --git a/src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php
index 3c98209e..2e912cb2 100644
--- a/src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php
+++ b/src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php
@@ -51,12 +51,13 @@ class PosNetV1PosRequestDataMapper extends AbstractRequestDataMapper
* {@inheritDoc}
*/
protected array $txTypeMappings = [
- PosInterface::TX_TYPE_PAY_AUTH => 'Sale',
- PosInterface::TX_TYPE_PAY_PRE_AUTH => 'Auth',
- PosInterface::TX_TYPE_PAY_POST_AUTH => 'Capture',
- PosInterface::TX_TYPE_CANCEL => 'Reverse',
- PosInterface::TX_TYPE_REFUND => 'Return',
- PosInterface::TX_TYPE_STATUS => 'TransactionInquiry',
+ PosInterface::TX_TYPE_PAY_AUTH => 'Sale',
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => 'Auth',
+ PosInterface::TX_TYPE_PAY_POST_AUTH => 'Capture',
+ PosInterface::TX_TYPE_CANCEL => 'Reverse',
+ PosInterface::TX_TYPE_REFUND => 'Return',
+ PosInterface::TX_TYPE_REFUND_PARTIAL => 'Return',
+ PosInterface::TX_TYPE_STATUS => 'TransactionInquiry',
];
/**
@@ -281,7 +282,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);
diff --git a/src/DataMapper/RequestDataMapper/RequestDataMapperInterface.php b/src/DataMapper/RequestDataMapper/RequestDataMapperInterface.php
index bdf3919c..9fe2a730 100644
--- a/src/DataMapper/RequestDataMapper/RequestDataMapperInterface.php
+++ b/src/DataMapper/RequestDataMapper/RequestDataMapperInterface.php
@@ -135,14 +135,17 @@ public function createStatusRequestData(AbstractPosAccount $posAccount, array $o
public function createCancelRequestData(AbstractPosAccount $posAccount, array $order): array;
/**
+ * @phpstan-param PosInterface::TX_TYPE_REFUND* $refundTxType
+ *
* @param AbstractPosAccount $posAccount
* @param array
$order
+ * @param string $refundTxType
*
* @return array
*
* @throws UnsupportedTransactionTypeException
*/
- public function createRefundRequestData(AbstractPosAccount $posAccount, array $order): array;
+ public function createRefundRequestData(AbstractPosAccount $posAccount, array $order, string $refundTxType): array;
/**
* @param AbstractPosAccount $posAccount
diff --git a/src/DataMapper/RequestDataMapper/ToslaPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/ToslaPosRequestDataMapper.php
index 234f61d1..3e50d328 100644
--- a/src/DataMapper/RequestDataMapper/ToslaPosRequestDataMapper.php
+++ b/src/DataMapper/RequestDataMapper/ToslaPosRequestDataMapper.php
@@ -23,11 +23,12 @@ class ToslaPosRequestDataMapper extends AbstractRequestDataMapper
* {@inheritDoc}
*/
protected array $txTypeMappings = [
- PosInterface::TX_TYPE_PAY_AUTH => '1',
- PosInterface::TX_TYPE_PAY_PRE_AUTH => '2',
- PosInterface::TX_TYPE_PAY_POST_AUTH => '3',
- PosInterface::TX_TYPE_CANCEL => '4',
- PosInterface::TX_TYPE_REFUND => '5',
+ PosInterface::TX_TYPE_PAY_AUTH => '1',
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => '2',
+ PosInterface::TX_TYPE_PAY_POST_AUTH => '3',
+ PosInterface::TX_TYPE_CANCEL => '4',
+ PosInterface::TX_TYPE_REFUND => '5',
+ PosInterface::TX_TYPE_REFUND_PARTIAL => '5',
];
/**
@@ -146,7 +147,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);
diff --git a/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php
index 606025f5..466b193c 100644
--- a/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php
+++ b/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php
@@ -34,13 +34,6 @@ class VakifKatilimPosRequestDataMapper extends AbstractRequestDataMapper
PosInterface::MODEL_NON_SECURE => '5',
];
- /**
- * {@inheritDoc}
- */
- protected array $txTypeMappings = [
- PosInterface::TX_TYPE_PAY_AUTH => '1',
- ];
-
/**
* Currency mapping
*
@@ -229,7 +222,7 @@ public function createCancelRequestData(AbstractPosAccount $posAccount, array $o
* @param KuveytPosAccount $posAccount
* {@inheritDoc}
*/
- public function createRefundRequestData(AbstractPosAccount $posAccount, array $order): array
+ public function createRefundRequestData(AbstractPosAccount $posAccount, array $order, string $refundTxType): array
{
$order = $this->prepareRefundOrder($order);
diff --git a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php
index 60460e0d..ef4c5723 100644
--- a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php
+++ b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php
@@ -196,6 +196,9 @@ public function mapStatusResponse(array $rawResponseData): array
return $defaultResponse;
}
+ /**
+ * @inheritDoc
+ */
public function mapRefundResponse(array $rawResponseData): array
{
$rawResponseData = $this->emptyStringsToNull($rawResponseData);
diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php
index 03ccd7f8..3d4fc245 100644
--- a/src/Gateways/AbstractGateway.php
+++ b/src/Gateways/AbstractGateway.php
@@ -311,7 +311,10 @@ public function makeRegularPostPayment(array $order): PosInterface
public function refund(array $order): PosInterface
{
$txType = PosInterface::TX_TYPE_REFUND;
- $requestData = $this->requestDataMapper->createRefundRequestData($this->account, $order);
+ if (isset($order['order_amount']) && $order['amount'] < $order['order_amount']) {
+ $txType = PosInterface::TX_TYPE_REFUND_PARTIAL;
+ }
+ $requestData = $this->requestDataMapper->createRefundRequestData($this->account, $order, $txType);
$event = new RequestDataPreparedEvent(
$requestData,
diff --git a/src/Gateways/AkbankPos.php b/src/Gateways/AkbankPos.php
index d374bc7f..54d2b752 100644
--- a/src/Gateways/AkbankPos.php
+++ b/src/Gateways/AkbankPos.php
@@ -27,19 +27,20 @@ class AkbankPos extends AbstractGateway
/** @inheritdoc */
protected static array $supportedTransactions = [
- PosInterface::TX_TYPE_PAY_AUTH => [
+ PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_3D_SECURE,
PosInterface::MODEL_3D_PAY,
PosInterface::MODEL_3D_HOST,
PosInterface::MODEL_NON_SECURE,
],
- PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
- PosInterface::TX_TYPE_PAY_POST_AUTH => true,
- PosInterface::TX_TYPE_STATUS => false,
- PosInterface::TX_TYPE_CANCEL => true,
- PosInterface::TX_TYPE_REFUND => true,
- PosInterface::TX_TYPE_ORDER_HISTORY => true,
- PosInterface::TX_TYPE_HISTORY => true,
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
+ PosInterface::TX_TYPE_PAY_POST_AUTH => true,
+ PosInterface::TX_TYPE_STATUS => false,
+ PosInterface::TX_TYPE_CANCEL => true,
+ PosInterface::TX_TYPE_REFUND => true,
+ PosInterface::TX_TYPE_REFUND_PARTIAL => true,
+ PosInterface::TX_TYPE_ORDER_HISTORY => true,
+ PosInterface::TX_TYPE_HISTORY => true,
];
/**
@@ -196,7 +197,7 @@ protected function send($contents, string $txType, string $paymentModel, string
$response = $this->client->post($url, [
'headers' => [
'Content-Type' => 'application/json',
- 'auth-hash' => $hash,
+ 'auth-hash' => $hash,
],
'body' => $contents,
]);
diff --git a/src/Gateways/EstPos.php b/src/Gateways/EstPos.php
index 8f0b84c6..9fc39856 100644
--- a/src/Gateways/EstPos.php
+++ b/src/Gateways/EstPos.php
@@ -30,20 +30,21 @@ class EstPos extends AbstractGateway
/** @inheritdoc */
protected static array $supportedTransactions = [
- PosInterface::TX_TYPE_PAY_AUTH => [
+ PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_3D_SECURE,
PosInterface::MODEL_3D_PAY,
PosInterface::MODEL_3D_HOST,
PosInterface::MODEL_3D_PAY_HOSTING,
PosInterface::MODEL_NON_SECURE,
],
- PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
- PosInterface::TX_TYPE_PAY_POST_AUTH => true,
- PosInterface::TX_TYPE_STATUS => true,
- PosInterface::TX_TYPE_CANCEL => true,
- PosInterface::TX_TYPE_REFUND => true,
- PosInterface::TX_TYPE_ORDER_HISTORY => true,
- PosInterface::TX_TYPE_HISTORY => false,
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
+ PosInterface::TX_TYPE_PAY_POST_AUTH => true,
+ PosInterface::TX_TYPE_STATUS => true,
+ PosInterface::TX_TYPE_CANCEL => true,
+ PosInterface::TX_TYPE_REFUND => true,
+ PosInterface::TX_TYPE_REFUND_PARTIAL => true,
+ PosInterface::TX_TYPE_ORDER_HISTORY => true,
+ PosInterface::TX_TYPE_HISTORY => false,
];
diff --git a/src/Gateways/GarantiPos.php b/src/Gateways/GarantiPos.php
index b54fc28a..4824c711 100644
--- a/src/Gateways/GarantiPos.php
+++ b/src/Gateways/GarantiPos.php
@@ -36,18 +36,19 @@ class GarantiPos extends AbstractGateway
/** @inheritdoc */
protected static array $supportedTransactions = [
- PosInterface::TX_TYPE_PAY_AUTH => [
+ PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_3D_SECURE,
PosInterface::MODEL_3D_PAY,
PosInterface::MODEL_NON_SECURE,
],
- PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
- PosInterface::TX_TYPE_PAY_POST_AUTH => true,
- PosInterface::TX_TYPE_STATUS => true,
- PosInterface::TX_TYPE_CANCEL => true,
- PosInterface::TX_TYPE_REFUND => true,
- PosInterface::TX_TYPE_ORDER_HISTORY => true,
- PosInterface::TX_TYPE_HISTORY => true,
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
+ PosInterface::TX_TYPE_PAY_POST_AUTH => true,
+ PosInterface::TX_TYPE_STATUS => true,
+ PosInterface::TX_TYPE_CANCEL => true,
+ PosInterface::TX_TYPE_REFUND => true,
+ PosInterface::TX_TYPE_REFUND_PARTIAL => true,
+ PosInterface::TX_TYPE_ORDER_HISTORY => true,
+ PosInterface::TX_TYPE_HISTORY => true,
];
diff --git a/src/Gateways/InterPos.php b/src/Gateways/InterPos.php
index b121a76f..b2b450d9 100644
--- a/src/Gateways/InterPos.php
+++ b/src/Gateways/InterPos.php
@@ -39,19 +39,20 @@ class InterPos extends AbstractGateway
/** @inheritdoc */
protected static array $supportedTransactions = [
- PosInterface::TX_TYPE_PAY_AUTH => [
+ PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_3D_SECURE,
PosInterface::MODEL_3D_PAY,
PosInterface::MODEL_3D_HOST,
PosInterface::MODEL_NON_SECURE,
],
- PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
- PosInterface::TX_TYPE_PAY_POST_AUTH => true,
- PosInterface::TX_TYPE_STATUS => true,
- PosInterface::TX_TYPE_CANCEL => true,
- PosInterface::TX_TYPE_REFUND => true,
- PosInterface::TX_TYPE_HISTORY => false,
- PosInterface::TX_TYPE_ORDER_HISTORY => false,
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
+ PosInterface::TX_TYPE_PAY_POST_AUTH => true,
+ PosInterface::TX_TYPE_STATUS => true,
+ PosInterface::TX_TYPE_CANCEL => true,
+ PosInterface::TX_TYPE_REFUND => true,
+ PosInterface::TX_TYPE_REFUND_PARTIAL => true,
+ PosInterface::TX_TYPE_HISTORY => false,
+ PosInterface::TX_TYPE_ORDER_HISTORY => false,
];
/** @return InterPosAccount */
diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php
index 344f8d6f..fcab2e4a 100644
--- a/src/Gateways/KuveytPos.php
+++ b/src/Gateways/KuveytPos.php
@@ -43,17 +43,18 @@ class KuveytPos extends AbstractGateway
/** @inheritdoc */
protected static array $supportedTransactions = [
- PosInterface::TX_TYPE_PAY_AUTH => [
+ PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_NON_SECURE,
PosInterface::MODEL_3D_SECURE,
],
- PosInterface::TX_TYPE_PAY_PRE_AUTH => false,
- PosInterface::TX_TYPE_PAY_POST_AUTH => false,
- PosInterface::TX_TYPE_STATUS => true,
- PosInterface::TX_TYPE_CANCEL => true,
- PosInterface::TX_TYPE_REFUND => true,
- PosInterface::TX_TYPE_HISTORY => false,
- PosInterface::TX_TYPE_ORDER_HISTORY => false,
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => false,
+ PosInterface::TX_TYPE_PAY_POST_AUTH => false,
+ PosInterface::TX_TYPE_STATUS => true,
+ PosInterface::TX_TYPE_CANCEL => true,
+ PosInterface::TX_TYPE_REFUND => true,
+ PosInterface::TX_TYPE_REFUND_PARTIAL => true,
+ PosInterface::TX_TYPE_HISTORY => false,
+ PosInterface::TX_TYPE_ORDER_HISTORY => false,
];
/** @return KuveytPosAccount */
@@ -73,6 +74,7 @@ public function getApiURL(string $txType = null, string $paymentModel = null, ?s
$txType,
[
PosInterface::TX_TYPE_REFUND,
+ PosInterface::TX_TYPE_REFUND_PARTIAL,
PosInterface::TX_TYPE_STATUS,
PosInterface::TX_TYPE_CANCEL,
],
@@ -211,7 +213,12 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
*/
protected function send($contents, string $txType, string $paymentModel, string $url): array
{
- if (\in_array($txType, [PosInterface::TX_TYPE_REFUND, PosInterface::TX_TYPE_STATUS, PosInterface::TX_TYPE_CANCEL], true)) {
+ if (\in_array($txType, [
+ PosInterface::TX_TYPE_REFUND,
+ PosInterface::TX_TYPE_REFUND_PARTIAL,
+ PosInterface::TX_TYPE_STATUS,
+ PosInterface::TX_TYPE_CANCEL,
+ ], true)) {
if (!\is_array($contents)) {
throw new InvalidArgumentException(\sprintf('Invalid data type provided for %s transaction!', $txType));
}
@@ -233,7 +240,7 @@ protected function send($contents, string $txType, string $paymentModel, string
}
/**
- * @phpstan-param PosInterface::TX_TYPE_STATUS|PosInterface::TX_TYPE_REFUND|PosInterface::TX_TYPE_CANCEL $txType
+ * @phpstan-param PosInterface::TX_TYPE_STATUS|PosInterface::TX_TYPE_REFUND|PosInterface::TX_TYPE_REFUND_PARTIAL|PosInterface::TX_TYPE_CANCEL $txType
*
* @param array $contents
* @param string $txType
diff --git a/src/Gateways/PayFlexCPV4Pos.php b/src/Gateways/PayFlexCPV4Pos.php
index 9915391a..fe9bab34 100644
--- a/src/Gateways/PayFlexCPV4Pos.php
+++ b/src/Gateways/PayFlexCPV4Pos.php
@@ -39,18 +39,19 @@ class PayFlexCPV4Pos extends AbstractGateway
/** @inheritdoc */
protected static array $supportedTransactions = [
- PosInterface::TX_TYPE_PAY_AUTH => [
+ PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_3D_PAY,
PosInterface::MODEL_3D_HOST,
PosInterface::MODEL_NON_SECURE,
],
- PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
- PosInterface::TX_TYPE_PAY_POST_AUTH => true,
- PosInterface::TX_TYPE_STATUS => false,
- PosInterface::TX_TYPE_CANCEL => true,
- PosInterface::TX_TYPE_REFUND => true,
- PosInterface::TX_TYPE_HISTORY => false,
- PosInterface::TX_TYPE_ORDER_HISTORY => false,
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
+ PosInterface::TX_TYPE_PAY_POST_AUTH => true,
+ PosInterface::TX_TYPE_STATUS => false,
+ PosInterface::TX_TYPE_CANCEL => true,
+ PosInterface::TX_TYPE_REFUND => true,
+ PosInterface::TX_TYPE_REFUND_PARTIAL => true,
+ PosInterface::TX_TYPE_HISTORY => false,
+ PosInterface::TX_TYPE_ORDER_HISTORY => false,
];
/** @return PayFlexAccount */
diff --git a/src/Gateways/PayFlexV4Pos.php b/src/Gateways/PayFlexV4Pos.php
index 93d38102..13af344f 100644
--- a/src/Gateways/PayFlexV4Pos.php
+++ b/src/Gateways/PayFlexV4Pos.php
@@ -41,17 +41,18 @@ class PayFlexV4Pos extends AbstractGateway
/** @inheritdoc */
protected static array $supportedTransactions = [
- PosInterface::TX_TYPE_PAY_AUTH => [
+ PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_3D_SECURE,
PosInterface::MODEL_NON_SECURE,
],
- PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
- PosInterface::TX_TYPE_PAY_POST_AUTH => true,
- PosInterface::TX_TYPE_STATUS => true,
- PosInterface::TX_TYPE_CANCEL => true,
- PosInterface::TX_TYPE_REFUND => true,
- PosInterface::TX_TYPE_HISTORY => false,
- PosInterface::TX_TYPE_ORDER_HISTORY => false,
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
+ PosInterface::TX_TYPE_PAY_POST_AUTH => true,
+ PosInterface::TX_TYPE_STATUS => true,
+ PosInterface::TX_TYPE_CANCEL => true,
+ PosInterface::TX_TYPE_REFUND => true,
+ PosInterface::TX_TYPE_REFUND_PARTIAL => true,
+ PosInterface::TX_TYPE_HISTORY => false,
+ PosInterface::TX_TYPE_ORDER_HISTORY => false,
];
/** @return PayFlexAccount */
diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php
index bc9d2958..4b0a2a05 100644
--- a/src/Gateways/PayForPos.php
+++ b/src/Gateways/PayForPos.php
@@ -36,19 +36,20 @@ class PayForPos extends AbstractGateway
/** @inheritdoc */
protected static array $supportedTransactions = [
- PosInterface::TX_TYPE_PAY_AUTH => [
+ PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_3D_SECURE,
PosInterface::MODEL_3D_PAY,
PosInterface::MODEL_3D_HOST,
PosInterface::MODEL_NON_SECURE,
],
- PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
- PosInterface::TX_TYPE_PAY_POST_AUTH => true,
- PosInterface::TX_TYPE_STATUS => true,
- PosInterface::TX_TYPE_CANCEL => true,
- PosInterface::TX_TYPE_REFUND => true,
- PosInterface::TX_TYPE_HISTORY => true,
- PosInterface::TX_TYPE_ORDER_HISTORY => true,
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
+ PosInterface::TX_TYPE_PAY_POST_AUTH => true,
+ PosInterface::TX_TYPE_STATUS => true,
+ PosInterface::TX_TYPE_CANCEL => true,
+ PosInterface::TX_TYPE_REFUND => true,
+ PosInterface::TX_TYPE_REFUND_PARTIAL => true,
+ PosInterface::TX_TYPE_HISTORY => true,
+ PosInterface::TX_TYPE_ORDER_HISTORY => true,
];
/** @return PayForAccount */
diff --git a/src/Gateways/PosNet.php b/src/Gateways/PosNet.php
index 7a7f2806..bf7317a6 100644
--- a/src/Gateways/PosNet.php
+++ b/src/Gateways/PosNet.php
@@ -41,17 +41,18 @@ class PosNet extends AbstractGateway
/** @inheritdoc */
protected static array $supportedTransactions = [
- PosInterface::TX_TYPE_PAY_AUTH => [
+ PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_3D_SECURE,
PosInterface::MODEL_NON_SECURE,
],
- PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
- PosInterface::TX_TYPE_PAY_POST_AUTH => true,
- PosInterface::TX_TYPE_STATUS => true,
- PosInterface::TX_TYPE_CANCEL => true,
- PosInterface::TX_TYPE_REFUND => true,
- PosInterface::TX_TYPE_HISTORY => false,
- PosInterface::TX_TYPE_ORDER_HISTORY => false,
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
+ PosInterface::TX_TYPE_PAY_POST_AUTH => true,
+ PosInterface::TX_TYPE_STATUS => true,
+ PosInterface::TX_TYPE_CANCEL => true,
+ PosInterface::TX_TYPE_REFUND => true,
+ PosInterface::TX_TYPE_REFUND_PARTIAL => true,
+ PosInterface::TX_TYPE_HISTORY => false,
+ PosInterface::TX_TYPE_ORDER_HISTORY => false,
];
/**
diff --git a/src/Gateways/PosNetV1Pos.php b/src/Gateways/PosNetV1Pos.php
index 759f24e1..adf17d20 100644
--- a/src/Gateways/PosNetV1Pos.php
+++ b/src/Gateways/PosNetV1Pos.php
@@ -36,17 +36,18 @@ class PosNetV1Pos extends AbstractGateway
/** @inheritdoc */
protected static array $supportedTransactions = [
- PosInterface::TX_TYPE_PAY_AUTH => [
+ PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_3D_SECURE,
PosInterface::MODEL_NON_SECURE,
],
- PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
- PosInterface::TX_TYPE_PAY_POST_AUTH => true,
- PosInterface::TX_TYPE_STATUS => true,
- PosInterface::TX_TYPE_CANCEL => true,
- PosInterface::TX_TYPE_REFUND => true,
- PosInterface::TX_TYPE_HISTORY => false,
- PosInterface::TX_TYPE_ORDER_HISTORY => false,
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => true,
+ PosInterface::TX_TYPE_PAY_POST_AUTH => true,
+ PosInterface::TX_TYPE_STATUS => true,
+ PosInterface::TX_TYPE_CANCEL => true,
+ PosInterface::TX_TYPE_REFUND => true,
+ PosInterface::TX_TYPE_REFUND_PARTIAL => true,
+ PosInterface::TX_TYPE_HISTORY => false,
+ PosInterface::TX_TYPE_ORDER_HISTORY => false,
];
/** @return PosNetAccount */
diff --git a/src/Gateways/ToslaPos.php b/src/Gateways/ToslaPos.php
index 20770418..7cb51ce1 100644
--- a/src/Gateways/ToslaPos.php
+++ b/src/Gateways/ToslaPos.php
@@ -49,12 +49,13 @@ class ToslaPos extends AbstractGateway
PosInterface::MODEL_3D_HOST,
],
- PosInterface::TX_TYPE_HISTORY => false,
- PosInterface::TX_TYPE_ORDER_HISTORY => true,
- PosInterface::TX_TYPE_PAY_POST_AUTH => true,
- PosInterface::TX_TYPE_CANCEL => true,
- PosInterface::TX_TYPE_REFUND => true,
- PosInterface::TX_TYPE_STATUS => true,
+ PosInterface::TX_TYPE_HISTORY => false,
+ PosInterface::TX_TYPE_ORDER_HISTORY => true,
+ PosInterface::TX_TYPE_PAY_POST_AUTH => true,
+ PosInterface::TX_TYPE_CANCEL => true,
+ PosInterface::TX_TYPE_REFUND => true,
+ PosInterface::TX_TYPE_REFUND_PARTIAL => true,
+ PosInterface::TX_TYPE_STATUS => true,
];
@@ -260,20 +261,21 @@ private function registerPayment(array $order, string $paymentModel, string $txT
private function getRequestURIByTransactionType(string $txType, string $paymentModel): string
{
$arr = [
- PosInterface::TX_TYPE_PAY_AUTH => [
+ PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_NON_SECURE => 'Payment',
PosInterface::MODEL_3D_PAY => 'threeDPayment',
PosInterface::MODEL_3D_HOST => 'threeDPayment',
],
- PosInterface::TX_TYPE_PAY_PRE_AUTH => [
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => [
PosInterface::MODEL_3D_PAY => 'threeDPreAuth',
PosInterface::MODEL_3D_HOST => 'threeDPreAuth',
],
- PosInterface::TX_TYPE_PAY_POST_AUTH => 'postAuth',
- PosInterface::TX_TYPE_CANCEL => 'void',
- PosInterface::TX_TYPE_REFUND => 'refund',
- PosInterface::TX_TYPE_STATUS => 'inquiry',
- PosInterface::TX_TYPE_ORDER_HISTORY => 'history',
+ 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_STATUS => 'inquiry',
+ PosInterface::TX_TYPE_ORDER_HISTORY => 'history',
];
if (!isset($arr[$txType])) {
diff --git a/src/Gateways/VakifKatilimPos.php b/src/Gateways/VakifKatilimPos.php
index 16c67595..2ffa8b59 100644
--- a/src/Gateways/VakifKatilimPos.php
+++ b/src/Gateways/VakifKatilimPos.php
@@ -39,20 +39,21 @@ class VakifKatilimPos extends AbstractGateway
/** @inheritdoc */
protected static array $supportedTransactions = [
- PosInterface::TX_TYPE_PAY_AUTH => [
+ PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_NON_SECURE,
PosInterface::MODEL_3D_SECURE,
PosInterface::MODEL_3D_HOST,
],
- PosInterface::TX_TYPE_PAY_PRE_AUTH => [
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => [
PosInterface::MODEL_NON_SECURE,
],
- PosInterface::TX_TYPE_PAY_POST_AUTH => true,
- PosInterface::TX_TYPE_STATUS => true,
- PosInterface::TX_TYPE_CANCEL => true,
- PosInterface::TX_TYPE_REFUND => true,
- PosInterface::TX_TYPE_HISTORY => true,
- PosInterface::TX_TYPE_ORDER_HISTORY => true,
+ PosInterface::TX_TYPE_PAY_POST_AUTH => true,
+ PosInterface::TX_TYPE_STATUS => true,
+ PosInterface::TX_TYPE_CANCEL => true,
+ PosInterface::TX_TYPE_REFUND => true,
+ PosInterface::TX_TYPE_REFUND_PARTIAL => true,
+ PosInterface::TX_TYPE_HISTORY => true,
+ PosInterface::TX_TYPE_ORDER_HISTORY => true,
];
/** @return KuveytPosAccount */
@@ -244,29 +245,34 @@ private function getRequestURIByTransactionType(string $txType, string $paymentM
$orderTxType ??= PosInterface::TX_TYPE_PAY_AUTH;
$arr = [
- PosInterface::TX_TYPE_PAY_AUTH => [
+ PosInterface::TX_TYPE_PAY_AUTH => [
PosInterface::MODEL_NON_SECURE => 'Non3DPayGate',
PosInterface::MODEL_3D_SECURE => 'ThreeDModelProvisionGate',
],
- PosInterface::TX_TYPE_PAY_PRE_AUTH => [
+ PosInterface::TX_TYPE_PAY_PRE_AUTH => [
PosInterface::MODEL_NON_SECURE => 'PreAuthorizaten',
],
- PosInterface::TX_TYPE_PAY_POST_AUTH => 'PreAuthorizatenClose',
- PosInterface::TX_TYPE_CANCEL => [
+ PosInterface::TX_TYPE_PAY_POST_AUTH => 'PreAuthorizatenClose',
+ PosInterface::TX_TYPE_CANCEL => [
PosInterface::MODEL_NON_SECURE => [
PosInterface::TX_TYPE_PAY_AUTH => 'SaleReversal',
PosInterface::TX_TYPE_PAY_PRE_AUTH => 'PreAuthorizationReversal',
],
],
- PosInterface::TX_TYPE_REFUND => [
+ PosInterface::TX_TYPE_REFUND => [
PosInterface::MODEL_NON_SECURE => [
PosInterface::TX_TYPE_PAY_AUTH => 'DrawBack',
PosInterface::TX_TYPE_PAY_PRE_AUTH => 'PreAuthorizationDrawBack',
],
],
- PosInterface::TX_TYPE_STATUS => 'SelectOrderByMerchantOrderId',
- PosInterface::TX_TYPE_ORDER_HISTORY => 'SelectOrder',
- PosInterface::TX_TYPE_HISTORY => 'SelectOrder',
+ PosInterface::TX_TYPE_REFUND_PARTIAL => [
+ PosInterface::MODEL_NON_SECURE => [
+ PosInterface::TX_TYPE_PAY_AUTH => 'PartialDrawBack',
+ ],
+ ],
+ PosInterface::TX_TYPE_STATUS => 'SelectOrderByMerchantOrderId',
+ PosInterface::TX_TYPE_ORDER_HISTORY => 'SelectOrder',
+ PosInterface::TX_TYPE_HISTORY => 'SelectOrder',
];
if (\is_string($arr[$txType])) {
diff --git a/src/PosInterface.php b/src/PosInterface.php
index 6b149835..0a486a81 100644
--- a/src/PosInterface.php
+++ b/src/PosInterface.php
@@ -39,6 +39,9 @@ interface PosInterface
/** @var string */
public const TX_TYPE_REFUND = 'refund';
+ /** @var string */
+ public const TX_TYPE_REFUND_PARTIAL = 'refund_partial';
+
/** @var string */
public const TX_TYPE_STATUS = 'status';
diff --git a/src/Serializer/KuveytPosSerializer.php b/src/Serializer/KuveytPosSerializer.php
index 365e41f3..a1a9f9c1 100644
--- a/src/Serializer/KuveytPosSerializer.php
+++ b/src/Serializer/KuveytPosSerializer.php
@@ -23,6 +23,7 @@ class KuveytPosSerializer implements SerializerInterface
/** @var string[] */
private array $nonPaymentTransactions = [
PosInterface::TX_TYPE_REFUND,
+ PosInterface::TX_TYPE_REFUND_PARTIAL,
PosInterface::TX_TYPE_STATUS,
PosInterface::TX_TYPE_CANCEL,
];
diff --git a/src/Serializer/PayFlexCPV4PosSerializer.php b/src/Serializer/PayFlexCPV4PosSerializer.php
index 6c61f97c..6822ea75 100644
--- a/src/Serializer/PayFlexCPV4PosSerializer.php
+++ b/src/Serializer/PayFlexCPV4PosSerializer.php
@@ -48,7 +48,9 @@ public function encode(array $data, string $txType)
);
}
- if (PosInterface::TX_TYPE_REFUND === $txType || PosInterface::TX_TYPE_CANCEL === $txType) {
+ if (PosInterface::TX_TYPE_REFUND === $txType
+ || PosInterface::TX_TYPE_REFUND_PARTIAL === $txType
+ || PosInterface::TX_TYPE_CANCEL === $txType) {
return $this->serializer->encode($data, XmlEncoder::FORMAT);
}
diff --git a/tests/Functional/AkbankPosTest.php b/tests/Functional/AkbankPosTest.php
index 667f75e3..74a5fef9 100644
--- a/tests/Functional/AkbankPosTest.php
+++ b/tests/Functional/AkbankPosTest.php
@@ -231,6 +231,33 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThro
return $lastResponse;
}
+ /**
+ * @depends testNonSecurePostPaymentSuccess
+ */
+ public function testRefundSuccess(array $lastResponse): array
+ {
+ $refundOrder = $this->createRefundOrder(\get_class($this->pos), $lastResponse);
+
+ $eventIsThrown = false;
+ $this->eventDispatcher->addListener(
+ RequestDataPreparedEvent::class,
+ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void {
+ $eventIsThrown = true;
+ $this->assertSame(PosInterface::TX_TYPE_REFUND, $requestDataPreparedEvent->getTxType());
+ $this->assertCount(7, $requestDataPreparedEvent->getRequestData());
+ });
+
+ $this->pos->refund($refundOrder);
+
+ $response = $this->pos->getResponse();
+ $this->assertTrue($this->pos->isSuccess(), $response['error_message'] ?? '');
+ $this->assertIsArray($response);
+ $this->assertNotEmpty($response);
+ $this->assertTrue($eventIsThrown);
+
+ return $lastResponse;
+ }
+
public function testNonSecurePaymentRecurringSuccess(): array
{
$order = $this->createPaymentOrder(
@@ -403,6 +430,7 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThro
$this->recurringPos->history($historyOrder);
$response = $this->recurringPos->getResponse();
+ $this->assertTrue($this->recurringPos->isSuccess());
$this->assertIsArray($response);
$this->assertTrue($eventIsThrown);
$this->assertNotEmpty($response['transactions']);
diff --git a/tests/Functional/EstV3PosTest.php b/tests/Functional/EstV3PosTest.php
index f50edc19..da15f1d0 100644
--- a/tests/Functional/EstV3PosTest.php
+++ b/tests/Functional/EstV3PosTest.php
@@ -230,7 +230,7 @@ public function testRefundSuccess(array $lastResponse): array
RequestDataPreparedEvent::class,
function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void {
$eventIsThrown = true;
- $this->assertSame(PosInterface::TX_TYPE_REFUND, $requestDataPreparedEvent->getTxType());
+ $this->assertSame(PosInterface::TX_TYPE_REFUND_PARTIAL, $requestDataPreparedEvent->getTxType());
$this->assertCount(7, $requestDataPreparedEvent->getRequestData());
});
diff --git a/tests/Functional/KuveytPosTest.php b/tests/Functional/KuveytPosTest.php
index 95274b51..5d4fcf40 100644
--- a/tests/Functional/KuveytPosTest.php
+++ b/tests/Functional/KuveytPosTest.php
@@ -287,7 +287,7 @@ public function testPartialRefundSuccess(array $lastResponse): array
RequestDataPreparedEvent::class,
function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void {
$eventIsThrown = true;
- $this->assertSame(PosInterface::TX_TYPE_REFUND, $requestDataPreparedEvent->getTxType());
+ $this->assertSame(PosInterface::TX_TYPE_REFUND_PARTIAL, $requestDataPreparedEvent->getTxType());
$this->assertCount(14, $requestDataPreparedEvent->getRequestData());
});
diff --git a/tests/Functional/ToslaPosTest.php b/tests/Functional/ToslaPosTest.php
index 5c9f1bad..cd146842 100644
--- a/tests/Functional/ToslaPosTest.php
+++ b/tests/Functional/ToslaPosTest.php
@@ -211,7 +211,7 @@ public function testPartialRefundSuccess(): array
RequestDataPreparedEvent::class,
function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void {
$eventIsThrown = true;
- $this->assertSame(PosInterface::TX_TYPE_REFUND, $requestDataPreparedEvent->getTxType());
+ $this->assertSame(PosInterface::TX_TYPE_REFUND_PARTIAL, $requestDataPreparedEvent->getTxType());
$this->assertCount(7, $requestDataPreparedEvent->getRequestData());
});
diff --git a/tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php
index 5df8d1d2..565386b8 100644
--- a/tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php
+++ b/tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php
@@ -368,13 +368,13 @@ public function testCreateCancelRequestData(array $order, array $expectedData):
/**
* @dataProvider refundRequestDataProvider
*/
- public function testCreateRefundRequestData(array $order, array $expectedData): void
+ public function testCreateRefundRequestData(array $order, string $txType, array $expectedData): void
{
$this->crypt->expects(self::once())
->method('generateRandomString')
->willReturn($expectedData['randomNumber']);
- $actualData = $this->requestDataMapper->createRefundRequestData($this->account, $order);
+ $actualData = $this->requestDataMapper->createRefundRequestData($this->account, $order, $txType);
$this->assertSame(23, \strlen($actualData['requestDateTime']));
unset($actualData['requestDateTime']);
@@ -552,6 +552,7 @@ public static function refundRequestDataProvider(): array
'amount' => 1.02,
'currency' => PosInterface::CURRENCY_TRY,
],
+ 'txType' => PosInterface::TX_TYPE_REFUND,
'expected' => [
'terminal' => [
'merchantSafeId' => '2023090417500272654BD9A49CF07574',
@@ -576,6 +577,7 @@ public static function refundRequestDataProvider(): array
'currency' => PosInterface::CURRENCY_TRY,
'recurringOrderInstallmentNumber' => 2,
],
+ 'txType' => PosInterface::TX_TYPE_REFUND,
'expected' => [
'terminal' => [
'merchantSafeId' => '2023090417500272654BD9A49CF07574',
diff --git a/tests/Unit/DataMapper/RequestDataMapper/EstPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/EstPosRequestDataMapperTest.php
index 5a3cf5b2..b3694e12 100644
--- a/tests/Unit/DataMapper/RequestDataMapper/EstPosRequestDataMapperTest.php
+++ b/tests/Unit/DataMapper/RequestDataMapper/EstPosRequestDataMapperTest.php
@@ -272,20 +272,15 @@ public function testCreateRecurringStatusRequestData(): void
}
/**
- * @return void
+ * @dataProvider refundRequestDataProvider
*/
- public function testCreateRefundRequestData(): void
+ public function testCreateRefundRequestData(array $order, string $txType, array $expectedData): void
{
- $order = [
- 'id' => '2020110828BC',
- 'amount' => 50,
- 'currency' => PosInterface::CURRENCY_TRY,
- ];
+ $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order, $txType);
- $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order);
-
- $expectedData = $this->getSampleRefundXMLData($this->account, $order);
- $this->assertEquals($expectedData, $actual);
+ \ksort($actual);
+ \ksort($expectedData);
+ $this->assertSame($expectedData, $actual);
}
@@ -545,6 +540,46 @@ public static function orderHistoryRequestDataProvider(): array
];
}
+ public static function refundRequestDataProvider(): array
+ {
+ return [
+ 'full_refund' => [
+ 'order' => [
+ 'id' => 'order-123',
+ 'currency' => PosInterface::CURRENCY_TRY,
+ 'amount' => 5,
+ ],
+ 'txType' => PosInterface::TX_TYPE_REFUND,
+ 'expected' => [
+ 'ClientId' => '700655000200',
+ 'Currency' => '949',
+ 'Name' => 'ISBANKAPI',
+ 'OrderId' => 'order-123',
+ 'Password' => 'ISBANK07',
+ 'Total' => '5',
+ 'Type' => 'Credit',
+ ],
+ ],
+ 'partial_refund' => [
+ 'order' => [
+ 'id' => 'order-123',
+ 'currency' => PosInterface::CURRENCY_TRY,
+ 'amount' => 5,
+ ],
+ 'txType' => PosInterface::TX_TYPE_REFUND_PARTIAL,
+ 'expected' => [
+ 'ClientId' => '700655000200',
+ 'Currency' => '949',
+ 'Name' => 'ISBANKAPI',
+ 'OrderId' => 'order-123',
+ 'Password' => 'ISBANK07',
+ 'Total' => '5',
+ 'Type' => 'Credit',
+ ],
+ ],
+ ];
+ }
+
/**
* @param AbstractPosAccount $posAccount
* @param array $order
@@ -645,28 +680,4 @@ private function getSampleRecurringStatusRequestData(AbstractPosAccount $posAcco
],
];
}
-
- /**
- * @param AbstractPosAccount $posAccount
- * @param array $order
- *
- * @return array
- */
- private function getSampleRefundXMLData(AbstractPosAccount $posAccount, array $order): array
- {
- $data = [
- 'Name' => $posAccount->getUsername(),
- 'Password' => $posAccount->getPassword(),
- 'ClientId' => $posAccount->getClientId(),
- 'OrderId' => $order['id'],
- 'Currency' => 949,
- 'Type' => 'Credit',
- ];
-
- if ($order['amount']) {
- $data['Total'] = $order['amount'];
- }
-
- return $data;
- }
}
diff --git a/tests/Unit/DataMapper/RequestDataMapper/GarantiPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/GarantiPosRequestDataMapperTest.php
index 7d5c2f11..3d237618 100644
--- a/tests/Unit/DataMapper/RequestDataMapper/GarantiPosRequestDataMapperTest.php
+++ b/tests/Unit/DataMapper/RequestDataMapper/GarantiPosRequestDataMapperTest.php
@@ -294,11 +294,13 @@ public function testCreateStatusRequestData(): void
/**
* @dataProvider refundOrderDataProvider
*/
- public function testCreateRefundRequestData(GarantiPosAccount $garantiPosAccount, array $order, array $expectedData): void
+ public function testCreateRefundRequestData(array $order, string $txType, array $expectedData): void
{
- $actual = $this->requestDataMapper->createRefundRequestData($garantiPosAccount, $order);
+ $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order, $txType);
- $this->assertEquals($expectedData, $actual);
+ \ksort($actual);
+ \ksort($expectedData);
+ $this->assertSame($expectedData, $actual);
}
/**
@@ -448,7 +450,7 @@ private function getSampleStatusRequestData(AbstractPosAccount $posAccount, arra
public static function refundOrderDataProvider(): \Generator
{
- $order = [
+ $order = [
'id' => '2020110828BC',
'ip' => '127.15.15.1',
'currency' => PosInterface::CURRENCY_TRY,
@@ -456,20 +458,41 @@ public static function refundOrderDataProvider(): \Generator
'ref_ret_num' => '831803579226',
'installment' => 0,
];
- $account = AccountFactory::createGarantiPosAccount(
- 'garanti',
- '7000679',
- 'PROVAUT',
- '123qweASD/',
- '30691298',
- PosInterface::MODEL_3D_SECURE,
- '12345678',
- 'PROVRFN',
- '123qweASD/'
- );
+
+ yield [
+ 'order' => $order,
+ 'tx_type' => PosInterface::TX_TYPE_REFUND,
+ 'expectedData' => [
+ 'Mode' => 'TEST',
+ 'Version' => '512',
+ 'Terminal' => [
+ 'ProvUserID' => 'PROVRFN',
+ 'UserID' => 'PROVRFN',
+ 'HashData' => 'CF49751B3B793B9E1946A08815451989D0231D68A5B495C6EABA9C400442F2E6B7DF97446CE2D3562780767E634A6ECBAA1DF69F6DF7F447884A71BDE38D12AA',
+ 'ID' => '30691298',
+ 'MerchantID' => '7000679',
+ ],
+ 'Customer' => [
+ 'IPAddress' => '127.15.15.1',
+ ],
+ 'Order' => [
+ 'OrderID' => '2020110828BC',
+ ],
+ 'Transaction' => [
+ 'Type' => 'refund',
+ 'InstallmentCnt' => '',
+ 'Amount' => 12310,
+ 'CurrencyCode' => '949',
+ 'CardholderPresentCode' => '0',
+ 'MotoInd' => 'N',
+ 'OriginalRetrefNum' => '831803579226',
+ ],
+ ],
+ ];
+
yield [
- 'account' => $account,
'order' => $order,
+ 'tx_type' => PosInterface::TX_TYPE_REFUND_PARTIAL,
'expectedData' => [
'Mode' => 'TEST',
'Version' => '512',
@@ -489,7 +512,7 @@ public static function refundOrderDataProvider(): \Generator
'Transaction' => [
'Type' => 'refund',
'InstallmentCnt' => '',
- 'Amount' => '12310',
+ 'Amount' => 12310,
'CurrencyCode' => '949',
'CardholderPresentCode' => '0',
'MotoInd' => 'N',
diff --git a/tests/Unit/DataMapper/RequestDataMapper/InterPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/InterPosRequestDataMapperTest.php
index 03b77856..e26d72a2 100644
--- a/tests/Unit/DataMapper/RequestDataMapper/InterPosRequestDataMapperTest.php
+++ b/tests/Unit/DataMapper/RequestDataMapper/InterPosRequestDataMapperTest.php
@@ -254,19 +254,15 @@ public function testCreateStatusRequestData(): void
}
/**
- * @return void
+ * @dataProvider refundOrderDataProvider
*/
- public function testCreateRefundRequestData(): void
+ public function testCreateRefundRequestData(array $order, string $txType, array $expectedData): void
{
- $order = [
- 'id' => '2020110828BC',
- 'amount' => 50,
- ];
-
- $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order);
+ $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order, $txType);
- $expectedData = $this->getSampleRefundXMLData($order, $this->account);
- $this->assertEquals($expectedData, $actual);
+ \ksort($actual);
+ \ksort($expectedData);
+ $this->assertSame($expectedData, $actual);
}
/**
@@ -390,28 +386,6 @@ private function getSampleStatusRequestData(array $order, InterPosAccount $inter
];
}
- /**
- * @param array $order
- * @param InterPosAccount $interPosAccount
- *
- * @return array
- */
- private function getSampleRefundXMLData(array $order, InterPosAccount $interPosAccount): array
- {
- return [
- 'UserCode' => $interPosAccount->getUsername(),
- 'UserPass' => $interPosAccount->getPassword(),
- 'ShopCode' => $interPosAccount->getClientId(),
- 'OrderId' => null,
- 'orgOrderId' => $order['id'],
- 'PurchAmount' => $order['amount'],
- 'TxnType' => 'Refund',
- 'SecureType' => 'NonSecure',
- 'Lang' => $interPosAccount->getLang(),
- 'MOTO' => '0',
- ];
- }
-
public static function threeDFormDataProvider(): array
{
$order = [
@@ -507,4 +481,46 @@ public static function threeDFormDataProvider(): array
],
];
}
+
+ public static function refundOrderDataProvider(): \Generator
+ {
+ $order = [
+ 'id' => '2020110828BC',
+ 'amount' => 123.1,
+ ];
+
+ yield [
+ 'order' => $order,
+ 'tx_type' => PosInterface::TX_TYPE_REFUND,
+ 'expectedData' => [
+ 'Lang' => 'tr',
+ 'MOTO' => '0',
+ 'OrderId' => null,
+ 'PurchAmount' => '123.1',
+ 'SecureType' => 'NonSecure',
+ 'ShopCode' => '3123',
+ 'TxnType' => 'Refund',
+ 'UserCode' => 'InterTestApi',
+ 'UserPass' => '3',
+ 'orgOrderId' => '2020110828BC',
+ ],
+ ];
+
+ yield [
+ 'order' => $order,
+ 'tx_type' => PosInterface::TX_TYPE_REFUND_PARTIAL,
+ 'expectedData' => [
+ 'Lang' => 'tr',
+ 'MOTO' => '0',
+ 'OrderId' => null,
+ 'PurchAmount' => '123.1',
+ 'SecureType' => 'NonSecure',
+ 'ShopCode' => '3123',
+ 'TxnType' => 'Refund',
+ 'UserCode' => 'InterTestApi',
+ 'UserPass' => '3',
+ 'orgOrderId' => '2020110828BC',
+ ],
+ ];
+ }
}
diff --git a/tests/Unit/DataMapper/RequestDataMapper/KuveytPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/KuveytPosRequestDataMapperTest.php
index bfe66992..d5e7da15 100644
--- a/tests/Unit/DataMapper/RequestDataMapper/KuveytPosRequestDataMapperTest.php
+++ b/tests/Unit/DataMapper/RequestDataMapper/KuveytPosRequestDataMapperTest.php
@@ -184,13 +184,13 @@ public function testCreateCancelRequestData(array $order, array $expected): void
/**
* @dataProvider createRefundRequestDataProvider
*/
- public function testCreateRefundRequestData(array $order, array $expected): void
+ public function testCreateRefundRequestData(array $order, string $txType, array $expected): void
{
$this->crypt->expects(self::once())
->method('createHash')
->willReturn('request-hash');
- $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order);
+ $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order, $txType);
foreach ($actual as &$item) {
if (is_array($item)) {
@@ -384,7 +384,7 @@ public static function createCancelRequestDataProvider(): iterable
public static function createRefundRequestDataProvider(): Generator
{
yield [
- 'full_order' => [
+ 'full_refund' => [
'id' => '2023070849CD',
'remote_order_id' => '114293600',
'ref_ret_num' => '318923298433',
@@ -393,7 +393,8 @@ public static function createRefundRequestDataProvider(): Generator
'amount' => 1.01,
'currency' => PosInterface::CURRENCY_TRY,
],
- 'expected' => [
+ 'tx_type' => PosInterface::TX_TYPE_REFUND,
+ 'expected' => [
'IsFromExternalNetwork' => true,
'BusinessKey' => 0,
'ResourceId' => 0,
@@ -445,6 +446,7 @@ public static function createRefundRequestDataProvider(): Generator
'order_amount' => 10.01,
'currency' => PosInterface::CURRENCY_TRY,
],
+ 'tx_type' => PosInterface::TX_TYPE_REFUND_PARTIAL,
'expected' => [
'IsFromExternalNetwork' => true,
'BusinessKey' => 0,
diff --git a/tests/Unit/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapperTest.php
index d42623f8..a24f0afa 100644
--- a/tests/Unit/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapperTest.php
+++ b/tests/Unit/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapperTest.php
@@ -213,16 +213,16 @@ public function testCreateCancelRequestData(): void
$this->assertEquals($expectedValue, $actualData);
}
- public function testCreateRefundRequestData(): void
+ /**
+ * @dataProvider refundRequestDataProvider
+ */
+ public function testCreateRefundRequestData(array $order, string $txType, array $expectedData): void
{
- $order = $this->order;
- $order['transaction_id'] = '7022b92e-3aa1-44fb-86d4-33658c700c80';
- $order['amount'] = 1000;
+ $actualData = $this->requestDataMapper->createRefundRequestData($this->account, $order, $txType);
- $expectedValue = $this->getSampleRefundRequestData();
- $actualData = $this->requestDataMapper->createRefundRequestData($this->account, $order);
-
- $this->assertEquals($expectedValue, $actualData);
+ \ksort($actualData);
+ \ksort($expectedData);
+ $this->assertSame($expectedData, $actualData);
}
/**
@@ -235,7 +235,7 @@ public function testCreate3DFormData(): void
$this->dispatcher->expects(self::never())
->method('dispatch');
- $actualData = $this->requestDataMapper->create3DFormData(
+ $actualData = $this->requestDataMapper->create3DFormData(
null,
null,
null,
@@ -451,6 +451,44 @@ public static function three3DEnrollmentRequestDataDataProvider(): \Generator
];
}
+ public static function refundRequestDataProvider(): array
+ {
+ return [
+ 'full_refund' => [
+ 'order' => [
+ 'transaction_id' => '7022b92e-3aa1-44fb-86d4-33658c700c80',
+ 'amount' => 5,
+ 'ip' => '127.0.0.1',
+ ],
+ 'txType' => PosInterface::TX_TYPE_REFUND,
+ 'expected' => [
+ 'ClientIp' => '127.0.0.1',
+ 'CurrencyAmount' => '5.00',
+ 'MerchantId' => '000000000111111',
+ 'Password' => '3XTgER89as',
+ 'ReferenceTransactionId' => '7022b92e-3aa1-44fb-86d4-33658c700c80',
+ 'TransactionType' => 'Refund',
+ ],
+ ],
+ 'partial_refund' => [
+ 'order' => [
+ 'transaction_id' => '7022b92e-3aa1-44fb-86d4-33658c700c80',
+ 'amount' => 5,
+ 'ip' => '127.0.0.1',
+ ],
+ 'txType' => PosInterface::TX_TYPE_REFUND_PARTIAL,
+ 'expected' => [
+ 'ClientIp' => '127.0.0.1',
+ 'CurrencyAmount' => '5.00',
+ 'MerchantId' => '000000000111111',
+ 'Password' => '3XTgER89as',
+ 'ReferenceTransactionId' => '7022b92e-3aa1-44fb-86d4-33658c700c80',
+ 'TransactionType' => 'Refund',
+ ],
+ ],
+ ];
+ }
+
/**
* @param PayFlexAccount $posAccount
* @param array $order
@@ -497,18 +535,6 @@ private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $po
];
}
- private function getSampleRefundRequestData(): array
- {
- return [
- 'MerchantId' => '000000000111111',
- 'Password' => '3XTgER89as',
- 'TransactionType' => 'Refund',
- 'ReferenceTransactionId' => '7022b92e-3aa1-44fb-86d4-33658c700c80',
- 'ClientIp' => '127.0.0.1',
- 'CurrencyAmount' => '1000.00',
- ];
- }
-
/**
* @return array
*/
diff --git a/tests/Unit/DataMapper/RequestDataMapper/PayForPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/PayForPosRequestDataMapperTest.php
index e33f8398..c7c32c05 100644
--- a/tests/Unit/DataMapper/RequestDataMapper/PayForPosRequestDataMapperTest.php
+++ b/tests/Unit/DataMapper/RequestDataMapper/PayForPosRequestDataMapperTest.php
@@ -264,20 +264,15 @@ public function testCreateStatusRequestData(): void
}
/**
- * @return void
+ * @dataProvider refundRequestDataProvider
*/
- public function testCreateRefundRequestData(): void
+ public function testCreateRefundRequestData(array $order, string $txType, array $expectedData): void
{
- $order = [
- 'id' => '2020110828BC',
- 'currency' => PosInterface::CURRENCY_TRY,
- 'amount' => 10.1,
- ];
-
- $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order);
+ $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order, $txType);
- $expectedData = $this->getSampleRefundXMLData($this->account, $order);
- $this->assertEquals($expectedData, $actual);
+ \ksort($expectedData);
+ \ksort($actual);
+ $this->assertSame($expectedData, $actual);
}
/**
@@ -390,34 +385,12 @@ private function getSampleStatusRequestData(AbstractPosAccount $posAccount, arra
];
}
- /**
- * @param AbstractPosAccount $posAccount
- * @param array $order
- *
- * @return array
- */
- private function getSampleRefundXMLData(AbstractPosAccount $posAccount, array $order): array
- {
- return [
- 'MbrId' => '5',
- 'MerchantId' => $posAccount->getClientId(),
- 'UserCode' => $posAccount->getUsername(),
- 'UserPass' => $posAccount->getPassword(),
- 'OrgOrderId' => $order['id'],
- 'SecureType' => 'NonSecure',
- 'Lang' => 'tr',
- 'TxnType' => 'Refund',
- 'PurchAmount' => $order['amount'],
- 'Currency' => 949,
- ];
- }
-
public static function orderHistoryRequestDataProvider(): array
{
return [
[
'order' => [
- 'id' => '2020110828BC',
+ 'id' => '2020110828BC',
],
'expected' => [
'MerchantId' => '085300000009704',
@@ -437,7 +410,7 @@ public static function historyRequestDataProvider(): array
{
return [
[
- 'data' => [
+ 'data' => [
'transaction_date' => new \DateTime('2022-05-18'),
],
'expected' => [
@@ -554,4 +527,50 @@ public static function threeDFormDataProvider(): array
],
];
}
+
+ public static function refundRequestDataProvider(): array
+ {
+ return [
+ 'full_refund' => [
+ 'order' => [
+ 'id' => '7022b92e-3aa1-44fb-86d4-33658c700c80',
+ 'currency' => PosInterface::CURRENCY_TRY,
+ 'amount' => 5,
+ ],
+ 'txType' => PosInterface::TX_TYPE_REFUND,
+ 'expected' => [
+ 'Currency' => '949',
+ 'Lang' => 'tr',
+ 'MbrId' => '5',
+ 'MerchantId' => '085300000009704',
+ 'OrgOrderId' => '7022b92e-3aa1-44fb-86d4-33658c700c80',
+ 'PurchAmount' => '5',
+ 'SecureType' => 'NonSecure',
+ 'TxnType' => 'Refund',
+ 'UserCode' => 'QNB_API_KULLANICI_3DPAY',
+ 'UserPass' => 'UcBN0',
+ ],
+ ],
+ 'partial_refund' => [
+ 'order' => [
+ 'id' => '7022b92e-3aa1-44fb-86d4-33658c700c80',
+ 'currency' => PosInterface::CURRENCY_TRY,
+ 'amount' => 5,
+ ],
+ 'txType' => PosInterface::TX_TYPE_REFUND_PARTIAL,
+ 'expected' => [
+ 'Currency' => '949',
+ 'Lang' => 'tr',
+ 'MbrId' => '5',
+ 'MerchantId' => '085300000009704',
+ 'OrgOrderId' => '7022b92e-3aa1-44fb-86d4-33658c700c80',
+ 'PurchAmount' => '5',
+ 'SecureType' => 'NonSecure',
+ 'TxnType' => 'Refund',
+ 'UserCode' => 'QNB_API_KULLANICI_3DPAY',
+ 'UserPass' => 'UcBN0',
+ ],
+ ],
+ ];
+ }
}
diff --git a/tests/Unit/DataMapper/RequestDataMapper/PosNetRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/PosNetRequestDataMapperTest.php
index abb2457e..6c23fa7d 100644
--- a/tests/Unit/DataMapper/RequestDataMapper/PosNetRequestDataMapperTest.php
+++ b/tests/Unit/DataMapper/RequestDataMapper/PosNetRequestDataMapperTest.php
@@ -259,13 +259,15 @@ public function testCreateStatusRequestData(array $order, array $expectedData):
}
/**
- * @dataProvider refundDataProvider
+ * @dataProvider refundRequestDataProvider
*/
- public function testCreateRefundRequestData(array $order, array $expectedData): void
+ public function testCreateRefundRequestData(array $order, string $txType, array $expectedData): void
{
- $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order);
+ $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order, $txType);
- $this->assertEquals($expectedData, $actual);
+ \ksort($actual);
+ \ksort($expectedData);
+ $this->assertSame($expectedData, $actual);
}
public static function threeDFormDataDataProvider(): array
@@ -450,7 +452,7 @@ public static function statusRequestDataProvider(): array
];
}
- public static function refundDataProvider(): array
+ public static function refundRequestDataProvider(): array
{
return [
'with_order_id' => [
@@ -460,6 +462,7 @@ public static function refundDataProvider(): array
'amount' => 50,
'currency' => PosInterface::CURRENCY_TRY,
],
+ 'tx_type' => PosInterface::TX_TYPE_REFUND,
'expected' => [
'mid' => '6706598320',
'tid' => '67005551',
@@ -478,6 +481,7 @@ public static function refundDataProvider(): array
'amount' => 50,
'currency' => PosInterface::CURRENCY_TRY,
],
+ 'tx_type' => PosInterface::TX_TYPE_REFUND,
'expected' => [
'mid' => '6706598320',
'tid' => '67005551',
diff --git a/tests/Unit/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapperTest.php
index e1031aaa..c88de79c 100644
--- a/tests/Unit/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapperTest.php
+++ b/tests/Unit/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapperTest.php
@@ -163,7 +163,7 @@ public function testCreateNonSecurePostAuthPaymentRequestData(array $order, arra
*/
public function testCreateNonSecurePaymentRequestData(array $order, array $expectedData): void
{
- $actual = $this->requestDataMapper->createNonSecurePaymentRequestData($this->account,$order, PosInterface::TX_TYPE_PAY_AUTH, $this->card);
+ $actual = $this->requestDataMapper->createNonSecurePaymentRequestData($this->account, $order, PosInterface::TX_TYPE_PAY_AUTH, $this->card);
$this->assertEquals($expectedData, $actual);
}
@@ -216,10 +216,13 @@ public function testCreateStatusRequestData(array $order, array $expected): void
/**
* @dataProvider createRefundRequestDataDataProvider
*/
- public function testCreateRefundRequestData(array $order, array $expected): void
+ public function testCreateRefundRequestData(array $order, string $txType, array $expected): void
{
- $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order);
- $this->assertEquals($expected, $actual);
+ $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order, $txType);
+
+ ksort($actual);
+ ksort($expected);
+ $this->assertSame($expected, $actual);
}
@@ -281,7 +284,7 @@ public static function threeDFormDataTestProvider(): iterable
public static function nonSecurePaymentRequestDataDataProvider(): iterable
{
yield [
- 'order' => [
+ 'order' => [
'id' => '123',
'amount' => 10.0,
'installment' => 0,
@@ -449,6 +452,7 @@ public static function createRefundRequestDataDataProvider(): iterable
'payment_model' => PosInterface::MODEL_3D_SECURE,
'transaction_type' => PosInterface::TX_TYPE_PAY_AUTH,
],
+ 'tx_type' => PosInterface::TX_TYPE_REFUND,
'expected' => [
'ApiType' => 'JSON',
'ApiVersion' => 'V100',
@@ -473,6 +477,7 @@ public static function createRefundRequestDataDataProvider(): iterable
'payment_model' => PosInterface::MODEL_3D_SECURE,
'transaction_type' => PosInterface::TX_TYPE_PAY_AUTH,
],
+ 'tx_type' => PosInterface::TX_TYPE_REFUND,
'expected' => [
'ApiType' => 'JSON',
'ApiVersion' => 'V100',
@@ -497,6 +502,7 @@ public static function createRefundRequestDataDataProvider(): iterable
'payment_model' => PosInterface::MODEL_3D_SECURE,
'transaction_type' => PosInterface::TX_TYPE_PAY_AUTH,
],
+ 'tx_type' => PosInterface::TX_TYPE_REFUND,
'expected' => [
'ApiType' => 'JSON',
'ApiVersion' => 'V100',
@@ -521,6 +527,7 @@ public static function createRefundRequestDataDataProvider(): iterable
'amount' => 112,
'transaction_type' => PosInterface::TX_TYPE_PAY_PRE_AUTH,
],
+ 'tx_type' => PosInterface::TX_TYPE_REFUND,
'expected' => [
'ApiType' => 'JSON',
'ApiVersion' => 'V100',
diff --git a/tests/Unit/DataMapper/RequestDataMapper/ToslaPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/ToslaPosRequestDataMapperTest.php
index ae1b2beb..bf04cad4 100644
--- a/tests/Unit/DataMapper/RequestDataMapper/ToslaPosRequestDataMapperTest.php
+++ b/tests/Unit/DataMapper/RequestDataMapper/ToslaPosRequestDataMapperTest.php
@@ -234,7 +234,7 @@ public function testCreateStatusRequestData(array $order, array $expected): void
/**
* @dataProvider refundRequestDataProvider
*/
- public function testCreateRefundRequestData(array $order, array $expected): void
+ public function testCreateRefundRequestData(array $order, string $txType, array $expected): void
{
$this->crypt->expects(self::once())
->method('generateRandomString')
@@ -243,9 +243,11 @@ public function testCreateRefundRequestData(array $order, array $expected): void
->method('createHash')
->willReturn($expected['hash']);
- $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order);
+ $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order, $txType);
- $this->assertEquals($expected, $actual);
+ ksort($actual);
+ ksort($expected);
+ $this->assertSame($expected, $actual);
}
public static function statusRequestDataProvider(): array
@@ -297,6 +299,7 @@ public static function refundRequestDataProvider(): array
'amount' => 1.02,
'time_span' => '20231209215355',
],
+ 'tx_type' => PosInterface::TX_TYPE_REFUND,
'expected' => [
'clientId' => '1000000494',
'apiUser' => 'POS_ENT_Test_001',
diff --git a/tests/Unit/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapperTest.php
index b1a63bdd..12838e71 100644
--- a/tests/Unit/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapperTest.php
+++ b/tests/Unit/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapperTest.php
@@ -9,7 +9,6 @@
use Mews\Pos\DataMapper\RequestDataMapper\VakifKatilimPosRequestDataMapper;
use Mews\Pos\Entity\Account\KuveytPosAccount;
use Mews\Pos\Entity\Card\CreditCardInterface;
-use Mews\Pos\Exceptions\UnsupportedTransactionTypeException;
use Mews\Pos\Factory\AccountFactory;
use Mews\Pos\Factory\CreditCardFactory;
use Mews\Pos\Factory\CryptFactory;
@@ -60,24 +59,6 @@ protected function setUp(): void
$this->requestDataMapper = new VakifKatilimPosRequestDataMapper($this->dispatcher, $crypt);
}
- /**
- * @testWith ["pay", "1"]
- */
- public function testMapTxType(string $txType, string $expected): void
- {
- $actual = $this->requestDataMapper->mapTxType($txType);
- $this->assertSame($expected, $actual);
- }
-
- /**
- * @testWith ["Sale"]
- */
- public function testMapTxTypeException(string $txType): void
- {
- $this->expectException(UnsupportedTransactionTypeException::class);
- $this->requestDataMapper->mapTxType($txType);
- }
-
/**
* @return void
*/
@@ -204,10 +185,13 @@ public function testCreateCancelRequestData(array $order, array $expected): void
/**
* @dataProvider createRefundRequestDataProvider
*/
- public function testCreateRefundRequestData(array $order, array $expected): void
+ public function testCreateRefundRequestData(array $order, string $txType, array $expected): void
{
- $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order);
- $this->assertEquals($expected, $actual);
+ $actual = $this->requestDataMapper->createRefundRequestData($this->account, $order, $txType);
+
+ \ksort($actual);
+ \ksort($expected);
+ $this->assertSame($expected, $actual);
}
/**
@@ -321,6 +305,7 @@ public static function createRefundRequestDataProvider(): Generator
'remote_order_id' => '114293600',
'amount' => 1.01,
],
+ 'tx_type' => PosInterface::TX_TYPE_REFUND,
'expected' => [
'MerchantId' => '1',
'CustomerId' => '11111',
diff --git a/tests/Unit/Gateways/AkbankPosTest.php b/tests/Unit/Gateways/AkbankPosTest.php
index c454e32c..179c2b39 100644
--- a/tests/Unit/Gateways/AkbankPosTest.php
+++ b/tests/Unit/Gateways/AkbankPosTest.php
@@ -600,15 +600,14 @@ public function testCancelRequest(array $order, string $apiUrl): void
/**
* @dataProvider refundRequestDataProvider
*/
- public function testRefundRequest(array $order, string $apiUrl): void
+ public function testRefundRequest(array $order, string $txType, string $apiUrl): void
{
$account = $this->pos->getAccount();
- $txType = PosInterface::TX_TYPE_REFUND;
$requestData = ['createRefundRequestData'];
$this->requestMapperMock->expects(self::once())
->method('createRefundRequestData')
- ->with($account, $order)
+ ->with($account, $order, $txType)
->willReturn($requestData);
$this->configureClientResponse(
@@ -648,6 +647,11 @@ public static function getApiUrlDataProvider(): array
'paymentModel' => PosInterface::MODEL_NON_SECURE,
'expected' => 'https://apipre.akbank.com/api/v1/payment/virtualpos/transaction/process',
],
+ [
+ 'txType' => PosInterface::TX_TYPE_REFUND_PARTIAL,
+ 'paymentModel' => PosInterface::MODEL_NON_SECURE,
+ 'expected' => 'https://apipre.akbank.com/api/v1/payment/virtualpos/transaction/process',
+ ],
[
'txType' => PosInterface::TX_TYPE_HISTORY,
'paymentModel' => PosInterface::MODEL_NON_SECURE,
@@ -702,10 +706,21 @@ public static function cancelRequestDataProvider(): array
public static function refundRequestDataProvider(): array
{
return [
- [
+ 'full_refund' => [
'order' => [
- 'id' => '2020110828BC',
+ 'id' => '2020110828BC',
+ 'amount' => 5,
+ ],
+ 'tx_type' => PosInterface::TX_TYPE_REFUND,
+ 'api_url' => 'https://apipre.akbank.com/api/v1/payment/virtualpos/transaction/process',
+ ],
+ 'partial_refund' => [
+ 'order' => [
+ 'id' => '2020110828BC',
+ 'amount' => 5,
+ 'order_amount' => 10,
],
+ 'tx_type' => PosInterface::TX_TYPE_REFUND_PARTIAL,
'api_url' => 'https://apipre.akbank.com/api/v1/payment/virtualpos/transaction/process',
],
];
diff --git a/tests/Unit/Gateways/EstPosTest.php b/tests/Unit/Gateways/EstPosTest.php
index 3a70de9a..d032f8dc 100644
--- a/tests/Unit/Gateways/EstPosTest.php
+++ b/tests/Unit/Gateways/EstPosTest.php
@@ -365,7 +365,7 @@ public function testRefund(array $bankResponse, array $expectedData, bool $isSuc
$this->requestMapperMock->expects(self::once())
->method('createRefundRequestData')
- ->with($account, $order)
+ ->with($account, $order, $txType)
->willReturn($requestData);
$this->configureClientResponse(
diff --git a/tests/Unit/Gateways/GarantiPosTest.php b/tests/Unit/Gateways/GarantiPosTest.php
index a47b9671..2d5532c8 100644
--- a/tests/Unit/Gateways/GarantiPosTest.php
+++ b/tests/Unit/Gateways/GarantiPosTest.php
@@ -425,7 +425,7 @@ public function testRefundRequest(array $order, string $apiUrl): void
$this->requestMapperMock->expects(self::once())
->method('createRefundRequestData')
- ->with($account, $order)
+ ->with($account, $order, $txType)
->willReturn($requestData);
$decodedResponse = ['decodedData'];
diff --git a/tests/Unit/Gateways/InterPosTest.php b/tests/Unit/Gateways/InterPosTest.php
index e8d17011..4cac171b 100644
--- a/tests/Unit/Gateways/InterPosTest.php
+++ b/tests/Unit/Gateways/InterPosTest.php
@@ -454,7 +454,7 @@ public function testRefundRequest(array $order, string $apiUrl): void
$this->requestMapperMock->expects(self::once())
->method('createRefundRequestData')
- ->with($account, $order)
+ ->with($account, $order, $txType)
->willReturn($requestData);
$decodedResponse = ['decodedData'];
diff --git a/tests/Unit/Gateways/KuveytPosTest.php b/tests/Unit/Gateways/KuveytPosTest.php
index 103aff46..0d433790 100644
--- a/tests/Unit/Gateways/KuveytPosTest.php
+++ b/tests/Unit/Gateways/KuveytPosTest.php
@@ -487,6 +487,11 @@ public static function getApiUrlDataProvider(): array
'paymentModel' => PosInterface::MODEL_NON_SECURE,
'expected' => 'https://boatest.kuveytturk.com.tr/BOA.Integration.WCFService/BOA.Integration.VirtualPos/VirtualPosService.svc?wsdl',
],
+ [
+ 'txType' => PosInterface::TX_TYPE_REFUND_PARTIAL,
+ 'paymentModel' => PosInterface::MODEL_NON_SECURE,
+ 'expected' => 'https://boatest.kuveytturk.com.tr/BOA.Integration.WCFService/BOA.Integration.VirtualPos/VirtualPosService.svc?wsdl',
+ ],
[
'txType' => PosInterface::TX_TYPE_CANCEL,
'paymentModel' => PosInterface::MODEL_NON_SECURE,
diff --git a/tests/Unit/Gateways/PayFlexCPV4PosTest.php b/tests/Unit/Gateways/PayFlexCPV4PosTest.php
index b98b7e3b..f4939630 100644
--- a/tests/Unit/Gateways/PayFlexCPV4PosTest.php
+++ b/tests/Unit/Gateways/PayFlexCPV4PosTest.php
@@ -444,7 +444,7 @@ public function testRefundRequest(array $order, string $apiUrl): void
$this->requestMapperMock->expects(self::once())
->method('createRefundRequestData')
- ->with($account, $order)
+ ->with($account, $order, $txType)
->willReturn($requestData);
$decodedResponse = ['decodedData'];
diff --git a/tests/Unit/Gateways/PayFlexV4PosTest.php b/tests/Unit/Gateways/PayFlexV4PosTest.php
index cb0cef3f..232ef759 100644
--- a/tests/Unit/Gateways/PayFlexV4PosTest.php
+++ b/tests/Unit/Gateways/PayFlexV4PosTest.php
@@ -461,7 +461,7 @@ public function testRefundRequest(array $order, string $apiUrl): void
$this->requestMapperMock->expects(self::once())
->method('createRefundRequestData')
- ->with($account, $order)
+ ->with($account, $order, $txType)
->willReturn($requestData);
$decodedResponse = ['decodedData'];
diff --git a/tests/Unit/Gateways/PayForTest.php b/tests/Unit/Gateways/PayForTest.php
index 50ec1c45..04f71d13 100644
--- a/tests/Unit/Gateways/PayForTest.php
+++ b/tests/Unit/Gateways/PayForTest.php
@@ -459,7 +459,7 @@ public function testRefundRequest(array $order, string $apiUrl): void
$this->requestMapperMock->expects(self::once())
->method('createRefundRequestData')
- ->with($account, $order)
+ ->with($account, $order, $txType)
->willReturn($requestData);
$decodedResponse = ['decodedData'];
diff --git a/tests/Unit/Gateways/PosNetTest.php b/tests/Unit/Gateways/PosNetTest.php
index ea16862e..8989393b 100644
--- a/tests/Unit/Gateways/PosNetTest.php
+++ b/tests/Unit/Gateways/PosNetTest.php
@@ -502,7 +502,7 @@ public function testRefundRequest(array $order, string $apiUrl): void
$this->requestMapperMock->expects(self::once())
->method('createRefundRequestData')
- ->with($account, $order)
+ ->with($account, $order, $txType)
->willReturn($requestData);
$decodedResponse = ['decodedData'];
diff --git a/tests/Unit/Gateways/PosNetV1PosTest.php b/tests/Unit/Gateways/PosNetV1PosTest.php
index 53bab61a..f656c860 100644
--- a/tests/Unit/Gateways/PosNetV1PosTest.php
+++ b/tests/Unit/Gateways/PosNetV1PosTest.php
@@ -440,7 +440,7 @@ public function testRefundRequest(array $order, string $apiUrl): void
$this->requestMapperMock->expects(self::once())
->method('createRefundRequestData')
- ->with($account, $order)
+ ->with($account, $order, $txType)
->willReturn($requestData);
$decodedResponse = ['decodedData'];
diff --git a/tests/Unit/Gateways/ToslaPosTest.php b/tests/Unit/Gateways/ToslaPosTest.php
index 9bd8a0ec..90cf1a80 100644
--- a/tests/Unit/Gateways/ToslaPosTest.php
+++ b/tests/Unit/Gateways/ToslaPosTest.php
@@ -383,6 +383,7 @@ public function testCancel(
*/
public function testRefund(
array $order,
+ string $txType,
array $requestData,
string $encodedRequest,
string $responseContent,
@@ -393,7 +394,7 @@ public function testRefund(
{
$this->requestMapperMock->expects(self::once())
->method('createRefundRequestData')
- ->with($this->pos->getAccount(), $order)
+ ->with($this->pos->getAccount(), $order, $txType)
->willReturn($requestData);
$this->responseMapperMock->expects(self::once())
@@ -499,6 +500,7 @@ public static function refundDataProvider(): iterable
{
yield [
'order' => ToslaPosRequestDataMapperTest::refundRequestDataProvider()[0]['order'],
+ 'txType' => PosInterface::TX_TYPE_REFUND,
'requestData' => ToslaPosRequestDataMapperTest::refundRequestDataProvider()[0]['expected'],
'encodedRequestData' => \json_encode(ToslaPosRequestDataMapperTest::refundRequestDataProvider()[0]['expected'], JSON_THROW_ON_ERROR),
'responseData' => \json_encode(ToslaPosResponseDataMapperTest::refundDataProvider()['success1']['responseData'], JSON_THROW_ON_ERROR),
@@ -721,7 +723,7 @@ public function testRefundRequest(array $order, string $apiUrl): void
$this->requestMapperMock->expects(self::once())
->method('createRefundRequestData')
- ->with($account, $order)
+ ->with($account, $order, $txType)
->willReturn($requestData);
$decodedResponse = ['decodedData'];
@@ -793,6 +795,11 @@ public static function getApiUrlDataProvider(): array
'paymentModel' => PosInterface::MODEL_NON_SECURE,
'expected' => 'https://ent.akodepos.com/api/Payment/refund',
],
+ [
+ 'txType' => PosInterface::TX_TYPE_REFUND_PARTIAL,
+ 'paymentModel' => PosInterface::MODEL_NON_SECURE,
+ 'expected' => 'https://ent.akodepos.com/api/Payment/refund',
+ ],
[
'txType' => PosInterface::TX_TYPE_ORDER_HISTORY,
'paymentModel' => PosInterface::MODEL_NON_SECURE,
diff --git a/tests/Unit/Gateways/VakifKatilimTest.php b/tests/Unit/Gateways/VakifKatilimTest.php
index 46c0120b..979d0b4f 100644
--- a/tests/Unit/Gateways/VakifKatilimTest.php
+++ b/tests/Unit/Gateways/VakifKatilimTest.php
@@ -489,15 +489,14 @@ public function testCancelRequest(array $order, string $apiUrl): void
/**
* @dataProvider refundRequestDataProvider
*/
- public function testRefundRequest(array $order, string $apiUrl): void
+ public function testRefundRequest(array $order, string $txType, string $apiUrl): void
{
$account = $this->pos->getAccount();
- $txType = PosInterface::TX_TYPE_REFUND;
$requestData = ['createRefundRequestData'];
$this->requestMapperMock->expects(self::once())
->method('createRefundRequestData')
- ->with($account, $order)
+ ->with($account, $order, $txType)
->willReturn($requestData);
$decodedResponse = ['decodedData'];
@@ -659,6 +658,12 @@ public static function getApiUrlDataProvider(): array
'paymentModel' => PosInterface::MODEL_NON_SECURE,
'expected' => 'https://boa.vakifkatilim.com.tr/VirtualPOS.Gateway/Home/DrawBack',
],
+ [
+ 'txType' => PosInterface::TX_TYPE_REFUND_PARTIAL,
+ 'orderTxType' => PosInterface::TX_TYPE_PAY_AUTH,
+ 'paymentModel' => PosInterface::MODEL_NON_SECURE,
+ 'expected' => 'https://boa.vakifkatilim.com.tr/VirtualPOS.Gateway/Home/PartialDrawBack',
+ ],
[
'txType' => PosInterface::TX_TYPE_CANCEL,
'orderTxType' => PosInterface::TX_TYPE_PAY_PRE_AUTH,
@@ -752,20 +757,32 @@ public static function cancelRequestDataProvider(): array
public static function refundRequestDataProvider(): array
{
return [
- 'pay_order' => [
+ 'pay_order' => [
'order' => [
'id' => '2020110828BC',
'transaction_type' => PosInterface::TX_TYPE_PAY_AUTH,
],
+ 'txType' => PosInterface::TX_TYPE_REFUND,
'api_url' => 'https://boa.vakifkatilim.com.tr/VirtualPOS.Gateway/Home/DrawBack',
],
- 'pay_auth_order' => [
+ 'pay_auth_order' => [
'order' => [
'id' => '2020110828BC',
'transaction_type' => PosInterface::TX_TYPE_PAY_PRE_AUTH,
],
+ 'txType' => PosInterface::TX_TYPE_REFUND,
'api_url' => 'https://boa.vakifkatilim.com.tr/VirtualPOS.Gateway/Home/PreAuthorizationDrawBack',
],
+ 'pay_order_partial_refund' => [
+ 'order' => [
+ 'id' => '2020110828BC',
+ 'order_amount' => 10,
+ 'amount' => 5,
+ 'transaction_type' => PosInterface::TX_TYPE_PAY_AUTH,
+ ],
+ 'txType' => PosInterface::TX_TYPE_REFUND_PARTIAL,
+ 'api_url' => 'https://boa.vakifkatilim.com.tr/VirtualPOS.Gateway/Home/PartialDrawBack',
+ ],
];
}
diff --git a/tests/Unit/Serializer/KuveytPosSerializerTest.php b/tests/Unit/Serializer/KuveytPosSerializerTest.php
index 28e2288c..f429b5eb 100644
--- a/tests/Unit/Serializer/KuveytPosSerializerTest.php
+++ b/tests/Unit/Serializer/KuveytPosSerializerTest.php
@@ -105,6 +105,12 @@ public static function encodeDataProvider(): Generator
'expected' => $refundTests[0]['expected'],
];
+ yield 'test_partial_refund' => [
+ 'input' => $refundTests[0]['expected'],
+ 'txType' => PosInterface::TX_TYPE_REFUND_PARTIAL,
+ 'expected' => $refundTests[0]['expected'],
+ ];
+
yield 'test_cancel' => [
'input' => ['abc' => 1],
'txType' => PosInterface::TX_TYPE_CANCEL,