Skip to content

Commit

Permalink
kuveyt pos integration - initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed Apr 15, 2022
1 parent f1dcba4 commit 689b206
Show file tree
Hide file tree
Showing 17 changed files with 1,651 additions and 23 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Bu paket ile amaçlanan; ortak bir arayüz sınıfı ile, tüm Türk banka sanal

- **InterPOS (Deniz bank)** destegi eklenmistir, test edildikce, sorunlari bulundukca hatalar giderilecek.

- **Kuveyt POS** 3d secure ödeme desteği eklenmiştir, test edildikçe, sorunları bulundukça hatalar giderilecek.

### Özellikler
- Standart E-Commerce modeliyle ödeme (model => `regular`)
- 3D Secure modeliyle ödeme (model => `3d`)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mews/pos",
"description": "Türk bankaları için sanal pos kütüphanesi",
"keywords": ["pos", "sanal pos", "est", "est pos", "akbank", "posnet", "payfor", "vakifbankpos", "InterVPos", "DenizBank Sanal Pos"],
"keywords": ["pos", "sanal pos", "est", "est pos", "akbank", "posnet", "payfor", "vakifbankpos", "InterVPos", "DenizBank Sanal Pos", "kuveytpos"],
"homepage": "https://github.com/mewebstudio/pos",
"license": "MIT",
"authors": [
Expand Down
41 changes: 20 additions & 21 deletions config/pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'production' => 'https://www.sanalakpos.com/fim/est3Dgate',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
],
]
],
],
'ziraat' => [
'name' => 'Ziraat Bankası',
Expand All @@ -30,7 +30,7 @@
'production' => 'https://sanalpos2.ziraatbank.com.tr/fim/est3dgate',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
],
]
],
],
'finansbank' => [
'name' => 'QNB Finansbank',
Expand All @@ -42,7 +42,7 @@
'production' => 'https://www.fbwebpos.com/fim/est3dgate',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
],
]
],
],
'halkbank' => [
'name' => 'Halkbank',
Expand All @@ -54,7 +54,7 @@
'production' => 'https://sanalpos.halkbank.com.tr/fim/est3dgate',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
],
]
],
],
'teb' => [
'name' => 'TEB',
Expand All @@ -66,7 +66,7 @@
'production' => 'https://sanalpos.teb.com.tr/fim/est3Dgate',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
],
]
],
],
'isbank' => [
'name' => 'İşbank',
Expand All @@ -78,20 +78,7 @@
'production' => 'https://sanalpos.isbank.com.tr/fim/est3Dgate',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
],
]
],
'isbank-payflex' => [
'name' => 'İşbank - PayFlex',
//TODO implement PayFlex
'class' => Mews\Pos\Gateways\PayFlex::class,
'urls' => [
'production' => 'https://trx.payflex.com.tr/VposWeb/v3/Vposreq.aspx',
'test' => 'https://sanalpos.innova.com.tr/ISBANK_v4/VposWeb/v3/Vposreq.aspx',
'gateway' => [
'production' => 'https://mpi.vpos.isbank.com.tr/MPIEnrollment.aspx',
'test' => 'https://sanalpos.innova.com.tr/ISBANK/MpiWeb/Enrollment.aspx',
],
]
],
],
'yapikredi' => [
'name' => 'Yapıkredi',
Expand All @@ -115,7 +102,7 @@
'production' => 'https://sanalposprov.garanti.com.tr/servlet/gt3dengine',
'test' => 'https://sanalposprovtest.garanti.com.tr/servlet/gt3dengine',
],
]
],
],
'qnbfinansbank-payfor' => [
'name' => 'QNBFinansbank-PayFor',
Expand All @@ -131,7 +118,7 @@
'production' => 'https://vpos.qnbfinansbank.com/Gateway/3DHost.aspx',
'test' => 'https://vpostest.qnbfinansbank.com/Gateway/3DHost.aspx',
],
]
],
],
'vakifbank' => [
'name' => 'VakifBank-VPOS',
Expand Down Expand Up @@ -161,5 +148,17 @@
],
],
],
'kuveytpos' => [
'name' => 'kuveyt-pos',
'class' => Mews\Pos\Gateways\KuveytPos::class,
'urls' => [
'production' => 'https://boa.kuveytturk.com.tr/sanalposservice/Home/ThreeDModelProvisionGate',
'test' => 'https://boatest.kuveytturk.com.tr/boa.virtualpos.services/Home/ThreeDModelProvisionGate',
'gateway' => [
'production' => 'https://boa.kuveytturk.com.tr/sanalposservice/Home/ThreeDModelPayGate',
'test' => 'https://boatest.kuveytturk.com.tr/boa.virtualpos.services/Home/ThreeDModelPayGate',
],
],
],
],
];
20 changes: 20 additions & 0 deletions examples/kuveytpos/3d/_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/3d/';

$account = \Mews\Pos\Factory\AccountFactory::createKuveytPosAccount(
'kuveytpos',
'496',
'apiuser1',
'400235',
'Api1232',
\Mews\Pos\Gateways\AbstractGateway::MODEL_3D_SECURE
);

$pos = getGateway($account);

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

$templateTitle = '3D Model Payment';
36 changes: 36 additions & 0 deletions examples/kuveytpos/3d/form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Symfony\Component\HttpFoundation\RedirectResponse;

require '_config.php';

require '../../template/_header.php';

if ($request->getMethod() !== 'POST') {
echo new RedirectResponse($baseUrl);
exit();
}

$order = getNewOrder($baseUrl, $ip, $request->get('installment'));

$session->set('order', $order);

$card = new \Mews\Pos\Entity\Card\CreditCardKuveytPos(
$request->get('number'),
$request->get('year'),
$request->get('month'),
$request->get('cvv'),
$request->get('name'),
$request->get('type')
);

$pos->prepare($order, $transaction, $card);

try {
$formData = $pos->get3DFormData();
} catch (\Exception $e) {
dd($e);
}

require '../../template/_redirect_form.php';
require '../../template/_footer.php';
10 changes: 10 additions & 0 deletions examples/kuveytpos/3d/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

require '_config.php';
require '../../template/_header.php';

$url = $baseUrl.'form.php';
$card = $testCards['visa1'];

require '../../template/_credit_card_form.php';
require '../../template/_footer.php';
4 changes: 4 additions & 0 deletions examples/kuveytpos/3d/response.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

$card = null;
require '../../template/_payment_response.php';
71 changes: 71 additions & 0 deletions examples/kuveytpos/_payment_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

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

require __DIR__.'/../_main_config.php';

$bankTestsUrl = $hostUrl.'/kuveytpos';

$subMenu = [
AbstractGateway::MODEL_3D_SECURE => [
'path' => '/3d/index.php',
'label' => '3D Ödeme',
],
];

$installments = [
0 => 'Peşin',
2 => '2 Taksit',
6 => '6 Taksit',
12 => '12 Taksit',
];

function getNewOrder(
string $baseUrl,
string $ip,
?int $installment = 0
): array {
$successUrl = $baseUrl.'response.php';
$failUrl = $baseUrl.'response.php';

$orderId = date('Ymd').strtoupper(substr(uniqid(sha1(time())), 0, 4));

$amount = 10.01;

$order = [
'id' => $orderId,
'amount' => $amount,
'installment' => $installment,
'currency' => 'TRY',
'success_url' => $successUrl,
'fail_url' => $failUrl,
'ip' => $ip,
];

return $order;
}


function doPayment(\Mews\Pos\PosInterface $pos, string $transaction, ?\Mews\Pos\Entity\Card\AbstractCreditCard $card)
{
if ($pos->getAccount()->getModel() === \Mews\Pos\Gateways\AbstractGateway::MODEL_NON_SECURE
&& \Mews\Pos\Gateways\AbstractGateway::TX_POST_PAY !== $transaction
) {
//bu asamada $card regular/non secure odemede lazim.
$pos->payment($card);
} else {
$pos->payment();
}
}

$testCards = [
'visa1' => new \Mews\Pos\Entity\Card\CreditCardKuveytPos(
'4155650100416111',
25,
1,
'123',
'John Doe',
AbstractCreditCard::CARD_TYPE_VISA
),
];
6 changes: 6 additions & 0 deletions examples/kuveytpos/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

$templateTitle = 'Kuveyt POS';
require './_payment_config.php';
require '../template/_header.php';
require '../template/_footer.php';
1 change: 1 addition & 0 deletions examples/template/_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<li> <a href="<?= $hostUrl ?>/finansbank-payfor/index.php">PayFor (Finansbank)</a></li>
<li> <a href="<?= $hostUrl ?>/garanti/index.php">Garanti POS</a></li>
<li> <a href="<?= $hostUrl ?>/ykb/index.php">PosNet (YKB)</a></li>
<li> <a href="<?= $hostUrl ?>/kuveytpos/index.php">KuveytPOS</a></li>
</ul>
</nav>
</div>
Expand Down
56 changes: 56 additions & 0 deletions src/Entity/Account/KuveytPosAccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace Mews\Pos\Entity\Account;

/**
* KuveytPosAccount
*/
class KuveytPosAccount extends AbstractPosAccount
{
/**
* POS dokumanda response'da SubMerchantId yer aliyor
* ancak kullanimi hakkinda hic bir bilgi yok.
* @var string|null
*/
protected $subMerchantId;

/**
* @param string $bank
* @param string $merchantId Mağaza Numarası
* @param string $username POS panelinizden kullanıcı işlemleri sayfasında APİ rolünde kullanıcı oluşturulmalıdır
* @param string $customerId CustomerNumber, Müşteri No
* @param string $storeKey Oluşturulan APİ kullanıcısının şifre bilgisidir.
* @param string $model
* @param string $lang
* @param string|null $subMerchantId
*/
public function __construct(
string $bank,
string $merchantId,
string $username,
string $customerId,
string $storeKey,
string $model,
string $lang,
?string $subMerchantId = null
) {
parent::__construct($bank, $model, $merchantId, $username, $customerId, $lang, $storeKey);
$this->subMerchantId = $subMerchantId;
}

/**
* @return string
*/
public function customerId(): string
{
return $this->password;
}

/**
* @return string|null
*/
public function getSubMerchantId(): ?string
{
return $this->subMerchantId;
}
}
42 changes: 42 additions & 0 deletions src/Entity/Card/CreditCardKuveytPos.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Mews\Pos\Entity\Card;

/**
* Class CreditCardEstPos
*/
class CreditCardKuveytPos extends AbstractCreditCard
{
private $cardTypeToCodeMapping = [
self::CARD_TYPE_VISA => 'Visa',
self::CARD_TYPE_MASTERCARD => 'MasterCard',
];

/**
* @inheritDoc
*/
public function getExpirationDate(): string
{
return $this->getExpireMonth().$this->getExpireYear();
}

/**
* @return string
*/
public function getCardCode(): string
{
if (!isset($this->cardTypeToCodeMapping[$this->type])) {
return $this->type;
}

return $this->cardTypeToCodeMapping[$this->type];
}

/**
* @return string[]
*/
public function getCardTypeToCodeMapping(): array
{
return $this->cardTypeToCodeMapping;
}
}
Loading

0 comments on commit 689b206

Please sign in to comment.