first commit
This commit is contained in:
4
app/Core/Payment/Pos/ex/.gitignore
vendored
Normal file
4
app/Core/Payment/Pos/ex/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
.DS_Store
|
||||
composer.lock
|
||||
/vendor
|
||||
/.idea
|
||||
3
app/Core/Payment/Pos/ex/LICENCE.md
Normal file
3
app/Core/Payment/Pos/ex/LICENCE.md
Normal file
@@ -0,0 +1,3 @@
|
||||
© 2018 Muharrem ERİN (me@mewebstudio.com)
|
||||
|
||||
http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
21
app/Core/Payment/Pos/ex/LICENSE.txt
Normal file
21
app/Core/Payment/Pos/ex/LICENSE.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 MeWebStudio - Muharrem ERİN
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
190
app/Core/Payment/Pos/ex/README.md
Normal file
190
app/Core/Payment/Pos/ex/README.md
Normal file
@@ -0,0 +1,190 @@
|
||||
# Türk bankaları için sanal pos paketi (PHP)
|
||||
|
||||
Bu paket ile amaçlanan; ortak bir arayüz sınıfı ile, tüm Türk banka sanal pos sistemlerinin kullanılabilmesidir.
|
||||
EST altyapısı tam olarak test edilmiş ve kullanıma hazırdır.
|
||||
Garanti Ödeme sistemi çalışmaktadır, fakat 3D ödeme kısmının üretim ortamında test edilmesi gerekiyor.
|
||||
YapıKredi Posnet sistemi çalışmaktadır, fakat 3D ödeme kısmının üretim ortamında test edilmesi gerekiyor.
|
||||
|
||||
> EST altyapısında olan Akbank ve Ziraat bankası test edilmiştir.
|
||||
|
||||
### Özellikler
|
||||
- Standart E-Commerce modeliyle ödeme (model => regular)
|
||||
- 3D modeliyle ödeme (model => 3d)
|
||||
- 3D Pay modeliyle ödeme (model => 3d_pay)
|
||||
- Sipariş/Ödeme sorgulama (query)
|
||||
- Sipariş/Ödeme geçmişi sorgulama (history)
|
||||
- Sipariş/Para iadesi yapma (refund)
|
||||
- Sipariş iptal etme (cancel)
|
||||
|
||||
### Minimum Gereksinimler
|
||||
- PHP >= 7.1.3
|
||||
- ext-dom
|
||||
- ext-json
|
||||
- ext-openssl
|
||||
- ext-SimpleXML
|
||||
|
||||
### Kurulum
|
||||
Test sunucunuz üzerinde;
|
||||
```sh
|
||||
$ mkdir pos-test && cd pos-test
|
||||
$ composer require mews/pos
|
||||
```
|
||||
|
||||
**config.php (Ayar dosyası)**
|
||||
```php
|
||||
<?php
|
||||
|
||||
require './vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos-test/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
// API kullanıcı bilgileri
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => 'regular',
|
||||
'client_id' => 'XXXXXXXX',
|
||||
'username' => 'XXXXXXXX',
|
||||
'password' => 'XXXXXXXX',
|
||||
'env' => 'test', // test veya production. test ise; API Test Url, production ise; API Production URL kullanılır.
|
||||
];
|
||||
|
||||
// API kullanıcı hesabı ile paket bir değişkene aktarılıyor
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
exit();
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
exit();
|
||||
}
|
||||
```
|
||||
|
||||
**test.php (Test Dosyası)**
|
||||
```php
|
||||
<?php
|
||||
|
||||
require 'config.php';
|
||||
|
||||
// Sipariş bilgileri
|
||||
$order = [
|
||||
'id' => 'BENZERSIZ-SIPERIS-ID',
|
||||
'name' => 'John Doe', // zorunlu değil
|
||||
'email' => 'mail@customer.com', // zorunlu değil
|
||||
'user_id' => '12', // zorunlu değil
|
||||
'amount' => (double) 20, // Sipariş tutarı
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth (Direkt satış için pay, ön provizyon için pre)
|
||||
];
|
||||
|
||||
// Kredi kartı bilgieri
|
||||
$card = [
|
||||
'number' => 'XXXXXXXXXXXXXXXX', // Kredi kartı numarası
|
||||
'month' => 'XX', // SKT ay
|
||||
'year' => 'XX', // SKT yıl, son iki hane
|
||||
'cvv' => 'XXX', // Güvenlik kodu, son üç hane
|
||||
];
|
||||
|
||||
// API kullanıcısı ile oluşturulan $pos değişkenine prepare metoduyla sipariş bilgileri gönderiliyor
|
||||
$pos->prepare($order);
|
||||
|
||||
// Ödeme tamamlanıyor
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
// Ödeme başarılı mı?
|
||||
$payment->isSuccess();
|
||||
//veya
|
||||
$pos->isSuccess();
|
||||
|
||||
// Ödeme başarısız mı?
|
||||
$payment->isError();
|
||||
//veya
|
||||
$pos->isError();
|
||||
|
||||
// Sonuç çıktısı
|
||||
var_dump($payment->response);
|
||||
|
||||
````
|
||||
|
||||
### Farklı Banka Sanal Poslarını Eklemek
|
||||
Kendi projenizin dizinindeyken
|
||||
```sh
|
||||
$ cp ./vendor/mews/pos/config/pos.php ./pos_ayarlar.php
|
||||
```
|
||||
ya da;
|
||||
|
||||
Projenizde bir ayar dosyası oluşturup (pos_ayarlar.php gibi), paket içerisinde `./config/pos.php` dosyasının içeriğini buraya kopyalayın.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
return [
|
||||
// Para birimleri
|
||||
'currencies' => [
|
||||
'TRY' => 949,
|
||||
'USD' => 840,
|
||||
'EUR' => 978,
|
||||
'GBP' => 826,
|
||||
'JPY' => 392,
|
||||
'RUB' => 643,
|
||||
],
|
||||
|
||||
// Banka sanal pos tanımlamaları
|
||||
'banks' => [
|
||||
'akbank' => [
|
||||
'name' => 'AKBANK T.A.S.',
|
||||
'class' => \Mews\Pos\EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://www.sanalakpos.com/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://www.sanalakpos.com/fim/est3Dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
// Yeni eklenen banka
|
||||
'isbank' => [
|
||||
'name' => 'İŞ BANKASI .A.S.',
|
||||
'class' => \Mews\Pos\EstPos::class, // Altyapı sınıfı
|
||||
'urls' => [
|
||||
'production' => 'xxxx', // API Url
|
||||
'test' => 'xxxx', // API Test Url
|
||||
'gateway' => [
|
||||
'production' => 'xxxx', // 3d Kapı Url
|
||||
'test' => 'xxxx', // 3d Test Kapı Url
|
||||
],
|
||||
]
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
```
|
||||
|
||||
Bundan sonra nesnemizi, yeni ayarlarımıza göre oluşturup kullanmamız gerekir. Örnek:
|
||||
```php
|
||||
$yeni_ayarlar = require './pos_ayarlar.php';
|
||||
$pos = new \Mews\Pos\Pos($account, $yeni_ayarlar);
|
||||
```
|
||||
|
||||
### Örnek Kodlar
|
||||
`./pos/examples` dizini içerisinde.
|
||||
|
||||
### Yol Haritası
|
||||
- Dökümantasyon hazırlanacak
|
||||
- UnitTest yazılacak -> Bu hiçbir zaman olmayabilir, birisi el atarsa sevinirim :)
|
||||
|
||||
> Değerli yorum, öneri ve katkılarınızı bekliyorum.
|
||||
|
||||
License
|
||||
----
|
||||
|
||||
MIT
|
||||
31
app/Core/Payment/Pos/ex/composer.json
Normal file
31
app/Core/Payment/Pos/ex/composer.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "mews/pos",
|
||||
"description": "Türk bankaları için sanal pos kütüphanesi",
|
||||
"keywords": ["pos", "sanal pos", "est", "est pos", "akbank"],
|
||||
"homepage": "https://github.com/mewebstudio/pos",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Muharrem ERİN",
|
||||
"email": "me@mewebstudio.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"ext-openssl": "*",
|
||||
"ext-SimpleXML": "*",
|
||||
"guzzlehttp/guzzle": "^6.3.3",
|
||||
"symfony/http-foundation": "^5.0",
|
||||
"symfony/serializer": "^5.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Mews\\Pos\\": "src/"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.0"
|
||||
}
|
||||
}
|
||||
30
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/_config.php
Normal file
30
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/_config.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/akbank/3d-pay/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => '3d_pay',
|
||||
'client_id' => 'XXXXXXX',
|
||||
'store_key' => 'XXXXXXX',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Pay Model Payment';
|
||||
64
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/form.php
Normal file
64
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/form.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
|
||||
$amount = (double) 320;
|
||||
$instalment = '0';
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$rand = microtime();
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'name' => 'John Doe', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth
|
||||
'lang' => 'tr',
|
||||
'rand' => $rand,
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'name' => $request->get('name'),
|
||||
'type' => $request->get('type'),
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $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'; ?>
|
||||
57
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/index.php
Normal file
57
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/index.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$url = $base_url . 'form.php';
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $url; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card holder name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card holder name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="visa">Visa</option>
|
||||
<option value="master">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
108
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/response.php
Normal file
108
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/response.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->status == 'approved' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->status == 'approved' ? 'Payment is successful!' : 'Payment is not successful'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $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"><?php echo $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"><?php echo $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 print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
32
app/Core/Payment/Pos/ex/examples/akbank/3d/_config.php
Normal file
32
app/Core/Payment/Pos/ex/examples/akbank/3d/_config.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/akbank/3d/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => '3d',
|
||||
'client_id' => 'XXXXXXX',
|
||||
'username' => 'XXXXXXX',
|
||||
'password' => 'XXXXXXX',
|
||||
'store_key' => 'XXXXXXX',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Model Payment';
|
||||
64
app/Core/Payment/Pos/ex/examples/akbank/3d/form.php
Normal file
64
app/Core/Payment/Pos/ex/examples/akbank/3d/form.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
|
||||
$amount = (double) 320;
|
||||
$instalment = '0';
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$rand = microtime();
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'name' => 'John Doe', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth,
|
||||
'lang' => 'tr',
|
||||
'rand' => $rand,
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'name' => $request->get('name'),
|
||||
'type' => $request->get('type'),
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $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'; ?>
|
||||
57
app/Core/Payment/Pos/ex/examples/akbank/3d/index.php
Normal file
57
app/Core/Payment/Pos/ex/examples/akbank/3d/index.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$url = $base_url . 'form.php';
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $url; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card holder name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card holder name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="visa">Visa</option>
|
||||
<option value="master">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
108
app/Core/Payment/Pos/ex/examples/akbank/3d/response.php
Normal file
108
app/Core/Payment/Pos/ex/examples/akbank/3d/response.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->status == 'approved' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->status == 'approved' ? 'Payment is successful!' : 'Payment is not successful'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response ? $response->response : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $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"><?php echo $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"><?php echo $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 print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
31
app/Core/Payment/Pos/ex/examples/akbank/regular/_config.php
Normal file
31
app/Core/Payment/Pos/ex/examples/akbank/regular/_config.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/akbank/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => 'regular',
|
||||
'client_id' => 'XXXXXXX',
|
||||
'username' => 'XXXXXXX',
|
||||
'password' => 'XXXXXXX',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$gateway = $base_url . 'response.php';
|
||||
|
||||
$template_title = 'Regular Payment';
|
||||
34
app/Core/Payment/Pos/ex/examples/akbank/regular/cancel.php
Normal file
34
app/Core/Payment/Pos/ex/examples/akbank/regular/cancel.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Cancel Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Cancel Order
|
||||
$cancel = $pos->bank->cancel([
|
||||
'order_id' => '20181029A3C1',
|
||||
]);
|
||||
|
||||
$response = $cancel->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Cancel Order is successful!' : 'Cancel Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
35
app/Core/Payment/Pos/ex/examples/akbank/regular/direct.php
Normal file
35
app/Core/Payment/Pos/ex/examples/akbank/regular/direct.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 100;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth
|
||||
];
|
||||
|
||||
$card = [
|
||||
'number' => '4355084355084358',
|
||||
'month' => '12',
|
||||
'year' => '18',
|
||||
'cvv' => '000',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
var_dump($payment->response);
|
||||
34
app/Core/Payment/Pos/ex/examples/akbank/regular/history.php
Normal file
34
app/Core/Payment/Pos/ex/examples/akbank/regular/history.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'History Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// History Order
|
||||
$query= $pos->bank->history([
|
||||
'order_id' => '201810297189',
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'History Order is successful!' : 'History Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
48
app/Core/Payment/Pos/ex/examples/akbank/regular/index.php
Normal file
48
app/Core/Payment/Pos/ex/examples/akbank/regular/index.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $gateway; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card Holder Number</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card Holder Number">
|
||||
</div>
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
66
app/Core/Payment/Pos/ex/examples/akbank/regular/post.php
Normal file
66
app/Core/Payment/Pos/ex/examples/akbank/regular/post.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/akbank/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => 'regular',
|
||||
'client_id' => '100100000',
|
||||
'username' => 'mewsapi',
|
||||
'password' => 'ME12345.',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
$template_title = 'Post Auth Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$order = [
|
||||
'id' => '201810297189',
|
||||
'transaction' => 'post',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment();
|
||||
|
||||
$response = $payment->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() == '00' ? 'Post Auth Order is successful!' : 'Post Auth Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
35
app/Core/Payment/Pos/ex/examples/akbank/regular/refund.php
Normal file
35
app/Core/Payment/Pos/ex/examples/akbank/regular/refund.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Refund Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Refund Order
|
||||
$refund = $pos->bank->refund([
|
||||
'order_id' => '201810297E8B',
|
||||
'amount' => '100',
|
||||
]);
|
||||
|
||||
$response = $refund->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Refund Order is successful!' : 'Refund Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
114
app/Core/Payment/Pos/ex/examples/akbank/regular/response.php
Normal file
114
app/Core/Payment/Pos/ex/examples/akbank/regular/response.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 100;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pre', // pay => Auth, pre PreAuth
|
||||
];
|
||||
|
||||
$pos->prepare($order);
|
||||
|
||||
$card = [
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $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"><?php echo $response->response; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Group ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->group_id ? $response->group_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $response->code; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
34
app/Core/Payment/Pos/ex/examples/akbank/regular/status.php
Normal file
34
app/Core/Payment/Pos/ex/examples/akbank/regular/status.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Order Status';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Query Order
|
||||
$query= $pos->bank->status([
|
||||
'order_id' => '201810297189'
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Query Order is successful!' : 'Query Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
33
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/_config.php
Normal file
33
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/_config.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/garanti/3d-pay/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'garanti',
|
||||
'model' => '3d_pay',
|
||||
'client_id' => '7000679',
|
||||
'terminal_id' => '30691298',
|
||||
'username' => 'PROVAUT',
|
||||
'password' => '123qweASD/',
|
||||
'store_key' => '12345678',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Pay Model Payment';
|
||||
68
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/form.php
Normal file
68
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/form.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
|
||||
$amount = (double) 1;
|
||||
$instalment = '0';
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$transaction = 'pay'; // pay => Auth, pre PreAuth
|
||||
$transaction_type = $pos->bank->types[$transaction];
|
||||
|
||||
$rand = microtime();
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'name' => 'John Doe', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => $transaction,
|
||||
'lang' => 'tr',
|
||||
'rand' => $rand,
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'name' => $request->get('name'),
|
||||
'type' => $request->get('type'),
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>">
|
||||
<?php endforeach; ?>
|
||||
<div class="text-center">Redirecting...</div>
|
||||
<hr>
|
||||
<pre><?php print_r($form_data) ?></pre>
|
||||
<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'; ?>
|
||||
57
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/index.php
Normal file
57
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/index.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$url = $base_url . 'form.php';
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $url; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card holder name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card holder name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="visa">Visa</option>
|
||||
<option value="master">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
109
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/response.php
Normal file
109
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/response.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<pre><?php print_r($_POST) ?></pre>
|
||||
<h3 class="text-center text-<?php echo $payment->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $payment->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"><?php echo $response->response ? $response->response : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $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"><?php echo $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"><?php echo $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 print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
33
app/Core/Payment/Pos/ex/examples/garanti/3d/_config.php
Normal file
33
app/Core/Payment/Pos/ex/examples/garanti/3d/_config.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/garanti/3d/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'garanti',
|
||||
'model' => '3d',
|
||||
'client_id' => '7000679',
|
||||
'terminal_id' => '30691298',
|
||||
'username' => 'PROVAUT',
|
||||
'password' => '123qweASD/',
|
||||
'store_key' => '12345678',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Model Payment';
|
||||
64
app/Core/Payment/Pos/ex/examples/garanti/3d/form.php
Normal file
64
app/Core/Payment/Pos/ex/examples/garanti/3d/form.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
|
||||
$amount = (double) 1;
|
||||
$instalment = '0';
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$rand = microtime();
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'name' => 'John Doe', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth,
|
||||
'lang' => 'tr',
|
||||
'rand' => $rand,
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'name' => $request->get('name'),
|
||||
'type' => $request->get('type'),
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $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'; ?>
|
||||
57
app/Core/Payment/Pos/ex/examples/garanti/3d/index.php
Normal file
57
app/Core/Payment/Pos/ex/examples/garanti/3d/index.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$url = $base_url . 'form.php';
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $url; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card holder name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card holder name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="visa">Visa</option>
|
||||
<option value="master">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
108
app/Core/Payment/Pos/ex/examples/garanti/3d/response.php
Normal file
108
app/Core/Payment/Pos/ex/examples/garanti/3d/response.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $payment->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $payment->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"><?php echo $response->response ? $response->response : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $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"><?php echo $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"><?php echo $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 print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
34
app/Core/Payment/Pos/ex/examples/garanti/regular/_config.php
Normal file
34
app/Core/Payment/Pos/ex/examples/garanti/regular/_config.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/garanti/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'garanti',
|
||||
'model' => 'regular',
|
||||
'client_id' => '7000679',
|
||||
'terminal_id' => '30691298',
|
||||
'username' => 'PROVAUT',
|
||||
'password' => '123qweASD/',
|
||||
'refund_username' => 'PROVRFN',
|
||||
'refund_password' => '123qweASD/',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$gateway = $base_url . 'response.php';
|
||||
|
||||
$template_title = 'Regular Payment';
|
||||
39
app/Core/Payment/Pos/ex/examples/garanti/regular/cancel.php
Normal file
39
app/Core/Payment/Pos/ex/examples/garanti/regular/cancel.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Cancel Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Cancel Order
|
||||
$cancel = $pos->bank->cancel([
|
||||
'order_id' => '20181114DF2C',
|
||||
'ip' => $ip,
|
||||
'email' => 'mail@customer.com',
|
||||
'ref_ret_num' => '831803579226',
|
||||
'amount' => 1,
|
||||
'currency' => 'TRY',
|
||||
]);
|
||||
|
||||
$response = $cancel->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Cancel Order is successful!' : 'Cancel Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
35
app/Core/Payment/Pos/ex/examples/garanti/regular/direct.php
Normal file
35
app/Core/Payment/Pos/ex/examples/garanti/regular/direct.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 100;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth
|
||||
];
|
||||
|
||||
$card = [
|
||||
'number' => '4282209027132016',
|
||||
'month' => '05',
|
||||
'year' => '20',
|
||||
'cvv' => '165',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
var_dump($payment->response);
|
||||
36
app/Core/Payment/Pos/ex/examples/garanti/regular/history.php
Normal file
36
app/Core/Payment/Pos/ex/examples/garanti/regular/history.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'History Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// History Order
|
||||
$query= $pos->bank->history([
|
||||
'order_id' => '2018111377EF',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'History Order is successful!' : 'History Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
44
app/Core/Payment/Pos/ex/examples/garanti/regular/index.php
Normal file
44
app/Core/Payment/Pos/ex/examples/garanti/regular/index.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $gateway; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
70
app/Core/Payment/Pos/ex/examples/garanti/regular/post.php
Normal file
70
app/Core/Payment/Pos/ex/examples/garanti/regular/post.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/garanti/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'garanti',
|
||||
'model' => 'regular',
|
||||
'client_id' => '7000679',
|
||||
'terminal_id' => '30691297',
|
||||
'username' => 'PROVAUT',
|
||||
'password' => '123qweASD/',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
$template_title = 'Post Auth Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$order = [
|
||||
'id' => '201810231553',
|
||||
'transaction' => 'post',
|
||||
'amount' => '1',
|
||||
'ref_ret_num' => '829603332856',
|
||||
'ip' => $ip,
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment();
|
||||
|
||||
$response = $payment->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Post Auth Order is successful!' : 'Post Auth Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
39
app/Core/Payment/Pos/ex/examples/garanti/regular/refund.php
Normal file
39
app/Core/Payment/Pos/ex/examples/garanti/regular/refund.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Refund Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Refund Order
|
||||
$refund = $pos->bank->refund([
|
||||
'order_id' => '201811142A0A',
|
||||
'ip' => $ip,
|
||||
'email' => 'mail@customer.com',
|
||||
'ref_ret_num' => '831803586333',
|
||||
'amount' => 1,
|
||||
'currency' => 'TRY',
|
||||
]);
|
||||
|
||||
$response = $refund->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Refund Order is successful!' : 'Refund Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
125
app/Core/Payment/Pos/ex/examples/garanti/regular/response.php
Normal file
125
app/Core/Payment/Pos/ex/examples/garanti/regular/response.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 1;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '1',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => S, pre => preauth
|
||||
];
|
||||
|
||||
$pos->prepare($order);
|
||||
|
||||
$card = [
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $payment->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $payment->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"><?php echo $response->response; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Group ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->group_id ? $response->group_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">RetrefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->ret_ref_num ? $response->ret_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HashData:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash_data ? $response->hash_data : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
36
app/Core/Payment/Pos/ex/examples/garanti/regular/status.php
Normal file
36
app/Core/Payment/Pos/ex/examples/garanti/regular/status.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Order Status';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Query Order
|
||||
$query= $pos->bank->status([
|
||||
'order_id' => '201812195CF2',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Query Order is successful!' : 'Query Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
15
app/Core/Payment/Pos/ex/examples/template/_footer.php
Normal file
15
app/Core/Payment/Pos/ex/examples/template/_footer.php
Normal file
@@ -0,0 +1,15 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
var redirectForm = $('form.redirect-form')
|
||||
if (redirectForm.length) {
|
||||
redirectForm.submit()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
16
app/Core/Payment/Pos/ex/examples/template/_header.php
Normal file
16
app/Core/Payment/Pos/ex/examples/template/_header.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo $template_title; ?></title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="wrapper">
|
||||
<div class="container" style="max-width: 640px;">
|
||||
<h2 class="text-center"><?php echo $template_title; ?></h2>
|
||||
<hr>
|
||||
38
app/Core/Payment/Pos/ex/examples/ykb/3d/_config.php
Normal file
38
app/Core/Payment/Pos/ex/examples/ykb/3d/_config.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/ykb/3d/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'yapikredi',
|
||||
'model' => '3d',
|
||||
'client_id' => 'XXXXXX',
|
||||
'terminal_id' => 'XXXXXX',
|
||||
'posnet_id' => 'XXXXXX',
|
||||
'username' => 'XXXXXX',
|
||||
'password' => 'XXXXXX',
|
||||
'store_key' => '10,10,10,10,10,10,10,10',
|
||||
'promotion_code' => '',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Model Payment';
|
||||
48
app/Core/Payment/Pos/ex/examples/ykb/3d/form.php
Normal file
48
app/Core/Payment/Pos/ex/examples/ykb/3d/form.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = [
|
||||
'id' => $_POST['order_id'],
|
||||
'name' => $_POST['name'],
|
||||
'amount' => $_POST['amount'],
|
||||
'currency' => $_POST['currency'],
|
||||
'transaction' => $_POST['transaction'],
|
||||
'success_url' => $_POST['success_url'],
|
||||
'fail_url' => $_POST['fail_url'],
|
||||
'lang' => $_POST['lang'],
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'type' => $_POST['type'],
|
||||
'name' => $_POST['name'],
|
||||
'number' => $_POST['number'],
|
||||
'month' => $_POST['month'],
|
||||
'year' => $_POST['year'],
|
||||
'cvv' => $_POST['cvv'],
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<span class="text-muted text-center">Redirecting...</span>
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>">
|
||||
<?php endforeach; ?>
|
||||
<hr>
|
||||
<button class="btn btn-success" type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
77
app/Core/Payment/Pos/ex/examples/ykb/3d/index.php
Normal file
77
app/Core/Payment/Pos/ex/examples/ykb/3d/index.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 1;
|
||||
$instalment = '0';
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => 'pay', // pay => Sale, pre Auth
|
||||
'lang' => 'tr',
|
||||
];
|
||||
?>
|
||||
|
||||
<form method="post" action="./form.php" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card Holder Name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card Holder Name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="1">Visa</option>
|
||||
<option value="2">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="amount" value="<?php echo $order['amount']; ?>" />
|
||||
<input type="hidden" name="currency" value="<?php echo $order['currency']; ?>" />
|
||||
<input type="hidden" name="order_id" value="<?php echo $order['id']; ?>" />
|
||||
<input type="hidden" name="transaction" value="<?php echo $order['transaction']; ?>" />
|
||||
<input type="hidden" name="success_url" value="<?php echo $order['success_url']; ?>" />
|
||||
<input type="hidden" name="fail_url" value="<?php echo $order['fail_url']; ?>" />
|
||||
<input name="lang" type="hidden" id="lang" value="<?php echo $order['lang'] ?>">
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
112
app/Core/Payment/Pos/ex/examples/ykb/3d/response.php
Normal file
112
app/Core/Payment/Pos/ex/examples/ykb/3d/response.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->status == 'approved' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->status == 'approved' ? 'Payment is successful!' : 'Payment is not successful'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response ? $response->response : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9">
|
||||
<?php foreach ($response->hash as $key => $hash): ?>
|
||||
<?php echo $key . ': ' . $hash; ?>
|
||||
<?php endforeach; ?>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->id; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $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"><?php echo $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"><?php echo $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 print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
31
app/Core/Payment/Pos/ex/examples/ykb/regular/_config.php
Normal file
31
app/Core/Payment/Pos/ex/examples/ykb/regular/_config.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/ykb/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'yapikredi',
|
||||
'model' => 'regular',
|
||||
'client_id' => '6706598320',
|
||||
'terminal_id' => '67322946',
|
||||
'posnet_id' => '27426',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$gateway = $base_url . 'response.php';
|
||||
|
||||
$template_title = 'Regular Payment';
|
||||
43
app/Core/Payment/Pos/ex/examples/ykb/regular/cancel.php
Normal file
43
app/Core/Payment/Pos/ex/examples/ykb/regular/cancel.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Cancel Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Cancel Order
|
||||
$cancel = $pos->bank->cancel([
|
||||
'order_id' => '201811133F3F',
|
||||
]);
|
||||
|
||||
/*
|
||||
// faster params...
|
||||
$cancel = $pos->bank->cancel([
|
||||
'order_id' => '201810295863',
|
||||
'host_ref_num' => '018711539490000181',
|
||||
'auth_code' => '115394',
|
||||
]);
|
||||
*/
|
||||
|
||||
$response = $cancel->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Cancel Order is successful!' : 'Cancel Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
35
app/Core/Payment/Pos/ex/examples/ykb/regular/direct.php
Normal file
35
app/Core/Payment/Pos/ex/examples/ykb/regular/direct.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 100;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth
|
||||
];
|
||||
|
||||
$card = [
|
||||
'number' => '4355084355084358',
|
||||
'month' => '12',
|
||||
'year' => '18',
|
||||
'cvv' => '000',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
var_dump($payment->response);
|
||||
34
app/Core/Payment/Pos/ex/examples/ykb/regular/history.php
Normal file
34
app/Core/Payment/Pos/ex/examples/ykb/regular/history.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'History Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// History Order
|
||||
$query = $pos->bank->history([
|
||||
'order_id' => '201811133F3F',
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() == '00' ? 'History Order is successful!' : 'History Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
44
app/Core/Payment/Pos/ex/examples/ykb/regular/index.php
Normal file
44
app/Core/Payment/Pos/ex/examples/ykb/regular/index.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $gateway; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
70
app/Core/Payment/Pos/ex/examples/ykb/regular/post.php
Normal file
70
app/Core/Payment/Pos/ex/examples/ykb/regular/post.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/ykb/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'yapikredi',
|
||||
'model' => 'regular',
|
||||
'client_id' => '6706598320',
|
||||
'terminal_id' => '67322946',
|
||||
'posnet_id' => '27426',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
$template_title = 'Post Auth Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$order = [
|
||||
'id' => '2018102949E0',
|
||||
'host_ref_num' => '018711533790000181',
|
||||
'amount' => '100',
|
||||
'currency' => 'TRY',
|
||||
'installment' => '2',
|
||||
'transaction' => 'post',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment();
|
||||
|
||||
$response = $payment->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Post Auth Order is successful!' : 'Post Auth Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
36
app/Core/Payment/Pos/ex/examples/ykb/regular/refund.php
Normal file
36
app/Core/Payment/Pos/ex/examples/ykb/regular/refund.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Refund Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Refund Order
|
||||
$refund = $pos->bank->refund([
|
||||
'order_id' => '20181113DCDB',
|
||||
'amount' => '1',
|
||||
'currency' => 'TRY',
|
||||
]);
|
||||
|
||||
$response = $refund->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Refund Order is successful!' : 'Refund Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
119
app/Core/Payment/Pos/ex/examples/ykb/regular/response.php
Normal file
119
app/Core/Payment/Pos/ex/examples/ykb/regular/response.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 100;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => 1,
|
||||
'currency' => 'TRY',
|
||||
'transaction' => 'pay', // pay => Sale, pre Auth
|
||||
];
|
||||
|
||||
$pos->prepare($order);
|
||||
|
||||
$card = [
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $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"><?php echo $response->response; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Group ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->group_id ? $response->group_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $response->proc_return_code; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $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"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
34
app/Core/Payment/Pos/ex/examples/ykb/regular/status.php
Normal file
34
app/Core/Payment/Pos/ex/examples/ykb/regular/status.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Order Status';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Query Order
|
||||
$query= $pos->bank->status([
|
||||
'order_id' => '201811133F3F',
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Query Order is successful!' : 'Query Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
25
app/Core/Payment/Pos/ex/phpunit.xml
Normal file
25
app/Core/Payment/Pos/ex/phpunit.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
bootstrap="vendor/autoload.php"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false">
|
||||
|
||||
<testsuite name="Integration">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">src</directory>
|
||||
<exclude>
|
||||
<directory>vendor</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
149
app/Core/Payment/Pos/ex/tests/EstPostTest.php
Normal file
149
app/Core/Payment/Pos/ex/tests/EstPostTest.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace Mews\Pos\Tests;
|
||||
|
||||
use Mews\Pos\EstPos;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
class EstPostTest extends TestCase
|
||||
{
|
||||
private $account;
|
||||
private $estpos;
|
||||
private $config;
|
||||
private $card;
|
||||
private $order;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->config = require __DIR__ . '/../config/pos.php';
|
||||
|
||||
$this->account = (object)[
|
||||
'bank' => 'akbank',
|
||||
'model' => '3d',
|
||||
'client_id' => 'XXXXXXX',
|
||||
'username' => 'XXXXXXX',
|
||||
'password' => 'XXXXXXX',
|
||||
'store_key' => 'VnM5WZ3sGrPusmWP',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
$this->card = (object)[
|
||||
'number' => '5555444433332222',
|
||||
'year' => '21',
|
||||
'month' => '12',
|
||||
'cvv' => '122',
|
||||
'name' => 'ahmet',
|
||||
'type' => 'visa'
|
||||
];
|
||||
|
||||
$this->order = (object)[
|
||||
'id' => 'order222',
|
||||
'name' => 'siparis veren',
|
||||
'email' => 'test@test.com',
|
||||
'amount' => '100.25',
|
||||
'installment' => 0,
|
||||
'currency' => 'TRY',
|
||||
'success_url' => 'https://domain.com/success',
|
||||
'fail_url' => 'https://domain.com/fail_url',
|
||||
'lang' => 'tr',
|
||||
'rand' => microtime()
|
||||
];
|
||||
|
||||
$this->estpos = new EstPos(
|
||||
$this->config['banks'][$this->account->bank],
|
||||
$this->account,
|
||||
$this->config['currencies']);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->assertEquals($this->config['banks'][$this->account->bank], $this->estpos->getConfig());
|
||||
$this->assertEquals($this->account, $this->estpos->getAccount());
|
||||
$this->assertEquals($this->config['currencies'], $this->estpos->getCurrencies());
|
||||
}
|
||||
|
||||
public function testPrepare()
|
||||
{
|
||||
|
||||
$this->estpos->prepare($this->order, $this->card);
|
||||
$this->assertEquals($this->card, $this->estpos->getCard());
|
||||
$this->assertEquals($this->order, $this->estpos->getOrder());
|
||||
}
|
||||
|
||||
public function testGetCardCode()
|
||||
{
|
||||
$card = $this->card;
|
||||
|
||||
$card->type = '1';
|
||||
$this->estpos->prepare($this->order, $card);
|
||||
$this->assertEquals($card->type, $this->estpos->getCardCode());
|
||||
|
||||
$card->type = 'visa';
|
||||
$this->estpos->prepare($this->order, $card);
|
||||
$this->assertNotNull($this->estpos->getCardCode());
|
||||
|
||||
$card->type = 'master';
|
||||
$this->estpos->prepare($this->order, $card);
|
||||
$this->assertNotNull($this->estpos->getCardCode());
|
||||
}
|
||||
|
||||
public function testGet3DFormData()
|
||||
{
|
||||
$this->estpos->prepare($this->order, $this->card);
|
||||
|
||||
$form = [
|
||||
'gateway' => $this->config['banks'][$this->account->bank]['urls']['gateway'][$this->account->env],
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand,
|
||||
'hash' => $this->estpos->create3DHash(),
|
||||
'inputs' => [
|
||||
'clientid' => $this->account->client_id,
|
||||
'storetype' => $this->account->model,
|
||||
'hash' => $this->estpos->create3DHash(),
|
||||
'cardType' => $this->estpos->getCardCode(),
|
||||
'pan' => $this->card->number,
|
||||
'Ecom_Payment_Card_ExpDate_Month' => $this->card->month,
|
||||
'Ecom_Payment_Card_ExpDate_Year' => $this->card->year,
|
||||
'cv2' => $this->card->cvv,
|
||||
'firmaadi' => $this->order->name,
|
||||
'Email' => $this->order->email,
|
||||
'amount' => $this->order->amount,
|
||||
'oid' => $this->order->id,
|
||||
'okUrl' => $this->order->success_url,
|
||||
'failUrl' => $this->order->fail_url,
|
||||
'rnd' => $this->order->rand,
|
||||
'lang' => $this->order->lang,
|
||||
'currency' => $this->order->currency,
|
||||
]
|
||||
];
|
||||
$this->assertEquals($form, $this->estpos->get3DFormData());
|
||||
}
|
||||
|
||||
public function testCheck3DHash()
|
||||
{
|
||||
$data = [
|
||||
"md" => "478719:0373D10CFD8BDED34FA0546D27D5BE76F8BA4A947D1EC499102AE97B880EB1B9:4242:##400902568",
|
||||
"cavv" => "BwAQAhIYRwEAABWGABhHEE6v5IU=",
|
||||
"AuthCode" => "",
|
||||
"oid" => "880",
|
||||
"mdStatus" => "4",
|
||||
"eci" => "06",
|
||||
"clientid" => "400902568",
|
||||
"rnd" => "hDx50d0cq7u1vbpWQMae",
|
||||
"ProcReturnCode" => "N7",
|
||||
"Response" => "Declined",
|
||||
"HASH" => "D+B5fFWXEWFqVSkwotyuTPUW800=",
|
||||
"HASHPARAMS" => "clientid:oid:AuthCode:ProcReturnCode:Response:mdStatus:cavv:eci:md:rnd:",
|
||||
"HASHPARAMSVAL" => "400902568880N7Declined4BwAQAhIYRwEAABWGABhHEE6v5IU=06478719:0373D10CFD8BDED34FA0546D27D5BE76F8BA4A947D1EC499102AE97B880EB1B9:4242:##400902568hDx50d0cq7u1vbpWQMae"
|
||||
];
|
||||
|
||||
$this->assertTrue($this->estpos->check3DHash($data));
|
||||
|
||||
$data['mdStatus'] = '';
|
||||
$this->assertFalse($this->estpos->check3DHash($data));
|
||||
}
|
||||
}
|
||||
98
app/Core/Payment/Pos/ex/tests/GarantiPosTest.php
Normal file
98
app/Core/Payment/Pos/ex/tests/GarantiPosTest.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace Mews\Pos\Tests;
|
||||
|
||||
use Mews\Pos\GarantiPos;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
class GarantiPosTest extends TestCase
|
||||
{
|
||||
private $account;
|
||||
private $garantiPos;
|
||||
private $config;
|
||||
private $card;
|
||||
private $order;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->config = require __DIR__ . '/../config/pos.php';
|
||||
|
||||
$this->account = (object)[
|
||||
'bank' => 'akbank',
|
||||
'model' => '3d',
|
||||
'client_id' => 'XXXXXXX',
|
||||
'terminal_id' => '13456',
|
||||
'username' => 'XXXXXXX',
|
||||
'password' => 'XXXXXXX',
|
||||
'store_key' => 'XXXXXXX',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
$this->card = (object)[
|
||||
'number' => '5555444433332222',
|
||||
'year' => '21',
|
||||
'month' => '12',
|
||||
'cvv' => '122',
|
||||
'name' => 'ahmet',
|
||||
'type' => 'visa'
|
||||
];
|
||||
|
||||
$this->order = (object)[
|
||||
'id' => 'order222',
|
||||
'name' => 'siparis veren',
|
||||
'email' => 'test@test.com',
|
||||
'amount' => '100.25',
|
||||
'installment' => 0,
|
||||
'currency' => 'TRY',
|
||||
'success_url' => 'https://domain.com/success',
|
||||
'fail_url' => 'https://domain.com/fail_url',
|
||||
'lang' => 'tr',
|
||||
'rand' => microtime(),
|
||||
'ip' => '156.155.154.153'
|
||||
];
|
||||
|
||||
$this->garantiPos = new GarantiPos(
|
||||
$this->config['banks'][$this->account->bank],
|
||||
$this->account,
|
||||
$this->config['currencies']);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->assertEquals($this->config['banks'][$this->account->bank], $this->garantiPos->getConfig());
|
||||
$this->assertEquals($this->account, $this->garantiPos->getAccount());
|
||||
$this->assertEquals($this->config['currencies'], $this->garantiPos->getCurrencies());
|
||||
}
|
||||
|
||||
public function testPrepare()
|
||||
{
|
||||
|
||||
$this->garantiPos->prepare($this->order, $this->card);
|
||||
$this->assertEquals($this->card, $this->garantiPos->getCard());
|
||||
$this->assertEquals($this->order, $this->garantiPos->getOrder());
|
||||
}
|
||||
|
||||
public function testGet3DFormData()
|
||||
{
|
||||
$this->garantiPos->prepare($this->order, $this->card);
|
||||
|
||||
$form = [
|
||||
'gateway' => $this->config['banks'][$this->account->bank]['urls']['gateway'][$this->account->env],
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand
|
||||
];
|
||||
$actualForm = $this->garantiPos->get3DFormData();
|
||||
$this->assertNotEmpty($actualForm['inputs']);
|
||||
$this->assertNotEmpty($actualForm['hash']);
|
||||
|
||||
unset($actualForm['inputs']);
|
||||
unset($actualForm['hash']);
|
||||
$this->assertEquals($form, $actualForm);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
35
app/Core/Payment/Pos/ex/tests/PosNetCryptTest.php
Normal file
35
app/Core/Payment/Pos/ex/tests/PosNetCryptTest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Mews\Pos\Tests;
|
||||
use Mews\Pos\PosNetCrypt;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
class PosNetCryptTest extends TestCase
|
||||
{
|
||||
private $crypt;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->crypt = new PosNetCrypt();
|
||||
}
|
||||
|
||||
public function testDecrypt(){
|
||||
$data = '9ACF38C842B3522415364850EAD1909BD43FD590BE3CBD539AD5FF6C7465973ABD61E8371E03282605ED06C994DF394244B7E7DAD54A046510484FAA724330C4C95A527D7891151E7C195D4136CBD70A87D1BD1F75473CF6B45A3F2FA8231DD71FFB4150E0BF4B133ECAA5ACC82CFD74903E21BC6EECB4B33AF39B8AF0C183A64002CFC125A55685C69A13192F3A9A4FDAC860E90C3FB6D125285E9E687BEFBE05707E131FC7ABE25FE35AB114FAE8A247B8C0F3DBA8AA74396D10564B7A0617EED913ED';
|
||||
|
||||
$key = '10,10,10,10,10,10,10,10';
|
||||
$expected_output = '6706598320;67005551;100;00;YKB_TST_090519001330;0;0;https://setmpos.ykb.com/PosnetWebService/YKBTransactionService;posnettest.ykb.com;2225;N;0;Not authenticated;1557398383820;TL';
|
||||
|
||||
$dc = $this->crypt->decrypt($data, $key);
|
||||
$this->assertEquals($expected_output, $dc);
|
||||
|
||||
$data = '1974BC4B9984FF173F9DF305090E44241243CCC9648349C0D607AECACCB55C1F1ED47452B3AD90785F9BCC6AC7E65450D4E72F31B9FC8F9F55A7D109C2BE966C6DD3F3DE12B3457FF0C6FA8BCDBB4B8E5341C1C3DA327992C28354EB3B5C62472C06B8FB6DF34E351206D2CCD5E323FA26EC3EFF2C25656C74C836954F193E634AF391761F88B5D53DBE1FC61A89DB713DFC983D9605D080ACA857196DD3E7B3C52BFCC914CE47961D76B590ECB34B28113A6E4FAA572958D836B09546A9A62D24F829FE18628DF84504FB02';
|
||||
$expected_output = '6706598320;67825768;100;00;00000000000000000892;0;0;https://setmpos.ykb.com/PosnetWebService/YKBTransactionService;posnettest.ykb.com;2225;N;9;None 3D - Secure Transaction;1586175747626;TL';
|
||||
|
||||
$dc = $this->crypt->decrypt($data, $key);
|
||||
$this->assertEquals($expected_output, $dc);
|
||||
}
|
||||
|
||||
}
|
||||
110
app/Core/Payment/Pos/ex/tests/PosNetTest.php
Normal file
110
app/Core/Payment/Pos/ex/tests/PosNetTest.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace Mews\Pos\Tests;
|
||||
use Mews\Pos\PosNet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
|
||||
class PosNetTest extends TestCase
|
||||
{
|
||||
private $account;
|
||||
private $posnet;
|
||||
private $config;
|
||||
|
||||
private $card;
|
||||
private $order;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->account = (object)[
|
||||
'bank' => 'yapikredi',
|
||||
'model' => 'regular',
|
||||
'client_id' => '6706598320',
|
||||
'terminal_id' => '67005551',
|
||||
'posnet_id' => '27426',
|
||||
'env' => 'test',
|
||||
'store_key' => '10,10,10,10,10,10,10,10',
|
||||
'model' => '3d'
|
||||
];
|
||||
|
||||
$this->card = (object)[
|
||||
'number' => '5555444433332222',
|
||||
'year' => '21',
|
||||
'month' => '12',
|
||||
'cvv' => '122',
|
||||
'name' => 'ahmet',
|
||||
'type' => 'visa'
|
||||
];
|
||||
|
||||
$this->order = (object)[
|
||||
'id' => 'YKB_TST_190620093100_024',
|
||||
'name' => 'siparis veren',
|
||||
'email' => 'test@test.com',
|
||||
'amount' => '1.75',
|
||||
'installment' => 0,
|
||||
'currency' => 'TL',
|
||||
'success_url' => 'https://domain.com/success',
|
||||
'fail_url' => 'https://domain.com/fail_url',
|
||||
'lang' => 'tr',
|
||||
'rand' => microtime()
|
||||
];
|
||||
|
||||
|
||||
$this->config = require __DIR__ . '/../config/pos.php';
|
||||
$this->posnet = new PosNet(
|
||||
$this->config['banks'][$this->account->bank],
|
||||
$this->account,
|
||||
$this->config['currencies']);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->assertEquals($this->config['banks'][$this->account->bank], $this->posnet->getConfig());
|
||||
$this->assertEquals($this->account, $this->posnet->getAccount());
|
||||
$this->assertEquals($this->config['currencies'], $this->posnet->getCurrencies());
|
||||
}
|
||||
|
||||
public function testPrepare()
|
||||
{
|
||||
$this->posnet->prepare($this->order, $this->card);
|
||||
$this->assertEquals($this->card, $this->posnet->getCard());
|
||||
$this->assertEquals($this->order, $this->posnet->getOrder());
|
||||
}
|
||||
|
||||
public function testCreate3DHash(){
|
||||
|
||||
$this->posnet->prepare($this->order, $this->card);
|
||||
$this->assertEquals('J/7/Xprj7F/KDf98luVfIGyUPRQzUCqGwpmvz3KT7oQ=', $this->posnet->create3DHash());
|
||||
}
|
||||
|
||||
public function testVerifyResponseMAC(){
|
||||
|
||||
$order = $this->order;
|
||||
$order->id = '895';
|
||||
$order->amount = 1;
|
||||
$order->currency = 'TL';
|
||||
|
||||
$account = $this->account;
|
||||
$account->client_id = '6706598320';
|
||||
$account->terminal_id = '67825768';
|
||||
$account->store_key = '10,10,10,10,10,10,10,10';
|
||||
|
||||
$this->posnet->prepare($order, $account);
|
||||
$data = (object)[
|
||||
'mdStatus' => '9',
|
||||
'mac' => 'U2kU/JWjclCvKZjILq8xBJUXhyB4DswKvN+pKfxl0u0='
|
||||
];
|
||||
$this->assertTrue($this->posnet->verifyResponseMAC($data));
|
||||
|
||||
$order->id = '800';
|
||||
$this->posnet->prepare($order, $account);
|
||||
$data = (object)[
|
||||
'mdStatus' => '9',
|
||||
'mac' => 'U2kU/JWjclCvKZjILq8xBJUXhyB4DswKvN+pKfxl0u0='
|
||||
];
|
||||
$this->assertFalse($this->posnet->verifyResponseMAC($data));
|
||||
}
|
||||
}
|
||||
94
app/Core/Payment/Pos/ex/tests/PosTest.php
Normal file
94
app/Core/Payment/Pos/ex/tests/PosTest.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Mews\Pos\Tests;
|
||||
use Mews\Pos\Pos;
|
||||
use Mews\Pos\PosHelpersTrait;
|
||||
use Mews\Pos\PosNet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
|
||||
class PosTest extends TestCase
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
private $account;
|
||||
private $pos;
|
||||
private $config;
|
||||
|
||||
private $card;
|
||||
private $order;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->config = require __DIR__ . '/../config/pos.php';
|
||||
$this->account = [
|
||||
'bank' => 'yapikredi',
|
||||
'model' => 'regular',
|
||||
'client_id' => '6706598320',
|
||||
'terminal_id' => '67322946',
|
||||
'posnet_id' => '27426',
|
||||
'env' => 'test',
|
||||
'store_key' => '10,10,10,10,10,10,10,10'
|
||||
];
|
||||
|
||||
$this->card = [
|
||||
'number' => '5555444433332222',
|
||||
'year' => '21',
|
||||
'month' => '12',
|
||||
'cvv' => '122',
|
||||
'name' => 'ahmet',
|
||||
'type' => 'visa'
|
||||
];
|
||||
|
||||
$this->order = [
|
||||
'id' => 'order222',
|
||||
'name' => 'siparis veren',
|
||||
'email' => 'test@test.com',
|
||||
'amount' => '100.25',
|
||||
'installment' => 0,
|
||||
'currency' => 'TRY',
|
||||
'success_url' => 'https://domain.com/success',
|
||||
'fail_url' => 'https://domain.com/fail_url',
|
||||
'lang' => 'tr',
|
||||
'rand' => microtime()
|
||||
];
|
||||
|
||||
$this->pos = new Pos($this->account);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->assertEquals($this->config['banks'][$this->account['bank']], $this->pos->getConfig());
|
||||
$this->assertEquals((object)$this->account, $this->pos->getAccount());
|
||||
$this->assertEquals($this->config['currencies'], $this->pos->getCurrencies());
|
||||
$this->assertInstanceOf(PosNet::class, $this->pos->bank);
|
||||
}
|
||||
|
||||
public function testCreateXML()
|
||||
{
|
||||
$xml_str = $this->createXML($this->order);
|
||||
$this->assertIsString($xml_str);
|
||||
}
|
||||
|
||||
public function testXMLStringToObject()
|
||||
{
|
||||
$xml_str = $this->createXML(['order' => $this->order]);
|
||||
$this->assertEquals((object)$this->order, $this->XMLStringToObject($xml_str));
|
||||
}
|
||||
|
||||
public function testPrepare()
|
||||
{
|
||||
|
||||
$this->pos->prepare($this->order, $this->card);
|
||||
$this->assertEquals((object)$this->card, $this->pos->getCard());
|
||||
//$this->assertEquals((object)$order, $this->pos->getOrder());
|
||||
}
|
||||
|
||||
public function testGetGatewayUrl()
|
||||
{
|
||||
$this->assertEquals($this->config['banks'][$this->account['bank']]['urls']['gateway'][$this->account['env']], $this->pos->getGatewayUrl());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user