-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #250 support for custom queries
- Loading branch information
mustapayev
committed
Nov 4, 2024
1 parent
e5afa63
commit f136422
Showing
79 changed files
with
2,574 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
]; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
require '../../_common-codes/regular/custom_query.php'; | ||
|
||
function getCustomRequestData(): array | ||
{ | ||
return [ | ||
[ | ||
'MACParams' => 'MerchantNo:TerminalNo:CardNo:Cvc2:ExpireDate', | ||
'CipheredData' => null, | ||
'DealerData' => null, | ||
'IsEncrypted' => 'N', | ||
'PaymentFacilitatorData' => null, | ||
'AdditionalInfoData' => null, | ||
'CardInformationData' => [ | ||
'CardHolderName' => 'deneme deneme', | ||
'CardNo' => '5400619360964581', | ||
'Cvc2' => '056', | ||
'ExpireDate' => '2001', | ||
], | ||
'IsMailOrder' => null, | ||
'IsRecurring' => null, | ||
'IsTDSecureMerchant' => 'Y', | ||
'PaymentInstrumentType' => 'CARD', | ||
'ThreeDSecureData' => null, | ||
], | ||
'https://epostest.albarakaturk.com.tr/ALBMerchantService/MerchantJSONAPI.svc/PointInquiry', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
require '../../_common-codes/regular/custom_query.php'; | ||
|
||
function getCustomRequestData(): array | ||
{ | ||
return [ | ||
[ | ||
'pointUsage' => [ | ||
'amount' => '250', | ||
'lpAmount' => '40', | ||
'ccno' => '4048090000000001', | ||
'currencyCode' => 'TL', | ||
'expDate' => '2411', | ||
'orderID' => 'PKPPislemleriNT000000001', | ||
], | ||
], | ||
null, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [ | ||
[ | ||
'bin' => 415956, | ||
], | ||
'https://prepentegrasyon.tosla.com/api/Payment/GetCommissionAndInstallmentInfo', | ||
]; | ||
} |
Oops, something went wrong.