From 26a6f3203288a4a467ddd27dd114a65e7cf3b65c Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 13 Apr 2024 21:47:59 +0200 Subject: [PATCH 1/6] ToslaPosResponseDataMapperTest remove unused method --- .../ToslaPosResponseDataMapperTest.php | 261 ------------------ 1 file changed, 261 deletions(-) diff --git a/tests/Unit/DataMapper/ResponseDataMapper/ToslaPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/ToslaPosResponseDataMapperTest.php index f2889f8d..b53e5fe7 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/ToslaPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/ToslaPosResponseDataMapperTest.php @@ -345,267 +345,6 @@ public static function paymentDataProvider(): iterable ]; } - - public static function threeDPaymentDataProvider(): array - { - return [ - 'threed_auth_fail1' => [ - 'threeDResponseData' => [ - 'sID' => '1', - 'oid' => '2022103076E7', - 'encoding' => 'ISO-8859-9', - 'Ecom_Payment_Card_ExpDate_Month' => '12', - 'version' => '2.0', - 'currency' => '949', - 'dsId' => '1', - 'callbackCall' => 'true', - 'amount' => '1.01', - 'maskedCreditCard' => '4355 08** **** 4358', - 'islemtipi' => 'Auth', - 'firmaadi' => 'John Doe', - 'merchantName' => 'Ziraat 3D', - 'ACQBIN' => '454672', - 'PAResSyntaxOK' => 'true', - 'Ecom_Payment_Card_ExpDate_Year' => '26', - 'storetype' => '3d', - 'mdStatus' => '0', - 'failUrl' => 'http://localhost/akbank/3d/response.php', - 'clientIp' => '89.244.149.137', - 'merchantID' => '190100000', - 'mdErrorMsg' => 'N-status/Challenge authentication via ACS: https://3ds-acs.test.modirum.com/mdpayacs/creq?token=214704671.1667119085._nUCBN9o1Wh', - 'clientid' => '190100000', - 'MaskedPan' => '435508***4358', - 'txstatus' => 'N', - 'digest' => 'digest', - 'PAResVerified' => 'true', - 'Email' => 'mail@customer.com', - 'taksit' => '', - 'okUrl' => 'http://localhost/akbank/3d/response.php', - 'md' => '435508:72240E12F06488A0D50ECB1AF842B5E939950C417D6456EA033087ED8E7FA6CE:3894:##190100000', - 'lang' => 'tr', - 'xid' => 'rIpI0Jrjzra7OF6UyD4pQZVyxpw=', - 'TRANID' => '', - 'HASH' => 'gEcAQuPX+Wriv+UJ+mNCYouzV04=', - 'rnd' => 'THlysKkGRD/Ly/z5xSKB', - 'HASHPARAMS' => 'clientid:oid:mdStatus:cavv:eci:md:rnd:', - 'HASHPARAMSVAL' => '1901000002022103076E70435508:72240E12F06488A0D50ECB1AF842B5E939950C417D6456EA033087ED8E7FA6CE:3894:##190100000THlysKkGRD/Ly/z5xSKB', - ], - 'paymentData' => [], - 'expectedData' => [ - 'transaction_security' => 'MPI fallback', - 'md_status' => '0', - 'masked_number' => '4355 08** **** 4358', - 'month' => '12', - 'year' => '26', - 'amount' => 1.01, - 'currency' => PosInterface::CURRENCY_TRY, - 'eci' => null, - 'tx_status' => null, - 'cavv' => null, - 'md_error_message' => 'N-status/Challenge authentication via ACS: https://3ds-acs.test.modirum.com/mdpayacs/creq?token=214704671.1667119085._nUCBN9o1Wh', - 'transaction_id' => null, - 'auth_code' => null, - 'ref_ret_num' => null, - 'proc_return_code' => null, - 'status' => 'declined', - 'status_detail' => null, - 'error_code' => null, - 'error_message' => null, - 'order_id' => '2022103076E7', - 'installment_count' => null, - ], - ], - 'auth_success_payment_fail' => [ - 'threeDResponseData' => [ - 'TRANID' => '', - 'PAResSyntaxOK' => 'true', - 'firmaadi' => 'John Doe', - 'islemtipi' => 'Auth', - 'lang' => 'tr', - 'merchantID' => '190100000', - 'maskedCreditCard' => '4355 08** **** 4358', - 'amount' => '1.01', - 'sID' => '1', - 'ACQBIN' => '454672', - 'Ecom_Payment_Card_ExpDate_Year' => '26', - 'Email' => 'mail@customer.com', - 'MaskedPan' => '435508***4358', - 'merchantName' => 'Ziraat 3D', - 'clientIp' => '89.244.149.137', - 'okUrl' => 'http://localhost/akbank/3d/response.php', - 'md' => '435508:9716234382F9D9B630CC01452A6F160D31A2E1DBD41706C6AF8B8E6F730FE65D:3677:##190100000', - 'taksit' => '12', - 'Ecom_Payment_Card_ExpDate_Month' => '12', - 'storetype' => '3d', - 'mdErrorMsg' => 'Y-status/Challenge authentication via ACS: https://3ds-acs.test.modirum.com/mdpayacs/creq?token=214704701.1667119495.sIHzA7ckv-0', - 'PAResVerified' => 'true', - 'cavv' => 'ABABA##################AEJI=', - 'digest' => 'digest', - 'callbackCall' => 'true', - 'failUrl' => 'http://localhost/akbank/3d/response.php', - 'xid' => '2aeoSfQde3NyV2XjSeTL0sGNYSg=', - 'encoding' => 'ISO-8859-9', - 'currency' => '949', - 'oid' => '20221030FE4C', - 'mdStatus' => '1', - 'dsId' => '1', - 'eci' => '05', - 'version' => '2.0', - 'clientid' => '190100000', - 'txstatus' => 'Y', - 'HASH' => '+NYQKADaaWWUIAIg6U77nGIK+8k=', - 'rnd' => 'IXa1XnlaOxpMCacqG/cB', - 'HASHPARAMS' => 'clientid:oid:mdStatus:cavv:eci:md:rnd:', - 'HASHPARAMSVAL' => '19010000020221030FE4C1ABABA##################AEJI=05435508:9716234382F9D9B630CC01452A6F160D31A2E1DBD41706C6AF8B8E6F730FE65D:3677:##190100000IXa1XnlaOxpMCacqG/cB', - ], - 'paymentData' => [ - 'OrderId' => '20221030FE4C', - 'GroupId' => '20221030FE4C', - 'Response' => 'Error', - 'AuthCode' => '', - 'HostRefNum' => '', - 'ProcReturnCode' => '99', - 'TransId' => '22303LtCH15933', - 'ErrMsg' => 'Taksit tablosu icin gecersiz deger', - 'Extra' => [ - 'SETTLEID' => '', - 'TRXDATE' => '20221030 11:45:02', - 'ERRORCODE' => 'CORE-2603', - 'NUMCODE' => '992603', - ], - ], - 'expectedData' => [ - 'transaction_security' => 'Full 3D Secure', - 'md_status' => '1', - 'masked_number' => '4355 08** **** 4358', - 'month' => '12', - 'year' => '26', - 'amount' => 1.01, - 'currency' => PosInterface::CURRENCY_TRY, - 'eci' => '05', - 'tx_status' => null, - 'cavv' => 'ABABA##################AEJI=', - 'md_error_message' => null, - 'group_id' => '20221030FE4C', - 'transaction_id' => '22303LtCH15933', - 'auth_code' => null, - 'ref_ret_num' => null, - 'proc_return_code' => '99', - 'status' => 'declined', - 'status_detail' => 'general_error', - 'error_code' => 'CORE-2603', - 'error_message' => 'Taksit tablosu icin gecersiz deger', - 'recurring_id' => null, - 'extra' => [ - 'SETTLEID' => null, - 'TRXDATE' => '20221030 11:45:02', - 'ERRORCODE' => 'CORE-2603', - 'NUMCODE' => '992603', - ], - 'order_id' => '20221030FE4C', - ], - ], - 'success1' => [ - 'threeDResponseData' => [ - 'TRANID' => '', - 'PAResSyntaxOK' => 'true', - 'firmaadi' => 'John Doe', - 'islemtipi' => 'Auth', - 'lang' => 'tr', - 'merchantID' => '190100000', - 'maskedCreditCard' => '4355 08** **** 4358', - 'amount' => '1.01', - 'sID' => '1', - 'ACQBIN' => '454672', - 'Ecom_Payment_Card_ExpDate_Year' => '26', - 'Email' => 'mail@customer.com', - 'MaskedPan' => '435508***4358', - 'merchantName' => 'Ziraat 3D', - 'clientIp' => '89.244.149.137', - 'okUrl' => 'http://localhost/akbank/3d/response.php', - 'md' => '435508:4328956B2D668C558B0AECFF49A883EEFF2CD4168F54758441F31C79840636B8:3827:##190100000', - 'taksit' => '', - 'Ecom_Payment_Card_ExpDate_Month' => '12', - 'storetype' => '3d', - 'mdErrorMsg' => 'Y-status/Challenge authentication via ACS: https://3ds-acs.test.modirum.com/mdpayacs/creq?token=214704801.1667119895.nGaNF3vG_bb', - 'PAResVerified' => 'true', - 'cavv' => 'ABABCSQDGQAAAABllJMDdUQAEJI=', - 'digest' => 'digest', - 'callbackCall' => 'true', - 'failUrl' => 'http://localhost/akbank/3d/response.php', - 'xid' => 'XWOb78QRZ1Re8f7i8b2ZW85cLr8=', - 'encoding' => 'ISO-8859-9', - 'currency' => '949', - 'oid' => '202210304547', - 'mdStatus' => '1', - 'dsId' => '1', - 'eci' => '05', - 'version' => '2.0', - 'clientid' => '190100000', - 'txstatus' => 'Y', - 'HASH' => 'MyL35j/zA22D90nUkW0on1k2njE=', - 'rnd' => 'yVCgrF4/9i3p9R0rQvw8', - 'HASHPARAMS' => 'clientid:oid:mdStatus:cavv:eci:md:rnd:', - 'HASHPARAMSVAL' => '1901000002022103045471ABABCSQDGQAAAABllJMDdUQAEJI=05435508:4328956B2D668C558B0AECFF49A883EEFF2CD4168F54758441F31C79840636B8:3827:##190100000yVCgrF4/9i3p9R0rQvw8', - ], - 'paymentData' => [ - 'OrderId' => '202210304547', - 'GroupId' => '202210304547', - 'Response' => 'Approved', - 'AuthCode' => '563339', - 'HostRefNum' => '230311184777', - 'ProcReturnCode' => '00', - 'TransId' => '22303LzpJ16296', - 'ErrMsg' => '', - 'Extra' => [ - 'SETTLEID' => '2400', - 'TRXDATE' => '20221030 11:51:41', - 'ERRORCODE' => '', - 'CARDBRAND' => 'VISA', - 'CARDISSUER' => 'AKBANK T.A.S.', - 'KAZANILANPUAN' => '000000010.00', - 'NUMCODE' => '00', - ], - ], - 'expectedData' => [ - 'transaction_security' => 'Full 3D Secure', - 'md_status' => '1', - 'masked_number' => '4355 08** **** 4358', - 'month' => '12', - 'year' => '26', - 'amount' => 1.01, - 'currency' => PosInterface::CURRENCY_TRY, - 'eci' => '05', - 'tx_status' => null, - 'cavv' => 'ABABCSQDGQAAAABllJMDdUQAEJI=', - 'md_error_message' => null, - 'group_id' => '202210304547', - 'transaction_id' => '22303LzpJ16296', - 'auth_code' => '563339', - 'ref_ret_num' => '230311184777', - 'proc_return_code' => '00', - 'status' => 'approved', - 'status_detail' => 'approved', - 'error_code' => null, - 'error_message' => null, - 'recurring_id' => null, - 'extra' => [ - 'SETTLEID' => '2400', - 'TRXDATE' => '20221030 11:51:41', - 'ERRORCODE' => null, - 'CARDBRAND' => 'VISA', - 'CARDISSUER' => 'AKBANK T.A.S.', - 'KAZANILANPUAN' => '000000010.00', - 'NUMCODE' => '00', - ], - 'order_id' => '202210304547', - 'installment_count' => null, - ], - ], - ]; - } - - public static function threeDPayPaymentDataProvider(): array { return [ From 60d0133db7cfad2d53cc739a87228d52e2aa5655 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 14 Apr 2024 12:21:26 +0200 Subject: [PATCH 2/6] fix crypt generateRandomString is not creating string with max length 32 --- src/Crypt/AbstractCrypt.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Crypt/AbstractCrypt.php b/src/Crypt/AbstractCrypt.php index c078a361..e43760dd 100644 --- a/src/Crypt/AbstractCrypt.php +++ b/src/Crypt/AbstractCrypt.php @@ -32,11 +32,19 @@ public function __construct(LoggerInterface $logger) * * @param int<1, max> $length * - * @return string + * @return non-empty-string */ public function generateRandomString(int $length = 24): string { - return \substr(\md5(\uniqid(\microtime())), 0, $length - 1); + $characters = '0123456789ABCDEF'; + $charactersLength = \strlen($characters); + $randomString = ''; + + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[\rand(0, $charactersLength - 1)]; + } + + return $randomString; } /** From 0f495b758481cee5d33d7151760f2190e0d7c1f7 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 21 Apr 2024 11:47:43 +0200 Subject: [PATCH 3/6] issue #191 added Akbank Pos gateway integration --- README.md | 1 + config/pos_production.php | 9 + config/pos_test.php | 115 +- docs/CANCEL-EXAMPLE.md | 32 +- docs/ORDER-HISTORY-EXAMPLE.md | 9 + docs/REFUND-EXAMPLE.md | 11 + docs/THREED-PAYMENT-EXAMPLE.md | 2 +- examples/_common-codes/3d-host/index.php | 1 + examples/_common-codes/3d/form.php | 1 + examples/_common-codes/regular/cancel.php | 36 +- examples/_common-codes/regular/form.php | 1 + .../_common-codes/regular/order_history.php | 10 + examples/_common-codes/regular/refund.php | 11 + examples/_main_config.php | 14 +- examples/_templates/_header.php | 1 + examples/akbankpos/3d-host/_config.php | 22 + examples/akbankpos/3d-host/index.php | 3 + examples/akbankpos/3d-host/response.php | 3 + examples/akbankpos/3d-pay/_config.php | 22 + examples/akbankpos/3d-pay/form.php | 3 + examples/akbankpos/3d-pay/index.php | 3 + examples/akbankpos/3d-pay/response.php | 3 + examples/akbankpos/3d/_config.php | 22 + examples/akbankpos/3d/form.php | 3 + examples/akbankpos/3d/index.php | 3 + examples/akbankpos/3d/response.php | 3 + examples/akbankpos/_payment_config.php | 17 + examples/akbankpos/index.php | 6 + examples/akbankpos/regular/_config.php | 20 + examples/akbankpos/regular/cancel.php | 3 + examples/akbankpos/regular/form.php | 3 + examples/akbankpos/regular/index.php | 3 + examples/akbankpos/regular/order_history.php | 3 + examples/akbankpos/regular/post-auth.php | 3 + examples/akbankpos/regular/refund.php | 3 + phpstan-baseline.neon | 37 +- src/Crypt/AbstractCrypt.php | 14 +- src/Crypt/AkbankPosCrypt.php | 122 + src/Crypt/CryptInterface.php | 7 +- src/Crypt/GarantiPosCrypt.php | 8 +- .../AbstractRequestDataMapper.php | 59 +- .../AkbankPosRequestDataMapper.php | 562 ++++ .../EstPosRequestDataMapper.php | 10 + .../GarantiPosRequestDataMapper.php | 10 + .../InterPosRequestDataMapper.php | 10 + .../PayFlexCPV4PosRequestDataMapper.php | 10 + .../PayFlexV4PosRequestDataMapper.php | 10 + .../PayForPosRequestDataMapper.php | 10 + .../PosNetRequestDataMapper.php | 6 +- .../PosNetV1PosRequestDataMapper.php | 14 +- .../AbstractResponseDataMapper.php | 17 +- .../AkbankPosResponseDataMapper.php | 560 ++++ .../ToslaPosResponseDataMapper.php | 2 +- src/Entity/Account/AkbankPosAccount.php | 51 + src/Factory/AccountFactory.php | 18 + src/Factory/CryptFactory.php | 3 + src/Factory/RequestDataMapperFactory.php | 3 + src/Factory/ResponseDataMapperFactory.php | 3 + src/Factory/SerializerFactory.php | 2 + src/Gateways/AkbankPos.php | 234 ++ src/Serializer/AkbankPosSerializer.php | 44 + tests/Functional/AkbankPosTest.php | 359 +++ tests/Functional/PaymentTestTrait.php | 19 +- tests/Unit/Crypt/AkbankPosCryptTest.php | 183 ++ .../AkbankPosRequestDataMapperTest.php | 961 ++++++ .../AkbankPosResponseDataMapperTest.php | 2618 +++++++++++++++++ tests/Unit/Factory/AccountFactoryTest.php | 20 + tests/Unit/Gateways/AkbankPosTest.php | 883 ++++++ tests/Unit/HttpClientTestTrait.php | 13 +- .../Serializer/AkbankPosSerializerTest.php | 73 + 70 files changed, 7232 insertions(+), 128 deletions(-) create mode 100644 examples/akbankpos/3d-host/_config.php create mode 100644 examples/akbankpos/3d-host/index.php create mode 100644 examples/akbankpos/3d-host/response.php create mode 100644 examples/akbankpos/3d-pay/_config.php create mode 100644 examples/akbankpos/3d-pay/form.php create mode 100644 examples/akbankpos/3d-pay/index.php create mode 100644 examples/akbankpos/3d-pay/response.php create mode 100644 examples/akbankpos/3d/_config.php create mode 100644 examples/akbankpos/3d/form.php create mode 100644 examples/akbankpos/3d/index.php create mode 100644 examples/akbankpos/3d/response.php create mode 100644 examples/akbankpos/_payment_config.php create mode 100644 examples/akbankpos/index.php create mode 100644 examples/akbankpos/regular/_config.php create mode 100644 examples/akbankpos/regular/cancel.php create mode 100644 examples/akbankpos/regular/form.php create mode 100644 examples/akbankpos/regular/index.php create mode 100644 examples/akbankpos/regular/order_history.php create mode 100644 examples/akbankpos/regular/post-auth.php create mode 100644 examples/akbankpos/regular/refund.php create mode 100644 src/Crypt/AkbankPosCrypt.php create mode 100644 src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php create mode 100644 src/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapper.php create mode 100644 src/Entity/Account/AkbankPosAccount.php create mode 100644 src/Gateways/AkbankPos.php create mode 100644 src/Serializer/AkbankPosSerializer.php create mode 100644 tests/Functional/AkbankPosTest.php create mode 100644 tests/Unit/Crypt/AkbankPosCryptTest.php create mode 100644 tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php create mode 100644 tests/Unit/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapperTest.php create mode 100644 tests/Unit/Gateways/AkbankPosTest.php create mode 100644 tests/Unit/Serializer/AkbankPosSerializerTest.php diff --git a/README.md b/README.md index c852a60d..a089abf4 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ sistemlerinin kullanılabilmesidir. | Gateway | Desktekleyen
bankalar | Desteklenen
Ödeme Tipleri | Desteklenen Sorgular | |-------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|---------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------| | Tosla (AKÖde) | ? | NonSecure
3DPay
3DHost | İptal
İade
Durum sorgulama
Sipariş Tarihçesini sorgulama | +| AkbankPos | Akbank | NonSecure
3DSecur
3DPay
3DHost
Tekrarlanan Ödeme | İptal
İade
Sipariş Tarihçesini 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
İşbank | NonSecure
3DSecure
Tekrarlanan Ödeme | İptal
İade
Durum sorgulama | diff --git a/config/pos_production.php b/config/pos_production.php index 0f67ce60..ded5e3a4 100644 --- a/config/pos_production.php +++ b/config/pos_production.php @@ -4,6 +4,15 @@ */ return [ 'banks' => [ + 'akbank-pos' => [ + 'name' => 'AKBANK T.A.S.', + 'class' => Mews\Pos\Gateways\AkbankPos::class, + 'gateway_endpoints' => [ + 'payment_api' => 'https://api.akbank.com/api/v1/payment/virtualpos', + 'gateway_3d' => 'https://virtualpospaymentgateway.akbank.com/securepay', + 'gateway_3d_host' => 'https://virtualpospaymentgateway.akbank.com/payhosting', + ], + ], 'akbankv3' => [ 'name' => 'AKBANK T.A.S.', 'class' => Mews\Pos\Gateways\EstV3Pos::class, diff --git a/config/pos_test.php b/config/pos_test.php index eb706c0a..f0e7b0fa 100644 --- a/config/pos_test.php +++ b/config/pos_test.php @@ -2,104 +2,113 @@ return [ 'banks' => [ + 'akbank-pos' => [ + 'name' => 'AKBANK T.A.S.', + 'class' => Mews\Pos\Gateways\AkbankPos::class, + 'gateway_endpoints' => [ + 'payment_api' => 'https://apipre.akbank.com/api/v1/payment/virtualpos', + 'gateway_3d' => 'https://virtualpospaymentgatewaypre.akbank.com/securepay', + 'gateway_3d_host' => 'https://virtualpospaymentgatewaypre.akbank.com/payhosting', + ], + ], 'akbankv3' => [ - 'name' => 'AKBANK T.A.S.', - 'class' => Mews\Pos\Gateways\EstV3Pos::class, - 'gateway_endpoints' => [ - 'payment_api' => 'https://entegrasyon.asseco-see.com.tr/fim/api', - 'gateway_3d' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate', + 'name' => 'AKBANK T.A.S.', + 'class' => Mews\Pos\Gateways\EstPos::class, + 'gateway_endpoints' => [ + 'payment_api' => 'https://entegrasyon.asseco-see.com.tr/fim/api', + 'gateway_3d' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate', ], ], 'akbank' => [ - 'name' => 'AKBANK T.A.S.', - 'class' => Mews\Pos\Gateways\EstPos::class, - 'gateway_endpoints' => [ - 'payment_api' => 'https://entegrasyon.asseco-see.com.tr/fim/api', - 'gateway_3d' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate', + 'name' => 'AKBANK T.A.S.', + 'class' => Mews\Pos\Gateways\EstPos::class, + 'gateway_endpoints' => [ + 'payment_api' => 'https://entegrasyon.asseco-see.com.tr/fim/api', + 'gateway_3d' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate', ], ], - 'tosla' => [ - 'name' => 'AkÖde A.Ş.', - 'class' => Mews\Pos\Gateways\ToslaPos::class, - 'gateway_endpoints' => [ + 'tosla' => [ + 'name' => 'AkÖde A.Ş.', + 'class' => Mews\Pos\Gateways\ToslaPos::class, + 'gateway_endpoints' => [ 'payment_api' => 'https://prepentegrasyon.tosla.com/api/Payment', 'gateway_3d' => 'https://prepentegrasyon.tosla.com/api/Payment/ProcessCardForm', 'gateway_3d_host' => 'https://prepentegrasyon.tosla.com/api/Payment/threeDSecure', ], ], 'yapikredi' => [ - 'name' => 'Yapıkredi', - 'class' => Mews\Pos\Gateways\PosNet::class, - 'gateway_endpoints' => [ - 'payment_api' => 'https://setmpos.ykb.com/PosnetWebService/XML', - 'gateway_3d' => 'https://setmpos.ykb.com/3DSWebService/YKBPaymentService', + 'name' => 'Yapıkredi', + 'class' => Mews\Pos\Gateways\PosNet::class, + 'gateway_endpoints' => [ + 'payment_api' => 'https://setmpos.ykb.com/PosnetWebService/XML', + 'gateway_3d' => 'https://setmpos.ykb.com/3DSWebService/YKBPaymentService', ], ], 'albaraka' => [ - 'name' => 'Albaraka', - 'class' => Mews\Pos\Gateways\PosNetV1Pos::class, - 'gateway_endpoints' => [ - 'payment_api' => 'https://epostest.albarakaturk.com.tr/ALBMerchantService/MerchantJSONAPI.svc', - 'gateway_3d' => 'https://epostest.albarakaturk.com.tr/ALBSecurePaymentUI/SecureProcess/SecureVerification.aspx', + 'name' => 'Albaraka', + 'class' => Mews\Pos\Gateways\PosNetV1Pos::class, + 'gateway_endpoints' => [ + 'payment_api' => 'https://epostest.albarakaturk.com.tr/ALBMerchantService/MerchantJSONAPI.svc', + 'gateway_3d' => 'https://epostest.albarakaturk.com.tr/ALBSecurePaymentUI/SecureProcess/SecureVerification.aspx', ], ], 'garanti' => [ - 'name' => 'Garanti', - 'class' => Mews\Pos\Gateways\GarantiPos::class, - 'gateway_endpoints' => [ - 'payment_api' => 'https://sanalposprovtest.garantibbva.com.tr/VPServlet', - 'gateway_3d' => 'https://sanalposprovtest.garantibbva.com.tr/servlet/gt3dengine', + 'name' => 'Garanti', + 'class' => Mews\Pos\Gateways\GarantiPos::class, + 'gateway_endpoints' => [ + 'payment_api' => 'https://sanalposprovtest.garantibbva.com.tr/VPServlet', + 'gateway_3d' => 'https://sanalposprovtest.garantibbva.com.tr/servlet/gt3dengine', ], ], 'qnbfinansbank-payfor' => [ - 'name' => 'QNBFinansbank-PayFor', - 'class' => Mews\Pos\Gateways\PayForPos::class, - 'gateway_endpoints' => [ + 'name' => 'QNBFinansbank-PayFor', + 'class' => Mews\Pos\Gateways\PayForPos::class, + 'gateway_endpoints' => [ 'payment_api' => 'https://vpostest.qnbfinansbank.com/Gateway/XMLGate.aspx', 'gateway_3d' => 'https://vpostest.qnbfinansbank.com/Gateway/Default.aspx', 'gateway_3d_host' => 'https://vpostest.qnbfinansbank.com/Gateway/3DHost.aspx', ], ], 'vakifbank' => [ - 'name' => 'VakifBank-VPOS', - 'class' => Mews\Pos\Gateways\PayFlexV4Pos::class, - 'gateway_endpoints' => [ - 'payment_api' => 'https://onlineodemetest.vakifbank.com.tr:4443/VposService/v3/Vposreq.aspx', - 'gateway_3d' => 'https://3dsecuretest.vakifbank.com.tr:4443/MPIAPI/MPI_Enrollment.aspxs', - 'query_api' => 'https://sanalpos.vakifbank.com.tr/v4/UIWebService/Search.aspx', // todo update with the correct one + 'name' => 'VakifBank-VPOS', + 'class' => Mews\Pos\Gateways\PayFlexV4Pos::class, + 'gateway_endpoints' => [ + 'payment_api' => 'https://onlineodemetest.vakifbank.com.tr:4443/VposService/v3/Vposreq.aspx', + 'gateway_3d' => 'https://3dsecuretest.vakifbank.com.tr:4443/MPIAPI/MPI_Enrollment.aspxs', + 'query_api' => 'https://sanalpos.vakifbank.com.tr/v4/UIWebService/Search.aspx', // todo update with the correct one ], ], 'ziraat-vpos' => [ - 'name' => 'Ziraat Bankası', - 'class' => Mews\Pos\Gateways\PayFlexV4Pos::class, - 'gateway_endpoints' => [ - 'payment_api' => 'https://preprod.payflex.com.tr/Ziraatbank/VposWeb/v3/Vposreq.aspx', - 'gateway_3d' => 'https://preprod.payflex.com.tr/ZiraatBank/MpiWeb/MPI_Enrollment.aspx', - 'query_api' => 'https://sanalpos.ziraatbank.com.tr/v4/UIWebService/Search.aspx', + 'name' => 'Ziraat Bankası', + 'class' => Mews\Pos\Gateways\PayFlexV4Pos::class, + 'gateway_endpoints' => [ + 'payment_api' => 'https://preprod.payflex.com.tr/Ziraatbank/VposWeb/v3/Vposreq.aspx', + 'gateway_3d' => 'https://preprod.payflex.com.tr/ZiraatBank/MpiWeb/MPI_Enrollment.aspx', + 'query_api' => 'https://sanalpos.ziraatbank.com.tr/v4/UIWebService/Search.aspx', ], ], 'vakifbank-cp' => [ - 'name' => 'VakifBank-PayFlex-Common-Payment', - 'class' => Mews\Pos\Gateways\PayFlexCPV4Pos::class, - 'gateway_endpoints' => [ + 'name' => 'VakifBank-PayFlex-Common-Payment', + 'class' => Mews\Pos\Gateways\PayFlexCPV4Pos::class, + 'gateway_endpoints' => [ 'payment_api' => 'https://cptest.vakifbank.com.tr/CommonPayment/api/RegisterTransaction', 'gateway_3d' => 'https://cptest.vakifbank.com.tr/CommonPayment/api/VposTransaction', 'query_api' => 'https://cptest.vakifbank.com.tr/CommonPayment/SecurePayment', ], ], 'denizbank' => [ - 'name' => 'DenizBank-InterPos', - 'class' => Mews\Pos\Gateways\InterPos::class, - 'gateway_endpoints' => [ + 'name' => 'DenizBank-InterPos', + 'class' => Mews\Pos\Gateways\InterPos::class, + 'gateway_endpoints' => [ 'payment_api' => 'https://test.inter-vpos.com.tr/mpi/Default.aspx', 'gateway_3d' => 'https://test.inter-vpos.com.tr/mpi/Default.aspx', 'gateway_3d_host' => 'https://test.inter-vpos.com.tr/mpi/3DHost.aspx', ], ], 'kuveytpos' => [ - 'name' => 'kuveyt-pos', - 'class' => Mews\Pos\Gateways\KuveytPos::class, - 'gateway_endpoints' => [ + 'name' => 'kuveyt-pos', + 'class' => Mews\Pos\Gateways\KuveytPos::class, + 'gateway_endpoints' => [ 'payment_api' => 'https://boatest.kuveytturk.com.tr/boa.virtualpos.services/Home/ThreeDModelProvisionGate', 'gateway_3d' => 'https://boatest.kuveytturk.com.tr/boa.virtualpos.services/Home/ThreeDModelPayGate', 'query_api' => 'https://boatest.kuveytturk.com.tr/BOA.Integration.WCFService/BOA.Integration.VirtualPos/VirtualPosService.svc?wsdl', diff --git a/docs/CANCEL-EXAMPLE.md b/docs/CANCEL-EXAMPLE.md index 6d0e68f1..5cc3961a 100644 --- a/docs/CANCEL-EXAMPLE.md +++ b/docs/CANCEL-EXAMPLE.md @@ -79,13 +79,33 @@ function createCancelOrder(string $gatewayClass, array $lastResponse, string $ip } - if (isset($lastResponse['recurring_id']) - && \Mews\Pos\Gateways\EstPos::class === $gatewayClass || \Mews\Pos\Gateways\EstV3Pos::class === $gatewayClass - ) { + if (isset($lastResponse['recurring_id'])) { // tekrarlanan odemeyi iptal etmek icin: - $cancelOrder = [ - 'recurringOrderInstallmentNumber' => 1, // hangi taksidi iptal etmek istiyoruz? - ]; + if (\Mews\Pos\Gateways\EstPos::class === $gatewayClass || \Mews\Pos\Gateways\EstV3Pos::class === $gatewayClass) { + $cancelOrder += [ + 'recurringOrderInstallmentNumber' => 1, // hangi taksidi iptal etmek istiyoruz? + ]; + } elseif (\Mews\Pos\Gateways\AkbankPos::class === $gatewayClass) { + // odemesi gerceklesmis recurring taksidin iptali: +// $cancelOrder += [ +// 'recurring_id' => $lastResponse['recurring_id'], +// 'recurringOrderInstallmentNumber' => 1, +// ]; + + // odemesi henuz gerceklesmemis recurring taksidin iptali: + $cancelOrder += [ + 'recurring_id' => $lastResponse['recurring_id'], + 'recurringOrderInstallmentNumber' => 2, + 'recurring_payment_is_pending' => true, + ]; + + // odemesi henuz gerceklesmemis recurring işlem talimatlarının tamamı iptal edilmek isteniyorsa +// $cancelOrder += [ +// 'recurring_id' => $lastResponse['recurring_id'], +// 'recurringOrderInstallmentNumber' => null, +// 'recurring_payment_is_pending' => true, +// ]; + } } return $cancelOrder; diff --git a/docs/ORDER-HISTORY-EXAMPLE.md b/docs/ORDER-HISTORY-EXAMPLE.md index a94f5f28..064bbcd3 100644 --- a/docs/ORDER-HISTORY-EXAMPLE.md +++ b/docs/ORDER-HISTORY-EXAMPLE.md @@ -50,6 +50,15 @@ function createOrderHistoryOrder(string $gatewayClass, array $lastResponse): arr $order = [ 'id' => $lastResponse['order_id'], ]; + } elseif (\Mews\Pos\Gateways\AkbankPos::class === $gatewayClass) { + if (isset($lastResponse['recurring_id'])) { + $order = [ + 'recurring_id' => $lastResponse['recurring_id'], + ]; + } else { + $order = [ + 'id' => $lastResponse['order_id'], + ]; } elseif (ToslaPos::class === $gatewayClass) { $order = [ 'id' => $lastResponse['order_id'], diff --git a/docs/REFUND-EXAMPLE.md b/docs/REFUND-EXAMPLE.md index 6ef7bbf7..704aa488 100644 --- a/docs/REFUND-EXAMPLE.md +++ b/docs/REFUND-EXAMPLE.md @@ -74,6 +74,17 @@ function createRefundOrder(string $gatewayClass, array $lastResponse, string $ip $refundOrder['payment_model'] = $lastResponse['payment_model']; } + if (isset($lastResponse['recurring_id'])) { + // tekrarlanan odemeyi iade etmek icin: + if (\Mews\Pos\Gateways\AkbankPos::class === $gatewayClass) { + // odemesi gerceklesmis recurring taksidinin iadesi: + $refundOrder += [ + 'recurring_id' => $lastResponse['recurring_id'], + 'recurringOrderInstallmentNumber' => 1, + ]; + } + } + return $refundOrder; } diff --git a/docs/THREED-PAYMENT-EXAMPLE.md b/docs/THREED-PAYMENT-EXAMPLE.md index 83be25be..87fed48f 100644 --- a/docs/THREED-PAYMENT-EXAMPLE.md +++ b/docs/THREED-PAYMENT-EXAMPLE.md @@ -80,7 +80,7 @@ $order = [ ]; if ($tekrarlanan = false) { // recurring payments - // Desteleyen Gatewayler: GarantiPos, EstPos, EstV3Pos, PayFlexV4 + // Desteleyen Gatewayler: GarantiPos, EstPos, EstV3Pos, PayFlexV4, AkbankPos $order['installment'] = 0; // Tekrarlayan ödemeler taksitli olamaz. $recurringFrequency = 3; diff --git a/examples/_common-codes/3d-host/index.php b/examples/_common-codes/3d-host/index.php index 43091f5b..22a736ff 100644 --- a/examples/_common-codes/3d-host/index.php +++ b/examples/_common-codes/3d-host/index.php @@ -11,6 +11,7 @@ require '../../_templates/_header.php'; $order = getNewOrder( + $pos, $baseUrl, $ip, $request->get('currency', PosInterface::CURRENCY_TRY), diff --git a/examples/_common-codes/3d/form.php b/examples/_common-codes/3d/form.php index 250f7841..b77d0cfa 100644 --- a/examples/_common-codes/3d/form.php +++ b/examples/_common-codes/3d/form.php @@ -22,6 +22,7 @@ } $transaction = $request->get('tx', PosInterface::TX_TYPE_PAY_AUTH); $order = getNewOrder( + $pos, $baseUrl, $ip, $request->get('currency', PosInterface::CURRENCY_TRY), diff --git a/examples/_common-codes/regular/cancel.php b/examples/_common-codes/regular/cancel.php index bcf01023..6b230c23 100644 --- a/examples/_common-codes/regular/cancel.php +++ b/examples/_common-codes/regular/cancel.php @@ -26,8 +26,8 @@ function createCancelOrder(string $gatewayClass, array $lastResponse, string $ip $cancelOrder['transaction_id'] = $lastResponse['transaction_id']; $cancelOrder['amount'] = $lastResponse['amount']; } elseif (\Mews\Pos\Gateways\VakifKatilimPos::class === $gatewayClass) { - $cancelOrder['remote_order_id'] = $lastResponse['remote_order_id']; // banka tarafındaki order id - $cancelOrder['amount'] = $lastResponse['amount']; + $cancelOrder['remote_order_id'] = $lastResponse['remote_order_id']; // banka tarafındaki order id + $cancelOrder['amount'] = $lastResponse['amount']; // on otorizasyon islemin iptali icin PosInterface::TX_TYPE_PAY_PRE_AUTH saglanmasi gerekiyor $cancelOrder['transaction_type'] = $lastResponse['transaction_type'] ?? PosInterface::TX_TYPE_PAY_AUTH; } elseif (\Mews\Pos\Gateways\PayFlexV4Pos::class === $gatewayClass || \Mews\Pos\Gateways\PayFlexCPV4Pos::class === $gatewayClass) { @@ -45,13 +45,33 @@ function createCancelOrder(string $gatewayClass, array $lastResponse, string $ip } - if (isset($lastResponse['recurring_id']) - && (\Mews\Pos\Gateways\EstPos::class === $gatewayClass || \Mews\Pos\Gateways\EstV3Pos::class === $gatewayClass) - ) { + if (isset($lastResponse['recurring_id'])) { // tekrarlanan odemeyi iptal etmek icin: - $cancelOrder = [ - 'recurringOrderInstallmentNumber' => 1, // hangi taksidi iptal etmek istiyoruz? - ]; + if (\Mews\Pos\Gateways\EstPos::class === $gatewayClass || \Mews\Pos\Gateways\EstV3Pos::class === $gatewayClass) { + $cancelOrder += [ + 'recurringOrderInstallmentNumber' => 1, // hangi taksidi iptal etmek istiyoruz? + ]; + } elseif (\Mews\Pos\Gateways\AkbankPos::class === $gatewayClass) { + // odemesi gerceklesmis recurring taksidin iptali: +// $cancelOrder += [ +// 'recurring_id' => $lastResponse['recurring_id'], +// 'recurringOrderInstallmentNumber' => 1, +// ]; + + // odemesi henuz gerceklesmemis recurring taksidin iptali: + $cancelOrder += [ + 'recurring_id' => $lastResponse['recurring_id'], + 'recurringOrderInstallmentNumber' => 2, + 'recurring_payment_is_pending' => true, + ]; + + // odemesi henuz gerceklesmemis recurring işlem talimatlarının tamamı iptal edilmek isteniyorsa +// $cancelOrder += [ +// 'recurring_id' => $lastResponse['recurring_id'], +// 'recurringOrderInstallmentNumber' => null, +// 'recurring_payment_is_pending' => true, +// ]; + } } return $cancelOrder; diff --git a/examples/_common-codes/regular/form.php b/examples/_common-codes/regular/form.php index de0dc86b..39b73cd8 100644 --- a/examples/_common-codes/regular/form.php +++ b/examples/_common-codes/regular/form.php @@ -9,6 +9,7 @@ $transaction = $request->get('tx', PosInterface::TX_TYPE_PAY_AUTH); $order = getNewOrder( + $pos, $baseUrl, $ip, $request->get('currency', PosInterface::CURRENCY_TRY), diff --git a/examples/_common-codes/regular/order_history.php b/examples/_common-codes/regular/order_history.php index 538e77b0..2aa37669 100644 --- a/examples/_common-codes/regular/order_history.php +++ b/examples/_common-codes/regular/order_history.php @@ -22,6 +22,16 @@ function createOrderHistoryOrder(string $gatewayClass, array $lastResponse): arr $order = [ 'id' => $lastResponse['order_id'], ]; + } elseif (\Mews\Pos\Gateways\AkbankPos::class === $gatewayClass) { + if (isset($lastResponse['recurring_id'])) { + $order = [ + 'recurring_id' => $lastResponse['recurring_id'], + ]; + } else { + $order = [ + 'id' => $lastResponse['order_id'], + ]; + } } elseif (ToslaPos::class === $gatewayClass) { $order = [ 'id' => $lastResponse['order_id'], diff --git a/examples/_common-codes/regular/refund.php b/examples/_common-codes/regular/refund.php index c1e70b00..2d87af83 100644 --- a/examples/_common-codes/regular/refund.php +++ b/examples/_common-codes/regular/refund.php @@ -41,6 +41,17 @@ function createRefundOrder(string $gatewayClass, array $lastResponse, string $ip $refundOrder['payment_model'] = $lastResponse['payment_model']; } + if (isset($lastResponse['recurring_id'])) { + // tekrarlanan odemeyi iade etmek icin: + if (\Mews\Pos\Gateways\AkbankPos::class === $gatewayClass) { + // odemesi gerceklesmis recurring taksidinin iadesi: + $refundOrder += [ + 'recurring_id' => $lastResponse['recurring_id'], + 'recurringOrderInstallmentNumber' => 1, + ]; + } + } + return $refundOrder; } diff --git a/examples/_main_config.php b/examples/_main_config.php index 3317ca2d..73f2798a 100644 --- a/examples/_main_config.php +++ b/examples/_main_config.php @@ -1,5 +1,6 @@ start(); $hostUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http')."://$_SERVER[HTTP_HOST]"; +//$hostUrl .= '/pos/examples'; $subMenu = []; $handler = new \Monolog\Handler\StreamHandler(__DIR__.'/../var/log/pos.log', \Psr\Log\LogLevel::DEBUG); @@ -106,6 +108,7 @@ function createCard(PosInterface $pos, array $card): \Mews\Pos\Entity\Card\Credi } function getNewOrder( + PosInterface $pos, string $baseUrl, string $ip, string $currency = PosInterface::CURRENCY_TRY, @@ -117,11 +120,16 @@ function getNewOrder( $successUrl = $baseUrl.'response.php'; $failUrl = $baseUrl.'response.php'; - $orderId = date('Ymd').strtoupper(substr(uniqid(sha1(time())), 0, 4)); + if ($tekrarlanan && get_class($pos) === AkbankPos::class) { + // AkbankPos'ta recurring odemede orderTrackId/orderId en az 36 karakter olmasi gerekiyor + $orderId = date('Ymd').strtoupper(substr(uniqid(sha1(time())), 0, 28)); + } else { + $orderId = date('Ymd').strtoupper(substr(uniqid(sha1(time())), 0, 4)); + } $order = [ 'id' => $orderId, - 'amount' => 1.01, + 'amount' => 10.01, 'currency' => $currency, 'installment' => $installment, 'ip' => filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ? $ip : '127.0.0.1', @@ -137,7 +145,7 @@ function getNewOrder( } if ($tekrarlanan) { - // Desteleyen Gatewayler: GarantiPos, EstPos, PayFlexV4 + // Desteleyen Gatewayler: GarantiPos, EstPos, PayFlexV4, AkbankPos $order['installment'] = 0; // Tekrarlayan ödemeler taksitli olamaz. diff --git a/examples/_templates/_header.php b/examples/_templates/_header.php index a4989a6a..e6ea1387 100644 --- a/examples/_templates/_header.php +++ b/examples/_templates/_header.php @@ -29,6 +29,7 @@