Skip to content

Commit

Permalink
Merge pull request #16 from nuryagdym/master
Browse files Browse the repository at this point in the history
code refactoring and improvement
  • Loading branch information
mewebstudio authored Dec 3, 2020
2 parents b6730a0 + 436133d commit d2fd649
Show file tree
Hide file tree
Showing 92 changed files with 6,313 additions and 4,919 deletions.
51 changes: 20 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Finansbank'ın PayFor sanal pos sistemini desteklemektedir, Finansbank'ın IP k
- 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 sorgulama (status)
- Sipariş/Ödeme geçmişi sorgulama (history)
- Sipariş/Para iadesi yapma (refund)
- Sipariş iptal etme (cancel)
Expand Down Expand Up @@ -47,18 +47,13 @@ $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.
];
$account = \Mews\Pos\Factory\AccountFactory::createEstPosAccount('akbank', 'XXXXXXX', 'XXXXXXX', 'XXXXXXX', '3d', 'XXXXXXX', \Mews\Pos\Gateways\EstPos::LANG_TR);

// API kullanıcı hesabı ile paket bir değişkene aktarılıyor
try {
$pos = new \Mews\Pos\Pos($account);
$pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account);
//değere göre API URL'leri test veya production değerler kullanılır.
$pos->setTestMode(true);
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
dump($e->getCode(), $e->getMessage());
exit();
Expand All @@ -84,30 +79,25 @@ $order = [
'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 = new \Mews\Pos\Entity\Card\CreditCardEstPos('1111222233334444', '20', '01', '000');

// API kullanıcısı ile oluşturulan $pos değişkenine prepare metoduyla sipariş bilgileri gönderiliyor
$pos->prepare($order);
$pos->prepare($order, \Mews\Pos\Gateways\AbstractGateway::TX_PAY);

// Ödeme tamamlanıyor
$payment = $pos->payment($card);
// Ödeme tamamlanıyor, $card zorunlu değil.
$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ı
dump($payment->getResponse());
dump($pos->getResponse());

````

Expand All @@ -124,21 +114,18 @@ Projenizde bir ayar dosyası oluşturup (pos_ayarlar.php gibi), paket içerisind
<?php

return [
// Para birimleri

//param birimleri Gateway'ler icinde tanımlıdır, özel bir mapping istemediğiniz sürece boş bırakınız
'currencies' => [
'TRY' => 949,
'USD' => 840,
'EUR' => 978,
'GBP' => 826,
'JPY' => 392,
'RUB' => 643,
// 'TRY' => 949,
// 'USD' => 840,
],

// Banka sanal pos tanımlamaları
'banks' => [
'akbank' => [
'name' => 'AKBANK T.A.S.',
'class' => \Mews\Pos\EstPos::class,
'class' => \Mews\Pos\Gateways\EstPos::class,
'urls' => [
'production' => 'https://www.sanalakpos.com/fim/api',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
Expand All @@ -152,7 +139,7 @@ return [
// Yeni eklenen banka
'isbank' => [
'name' => 'İŞ BANKASI .A.S.',
'class' => \Mews\Pos\EstPos::class, // Altyapı sınıfı
'class' => \Mews\Pos\Gateways\EstPos::class, // Altyapı sınıfı
'urls' => [
'production' => 'xxxx', // API Url
'test' => 'xxxx', // API Test Url
Expand All @@ -169,8 +156,9 @@ return [

Bundan sonra nesnemizi, yeni ayarlarımıza göre oluşturup kullanmamız gerekir. Örnek:
```php
//yeni ayar yolu ya da degeri
$yeni_ayarlar = require './pos_ayarlar.php';
$pos = new \Mews\Pos\Pos($account, $yeni_ayarlar);
$pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account, $yeni_ayarlar);
```

### Örnek Kodlar
Expand All @@ -185,9 +173,10 @@ http://localhost/ URL projenin `examples` klasörünün içine bakar.

### 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.
> Değerli yorum, öneri ve katkılarınızı
>
> Sorun bulursanız veya eklenmesi gereken POS sistemi varsa lütfen issue oluşturun.
License
----
Expand Down
49 changes: 18 additions & 31 deletions config/pos.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
<?php

return [

// Currencies
//if you need to use custom keys for currency mapping, otherwise leave empty
'currencies' => [
'TRY' => 949,
'USD' => 840,
'EUR' => 978,
'GBP' => 826,
'JPY' => 392,
'RUB' => 643,
// 'TRY' => 949,
// 'USD' => 840,
],

// Banks
'banks' => [
'akbank' => [
'name' => 'AKBANK T.A.S.',
'class' => Mews\Pos\EstPos::class,
'class' => Mews\Pos\Gateways\EstPos::class,
'urls' => [
'production' => 'https://www.sanalakpos.com/fim/api',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
Expand All @@ -28,7 +22,7 @@
],
'ziraat' => [
'name' => 'Ziraat Bankası',
'class' => Mews\Pos\EstPos::class,
'class' => Mews\Pos\Gateways\EstPos::class,
'urls' => [
'production' => 'https://sanalpos2.ziraatbank.com.tr/fim/api',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
Expand All @@ -40,7 +34,7 @@
],
'finansbank' => [
'name' => 'QNB Finansbank',
'class' => Mews\Pos\EstPos::class,
'class' => Mews\Pos\Gateways\EstPos::class,
'urls' => [
'production' => 'https://www.fbwebpos.com/fim/api',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
Expand All @@ -52,7 +46,7 @@
],
'halkbank' => [
'name' => 'Halkbank',
'class' => Mews\Pos\EstPos::class,
'class' => Mews\Pos\Gateways\EstPos::class,
'urls' => [
'production' => 'https://sanalpos.halkbank.com.tr/fim/api',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
Expand All @@ -64,7 +58,7 @@
],
'teb' => [
'name' => 'TEB',
'class' => Mews\Pos\EstPos::class,
'class' => Mews\Pos\Gateways\EstPos::class,
'urls' => [
'production' => 'https://sanalpos.teb.com.tr/fim/api',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
Expand All @@ -76,7 +70,7 @@
],
'isbank' => [
'name' => 'İşbank',
'class' => Mews\Pos\EstPos::class,
'class' => Mews\Pos\Gateways\EstPos::class,
'urls' => [
'production' => 'https://sanalpos.isbank.com.tr/fim/api',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
Expand All @@ -88,7 +82,8 @@
],
'isbank-payflex' => [
'name' => 'İşbank - PayFlex',
'class' => Mews\Pos\PayFlex::class,
//TODO implement PayFlex
'class' => Mews\Pos\Gateways\PayFlex::class,
'urls' => [
'production' => 'https://trx.payflex.com.tr/VposWeb/v3/Vposreq.aspx',
'test' => 'https://sanalpos.innova.com.tr/ISBANK_v4/VposWeb/v3/Vposreq.aspx',
Expand All @@ -100,26 +95,19 @@
],
'yapikredi' => [
'name' => 'Yapıkredi',
'class' => Mews\Pos\PosNet::class,
'class' => Mews\Pos\Gateways\PosNet::class,
'urls' => [
'production' => 'https://www.posnet.ykb.com/PosnetWebService/XML',
'test' => 'https://setmpos.ykb.com/PosnetWebService/XML',
'production' => 'https://posnet.yapikredi.com.tr/PosnetWebService/XML',
'test' => 'https://setmpos.yapikredi.com.tr/PosnetWebService/XML',
'gateway' => [
'production' => 'https://www.posnet.ykb.com/3DSWebService/YKBPaymentService',
'test' => 'https://setmpos.ykb.com/3DSWebService/YKBPaymentService',
'production' => 'https://www.posnet.yapikredi.com.tr/3DSWebService/YKBPaymentService',
'test' => 'https://setmpos.yapikredi.com.tr/3DSWebService/YKBPaymentService',
],
],
'order' => [
'id_total_length' => 24,
'id_length' => 20,
'id_3d_prefix' => 'TDSC',
'id_3d_pay_prefix' => '', //?
'id_regular_prefix' => '' //?
]
],
'garanti' => [
'name' => 'Garanti',
'class' => Mews\Pos\GarantiPos::class,
'class' => Mews\Pos\Gateways\GarantiPos::class,
'urls' => [
'production' => 'https://sanalposprov.garanti.com.tr/VPServlet',
'test' => 'https://sanalposprovtest.garanti.com.tr/VPServlet',
Expand All @@ -131,7 +119,7 @@
],
'qnbfinansbank-payfor' => [
'name' => 'QNBFinansbank-PayFor',
'class' => Mews\Pos\PayForPos::class,
'class' => Mews\Pos\Gateways\PayForPos::class,
'urls' => [
'production' => 'https://vpos.qnbfinansbank.com/Gateway/XMLGate.aspx',
'test' => 'https://vpostest.qnbfinansbank.com/Gateway/XmlGate.aspx',
Expand All @@ -146,5 +134,4 @@
]
]
],

];
3 changes: 3 additions & 0 deletions examples/_main_config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$root = realpath($_SERVER["DOCUMENT_ROOT"]);
require_once "$root/../vendor/autoload.php";
Expand Down
14 changes: 4 additions & 10 deletions examples/akbank/3d-pay/_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,16 @@
require '../../_main_config.php';

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

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

$account = [
'bank' => 'akbank',
'model' => '3d_pay',
'client_id' => 'XXXXXXX',
'store_key' => 'XXXXXXX',
'env' => 'test',
'lang' => \Mews\Pos\EstPos::LANG_TR
];
$account = \Mews\Pos\Factory\AccountFactory::createEstPosAccount('akbank', 'XXXXXXX', 'XXXXXXX', '', '3d_pay', 'XXXXXXX');

try {
$pos = new \Mews\Pos\Pos($account);
$pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account);
$pos->setTestMode(true);
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
dump($e->getCode(), $e->getMessage());
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
Expand Down
9 changes: 4 additions & 5 deletions examples/akbank/3d-pay/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

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

$amount = (double) 320;
$amount = (double) 32.0;
$instalment = '0';

$success_url = $baseUrl . 'response.php';
Expand All @@ -29,8 +29,7 @@
'ip' => $ip,
'success_url' => $success_url,
'fail_url' => $fail_url,
'transaction' => 'pay', // pay => Auth, pre PreAuth
'lang' => \Mews\Pos\EstPos::LANG_TR,
'lang' => \Mews\Pos\Gateways\EstPos::LANG_TR,
'rand' => $rand,
];

Expand All @@ -45,9 +44,9 @@
$request->get('type')
);

$pos->prepare($order, $card);
$pos->prepare($order, \Mews\Pos\Gateways\AbstractGateway::TX_PAY, $card);

$form_data = $pos->get3dFormData();
$form_data = $pos->get3DFormData();
?>

<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
Expand Down
2 changes: 1 addition & 1 deletion examples/akbank/3d-pay/response.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

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

$pos->prepare($order);
$pos->prepare($order, \Mews\Pos\Gateways\AbstractGateway::TX_PAY);
$payment = $pos->payment();
$response = $payment->getResponse();
?>
Expand Down
17 changes: 4 additions & 13 deletions examples/akbank/3d/_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,15 @@
require '../../_main_config.php';

$path = '/akbank/3d/';
$baseUrl = $hostUrl . $path;
$baseUrl = $hostUrl.$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',
'lang' => \Mews\Pos\EstPos::LANG_TR
];
$account = \Mews\Pos\Factory\AccountFactory::createEstPosAccount('akbank', 'XXXXXXX', 'XXXXXXX', 'XXXXXXX', '3d', 'XXXXXXX', \Mews\Pos\Gateways\EstPos::LANG_TR);

try {
$pos = new \Mews\Pos\Pos($account);
$pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account);
$pos->setTestMode(true);
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
dump($e->getCode(), $e->getMessage());
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
Expand Down
7 changes: 3 additions & 4 deletions examples/akbank/3d/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
'ip' => $ip,
'success_url' => $success_url,
'fail_url' => $fail_url,
'transaction' => 'pay', // pay => Auth, pre PreAuth,
'lang' => \Mews\Pos\EstPos::LANG_TR,
'lang' => \Mews\Pos\Gateways\EstPos::LANG_TR,
'rand' => $rand,
];

Expand All @@ -45,9 +44,9 @@
$request->get('type')
);

$pos->prepare($order, $card);
$pos->prepare($order, \Mews\Pos\Gateways\AbstractGateway::TX_PAY, $card);

$form_data = $pos->get3dFormData();
$form_data = $pos->get3DFormData();
?>

<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
Expand Down
Loading

0 comments on commit d2fd649

Please sign in to comment.