Skip to content

Commit 82dbbac

Browse files
authored
Merge pull request #17 from amora2972/laravel-pos-refactoring
comply laravel-pos to the new interface of mews/pos
2 parents d9cdd1e + 7721321 commit 82dbbac

File tree

5 files changed

+245
-30
lines changed

5 files changed

+245
-30
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
[Pos](https://github.com/mewebstudio/pos)
55

66
### Minimum Gereksinimler
7-
- PHP >= 7.1.3
8-
- ext-dom
9-
- ext-json
10-
- ext-openssl
11-
- ext-SimpleXML
7+
- PHP >= 7.1.3
8+
- ext-dom
9+
- ext-json
10+
- ext-openssl
11+
- ext-SimpleXML
1212

1313
### Kurulum
1414
```sh

config/laravel-pos.php

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
'banks' => [
1717
'akbank' => [
1818
'name' => 'AKBANK T.A.S.',
19-
'class' => \Mews\Pos\EstPos::class,
19+
'class' => Mews\Pos\Gateways\EstPos::class,
2020
'urls' => [
2121
'production' => 'https://www.sanalakpos.com/fim/api',
2222
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
@@ -28,7 +28,7 @@
2828
],
2929
'ziraat' => [
3030
'name' => 'Ziraat Bankası',
31-
'class' => \Mews\Pos\EstPos::class,
31+
'class' => Mews\Pos\Gateways\EstPos::class,
3232
'urls' => [
3333
'production' => 'https://sanalpos2.ziraatbank.com.tr/fim/api',
3434
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
@@ -38,9 +38,45 @@
3838
],
3939
]
4040
],
41+
'finansbank' => [
42+
'name' => 'QNB Finansbank',
43+
'class' => Mews\Pos\Gateways\EstPos::class,
44+
'urls' => [
45+
'production' => 'https://www.fbwebpos.com/fim/api',
46+
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
47+
'gateway' => [
48+
'production' => 'https://www.fbwebpos.com/fim/est3dgate',
49+
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
50+
],
51+
]
52+
],
53+
'halkbank' => [
54+
'name' => 'Halkbank',
55+
'class' => Mews\Pos\Gateways\EstPos::class,
56+
'urls' => [
57+
'production' => 'https://sanalpos.halkbank.com.tr/fim/api',
58+
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
59+
'gateway' => [
60+
'production' => 'https://sanalpos.halkbank.com.tr/fim/est3dgate',
61+
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
62+
],
63+
]
64+
],
65+
'teb' => [
66+
'name' => 'TEB',
67+
'class' => Mews\Pos\Gateways\EstPos::class,
68+
'urls' => [
69+
'production' => 'https://sanalpos.teb.com.tr/fim/api',
70+
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
71+
'gateway' => [
72+
'production' => 'https://sanalpos.teb.com.tr/fim/est3Dgate',
73+
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
74+
],
75+
]
76+
],
4177
'isbank' => [
4278
'name' => 'İşbank',
43-
'class' => \Mews\Pos\EstPos::class,
79+
'class' => Mews\Pos\Gateways\EstPos::class,
4480
'urls' => [
4581
'production' => 'https://sanalpos.isbank.com.tr/fim/api',
4682
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
@@ -52,19 +88,19 @@
5288
],
5389
'yapikredi' => [
5490
'name' => 'Yapıkredi',
55-
'class' => \Mews\Pos\PosNet::class,
91+
'class' => Mews\Pos\Gateways\PosNet::class,
5692
'urls' => [
5793
'production' => 'https://posnet.yapikredi.com.tr/PosnetWebService/XML',
58-
'test' => 'http://setmpos.ykb.com/PosnetWebService/XML',
94+
'test' => 'https://setmpos.ykb.com/PosnetWebService/XML',
5995
'gateway' => [
60-
'production' => 'http://posnet.ykb.com/3DSWebService/YKBPaymentService',
61-
'test' => 'http://setmpos.ykb.com/3DSWebService/YKBPaymentService',
96+
'production' => 'https://posnet.yapikredi.com.tr/3DSWebService/YKBPaymentService',
97+
'test' => 'https://setmpos.ykb.com/3DSWebService/YKBPaymentService',
6298
],
63-
]
99+
],
64100
],
65101
'garanti' => [
66102
'name' => 'Garanti',
67-
'class' => \Mews\Pos\GarantiPos::class,
103+
'class' => Mews\Pos\Gateways\GarantiPos::class,
68104
'urls' => [
69105
'production' => 'https://sanalposprov.garanti.com.tr/VPServlet',
70106
'test' => 'https://sanalposprovtest.garanti.com.tr/VPServlet',
@@ -74,6 +110,34 @@
74110
],
75111
]
76112
],
113+
'qnbfinansbank-payfor' => [
114+
'name' => 'QNBFinansbank-PayFor',
115+
'class' => Mews\Pos\Gateways\PayForPos::class,
116+
'urls' => [
117+
'production' => 'https://vpos.qnbfinansbank.com/Gateway/XMLGate.aspx',
118+
'test' => 'https://vpostest.qnbfinansbank.com/Gateway/XmlGate.aspx',
119+
'gateway' => [
120+
'production' => 'https://vpos.qnbfinansbank.com/Gateway/Default.aspx',
121+
'test' => 'https://vpostest.qnbfinansbank.com/Gateway/Default.aspx',
122+
],
123+
'gateway_3d_host' => [
124+
'production' => 'https://vpos.qnbfinansbank.com/Gateway/3DHost.aspx',
125+
'test' => 'https://vpostest.qnbfinansbank.com/Gateway/3DHost.aspx',
126+
],
127+
]
128+
],
129+
'vakifbank' => [
130+
'name' => 'VakifBank-VPOS',
131+
'class' => Mews\Pos\Gateways\VakifBankPos::class,
132+
'urls' => [
133+
'production' => 'https://onlineodeme.vakifbank.com.tr:4443/VposService/v3/Vposreq.aspx',
134+
'test' => 'https://onlineodemetest.vakifbank.com.tr:4443/VposService/v3/Vposreq.aspx',
135+
'gateway' => [
136+
'production' => 'https://3dsecure.vakifbank.com.tr:4443/MPIAPI/MPI_Enrollment.aspx',
137+
'test' => 'https://3dsecuretest.vakifbank.com.tr:4443/MPIAPI/MPI_Enrollment.aspx',
138+
],
139+
],
140+
],
77141
],
78142

79143
];

src/Factory/AccountFactory.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
4+
namespace Mews\LaravelPos\Factory;
5+
6+
7+
use Mews\Pos\Entity\Account\EstPosAccount;
8+
use Mews\Pos\Entity\Account\GarantiPosAccount;
9+
use Mews\Pos\Entity\Account\PayForAccount;
10+
use Mews\Pos\Entity\Account\PosNetAccount;
11+
use Mews\Pos\Entity\Account\VakifBankAccount;
12+
use Mews\Pos\Exceptions\BankNotFoundException;
13+
14+
class AccountFactory
15+
{
16+
const ACCOUNTS = [
17+
'akbank' => EstPosAccount::class,
18+
'ziraat' => EstPosAccount::class,
19+
'isbank' => EstPosAccount::class,
20+
'finansbank' => EstPosAccount::class,
21+
'halkbank' => EstPosAccount::class,
22+
'teb' => EstPosAccount::class,
23+
'yapikredi' => PosNetAccount::class,
24+
'garanti' => GarantiPosAccount::class,
25+
'qnbfinansbank-payfor' => PayForAccount::class,
26+
'vakifbank' => VakifBankAccount::class,
27+
];
28+
29+
public static function create(array $account)
30+
{
31+
$class = self::ACCOUNTS[$account['bank']] ?? null;
32+
33+
if (! $class) {
34+
throw new BankNotFoundException();
35+
}
36+
37+
$params = [
38+
$account['bank'],
39+
$account['model'],
40+
$account['client_id'],
41+
];
42+
43+
if ($account['bank'] != 'vakifbank') {
44+
$params[] = $account['username'];
45+
}
46+
47+
$params[] = $account['password'];
48+
49+
if ($account['bank'] != 'vakifbank') {
50+
$params[] = $account['lang'] ?? 'tr';
51+
}
52+
53+
switch ($account['bank']) {
54+
case "garanti":
55+
$params[] = $account['terminal_id'];
56+
$params[] = $account['store_key'] ?? null;
57+
$params[] = $account['refund_username'] ?? null;
58+
$params[] = $account['refund_password'] ?? null;
59+
break;
60+
case "yapikredi":
61+
$params[] = $account['terminal_id'];
62+
$params[] = $account['pos_net_id'];
63+
$params[] = $account['store_key'];
64+
break;
65+
case "vakifbank":
66+
$params[] = $account['terminal_id'];
67+
$params[] = $account['merchant_type'] ?? 0;
68+
$params[] = $account['sub_merchant_id'] ?? null;
69+
}
70+
71+
if ($account['bank'] != 'vakifbank') {
72+
$params[] = $account['store_key'] ?? null;
73+
}
74+
75+
return new $class(...$params);
76+
}
77+
}

src/Factory/CardFactory.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
4+
namespace Mews\LaravelPos\Factory;
5+
6+
7+
use Mews\Pos\Entity\Card\CreditCardEstPos;
8+
use Mews\Pos\Entity\Card\CreditCardGarantiPos;
9+
use Mews\Pos\Entity\Card\CreditCardPayFor;
10+
use Mews\Pos\Entity\Card\CreditCardPosNet;
11+
use Mews\Pos\Entity\Card\CreditCardVakifBank;
12+
use Mews\Pos\Exceptions\BankNotFoundException;
13+
14+
class CardFactory
15+
{
16+
const CARDS = [
17+
'akbank' => CreditCardEstPos::class,
18+
'ziraat' => CreditCardEstPos::class,
19+
'isbank' => CreditCardEstPos::class,
20+
'finansbank' => CreditCardEstPos::class,
21+
'halkbank' => CreditCardEstPos::class,
22+
'teb' => CreditCardEstPos::class,
23+
'yapikredi' => CreditCardPosNet::class,
24+
'garanti' => CreditCardGarantiPos::class,
25+
'qnbfinansbank-payfor' => CreditCardPayFor::class,
26+
'vakifbank' => CreditCardVakifBank::class,
27+
];
28+
29+
public static function create(array $card)
30+
{
31+
$class = self::CARDS[$card['bank']];
32+
33+
if (! $class) {
34+
throw new BankNotFoundException();
35+
}
36+
37+
$number = $card['number'];
38+
$expireMonth = $card['month'];
39+
$expireYear = $card['year'];
40+
$cvv = $card['cvv'];
41+
$cardHolderName = $card['name'] ?? null;
42+
$cardType = $card['type'] ?? null;
43+
44+
return new $class($number, $expireYear, $expireMonth, $cvv, $cardHolderName, $cardType);
45+
}
46+
}

0 commit comments

Comments
 (0)