Skip to content

Commit cec6841

Browse files
committed
issue #172 - upgrade KuveytPos version to TDV2.0.0
1 parent 94a88c3 commit cec6841

File tree

8 files changed

+259
-13
lines changed

8 files changed

+259
-13
lines changed

config/pos_production.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@
152152
'name' => 'kuveyt-pos',
153153
'class' => Mews\Pos\Gateways\KuveytPos::class,
154154
'gateway_endpoints' => [
155-
'payment_api' => 'https://boa.kuveytturk.com.tr/sanalposservice/Home/ThreeDModelProvisionGate',
156-
'gateway_3d' => 'https://boa.kuveytturk.com.tr/sanalposservice/Home/ThreeDModelPayGate',
155+
'payment_api' => 'https://sanalpos.kuveytturk.com.tr/ServiceGateWay/Home/ThreeDModelProvisionGate',
156+
'gateway_3d' => 'https://sanalpos.kuveytturk.com.tr/ServiceGateWay/Home/ThreeDModelPayGate',
157157
'query_api' => 'https://boa.kuveytturk.com.tr/BOA.Integration.WCFService/BOA.Integration.VirtualPos/VirtualPosService.svc?wsdl',
158158
],
159159
],

docs/THREED-PAYMENT-EXAMPLE.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,39 @@ try {
172172
}
173173
});
174174

175+
// KuveytVos TDV2.0.0 icin ozel biri durum
176+
$eventDispatcher->addListener(
177+
RequestDataPreparedEvent::class,
178+
function (RequestDataPreparedEvent $requestDataPreparedEvent) use ($pos): void {
179+
if (get_class($pos) !== \Mews\Pos\Gateways\KuveytPos::class) {
180+
return;
181+
}
182+
// KuveytPos TDV2.0.0 icin zorunlu eklenmesi gereken ekstra alanlar:
183+
$additionalRequestDataForKuveyt = [
184+
'DeviceData' => [
185+
//2 karakter olmalıdır. 01-Mobil, 02-Web Browser için kullanılmalıdır.
186+
'DeviceChannel' => '02',
187+
],
188+
'CardHolderData' => [
189+
'BillAddrCity' => 'İstanbul',
190+
// ISO 3166-1 sayısal üç haneli ülke kodu standardı kullanılmalıdır.
191+
'BillAddrCountry' => '792',
192+
'BillAddrLine1' => 'XXX Mahallesi XXX Caddesi No 55 Daire 1',
193+
'BillAddrPostCode' => '34000',
194+
// ISO 3166-2'de tanımlı olan il/eyalet kodu olmalıdır.
195+
'BillAddrState' => '40',
196+
'Email' => '[email protected]',
197+
'MobilePhone' => [
198+
'Cc' => '90',
199+
'Subscriber' => '1234567899',
200+
],
201+
],
202+
];
203+
$requestData = $requestDataPreparedEvent->getRequestData();
204+
$requestData = array_merge($requestData, $additionalRequestDataForKuveyt);
205+
$requestDataPreparedEvent->setRequestData($requestData);
206+
});
207+
175208
$formData = $pos->get3DFormData(
176209
$order,
177210
$paymentModel,

examples/_common-codes/3d/form.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,71 @@
5656
*/
5757
});
5858

59+
// KuveytVos TDV2.0.0 icin ozel biri durum
60+
$eventDispatcher->addListener(
61+
RequestDataPreparedEvent::class,
62+
function (RequestDataPreparedEvent $requestDataPreparedEvent) use ($pos): void {
63+
if (get_class($pos) !== \Mews\Pos\Gateways\KuveytPos::class) {
64+
return;
65+
}
66+
// KuveytPos TDV2.0.0 icin zorunlu eklenmesi gereken ekstra alanlar:
67+
$additionalRequestDataForKuveyt = [
68+
'DeviceData' => [
69+
/**
70+
* DeviceChannel : DeviceData alanı içerisinde gönderilmesi beklenen işlemin yapıldığı cihaz bilgisi.
71+
* 2 karakter olmalıdır. 01-Mobil, 02-Web Browser için kullanılmalıdır.
72+
*/
73+
'DeviceChannel' => '02',
74+
],
75+
'CardHolderData' => [
76+
/**
77+
* BillAddrCity: Kullanılan kart ile ilişkili kart hamilinin fatura adres şehri.
78+
* Maksimum 50 karakter uzunluğunda olmalıdır.
79+
*/
80+
'BillAddrCity' => 'İstanbul',
81+
/**
82+
* BillAddrCountry Kullanılan kart ile ilişkili kart hamilinin fatura adresindeki ülke kodu.
83+
* Maksimum 3 karakter uzunluğunda olmalıdır.
84+
* ISO 3166-1 sayısal üç haneli ülke kodu standardı kullanılmalıdır.
85+
*/
86+
'BillAddrCountry' => '792',
87+
/**
88+
* BillAddrLine1: Kullanılan kart ile ilişkili kart hamilinin teslimat adresinde yer alan sokak vb. bilgileri içeren açık adresi.
89+
* Maksimum 150 karakter uzunluğunda olmalıdır.
90+
*/
91+
'BillAddrLine1' => 'XXX Mahallesi XXX Caddesi No 55 Daire 1',
92+
/**
93+
* BillAddrPostCode: Kullanılan kart ile ilişkili kart hamilinin fatura adresindeki posta kodu.
94+
*/
95+
'BillAddrPostCode' => '34000',
96+
/**
97+
* BillAddrState: CardHolderData alanı içerisinde gönderilmesi beklenen ödemede kullanılan kart ile ilişkili kart hamilinin fatura adresindeki il veya eyalet bilgisi kodu.
98+
* ISO 3166-2'de tanımlı olan il/eyalet kodu olmalıdır.
99+
*/
100+
'BillAddrState' => '40',
101+
/**
102+
* Email: Kullanılan kart ile ilişkili kart hamilinin iş yerinde oluşturduğu hesapta kullandığı email adresi.
103+
* Maksimum 254 karakter uzunluğunda olmalıdır.
104+
*/
105+
'Email' => '[email protected]',
106+
'MobilePhone' => [
107+
/**
108+
* Cc: Kullanılan kart ile ilişkili kart hamilinin cep telefonuna ait ülke kodu. 1-3 karakter uzunluğunda olmalıdır.
109+
*/
110+
'Cc' => '90',
111+
/**
112+
* Subscriber: Kullanılan kart ile ilişkili kart hamilinin cep telefonuna ait abone numarası.
113+
* Maksimum 15 karakter uzunluğunda olmalıdır.
114+
*/
115+
'Subscriber' => '1234567899',
116+
],
117+
],
118+
];
119+
$requestData = $requestDataPreparedEvent->getRequestData();
120+
$requestData = array_merge($requestData, $additionalRequestDataForKuveyt);
121+
$requestDataPreparedEvent->setRequestData($requestData);
122+
});
123+
59124
/**
60125
* Bu Event'i dinleyerek 3D formun hash verisi hesaplanmadan önce formun input array içireğini güncelleyebilirsiniz.
61126
*/

examples/kuveytpos/3d/_config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
$account = \Mews\Pos\Factory\AccountFactory::createKuveytPosAccount(
1010
'kuveytpos',
1111
'496',
12-
'apiuser1',
12+
'apitest',
1313
'400235',
14-
'Api1232',
14+
'api123',
1515
PosInterface::MODEL_3D_SECURE
1616
);
1717

examples/kuveytpos/_payment_config.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99

1010
$testCards = [
1111
'visa1' => [
12-
'number' => '4155650100416111',
12+
//Kart Doğrulama Şifresi: 123456
13+
'number' => '5188961939192544',
1314
'year' => '25',
14-
'month' => '1',
15-
'cvv' => '123',
15+
'month' => '06',
16+
'cvv' => '929',
1617
'name' => 'John Doe',
17-
'type' => CreditCardInterface::CARD_TYPE_VISA,
18+
'type' => CreditCardInterface::CARD_TYPE_MASTERCARD,
1819
],
1920
];

src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class KuveytPosRequestDataMapper extends AbstractRequestDataMapper
2020
{
2121
/** @var string */
22-
public const API_VERSION = '1.0.0';
22+
public const API_VERSION = 'TDV2.0.0';
2323

2424
/** @var string */
2525
public const CREDIT_CARD_EXP_YEAR_FORMAT = 'y';
@@ -39,10 +39,10 @@ class KuveytPosRequestDataMapper extends AbstractRequestDataMapper
3939
* {@inheritDoc}
4040
*/
4141
protected array $txTypeMappings = [
42-
PosInterface::TX_TYPE_PAY_AUTH => 'Sale',
43-
PosInterface::TX_TYPE_CANCEL => 'SaleReversal',
44-
PosInterface::TX_TYPE_STATUS => 'GetMerchantOrderDetail',
45-
PosInterface::TX_TYPE_REFUND => 'PartialDrawback', // Also there is a "Drawback"
42+
PosInterface::TX_TYPE_PAY_AUTH => 'Sale',
43+
PosInterface::TX_TYPE_CANCEL => 'SaleReversal',
44+
PosInterface::TX_TYPE_STATUS => 'GetMerchantOrderDetail',
45+
PosInterface::TX_TYPE_REFUND => 'PartialDrawback', // Also there is a "Drawback"
4646
];
4747

4848
/**
@@ -133,6 +133,9 @@ public function create3DEnrollmentCheckRequestData(KuveytPosAccount $kuveytPosAc
133133
'MerchantOrderId' => $order['id'],
134134
'OkUrl' => $order['success_url'],
135135
'FailUrl' => $order['fail_url'],
136+
'DeviceData' => [
137+
'ClientIP' => $order['ip'],
138+
],
136139
];
137140

138141
if ($creditCard instanceof CreditCardInterface) {

tests/Functional/KuveytPosTest.php

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?php
2+
/**
3+
* @license MIT
4+
*/
5+
6+
use Mews\Pos\Entity\Card\CreditCardInterface;
7+
use Mews\Pos\Event\RequestDataPreparedEvent;
8+
use Mews\Pos\Factory\CreditCardFactory;
9+
use Mews\Pos\Factory\PosFactory;
10+
use Mews\Pos\PosInterface;
11+
use Monolog\Test\TestCase;
12+
use Symfony\Component\EventDispatcher\EventDispatcher;
13+
14+
class KuveytPosTest extends TestCase
15+
{
16+
use \Mews\Pos\Tests\Functional\PaymentTestTrait;
17+
18+
private CreditCardInterface $card;
19+
20+
private EventDispatcher $eventDispatcher;
21+
22+
/** @var KuveytPosTest */
23+
private PosInterface $pos;
24+
25+
private array $lastResponse;
26+
27+
protected function setUp(): void
28+
{
29+
parent::setUp();
30+
31+
$config = require __DIR__.'/../../config/pos_test.php';
32+
33+
$account = \Mews\Pos\Factory\AccountFactory::createKuveytPosAccount(
34+
'kuveytpos',
35+
'496',
36+
'apitest',
37+
'400235',
38+
'api123',
39+
PosInterface::MODEL_3D_SECURE
40+
);
41+
42+
$this->eventDispatcher = new EventDispatcher();
43+
44+
$this->pos = PosFactory::createPosGateway($account, $config, $this->eventDispatcher);
45+
46+
$this->pos->setTestMode(true);
47+
48+
$this->card = CreditCardFactory::createForGateway(
49+
$this->pos,
50+
'5188961939192544',
51+
'25',
52+
'06',
53+
'929',
54+
'John Doe',
55+
CreditCardInterface::CARD_TYPE_MASTERCARD
56+
);
57+
}
58+
59+
/**
60+
* NOT: sadece Turkiye IPsiyle istek gonderince cevap alabiliyoruz.
61+
* @return void
62+
*/
63+
public function testCreate3DFormData(): void
64+
{
65+
$order = $this->createPaymentOrder();
66+
67+
$eventIsThrown = false;
68+
$this->eventDispatcher->addListener(
69+
RequestDataPreparedEvent::class,
70+
function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void {
71+
$eventIsThrown = true;
72+
$additionalRequestDataForKuveyt = [
73+
'DeviceData' => [
74+
/**
75+
* DeviceChannel : DeviceData alanı içerisinde gönderilmesi beklenen işlemin yapıldığı cihaz bilgisi.
76+
* 2 karakter olmalıdır. 01-Mobil, 02-Web Browser için kullanılmalıdır.
77+
*/
78+
'DeviceChannel' => '02',
79+
],
80+
'CardHolderData' => [
81+
/**
82+
* BillAddrCity: Kullanılan kart ile ilişkili kart hamilinin fatura adres şehri.
83+
* Maksimum 50 karakter uzunluğunda olmalıdır.
84+
*/
85+
'BillAddrCity' => 'İstanbul',
86+
/**
87+
* BillAddrCountry Kullanılan kart ile ilişkili kart hamilinin fatura adresindeki ülke kodu.
88+
* Maksimum 3 karakter uzunluğunda olmalıdır.
89+
* ISO 3166-1 sayısal üç haneli ülke kodu standardı kullanılmalıdır.
90+
*/
91+
'BillAddrCountry' => '792',
92+
/**
93+
* BillAddrLine1: Kullanılan kart ile ilişkili kart hamilinin teslimat adresinde yer alan sokak vb. bilgileri içeren açık adresi.
94+
* Maksimum 150 karakter uzunluğunda olmalıdır.
95+
*/
96+
'BillAddrLine1' => 'XXX Mahallesi XXX Caddesi No 55 Daire 1',
97+
/**
98+
* BillAddrPostCode: Kullanılan kart ile ilişkili kart hamilinin fatura adresindeki posta kodu.
99+
*/
100+
'BillAddrPostCode' => '34000',
101+
/**
102+
* BillAddrState: CardHolderData alanı içerisinde gönderilmesi beklenen ödemede kullanılan kart ile ilişkili kart hamilinin fatura adresindeki il veya eyalet bilgisi kodu.
103+
* ISO 3166-2'de tanımlı olan il/eyalet kodu olmalıdır.
104+
*/
105+
'BillAddrState' => '40',
106+
/**
107+
* Email: Kullanılan kart ile ilişkili kart hamilinin iş yerinde oluşturduğu hesapta kullandığı email adresi.
108+
* Maksimum 254 karakter uzunluğunda olmalıdır.
109+
*/
110+
'Email' => '[email protected]',
111+
'MobilePhone' => [
112+
/**
113+
* Cc: Kullanılan kart ile ilişkili kart hamilinin cep telefonuna ait ülke kodu. 1-3 karakter uzunluğunda olmalıdır.
114+
*/
115+
'Cc' => '90',
116+
/**
117+
* Subscriber: Kullanılan kart ile ilişkili kart hamilinin cep telefonuna ait abone numarası.
118+
* Maksimum 15 karakter uzunluğunda olmalıdır.
119+
*/
120+
'Subscriber' => '1234567899',
121+
],
122+
],
123+
];
124+
$requestData = $requestDataPreparedEvent->getRequestData();
125+
$requestData = array_merge($requestData, $additionalRequestDataForKuveyt);
126+
$requestDataPreparedEvent->setRequestData($requestData);
127+
$this->assertSame(PosInterface::TX_TYPE_PAY_AUTH, $requestDataPreparedEvent->getTxType());
128+
});
129+
130+
$formData = $this->pos->get3DFormData(
131+
$order,
132+
PosInterface::MODEL_3D_SECURE,
133+
PosInterface::TX_TYPE_PAY_AUTH,
134+
$this->card,
135+
);
136+
137+
$this->assertIsArray($formData);
138+
$this->assertNotEmpty($formData);
139+
$this->assertTrue($eventIsThrown);
140+
}
141+
}

tests/Unit/DataMapper/RequestDataMapper/KuveytPosRequestDataMapperTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ public static function create3DEnrollmentCheckRequestDataDataProvider(): array
466466
'CardExpireDateYear' => '25',
467467
'CardExpireDateMonth' => '01',
468468
'CardCVV2' => '123',
469+
'DeviceData' => [
470+
'ClientIP' => '127.0.0.1',
471+
],
469472
],
470473
],
471474
];

0 commit comments

Comments
 (0)