Skip to content

Commit

Permalink
moved language mapping into data mappers
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed May 1, 2022
1 parent 3c1069d commit 1ec2211
Show file tree
Hide file tree
Showing 35 changed files with 135 additions and 94 deletions.
10 changes: 9 additions & 1 deletion examples/_common-codes/3d-host/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
require '_config.php';
require '../../template/_header.php';

$order = getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session);
$order = getNewOrder(
$baseUrl,
$ip,
$request->get('currency', 'TRY'),
$session,
$request->get('installment'),
false,
$request->get('lang', \Mews\Pos\Gateways\AbstractGateway::LANG_TR)
);
$session->set('order', $order);

$pos->prepare($order, $transaction);
Expand Down
11 changes: 10 additions & 1 deletion examples/_common-codes/3d/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
exit();
}
$transaction = $request->get('tx', \Mews\Pos\Gateways\AbstractGateway::TX_PAY);
$order = getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session, $request->get('installment'));
$order = getNewOrder(
$baseUrl,
$ip,
$request->get('currency', 'TRY'),
$session,
$request->get('installment'),
false,
$request->get('lang', \Mews\Pos\Gateways\AbstractGateway::LANG_TR)
);
$session->set('order', $order);

$card = createCard($pos, $request->request->all());
Expand All @@ -24,6 +32,7 @@

try {
$formData = $pos->get3DFormData();
//dd($formData);
} catch (\Throwable $e) {
dd($e);
}
Expand Down
10 changes: 9 additions & 1 deletion examples/_common-codes/regular/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

require_once '_config.php';

$order = getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session, $request->get('installment'));
$order = getNewOrder(
$baseUrl,
$ip,
$request->get('currency', 'TRY'),
$session,
$request->get('installment'),
false,
$request->get('lang', \Mews\Pos\Gateways\AbstractGateway::LANG_TR)
);
$session->set('order', $order);
$transaction = $request->get('tx', \Mews\Pos\Gateways\AbstractGateway::TX_PAY);

Expand Down
4 changes: 3 additions & 1 deletion examples/akbank/3d-host/_config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Mews\Pos\Gateways\AbstractGateway;

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/3d-host/';
Expand All @@ -11,7 +13,7 @@
'ISBANK07',
\Mews\Pos\Gateways\AbstractGateway::MODEL_3D_HOST,
'TRPS0200',
\Mews\Pos\Gateways\EstPos::LANG_TR
AbstractGateway::LANG_TR
);

$pos = getGateway($account);
Expand Down
4 changes: 3 additions & 1 deletion examples/akbank/3d-pay/_config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Mews\Pos\Gateways\AbstractGateway;

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/3d-pay/';
Expand All @@ -11,7 +13,7 @@
'ISBANK07',
\Mews\Pos\Gateways\AbstractGateway::MODEL_3D_PAY,
'TRPS0200',
\Mews\Pos\Gateways\EstPos::LANG_TR
AbstractGateway::LANG_TR
);

$pos = getGateway($account);
Expand Down
4 changes: 3 additions & 1 deletion examples/akbank/3d/_config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Mews\Pos\Gateways\AbstractGateway;

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/3d/';
Expand All @@ -11,7 +13,7 @@
'ISBANK07',
\Mews\Pos\Gateways\AbstractGateway::MODEL_3D_SECURE,
'TRPS0200',
\Mews\Pos\Gateways\EstPos::LANG_TR
AbstractGateway::LANG_TR
);

$pos = getGateway($account);
Expand Down
5 changes: 3 additions & 2 deletions examples/akbank/_payment_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ function getNewOrder(
string $currency,
\Symfony\Component\HttpFoundation\Session\Session $session,
?int $installment = 0,
bool $tekrarlanan = false
bool $tekrarlanan = false,
string $lang = AbstractGateway::LANG_TR
): array {
$order = createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, \Mews\Pos\Gateways\EstPos::LANG_TR);
$order = createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, $lang);

if ($tekrarlanan) {
//tekrarlanan odemeler icin (optional):
Expand Down
5 changes: 3 additions & 2 deletions examples/finansbank-payfor/_payment_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ function getNewOrder(
string $currency,
\Symfony\Component\HttpFoundation\Session\Session $session,
?int $installment = 0,
bool $tekrarlanan = false
bool $tekrarlanan = false,
string $lang = AbstractGateway::LANG_TR
): array {
return createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, \Mews\Pos\Gateways\PayForPos::LANG_TR);
return createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, $lang);
}


Expand Down
5 changes: 3 additions & 2 deletions examples/garanti/_payment_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ function getNewOrder(
string $currency,
\Symfony\Component\HttpFoundation\Session\Session $session,
?int $installment = 0,
bool $tekrarlanan = false
bool $tekrarlanan = false,
string $lang = AbstractGateway::LANG_TR
): array {
$order = createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, \Mews\Pos\Gateways\GarantiPos::LANG_TR);
$order = createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, $lang);
if ($tekrarlanan) {
$order['recurringFrequencyType'] = 'MONTH';
$order['recurringFrequency'] = 2;
Expand Down
8 changes: 5 additions & 3 deletions examples/interpos/3d-host/_config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Mews\Pos\Gateways\AbstractGateway;

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/3d-host/';
Expand All @@ -15,13 +17,13 @@
$shopCode,
$userCode,
$userPass,
\Mews\Pos\Gateways\AbstractGateway::MODEL_3D_HOST,
AbstractGateway::MODEL_3D_HOST,
$merchantPass,
\Mews\Pos\Gateways\InterPos::LANG_TR
AbstractGateway::LANG_TR
);

$pos = getGateway($account);

$transaction = \Mews\Pos\Gateways\AbstractGateway::TX_PAY;
$transaction = AbstractGateway::TX_PAY;

$templateTitle = '3D Host Model Payment';
8 changes: 5 additions & 3 deletions examples/interpos/3d-pay/_config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Mews\Pos\Gateways\AbstractGateway;

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/3d-pay/';
Expand All @@ -13,13 +15,13 @@
$shopCode,
$userCode,
$userPass,
\Mews\Pos\Gateways\AbstractGateway::MODEL_3D_PAY,
AbstractGateway::MODEL_3D_PAY,
$merchantPass,
\Mews\Pos\Gateways\InterPos::LANG_TR
AbstractGateway::LANG_TR
);

$pos = getGateway($account);

$transaction = \Mews\Pos\Gateways\AbstractGateway::TX_PAY;
$transaction = AbstractGateway::TX_PAY;

$templateTitle = '3D Model Pay Payment';
8 changes: 5 additions & 3 deletions examples/interpos/3d/_config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Mews\Pos\Gateways\AbstractGateway;

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/3d/';
Expand All @@ -13,13 +15,13 @@
$shopCode,
$userCode,
$userPass,
\Mews\Pos\Gateways\AbstractGateway::MODEL_3D_SECURE,
AbstractGateway::MODEL_3D_SECURE,
$merchantPass,
\Mews\Pos\Gateways\InterPos::LANG_TR
AbstractGateway::LANG_TR
);

$pos = getGateway($account);

$transaction = \Mews\Pos\Gateways\AbstractGateway::TX_PAY;
$transaction = AbstractGateway::TX_PAY;

$templateTitle = '3D Model Payment';
5 changes: 3 additions & 2 deletions examples/interpos/_payment_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ function getNewOrder(
string $currency,
\Symfony\Component\HttpFoundation\Session\Session $session,
?int $installment = 0,
bool $tekrarlanan = false
bool $tekrarlanan = false,
string $lang = AbstractGateway::LANG_TR
): array {
// todo tekrarlanan odemeler icin daha fazla bilgi lazim, Deniz bank dokumantasyonunda hic bir aciklama yok
// ornek kodlarda ise sadece bu alttaki 2 veriyi gondermis.
//'MaturityPeriod' => 1,
//'PaymentFrequency' => 2,

return createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, \Mews\Pos\Gateways\InterPos::LANG_TR);
return createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, $lang);
}

function doPayment(\Mews\Pos\PosInterface $pos, string $transaction, ?\Mews\Pos\Entity\Card\AbstractCreditCard $card)
Expand Down
5 changes: 3 additions & 2 deletions examples/kuveytpos/_payment_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ function getNewOrder(
string $currency,
\Symfony\Component\HttpFoundation\Session\Session $session,
?int $installment = 0,
bool $tekrarlanan = false
bool $tekrarlanan = false,
string $lang = AbstractGateway::LANG_TR
): array {
return createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, \Mews\Pos\Gateways\KuveytPos::LANG_TR);
return createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, $lang);
}


Expand Down
7 changes: 7 additions & 0 deletions examples/template/_credit_card_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
<option value="<?= \Mews\Pos\Gateways\AbstractGateway::TX_PRE_PAY; ?>">Ön Provizyon</option>
</select>
</div>
<div class="form-group col-md-4">
<select name="lang" id="lang" class="form-control input-lg">
<?php foreach ($pos->getLanguages() as $lang) : ?>
<option value="<?= $lang; ?>" <?= $lang === \Mews\Pos\Gateways\AbstractGateway::LANG_TR ? 'selected': null ?>><?= strtoupper($lang); ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<hr>
<div class="form-group text-center">
Expand Down
5 changes: 3 additions & 2 deletions examples/vakifbank/_payment_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ function getNewOrder(
string $currency,
\Symfony\Component\HttpFoundation\Session\Session $session,
?int $installment = 0,
bool $tekrarlanan = false
bool $tekrarlanan = false,
string $lang = AbstractGateway::LANG_TR
): array {
$order = createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment);
$order = createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, $lang);

$order['extraData'] = $session->getId(); //optional, istekte SessionInfo degere atanir
if ($tekrarlanan) {
Expand Down
11 changes: 9 additions & 2 deletions examples/ykb/_payment_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,16 @@ function getNewOrder(
string $currency,
\Symfony\Component\HttpFoundation\Session\Session $session,
?int $installment = 0,
bool $tekrarlanan = false
bool $tekrarlanan = false,
string $lang = AbstractGateway::LANG_TR
): array {
return createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, \Mews\Pos\Gateways\InterPos::LANG_TR);
/**
* useJokerVadaa: Sadece TDS sistemini kullanacak Üye İşyerleri için, 3D-Secure doğrulamasından
* önce Joker Vadaa(üye işyerlerine özel ek taksit ve öteleme kampanyaları)
* sorgulamasını ve kullanımını aktif etmek için kullanılır. Opsiyoneldir.
* useJokerVadaa degeri $order->koiCode = 1; sekilde set etebilirsiniz.
*/
return createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, $lang);
}

function doPayment(\Mews\Pos\PosInterface $pos, string $transaction, ?\Mews\Pos\Entity\Card\AbstractCreditCard $card)
Expand Down
12 changes: 9 additions & 3 deletions src/DataMapper/AbstractRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

use Mews\Pos\Entity\Account\AbstractPosAccount;
use Mews\Pos\Entity\Card\AbstractCreditCard;
use Mews\Pos\Gateways\AbstractGateway;

/**
* todo move txType, currency, installment mapping to here from all gateways
* todo move txType, installment mapping to here from all gateways
* AbstractRequestDataMapper
*/
abstract class AbstractRequestDataMapper
Expand All @@ -27,6 +28,11 @@ abstract class AbstractRequestDataMapper

protected $cardTypeMapping = [];

protected $langMappings = [
AbstractGateway::LANG_TR => 'tr',
AbstractGateway::LANG_EN => 'en',
];

/**
* default olarak ISO 4217 kodlar tanimliyoruz.
* fakat bazi banklar ISO standarti kullanmiyorlar.
Expand Down Expand Up @@ -247,9 +253,9 @@ protected function hashString(string $str): string
protected function getLang(AbstractPosAccount $account, $order): string
{
if ($order && isset($order->lang)) {
return $order->lang;
return $this->langMappings[$order->lang];
}

return $account->getLang();
return $this->langMappings[$account->getLang()];
}
}
Loading

0 comments on commit 1ec2211

Please sign in to comment.