Skip to content

Commit

Permalink
Merge branch 'master' into v2
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php
#	src/DataMapper/RequestDataMapper/GarantiPosRequestDataMapper.php
#	src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php
#	src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php
#	src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php
#	tests/Unit/Gateways/PayForTest.php
  • Loading branch information
mustapayev committed Nov 16, 2024
2 parents 39eef0f + 4c53a77 commit 21629cb
Show file tree
Hide file tree
Showing 85 changed files with 3,273 additions and 170 deletions.
73 changes: 47 additions & 26 deletions README.md

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Changelog
## [1.5.0] - 2024-11-11

### New Features
- [Custom Query](./CUSTOM-QUERY-EXAMPLE.md) desteği eklendi. (issue #250)

### Changed
- **VakifKatilimPos** - sipariş detay sorgusunda mapping iyileştirilmesi.

### Fixed
- Bazı gatewaylarin response'larında bankadan gelen verinin yer almaması.

## [1.4.0] - 2024-07-02

### New Features
Expand Down
85 changes: 85 additions & 0 deletions docs/CUSTOM-QUERY-EXAMPLE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

### Custom Query

Kütüphanenin desteği olmadığı özel istekleri bu methodla yapabilirsiniz.

```sh
$ cp ./vendor/mews/pos/config/pos_test.php ./pos_test_ayarlar.php
```

**config.php (Ayar dosyası)**
```php
<?php
require './vendor/autoload.php';

// API kullanıcı bilgileri
// AccountFactory'de kullanılacak method Gateway'e göre değişir!!!
// /examples altındaki _config.php dosyalara bakınız
// (örn: /examples/tosla/regular/_config.php)
$account = \Mews\Pos\Factory\AccountFactory::createToslaPosAccount(
'tosla',
'424342224432',
'POS_rwrwwrwr',
'POS_4343223',
);
$eventDispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();

try {
$config = require __DIR__.'/pos_test_ayarlar.php';

$pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account, $config, $eventDispatcher);

// GarantiPos'u test ortamda test edebilmek için zorunlu.
$pos->setTestMode(true);
} catch (\Mews\Pos\Exceptions\BankNotFoundException | \Mews\Pos\Exceptions\BankClassNullException $e) {
var_dump($e));
exit;
}
```

**custom_query.php**
```php
<?php

require 'config.php';

/**
* requestData içinde API hesap bilgileri, hash verisi ve bazi sabit değerler
* eğer zaten bulunmuyorsa kütüphane otomatik ekler.
*/
$requestData = [
'bin' => 415956,
];

/** @var \Symfony\Component\EventDispatcher\EventDispatcher $eventDispatcher */
$eventDispatcher->addListener(\Mews\Pos\Event\RequestDataPreparedEvent::class, function (\Mews\Pos\Event\RequestDataPreparedEvent $event) {
// dump($event->getRequestData()); //bankaya gonderilecek veri:
//
// // Burda istek banka API'na gonderilmeden once gonderilecek veriyi degistirebilirsiniz.
// // Ornek:
// if ($event->getTxType() === PosInterface::TX_TYPE_CUSTOM_QUERY) {
// $data = $event->getRequestData();
// $data['abcd'] = '1234';
// $event->setRequestData($data);
// }
});

try {
$pos->customQuery(
$requestData,

// URL optional, bazı gateway'lerde zorunlu.
// Default olarak configdeki query_api ya da payment_api kullanılır.
'https://prepentegrasyon.tosla.com/api/Payment/GetCommissionAndInstallmentInfo'
);
} catch (Exception $e) {
dd($e);
}

/**
* Bankadan dönen cevap array'e dönüştürülür,
* ancak diğer transaction'larda olduğu gibi mapping/normalization yapılmaz.
*/
$response = $pos->getResponse();
var_dump($response);
```
6 changes: 6 additions & 0 deletions docs/THREED-PAYMENT-EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ try {
$transactionType,
$card
);
} catch (\InvalidArgumentException $e) {
// örneğin kart bilgisi sağlanmadığında bu exception'i alırsınız.
var_dump($e);
} catch (\LogicException $e) {
// ödeme modeli veya işlem tipi desteklenmiyorsa bu exception'i alırsınız.
var_dump($e);
} catch (\Exception|\Error $e) {
var_dump($e);
exit;
Expand Down
6 changes: 6 additions & 0 deletions docs/THREED-SECURE-AND-PAY-PAYMENT-IN-MODALBOX-EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ try {
$transactionType,
$card
);
} catch (\InvalidArgumentException $e) {
// örneğin kart bilgisi sağlanmadığında bu exception'i alırsınız.
var_dump($e);
} catch (\LogicException $e) {
// ödeme modeli veya işlem tipi desteklenmiyorsa bu exception'i alırsınız.
var_dump($e);
} catch (\Throwable $e) {
var_dump($e);
exit;
Expand Down
3 changes: 3 additions & 0 deletions examples/_common-codes/3d-host/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@

try {
$formData = $pos->get3DFormData($order, PosInterface::MODEL_3D_HOST, $transaction);
} catch (\LogicException $e) {
// ödeme modeli veya işlem tipi desteklenmiyorsa bu exception'i alırsınız.
dd($e);
} catch (\Exception $e) {
dd($e);
}
Expand Down
6 changes: 6 additions & 0 deletions examples/_common-codes/3d/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent): void {
try {
$formData = $pos->get3DFormData($order, $paymentModel, $transaction, $card);
//dd($formData);
} catch (\InvalidArgumentException $e) {
// örneğin kart bilgisi sağlanmadığında bu exception'i alırsınız.
dd($e);
} catch (\LogicException $e) {
// ödeme modeli veya işlem tipi desteklenmiyorsa bu exception'i alırsınız.
dd($e);
} catch (\Throwable $e) {
dd($e);
}
Expand Down
53 changes: 53 additions & 0 deletions examples/_common-codes/regular/custom_query.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

use Mews\Pos\PosInterface;

$templateTitle = 'Custom Query';

require '_config.php';
$transaction = PosInterface::TX_TYPE_CUSTOM_QUERY;

require '../../_templates/_header.php';

[$requestData, $apiUrl] = getCustomRequestData();

dump($requestData, $apiUrl);

/** @var \Symfony\Component\EventDispatcher\EventDispatcher $eventDispatcher */
$eventDispatcher->addListener(\Mews\Pos\Event\RequestDataPreparedEvent::class, function (\Mews\Pos\Event\RequestDataPreparedEvent $event) {
dump($event->getRequestData()); //bankaya gonderilecek veri:
//
// // Burda istek banka API'na gonderilmeden once gonderilecek veriyi degistirebilirsiniz.
// // Ornek:
// if ($event->getTxType() === PosInterface::TX_TYPE_CUSTOM_QUERY) {
// $data = $event->getRequestData();
// $data['abcd'] = '1234';
// $event->setRequestData($data);
// }
});


try {
/**
* requestData içinde API hesap bilgileri, hash verisi ve bazi sabit değerler
* eğer zaten bulunmuyorsa kütüphane otomatik ekler.
*/
$pos->customQuery(
$requestData,

// URL optional, bazı gateway'lerde zorunlu.
// Default olarak configdeki query_api ya da payment_api kullanılır.
$apiUrl
);
} catch (Exception $e) {
dd($e);
}

/**
* Bankadan dönen cevap array'e dönüştürülür,
* ancak diğer transaction'larda olduğu gibi mapping/normalization yapılmaz.
*/
$response = $pos->getResponse();

require '../../_templates/_simple_response_dump.php';
require '../../_templates/_footer.php';
7 changes: 6 additions & 1 deletion examples/_templates/_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</nav>
</header>
<div id="wrapper">
<div class="container" style="max-width: 640px;">
<div class="container" style="max-width: 720px;">
<h2 class="text-center"><?= $templateTitle; ?></h2>
<hr>
<?php if (isset($posClass)): ?>
Expand Down Expand Up @@ -133,6 +133,11 @@
<a class="nav-link <?= $transaction === \Mews\Pos\PosInterface::TX_TYPE_HISTORY ? 'active' : ''; ?>" href="<?= $bankTestsUrl ?>/regular/history.php">History</a>
</li>
<?php endif; ?>
<?php if ($posClass::isSupportedTransaction(\Mews\Pos\PosInterface::TX_TYPE_CUSTOM_QUERY, \Mews\Pos\PosInterface::MODEL_NON_SECURE)): ?>
<li class="nav-item">
<a class="nav-link <?= $transaction === \Mews\Pos\PosInterface::TX_TYPE_CUSTOM_QUERY ? 'active' : ''; ?>" href="<?= $bankTestsUrl ?>/regular/custom_query.php">Custom Query</a>
</li>
<?php endif; ?>
</ul>
</div>
</div>
Expand Down
27 changes: 27 additions & 0 deletions examples/akbankpos/regular/custom_query.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

require '../../_common-codes/regular/custom_query.php';

function getCustomRequestData(): array
{
return [
[
'txnCode' => '1020',
'order' => [
'orderTrackId' => 'ae15a6c8-467e-45de-b24c-b98821a42667',
],
'payByLink' => [
'linkTxnCode' => '3000',
'linkTransferType' => 'SMS',
'mobilePhoneNumber' => '5321234567',
],
'transaction' => [
'amount' => 1.00,
'currencyCode' => 949,
'motoInd' => 0,
'installCount' => 1,
],
],
null,
];
}
17 changes: 17 additions & 0 deletions examples/finansbank-payfor/regular/custom_query.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

require '../../_common-codes/regular/custom_query.php';

function getCustomRequestData(): array
{
return [
[
'SecureType' => 'Inquiry',
'TxnType' => 'ParaPuanInquiry',
'Pan' => '4155650100416111',
'Expiry' => '0125',
'Cvv2' => '123',
],
null,
];
}
30 changes: 30 additions & 0 deletions examples/garanti/regular/custom_query.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

require '../../_common-codes/regular/custom_query.php';

function getCustomRequestData(): array
{
return [
[
'Version' => 'v0.00',
'Customer' => [
'IPAddress' => '1.1.111.111',
'EmailAddress' => '[email protected]',
],
'Order' => [
'OrderID' => 'SISTD5A61F1682E745B28871872383ABBEB1',
'GroupID' => '',
'Description' => '',
],
'Transaction' => [
'Type' => 'bininq',
'Amount' => '1',
'BINInq' => [
'Group' => 'A',
'CardType' => 'A',
],
],
],
null,
];
}
13 changes: 13 additions & 0 deletions examples/interpos/regular/custom_query.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

require '../../_common-codes/regular/custom_query.php';

function getCustomRequestData(): array
{
return [
[
'abc' => 'abc',
],
null,
];
}
13 changes: 13 additions & 0 deletions examples/kuveytpos/regular/custom_query.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

require '../../_common-codes/regular/custom_query.php';

function getCustomRequestData(): array
{
return [
[
'abc' => 'abc',
],
null,
];
}
14 changes: 14 additions & 0 deletions examples/payflex-cp-v4/regular/custom_query.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

require '../../_common-codes/regular/custom_query.php';

function getCustomRequestData(): array
{
return [
[
'abc' => 'abc',
],
null,
];
}

14 changes: 14 additions & 0 deletions examples/payflex-mpi-v4/regular/custom_query.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

require '../../_common-codes/regular/custom_query.php';

function getCustomRequestData(): array
{
return [
[
'TransactionType' => 'CampaignSearch',
'TransactionId' => date('Ymd').strtoupper(substr(uniqid(sha1(time()), true), 0, 4)),
],
null,
];
}
18 changes: 18 additions & 0 deletions examples/payten/regular/custom_query.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

require '../../_common-codes/regular/custom_query.php';

function getCustomRequestData(): array
{
return [
[
'Type' => 'Query',
'Number' => '4242424242424242',
'Expires' => '10.2028',
'Extra' => [
'IMECECARDQUERY' => null,
],
],
null,
];
}
Loading

0 comments on commit 21629cb

Please sign in to comment.