Skip to content

Commit

Permalink
Merge pull request #17 from amora2972/laravel-pos-refactoring
Browse files Browse the repository at this point in the history
comply laravel-pos to the new interface of mews/pos
  • Loading branch information
mewebstudio authored Jun 28, 2021
2 parents d9cdd1e + 7721321 commit 82dbbac
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 30 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
[Pos](https://github.com/mewebstudio/pos)

### Minimum Gereksinimler
- PHP >= 7.1.3
- ext-dom
- ext-json
- ext-openssl
- ext-SimpleXML
- PHP >= 7.1.3
- ext-dom
- ext-json
- ext-openssl
- ext-SimpleXML

### Kurulum
```sh
Expand Down
82 changes: 73 additions & 9 deletions config/laravel-pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'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 +28,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 @@ -38,9 +38,45 @@
],
]
],
'finansbank' => [
'name' => 'QNB Finansbank',
'class' => Mews\Pos\Gateways\EstPos::class,
'urls' => [
'production' => 'https://www.fbwebpos.com/fim/api',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
'gateway' => [
'production' => 'https://www.fbwebpos.com/fim/est3dgate',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
],
]
],
'halkbank' => [
'name' => 'Halkbank',
'class' => Mews\Pos\Gateways\EstPos::class,
'urls' => [
'production' => 'https://sanalpos.halkbank.com.tr/fim/api',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
'gateway' => [
'production' => 'https://sanalpos.halkbank.com.tr/fim/est3dgate',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
],
]
],
'teb' => [
'name' => 'TEB',
'class' => Mews\Pos\Gateways\EstPos::class,
'urls' => [
'production' => 'https://sanalpos.teb.com.tr/fim/api',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
'gateway' => [
'production' => 'https://sanalpos.teb.com.tr/fim/est3Dgate',
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
],
]
],
'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 @@ -52,19 +88,19 @@
],
'yapikredi' => [
'name' => 'Yapıkredi',
'class' => \Mews\Pos\PosNet::class,
'class' => Mews\Pos\Gateways\PosNet::class,
'urls' => [
'production' => 'https://posnet.yapikredi.com.tr/PosnetWebService/XML',
'test' => 'http://setmpos.ykb.com/PosnetWebService/XML',
'test' => 'https://setmpos.ykb.com/PosnetWebService/XML',
'gateway' => [
'production' => 'http://posnet.ykb.com/3DSWebService/YKBPaymentService',
'test' => 'http://setmpos.ykb.com/3DSWebService/YKBPaymentService',
'production' => 'https://posnet.yapikredi.com.tr/3DSWebService/YKBPaymentService',
'test' => 'https://setmpos.ykb.com/3DSWebService/YKBPaymentService',
],
]
],
],
'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 @@ -74,6 +110,34 @@
],
]
],
'qnbfinansbank-payfor' => [
'name' => 'QNBFinansbank-PayFor',
'class' => Mews\Pos\Gateways\PayForPos::class,
'urls' => [
'production' => 'https://vpos.qnbfinansbank.com/Gateway/XMLGate.aspx',
'test' => 'https://vpostest.qnbfinansbank.com/Gateway/XmlGate.aspx',
'gateway' => [
'production' => 'https://vpos.qnbfinansbank.com/Gateway/Default.aspx',
'test' => 'https://vpostest.qnbfinansbank.com/Gateway/Default.aspx',
],
'gateway_3d_host' => [
'production' => 'https://vpos.qnbfinansbank.com/Gateway/3DHost.aspx',
'test' => 'https://vpostest.qnbfinansbank.com/Gateway/3DHost.aspx',
],
]
],
'vakifbank' => [
'name' => 'VakifBank-VPOS',
'class' => Mews\Pos\Gateways\VakifBankPos::class,
'urls' => [
'production' => 'https://onlineodeme.vakifbank.com.tr:4443/VposService/v3/Vposreq.aspx',
'test' => 'https://onlineodemetest.vakifbank.com.tr:4443/VposService/v3/Vposreq.aspx',
'gateway' => [
'production' => 'https://3dsecure.vakifbank.com.tr:4443/MPIAPI/MPI_Enrollment.aspx',
'test' => 'https://3dsecuretest.vakifbank.com.tr:4443/MPIAPI/MPI_Enrollment.aspx',
],
],
],
],

];
77 changes: 77 additions & 0 deletions src/Factory/AccountFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php


namespace Mews\LaravelPos\Factory;


use Mews\Pos\Entity\Account\EstPosAccount;
use Mews\Pos\Entity\Account\GarantiPosAccount;
use Mews\Pos\Entity\Account\PayForAccount;
use Mews\Pos\Entity\Account\PosNetAccount;
use Mews\Pos\Entity\Account\VakifBankAccount;
use Mews\Pos\Exceptions\BankNotFoundException;

class AccountFactory
{
const ACCOUNTS = [
'akbank' => EstPosAccount::class,
'ziraat' => EstPosAccount::class,
'isbank' => EstPosAccount::class,
'finansbank' => EstPosAccount::class,
'halkbank' => EstPosAccount::class,
'teb' => EstPosAccount::class,
'yapikredi' => PosNetAccount::class,
'garanti' => GarantiPosAccount::class,
'qnbfinansbank-payfor' => PayForAccount::class,
'vakifbank' => VakifBankAccount::class,
];

public static function create(array $account)
{
$class = self::ACCOUNTS[$account['bank']] ?? null;

if (! $class) {
throw new BankNotFoundException();
}

$params = [
$account['bank'],
$account['model'],
$account['client_id'],
];

if ($account['bank'] != 'vakifbank') {
$params[] = $account['username'];
}

$params[] = $account['password'];

if ($account['bank'] != 'vakifbank') {
$params[] = $account['lang'] ?? 'tr';
}

switch ($account['bank']) {
case "garanti":
$params[] = $account['terminal_id'];
$params[] = $account['store_key'] ?? null;
$params[] = $account['refund_username'] ?? null;
$params[] = $account['refund_password'] ?? null;
break;
case "yapikredi":
$params[] = $account['terminal_id'];
$params[] = $account['pos_net_id'];
$params[] = $account['store_key'];
break;
case "vakifbank":
$params[] = $account['terminal_id'];
$params[] = $account['merchant_type'] ?? 0;
$params[] = $account['sub_merchant_id'] ?? null;
}

if ($account['bank'] != 'vakifbank') {
$params[] = $account['store_key'] ?? null;
}

return new $class(...$params);
}
}
46 changes: 46 additions & 0 deletions src/Factory/CardFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php


namespace Mews\LaravelPos\Factory;


use Mews\Pos\Entity\Card\CreditCardEstPos;
use Mews\Pos\Entity\Card\CreditCardGarantiPos;
use Mews\Pos\Entity\Card\CreditCardPayFor;
use Mews\Pos\Entity\Card\CreditCardPosNet;
use Mews\Pos\Entity\Card\CreditCardVakifBank;
use Mews\Pos\Exceptions\BankNotFoundException;

class CardFactory
{
const CARDS = [
'akbank' => CreditCardEstPos::class,
'ziraat' => CreditCardEstPos::class,
'isbank' => CreditCardEstPos::class,
'finansbank' => CreditCardEstPos::class,
'halkbank' => CreditCardEstPos::class,
'teb' => CreditCardEstPos::class,
'yapikredi' => CreditCardPosNet::class,
'garanti' => CreditCardGarantiPos::class,
'qnbfinansbank-payfor' => CreditCardPayFor::class,
'vakifbank' => CreditCardVakifBank::class,
];

public static function create(array $card)
{
$class = self::CARDS[$card['bank']];

if (! $class) {
throw new BankNotFoundException();
}

$number = $card['number'];
$expireMonth = $card['month'];
$expireYear = $card['year'];
$cvv = $card['cvv'];
$cardHolderName = $card['name'] ?? null;
$cardType = $card['type'] ?? null;

return new $class($number, $expireYear, $expireMonth, $cvv, $cardHolderName, $cardType);
}
}
Loading

0 comments on commit 82dbbac

Please sign in to comment.