Skip to content

Commit

Permalink
Merge pull request mewebstudio#65 from nuryagdym/interpos-integration
Browse files Browse the repository at this point in the history
Interpos integration and many other fixes, improvements
  • Loading branch information
nuryagdym authored Apr 11, 2022
2 parents 47c0ccf + 0acdb9c commit c3a92b7
Show file tree
Hide file tree
Showing 149 changed files with 3,404 additions and 3,986 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Bu paket ile amaçlanan; ortak bir arayüz sınıfı ile, tüm Türk banka sanal pos sistemlerinin kullanılabilmesidir.

- **EST POS** altyapısı tam olarak test edilmiş ve kullanıma hazırdır. Akbank, TEB ve Ziraat bankası test edilmiştir.

- **Garanti Virtual POS** ödeme sistemi çalışmaktadır, fakat 3D ödeme kısmının üretim ortamında test edilmesi gerekiyor.

- **YapıKredi PosNet** sistemi 3D ödeme çalışmaktadır, fakat `cancel`, `refund` işlemleri test edilmedi.
Expand All @@ -11,6 +12,8 @@ Bu paket ile amaçlanan; ortak bir arayüz sınıfı ile, tüm Türk banka sanal

- **VakifBank GET 7/24 MPI ve VPOS 7/24** 3D Secure ödemesi çalışır durumda, diğer işlemlerde sorunlar ortaya çıktıkça giderilecek.

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

### Özellikler
- Standart E-Commerce modeliyle ödeme (model => `regular`)
- 3D Secure modeliyle ödeme (model => `3d`)
Expand Down Expand Up @@ -84,7 +87,7 @@ $order = [
'name' => 'John Doe', // zorunlu değil
'email' => '[email protected]', // zorunlu değil
'user_id' => '12', // zorunlu değil
'amount' => (float) 20, // Sipariş tutarı
'amount' => 20.0, // Sipariş tutarı
'installment' => '0',
'currency' => 'TRY',
'ip' => $ip,
Expand Down Expand Up @@ -173,6 +176,15 @@ $pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account, $yeni_ayarlar);
### Örnek Kodlar
`./pos/examples` dizini içerisinde.

3D ödeme örnek kodlar genel olarak kart bilgilerini website sunucusuna POST eder (`index.php` => `form.php`),
ondan sonra da işlenip gateway'e yönlendiriliyor.
Bu şekilde farklı bankalar arası implementation degişmemesi sağlanmakta (ortak kredi kart formu ve aynı işlem akışı).
Genel olarak kart bilgilerini, website sunucusuna POST yapmadan,
direk gateway'e yönlendirecek şekilde kullanılabilinir (genelde, banka örnek kodları bu şekilde implement edilmiş).
Fakat,
- birden fazla bank seçenegi olunca veya müşteri banka degiştirmek istediginde kart bilgi formunu ona göre güncellemeniz gerekecek.
- üstelik YKB POSNet ve VakıfBank POS kart bilgilerini website sunucusu tarafından POST edilmesini gerektiriyor.

### Docker ile test ortamı
Makinenizde Docker kurulu olmasi gerekiyor.
Projenin root klasöründe `docker-compose up` komutu çalıştırmanız yeterli.
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"],
"keywords": ["pos", "sanal pos", "est", "est pos", "akbank", "posnet", "payfor", "vakifbankpos", "InterVPos", "DenizBank Sanal Pos"],
"homepage": "https://github.com/mewebstudio/pos",
"license": "MIT",
"authors": [
Expand Down
16 changes: 16 additions & 0 deletions config/pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,21 @@
],
],
],
'denizbank' => [
'name' => 'DenizBank-InterPos',
'class' => Mews\Pos\Gateways\InterPos::class,
'urls' => [
'production' => 'https://inter-vpos.com.tr/mpi/Default.aspx',
'test' => 'https://test.inter-vpos.com.tr/mpi/Default.aspx',
'gateway' => [
'production' => 'https://inter-vpos.com.tr/mpi/Default.aspx',
'test' => 'https://test.inter-vpos.com.tr/mpi/Default.aspx',
],
'gateway_3d_host' => [
'production' => 'https://inter-vpos.com.tr/mpi/3DHost.aspx',
'test' => 'https://test.inter-vpos.com.tr/mpi/3DHost.aspx',
],
],
],
],
];
18 changes: 18 additions & 0 deletions examples/_main_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
$root = realpath(__DIR__);
require_once "$root/../vendor/autoload.php";

$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
$ip = $request->getClientIp();

/*$redis = new Redis();
$redis->connect('pos_redis', 6379);
$sessionHandler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler($redis);
Expand All @@ -25,3 +28,18 @@


$hostUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http')."://$_SERVER[HTTP_HOST]";
$subMenu = [];

function getGateway(\Mews\Pos\Entity\Account\AbstractPosAccount $account): ?\Mews\Pos\PosInterface
{
try {
$pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account);
$pos->setTestMode(true);

return $pos;
} catch (Exception $e) {
dd($e);
}
}

//$hostUrl .= '/pos/examples';
26 changes: 12 additions & 14 deletions examples/akbank/3d-host/_config.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<?php

require '../../_main_config.php';
require '../_payment_config.php';

$path = '/akbank/3d-host/';
$baseUrl = $hostUrl.$path;
$baseUrl = $bankTestsUrl.'/3d-host/';

$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
$ip = $request->getClientIp();
$account = \Mews\Pos\Factory\AccountFactory::createEstPosAccount(
'akbank',
'XXXXXXX',
'XXXXXXX',
'',
\Mews\Pos\Gateways\AbstractGateway::MODEL_3D_HOST,
'XXXXXXX'
);

$account = \Mews\Pos\Factory\AccountFactory::createEstPosAccount('akbank', 'XXXXXXX', 'XXXXXXX', '', '3d_host', 'XXXXXXX');
$pos = getGateway($account);

try {
$pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account);
$pos->setTestMode(true);
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
dump($e->getCode(), $e->getMessage());
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
dump($e->getCode(), $e->getMessage());
}
$transaction = \Mews\Pos\Gateways\AbstractGateway::TX_PAY;

$templateTitle = '3D Host Model Payment';
50 changes: 5 additions & 45 deletions examples/akbank/3d-host/index.php
Original file line number Diff line number Diff line change
@@ -1,54 +1,14 @@
<?php

use Mews\Pos\Entity\Card\CreditCardEstPos;
use Mews\Pos\Gateways\AbstractGateway;
use Mews\Pos\Gateways\EstPos;
use Symfony\Component\HttpFoundation\RedirectResponse;

require '_config.php';

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

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

$amount = (float) 32.0;
$installment = '0';

$successUrl = $baseUrl.'response.php';
$failUrl = $baseUrl.'response.php';
$order = getNewOrder($baseUrl, $ip);
$session->set('order', $order);

$rand = microtime();

$order = [
'id' => $orderId,
'email' => '[email protected]', // optional
'name' => 'John Doe', // optional
'amount' => $amount,
'installment' => $installment,
'currency' => 'TRY',
'ip' => $ip,
'success_url' => $successUrl,
'fail_url' => $failUrl,
'lang' => EstPos::LANG_TR,
'rand' => $rand,
];

$redis->lPush('order', json_encode($order));

$pos->prepare($order, AbstractGateway::TX_PAY);
$pos->prepare($order, $transaction);

$formData = $pos->get3DFormData();
?>

<form method="post" action="<?= $formData['gateway']; ?>" class="redirect-form" role="form">
<?php foreach ($formData['inputs'] as $key => $value) : ?>
<input type="hidden" name="<?= $key; ?>" value="<?= $value; ?>">
<?php endforeach; ?>
<div class="text-center">Redirecting...</div>
<hr>
<div class="form-group text-center">
<button type="submit" class="btn btn-lg btn-block btn-success">Submit</button>
</div>
</form>

<?php require '../../template/_footer.php';
require '../../template/_redirect_form.php';
require '../../template/_footer.php';
109 changes: 2 additions & 107 deletions examples/akbank/3d-host/response.php
Original file line number Diff line number Diff line change
@@ -1,109 +1,4 @@
<?php

use Mews\Pos\Gateways\AbstractGateway;
use Symfony\Component\HttpFoundation\RedirectResponse;

require '_config.php';

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

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

$order = (array) json_decode($redis->lPop('order'));

$pos->prepare($order, AbstractGateway::TX_PAY);
$payment = $pos->payment();
$response = $payment->getResponse();
?>

<div class="result">
<h3 class="text-center text-<?= $pos->isSuccess() ? 'success' : 'danger'; ?>">
<?= $pos->isSuccess() ? 'Payment is successful!' : 'Payment is not successful'; ?>
</h3>
<hr>
<dl class="row">
<dt class="col-sm-3">Response:</dt>
<dd class="col-sm-9"><?= $response->response; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Status:</dt>
<dd class="col-sm-9"><?= $response->status; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Transaction:</dt>
<dd class="col-sm-9"><?= $response->transaction; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Transaction Type:</dt>
<dd class="col-sm-9"><?= $response->transaction_type; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Transaction Security:</dt>
<dd class="col-sm-9"><?= $response->transaction_security; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Hash:</dt>
<dd class="col-sm-9"><?= $response->hash; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Order ID:</dt>
<dd class="col-sm-9"><?= $response->order_id ? $response->order_id : '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">AuthCode:</dt>
<dd class="col-sm-9"><?= $response->auth_code ? $response->auth_code : '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">HostRefNum:</dt>
<dd class="col-sm-9"><?= $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">ProcReturnCode:</dt>
<dd class="col-sm-9"><?= $response->code ? $response->code : '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">mdStatus:</dt>
<dd class="col-sm-9"><?= $response->md_status ? $response->md_status : '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Error Code:</dt>
<dd class="col-sm-9"><?= $response->error_code ? $response->error_code : '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Error Message:</dt>
<dd class="col-sm-9"><?= $response->error_message ? $response->error_message : '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Md Error Message:</dt>
<dd class="col-sm-9"><?= $response->md_error_message ? $response->md_error_message : '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-12">All Data Dump:</dt>
<dd class="col-sm-12">
<pre><?php dump($response); ?></pre>
</dd>
</dl>
<hr>
<div class="text-right">
<a href="index.php" class="btn btn-lg btn-info">&lt; Click to payment form</a>
</div>
</div>

<?php require '../../template/_footer.php';
$card = null;
require '../../template/_payment_response.php';
26 changes: 12 additions & 14 deletions examples/akbank/3d-pay/_config.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<?php

require '../../_main_config.php';
require '../_payment_config.php';

$path = '/akbank/3d-pay/';
$baseUrl = $hostUrl.$path;
$baseUrl = $bankTestsUrl.'/3d-pay/';

$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
$ip = $request->getClientIp();
$account = \Mews\Pos\Factory\AccountFactory::createEstPosAccount(
'akbank',
'XXXXXXX',
'XXXXXXX',
'',
\Mews\Pos\Gateways\AbstractGateway::MODEL_3D_PAY,
'XXXXXXX'
);

$account = \Mews\Pos\Factory\AccountFactory::createEstPosAccount('akbank', 'XXXXXXX', 'XXXXXXX', '', '3d_pay', 'XXXXXXX');
$pos = getGateway($account);

try {
$pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account);
$pos->setTestMode(true);
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
dump($e->getCode(), $e->getMessage());
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
dump($e->getCode(), $e->getMessage());
}
$transaction = \Mews\Pos\Gateways\AbstractGateway::TX_PAY;

$templateTitle = '3D Pay Model Payment';
Loading

0 comments on commit c3a92b7

Please sign in to comment.