Skip to content

Commit d84b40c

Browse files
authored
Merge pull request #155 from mewebstudio/153-asseco-isbanka-imece-kart-destegi
issue #153 Isbank Asseco İMECE kart ile ödeme desteği eklendi
2 parents 8925de9 + 0014ddd commit d84b40c

File tree

5 files changed

+260
-4
lines changed

5 files changed

+260
-4
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Bu paket ile amaçlanan; ortak bir arayüz sınıfı ile, tüm Türk banka sanal
2323

2424
- **EST POS V3** EstPos altyapının daha güvenli (sha512) hash algoritmasıyla uygulaması.
2525

26-
Desktekleyen bankalar: Akbank, TEB, ~~İşbank,~~ Şekerbank, Halkbank ve Finansbank.
26+
Desktekleyen bankalar: Akbank, TEB, İşbank, Şekerbank, Halkbank ve Finansbank.
2727

2828

2929
- **PayFlex MPI VPOS V4**
@@ -120,6 +120,7 @@ Bu paket ile amaçlanan; ortak bir arayüz sınıfı ile, tüm Türk banka sanal
120120
- Sipariş/Para iadesi yapma (`AbstractGateway::TX_REFUND`)
121121
- Sipariş iptal etme (`AbstractGateway::TX_CANCEL`)
122122
- Tekrarlanan (Recurring) ödeme talimatları
123+
- İşbank [İMECE kart](https://www.isbank.com.tr/is-ticari/imece-kart) kart ile ödeme desteği
123124
- [PSR-3](https://www.php-fig.org/psr/psr-3/) logger desteği
124125
- [PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP Client desteği
125126

@@ -393,11 +394,11 @@ $logger = new \Monolog\Logger('pos', [$handler]);
393394
$pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account, null, null, $logger);
394395
```
395396

396-
## Genel Kültür
397+
## Genel Kultur
397398
### NonSecure, 3D Secure, 3DPay ve 3DHost ödeme modeller arasındaki farklar
398399
- **3D** - Bankaya göre farklı isimler verilebilir, örn. 3D Full. Gateway'den (3D şifre girdiginiz sayfadan) döndükten sonra ödemeyi tamamlamak için banka gateway'ne 1 istek daha (_provizyon_ isteği) gönderir.
399400
Bu isteği göndermeden ödeme tamamlanmaz.
400-
- **3DPay** - Bankaya göre farklı isimler verilebilir, örn. 3D Half. Gateway'den (3D şifre girdiginiz sayfadan) döndükten sonra ödeme bitmiş sayılır. 3D ödeme yapıldığı gibi ekstra provizyon istek gönderilmez.
401+
- **3DPay** - Bankaya göre farklı isimler verilebilir, örn. 3D Half. Gateway'den (3D şifre girdiginiz sayfadan) döndükten sonra ödeme bitmiş sayılır. 3D ödemede yapıldığı gibi ekstra provizyon istek gönderilmez.
401402
- **3DHost** - Kredi kart girişi için kullanıcı bankanın sayfasına yönledirilir, kredi kart bilgileri girdikten sonra bankanın 3D gateway sayfasına yönlendirilir, ordan da websitenize geri yönlendirilir. Yönlendirme sonucunda ödeme tamanlanmış olur.
402403
- **NonSecure** - Ödeme işlemi kullanıcı 3D onay işlemi yapmadan gerçekleşir.
403404
- **NonSecure, 3D ve 3DPay** - Ödemede kredi kart bilgisi websiteniz tarafından alınır. **3DHost** ödemede ise banka websayfasından alınır.

docs/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## [0.14.0] - 2023-09-09
4+
### New Features
5+
- **İşbank Asseco** - İMECE kart ile ödeme desteği eklendi.
6+
7+
İMECE kart ile ödeme yapabilmek için
8+
```
9+
$order['is_imece_card'] = true;
10+
```
11+
ekleyerek sipariş verisi oluşturulması gerekiyor.
12+
313
## [0.13.0] - 2023-06-24
414
### New Features
515
- **PosNetV1** - JSON API desteği eklendi.

examples/akbank/_payment_config.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ function getNewOrder(
5959
\Symfony\Component\HttpFoundation\Session\Session $session,
6060
?int $installment = 0,
6161
bool $tekrarlanan = false,
62-
string $lang = AbstractGateway::LANG_TR
62+
string $lang = AbstractGateway::LANG_TR,
63+
bool $isImeceCard = false
6364
): array {
6465
$order = createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, $lang);
6566

@@ -72,6 +73,14 @@ function getNewOrder(
7273
$order['recurringInstallmentCount'] = $installment;
7374
}
7475

76+
if ($isImeceCard) {
77+
/**
78+
* IMECE kartlar isbankin tarima destek icin ozel kampanyalari olan kartlardir.
79+
* https://www.isbank.com.tr/is-ticari/imece-kart
80+
*/
81+
$order['is_imece_card'] = true;
82+
}
83+
7584
return $order;
7685
}
7786

@@ -120,4 +129,20 @@ function doPayment(\Mews\Pos\PosInterface $pos, string $transaction, ?\Mews\Pos\
120129
'name' => 'John Doe',
121130
'type' => AbstractCreditCard::CARD_TYPE_VISA,
122131
],
132+
'visa_isbank_imece' => [
133+
/**
134+
* IMECE kartlar isbankin tarima destek icin ozel kampanyalari olan kartlardir.
135+
* https://www.isbank.com.tr/is-ticari/imece-kart
136+
*
137+
* bu karti test edebilmek icin bu kartlarla odemeyi destekleyen Isbank Pos hesabi lazim.
138+
*
139+
* ayrica $order['is_imece_card'] = true verisiyle siparis verisi olusturulacak
140+
*/
141+
'number' => '4242424242424242',
142+
'year' => '2028',
143+
'month' => '10',
144+
'cvv' => '123',
145+
'name' => 'John Doe',
146+
'type' => AbstractCreditCard::CARD_TYPE_VISA,
147+
],
123148
];

src/DataMapper/EstPosRequestDataMapper.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order,
9393
];
9494
}
9595

96+
/**
97+
* IMECE kartlar isbankin tarima destek icin ozel kampanyalari olan kartlardir.
98+
* IMECE kart ile odeme yapabilmek icin MODEL_3D_SECURE odemede alttaki 2 alan gonderilmesi gerkeiyor.
99+
* https://www.isbank.com.tr/is-ticari/imece-kart
100+
*/
101+
if (isset($order->is_imece_card) && true === $order->is_imece_card) {
102+
$requestData['Extra']['IMCKOD'] = 'İmece Ürün Bilgisi';
103+
$requestData['Extra']['FDONEM'] = 'Faizsiz Dönem Bilgisi';
104+
}
105+
96106
if (isset($order->recurringFrequency)) {
97107
$requestData += $this->getRecurringRequestOrderData($order);
98108
}
@@ -277,6 +287,27 @@ public function create3DFormDataCommon(AbstractPosAccount $account, $order, stri
277287
$inputs['cv2'] = $card->getCvv();
278288
}
279289

290+
/**
291+
* IMECE kartlar isbankin tarima destek icin ozel kampanyalari olan kartlardir.
292+
* IMECE kart ile odeme yapabilmek icin MODEL_3D_SECURE odemede alttaki 2 alan gonderilmesi gerkeiyor.
293+
* https://www.isbank.com.tr/is-ticari/imece-kart
294+
*/
295+
if (isset($order->is_imece_card) && true === $order->is_imece_card) {
296+
/**
297+
* AbstractGateway::MODEL_3D_SECURE modeli icin IMECE alanlari formda gondermiyoruz,
298+
* bir sonraki prozizyon tamamlama asamasinda gonderiyoruz
299+
*/
300+
$supportedPaymentModels = [
301+
AbstractGateway::MODEL_3D_PAY,
302+
AbstractGateway::MODEL_3D_PAY_HOSTING,
303+
AbstractGateway::MODEL_3D_HOST,
304+
];
305+
if (in_array($account->getModel(), $supportedPaymentModels)) {
306+
$inputs['IMCKOD'] = 'İmece Ürün Bilgisi';
307+
$inputs['FDONEM'] = 'Faizsiz Dönem Bilgisi';
308+
}
309+
}
310+
280311
return [
281312
'gateway' => $gatewayURL,
282313
'method' => 'POST',

tests/DataMapper/EstPosRequestDataMapperTest.php

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,41 @@ public function testCreate3DPaymentRequestData()
227227
$this->assertEquals($expectedData, $actual);
228228
}
229229

230+
/**
231+
* @return void
232+
*/
233+
public function testCreate3DPaymentImeceRequestData()
234+
{
235+
$order = [
236+
'id' => '2020110828BC',
237+
'email' => 'samp@iexample.com',
238+
'name' => 'john doe',
239+
'user_id' => '1535',
240+
'ip' => '192.168.1.0',
241+
'amount' => 100.01,
242+
'installment' => '0',
243+
'currency' => 'TRY',
244+
'success_url' => 'http://localhost/finansbank-payfor/3d/response.php',
245+
'fail_url' => 'http://localhost/finansbank-payfor/3d/response.php',
246+
'is_imece_card' => true,
247+
];
248+
249+
$responseData = [
250+
'md' => '1',
251+
'xid' => '100000005xid',
252+
'eci' => '100000005eci',
253+
'cavv' => 'cavv',
254+
];
255+
256+
$pos = $this->pos;
257+
$pos->prepare($order, AbstractGateway::TX_PAY);
258+
259+
$actual = $this->requestDataMapper->create3DPaymentRequestData($pos->getAccount(), $pos->getOrder(), AbstractGateway::TX_PAY, $responseData);
260+
261+
$expectedData = $this->getSample3DPaymentImeceRequestData($pos->getAccount(), $responseData);
262+
$this->assertEquals($expectedData, $actual);
263+
}
264+
230265
/**
231266
* @return void
232267
*/
@@ -323,6 +358,23 @@ public function testGet3DFormData()
323358
));
324359
}
325360

361+
/**
362+
* @dataProvider threeDFormDataProvider
363+
*/
364+
public function testGet3DFormDataImece(AbstractGateway $pos, array $order, string $txType, ?AbstractCreditCard $card, array $expectedResponse): void
365+
{
366+
$pos->prepare($order, $txType);
367+
$gatewayURL = $this->config['banks'][$pos->getAccount()->getBank()]['urls']['gateway']['test'];
368+
369+
$this->assertSame($expectedResponse, $this->requestDataMapper->create3DFormData(
370+
$pos->getAccount(),
371+
$pos->getOrder(),
372+
$txType,
373+
$gatewayURL,
374+
$card
375+
));
376+
}
377+
326378
/**
327379
* @return void
328380
*/
@@ -429,6 +481,108 @@ public function testCreateRefundRequestData()
429481
$this->assertEquals($expectedData, $actual);
430482
}
431483

484+
public static function threeDFormDataProvider(): iterable
485+
{
486+
$threeDAccount = AccountFactory::createEstPosAccount(
487+
'akbank',
488+
'700655000200',
489+
'ISBANKAPI',
490+
'ISBANK07',
491+
AbstractGateway::MODEL_3D_SECURE,
492+
'TRPS0200'
493+
);
494+
$order = [
495+
'id' => 'order222',
496+
'ip' => '127.0.0.1',
497+
'name' => 'siparis veren',
498+
'email' => 'test@test.com',
499+
'amount' => '100.25',
500+
'installment' => 0,
501+
'currency' => 'TRY',
502+
'success_url' => 'https://domain.com/success',
503+
'fail_url' => 'https://domain.com/fail_url',
504+
'lang' => 'tr',
505+
'rand' => 'rand',
506+
'is_imece_card' => true,
507+
];
508+
$threeDSecurePos = PosFactory::createPosGateway($threeDAccount);
509+
$card = CreditCardFactory::create($threeDSecurePos, '5555444433332222', '22', '01', '123', 'ahmet', AbstractCreditCard::CARD_TYPE_VISA);
510+
yield 'imece_3d_secure' => [
511+
$threeDSecurePos,
512+
$order,
513+
AbstractGateway::TX_PAY,
514+
$card,
515+
[
516+
'gateway' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
517+
'method' => 'POST',
518+
'inputs' => [
519+
'clientid' => '700655000200',
520+
'storetype' => '3d',
521+
'amount' => '100.25',
522+
'oid' => 'order222',
523+
'okUrl' => 'https://domain.com/success',
524+
'failUrl' => 'https://domain.com/fail_url',
525+
'rnd' => 'rand',
526+
'lang' => 'tr',
527+
'currency' => '949',
528+
'taksit' => '',
529+
'islemtipi' => 'Auth',
530+
'firmaadi' => 'siparis veren',
531+
'Email' => 'test@test.com',
532+
'cardType' => '1',
533+
'pan' => '5555444433332222',
534+
'Ecom_Payment_Card_ExpDate_Month' => '01',
535+
'Ecom_Payment_Card_ExpDate_Year' => '22',
536+
'cv2' => '123',
537+
'hash' => 'S7UxUAohxaxzl35WxHyDfuQx0sg=',
538+
],
539+
],
540+
];
541+
542+
$threeDPayAccount = AccountFactory::createEstPosAccount(
543+
'akbank',
544+
'700655000200',
545+
'ISBANKAPI',
546+
'ISBANK07',
547+
AbstractGateway::MODEL_3D_PAY,
548+
'TRPS0200'
549+
);
550+
551+
yield 'imece_3d_pay' => [
552+
PosFactory::createPosGateway($threeDPayAccount),
553+
$order,
554+
AbstractGateway::TX_PAY,
555+
$card,
556+
[
557+
'gateway' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
558+
'method' => 'POST',
559+
'inputs' => [
560+
'clientid' => '700655000200',
561+
'storetype' => '3d_pay',
562+
'amount' => '100.25',
563+
'oid' => 'order222',
564+
'okUrl' => 'https://domain.com/success',
565+
'failUrl' => 'https://domain.com/fail_url',
566+
'rnd' => 'rand',
567+
'lang' => 'tr',
568+
'currency' => '949',
569+
'taksit' => '',
570+
'islemtipi' => 'Auth',
571+
'firmaadi' => 'siparis veren',
572+
'Email' => 'test@test.com',
573+
'cardType' => '1',
574+
'pan' => '5555444433332222',
575+
'Ecom_Payment_Card_ExpDate_Month' => '01',
576+
'Ecom_Payment_Card_ExpDate_Year' => '22',
577+
'cv2' => '123',
578+
'IMCKOD' => 'İmece Ürün Bilgisi',
579+
'FDONEM' => 'Faizsiz Dönem Bilgisi',
580+
'hash' => 'S7UxUAohxaxzl35WxHyDfuQx0sg=',
581+
],
582+
],
583+
];
584+
}
585+
432586
/**
433587
* @param AbstractPosAccount $account
434588
* @param $order
@@ -474,6 +628,41 @@ private function getSample3DPaymentRequestData(AbstractPosAccount $account, $ord
474628
return $requestData;
475629
}
476630

631+
/**
632+
* @param AbstractPosAccount $account
633+
* @param array $responseData
634+
*
635+
* @return array
636+
*/
637+
private function getSample3DPaymentImeceRequestData(AbstractPosAccount $account, array $responseData): array
638+
{
639+
return [
640+
'Name' => $account->getUsername(),
641+
'Password' => $account->getPassword(),
642+
'ClientId' => $account->getClientId(),
643+
'Type' => 'Auth',
644+
'IPAddress' => '192.168.1.0',
645+
'Email' => 'samp@iexample.com',
646+
'OrderId' => '2020110828BC',
647+
'UserId' => '1535',
648+
'Total' => '100.01',
649+
'Currency' => '949',
650+
'Taksit' => '',
651+
'Number' => $responseData['md'],
652+
'PayerTxnId' => $responseData['xid'],
653+
'PayerSecurityLevel' => $responseData['eci'],
654+
'PayerAuthenticationCode' => $responseData['cavv'],
655+
'Mode' => 'P',
656+
'Extra' => [
657+
'IMCKOD' => 'İmece Ürün Bilgisi',
658+
'FDONEM' => 'Faizsiz Dönem Bilgisi',
659+
],
660+
'BillTo' => [
661+
'Name' => 'john doe',
662+
],
663+
];
664+
}
665+
477666
/**
478667
* @param AbstractPosAccount $account
479668
* @param $order

0 commit comments

Comments
 (0)