From f136422335283ca7215d9f162ea91e8d10a09893 Mon Sep 17 00:00:00 2001 From: mustapayev Date: Mon, 4 Nov 2024 12:13:13 +0100 Subject: [PATCH] issue #250 support for custom queries --- README.md | 73 +++++--- docs/CHANGELOG.md | 11 ++ docs/CUSTOM-QUERY-EXAMPLE.md | 85 +++++++++ .../_common-codes/regular/custom_query.php | 53 ++++++ examples/_templates/_header.php | 7 +- examples/akbankpos/regular/custom_query.php | 27 +++ .../regular/custom_query.php | 17 ++ examples/garanti/regular/custom_query.php | 30 ++++ examples/interpos/regular/custom_query.php | 13 ++ examples/kuveytpos/regular/custom_query.php | 13 ++ .../payflex-cp-v4/regular/custom_query.php | 14 ++ .../payflex-mpi-v4/regular/custom_query.php | 14 ++ examples/payten/regular/custom_query.php | 18 ++ examples/posnet-v1/regular/custom_query.php | 29 +++ examples/posnet-ykb/regular/custom_query.php | 20 +++ examples/tosla/regular/custom_query.php | 13 ++ .../vakif-katilim/regular/custom_query.php | 39 ++++ src/Crypt/GarantiPosCrypt.php | 2 +- .../AkbankPosRequestDataMapper.php | 16 ++ .../EstPosRequestDataMapper.php | 10 ++ .../GarantiPosRequestDataMapper.php | 20 +++ .../InterPosRequestDataMapper.php | 10 ++ .../KuveytPosRequestDataMapper.php | 20 +++ .../PayFlexCPV4PosRequestDataMapper.php | 12 ++ .../PayFlexV4PosRequestDataMapper.php | 12 ++ .../PayForPosRequestDataMapper.php | 12 ++ .../PosNetRequestDataMapper.php | 15 ++ .../PosNetV1PosRequestDataMapper.php | 25 +++ .../RequestDataMapperInterface.php | 11 ++ .../ToslaPosRequestDataMapper.php | 17 ++ .../VakifKatilimPosRequestDataMapper.php | 19 ++ src/Gateways/AbstractGateway.php | 41 +++++ src/Gateways/AkbankPos.php | 1 + src/Gateways/EstPos.php | 1 + src/Gateways/GarantiPos.php | 1 + src/Gateways/InterPos.php | 1 + src/Gateways/KuveytPos.php | 5 +- src/Gateways/PayFlexCPV4Pos.php | 1 + src/Gateways/PayFlexV4Pos.php | 9 + src/Gateways/PayForPos.php | 1 + src/Gateways/PosNet.php | 1 + src/Gateways/PosNetV1Pos.php | 13 ++ src/Gateways/ToslaPos.php | 13 ++ src/Gateways/VakifKatilimPos.php | 13 ++ src/PosInterface.php | 21 +++ src/Serializer/KuveytPosSerializer.php | 1 + src/Serializer/PayFlexCPV4PosSerializer.php | 11 +- tests/Functional/AkbankPosTest.php | 39 ++++ tests/Functional/EstV3PosTest.php | 30 ++++ tests/Functional/GarantiPosTest.php | 42 +++++ tests/Functional/KuveytPosTest.php | 30 ++++ tests/Functional/PayForPosTest.php | 29 +++ tests/Functional/ToslaPosTest.php | 25 +++ tests/Unit/Crypt/GarantiPosCryptTest.php | 23 +++ .../AkbankPosRequestDataMapperTest.php | 114 ++++++++++++ .../EstPosRequestDataMapperTest.php | 63 ++++++- .../GarantiPosRequestDataMapperTest.php | 132 ++++++++++++++ .../InterPosRequestDataMapperTest.php | 42 +++++ .../KuveytPosRequestDataMapperTest.php | 63 ++++++- .../PayFlexCPV4PosRequestDataMapperTest.php | 40 +++++ .../PayFlexV4PosRequestDataMapperTest.php | 42 +++++ .../PayForPosRequestDataMapperTest.php | 61 +++++++ .../PosNetRequestDataMapperTest.php | 67 +++++++ .../PosNetV1PosRequestDataMapperTest.php | 118 ++++++++++++ .../ToslaPosRequestDataMapperTest.php | 58 ++++++ .../VakifKatilimPosRequestDataMapperTest.php | 170 +++++++++++++++++- tests/Unit/Gateways/AkbankPosTest.php | 50 ++++++ tests/Unit/Gateways/EstPosTest.php | 50 ++++++ tests/Unit/Gateways/GarantiPosTest.php | 50 ++++++ tests/Unit/Gateways/InterPosTest.php | 50 ++++++ tests/Unit/Gateways/PayFlexCPV4PosTest.php | 50 ++++++ tests/Unit/Gateways/PayFlexV4PosTest.php | 50 ++++++ tests/Unit/Gateways/PayForTest.php | 50 ++++++ tests/Unit/Gateways/PosNetTest.php | 50 ++++++ tests/Unit/Gateways/PosNetV1PosTest.php | 51 ++++++ tests/Unit/Gateways/ToslaPosTest.php | 51 ++++++ tests/Unit/Gateways/VakifKatilimTest.php | 51 ++++++ .../Serializer/KuveytPosSerializerTest.php | 11 ++ .../PayFlexCPV4PosSerializerTest.php | 82 +++++---- 79 files changed, 2574 insertions(+), 71 deletions(-) create mode 100644 docs/CUSTOM-QUERY-EXAMPLE.md create mode 100644 examples/_common-codes/regular/custom_query.php create mode 100644 examples/akbankpos/regular/custom_query.php create mode 100644 examples/finansbank-payfor/regular/custom_query.php create mode 100644 examples/garanti/regular/custom_query.php create mode 100644 examples/interpos/regular/custom_query.php create mode 100644 examples/kuveytpos/regular/custom_query.php create mode 100644 examples/payflex-cp-v4/regular/custom_query.php create mode 100644 examples/payflex-mpi-v4/regular/custom_query.php create mode 100644 examples/payten/regular/custom_query.php create mode 100644 examples/posnet-v1/regular/custom_query.php create mode 100644 examples/posnet-ykb/regular/custom_query.php create mode 100644 examples/tosla/regular/custom_query.php create mode 100644 examples/vakif-katilim/regular/custom_query.php diff --git a/README.md b/README.md index 409fc9e1..caf299bd 100644 --- a/README.md +++ b/README.md @@ -10,21 +10,21 @@ sistemlerinin kullanılabilmesidir. ### Deskteklenen Payment Gateway'ler / Bankalar: -| Gateway | Desktekleyen
bankalar | Desteklenen
Ödeme Tipleri | Desteklenen Sorgular | -|------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------| -| Tosla (AKÖde) | ? | NonSecure
3DPay
3DHost | İptal
İade
Durum sorgulama
Sipariş Tarihçesini sorgulama | -| AkbankPos
(Akbankın yeni altyapısı) | Akbank | NonSecure
3DSecur
3DPay
3DHost
Tekrarlanan Ödeme | İptal
İade
Sipariş Tarihçesini sorgulama
Geçmiş İşlemleri sorgulama | -| EST POS
(Asseco/Payten)
_deprecated_
| Akbank
TEB
İşbank
Şekerbank
Halkbank
Finansbank
Ziraat | NonSecure
3DSecure
3DPay
3DHost
3DPayHost
Tekrarlanan Ödeme | İptal
İade
Durum sorgulama
Sipariş Tarihçesini sorgulama | -| EST V3 POS

EstPos altyapının
daha güvenli
(sha512) hash
algoritmasıyla
uygulaması.
| -----"----- | -----"----- | -----"----- | -| PayFlex MPI VPOS V4 | Ziraat
Vakıfbank VPOS 7/24
İşbank | NonSecure
3DSecure
Tekrarlanan Ödeme | İptal
İade
Durum sorgulama | -| PayFlex
Common Payment V4
(Ortak Ödeme) | Ziraat
Vakıfbank
İşbank | NonSecure
3DPay
3DHost | İptal
İade | -| Garanti Virtual POS | Garanti | NonSecure
3DSecure
3DPay
3DHost
Tekrarlanan Ödeme | İptal
İade
Durum sorgulama
Sipariş Tarihçesini sorgulama
Geçmiş İşlemleri sorgulama | -| PosNet | YapıKredi | NonSecure
3DSecure
| İptal
İade
Durum sorgulama | -| PosNetV1
(JSON API) | Albaraka Türk | NonSecure
3DSecure | İptal
İade
Durum sorgulama | -| PayFor | Finansbank
Enpara | NonSecure
3DSecure
3DPay
3DHost | İptal
İade
Durum sorgulama
Sipariş Tarihçesini sorgulama
Geçmiş İşlemleri sorgulama | -| InterPOS | Deniz bank | NonSecure
3DSecure
3DPay
3DHost | İptal
İade
Durum sorgulama | -| Kuveyt POS TDV2.0.0 | Kuveyt Türk | NonSecure
3DSecure | İptal
İade
Durum sorgulama
(SOAP API) | -| VakifKatilimPos | Vakıf Katılım | NonSecure (test edilmesi gerekiyor)
3DSecure
3DHost (test edilmesi gerekiyor) | İptal
İade
Durum sorgulama
Sipariş Tarihçesini sorgulama
Geçmiş İşlemleri sorgulama | +| Gateway | Desktekleyen
bankalar | Desteklenen
Ödeme Tipleri | Desteklenen Sorgular | +|------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------| +| Tosla (AKÖde) | ? | NonSecure
3DPay
3DHost | İptal
İade
Durum sorgulama
Sipariş Tarihçesini sorgulama
Özel Sorgu | +| AkbankPos
(Akbankın yeni altyapısı) | Akbank | NonSecure
3DSecur
3DPay
3DHost
Tekrarlanan Ödeme | İptal
İade
Sipariş Tarihçesini sorgulama
Geçmiş İşlemleri sorgulama
Özel Sorgu | +| EST POS
(Asseco/Payten)
_deprecated_
| Akbank
TEB
İşbank
Şekerbank
Halkbank
Finansbank
Ziraat | NonSecure
3DSecure
3DPay
3DHost
3DPayHost
Tekrarlanan Ödeme | İptal
İade
Durum sorgulama
Sipariş Tarihçesini sorgulama
Özel Sorgu | +| EST V3 POS

EstPos altyapının
daha güvenli
(sha512) hash
algoritmasıyla
uygulaması.
| -----"----- | -----"----- | -----"----- | +| PayFlex MPI VPOS V4 | Ziraat
Vakıfbank VPOS 7/24
İşbank | NonSecure
3DSecure
Tekrarlanan Ödeme | İptal
İade
Durum sorgulama
Özel Sorgu | +| PayFlex
Common Payment V4
(Ortak Ödeme) | Ziraat
Vakıfbank
İşbank | NonSecure
3DPay
3DHost | İptal
İade
Özel Sorgu | +| Garanti Virtual POS | Garanti | NonSecure
3DSecure
3DPay
3DHost
Tekrarlanan Ödeme | İptal
İade
Durum sorgulama
Sipariş Tarihçesini sorgulama
Geçmiş İşlemleri sorgulama
Özel Sorgu | +| PosNet | YapıKredi | NonSecure
3DSecure
| İptal
İade
Durum sorgulama
Özel Sorgu | +| PosNetV1
(JSON API) | Albaraka Türk | NonSecure
3DSecure | İptal
İade
Durum sorgulama
Özel Sorgu | +| PayFor | Finansbank
Enpara | NonSecure
3DSecure
3DPay
3DHost | İptal
İade
Durum sorgulama
Sipariş Tarihçesini sorgulama
Geçmiş İşlemleri sorgulama
Özel Sorgu | +| InterPOS | Deniz bank | NonSecure
3DSecure
3DPay
3DHost | İptal
İade
Durum sorgulama
Özel Sorgu | +| Kuveyt POS TDV2.0.0 | Kuveyt Türk | NonSecure
3DSecure | İptal
İade
Durum sorgulama
(SOAP API)
Özel Sorgu | +| VakifKatilimPos | Vakıf Katılım | NonSecure (test edilmesi gerekiyor)
3DSecure
3DHost (test edilmesi gerekiyor) | İptal
İade
Durum sorgulama
Sipariş Tarihçesini sorgulama
Geçmiş İşlemleri sorgulama
Özel Sorgu | ### Ana başlıklar @@ -41,6 +41,7 @@ sistemlerinin kullanılabilmesidir. - [Ödeme İptal](./docs/CANCEL-EXAMPLE.md) - [Ödeme İade](./docs/REFUND-EXAMPLE.md) - [Ödeme Durum Sorgulama](./docs/STATUS-EXAMPLE.md) + - [Özel Sorgular](./docs/CUSTOM-QUERY-EXAMPLE.md) - [Popup Windowda veya Iframe icinde odeme yapma](#popup-windowda-veya-iframe-icinde-odeme-yapma) - [Troubleshoots](#troubleshoots) @@ -57,8 +58,10 @@ sistemlerinin kullanılabilmesidir. - Sipariş Tarihçesini sorgulama sorgulama (`PosInterface::TX_TYPE_ORDER_HISTORY`) - Geçmiş işlemleri sorgulama (`PosInterface::TX_TYPE_HISTORY`) -- Sipariş/Para iadesi yapma (`PosInterface::TX_TYPE_REFUND`) +- Sipariş/Para iadesi yapma (`PosInterface::TX_TYPE_REFUND` + ve `PosInterface::TX_TYPE_PARTIAL_REFUND`) - Sipariş iptal etme (`PosInterface::TX_TYPE_CANCEL`) +- Özel Sorgular (`PosInterface::TX_TYPE_CUSTOM_QUERY`) - API istek verilerinin gateway API'na gönderilmeden önce değiştirebilme - Farklı Para birimler ile ödeme desteği - Tekrarlanan (Recurring) ödeme talimatları @@ -97,8 +100,13 @@ Son yapılan değişiklikler için [`CHANGELOG`](./docs/CHANGELOG.md). ### Kurulum #### Frameworks -- **Symfony** kurulum için [mews/pos-bundle](https://github.com/mewebstudio/PosBundle) kullanabilirsiniz. -- **Laravel** kurulum için [mews/laravel-pos](https://github.com/mewebstudio/laravel-pos) kullanabilirsiniz. + +- **Symfony** kurulum + için [mews/pos-bundle](https://github.com/mewebstudio/PosBundle) + kullanabilirsiniz. +- **Laravel** kurulum + için [mews/laravel-pos](https://github.com/mewebstudio/laravel-pos) + kullanabilirsiniz. #### Basic kurulum @@ -121,17 +129,23 @@ kütüphaneler: https://packagist.org/providers/psr/http-client-implementation Sonra kendi projenizin dizinindeyken alttaki komutu çalıştırarak ayarlar dosyasını projenize kopyalayınız. + ```sh $ cp ./vendor/mews/pos/config/pos_production.php ./pos_prod_ayarlar.php ``` + Test ortamda geliştirecekseniz test ayarları da kopyalanız: + ```sh $ cp ./vendor/mews/pos/config/pos_test.php ./pos_test_ayarlar.php ``` + Kopyaladıktan sonra ayarlardaki kullanmayacağınız banka ayarları silebilirsiniz. -Bundan sonra `Pos` nesnemizi, yeni ayarlarımıza göre oluşturup kullanmamız gerekir. +Bundan sonra `Pos` nesnemizi, yeni ayarlarımıza göre oluşturup kullanmamız +gerekir. Örnek: + ```php $yeniAyarlar = require __DIR__ . '/pos_prod_ayarlar.php'; // veya test ortamı için $yeniAyarlar = require __DIR__ . '/pos_test_ayarlar.php'; @@ -139,13 +153,15 @@ $yeniAyarlar = require __DIR__ . '/pos_prod_ayarlar.php'; $pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account, $yeniAyarlar, $eventDispatcher); ``` - -_Kütüphanede yer alan `pos_production.php` ve `pos_test.php` ayar dosyaları projenizde direk kullanmayınız! +_Kütüphanede yer alan `pos_production.php` ve `pos_test.php` ayar dosyaları +projenizde direk kullanmayınız! Yukarda belirtildiği gibi kopyalayarak kullanmanız tavsiye edilir._ ### Farkli Banka Sanal Poslarini Eklemek -Projenize kopyaladığınız `./pos_prod_ayarlar.php` dosyasına farklı banka ayarı eklemek için alttaki örneği kullanabilirsiniz. +Projenize kopyaladığınız `./pos_prod_ayarlar.php` dosyasına farklı banka ayarı +eklemek için alttaki örneği kullanabilirsiniz. + ```php `form.php`), @@ -191,7 +207,8 @@ Fakat - birden fazla bank seçeneği olunca veya müşteri banka degiştirmek istediğinde kart bilgi formunu ona göre güncellemeniz gerekecek. -- üstelik YKB POSNet, Vakıf Katılım ve VakıfBank POS kart bilgilerini website sunucusu +- üstelik YKB POSNet, Vakıf Katılım ve VakıfBank POS kart bilgilerini website + sunucusu tarafından POST edilmesini gerektiriyor. ### Popup Windowda veya Iframe icinde odeme yapma @@ -199,7 +216,9 @@ Fakat Müşteriyi banka sayfasına redirect etmeden **iframe** üzerinden veya **popup window** üzerinden ödeme akışı -[examples'da](./examples/) ve [/docs'da](./docs/THREED-SECURE-AND-PAY-PAYMENT-IN-MODALBOX-EXAMPLE.md) 3D ödeme ile örnek PHP ve JS kodlar yer almaktadır. +[examples'da](./examples/) +ve [/docs'da](./docs/THREED-SECURE-AND-PAY-PAYMENT-IN-MODALBOX-EXAMPLE.md) 3D +ödeme ile örnek PHP ve JS kodlar yer almaktadır. #### Dikkat edilmesi gerekenler @@ -256,7 +275,9 @@ $pos = \Mews\Pos\Factory\PosFactory::createPosGateway( ## Genel Kultur -Ödeme modelleri hakkında bilgi edinmek istiyorsanız [bu makaleyi](https://medium.com/p/fa5cd016999c) inceleyebilirsiniz. +Ödeme modelleri hakkında bilgi edinmek +istiyorsanız [bu makaleyi](https://medium.com/p/fa5cd016999c) +inceleyebilirsiniz. ### Otorizasyon, Ön Otorizasyon, Ön Provizyon Kapama İşlemler arasındaki farklar diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3dce2467..ab294ce8 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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 diff --git a/docs/CUSTOM-QUERY-EXAMPLE.md b/docs/CUSTOM-QUERY-EXAMPLE.md new file mode 100644 index 00000000..fd54aa9a --- /dev/null +++ b/docs/CUSTOM-QUERY-EXAMPLE.md @@ -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 +setTestMode(true); +} catch (\Mews\Pos\Exceptions\BankNotFoundException | \Mews\Pos\Exceptions\BankClassNullException $e) { + var_dump($e)); + exit; +} +``` + +**custom_query.php** +```php + 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); +``` diff --git a/examples/_common-codes/regular/custom_query.php b/examples/_common-codes/regular/custom_query.php new file mode 100644 index 00000000..b2c72725 --- /dev/null +++ b/examples/_common-codes/regular/custom_query.php @@ -0,0 +1,53 @@ +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'; diff --git a/examples/_templates/_header.php b/examples/_templates/_header.php index 1f986eb0..cd5fb980 100644 --- a/examples/_templates/_header.php +++ b/examples/_templates/_header.php @@ -74,7 +74,7 @@
-
+


@@ -133,6 +133,11 @@ History + + +
diff --git a/examples/akbankpos/regular/custom_query.php b/examples/akbankpos/regular/custom_query.php new file mode 100644 index 00000000..0f504dac --- /dev/null +++ b/examples/akbankpos/regular/custom_query.php @@ -0,0 +1,27 @@ + '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, + ]; +} diff --git a/examples/finansbank-payfor/regular/custom_query.php b/examples/finansbank-payfor/regular/custom_query.php new file mode 100644 index 00000000..ac0feb94 --- /dev/null +++ b/examples/finansbank-payfor/regular/custom_query.php @@ -0,0 +1,17 @@ + 'Inquiry', + 'TxnType' => 'ParaPuanInquiry', + 'Pan' => '4155650100416111', + 'Expiry' => '0125', + 'Cvv2' => '123', + ], + null, + ]; +} diff --git a/examples/garanti/regular/custom_query.php b/examples/garanti/regular/custom_query.php new file mode 100644 index 00000000..eab803f2 --- /dev/null +++ b/examples/garanti/regular/custom_query.php @@ -0,0 +1,30 @@ + 'v0.00', + 'Customer' => [ + 'IPAddress' => '1.1.111.111', + 'EmailAddress' => 'Cem@cem.com', + ], + 'Order' => [ + 'OrderID' => 'SISTD5A61F1682E745B28871872383ABBEB1', + 'GroupID' => '', + 'Description' => '', + ], + 'Transaction' => [ + 'Type' => 'bininq', + 'Amount' => '1', + 'BINInq' => [ + 'Group' => 'A', + 'CardType' => 'A', + ], + ], + ], + null, + ]; +} diff --git a/examples/interpos/regular/custom_query.php b/examples/interpos/regular/custom_query.php new file mode 100644 index 00000000..66780660 --- /dev/null +++ b/examples/interpos/regular/custom_query.php @@ -0,0 +1,13 @@ + 'abc', + ], + null, + ]; +} diff --git a/examples/kuveytpos/regular/custom_query.php b/examples/kuveytpos/regular/custom_query.php new file mode 100644 index 00000000..66780660 --- /dev/null +++ b/examples/kuveytpos/regular/custom_query.php @@ -0,0 +1,13 @@ + 'abc', + ], + null, + ]; +} diff --git a/examples/payflex-cp-v4/regular/custom_query.php b/examples/payflex-cp-v4/regular/custom_query.php new file mode 100644 index 00000000..7eeb5f65 --- /dev/null +++ b/examples/payflex-cp-v4/regular/custom_query.php @@ -0,0 +1,14 @@ + 'abc', + ], + null, + ]; +} + diff --git a/examples/payflex-mpi-v4/regular/custom_query.php b/examples/payflex-mpi-v4/regular/custom_query.php new file mode 100644 index 00000000..05987905 --- /dev/null +++ b/examples/payflex-mpi-v4/regular/custom_query.php @@ -0,0 +1,14 @@ + 'CampaignSearch', + 'TransactionId' => date('Ymd').strtoupper(substr(uniqid(sha1(time()), true), 0, 4)), + ], + null, + ]; +} diff --git a/examples/payten/regular/custom_query.php b/examples/payten/regular/custom_query.php new file mode 100644 index 00000000..cd19ab61 --- /dev/null +++ b/examples/payten/regular/custom_query.php @@ -0,0 +1,18 @@ + 'Query', + 'Number' => '4242424242424242', + 'Expires' => '10.2028', + 'Extra' => [ + 'IMECECARDQUERY' => null, + ], + ], + null, + ]; +} diff --git a/examples/posnet-v1/regular/custom_query.php b/examples/posnet-v1/regular/custom_query.php new file mode 100644 index 00000000..d417cf24 --- /dev/null +++ b/examples/posnet-v1/regular/custom_query.php @@ -0,0 +1,29 @@ + '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', + ]; +} diff --git a/examples/posnet-ykb/regular/custom_query.php b/examples/posnet-ykb/regular/custom_query.php new file mode 100644 index 00000000..ffd5a94e --- /dev/null +++ b/examples/posnet-ykb/regular/custom_query.php @@ -0,0 +1,20 @@ + [ + 'amount' => '250', + 'lpAmount' => '40', + 'ccno' => '4048090000000001', + 'currencyCode' => 'TL', + 'expDate' => '2411', + 'orderID' => 'PKPPislemleriNT000000001', + ], + ], + null, + ]; +} diff --git a/examples/tosla/regular/custom_query.php b/examples/tosla/regular/custom_query.php new file mode 100644 index 00000000..8d994980 --- /dev/null +++ b/examples/tosla/regular/custom_query.php @@ -0,0 +1,13 @@ + 415956, + ], + 'https://prepentegrasyon.tosla.com/api/Payment/GetCommissionAndInstallmentInfo', + ]; +} diff --git a/examples/vakif-katilim/regular/custom_query.php b/examples/vakif-katilim/regular/custom_query.php new file mode 100644 index 00000000..cbfbe303 --- /dev/null +++ b/examples/vakif-katilim/regular/custom_query.php @@ -0,0 +1,39 @@ + '2126497214', + 'InstallmentCount' => '0', + 'Amount' => '120', + 'DisplayAmount' => '120', + 'FECAmount' => '0', + 'FECCurrencyCode' => '0949', + 'Addresses' => [ + 'VPosAddressContract' => [ + 'Type' => '1', + 'Name' => 'Mahmut Sami YAZAR', + 'PhoneNumber' => '324234234234', + 'OrderId' => '0', + 'AddressId' => '12', + 'Email' => 'mahmutsamiyazar@hotmail.com', + ], + ], + 'CardNumber' => '5353550000958906', + 'CardExpireDateYear' => '23', + 'CardExpireDateMonth' => '01', + 'CardCVV2' => '741', + 'CardHolderName' => 'Hasan Karacan', + 'DebtId' => '0', + 'SurchargeAmount' => '0', + 'SGKDebtAmount' => '0', + 'InstallmentMaturityCommisionFlag' => '0', + 'TransactionSecurity' => '1', + 'CardGuid' => 'AA9588EF350C480FBE5CAD40A463AF00', + ], + 'https://boa.vakifkatilim.com.tr/VirtualPOS.Gateway/Home/MailOrderSale', + ]; +} diff --git a/src/Crypt/GarantiPosCrypt.php b/src/Crypt/GarantiPosCrypt.php index dd05f99e..39c6aba5 100644 --- a/src/Crypt/GarantiPosCrypt.php +++ b/src/Crypt/GarantiPosCrypt.php @@ -74,7 +74,7 @@ public function createHash(AbstractPosAccount $posAccount, array $requestData): $posAccount->getTerminalId(), $requestData['Card']['Number'] ?? null, $requestData['Transaction']['Amount'], - $requestData['Transaction']['CurrencyCode'], + $requestData['Transaction']['CurrencyCode'] ?? null, $this->createSecurityData($posAccount, $requestData['Transaction']['Type']), ]; diff --git a/src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php index f7820999..6a8ae038 100644 --- a/src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php @@ -410,6 +410,22 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s return $data; } + /** + * @param AkbankPosAccount $posAccount + * + * @inheritDoc + */ + public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array + { + return $requestData + + $this->getRequestAccountData($posAccount) + + [ + 'version' => self::API_VERSION, + 'requestDateTime' => $requestData['requestDateTime'] ?? $this->formatRequestDateTime($this->createDateTime()), + 'randomNumber' => $this->crypt->generateRandomString(), + ]; + } + /** * 0 => 1 * 1 => 1 diff --git a/src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php index cbb5cce1..6266d1a1 100644 --- a/src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php @@ -267,6 +267,16 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s return $data; } + /** + * @inheritDoc + */ + public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array + { + $requestData += $this->getRequestAccountData($posAccount); + + return $requestData; + } + /** * @phpstan-param PosInterface::MODEL_3D_* $paymentModel * @phpstan-param PosInterface::TX_TYPE_PAY_AUTH|PosInterface::TX_TYPE_PAY_PRE_AUTH $txType diff --git a/src/DataMapper/RequestDataMapper/GarantiPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/GarantiPosRequestDataMapper.php index 21c333ba..dba624e0 100644 --- a/src/DataMapper/RequestDataMapper/GarantiPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/GarantiPosRequestDataMapper.php @@ -419,6 +419,26 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s ]; } + /** + * @param GarantiPosAccount $posAccount + * + * @inheritDoc + */ + public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array + { + $requestData += [ + 'Mode' => $this->getMode(), + 'Version' => self::API_VERSION, + 'Terminal' => $this->getTerminalData($posAccount), + ]; + + if (!isset($requestData['Terminal']['HashData']) || '' === $requestData['Terminal']['HashData']) { + $requestData['Terminal']['HashData'] = $this->crypt->createHash($posAccount, $requestData); + } + + return $requestData; + } + /** * 0 => '' * 1 => '' diff --git a/src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php index fa7219ba..cc48b640 100644 --- a/src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php @@ -249,6 +249,16 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s ]; } + /** + * @inheritDoc + */ + public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array + { + $requestData += $this->getRequestAccountData($posAccount); + + return $requestData; + } + /** * 0 => '' * 1 => '' diff --git a/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php index 62a52c2d..f3319ea4 100644 --- a/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php @@ -353,6 +353,26 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o return $result; } + /** + * @param KuveytPosAccount $posAccount + * + * @inheritDoc + */ + public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array + { + $requestData += [ + 'VPosMessage' => $this->getRequestAccountData($posAccount) + [ + 'APIVersion' => self::API_VERSION, + ], + ]; + + if (!isset($requestData['VPosMessage']['HashData'])) { + $requestData['VPosMessage']['HashData'] = $this->crypt->createHash($posAccount, $requestData['VPosMessage']); + } + + return $requestData; + } + /** * {@inheritDoc} * diff --git a/src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php index e9c1a9b4..81d9db6c 100644 --- a/src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php @@ -243,6 +243,18 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o ]; } + /** + * @param PayFlexAccount $posAccount + * + * @inheritDoc + */ + public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array + { + $requestData += $this->getRequestAccountData($posAccount); + + return $requestData; + } + /** * {@inheritDoc} */ diff --git a/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php index ea7eea68..b99139f8 100644 --- a/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php @@ -248,6 +248,18 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o ]; } + /** + * @param PayFlexAccount $posAccount + * + * @inheritDoc + */ + public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array + { + $requestData += $this->getRequestAccountData($posAccount); + + return $requestData; + } + /** * {@inheritDoc} */ diff --git a/src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php index 7a03c07d..159368a1 100644 --- a/src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php @@ -209,6 +209,18 @@ public function createHistoryRequestData(AbstractPosAccount $posAccount, array $ return $this->getRequestAccountData($posAccount) + $requestData; } + /** + * @inheritDoc + */ + public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array + { + $requestData += $this->getRequestAccountData($posAccount) + [ + 'MbrId' => self::MBR_ID, + ]; + + return $requestData; + } + /** * {@inheritDoc} */ diff --git a/src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php index d2d5a711..8235a72d 100644 --- a/src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php @@ -347,6 +347,21 @@ public function create3DResolveMerchantRequestData(AbstractPosAccount $posAccoun ]; } + /** + * @param PosNetAccount $posAccount + * + * @inheritDoc + */ + public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array + { + $requestData += [ + 'mid' => $posAccount->getClientId(), + 'tid' => $posAccount->getTerminalId(), + ]; + + return $requestData; + } + /** * Get PrefixedOrderId * To check the status of an order or cancel/refund order Yapikredi diff --git a/src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php index a06d65b7..38e05907 100644 --- a/src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php @@ -321,6 +321,31 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o return $requestData; } + /** + * @param PosNetAccount $posAccount + * + * @inheritDoc + */ + public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array + { + $requestData += [ + 'ApiType' => 'JSON', + 'ApiVersion' => self::API_VERSION, + 'MerchantNo' => $posAccount->getClientId(), + 'TerminalNo' => $posAccount->getTerminalId(), + ]; + + if (!isset($requestData['MAC'])) { + if (null === $posAccount->getStoreKey()) { + throw new \LogicException('Account storeKey eksik!'); + } + + $requestData['MAC'] = $this->crypt->hashFromParams($posAccount->getStoreKey(), $requestData, 'MACParams', ':'); + } + + return $requestData; + } + /** * {@inheritDoc} */ diff --git a/src/DataMapper/RequestDataMapper/RequestDataMapperInterface.php b/src/DataMapper/RequestDataMapper/RequestDataMapperInterface.php index 9fe2a730..b0573d39 100644 --- a/src/DataMapper/RequestDataMapper/RequestDataMapperInterface.php +++ b/src/DataMapper/RequestDataMapper/RequestDataMapperInterface.php @@ -166,4 +166,15 @@ public function createOrderHistoryRequestData(AbstractPosAccount $posAccount, ar * @throws UnsupportedTransactionTypeException */ public function createHistoryRequestData(AbstractPosAccount $posAccount, array $data = []): array; + + + /** + * Adds account information, constant values, calculated hash into $requestData if it is not already set. + * + * @param AbstractPosAccount $posAccount + * @param array $requestData user generated request data + * + * @return array + */ + public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array; } diff --git a/src/DataMapper/RequestDataMapper/ToslaPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/ToslaPosRequestDataMapper.php index 3fcddaae..6a4f3344 100644 --- a/src/DataMapper/RequestDataMapper/ToslaPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/ToslaPosRequestDataMapper.php @@ -183,6 +183,23 @@ public function createOrderHistoryRequestData(AbstractPosAccount $posAccount, ar return $this->getRequestAccountData($posAccount) + $requestData; } + /** + * @inheritDoc + */ + public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array + { + $requestData += $this->getRequestAccountData($posAccount) + [ + 'rnd' => $this->crypt->generateRandomString(), + 'timeSpan' => $this->newTimeSpan(), + ]; + + if (!isset($requestData['hash'])) { + $requestData['hash'] = $this->crypt->createHash($posAccount, $requestData); + } + + return $requestData; + } + /** * {@inheritDoc} */ diff --git a/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php index 1355302e..9fa22c26 100644 --- a/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php @@ -238,6 +238,25 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o return $result; } + /** + * @param KuveytPosAccount $posAccount + * + * @inheritDoc + */ + public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array + { + $requestData += $this->getRequestAccountData($posAccount) + [ + 'APIVersion' => self::API_VERSION, + 'HashPassword' => $this->crypt->hashString($posAccount->getStoreKey() ?? ''), + ]; + + if (!isset($requestData['HashData'])) { + $requestData['HashData'] = $this->crypt->createHash($posAccount, $requestData); + } + + return $requestData; + } + /** * {@inheritDoc} * diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index 4fd2b332..c5427ed7 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -519,6 +519,47 @@ public function orderHistory(array $order): PosInterface return $this; } + /** + * @inheritDoc + */ + public function customQuery(array $requestData, string $apiUrl = null): PosInterface + { + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + $updatedRequestData = $this->requestDataMapper->createCustomQueryRequestData($this->account, $requestData); + + $event = new RequestDataPreparedEvent( + $updatedRequestData, + $this->account->getBank(), + $txType, + \get_class($this), + $requestData, + PosInterface::MODEL_NON_SECURE + ); + + /** @var RequestDataPreparedEvent $event */ + $event = $this->eventDispatcher->dispatch($event); + if ($updatedRequestData !== $event->getRequestData()) { + $this->logger->debug('Request data is changed via listeners', [ + 'txType' => $event->getTxType(), + 'bank' => $event->getBank(), + 'initialData' => $requestData, + 'updatedData' => $event->getRequestData(), + ]); + $updatedRequestData = $event->getRequestData(); + } + + $data = $this->serializer->encode($updatedRequestData, $txType); + $apiUrl = $apiUrl ?? $this->getQueryAPIUrl($txType); + $this->response = $this->send( + $data, + $txType, + PosInterface::MODEL_NON_SECURE, + $apiUrl + ); + + return $this; + } + /** * @param bool $testMode * diff --git a/src/Gateways/AkbankPos.php b/src/Gateways/AkbankPos.php index a1797400..26c783b3 100644 --- a/src/Gateways/AkbankPos.php +++ b/src/Gateways/AkbankPos.php @@ -41,6 +41,7 @@ class AkbankPos extends AbstractGateway PosInterface::TX_TYPE_REFUND_PARTIAL => true, PosInterface::TX_TYPE_ORDER_HISTORY => true, PosInterface::TX_TYPE_HISTORY => true, + PosInterface::TX_TYPE_CUSTOM_QUERY => true, ]; /** diff --git a/src/Gateways/EstPos.php b/src/Gateways/EstPos.php index d70723f7..d61cb387 100644 --- a/src/Gateways/EstPos.php +++ b/src/Gateways/EstPos.php @@ -44,6 +44,7 @@ class EstPos extends AbstractGateway PosInterface::TX_TYPE_REFUND => true, PosInterface::TX_TYPE_REFUND_PARTIAL => true, PosInterface::TX_TYPE_ORDER_HISTORY => true, + PosInterface::TX_TYPE_CUSTOM_QUERY => true, PosInterface::TX_TYPE_HISTORY => false, ]; diff --git a/src/Gateways/GarantiPos.php b/src/Gateways/GarantiPos.php index 0ca3d684..2d1766d6 100644 --- a/src/Gateways/GarantiPos.php +++ b/src/Gateways/GarantiPos.php @@ -49,6 +49,7 @@ class GarantiPos extends AbstractGateway PosInterface::TX_TYPE_REFUND_PARTIAL => true, PosInterface::TX_TYPE_ORDER_HISTORY => true, PosInterface::TX_TYPE_HISTORY => true, + PosInterface::TX_TYPE_CUSTOM_QUERY => true, ]; diff --git a/src/Gateways/InterPos.php b/src/Gateways/InterPos.php index 9277dfb8..625d86e7 100644 --- a/src/Gateways/InterPos.php +++ b/src/Gateways/InterPos.php @@ -53,6 +53,7 @@ class InterPos extends AbstractGateway PosInterface::TX_TYPE_REFUND_PARTIAL => true, PosInterface::TX_TYPE_HISTORY => false, PosInterface::TX_TYPE_ORDER_HISTORY => false, + PosInterface::TX_TYPE_CUSTOM_QUERY => true, ]; /** @return InterPosAccount */ diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php index 5f16af41..df5ea019 100644 --- a/src/Gateways/KuveytPos.php +++ b/src/Gateways/KuveytPos.php @@ -55,6 +55,7 @@ class KuveytPos extends AbstractGateway PosInterface::TX_TYPE_REFUND_PARTIAL => true, PosInterface::TX_TYPE_HISTORY => false, PosInterface::TX_TYPE_ORDER_HISTORY => false, + PosInterface::TX_TYPE_CUSTOM_QUERY => true, ]; /** @return KuveytPosAccount */ @@ -78,6 +79,7 @@ public function getApiURL(string $txType = null, string $paymentModel = null, ?s PosInterface::TX_TYPE_REFUND_PARTIAL, PosInterface::TX_TYPE_STATUS, PosInterface::TX_TYPE_CANCEL, + PosInterface::TX_TYPE_CUSTOM_QUERY, ], true )) { @@ -220,6 +222,7 @@ protected function send($contents, string $txType, string $paymentModel, string PosInterface::TX_TYPE_REFUND_PARTIAL, PosInterface::TX_TYPE_STATUS, PosInterface::TX_TYPE_CANCEL, + PosInterface::TX_TYPE_CUSTOM_QUERY, ], true)) { if (!\is_array($contents)) { throw new InvalidArgumentException(\sprintf('Invalid data type provided for %s transaction!', $txType)); @@ -242,7 +245,7 @@ protected function send($contents, string $txType, string $paymentModel, string } /** - * @phpstan-param PosInterface::TX_TYPE_STATUS|PosInterface::TX_TYPE_REFUND|PosInterface::TX_TYPE_REFUND_PARTIAL|PosInterface::TX_TYPE_CANCEL $txType + * @phpstan-param PosInterface::TX_TYPE_STATUS|PosInterface::TX_TYPE_REFUND|PosInterface::TX_TYPE_REFUND_PARTIAL|PosInterface::TX_TYPE_CANCEL|PosInterface::TX_TYPE_CUSTOM_QUERY $txType * * @param array $contents * @param string $txType diff --git a/src/Gateways/PayFlexCPV4Pos.php b/src/Gateways/PayFlexCPV4Pos.php index 74361962..0d1e896d 100644 --- a/src/Gateways/PayFlexCPV4Pos.php +++ b/src/Gateways/PayFlexCPV4Pos.php @@ -52,6 +52,7 @@ class PayFlexCPV4Pos extends AbstractGateway PosInterface::TX_TYPE_REFUND_PARTIAL => true, PosInterface::TX_TYPE_HISTORY => false, PosInterface::TX_TYPE_ORDER_HISTORY => false, + PosInterface::TX_TYPE_CUSTOM_QUERY => true, ]; /** @return PayFlexAccount */ diff --git a/src/Gateways/PayFlexV4Pos.php b/src/Gateways/PayFlexV4Pos.php index 765582af..1b0ec579 100644 --- a/src/Gateways/PayFlexV4Pos.php +++ b/src/Gateways/PayFlexV4Pos.php @@ -53,6 +53,7 @@ class PayFlexV4Pos extends AbstractGateway PosInterface::TX_TYPE_REFUND_PARTIAL => true, PosInterface::TX_TYPE_HISTORY => false, PosInterface::TX_TYPE_ORDER_HISTORY => false, + PosInterface::TX_TYPE_CUSTOM_QUERY => true, ]; /** @return PayFlexAccount */ @@ -129,6 +130,14 @@ public function make3DHostPayment(Request $request, array $order, string $txType throw new UnsupportedPaymentModelException(); } + /** + * @inheritDoc + */ + public function customQuery(array $requestData, string $apiUrl = null): PosInterface + { + return parent::customQuery($requestData, $apiUrl ?? $this->getApiURL()); + } + /** * @inheritDoc */ diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php index 76742f46..aebf2d6b 100644 --- a/src/Gateways/PayForPos.php +++ b/src/Gateways/PayForPos.php @@ -50,6 +50,7 @@ class PayForPos extends AbstractGateway PosInterface::TX_TYPE_REFUND_PARTIAL => true, PosInterface::TX_TYPE_HISTORY => true, PosInterface::TX_TYPE_ORDER_HISTORY => true, + PosInterface::TX_TYPE_CUSTOM_QUERY => true, ]; /** @return PayForAccount */ diff --git a/src/Gateways/PosNet.php b/src/Gateways/PosNet.php index b19d1e19..ac0c8954 100644 --- a/src/Gateways/PosNet.php +++ b/src/Gateways/PosNet.php @@ -53,6 +53,7 @@ class PosNet extends AbstractGateway PosInterface::TX_TYPE_REFUND_PARTIAL => true, PosInterface::TX_TYPE_HISTORY => false, PosInterface::TX_TYPE_ORDER_HISTORY => false, + PosInterface::TX_TYPE_CUSTOM_QUERY => true, ]; /** diff --git a/src/Gateways/PosNetV1Pos.php b/src/Gateways/PosNetV1Pos.php index d869868d..ea61a498 100644 --- a/src/Gateways/PosNetV1Pos.php +++ b/src/Gateways/PosNetV1Pos.php @@ -48,6 +48,7 @@ class PosNetV1Pos extends AbstractGateway PosInterface::TX_TYPE_REFUND_PARTIAL => true, PosInterface::TX_TYPE_HISTORY => false, PosInterface::TX_TYPE_ORDER_HISTORY => false, + PosInterface::TX_TYPE_CUSTOM_QUERY => true, ]; /** @return PosNetAccount */ @@ -152,6 +153,18 @@ public function get3DFormData(array $order, string $paymentModel, string $txType return $this->requestDataMapper->create3DFormData($this->account, $order, $paymentModel, $txType, $this->get3DGatewayURL(), $creditCard); } + /** + * @inheritDoc + */ + public function customQuery(array $requestData, string $apiUrl = null): PosInterface + { + if (null === $apiUrl) { + throw new InvalidArgumentException('API URL is required for custom query'); + } + + return parent::customQuery($requestData, $apiUrl); + } + /** * @inheritDoc */ diff --git a/src/Gateways/ToslaPos.php b/src/Gateways/ToslaPos.php index 29e0d8b3..a480bb0a 100644 --- a/src/Gateways/ToslaPos.php +++ b/src/Gateways/ToslaPos.php @@ -57,6 +57,7 @@ class ToslaPos extends AbstractGateway PosInterface::TX_TYPE_REFUND => true, PosInterface::TX_TYPE_REFUND_PARTIAL => true, PosInterface::TX_TYPE_STATUS => true, + PosInterface::TX_TYPE_CUSTOM_QUERY => true, ]; @@ -161,6 +162,18 @@ public function get3DFormData(array $order, string $paymentModel, string $txType return $this->requestDataMapper->create3DFormData($this->account, $data, $paymentModel, $txType, $gatewayUrl, $creditCard); } + /** + * @inheritDoc + */ + public function customQuery(array $requestData, string $apiUrl = null): PosInterface + { + if (null === $apiUrl) { + throw new \InvalidArgumentException('API URL is required for custom query'); + } + + return parent::customQuery($requestData, $apiUrl); + } + /** * @inheritDoc */ diff --git a/src/Gateways/VakifKatilimPos.php b/src/Gateways/VakifKatilimPos.php index d93b5160..483b1621 100644 --- a/src/Gateways/VakifKatilimPos.php +++ b/src/Gateways/VakifKatilimPos.php @@ -54,6 +54,7 @@ class VakifKatilimPos extends AbstractGateway PosInterface::TX_TYPE_REFUND_PARTIAL => true, PosInterface::TX_TYPE_HISTORY => true, PosInterface::TX_TYPE_ORDER_HISTORY => true, + PosInterface::TX_TYPE_CUSTOM_QUERY => true, ]; /** @return KuveytPosAccount */ @@ -159,6 +160,18 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr } + /** + * @inheritDoc + */ + public function customQuery(array $requestData, string $apiUrl = null): PosInterface + { + if (null === $apiUrl) { + throw new \InvalidArgumentException('API URL is required for custom query'); + } + + return parent::customQuery($requestData, $apiUrl); + } + /** * @inheritDoc * diff --git a/src/PosInterface.php b/src/PosInterface.php index 0a486a81..9ee6a2e2 100644 --- a/src/PosInterface.php +++ b/src/PosInterface.php @@ -51,6 +51,9 @@ interface PosInterface /** @var string */ public const TX_TYPE_HISTORY = 'history'; + /** @var string */ + public const TX_TYPE_CUSTOM_QUERY = 'custom_query'; + /** @var string */ public const MODEL_3D_SECURE = '3d'; @@ -284,6 +287,24 @@ public function orderHistory(array $order): PosInterface; */ public function history(array $data): PosInterface; + + /** + * Kütüphanenin desteği olmadığı özel istekleri bu methodla yapabilirsiniz. + * requestData içinde API hesap bilgileri, hash verisi ve bazi sabit değerler + * eğer zaten bulunmuyorsa kütüphane otomatik ekler. + * + * Bankadan dönen cevap array'e dönüştürülür, + * ancak diğer transaction'larda olduğu gibi mapping/normalization yapılmaz. + * + * @param array $requestData API'a gönderilecek veri. + * @param non-empty-string|null $apiUrl + * + * @return PosInterface + * + * @throws ClientExceptionInterface + */ + public function customQuery(array $requestData, string $apiUrl = null): PosInterface; + /** * Is success * diff --git a/src/Serializer/KuveytPosSerializer.php b/src/Serializer/KuveytPosSerializer.php index a1a9f9c1..34ad7c32 100644 --- a/src/Serializer/KuveytPosSerializer.php +++ b/src/Serializer/KuveytPosSerializer.php @@ -26,6 +26,7 @@ class KuveytPosSerializer implements SerializerInterface PosInterface::TX_TYPE_REFUND_PARTIAL, PosInterface::TX_TYPE_STATUS, PosInterface::TX_TYPE_CANCEL, + PosInterface::TX_TYPE_CUSTOM_QUERY, ]; private Serializer $serializer; diff --git a/src/Serializer/PayFlexCPV4PosSerializer.php b/src/Serializer/PayFlexCPV4PosSerializer.php index 6822ea75..1551f85f 100644 --- a/src/Serializer/PayFlexCPV4PosSerializer.php +++ b/src/Serializer/PayFlexCPV4PosSerializer.php @@ -48,9 +48,14 @@ public function encode(array $data, string $txType) ); } - if (PosInterface::TX_TYPE_REFUND === $txType - || PosInterface::TX_TYPE_REFUND_PARTIAL === $txType - || PosInterface::TX_TYPE_CANCEL === $txType) { + $supportedTxTypes = [ + PosInterface::TX_TYPE_REFUND, + PosInterface::TX_TYPE_REFUND_PARTIAL, + PosInterface::TX_TYPE_CANCEL, + PosInterface::TX_TYPE_CUSTOM_QUERY, + ]; + + if (\in_array($txType, $supportedTxTypes, true)) { return $this->serializer->encode($data, XmlEncoder::FORMAT); } diff --git a/tests/Functional/AkbankPosTest.php b/tests/Functional/AkbankPosTest.php index 74a5fef9..78ec37f6 100644 --- a/tests/Functional/AkbankPosTest.php +++ b/tests/Functional/AkbankPosTest.php @@ -435,4 +435,43 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThro $this->assertTrue($eventIsThrown); $this->assertNotEmpty($response['transactions']); } + + public function testCustomQuery(): void + { + $customQuery = [ + '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, + ], + ]; + + $eventIsThrown = false; + $this->eventDispatcher->addListener( + RequestDataPreparedEvent::class, + function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void { + $eventIsThrown = true; + $this->assertSame(PosInterface::TX_TYPE_CUSTOM_QUERY, $requestDataPreparedEvent->getTxType()); + $this->assertCount(8, $requestDataPreparedEvent->getRequestData()); + }); + + $this->pos->customQuery($customQuery); + + $response = $this->pos->getResponse(); + + $this->assertIsArray($response); + $this->assertNotEmpty($response); + $this->assertArrayHasKey('responseCode', $response); + $this->assertTrue($eventIsThrown); + } } diff --git a/tests/Functional/EstV3PosTest.php b/tests/Functional/EstV3PosTest.php index da15f1d0..623d87b2 100644 --- a/tests/Functional/EstV3PosTest.php +++ b/tests/Functional/EstV3PosTest.php @@ -297,4 +297,34 @@ function (Before3DFormHashCalculatedEvent $before3DFormHashCalculatedEvent) use $this->assertArrayHasKey('test_input', $formData['inputs']); $this->assertTrue($eventIsThrown); } + + public function testCustomQuery(): void + { + $customQuery = [ + 'Type' => 'Query', + 'Number' => '4242424242424242', + 'Expires' => '10.2028', + 'Extra' => [ + 'IMECECARDQUERY' => null, + ], + ]; + + $eventIsThrown = false; + $this->eventDispatcher->addListener( + RequestDataPreparedEvent::class, + function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void { + $eventIsThrown = true; + $this->assertSame(PosInterface::TX_TYPE_CUSTOM_QUERY, $requestDataPreparedEvent->getTxType()); + $this->assertCount(7, $requestDataPreparedEvent->getRequestData()); + }); + + $this->pos->customQuery($customQuery); + + $response = $this->pos->getResponse(); + + $this->assertIsArray($response); + $this->assertNotEmpty($response); + $this->assertArrayHasKey('ProcReturnCode', $response); + $this->assertTrue($eventIsThrown); + } } diff --git a/tests/Functional/GarantiPosTest.php b/tests/Functional/GarantiPosTest.php index 1c5a5e5c..2659b5df 100644 --- a/tests/Functional/GarantiPosTest.php +++ b/tests/Functional/GarantiPosTest.php @@ -284,4 +284,46 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThro $this->assertTrue($eventIsThrown); $this->assertNotEmpty($response['transactions']); } + + public function testCustomQuery(): void + { + $customQuery = [ + 'Version' => 'v0.00', + 'Customer' => [ + 'IPAddress' => '1.1.111.111', + 'EmailAddress' => 'Cem@cem.com', + ], + 'Order' => [ + 'OrderID' => 'SISTD5A61F1682E745B28871872383ABBEB1', + 'GroupID' => '', + 'Description' => '', + ], + 'Transaction' => [ + 'Type' => 'bininq', + 'Amount' => '1', + 'BINInq' => [ + 'Group' => 'A', + 'CardType' => 'A', + ], + ], + ]; + + $eventIsThrown = false; + $this->eventDispatcher->addListener( + RequestDataPreparedEvent::class, + function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void { + $eventIsThrown = true; + $this->assertSame(PosInterface::TX_TYPE_CUSTOM_QUERY, $requestDataPreparedEvent->getTxType()); + $this->assertCount(6, $requestDataPreparedEvent->getRequestData()); + }); + + $this->pos->customQuery($customQuery); + + $response = $this->pos->getResponse(); + + $this->assertIsArray($response); + $this->assertNotEmpty($response); + $this->assertArrayHasKey('Transaction', $response); + $this->assertTrue($eventIsThrown); + } } diff --git a/tests/Functional/KuveytPosTest.php b/tests/Functional/KuveytPosTest.php index 5d4fcf40..3659dbcc 100644 --- a/tests/Functional/KuveytPosTest.php +++ b/tests/Functional/KuveytPosTest.php @@ -301,4 +301,34 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThro return $lastResponse; } + + public function testCustomQuery(): void + { + $customQuery = [ + 'SecureType' => 'Inquiry', + 'TxnType' => 'ParaPuanInquiry', + 'Pan' => $card->getNumber(), + 'Expiry' => $card->getExpirationDate(\Mews\Pos\DataMapper\RequestDataMapper\PayForPosRequestDataMapper::CREDIT_CARD_EXP_DATE_FORMAT), + 'Cvv2' => $card->getCvv(), + ]; + + + $eventIsThrown = false; + $this->eventDispatcher->addListener( + RequestDataPreparedEvent::class, + function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void { + $eventIsThrown = true; + $this->assertSame(PosInterface::TX_TYPE_CUSTOM_QUERY, $requestDataPreparedEvent->getTxType()); + $this->assertCount(6, $requestDataPreparedEvent->getRequestData()); + }); + + $this->pos->customQuery($customQuery); + + $response = $this->pos->getResponse(); + + $this->assertIsArray($response); + $this->assertNotEmpty($response); + $this->assertArrayHasKey('Transaction', $response); + $this->assertTrue($eventIsThrown); + } } diff --git a/tests/Functional/PayForPosTest.php b/tests/Functional/PayForPosTest.php index 75f157e9..c8d37de9 100644 --- a/tests/Functional/PayForPosTest.php +++ b/tests/Functional/PayForPosTest.php @@ -310,4 +310,33 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThro return $lastResponse; } + + public function testCustomQuery(): void + { + $customQuery = [ + 'SecureType' => 'Inquiry', + 'TxnType' => 'ParaPuanInquiry', + 'Pan' => '4155650100416111', + 'Expiry' => '0125', + 'Cvv2' => '123', + ]; + + $eventIsThrown = false; + $this->eventDispatcher->addListener( + RequestDataPreparedEvent::class, + function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void { + $eventIsThrown = true; + $this->assertSame(PosInterface::TX_TYPE_CUSTOM_QUERY, $requestDataPreparedEvent->getTxType()); + $this->assertCount(9, $requestDataPreparedEvent->getRequestData()); + }); + + $this->pos->customQuery($customQuery); + + $response = $this->pos->getResponse(); + + $this->assertIsArray($response); + $this->assertNotEmpty($response); + $this->assertArrayHasKey('ProcReturnCode', $response); + $this->assertTrue($eventIsThrown); + } } diff --git a/tests/Functional/ToslaPosTest.php b/tests/Functional/ToslaPosTest.php index cd146842..1766ee8d 100644 --- a/tests/Functional/ToslaPosTest.php +++ b/tests/Functional/ToslaPosTest.php @@ -225,4 +225,29 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThro return $lastResponse; } + + public function testCustomQuery(): void + { + $customQuery = [ + 'bin' => 415956, + ]; + + $eventIsThrown = false; + $this->eventDispatcher->addListener( + RequestDataPreparedEvent::class, + function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void { + $eventIsThrown = true; + $this->assertSame(PosInterface::TX_TYPE_CUSTOM_QUERY, $requestDataPreparedEvent->getTxType()); + $this->assertCount(6, $requestDataPreparedEvent->getRequestData()); + }); + + $this->pos->customQuery($customQuery, 'https://prepentegrasyon.tosla.com/api/Payment/GetCommissionAndInstallmentInfo'); + + $response = $this->pos->getResponse(); + dump($response); + $this->assertIsArray($response); + $this->assertNotEmpty($response); + $this->assertArrayHasKey('BankCode', $response); + $this->assertTrue($eventIsThrown); + } } diff --git a/tests/Unit/Crypt/GarantiPosCryptTest.php b/tests/Unit/Crypt/GarantiPosCryptTest.php index 32815f0b..8427964c 100644 --- a/tests/Unit/Crypt/GarantiPosCryptTest.php +++ b/tests/Unit/Crypt/GarantiPosCryptTest.php @@ -195,6 +195,29 @@ public function hashCreateDataProvider(): array ], 'expected' => '0F97D922001221B9C90AA692CF5D4082FF6D3EB38BE863A47F9C08E63CD87312270D6F298E5FBBC320654861DA1C6EE826E0C83E904916351A9D3032FA426BAA', ], + 'bininq' => [ + 'requestData' => [ + 'Version' => 'v0.00', + 'Customer' => [ + 'IPAddress' => '1.1.111.111', + 'EmailAddress' => 'Cem@cem.com', + ], + 'Order' => [ + 'OrderID' => 'SISTD5A61F1682E745B28871872383ABBEB1', + 'GroupID' => '', + 'Description' => '', + ], + 'Transaction' => [ + 'Type' => 'bininq', + 'Amount' => '1', + 'BINInq' => [ + 'Group' => 'A', + 'CardType' => 'A', + ], + ], + ], + 'expected' => 'B129BF998FF8C97C42D3FC923AA4271656B112549665FA130ACF631EA3EB73D917AEB3D646481564CACE38D1687F7744F82E5A1DBB6966F1512E0AF29B4C067B', + ], ]; } } diff --git a/tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php index 565386b8..53cc1c99 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php @@ -421,6 +421,120 @@ public function testCreateStatusRequestData(): void $this->requestDataMapper->createStatusRequestData($this->account, []); } + /** + * @dataProvider createCustomQueryRequestDataDataProvider + */ + public function testCreateCustomQueryRequestData(array $requestData, array $expectedData): void + { + $this->crypt->expects(self::once()) + ->method('generateRandomString') + ->willReturn($expectedData['randomNumber']); + + $actual = $this->requestDataMapper->createCustomQueryRequestData($this->account, $requestData); + $this->assertSame(23, \strlen($actual['requestDateTime'])); + unset($actual['requestDateTime']); + + \ksort($actual); + \ksort($expectedData); + $this->assertSame($expectedData, $actual); + } + + public static function createCustomQueryRequestDataDataProvider(): \Generator + { + yield 'without_account_data_link_creation_request' => [ + 'request_data' => [ + '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, + ], + ], + 'expected' => [ + 'version' => '1.00', + 'txnCode' => '1020', + 'randomNumber' => 'rand_134', + 'terminal' => [ + 'merchantSafeId' => '2023090417500272654BD9A49CF07574', + 'terminalSafeId' => '2023090417500284633D137A249DBBEB', + ], + 'order' => [ + 'orderTrackId' => 'ae15a6c8-467e-45de-b24c-b98821a42667', + ], + 'payByLink' => [ + 'linkTxnCode' => '3000', + 'linkTransferType' => 'SMS', + 'mobilePhoneNumber' => '5321234567', + ], + 'transaction' => [ + 'amount' => 1.00, + 'currencyCode' => 949, + 'motoInd' => 0, + 'installCount' => 1, + ], + ], + ]; + + yield 'with_account_data' => [ + 'request_data' => [ + 'version' => 'VERSION_11', + 'txnCode' => '1020', + 'requestDateTime' => '2024-04-14T16:45:30.000', + 'randomNumber' => 'random_123', + 'terminal' => [ + 'merchantSafeId' => 'MERCH_SAFE_ID', + 'terminalSafeId' => 'TERM_SAFE_ID', + ], + 'order' => [ + 'orderTrackId' => 'ae15a6c8-467e-45de-b24c-b98821a42667', + ], + 'payByLink' => [ + 'linkTxnCode' => '3000', + 'linkTransferType' => 'SMS', + 'mobilePhoneNumber' => '5321234567', + ], + 'transaction' => [ + 'amount' => 1.00, + 'currencyCode' => 949, + 'motoInd' => 0, + 'installCount' => 1, + ], + ], + 'expected' => [ + 'version' => 'VERSION_11', + 'txnCode' => '1020', + 'randomNumber' => 'random_123', + 'terminal' => [ + 'merchantSafeId' => 'MERCH_SAFE_ID', + 'terminalSafeId' => 'TERM_SAFE_ID', + ], + 'order' => [ + 'orderTrackId' => 'ae15a6c8-467e-45de-b24c-b98821a42667', + ], + 'payByLink' => [ + 'linkTxnCode' => '3000', + 'linkTransferType' => 'SMS', + 'mobilePhoneNumber' => '5321234567', + ], + 'transaction' => [ + 'amount' => 1.00, + 'currencyCode' => 949, + 'motoInd' => 0, + 'installCount' => 1, + ], + ], + ]; + } + public static function historyRequestDataProvider(): array { return [ diff --git a/tests/Unit/DataMapper/RequestDataMapper/EstPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/EstPosRequestDataMapperTest.php index 225d5ab1..c7c4563a 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/EstPosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/EstPosRequestDataMapperTest.php @@ -247,6 +247,67 @@ public function testCreateRefundRequestData(array $order, string $txType, array $this->assertSame($expectedData, $actual); } + /** + * @dataProvider createCustomQueryRequestDataDataProvider + */ + public function testCreateCustomQueryRequestData(array $requestData, array $expectedData): void + { + $actual = $this->requestDataMapper->createCustomQueryRequestData($this->account, $requestData); + + \ksort($actual); + \ksort($expectedData); + $this->assertSame($expectedData, $actual); + } + + public static function createCustomQueryRequestDataDataProvider(): \Generator + { + yield 'without_account_data' => [ + 'request_data' => [ + 'Type' => 'Query', + 'Number' => '4111111111111111', + 'Expires' => '10.2025', + 'Extra' => [ + 'IMECECARDQUERY' => null, + ], + ], + 'expected' => [ + 'Name' => 'ISBANKAPI', + 'Password' => 'ISBANK07', + 'ClientId' => '700655000200', + 'Type' => 'Query', + 'Number' => '4111111111111111', + 'Expires' => '10.2025', + 'Extra' => [ + 'IMECECARDQUERY' => null, + ], + ], + ]; + + yield 'with_account_data' => [ + 'request_data' => [ + 'Name' => 'ACCOUNTNAME', + 'Password' => 'ACCOUNTPASSWORD', + 'ClientId' => 'ACCCOUNTCLIENTID', + 'Type' => 'Query', + 'Number' => '4111111111111111', + 'Expires' => '10.2025', + 'Extra' => [ + 'IMECECARDQUERY' => null, + ], + ], + 'expected' => [ + 'Name' => 'ACCOUNTNAME', + 'Password' => 'ACCOUNTPASSWORD', + 'ClientId' => 'ACCCOUNTCLIENTID', + 'Type' => 'Query', + 'Number' => '4111111111111111', + 'Expires' => '10.2025', + 'Extra' => [ + 'IMECECARDQUERY' => null, + ], + ], + ]; + } public static function threeDPaymentRequestDataDataProvider(): \Generator { @@ -678,7 +739,7 @@ public static function statusRequestDataProvider(): array 'ClientId' => '700655000200', 'Extra' => [ 'ORDERSTATUS' => 'QUERY', - 'RECURRINGID' => '22303O8EA19252', + 'RECURRINGID' => '22303O8EA19252', ], ], ], diff --git a/tests/Unit/DataMapper/RequestDataMapper/GarantiPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/GarantiPosRequestDataMapperTest.php index 40eea299..3f1161de 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/GarantiPosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/GarantiPosRequestDataMapperTest.php @@ -346,6 +346,138 @@ public function testCreateRefundRequestDataWithoutRefundCredentials(): void ); } + /** + * @dataProvider createCustomQueryRequestDataDataProvider + */ + public function testCreateCustomQueryRequestData(array $requestData, array $expectedData): void + { + if (!isset($requestData['Terminal']['HashData'])) { + $this->crypt->expects(self::once()) + ->method('createHash') + ->willReturn($expectedData['Terminal']['HashData']); + } + + $actual = $this->requestDataMapper->createCustomQueryRequestData($this->account, $requestData); + + \ksort($actual['Terminal']); + \ksort($expectedData['Terminal']); + \ksort($actual); + \ksort($expectedData); + $this->assertSame($expectedData, $actual); + } + + public static function createCustomQueryRequestDataDataProvider(): \Generator + { + yield 'without_account_data_bin_inquiry' => [ + 'request_data' => [ + 'Version' => 'v0.00', + 'Customer' => [ + 'IPAddress' => '1.1.111.111', + 'EmailAddress' => 'Cem@cem.com', + ], + 'Order' => [ + 'OrderID' => 'SISTD5A61F1682E745B28871872383ABBEB1', + 'GroupID' => '', + 'Description' => '', + ], + 'Transaction' => [ + 'Type' => 'bininq', + 'Amount' => '1', + 'BINInq' => [ + 'Group' => 'A', + 'CardType' => 'A', + ], + ], + ], + 'expected' => [ + 'Customer' => [ + 'IPAddress' => '1.1.111.111', + 'EmailAddress' => 'Cem@cem.com', + ], + 'Mode' => 'TEST', + 'Order' => [ + 'OrderID' => 'SISTD5A61F1682E745B28871872383ABBEB1', + 'GroupID' => '', + 'Description' => '', + ], + 'Terminal' => [ + 'ProvUserID' => 'PROVAUT', + 'UserID' => 'PROVAUT', + 'HashData' => '', + 'ID' => '30691298', + 'MerchantID' => '7000679', + ], + 'Transaction' => [ + 'Type' => 'bininq', + 'Amount' => '1', + 'BINInq' => [ + 'Group' => 'A', + 'CardType' => 'A', + ], + ], + 'Version' => 'v0.00', + ], + ]; + + yield 'with_account_data_bin_inquiry' => [ + 'request_data' => [ + 'Customer' => [ + 'IPAddress' => '1.1.111.111', + 'EmailAddress' => 'Cem@cem.com', + ], + 'Mode' => 'TEST', + 'Order' => [ + 'OrderID' => 'SISTD5A61F1682E745B28871872383ABBEB1', + 'GroupID' => '', + 'Description' => '', + ], + 'Terminal' => [ + 'ProvUserID' => 'PROVAUT2', + 'UserID' => 'PROVAUT2', + 'ID' => '306912982', + 'MerchantID' => '70006792', + ], + 'Transaction' => [ + 'Type' => 'bininq', + 'Amount' => '1', + 'BINInq' => [ + 'Group' => 'A', + 'CardType' => 'A', + ], + ], + 'Version' => 'v0.00', + ], + 'expected' => [ + 'Customer' => [ + 'IPAddress' => '1.1.111.111', + 'EmailAddress' => 'Cem@cem.com', + ], + 'Mode' => 'TEST', + 'Order' => [ + 'OrderID' => 'SISTD5A61F1682E745B28871872383ABBEB1', + 'GroupID' => '', + 'Description' => '', + ], + 'Terminal' => [ + 'ProvUserID' => 'PROVAUT2', + 'UserID' => 'PROVAUT2', + 'HashData' => 'ljflsjflds', + 'ID' => '306912982', + 'MerchantID' => '70006792', + ], + 'Transaction' => [ + 'Type' => 'bininq', + 'Amount' => '1', + 'BINInq' => [ + 'Group' => 'A', + 'CardType' => 'A', + ], + ], + 'Version' => 'v0.00', + ], + ]; + } + public static function threeDFormDataProvider(): array { $order = [ diff --git a/tests/Unit/DataMapper/RequestDataMapper/InterPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/InterPosRequestDataMapperTest.php index 76d20879..368728e0 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/InterPosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/InterPosRequestDataMapperTest.php @@ -238,6 +238,48 @@ public function testCreateHistoryRequestData(): void $this->requestDataMapper->createHistoryRequestData($this->account, []); } + /** + * @dataProvider createCustomQueryRequestDataDataProvider + */ + public function testCreateCustomQueryRequestData(array $requestData, array $expectedData): void + { + $actual = $this->requestDataMapper->createCustomQueryRequestData($this->account, $requestData); + + \ksort($actual); + \ksort($expectedData); + $this->assertSame($expectedData, $actual); + } + + public static function createCustomQueryRequestDataDataProvider(): \Generator + { + yield 'without_account_data' => [ + 'request_data' => [ + 'abc' => '124', + ], + 'expected' => [ + 'abc' => '124', + 'ShopCode' => '3123', + 'UserCode' => 'InterTestApi', + 'UserPass' => '3', + ], + ]; + + yield 'with_account_data' => [ + 'request_data' => [ + 'abc' => '124', + 'ShopCode' => '31231', + 'UserCode' => 'InterTestApi1', + 'UserPass' => '31', + ], + 'expected' => [ + 'abc' => '124', + 'ShopCode' => '31231', + 'UserCode' => 'InterTestApi1', + 'UserPass' => '31', + ], + ]; + } + public static function create3DPaymentRequestDataDataProvider(): array { return [ diff --git a/tests/Unit/DataMapper/RequestDataMapper/KuveytPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/KuveytPosRequestDataMapperTest.php index 000b1dca..34ff8446 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/KuveytPosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/KuveytPosRequestDataMapperTest.php @@ -30,7 +30,7 @@ class KuveytPosRequestDataMapperTest extends TestCase private KuveytPosRequestDataMapper $requestDataMapper; - /** @var CryptInterface|MockObject */ + /** @var CryptInterface & MockObject */ private CryptInterface $crypt; /** @var EventDispatcherInterface & MockObject */ @@ -327,6 +327,67 @@ public function testCreateHistoryRequestData(): void $this->requestDataMapper->createHistoryRequestData($this->account, []); } + /** + * @dataProvider createCustomQueryRequestDataDataProvider + */ + public function testCreateCustomQueryRequestData(array $requestData, array $expectedData): void + { + if (!isset($requestData['VPosMessage']['HashData'])) { + $this->crypt->expects(self::once()) + ->method('createHash') + ->willReturn($expectedData['VPosMessage']['HashData']); + } + + $actual = $this->requestDataMapper->createCustomQueryRequestData($this->account, $requestData); + + \ksort($actual); + \ksort($expectedData); + $this->assertSame($expectedData, $actual); + } + + public static function createCustomQueryRequestDataDataProvider(): \Generator + { + yield 'without_account_data' => [ + 'request_data' => [ + 'abc' => 'abc', + ], + 'expected' => [ + 'abc' => 'abc', + 'VPosMessage' => [ + 'MerchantId' => '80', + 'CustomerId' => '400235', + 'UserName' => 'apiuser', + 'APIVersion' => 'TDV2.0.0', + 'HashData' => 'hasshhh', + ], + ], + ]; + + yield 'with_account_data' => [ + 'request_data' => [ + 'abc' => 'abc', + 'VPosMessage' => [ + 'MerchantId' => '802', + 'CustomerId' => '4002352', + 'UserName' => 'apiuser2', + 'APIVersion' => 'TDV1.0.0', + 'HashData' => 'hasshhh22', + ], + ], + 'expected' => [ + 'abc' => 'abc', + 'VPosMessage' => [ + 'MerchantId' => '802', + 'CustomerId' => '4002352', + 'UserName' => 'apiuser2', + 'APIVersion' => 'TDV1.0.0', + 'HashData' => 'hasshhh22', + ], + ], + ]; + } + + public static function createCancelRequestDataProvider(): iterable { yield [ diff --git a/tests/Unit/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapperTest.php index 65302c3f..15830480 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapperTest.php @@ -186,6 +186,46 @@ public function testCreateOrderHistoryRequestData(): void $this->requestDataMapper->createOrderHistoryRequestData($this->account, []); } + /** + * @dataProvider createCustomQueryRequestDataDataProvider + */ + public function testCreateCustomQueryRequestData(array $requestData, array $expectedData): void + { + $actual = $this->requestDataMapper->createCustomQueryRequestData($this->account, $requestData); + + \ksort($actual); + \ksort($expectedData); + $this->assertSame($expectedData, $actual); + } + + public static function createCustomQueryRequestDataDataProvider(): \Generator + { + yield 'without_account_data_bin_inquiry' => [ + 'request_data' => [ + 'abc' => 'abc', + ], + 'expected' => [ + 'abc' => 'abc', + 'MerchantId' => '000000000111111', + 'Password' => '3XTgER89as', + ], + ]; + + yield 'with_account_data_bin_inquiry' => [ + 'request_data' => [ + 'abc' => 'abc', + 'MerchantId' => '000000000111111xxx', + 'Password' => '3XTgER89asxxx', + ], + 'expected' => [ + 'abc' => 'abc', + 'MerchantId' => '000000000111111xxx', + 'Password' => '3XTgER89asxxx', + ], + ]; + } + + public static function registerDataProvider(): iterable { $account = AccountFactory::createPayFlexAccount( diff --git a/tests/Unit/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapperTest.php index d6248ae3..d7d5f92d 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapperTest.php @@ -247,6 +247,48 @@ public function testCreateHistoryRequestData(): void $this->requestDataMapper->createHistoryRequestData($this->account, []); } + /** + * @dataProvider createCustomQueryRequestDataDataProvider + */ + public function testCreateCustomQueryRequestData(array $requestData, array $expectedData): void + { + $actual = $this->requestDataMapper->createCustomQueryRequestData($this->account, $requestData); + + \ksort($actual); + \ksort($expectedData); + $this->assertSame($expectedData, $actual); + } + + public static function createCustomQueryRequestDataDataProvider(): \Generator + { + yield 'without_account_data_campaign_search' => [ + 'request_data' => [ + 'TransactionType' => 'CampaignSearch', + ], + 'expected' => [ + 'MerchantId' => '000000000111111', + 'Password' => '3XTgER89as', + 'TerminalNo' => 'VP999999', + 'TransactionType' => 'CampaignSearch', + ], + ]; + + yield 'with_account_data_campaign_search' => [ + 'request_data' => [ + 'MerchantId' => '000000000111111zz', + 'Password' => '3XTgER89aszzz', + 'TerminalNo' => 'VP999999zz', + 'TransactionType' => 'CampaignSearchzz', + ], + 'expected' => [ + 'MerchantId' => '000000000111111zz', + 'Password' => '3XTgER89aszzz', + 'TerminalNo' => 'VP999999zz', + 'TransactionType' => 'CampaignSearchzz', + ], + ]; + } + public static function createStatusRequestDataDataProvider(): array { return [ diff --git a/tests/Unit/DataMapper/RequestDataMapper/PayForPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/PayForPosRequestDataMapperTest.php index f6c7407d..79b4dc8c 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/PayForPosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/PayForPosRequestDataMapperTest.php @@ -253,6 +253,67 @@ public function testCreateRefundRequestData(array $order, string $txType, array $this->assertSame($expectedData, $actual); } + /** + * @dataProvider createCustomQueryRequestDataDataProvider + */ + public function testCreateCustomQueryRequestData(array $requestData, array $expectedData): void + { + $actual = $this->requestDataMapper->createCustomQueryRequestData($this->account, $requestData); + + \ksort($actual); + \ksort($expectedData); + $this->assertSame($expectedData, $actual); + } + + public static function createCustomQueryRequestDataDataProvider(): \Generator + { + yield 'without_account_data_point_inquiry' => [ + 'request_data' => [ + 'SecureType' => 'Inquiry', + 'TxnType' => 'ParaPuanInquiry', + 'Pan' => '4155650100416111', + 'Expiry' => '0125', + 'Cvv2' => '123', + ], + 'expected' => [ + 'Cvv2' => '123', + 'Expiry' => '0125', + 'MbrId' => '5', + 'MerchantId' => '085300000009704', + 'Pan' => '4155650100416111', + 'SecureType' => 'Inquiry', + 'TxnType' => 'ParaPuanInquiry', + 'UserCode' => 'QNB_API_KULLANICI_3DPAY', + 'UserPass' => 'UcBN0', + ], + ]; + + yield 'with_account_data_point_inquiry' => [ + 'request_data' => [ + 'Cvv2' => '123', + 'Expiry' => '0125', + 'MbrId' => '5', + 'MerchantId' => '085300000009704', + 'Pan' => '4155650100416111', + 'SecureType' => 'Inquiry', + 'TxnType' => 'ParaPuanInquiry', + 'UserCode' => 'QNB_API_KULLANICI_3DPAYxxx', + 'UserPass' => 'UcBN0xxx', + ], + 'expected' => [ + 'Cvv2' => '123', + 'Expiry' => '0125', + 'MbrId' => '5', + 'MerchantId' => '085300000009704', + 'Pan' => '4155650100416111', + 'SecureType' => 'Inquiry', + 'TxnType' => 'ParaPuanInquiry', + 'UserCode' => 'QNB_API_KULLANICI_3DPAYxxx', + 'UserPass' => 'UcBN0xxx', + ], + ]; + } + public static function create3DPaymentRequestDataDataProvider(): array { return [ diff --git a/tests/Unit/DataMapper/RequestDataMapper/PosNetRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/PosNetRequestDataMapperTest.php index 6aa18ec8..d6ff9a89 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/PosNetRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/PosNetRequestDataMapperTest.php @@ -312,6 +312,73 @@ public function testCreateOrderHistoryRequestData(): void $this->requestDataMapper->createOrderHistoryRequestData($this->account, []); } + /** + * @dataProvider createCustomQueryRequestDataDataProvider + */ + public function testCreateCustomQueryRequestData(array $requestData, array $expectedData): void + { + $actual = $this->requestDataMapper->createCustomQueryRequestData($this->account, $requestData); + + \ksort($actual); + \ksort($expectedData); + $this->assertSame($expectedData, $actual); + } + + public static function createCustomQueryRequestDataDataProvider(): \Generator + { + yield 'without_account_data_point_inquiry' => [ + 'request_data' => [ + 'pointUsage' => [ + 'amount' => '250', + 'lpAmount' => '40', + 'ccno' => '4048090000000001', + 'currencyCode' => 'TL', + 'expDate' => '2411', + 'orderID' => 'PKPPislemleriNT000000001', + ], + ], + 'expected' => [ + 'mid' => '6706598320', + 'tid' => '67005551', + 'pointUsage' => [ + 'amount' => '250', + 'lpAmount' => '40', + 'ccno' => '4048090000000001', + 'currencyCode' => 'TL', + 'expDate' => '2411', + 'orderID' => 'PKPPislemleriNT000000001', + ], + ], + ]; + + yield 'with_account_data_point_inquiry' => [ + 'request_data' => [ + 'mid' => '6706598320xxx', + 'tid' => '67005551xxx', + 'pointUsage' => [ + 'amount' => '250', + 'lpAmount' => '40', + 'ccno' => '4048090000000001', + 'currencyCode' => 'TL', + 'expDate' => '2411', + 'orderID' => 'PKPPislemleriNT000000001', + ], + ], + 'expected' => [ + 'mid' => '6706598320xxx', + 'tid' => '67005551xxx', + 'pointUsage' => [ + 'amount' => '250', + 'lpAmount' => '40', + 'ccno' => '4048090000000001', + 'currencyCode' => 'TL', + 'expDate' => '2411', + 'orderID' => 'PKPPislemleriNT000000001', + ], + ], + ]; + } + public static function threeDFormDataDataProvider(): array { return [ diff --git a/tests/Unit/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapperTest.php index 39f952d3..0b270e52 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapperTest.php @@ -309,6 +309,124 @@ public function testCreateOrderHistoryRequestData(): void $this->requestDataMapper->createOrderHistoryRequestData($this->account, []); } + /** + * @dataProvider createCustomQueryRequestDataDataProvider + */ + public function testCreateCustomQueryRequestData(array $requestData, array $expectedData): void + { + if (!isset($requestData['MAC'])) { + $this->crypt->expects(self::once()) + ->method('hashFromParams') + ->willReturn($expectedData['MAC']); + } + + $actual = $this->requestDataMapper->createCustomQueryRequestData($this->account, $requestData); + + \ksort($actual); + \ksort($expectedData); + $this->assertSame($expectedData, $actual); + } + + public static function createCustomQueryRequestDataDataProvider(): \Generator + { + yield 'without_account_data_point_inquiry' => [ + 'request_data' => [ + '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, + ], + 'expected' => [ + 'AdditionalInfoData' => null, + 'ApiType' => 'JSON', + 'ApiVersion' => 'V100', + 'CardInformationData' => [ + 'CardHolderName' => 'deneme deneme', + 'CardNo' => '5400619360964581', + 'Cvc2' => '056', + 'ExpireDate' => '2001', + ], + 'CipheredData' => null, + 'DealerData' => null, + 'IsEncrypted' => 'N', + 'IsMailOrder' => null, + 'IsRecurring' => null, + 'IsTDSecureMerchant' => 'Y', + 'MAC' => 'jlksjfjldsf', + 'MACParams' => 'MerchantNo:TerminalNo:CardNo:Cvc2:ExpireDate', + 'MerchantNo' => '6700950031', + 'PaymentFacilitatorData' => null, + 'PaymentInstrumentType' => 'CARD', + 'TerminalNo' => '67540050', + 'ThreeDSecureData' => null, + ], + ]; + + yield 'with_account_data_point_inquiry' => [ + 'request_data' => [ + 'AdditionalInfoData' => null, + 'ApiType' => 'JSON', + 'ApiVersion' => 'V100', + 'CardInformationData' => [ + 'CardHolderName' => 'deneme deneme', + 'CardNo' => '5400619360964581', + 'Cvc2' => '056', + 'ExpireDate' => '2001', + ], + 'CipheredData' => null, + 'DealerData' => null, + 'IsEncrypted' => 'N', + 'IsMailOrder' => null, + 'IsRecurring' => null, + 'IsTDSecureMerchant' => 'Y', + 'MAC' => 'jlksjfjldsfxxx', + 'MACParams' => 'MerchantNo:TerminalNo:CardNo:Cvc2:ExpireDate', + 'MerchantNo' => '6700950031xxx', + 'TerminalNo' => '67540050xxx', + 'PaymentFacilitatorData' => null, + 'PaymentInstrumentType' => 'CARD', + 'ThreeDSecureData' => null, + ], + 'expected' => [ + 'AdditionalInfoData' => null, + 'ApiType' => 'JSON', + 'ApiVersion' => 'V100', + 'CardInformationData' => [ + 'CardHolderName' => 'deneme deneme', + 'CardNo' => '5400619360964581', + 'Cvc2' => '056', + 'ExpireDate' => '2001', + ], + 'CipheredData' => null, + 'DealerData' => null, + 'IsEncrypted' => 'N', + 'IsMailOrder' => null, + 'IsRecurring' => null, + 'IsTDSecureMerchant' => 'Y', + 'MAC' => 'jlksjfjldsfxxx', + 'MACParams' => 'MerchantNo:TerminalNo:CardNo:Cvc2:ExpireDate', + 'MerchantNo' => '6700950031xxx', + 'TerminalNo' => '67540050xxx', + 'PaymentFacilitatorData' => null, + 'PaymentInstrumentType' => 'CARD', + 'ThreeDSecureData' => null, + ], + ]; + } + /** * @return array */ diff --git a/tests/Unit/DataMapper/RequestDataMapper/ToslaPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/ToslaPosRequestDataMapperTest.php index 2556f59f..3a59d661 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/ToslaPosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/ToslaPosRequestDataMapperTest.php @@ -268,6 +268,64 @@ public function testCreateHistoryRequestData(): void $this->requestDataMapper->createHistoryRequestData($this->account); } + /** + * @dataProvider createCustomQueryRequestDataDataProvider + */ + public function testCreateCustomQueryRequestData(array $requestData, array $expectedData): void + { + $this->crypt->expects(self::once()) + ->method('generateRandomString') + ->willReturn($expectedData['rnd']); + if (!isset($requestData['hash'])) { + $this->crypt->expects(self::once()) + ->method('createHash') + ->willReturn($expectedData['hash']); + } + + $actual = $this->requestDataMapper->createCustomQueryRequestData($this->account, $requestData); + $this->assertSame(14, \strlen($actual['timeSpan'])); + unset($actual['timeSpan'], $expectedData['timeSpan']); + + \ksort($actual); + \ksort($expectedData); + $this->assertSame($expectedData, $actual); + } + + public static function createCustomQueryRequestDataDataProvider(): \Generator + { + yield 'without_account_data_installment_option_inquiry' => [ + 'request_data' => [ + 'bin' => 415956, + ], + 'expected' => [ + 'apiUser' => 'POS_ENT_Test_001', + 'bin' => 415956, + 'clientId' => '1000000494', + 'hash' => '12fsdfdsfsfs', + 'rnd' => 'rndsfldfls', + 'timeSpan' => '20241103144302', + ], + ]; + + yield 'with_account_data_installment_option_inquiry' => [ + 'request_data' => [ + 'apiUser' => 'POS_ENT_Test_001xxx', + 'bin' => 415956, + 'clientId' => '1000000494xx', + 'hash' => '12fsdfdsfsfsxxx', + 'rnd' => 'rndsfldfls', + 'timeSpan' => '20241103144302', + ], + 'expected' => [ + 'apiUser' => 'POS_ENT_Test_001xxx', + 'bin' => 415956, + 'clientId' => '1000000494xx', + 'hash' => '12fsdfdsfsfsxxx', + 'rnd' => 'rndsfldfls', + 'timeSpan' => '20241103144302', + ], + ]; + } public static function statusRequestDataProvider(): array { diff --git a/tests/Unit/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapperTest.php index a558f77f..e9619461 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapperTest.php @@ -333,7 +333,7 @@ public function testCreateStatusRequestData(array $order, array $expected): void */ public function testCreate3DPaymentRequestData(KuveytPosAccount $kuveytPosAccount, array $order, string $txType, array $responseData, array $expectedData): void { - $hashCalculationData = $expectedData; + $hashCalculationData = $expectedData; $hashCalculationData['HashData'] = ''; $this->crypt->expects(self::once()) @@ -348,6 +348,174 @@ public function testCreate3DPaymentRequestData(KuveytPosAccount $kuveytPosAccoun $this->assertSame($expectedData, $actual); } + /** + * @dataProvider createCustomQueryRequestDataDataProvider + */ + public function testCreateCustomQueryRequestData(array $requestData, array $expectedData): void + { + if (!isset($requestData['HashData'])) { + $this->crypt->expects(self::once()) + ->method('createHash') + ->willReturn($expectedData['HashData']); + } + + $this->crypt->expects(self::once()) + ->method('hashString') + ->with($this->account->getStoreKey()) + ->willReturn($expectedData['HashPassword']); + + $actual = $this->requestDataMapper->createCustomQueryRequestData($this->account, $requestData); + + \ksort($actual); + \ksort($expectedData); + $this->assertSame($expectedData, $actual); + } + + public static function createCustomQueryRequestDataDataProvider(): \Generator + { + yield 'without_account_data_mail_order_sale' => [ + 'request_data' => [ + 'MerchantOrderId' => '2126497214', + 'InstallmentCount' => '0', + 'Amount' => '120', + 'DisplayAmount' => '120', + 'FECAmount' => '0', + 'FECCurrencyCode' => '0949', + 'Addresses' => [ + 'VPosAddressContract' => [ + 'Type' => '1', + 'Name' => 'Mahmut Sami YAZAR', + 'PhoneNumber' => '324234234234', + 'OrderId' => '0', + 'AddressId' => '12', + 'Email' => 'mahmutsamiyazar@hotmail.com', + ], + ], + 'CardNumber' => '5353550000958906', + 'CardExpireDateYear' => '23', + 'CardExpireDateMonth' => '01', + 'CardCVV2' => '741', + 'CardHolderName' => 'Hasan Karacan', + 'DebtId' => '0', + 'SurchargeAmount' => '0', + 'SGKDebtAmount' => '0', + 'InstallmentMaturityCommisionFlag' => '0', + 'TransactionSecurity' => '1', + 'CardGuid' => 'AA9588EF350C480FBE5CAD40A463AF00', + ], + 'expected' => [ + 'APIVersion' => '1.0.0', + 'Addresses' => [ + 'VPosAddressContract' => [ + 'Type' => '1', + 'Name' => 'Mahmut Sami YAZAR', + 'PhoneNumber' => '324234234234', + 'OrderId' => '0', + 'AddressId' => '12', + 'Email' => 'mahmutsamiyazar@hotmail.com', + ], + ], + 'Amount' => '120', + 'CardCVV2' => '741', + 'CardExpireDateMonth' => '01', + 'CardExpireDateYear' => '23', + 'CardGuid' => 'AA9588EF350C480FBE5CAD40A463AF00', + 'CardHolderName' => 'Hasan Karacan', + 'CardNumber' => '5353550000958906', + 'CustomerId' => '11111', + 'DebtId' => '0', + 'DisplayAmount' => '120', + 'FECAmount' => '0', + 'FECCurrencyCode' => '0949', + 'HashData' => 'fskfjslfjss', + 'HashPassword' => 'lf;slkddskf;sa', + 'InstallmentCount' => '0', + 'InstallmentMaturityCommisionFlag' => '0', + 'MerchantId' => '1', + 'MerchantOrderId' => '2126497214', + 'SGKDebtAmount' => '0', + 'SubMerchantId' => '0', + 'SurchargeAmount' => '0', + 'TransactionSecurity' => '1', + 'UserName' => 'APIUSER', + ], + ]; + + yield 'with_account_data_mail_order_sale' => [ + 'request_data' => [ + 'APIVersion' => '1.0.0', + 'Addresses' => [ + 'VPosAddressContract' => [ + 'Type' => '1', + 'Name' => 'Mahmut Sami YAZAR', + 'PhoneNumber' => '324234234234', + 'OrderId' => '0', + 'AddressId' => '12', + 'Email' => 'mahmutsamiyazar@hotmail.com', + ], + ], + 'Amount' => '120', + 'CardCVV2' => '741', + 'CardExpireDateMonth' => '01', + 'CardExpireDateYear' => '23', + 'CardGuid' => 'AA9588EF350C480FBE5CAD40A463AF00', + 'CardHolderName' => 'Hasan Karacan', + 'CardNumber' => '5353550000958906', + 'DebtId' => '0', + 'DisplayAmount' => '120', + 'FECAmount' => '0', + 'FECCurrencyCode' => '0949', + 'InstallmentCount' => '0', + 'InstallmentMaturityCommisionFlag' => '0', + 'MerchantOrderId' => '2126497214', + 'SGKDebtAmount' => '0', + 'SurchargeAmount' => '0', + 'TransactionSecurity' => '1', + 'SubMerchantId' => '0', + 'CustomerId' => '11111xxx', + 'HashPassword' => 'lf;slkddskf;saxxx', + 'MerchantId' => '1xxx', + 'UserName' => 'APIUSERXXX', + 'HashData' => 'fskfjslfjsszzzz', + ], + 'expected' => [ + 'APIVersion' => '1.0.0', + 'Addresses' => [ + 'VPosAddressContract' => [ + 'Type' => '1', + 'Name' => 'Mahmut Sami YAZAR', + 'PhoneNumber' => '324234234234', + 'OrderId' => '0', + 'AddressId' => '12', + 'Email' => 'mahmutsamiyazar@hotmail.com', + ], + ], + 'Amount' => '120', + 'CardCVV2' => '741', + 'CardExpireDateMonth' => '01', + 'CardExpireDateYear' => '23', + 'CardGuid' => 'AA9588EF350C480FBE5CAD40A463AF00', + 'CardHolderName' => 'Hasan Karacan', + 'CardNumber' => '5353550000958906', + 'DebtId' => '0', + 'DisplayAmount' => '120', + 'FECAmount' => '0', + 'FECCurrencyCode' => '0949', + 'InstallmentCount' => '0', + 'InstallmentMaturityCommisionFlag' => '0', + 'MerchantOrderId' => '2126497214', + 'SGKDebtAmount' => '0', + 'SurchargeAmount' => '0', + 'TransactionSecurity' => '1', + 'SubMerchantId' => '0', + 'CustomerId' => '11111xxx', + 'HashPassword' => 'lf;slkddskf;saxxx', + 'MerchantId' => '1xxx', + 'UserName' => 'APIUSERXXX', + 'HashData' => 'fskfjslfjsszzzz', + ], + ]; + } public static function createCancelRequestDataProvider(): iterable { diff --git a/tests/Unit/Gateways/AkbankPosTest.php b/tests/Unit/Gateways/AkbankPosTest.php index 917ebb77..757e88c5 100644 --- a/tests/Unit/Gateways/AkbankPosTest.php +++ b/tests/Unit/Gateways/AkbankPosTest.php @@ -639,6 +639,56 @@ public function testRefundRequest(array $order, string $txType, string $apiUrl): $this->pos->refund($order); } + /** + * @dataProvider customQueryRequestDataProvider + */ + public function testCustomQueryRequest(array $requestData, ?string $apiUrl, string $expectedApiUrl): void + { + $account = $this->pos->getAccount(); + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + + $updatedRequestData = $requestData + [ + 'abc' => 'def', + ]; + $this->requestMapperMock->expects(self::once()) + ->method('createCustomQueryRequestData') + ->with($account, $requestData) + ->willReturn($updatedRequestData); + + $this->configureClientResponse( + $txType, + $expectedApiUrl, + $updatedRequestData, + 'request-body', + 'response-body', + ['decodedResponse'], + $requestData, + PosInterface::MODEL_NON_SECURE + ); + + $this->pos->customQuery($requestData, $apiUrl); + } + + public static function customQueryRequestDataProvider(): array + { + return [ + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => 'https://apipre.akbank.com/api/v1/payment/virtualpos/xxxx', + 'expected_api_url' => 'https://apipre.akbank.com/api/v1/payment/virtualpos/xxxx', + ], + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => null, + 'expected_api_url' => 'https://apipre.akbank.com/api/v1/payment/virtualpos/transaction/process', + ], + ]; + } + public static function getApiUrlDataProvider(): array { return [ diff --git a/tests/Unit/Gateways/EstPosTest.php b/tests/Unit/Gateways/EstPosTest.php index 8e793276..2b4f150a 100644 --- a/tests/Unit/Gateways/EstPosTest.php +++ b/tests/Unit/Gateways/EstPosTest.php @@ -599,6 +599,56 @@ public function testMakeRegularPostAuthPayment(array $order, string $apiUrl): vo $this->pos->makeRegularPostPayment($order); } + /** + * @dataProvider customQueryRequestDataProvider + */ + public function testCustomQueryRequest(array $requestData, ?string $apiUrl, string $expectedApiUrl): void + { + $account = $this->pos->getAccount(); + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + + $updatedRequestData = $requestData + [ + 'abc' => 'def', + ]; + $this->requestMapperMock->expects(self::once()) + ->method('createCustomQueryRequestData') + ->with($account, $requestData) + ->willReturn($updatedRequestData); + + $this->configureClientResponse( + $txType, + $expectedApiUrl, + $updatedRequestData, + 'request-body', + 'response-body', + ['decodedResponse'], + $requestData, + PosInterface::MODEL_NON_SECURE + ); + + $this->pos->customQuery($requestData, $apiUrl); + } + + public static function customQueryRequestDataProvider(): array + { + return [ + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => 'https://entegrasyon.asseco-see.com.tr/fim/api/xxxx', + 'expected_api_url' => 'https://entegrasyon.asseco-see.com.tr/fim/api/xxxx', + ], + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => null, + 'expected_api_url' => 'https://entegrasyon.asseco-see.com.tr/fim/api', + ], + ]; + } + public static function make3DPaymentDataProvider(): array { return [ diff --git a/tests/Unit/Gateways/GarantiPosTest.php b/tests/Unit/Gateways/GarantiPosTest.php index 7c226550..730fa52c 100644 --- a/tests/Unit/Gateways/GarantiPosTest.php +++ b/tests/Unit/Gateways/GarantiPosTest.php @@ -546,6 +546,56 @@ public function testOrderHistoryRequest(array $order, string $apiUrl): void $this->pos->orderHistory($order); } + /** + * @dataProvider customQueryRequestDataProvider + */ + public function testCustomQueryRequest(array $requestData, ?string $apiUrl, string $expectedApiUrl): void + { + $account = $this->pos->getAccount(); + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + + $updatedRequestData = $requestData + [ + 'abc' => 'def', + ]; + $this->requestMapperMock->expects(self::once()) + ->method('createCustomQueryRequestData') + ->with($account, $requestData) + ->willReturn($updatedRequestData); + + $this->configureClientResponse( + $txType, + $expectedApiUrl, + $updatedRequestData, + 'request-body', + 'response-body', + ['decodedResponse'], + $requestData, + PosInterface::MODEL_NON_SECURE + ); + + $this->pos->customQuery($requestData, $apiUrl); + } + + public static function customQueryRequestDataProvider(): array + { + return [ + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => 'https://sanalposprovtest.garantibbva.com.tr/VPServlet/xxxx', + 'expected_api_url' => 'https://sanalposprovtest.garantibbva.com.tr/VPServlet/xxxx', + ], + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => null, + 'expected_api_url' => 'https://sanalposprovtest.garantibbva.com.tr/VPServlet', + ], + ]; + } + public static function make3DPaymentDataProvider(): array { return [ diff --git a/tests/Unit/Gateways/InterPosTest.php b/tests/Unit/Gateways/InterPosTest.php index 45405d9b..4aae3c5a 100644 --- a/tests/Unit/Gateways/InterPosTest.php +++ b/tests/Unit/Gateways/InterPosTest.php @@ -515,6 +515,56 @@ public function testRefundRequest(array $order, string $apiUrl): void $this->pos->refund($order); } + /** + * @dataProvider customQueryRequestDataProvider + */ + public function testCustomQueryRequest(array $requestData, ?string $apiUrl, string $expectedApiUrl): void + { + $account = $this->pos->getAccount(); + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + + $updatedRequestData = $requestData + [ + 'abc' => 'def', + ]; + $this->requestMapperMock->expects(self::once()) + ->method('createCustomQueryRequestData') + ->with($account, $requestData) + ->willReturn($updatedRequestData); + + $this->configureClientResponse( + $txType, + $expectedApiUrl, + $updatedRequestData, + $updatedRequestData, + 'response-body', + ['decodedResponse'], + $requestData, + PosInterface::MODEL_NON_SECURE + ); + + $this->pos->customQuery($requestData, $apiUrl); + } + + public static function customQueryRequestDataProvider(): array + { + return [ + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => 'https://test.inter-vpos.com.tr/mpi/Default.aspx/xxxx', + 'expected_api_url' => 'https://test.inter-vpos.com.tr/mpi/Default.aspx/xxxx', + ], + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => null, + 'expected_api_url' => 'https://test.inter-vpos.com.tr/mpi/Default.aspx', + ], + ]; + } + public static function make3DPaymentDataProvider(): array { return [ diff --git a/tests/Unit/Gateways/PayFlexCPV4PosTest.php b/tests/Unit/Gateways/PayFlexCPV4PosTest.php index b039bcb8..609d107d 100644 --- a/tests/Unit/Gateways/PayFlexCPV4PosTest.php +++ b/tests/Unit/Gateways/PayFlexCPV4PosTest.php @@ -479,6 +479,56 @@ public function testOrderHistoryRequest(): void $this->pos->orderHistory([]); } + /** + * @dataProvider customQueryRequestDataProvider + */ + public function testCustomQueryRequest(array $requestData, ?string $apiUrl, string $expectedApiUrl): void + { + $account = $this->pos->getAccount(); + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + + $updatedRequestData = $requestData + [ + 'abc' => 'def', + ]; + $this->requestMapperMock->expects(self::once()) + ->method('createCustomQueryRequestData') + ->with($account, $requestData) + ->willReturn($updatedRequestData); + + $this->configureClientResponse( + $txType, + $expectedApiUrl, + $updatedRequestData, + 'request-body', + 'response-body', + ['decodedResponse'], + $requestData, + PosInterface::MODEL_NON_SECURE + ); + + $this->pos->customQuery($requestData, $apiUrl); + } + + public static function customQueryRequestDataProvider(): array + { + return [ + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => 'https://cptest.vakifbank.com.tr/CommonPayment/SecurePayment/xxxx', + 'expected_api_url' => 'https://cptest.vakifbank.com.tr/CommonPayment/SecurePayment/xxxx', + ], + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => null, + 'expected_api_url' => 'https://cptest.vakifbank.com.tr/CommonPayment/SecurePayment', + ], + ]; + } + public static function make3DPayPaymentDataProvider(): array { $testData = iterator_to_array( diff --git a/tests/Unit/Gateways/PayFlexV4PosTest.php b/tests/Unit/Gateways/PayFlexV4PosTest.php index 1f359b55..0550a64e 100644 --- a/tests/Unit/Gateways/PayFlexV4PosTest.php +++ b/tests/Unit/Gateways/PayFlexV4PosTest.php @@ -518,6 +518,56 @@ public function testOrderHistoryRequest(): void $this->pos->orderHistory([]); } + /** + * @dataProvider customQueryRequestDataProvider + */ + public function testCustomQueryRequest(array $requestData, ?string $apiUrl, string $expectedApiUrl): void + { + $account = $this->pos->getAccount(); + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + + $updatedRequestData = $requestData + [ + 'abc' => 'def', + ]; + $this->requestMapperMock->expects(self::once()) + ->method('createCustomQueryRequestData') + ->with($account, $requestData) + ->willReturn($updatedRequestData); + + $this->configureClientResponse( + $txType, + $expectedApiUrl, + $updatedRequestData, + 'request-body', + 'response-body', + ['decodedResponse'], + $requestData, + PosInterface::MODEL_NON_SECURE + ); + + $this->pos->customQuery($requestData, $apiUrl); + } + + public static function customQueryRequestDataProvider(): array + { + return [ + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => 'https://onlineodemetest.vakifbank.com.tr:4443/VposService/v3/Vposreq.aspx/xxx', + 'expected_api_url' => 'https://onlineodemetest.vakifbank.com.tr:4443/VposService/v3/Vposreq.aspx/xxx', + ], + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => null, + 'expected_api_url' => 'https://onlineodemetest.vakifbank.com.tr:4443/VposService/v3/Vposreq.aspx', + ], + ]; + } + public static function enrollmentFailResponseDataProvider(): array { return [ diff --git a/tests/Unit/Gateways/PayForTest.php b/tests/Unit/Gateways/PayForTest.php index 34577dd3..212f2a91 100644 --- a/tests/Unit/Gateways/PayForTest.php +++ b/tests/Unit/Gateways/PayForTest.php @@ -580,6 +580,56 @@ public function testOrderHistoryRequest(array $order, string $apiUrl): void $this->pos->orderHistory($order); } + /** + * @dataProvider customQueryRequestDataProvider + */ + public function testCustomQueryRequest(array $requestData, ?string $apiUrl, string $expectedApiUrl): void + { + $account = $this->pos->getAccount(); + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + + $updatedRequestData = $requestData + [ + 'abc' => 'def', + ]; + $this->requestMapperMock->expects(self::once()) + ->method('createCustomQueryRequestData') + ->with($account, $requestData) + ->willReturn($updatedRequestData); + + $this->configureClientResponse( + $txType, + $expectedApiUrl, + $updatedRequestData, + 'request-body', + 'response-body', + ['decodedResponse'], + $requestData, + PosInterface::MODEL_NON_SECURE + ); + + $this->pos->customQuery($requestData, $apiUrl); + } + + public static function customQueryRequestDataProvider(): array + { + return [ + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => 'https://vpostest.qnbfinansbank.com/Gateway/XMLGate.aspx/xxxx', + 'expected_api_url' => 'https://vpostest.qnbfinansbank.com/Gateway/XMLGate.aspx/xxxx', + ], + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => null, + 'expected_api_url' => 'https://vpostest.qnbfinansbank.com/Gateway/XMLGate.aspx', + ], + ]; + } + public static function make3DPaymentDataProvider(): array { return [ diff --git a/tests/Unit/Gateways/PosNetTest.php b/tests/Unit/Gateways/PosNetTest.php index 9525d4f7..377f2577 100644 --- a/tests/Unit/Gateways/PosNetTest.php +++ b/tests/Unit/Gateways/PosNetTest.php @@ -650,6 +650,56 @@ public function testOrderHistoryRequest(): void $this->pos->orderHistory([]); } + /** + * @dataProvider customQueryRequestDataProvider + */ + public function testCustomQueryRequest(array $requestData, ?string $apiUrl, string $expectedApiUrl): void + { + $account = $this->pos->getAccount(); + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + + $updatedRequestData = $requestData + [ + 'abc' => 'def', + ]; + $this->requestMapperMock->expects(self::once()) + ->method('createCustomQueryRequestData') + ->with($account, $requestData) + ->willReturn($updatedRequestData); + + $this->configureClientResponse( + $txType, + $expectedApiUrl, + $updatedRequestData, + 'request-body', + 'response-body', + ['decodedResponse'], + $requestData, + PosInterface::MODEL_NON_SECURE + ); + + $this->pos->customQuery($requestData, $apiUrl); + } + + public static function customQueryRequestDataProvider(): array + { + return [ + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => 'https://setmpos.ykb.com/PosnetWebService/XML/xxxx', + 'expected_api_url' => 'https://setmpos.ykb.com/PosnetWebService/XML/xxxx', + ], + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => null, + 'expected_api_url' => 'https://setmpos.ykb.com/PosnetWebService/XML', + ], + ]; + } + public static function make3DPaymentDataProvider(): array { $resolveMerchantResponseData = [ diff --git a/tests/Unit/Gateways/PosNetV1PosTest.php b/tests/Unit/Gateways/PosNetV1PosTest.php index 929b2872..f94ac4b7 100644 --- a/tests/Unit/Gateways/PosNetV1PosTest.php +++ b/tests/Unit/Gateways/PosNetV1PosTest.php @@ -515,6 +515,57 @@ public function testOrderHistoryRequest(): void $this->pos->orderHistory([]); } + /** + * @dataProvider customQueryRequestDataProvider + */ + public function testCustomQueryRequest(array $requestData, string $apiUrl, string $expectedApiUrl): void + { + $account = $this->pos->getAccount(); + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + + $updatedRequestData = $requestData + [ + 'abc' => 'def', + ]; + $this->requestMapperMock->expects(self::once()) + ->method('createCustomQueryRequestData') + ->with($account, $requestData) + ->willReturn($updatedRequestData); + + $this->configureClientResponse( + $txType, + $expectedApiUrl, + $updatedRequestData, + 'request-body', + 'response-body', + ['decodedResponse'], + $requestData, + PosInterface::MODEL_NON_SECURE + ); + + $this->pos->customQuery($requestData, $apiUrl); + } + + + public function testCustomQueryRequestWithoutAPIurl(): void + { + $this->expectException(\InvalidArgumentException::class); + + $this->pos->customQuery(['ac' => 'aas']); + } + + public static function customQueryRequestDataProvider(): array + { + return [ + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => 'https://epostest.albarakaturk.com.tr/ALBMerchantService/MerchantJSONAPI.svc/xxx', + 'expected_api_url' => 'https://epostest.albarakaturk.com.tr/ALBMerchantService/MerchantJSONAPI.svc/xxx', + ], + ]; + } + public static function getApiURLDataProvider(): iterable { yield [ diff --git a/tests/Unit/Gateways/ToslaPosTest.php b/tests/Unit/Gateways/ToslaPosTest.php index a5b38f63..72b2c4c5 100644 --- a/tests/Unit/Gateways/ToslaPosTest.php +++ b/tests/Unit/Gateways/ToslaPosTest.php @@ -568,6 +568,57 @@ public function testOrderHistory( $this->assertSame($result, $mappedResponse); } + /** + * @dataProvider customQueryRequestDataProvider + */ + public function testCustomQueryRequest(array $requestData, string $apiUrl, string $expectedApiUrl): void + { + $account = $this->pos->getAccount(); + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + + $updatedRequestData = $requestData + [ + 'abc' => 'def', + ]; + $this->requestMapperMock->expects(self::once()) + ->method('createCustomQueryRequestData') + ->with($account, $requestData) + ->willReturn($updatedRequestData); + + $this->configureClientResponse( + $txType, + $expectedApiUrl, + $updatedRequestData, + 'request-body', + 'response-body', + ['decodedResponse'], + $requestData, + PosInterface::MODEL_NON_SECURE + ); + + $this->pos->customQuery($requestData, $apiUrl); + } + + + public function testCustomQueryRequestWithoutAPIurl(): void + { + $this->expectException(\InvalidArgumentException::class); + + $this->pos->customQuery(['ac' => 'aas']); + } + + public static function customQueryRequestDataProvider(): array + { + return [ + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => 'https://prepentegrasyon.tosla.com/api/Payment/GetCommissionAndInstallmentInfo', + 'expected_api_url' => 'https://prepentegrasyon.tosla.com/api/Payment/GetCommissionAndInstallmentInfo', + ], + ]; + } + public static function statusDataProvider(): iterable { $statusResponses = iterator_to_array(ToslaPosResponseDataMapperTest::statusResponseDataProvider()); diff --git a/tests/Unit/Gateways/VakifKatilimTest.php b/tests/Unit/Gateways/VakifKatilimTest.php index 336a7f4b..85127897 100644 --- a/tests/Unit/Gateways/VakifKatilimTest.php +++ b/tests/Unit/Gateways/VakifKatilimTest.php @@ -586,6 +586,57 @@ public function testOrderHistoryRequest(array $order, string $apiUrl): void $this->pos->orderHistory($order); } + /** + * @dataProvider customQueryRequestDataProvider + */ + public function testCustomQueryRequest(array $requestData, string $apiUrl, string $expectedApiUrl): void + { + $account = $this->pos->getAccount(); + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + + $updatedRequestData = $requestData + [ + 'abc' => 'def', + ]; + $this->requestMapperMock->expects(self::once()) + ->method('createCustomQueryRequestData') + ->with($account, $requestData) + ->willReturn($updatedRequestData); + + $this->configureClientResponse( + $txType, + $expectedApiUrl, + $updatedRequestData, + 'request-body', + 'response-body', + ['decodedResponse'], + $requestData, + PosInterface::MODEL_NON_SECURE + ); + + $this->pos->customQuery($requestData, $apiUrl); + } + + + public function testCustomQueryRequestWithoutAPIurl(): void + { + $this->expectException(\InvalidArgumentException::class); + + $this->pos->customQuery(['ac' => 'aas']); + } + + public static function customQueryRequestDataProvider(): array + { + return [ + [ + 'requestData' => [ + 'id' => '2020110828BC', + ], + 'api_url' => 'https://boa.vakifkatilim.com.tr/VirtualPOS.Gateway/Home/MailOrderSale', + 'expected_api_url' => 'https://boa.vakifkatilim.com.tr/VirtualPOS.Gateway/Home/MailOrderSale', + ], + ]; + } + public static function make3DPaymentDataProvider(): array { return [ diff --git a/tests/Unit/Serializer/KuveytPosSerializerTest.php b/tests/Unit/Serializer/KuveytPosSerializerTest.php index f429b5eb..19ac98e9 100644 --- a/tests/Unit/Serializer/KuveytPosSerializerTest.php +++ b/tests/Unit/Serializer/KuveytPosSerializerTest.php @@ -123,6 +123,12 @@ public static function encodeDataProvider(): Generator 'expected' => ['abc' => 1], ]; + yield 'test_custom_query' => [ + 'input' => ['abc' => 1], + 'txType' => PosInterface::TX_TYPE_CUSTOM_QUERY, + 'expected' => ['abc' => 1], + ]; + yield 'test_pay' => [ 'input' => ['abc' => 1], 'txType' => PosInterface::TX_TYPE_PAY_AUTH, @@ -279,6 +285,11 @@ public static function decodeJsonDataProvider(): Generator 'txType' => PosInterface::TX_TYPE_STATUS, 'expected' => ['abc' => 1], ]; + yield 'test_custom_query' => [ + 'input' => '{"abc": 1}', + 'txType' => PosInterface::TX_TYPE_CUSTOM_QUERY, + 'expected' => ['abc' => 1], + ]; } public static function decodeExceptionDataProvider(): Generator diff --git a/tests/Unit/Serializer/PayFlexCPV4PosSerializerTest.php b/tests/Unit/Serializer/PayFlexCPV4PosSerializerTest.php index 51613602..060d701c 100644 --- a/tests/Unit/Serializer/PayFlexCPV4PosSerializerTest.php +++ b/tests/Unit/Serializer/PayFlexCPV4PosSerializerTest.php @@ -81,32 +81,32 @@ public function testEncodeException(): void public static function encodeDataProvider(): Generator { yield 'test1' => [ - 'input' => [ - 'MerchantId' => '000000000111111', - 'Password' => '3XTgER89as', - 'TransactionType' => 'Sale', - 'OrderId' => 'order222', - 'CurrencyAmount' => '100.00', - 'CurrencyCode' => '949', - 'ClientIp' => '127.0.0.1', + 'input' => [ + 'MerchantId' => '000000000111111', + 'Password' => '3XTgER89as', + 'TransactionType' => 'Sale', + 'OrderId' => 'order222', + 'CurrencyAmount' => '100.00', + 'CurrencyCode' => '949', + 'ClientIp' => '127.0.0.1', 'TransactionDeviceSource' => '0', - 'Pan' => '5555444433332222', - 'Expiry' => '202112', - 'Cvv' => '122', + 'Pan' => '5555444433332222', + 'Expiry' => '202112', + 'Cvv' => '122', ], - 'txType' => PosInterface::TX_TYPE_PAY_AUTH, + 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'expected' => [ - 'MerchantId' => '000000000111111', - 'Password' => '3XTgER89as', - 'TransactionType' => 'Sale', - 'OrderId' => 'order222', - 'CurrencyAmount' => '100.00', - 'CurrencyCode' => '949', - 'ClientIp' => '127.0.0.1', + 'MerchantId' => '000000000111111', + 'Password' => '3XTgER89as', + 'TransactionType' => 'Sale', + 'OrderId' => 'order222', + 'CurrencyAmount' => '100.00', + 'CurrencyCode' => '949', + 'ClientIp' => '127.0.0.1', 'TransactionDeviceSource' => '0', - 'Pan' => '5555444433332222', - 'Expiry' => '202112', - 'Cvv' => '122', + 'Pan' => '5555444433332222', + 'Expiry' => '202112', + 'Cvv' => '122', ], ]; } @@ -114,32 +114,42 @@ public static function encodeDataProvider(): Generator public static function encodeNonPaymentDataProvider(): Generator { yield 'test1' => [ - 'input' => [ - 'MerchantId' => '000000000111111', - 'Password' => '3XTgER89as', - 'TransactionType' => 'Sale', - 'OrderId' => 'order222', - 'CurrencyAmount' => '100.00', - 'CurrencyCode' => '949', - 'ClientIp' => '127.0.0.1', + 'input' => [ + 'MerchantId' => '000000000111111', + 'Password' => '3XTgER89as', + 'TransactionType' => 'Sale', + 'OrderId' => 'order222', + 'CurrencyAmount' => '100.00', + 'CurrencyCode' => '949', + 'ClientIp' => '127.0.0.1', 'TransactionDeviceSource' => '0', - 'Pan' => '5555444433332222', - 'Expiry' => '202112', - 'Cvv' => '122', + 'Pan' => '5555444433332222', + 'Expiry' => '202112', + 'Cvv' => '122', ], - 'txType' => PosInterface::TX_TYPE_CANCEL, + 'txType' => PosInterface::TX_TYPE_CANCEL, 'expected' => '0000000001111113XTgER89asSaleorder222100.00949127.0.0.105555444433332222202112122', ]; + + yield 'custom_query' => [ + 'input' => [ + 'MerchantId' => '000000000111111', + 'Password' => '3XTgER89as', + 'abc' => 'abc', + ], + 'txType' => PosInterface::TX_TYPE_CUSTOM_QUERY, + 'expected' => '0000000001111113XTgER89asabc', + ]; } public static function decodeExceptionDataProvider(): Generator { yield 'test1' => [ - 'input' => "Request RejectedThe requested URL was rejected. Please consult with your administrator.

Your support ID is: 11795445874629392419

[Go Back]", + 'input' => "Request RejectedThe requested URL was rejected. Please consult with your administrator.

Your support ID is: 11795445874629392419

[Go Back]", 'expected_exception_class' => \Exception::class, ]; yield 'test2' => [ - 'input' => '', + 'input' => '', 'expected_exception_class' => NotEncodableValueException::class, ]; }