From d076b4d47505ef2defd565741d91f359b37edfb3 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra Date: Wed, 4 Mar 2020 09:28:24 +0200 Subject: [PATCH 1/7] MC-30395: De-couple Worldpay payment methods integrations from core in 2.4.0 --- app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml index 9ff952d04925d..64a3af472faa6 100644 --- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml +++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml @@ -62,10 +62,6 @@ authorizenet_directpost PAYMENT_CARD - - worldpay - PAYMENT_CARD - eway PAYMENT_CARD From d255b7d55bf7f759869a9074bd3cf4a77ca2b406 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra Date: Wed, 4 Mar 2020 09:39:55 +0200 Subject: [PATCH 2/7] MC-30394: De-couple eWay payment methods integrations from core in 2.4.0 --- app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml index 9ff952d04925d..23e0d6b07dfda 100644 --- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml +++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml @@ -66,10 +66,6 @@ worldpay PAYMENT_CARD - - eway - PAYMENT_CARD - cybersource PAYMENT_CARD From 87b561fdc2c2d41b426179fc8f51136eb9fd04de Mon Sep 17 00:00:00 2001 From: Myroslav Dobra Date: Wed, 4 Mar 2020 09:55:21 +0200 Subject: [PATCH 3/7] MC-30393: De-couple Cybersource payment methods integrations from core in 2.4.0 --- app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml index 9ff952d04925d..0cec7082fb4e3 100644 --- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml +++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml @@ -70,10 +70,6 @@ eway PAYMENT_CARD - - cybersource - PAYMENT_CARD - free FREE From ee783ac71321949cab64a5b7155f385df1403982 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra Date: Thu, 26 Mar 2020 15:07:34 +0200 Subject: [PATCH 4/7] MC-31296: Remove Signifyd code from Magento core --- app/code/Magento/Backend/README.md | 1 - .../InContext/Minicart/SmartButton.php | 2 + .../express/in-context/component.phtml | 11 +- .../Api/CaseCreationServiceInterface.php | 29 -- .../Signifyd/Api/CaseManagementInterface.php | 36 -- .../Signifyd/Api/CaseRepositoryInterface.php | 60 --- .../Signifyd/Api/Data/CaseInterface.php | 235 --------- .../Api/Data/CaseSearchResultsInterface.php | 34 -- .../GuaranteeCancelingServiceInterface.php | 27 -- .../Api/GuaranteeCreationServiceInterface.php | 27 -- .../Signifyd/Block/Adminhtml/CaseInfo.php | 120 ----- .../System/Config/Field/WebhookUrl.php | 60 --- .../Adminhtml/System/Config/Fieldset/Info.php | 31 -- .../Magento/Signifyd/Block/Fingerprint.php | 92 ---- .../Signifyd/Controller/Webhooks/Handler.php | 157 ------ app/code/Magento/Signifyd/LICENSE.txt | 48 -- app/code/Magento/Signifyd/LICENSE_AFL.txt | 48 -- .../Magento/Signifyd/Model/CaseEntity.php | 249 ---------- .../Magento/Signifyd/Model/CaseManagement.php | 93 ---- .../Magento/Signifyd/Model/CaseRepository.php | 134 ------ .../Signifyd/Model/CaseSearchResults.php | 18 - .../Model/CaseServices/CreationService.php | 101 ---- .../CaseServices/StubUpdatingService.php | 23 - .../Model/CaseServices/UpdatingService.php | 119 ----- .../CaseServices/UpdatingServiceFactory.php | 78 --- .../CaseServices/UpdatingServiceInterface.php | 23 - .../Signifyd/Model/CommentsHistoryUpdater.php | 65 --- app/code/Magento/Signifyd/Model/Config.php | 101 ---- .../Magento/Signifyd/Model/CustomerOrders.php | 173 ------- .../Guarantee/CancelGuaranteeAbility.php | 84 ---- .../Model/Guarantee/CancelingService.php | 94 ---- .../Guarantee/CreateGuaranteeAbility.php | 124 ----- .../Model/Guarantee/CreationService.php | 97 ---- .../Model/MessageGenerators/CaseRescore.php | 51 -- .../MessageGenerators/GeneratorException.php | 19 - .../MessageGenerators/GeneratorFactory.php | 112 ----- .../MessageGenerators/GeneratorInterface.php | 21 - .../MessageGenerators/PatternGenerator.php | 56 --- .../Signifyd/Model/OrderStateService.php | 119 ----- .../PaymentMethodMapper.php | 40 -- .../XmlToArrayConfigConverter.php | 88 ---- .../Model/PaymentVerificationFactory.php | 109 ----- .../Model/PredefinedVerificationCode.php | 37 -- .../QuoteSession/Adminhtml/BackendSession.php | 40 -- .../Model/QuoteSession/FrontendSession.php | 39 -- .../QuoteSession/QuoteSessionInterface.php | 19 - .../Model/ResourceModel/CaseEntity.php | 22 - .../ResourceModel/CaseEntity/Collection.php | 24 - .../NotSyncedOrderIdListProvider.php | 54 --- .../Model/SalesOrderGrid/OrderGridUpdater.php | 55 --- .../SignifydGateway/ApiCallException.php | 39 -- .../Model/SignifydGateway/ApiClient.php | 49 -- .../Client/HttpClientFactory.php | 146 ------ .../SignifydGateway/Client/RequestBuilder.php | 63 --- .../SignifydGateway/Client/RequestSender.php | 74 --- .../Client/ResponseHandler.php | 124 ----- .../SignifydGateway/Debugger/BlackHole.php | 33 -- .../Debugger/DebuggerFactory.php | 58 --- .../Debugger/DebuggerInterface.php | 35 -- .../Model/SignifydGateway/Debugger/Log.php | 146 ------ .../Model/SignifydGateway/Gateway.php | 225 --------- .../SignifydGateway/GatewayException.php | 14 - .../Request/AddressBuilder.php | 46 -- .../SignifydGateway/Request/CardBuilder.php | 56 --- .../Request/ClientVersionBuilder.php | 50 -- .../Request/CreateCaseBuilder.php | 131 ----- .../Request/CreateCaseBuilderInterface.php | 22 - .../Request/PurchaseBuilder.php | 227 --------- .../Request/RecipientBuilder.php | 55 --- .../SignifydGateway/Request/SellerBuilder.php | 136 ------ .../Request/UserAccountBuilder.php | 100 ---- .../Response/WebhookMessage.php | 64 --- .../Response/WebhookMessageReader.php | 65 --- .../Response/WebhookRequest.php | 58 --- .../Response/WebhookRequestValidator.php | 113 ----- .../Signifyd/Model/SignifydOrderSessionId.php | 39 -- .../Magento/Signifyd/Observer/PlaceOrder.php | 112 ----- .../Magento/Signifyd/Plugin/OrderPlugin.php | 52 -- .../Magento/Signifyd/Plugin/PaymentPlugin.php | 67 --- app/code/Magento/Signifyd/README.md | 78 --- .../Magento/Signifyd/Test/Mftf/LICENSE.txt | 48 -- .../Signifyd/Test/Mftf/LICENSE_AFL.txt | 48 -- .../Mftf/Page/AdminFraudProtectionPage.xml | 14 - app/code/Magento/Signifyd/Test/Mftf/README.md | 3 - .../AdminSignifydConfigurationSection.xml | 16 - ...gnifydConfigDependentOnActiveFieldTest.xml | 34 -- .../Unit/Block/Adminhtml/CaseInfoTest.php | 150 ------ .../Unit/Controller/Webhooks/HandlerTest.php | 374 --------------- .../UpdatingServiceFactoryTest.php | 167 ------- .../CaseServices/UpdatingServiceTest.php | 316 ------------ .../Unit/Model/CommentsHistoryUpdaterTest.php | 176 ------- .../Test/Unit/Model/CustomerOrdersTest.php | 267 ----------- .../Guarantee/CancelGuaranteeAbilityTest.php | 154 ------ .../Model/Guarantee/CancelingServiceTest.php | 215 --------- .../Guarantee/CreateGuaranteeAbilityTest.php | 260 ---------- .../Model/Guarantee/CreationServiceTest.php | 253 ---------- .../MessageGenerators/CaseRescoreTest.php | 148 ------ .../GeneratorFactoryTest.php | 99 ---- .../PatternGeneratorTest.php | 83 ---- .../Test/Unit/Model/OrderStateServiceTest.php | 204 -------- .../XmlToArrayConfigConverterTest.php | 76 --- .../_files/expected_array.php | 12 - .../_files/signifyd_payment_mapping.xml | 32 -- .../Model/PaymentVerificationFactoryTest.php | 222 --------- .../SalesOrderGrid/OrderGridUpdaterTest.php | 72 --- .../Client/HttpClientFactoryTest.php | 131 ----- .../Client/ResponseHandlerTest.php | 182 ------- .../Model/SignifydGateway/GatewayTest.php | 448 ------------------ .../Response/WebhookMessageReaderTest.php | 114 ----- .../Response/WebhookRequestValidatorTest.php | 231 --------- .../Unit/Model/SignifydOrderSessionIdTest.php | 60 --- .../Test/Unit/Observer/PlaceOrderTest.php | 284 ----------- .../Listing/Column/Guarantee/Options.php | 56 --- app/code/Magento/Signifyd/composer.json | 35 -- app/code/Magento/Signifyd/etc/acl.xml | 22 - .../Magento/Signifyd/etc/adminhtml/di.xml | 10 - .../Magento/Signifyd/etc/adminhtml/routes.xml | 14 - .../Magento/Signifyd/etc/adminhtml/system.xml | 77 --- app/code/Magento/Signifyd/etc/config.xml | 19 - app/code/Magento/Signifyd/etc/db_schema.xml | 43 -- .../Signifyd/etc/db_schema_whitelist.json | 28 -- app/code/Magento/Signifyd/etc/di.xml | 105 ---- app/code/Magento/Signifyd/etc/events.xml | 18 - app/code/Magento/Signifyd/etc/frontend/di.xml | 10 - .../Magento/Signifyd/etc/frontend/routes.xml | 14 - app/code/Magento/Signifyd/etc/module.xml | 20 - .../Signifyd/etc/signifyd_payment_mapping.xml | 82 ---- .../Signifyd/etc/signifyd_payment_mapping.xsd | 34 -- app/code/Magento/Signifyd/i18n/en_US.csv | 46 -- app/code/Magento/Signifyd/registration.php | 9 - .../adminhtml/layout/sales_order_view.xml | 14 - .../view/adminhtml/templates/case_info.phtml | 31 -- .../ui_component/sales_order_grid.xml | 20 - .../view/adminhtml/web/images/logo.png | Bin 5218 -> 0 bytes .../view/adminhtml/web/js/request-send.js | 24 - .../frontend/layout/checkout_cart_index.xml | 14 - .../frontend/layout/checkout_index_index.xml | 14 - .../view/frontend/templates/fingerprint.phtml | 16 - .../web/css/source/_module.less | 7 - .../web/css/source/module/_config.less | 25 - .../web/css/source/module/_order.less | 23 - composer.json | 1 - composer.lock | 8 +- dev/tests/functional/credentials.xml.dist | 2 - .../etc/repository_replacer_payments.xml | 7 - .../Test/Block/Adminhtml/Order/Grid.php | 33 -- .../Adminhtml/Order/View/FraudProtection.php | 31 -- .../Test/Block/SignifydConsole/CaseInfo.php | 245 ---------- .../Test/Block/SignifydConsole/CaseSearch.php | 119 ----- .../Block/SignifydConsole/SignifydLogin.php | 64 --- .../Test/Block/SignifydConsole/Webhooks.php | 216 --------- ...tingSignifydGuaranteeInCommentsHistory.php | 73 --- .../Test/Constraint/AssertCaseInfoOnAdmin.php | 85 ---- .../AssertCaseInfoOnSignifydConsole.php | 214 --------- .../AssertSignifydCaseInCommentsHistory.php | 56 --- .../AssertSignifydCaseInOrdersGrid.php | 50 -- ...gnifydGuaranteeCancelInCommentsHistory.php | 57 --- .../Signifyd/Test/Fixture/SignifydAccount.xml | 17 - .../Signifyd/Test/Fixture/SignifydAddress.xml | 15 - .../Fixture/SignifydAddress/Firstname.php | 46 -- .../Signifyd/Test/Fixture/SignifydData.xml | 21 - .../Test/Page/Adminhtml/OrdersGrid.xml | 12 - .../Test/Page/Adminhtml/SalesOrderView.xml | 12 - .../Page/SignifydConsole/SignifydCases.xml | 13 - .../Page/SignifydConsole/SignifydLogin.xml | 12 - .../SignifydConsole/SignifydNotifications.xml | 12 - .../Signifyd/Test/Repository/Address.xml | 22 - .../Signifyd/Test/Repository/ConfigData.xml | 45 -- .../Signifyd/Test/Repository/Customer.xml | 25 - .../Test/Repository/SignifydAccount.xml | 15 - .../Signifyd/Test/Repository/SignifydData.xml | 33 -- ...ymentWithSignifydGuaranteeDeclinedTest.php | 63 --- ...ymentWithSignifydGuaranteeDeclinedTest.xml | 38 -- ...ateSignifydGuaranteeAndCancelOrderTest.php | 62 --- ...ateSignifydGuaranteeAndCancelOrderTest.xml | 67 --- ...ymentWithSignifydGuaranteeDeclinedTest.php | 63 --- ...ymentWithSignifydGuaranteeDeclinedTest.xml | 39 -- .../Test/TestStep/OpenOrderGridStep.php | 173 ------- .../Test/TestStep/SignifydCancelOrderStep.php | 105 ---- .../TestStep/SignifydCreateCustomerStep.php | 77 --- .../SignifydFillShippingAddressStep.php | 70 --- .../Test/TestStep/SignifydLoginStep.php | 68 --- .../Test/TestStep/SignifydObserveCaseStep.php | 165 ------- .../SignifydSetWebhookHandlersStep.php | 64 --- .../TestStep/UnholdAndCancelOrderStep.php | 84 ---- .../app/Magento/Signifyd/Test/etc/di.xml | 34 -- .../Magento/Signifyd/Test/etc/testcase.xml | 58 --- .../testFromCreateProject/composer.lock | 40 -- .../_files/testSkeleton/composer.lock | 40 -- .../Signifyd/Block/Adminhtml/CaseInfoTest.php | 123 ----- .../Signifyd/Block/FingerprintTest.php | 63 --- .../Controller/Webhooks/HandlerTest.php | 135 ------ .../Signifyd/Model/CaseManagementTest.php | 83 ---- .../Signifyd/Model/CaseRepositoryTest.php | 148 ------ .../CaseServices/CreationServiceTest.php | 245 ---------- .../CaseServices/UpdatingServiceTest.php | 186 -------- .../Model/Guarantee/CancelingServiceTest.php | 158 ------ .../Model/Guarantee/CreationServiceTest.php | 155 ------ .../Request/CreateCaseBuilderTest.php | 291 ------------ .../Signifyd/Observer/PlaceOrderTest.php | 218 --------- .../Signifyd/Plugin/CancelOrderTest.php | 114 ----- .../Signifyd/Plugin/DenyPaymentTest.php | 209 -------- .../Magento/Signifyd/_files/approved_case.php | 38 -- .../Magento/Signifyd/_files/case.php | 42 -- .../Magento/Signifyd/_files/customer.php | 38 -- .../Magento/Signifyd/_files/declined_case.php | 38 -- .../Signifyd/_files/multiple_cases.php | 27 -- ..._with_customer_and_two_simple_products.php | 119 ----- .../order_with_guest_and_virtual_product.php | 68 --- .../Magento/Signifyd/_files/store.php | 33 -- .../Magento/Signifyd/_files/webhook_body.json | 1 - .../Signifyd/_files/website_configuration.php | 67 --- .../_files/website_configuration_rollback.php | 44 -- .../Modular/_files/skip_blocks_ce.php | 3 +- .../_files/skip_template_blocks_ce.php | 1 + .../Signifyd/frontend/js/Fingerprint.test.js | 47 -- .../_files/blacklist/exception_hierarchy.txt | 2 - .../Legacy/_files/obsolete_namespaces.php | 1 + 218 files changed, 16 insertions(+), 17251 deletions(-) delete mode 100644 app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php delete mode 100644 app/code/Magento/Signifyd/Api/CaseManagementInterface.php delete mode 100644 app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php delete mode 100644 app/code/Magento/Signifyd/Api/Data/CaseInterface.php delete mode 100644 app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php delete mode 100644 app/code/Magento/Signifyd/Api/GuaranteeCancelingServiceInterface.php delete mode 100644 app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php delete mode 100644 app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php delete mode 100644 app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Field/WebhookUrl.php delete mode 100644 app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Fieldset/Info.php delete mode 100644 app/code/Magento/Signifyd/Block/Fingerprint.php delete mode 100644 app/code/Magento/Signifyd/Controller/Webhooks/Handler.php delete mode 100644 app/code/Magento/Signifyd/LICENSE.txt delete mode 100644 app/code/Magento/Signifyd/LICENSE_AFL.txt delete mode 100644 app/code/Magento/Signifyd/Model/CaseEntity.php delete mode 100644 app/code/Magento/Signifyd/Model/CaseManagement.php delete mode 100644 app/code/Magento/Signifyd/Model/CaseRepository.php delete mode 100644 app/code/Magento/Signifyd/Model/CaseSearchResults.php delete mode 100644 app/code/Magento/Signifyd/Model/CaseServices/CreationService.php delete mode 100644 app/code/Magento/Signifyd/Model/CaseServices/StubUpdatingService.php delete mode 100644 app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php delete mode 100644 app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceFactory.php delete mode 100644 app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceInterface.php delete mode 100644 app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php delete mode 100644 app/code/Magento/Signifyd/Model/Config.php delete mode 100644 app/code/Magento/Signifyd/Model/CustomerOrders.php delete mode 100644 app/code/Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php delete mode 100644 app/code/Magento/Signifyd/Model/Guarantee/CancelingService.php delete mode 100644 app/code/Magento/Signifyd/Model/Guarantee/CreateGuaranteeAbility.php delete mode 100644 app/code/Magento/Signifyd/Model/Guarantee/CreationService.php delete mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php delete mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php delete mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php delete mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorInterface.php delete mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php delete mode 100644 app/code/Magento/Signifyd/Model/OrderStateService.php delete mode 100644 app/code/Magento/Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php delete mode 100644 app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php delete mode 100644 app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php delete mode 100644 app/code/Magento/Signifyd/Model/PredefinedVerificationCode.php delete mode 100644 app/code/Magento/Signifyd/Model/QuoteSession/Adminhtml/BackendSession.php delete mode 100644 app/code/Magento/Signifyd/Model/QuoteSession/FrontendSession.php delete mode 100644 app/code/Magento/Signifyd/Model/QuoteSession/QuoteSessionInterface.php delete mode 100644 app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity.php delete mode 100644 app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity/Collection.php delete mode 100644 app/code/Magento/Signifyd/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php delete mode 100644 app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/ApiCallException.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Client/HttpClientFactory.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Client/RequestBuilder.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Client/RequestSender.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Client/ResponseHandler.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/BlackHole.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/DebuggerFactory.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/DebuggerInterface.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/Log.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/GatewayException.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Request/AddressBuilder.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Request/CardBuilder.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Request/ClientVersionBuilder.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Request/RecipientBuilder.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestValidator.php delete mode 100644 app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php delete mode 100644 app/code/Magento/Signifyd/Observer/PlaceOrder.php delete mode 100644 app/code/Magento/Signifyd/Plugin/OrderPlugin.php delete mode 100644 app/code/Magento/Signifyd/Plugin/PaymentPlugin.php delete mode 100644 app/code/Magento/Signifyd/README.md delete mode 100644 app/code/Magento/Signifyd/Test/Mftf/LICENSE.txt delete mode 100644 app/code/Magento/Signifyd/Test/Mftf/LICENSE_AFL.txt delete mode 100644 app/code/Magento/Signifyd/Test/Mftf/Page/AdminFraudProtectionPage.xml delete mode 100644 app/code/Magento/Signifyd/Test/Mftf/README.md delete mode 100644 app/code/Magento/Signifyd/Test/Mftf/Section/AdminSignifydConfigurationSection.xml delete mode 100644 app/code/Magento/Signifyd/Test/Mftf/Test/AdminSignifydConfigDependentOnActiveFieldTest.xml delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/signifyd_payment_mapping.xml delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php delete mode 100644 app/code/Magento/Signifyd/Ui/Component/Listing/Column/Guarantee/Options.php delete mode 100644 app/code/Magento/Signifyd/composer.json delete mode 100644 app/code/Magento/Signifyd/etc/acl.xml delete mode 100644 app/code/Magento/Signifyd/etc/adminhtml/di.xml delete mode 100644 app/code/Magento/Signifyd/etc/adminhtml/routes.xml delete mode 100644 app/code/Magento/Signifyd/etc/adminhtml/system.xml delete mode 100644 app/code/Magento/Signifyd/etc/config.xml delete mode 100644 app/code/Magento/Signifyd/etc/db_schema.xml delete mode 100644 app/code/Magento/Signifyd/etc/db_schema_whitelist.json delete mode 100644 app/code/Magento/Signifyd/etc/di.xml delete mode 100644 app/code/Magento/Signifyd/etc/events.xml delete mode 100644 app/code/Magento/Signifyd/etc/frontend/di.xml delete mode 100644 app/code/Magento/Signifyd/etc/frontend/routes.xml delete mode 100644 app/code/Magento/Signifyd/etc/module.xml delete mode 100644 app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml delete mode 100644 app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd delete mode 100644 app/code/Magento/Signifyd/i18n/en_US.csv delete mode 100644 app/code/Magento/Signifyd/registration.php delete mode 100644 app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml delete mode 100644 app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml delete mode 100644 app/code/Magento/Signifyd/view/adminhtml/ui_component/sales_order_grid.xml delete mode 100644 app/code/Magento/Signifyd/view/adminhtml/web/images/logo.png delete mode 100644 app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js delete mode 100644 app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml delete mode 100644 app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml delete mode 100644 app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml delete mode 100644 app/design/adminhtml/Magento/backend/Magento_Signifyd/web/css/source/_module.less delete mode 100644 app/design/adminhtml/Magento/backend/Magento_Signifyd/web/css/source/module/_config.less delete mode 100644 app/design/adminhtml/Magento/backend/Magento_Signifyd/web/css/source/module/_order.less delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/Grid.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/View/FraudProtection.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseInfo.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseSearch.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/SignifydLogin.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/Webhooks.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnAdmin.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnSignifydConsole.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInCommentsHistory.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInOrdersGrid.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAccount.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress/Firstname.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydData.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/OrdersGrid.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/SalesOrderView.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydCases.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydLogin.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydNotifications.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Address.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/ConfigData.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Customer.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydAccount.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydData.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/OpenOrderGridStep.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCancelOrderStep.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydFillShippingAddressStep.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydLoginStep.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydObserveCaseStep.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydSetWebhookHandlersStep.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/UnholdAndCancelOrderStep.php delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/di.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/testcase.xml delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/approved_case.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/customer.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/declined_case.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/multiple_cases.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/webhook_body.json delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/website_configuration.php delete mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/website_configuration_rollback.php delete mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js diff --git a/app/code/Magento/Backend/README.md b/app/code/Magento/Backend/README.md index 205051809328a..f70dc9f676236 100644 --- a/app/code/Magento/Backend/README.md +++ b/app/code/Magento/Backend/README.md @@ -16,7 +16,6 @@ Before disabling or uninstalling this module, note that the following modules de - Magento_ReleaseNotification - Magento_Search - Magento_Security -- Magento_Signifyd - Magento_Swatches - Magento_Ui - Magento_User diff --git a/app/code/Magento/Paypal/Block/Express/InContext/Minicart/SmartButton.php b/app/code/Magento/Paypal/Block/Express/InContext/Minicart/SmartButton.php index c6a17fa5efb9f..a4732a8b4c579 100644 --- a/app/code/Magento/Paypal/Block/Express/InContext/Minicart/SmartButton.php +++ b/app/code/Magento/Paypal/Block/Express/InContext/Minicart/SmartButton.php @@ -27,6 +27,8 @@ class SmartButton extends Template implements ShortcutInterface { private const ALIAS_ELEMENT_INDEX = 'alias'; + const PAYPAL_BUTTON_ID = 'paypal-express-in-context-checkout-main'; + /** * @var Config */ diff --git a/app/code/Magento/Paypal/view/frontend/templates/express/in-context/component.phtml b/app/code/Magento/Paypal/view/frontend/templates/express/in-context/component.phtml index ba98f5caeb15a..c102b21830de8 100644 --- a/app/code/Magento/Paypal/view/frontend/templates/express/in-context/component.phtml +++ b/app/code/Magento/Paypal/view/frontend/templates/express/in-context/component.phtml @@ -3,12 +3,12 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -use Magento\Paypal\Block\Express\InContext\Minicart\Button; +use Magento\Paypal\Block\Express\InContext\Minicart\SmartButton; /** @var \Magento\Paypal\Block\Express\InContext\Component $block */ $configuration = [ - 'id' => Button::PAYPAL_BUTTON_ID, + 'id' => SmartButton::PAYPAL_BUTTON_ID, 'path' => $block->getUrl( 'paypal/express/gettoken', [ @@ -21,17 +21,18 @@ $configuration = [ 'locale' => $block->getLocale(), 'environment' => $block->getEnvironment(), 'button' => [ - Button::PAYPAL_BUTTON_ID, + SmartButton::PAYPAL_BUTTON_ID, ] ] ]; ?> - + diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php deleted file mode 100644 index f7611660b93a1..0000000000000 --- a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php +++ /dev/null @@ -1,29 +0,0 @@ -caseManagement = $caseManagement; - - parent::__construct($context, $data); - } - - /** - * Gets case entity associated with order id. - * - * @return CaseInterface|null - */ - private function getCaseEntity() - { - if ($this->caseEntity === false) { - $this->caseEntity = $this->caseManagement->getByOrderId( - $this->getOrderId() - ); - } - - return $this->caseEntity; - } - - /** - * Default getter for case properties - * - * @param mixed $defaultValue - * @param callable $callback - * @return mixed - */ - private function getCaseProperty($defaultValue, callable $callback) - { - return $this->isEmptyCase() ? $defaultValue : call_user_func($callback); - } - - /** - * Checks if case is exists for order - * - * @return bool - * @since 100.2.0 - */ - public function isEmptyCase() - { - return $this->getCaseEntity() === null; - } - - /** - * Gets case guarantee disposition status. - * - * @return string - * @since 100.2.0 - */ - public function getCaseGuaranteeDisposition() - { - return $this->getCaseProperty('', function () { - $guaranteeStatusMap = [ - CaseInterface::GUARANTEE_APPROVED => __('Approved'), - CaseInterface::GUARANTEE_DECLINED => __('Declined'), - CaseInterface::GUARANTEE_PENDING => __('Pending'), - CaseInterface::GUARANTEE_CANCELED => __('Canceled'), - CaseInterface::GUARANTEE_IN_REVIEW => __('In Review'), - CaseInterface::GUARANTEE_UNREQUESTED => __('Unrequested') - ]; - - $status = isset($guaranteeStatusMap[$this->getCaseEntity()->getGuaranteeDisposition()]) ? - $guaranteeStatusMap[$this->getCaseEntity()->getGuaranteeDisposition()] : - ''; - - return $status; - }); - } - - /** - * Retrieves current order Id. - * - * @return integer - */ - private function getOrderId() - { - return (int) $this->getRequest()->getParam('order_id'); - } -} diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Field/WebhookUrl.php b/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Field/WebhookUrl.php deleted file mode 100644 index 7964d6b1af397..0000000000000 --- a/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Field/WebhookUrl.php +++ /dev/null @@ -1,60 +0,0 @@ -getOriginalData(); - if (!empty($originalData['handler_url'])) { - $url = $this->getStoreUrl(); - $url .= $originalData['handler_url']; - } - - return '

' . $this->escapeHtml($url) . '

'; - } - - /** - * @inheritdoc - */ - protected function _isInheritCheckboxRequired(AbstractElement $element) - { - return false; - } - - /** - * Return base store URL. - * - * @return string - */ - private function getStoreUrl() - { - $website = $this->_storeManager->getWebsite($this->getRequest()->getParam('website')); - - $isSecure = $this->_scopeConfig->isSetFlag( - Store::XML_PATH_SECURE_IN_FRONTEND, - ScopeInterface::SCOPE_WEBSITE, - $website->getCode() - ); - - $configPath = $isSecure ? Store::XML_PATH_SECURE_BASE_LINK_URL : Store::XML_PATH_UNSECURE_BASE_LINK_URL; - - return $this->_scopeConfig->getValue($configPath, ScopeInterface::SCOPE_WEBSITE, $website->getCode()); - } -} diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Fieldset/Info.php b/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Fieldset/Info.php deleted file mode 100644 index c18c3dc596e21..0000000000000 --- a/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Fieldset/Info.php +++ /dev/null @@ -1,31 +0,0 @@ -getGroup(); - - if (!empty($groupConfig['more_url']) && !empty($element->getComment())) { - $comment = $element->getComment(); - $comment .= '

' . - $this->escapeHtml(__('Learn more')) . '

'; - $element->setComment($comment); - } - - return parent::_getHeaderCommentHtml($element); - } -} diff --git a/app/code/Magento/Signifyd/Block/Fingerprint.php b/app/code/Magento/Signifyd/Block/Fingerprint.php deleted file mode 100644 index f43bffce1fc1a..0000000000000 --- a/app/code/Magento/Signifyd/Block/Fingerprint.php +++ /dev/null @@ -1,92 +0,0 @@ -signifydOrderSessionId = $signifydOrderSessionId; - $this->config = $config; - $this->quoteSession = $quoteSession; - } - - /** - * Returns a unique Signifyd order session id. - * - * @return string - * @since 100.2.0 - */ - public function getSignifydOrderSessionId() - { - $quoteId = $this->quoteSession->getQuote()->getId(); - - return $this->signifydOrderSessionId->get($quoteId); - } - - /** - * Checks if module is enabled. - * - * @return boolean - * @since 100.2.0 - */ - public function isModuleActive() - { - $storeId = $this->quoteSession->getQuote()->getStoreId(); - - return $this->config->isActive($storeId); - } -} diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php deleted file mode 100644 index 2dee31f4048b9..0000000000000 --- a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php +++ /dev/null @@ -1,157 +0,0 @@ -webhookRequest = $webhookRequest; - $this->logger = $logger; - $this->webhookMessageReader = $webhookMessageReader; - $this->caseUpdatingServiceFactory = $caseUpdatingServiceFactory; - $this->webhookRequestValidator = $webhookRequestValidator; - $this->caseRepository = $caseRepository; - $this->config = $config; - } - - /** - * Processes webhook request data and updates case entity - * - * @return void - */ - public function execute() - { - if ($this->config->isDebugModeEnabled()) { - $this->logger->debug($this->webhookRequest->getEventTopic() . '|' . $this->webhookRequest->getBody()); - } - - if (!$this->webhookRequestValidator->validate($this->webhookRequest)) { - $this->_redirect('noroute'); - return; - } - - $webhookMessage = $this->webhookMessageReader->read($this->webhookRequest); - if ($webhookMessage->getEventTopic() === self::$eventTopicTest) { - return; - } - - $data = $webhookMessage->getData(); - if (empty($data['caseId'])) { - $this->_redirect('noroute'); - return; - } - - $case = $this->caseRepository->getByCaseId($data['caseId']); - if ($case === null) { - $this->_redirect('noroute'); - return; - } - - $caseUpdatingService = $this->caseUpdatingServiceFactory->create($webhookMessage->getEventTopic()); - try { - $caseUpdatingService->update($case, $data); - } catch (LocalizedException $e) { - $this->getResponse()->setHttpResponseCode(400); - $this->logger->critical($e); - } - } - - /** - * @inheritDoc - */ - public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException - { - return null; - } - - /** - * @inheritDoc - */ - public function validateForCsrf(RequestInterface $request): ?bool - { - return true; - } -} diff --git a/app/code/Magento/Signifyd/LICENSE.txt b/app/code/Magento/Signifyd/LICENSE.txt deleted file mode 100644 index 49525fd99da9c..0000000000000 --- a/app/code/Magento/Signifyd/LICENSE.txt +++ /dev/null @@ -1,48 +0,0 @@ - -Open Software License ("OSL") v. 3.0 - -This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: - -Licensed under the Open Software License version 3.0 - - 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: - - 1. to reproduce the Original Work in copies, either alone or as part of a collective work; - - 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; - - 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; - - 4. to perform the Original Work publicly; and - - 5. to display the Original Work publicly. - - 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. - - 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. - - 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. - - 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). - - 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. - - 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. - - 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. - - 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). - - 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. - - 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. - - 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. - - 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. - - 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - - 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. - - 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magento/Signifyd/LICENSE_AFL.txt b/app/code/Magento/Signifyd/LICENSE_AFL.txt deleted file mode 100644 index f39d641b18a19..0000000000000 --- a/app/code/Magento/Signifyd/LICENSE_AFL.txt +++ /dev/null @@ -1,48 +0,0 @@ - -Academic Free License ("AFL") v. 3.0 - -This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: - -Licensed under the Academic Free License version 3.0 - - 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: - - 1. to reproduce the Original Work in copies, either alone or as part of a collective work; - - 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; - - 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License; - - 4. to perform the Original Work publicly; and - - 5. to display the Original Work publicly. - - 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. - - 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. - - 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. - - 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). - - 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. - - 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. - - 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. - - 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). - - 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. - - 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. - - 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. - - 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. - - 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - - 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. - - 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php deleted file mode 100644 index c11c72db79f16..0000000000000 --- a/app/code/Magento/Signifyd/Model/CaseEntity.php +++ /dev/null @@ -1,249 +0,0 @@ -serializer = $serializer; - parent::__construct($context, $registry, $resource, $resourceCollection, $data); - } - - /** - * @inheritdoc - */ - protected function _construct() - { - $this->_init(ResourceModel\CaseEntity::class); - } - - /** - * @inheritdoc - */ - public function getEntityId() - { - return (int) $this->getData('entity_id'); - } - - /** - * @inheritdoc - */ - public function setEntityId($id) - { - $this->setData('entity_id', (int) $id); - return $this; - } - - /** - * @inheritdoc - */ - public function getCaseId() - { - return (int) $this->getData('case_id'); - } - - /** - * @inheritdoc - */ - public function setCaseId($id) - { - $this->setData('case_id', (int) $id); - return $this; - } - - /** - * @inheritdoc - */ - public function isGuaranteeEligible() - { - $value = $this->getData('guarantee_eligible'); - return ($value === null) ? $value : (bool) $value; - } - - /** - * @inheritdoc - */ - public function setGuaranteeEligible($guaranteeEligible) - { - $this->setData('guarantee_eligible', $guaranteeEligible); - return $this; - } - - /** - * @inheritdoc - */ - public function getGuaranteeDisposition() - { - return (string) $this->getData('guarantee_disposition'); - } - - /** - * @inheritdoc - */ - public function setGuaranteeDisposition($disposition) - { - $this->setData('guarantee_disposition', (string) $disposition); - return $this; - } - - /** - * @inheritdoc - */ - public function getStatus() - { - return (string) $this->getData('status'); - } - - /** - * @inheritdoc - */ - public function setStatus($status) - { - $this->setData('status', (string) $status); - return $this; - } - - /** - * @inheritdoc - */ - public function getScore() - { - return (int) $this->getData('score'); - } - - /** - * @inheritdoc - */ - public function setScore($score) - { - $this->setData('score', (int) $score); - return $this; - } - - /** - * @inheritdoc - */ - public function getOrderId() - { - return (int) $this->getData('order_id'); - } - - /** - * @inheritdoc - */ - public function setOrderId($orderId) - { - $this->setData('order_id', (int) $orderId); - return $this; - } - - /** - * @inheritdoc - */ - public function getAssociatedTeam() - { - $teamData = $this->getData('associated_team'); - return empty($teamData) ? [] : $this->serializer->unserialize($teamData); - } - - /** - * @inheritdoc - */ - public function setAssociatedTeam(array $team) - { - $this->setData('associated_team', $this->serializer->serialize($team)); - return $this; - } - - /** - * @inheritdoc - */ - public function getReviewDisposition() - { - return (string) $this->getData('review_disposition'); - } - - /** - * @inheritdoc - */ - public function setReviewDisposition($disposition) - { - $this->setData('review_disposition', (string) $disposition); - return $this; - } - - /** - * @inheritdoc - */ - public function getCreatedAt() - { - return $this->getData('created_at'); - } - - /** - * @inheritdoc - */ - public function setCreatedAt($datetime) - { - $this->setData('created_at', $datetime); - return $this; - } - - /** - * @inheritdoc - */ - public function getUpdatedAt() - { - return $this->getData('updated_at'); - } - - /** - * @inheritdoc - */ - public function setUpdatedAt($datetime) - { - $this->setData('updated_at', $datetime); - return $this; - } -} diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php deleted file mode 100644 index 1913f1e7a17b3..0000000000000 --- a/app/code/Magento/Signifyd/Model/CaseManagement.php +++ /dev/null @@ -1,93 +0,0 @@ -caseRepository = $caseRepository; - $this->caseFactory = $caseFactory; - $this->searchCriteriaBuilder = $searchCriteriaBuilder; - $this->filterBuilder = $filterBuilder; - } - - /** - * @inheritdoc - */ - public function create($orderId) - { - /** @var \Magento\Signifyd\Api\Data\CaseInterface $case */ - $case = $this->caseFactory->create(); - $case->setOrderId($orderId) - ->setStatus(CaseInterface::STATUS_PENDING) - ->setGuaranteeDisposition(CaseInterface::GUARANTEE_PENDING); - try { - return $this->caseRepository->save($case); - } catch (DuplicateException $e) { - throw new AlreadyExistsException(__('This order already has associated case entity'), $e); - } - } - - /** - * @inheritdoc - */ - public function getByOrderId($orderId) - { - $filters = [ - $this->filterBuilder->setField('order_id') - ->setValue($orderId) - ->create() - ]; - $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create(); - $items = $this->caseRepository->getList($searchCriteria)->getItems(); - return !empty($items) ? array_pop($items) : null; - } -} diff --git a/app/code/Magento/Signifyd/Model/CaseRepository.php b/app/code/Magento/Signifyd/Model/CaseRepository.php deleted file mode 100644 index ea3ea3e67aafd..0000000000000 --- a/app/code/Magento/Signifyd/Model/CaseRepository.php +++ /dev/null @@ -1,134 +0,0 @@ -collectionProcessor = $collectionProcessor; - $this->collectionFactory = $collectionFactory; - $this->searchResultsFactory = $searchResultsFactory; - $this->caseFactory = $caseFactory; - $this->resourceModel = $resourceModel; - } - - /** - * @inheritdoc - */ - public function save(CaseInterface $case) - { - /** @var CaseEntity $case */ - $this->resourceModel->save($case); - - return $case; - } - - /** - * @inheritdoc - */ - public function getById($id) - { - /** @var CaseEntity $case */ - $case = $this->caseFactory->create(); - $this->resourceModel->load($case, $id); - - return $case; - } - - /** - * @inheritdoc - */ - public function getByCaseId($caseId) - { - /** @var CaseEntity $case */ - $case = $this->caseFactory->create(); - $this->resourceModel->load($case, $caseId, 'case_id'); - - return $case->getEntityId() ? $case : null; - } - - /** - * @inheritdoc - */ - public function delete(CaseInterface $case) - { - $this->resourceModel->delete($case); - - return true; - } - - /** - * @inheritdoc - */ - public function getList(SearchCriteriaInterface $searchCriteria) - { - /** @var Collection $collection */ - $collection = $this->collectionFactory->create(); - $this->collectionProcessor->process($searchCriteria, $collection); - - /** @var CaseSearchResultsInterface $searchResults */ - $searchResults = $this->searchResultsFactory->create(); - $searchResults->setSearchCriteria($searchCriteria); - $searchResults->setItems($collection->getItems()); - - return $searchResults; - } -} diff --git a/app/code/Magento/Signifyd/Model/CaseSearchResults.php b/app/code/Magento/Signifyd/Model/CaseSearchResults.php deleted file mode 100644 index ff1ab8839f6cd..0000000000000 --- a/app/code/Magento/Signifyd/Model/CaseSearchResults.php +++ /dev/null @@ -1,18 +0,0 @@ -caseManagement = $caseManagement; - $this->signifydGateway = $signifydGateway; - $this->logger = $logger; - $this->caseRepository = $caseRepository; - $this->orderGridUpdater = $orderGridUpdater; - $this->orderStateService = $orderStateService; - } - - /** - * {@inheritdoc} - */ - public function createForOrder($orderId) - { - $case = $this->caseManagement->create($orderId); - $this->orderGridUpdater->update($orderId); - - try { - $caseId = $this->signifydGateway->createCase($orderId); - } catch (GatewayException $e) { - $this->logger->error($e->getMessage()); - return true; - } - - $case->setCaseId($caseId); - $this->caseRepository->save($case); - $this->orderStateService->updateByCase($case); - - return true; - } -} diff --git a/app/code/Magento/Signifyd/Model/CaseServices/StubUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseServices/StubUpdatingService.php deleted file mode 100644 index 295d7f13fb0ac..0000000000000 --- a/app/code/Magento/Signifyd/Model/CaseServices/StubUpdatingService.php +++ /dev/null @@ -1,23 +0,0 @@ -messageGenerator = $messageGenerator; - $this->caseRepository = $caseRepository; - $this->commentsHistoryUpdater = $commentsHistoryUpdater; - $this->orderGridUpdater = $orderGridUpdater; - $this->orderStateService = $orderStateService; - } - - /** - * Updates Signifyd Case entity by received data. - * - * @param CaseInterface $case - * @param array $data - * @return void - * @throws LocalizedException - */ - public function update(CaseInterface $case, array $data) - { - if (empty($case->getEntityId()) || empty($case->getCaseId())) { - throw new LocalizedException(__('The case entity should not be empty.')); - } - - try { - $previousDisposition = $case->getGuaranteeDisposition(); - $this->setCaseData($case, $data); - $orderHistoryComment = $this->messageGenerator->generate($data); - $case = $this->caseRepository->save($case); - $this->orderGridUpdater->update($case->getOrderId()); - $this->commentsHistoryUpdater->addComment($case, $orderHistoryComment); - if ($case->getGuaranteeDisposition() !== $previousDisposition) { - $this->orderStateService->updateByCase($case); - } - } catch (\Exception $e) { - throw new LocalizedException(__('Cannot update Case entity.'), $e); - } - } - - /** - * Sets data to case entity. - * - * @param CaseInterface $case - * @param array $data - * @return void - */ - private function setCaseData(CaseInterface $case, array $data) - { - // list of keys which should not be replaced, like order id - $notResolvedKeys = [ - 'orderId' - ]; - foreach ($data as $key => $value) { - $methodName = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key); - if (!in_array($key, $notResolvedKeys) && method_exists($case, $methodName)) { - call_user_func([$case, $methodName], $value); - } - } - } -} diff --git a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceFactory.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceFactory.php deleted file mode 100644 index 5415044b5edc4..0000000000000 --- a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceFactory.php +++ /dev/null @@ -1,78 +0,0 @@ -objectManager = $objectManager; - $this->generatorFactory = $generatorFactory; - $this->config = $config; - } - - /** - * Creates instance of service updating case. - * As param retrieves type of message generator. - * - * @param string $type - * @return UpdatingServiceInterface - * @throws \InvalidArgumentException - */ - public function create($type) - { - if (!$this->config->isActive() || $type === self::$caseTest) { - return $this->objectManager->create(StubUpdatingService::class); - } - - $messageGenerator = $this->generatorFactory->create($type); - $service = $this->objectManager->create(UpdatingService::class, [ - 'messageGenerator' => $messageGenerator - ]); - - return $service; - } -} diff --git a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceInterface.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceInterface.php deleted file mode 100644 index daa7b40bfd674..0000000000000 --- a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceInterface.php +++ /dev/null @@ -1,23 +0,0 @@ -historyFactory = $historyFactory; - $this->historyRepository = $historyRepository; - } - - /** - * Adds comment to case related order. - * Throws an exception if cannot save history comment. - * - * @param CaseInterface $case - * @param Phrase $message - * @param string $status - * @return void - */ - public function addComment(CaseInterface $case, Phrase $message, $status = '') - { - if (!$message->getText()) { - return; - } - - /** @var \Magento\Sales\Api\Data\OrderStatusHistoryInterface $history */ - $history = $this->historyFactory->create(); - $history->setParentId($case->getOrderId()) - ->setComment($message) - ->setEntityName('order') - ->setStatus($status); - $this->historyRepository->save($history); - } -} diff --git a/app/code/Magento/Signifyd/Model/Config.php b/app/code/Magento/Signifyd/Model/Config.php deleted file mode 100644 index 15d3608bd38c4..0000000000000 --- a/app/code/Magento/Signifyd/Model/Config.php +++ /dev/null @@ -1,101 +0,0 @@ -scopeConfig = $scopeConfig; - } - - /** - * If this config option set to false no Signifyd integration should be available - * (only possibility to configure Signifyd setting in admin) - * - * @param int|null $storeId - * @return bool - */ - public function isActive($storeId = null): bool - { - $enabled = $this->scopeConfig->isSetFlag( - 'fraud_protection/signifyd/active', - ScopeInterface::SCOPE_STORE, - $storeId - ); - return $enabled; - } - - /** - * Signifyd API Key used for authentication. - * - * @see https://www.signifyd.com/docs/api/#/introduction/authentication - * @see https://app.signifyd.com/settings - * - * @param int|null $storeId - * @return string - */ - public function getApiKey($storeId = null): string - { - $apiKey = $this->scopeConfig->getValue( - 'fraud_protection/signifyd/api_key', - ScopeInterface::SCOPE_STORE, - $storeId - ); - return $apiKey; - } - - /** - * Base URL to Signifyd REST API. - * Usually equals to https://api.signifyd.com/v2 and should not be changed - * - * @param int|null $storeId - * @return string - */ - public function getApiUrl($storeId = null): string - { - $apiUrl = $this->scopeConfig->getValue( - 'fraud_protection/signifyd/api_url', - ScopeInterface::SCOPE_STORE, - $storeId - ); - return $apiUrl; - } - - /** - * If is "true" extra information about interaction with Signifyd API are written to debug.log file - * - * @param int|null $storeId - * @return bool - */ - public function isDebugModeEnabled($storeId = null): bool - { - $debugModeEnabled = $this->scopeConfig->isSetFlag( - 'fraud_protection/signifyd/debug', - ScopeInterface::SCOPE_STORE, - $storeId - ); - return $debugModeEnabled; - } -} diff --git a/app/code/Magento/Signifyd/Model/CustomerOrders.php b/app/code/Magento/Signifyd/Model/CustomerOrders.php deleted file mode 100644 index c326cf06424c0..0000000000000 --- a/app/code/Magento/Signifyd/Model/CustomerOrders.php +++ /dev/null @@ -1,173 +0,0 @@ -searchCriteriaBuilder = $searchCriteriaBuilder; - $this->filterBuilder = $filterBuilder; - $this->orderRepository = $orderRepository; - $this->currencyFactory = $currencyFactory; - $this->logger = $logger; - } - - /** - * Returns aggregated customer orders count and total amount in USD. - * - * Returned array contains next keys: - * aggregateOrderCount - total count of orders placed by this account since it was created, including the current - * aggregateOrderDollars - total amount spent by this account since it was created, including the current order - * - * @param int $customerId - * @return array - */ - public function getAggregatedOrdersInfo($customerId) - { - $result = [ - 'aggregateOrderCount' => null, - 'aggregateOrderDollars' => null - ]; - - $customerOrders = $this->getCustomerOrders($customerId); - if (!empty($customerOrders)) { - try { - $orderTotalDollars = 0.0; - foreach ($customerOrders as $order) { - $orderTotalDollars += $this->getUsdOrderTotal( - $order->getBaseGrandTotal(), - $order->getBaseCurrencyCode() - ); - } - $result = [ - 'aggregateOrderCount' => count($customerOrders), - 'aggregateOrderDollars' => $orderTotalDollars - ]; - } catch (Exception $e) { - $this->logger->error($e->getMessage()); - } - } - - return $result; - } - - /** - * Returns customer orders. - * - * @param int $customerId - * @return OrderInterface[] - */ - private function getCustomerOrders($customerId) - { - $filters = [ - $this->filterBuilder->setField(OrderInterface::CUSTOMER_ID)->setValue($customerId)->create() - ]; - $this->searchCriteriaBuilder->addFilters($filters); - $searchCriteria = $this->searchCriteriaBuilder->create(); - $searchResults = $this->orderRepository->getList($searchCriteria); - - return $searchResults->getItems(); - } - - /** - * Returns amount in USD. - * - * @param float $amount - * @param string $currency - * @return float - */ - private function getUsdOrderTotal($amount, $currency) - { - if ($currency === self::$usdCurrencyCode) { - return $amount; - } - - $operationCurrency = $this->getCurrencyByCode($currency); - - return $operationCurrency->convert($amount, self::$usdCurrencyCode); - } - - /** - * Returns currency by currency code. - * - * @param string|null $currencyCode - * @return Currency - */ - private function getCurrencyByCode($currencyCode) - { - if (isset($this->currencies[$currencyCode])) { - return $this->currencies[$currencyCode]; - } - - /** @var Currency $currency */ - $currency = $this->currencyFactory->create(); - $this->currencies[$currencyCode] = $currency->load($currencyCode); - - return $this->currencies[$currencyCode]; - } -} diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php b/app/code/Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php deleted file mode 100644 index 65bede6f0cea5..0000000000000 --- a/app/code/Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php +++ /dev/null @@ -1,84 +0,0 @@ -caseManagement = $caseManagement; - $this->orderRepository = $orderRepository; - } - - /** - * Checks if it is possible to create Guarantee for order and case. - * - * @param int $orderId - * @return bool - */ - public function isAvailable($orderId) - { - $case = $this->caseManagement->getByOrderId($orderId); - if ($case === null) { - return false; - } - - if (in_array($case->getGuaranteeDisposition(), [null, $case::GUARANTEE_CANCELED])) { - return false; - } - - $order = $this->getOrder($orderId); - if (null === $order) { - return false; - } - - return true; - } - - /** - * Returns order by id - * - * @param int $orderId - * @return OrderInterface|null - */ - private function getOrder($orderId) - { - try { - $order = $this->orderRepository->get($orderId); - } catch (InputException $e) { - return null; - } catch (NoSuchEntityException $e) { - return null; - } - - return $order; - } -} diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CancelingService.php b/app/code/Magento/Signifyd/Model/Guarantee/CancelingService.php deleted file mode 100644 index b30efac8c2190..0000000000000 --- a/app/code/Magento/Signifyd/Model/Guarantee/CancelingService.php +++ /dev/null @@ -1,94 +0,0 @@ -caseManagement = $caseManagement; - $this->serviceFactory = $serviceFactory; - $this->gateway = $gateway; - $this->cancelGuaranteeAbility = $cancelGuaranteeAbility; - $this->logger = $logger; - } - - /** - * @inheritdoc - */ - public function cancelForOrder($orderId) - { - if (!$this->cancelGuaranteeAbility->isAvailable($orderId)) { - return false; - } - - $caseEntity = $this->caseManagement->getByOrderId($orderId); - - try { - $disposition = $this->gateway->cancelGuarantee($caseEntity->getCaseId()); - } catch (GatewayException $e) { - $this->logger->error($e->getMessage()); - return false; - } - - $updatingService = $this->serviceFactory->create('guarantees/cancel'); - $data = [ - 'guaranteeDisposition' => $disposition - ]; - $updatingService->update($caseEntity, $data); - - return true; - } -} diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CreateGuaranteeAbility.php b/app/code/Magento/Signifyd/Model/Guarantee/CreateGuaranteeAbility.php deleted file mode 100644 index 15addba3ec4fd..0000000000000 --- a/app/code/Magento/Signifyd/Model/Guarantee/CreateGuaranteeAbility.php +++ /dev/null @@ -1,124 +0,0 @@ -caseManagement = $caseManagement; - $this->orderRepository = $orderRepository; - $this->dateTimeFactory = $dateTimeFactory; - } - - /** - * Checks if it is possible to create Guarantee for order and case. - * - * @param int $orderId - * @return bool - */ - public function isAvailable($orderId) - { - $case = $this->caseManagement->getByOrderId($orderId); - if (null === $case) { - return false; - } - - if ($case->isGuaranteeEligible() === false) { - return false; - } - - $order = $this->getOrder($orderId); - if (null === $order) { - return false; - } - - if (in_array($order->getState(), [Order::STATE_CANCELED, Order::STATE_CLOSED])) { - return false; - } - - if ($this->isOrderOlderThen(static::$guarantyEligibleDays, $order)) { - return false; - } - - return true; - } - - /** - * Checks if Guarantee submit is applicable for order. - * - * @param OrderInterface $order - * @param int $days number of days from the order creation date to submit a case for Guarantee. - * @return bool - */ - private function isOrderOlderThen($days, OrderInterface $order) - { - $orderCreateDate = $this->dateTimeFactory->create($order->getCreatedAt(), new \DateTimeZone('UTC')); - $currentDate = $this->dateTimeFactory->create('now', new \DateTimeZone('UTC')); - - return $orderCreateDate->diff($currentDate)->days >= $days; - } - - /** - * Returns order by id - * - * @param int $orderId - * @return OrderInterface|null - */ - private function getOrder($orderId) - { - try { - $order = $this->orderRepository->get($orderId); - } catch (InputException $e) { - return null; - } catch (NoSuchEntityException $e) { - return null; - } - - return $order; - } -} diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php deleted file mode 100644 index 4080aee453f18..0000000000000 --- a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php +++ /dev/null @@ -1,97 +0,0 @@ -caseManagement = $caseManagement; - $this->caseUpdatingServiceFactory = $caseUpdatingServiceFactory; - $this->gateway = $gateway; - $this->createGuaranteeAbility = $createGuaranteeAbility; - $this->logger = $logger; - } - - /** - * @inheritdoc - */ - public function createForOrder($orderId) - { - if (!$this->createGuaranteeAbility->isAvailable($orderId)) { - return false; - } - - $caseEntity = $this->caseManagement->getByOrderId($orderId); - - try { - $disposition = $this->gateway->submitCaseForGuarantee($caseEntity->getCaseId()); - } catch (GatewayException $e) { - $this->logger->error($e->getMessage()); - return false; - } - - $updatingService = $this->caseUpdatingServiceFactory->create('guarantees/creation'); - $data = [ - 'caseId' => $caseEntity->getCaseId(), - 'guaranteeDisposition' => $disposition - ]; - $updatingService->update($caseEntity, $data); - - return true; - } -} diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php deleted file mode 100644 index d0e89854e3909..0000000000000 --- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php +++ /dev/null @@ -1,51 +0,0 @@ -caseRepository = $caseRepository; - } - - /** - * @inheritdoc - */ - public function generate(array $data) - { - if (empty($data['caseId'])) { - throw new GeneratorException(__('The "%1" should not be empty.', 'caseId')); - } - - $caseEntity = $this->caseRepository->getByCaseId($data['caseId']); - - if ($caseEntity === null) { - throw new GeneratorException(__('Case entity not found.')); - } - - return __( - 'Case Update: New score for the order is %1. Previous score was %2.', - !empty($data['score']) ? $data['score'] : 0, - $caseEntity->getScore() - ); - } -} diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php deleted file mode 100644 index 103cb9fc1e2d3..0000000000000 --- a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php +++ /dev/null @@ -1,19 +0,0 @@ -objectManager = $objectManager; - } - - /** - * Creates instance of message generator. - * Throws exception if type of message generator does not have implementations. - * - * @param string $type - * @return GeneratorInterface - * @throws \InvalidArgumentException - */ - public function create($type) - { - $className = PatternGenerator::class; - switch ($type) { - case self::$caseCreation: - $classConfig = [ - 'template' => 'Signifyd Case %1 has been created for order.', - 'requiredParams' => ['caseId'] - ]; - break; - case self::$caseRescore: - $classConfig = []; - $className = CaseRescore::class; - break; - case self::$caseReview: - $classConfig = [ - 'template' => 'Case Update: Case Review was completed. Review Deposition is %1.', - 'requiredParams' => ['reviewDisposition'] - ]; - break; - case self::$guaranteeCompletion: - $classConfig = [ - 'template' => 'Case Update: Guarantee Disposition is %1.', - 'requiredParams' => ['guaranteeDisposition'] - ]; - break; - case self::$guaranteeCreation: - $classConfig = [ - 'template' => 'Case Update: Case is submitted for guarantee.' - ]; - break; - case self::$guaranteeCancel: - $classConfig = [ - 'template' => 'Case Update: Case guarantee has been cancelled.' - ]; - break; - default: - throw new \InvalidArgumentException('Specified message type does not supported.'); - } - - return $this->objectManager->create($className, $classConfig); - } -} diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorInterface.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorInterface.php deleted file mode 100644 index 385cbe35f05ac..0000000000000 --- a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -template = $template; - $this->requiredParams = $requiredParams; - } - - /** - * @inheritdoc - */ - public function generate(array $data) - { - $placeholders = []; - foreach ($this->requiredParams as $param) { - if (empty($data[$param])) { - throw new GeneratorException(__('The "%1" should not be empty.', $param)); - } - $placeholders[] = $data[$param]; - } - return __($this->template, ...$placeholders); - } -} diff --git a/app/code/Magento/Signifyd/Model/OrderStateService.php b/app/code/Magento/Signifyd/Model/OrderStateService.php deleted file mode 100644 index 2b3f0e155981e..0000000000000 --- a/app/code/Magento/Signifyd/Model/OrderStateService.php +++ /dev/null @@ -1,119 +0,0 @@ -orderFactory = $orderFactory; - $this->orderManagement = $orderManagement; - $this->commentsHistoryUpdater = $commentsHistoryUpdater; - } - - /** - * Updates order state depending on case guarantee disposition status. - * - * @param CaseInterface $case - * @return void - */ - public function updateByCase(CaseInterface $case) - { - $orderId = $case->getOrderId(); - - switch ($case->getGuaranteeDisposition()) { - case CaseInterface::GUARANTEE_APPROVED: - $this->unHold($orderId); - break; - case CaseInterface::GUARANTEE_DECLINED: - $this->hold($orderId); - break; - case CaseInterface::GUARANTEE_PENDING: - if ($this->hold($orderId)) { - $this->commentsHistoryUpdater->addComment( - $case, - __('Awaiting the Signifyd guarantee disposition.'), - Order::STATE_HOLDED - ); - } - break; - } - } - - /** - * Tries to unhold the order. - * - * @param int $orderId - * @return bool - */ - private function unHold($orderId) - { - $order = $this->getOrder($orderId); - if ($order->canUnhold()) { - return $this->orderManagement->unHold($orderId); - } - - return false; - } - - /** - * Tries to hold the order. - * - * @param int $orderId - * @return bool - */ - private function hold($orderId) - { - $order = $this->getOrder($orderId); - if ($order->canHold()) { - return $this->orderManagement->hold($orderId); - } - - return false; - } - - /** - * Returns the order. - * - * @param int $orderId - * @return Order - */ - private function getOrder($orderId) - { - return $this->orderFactory->create()->load($orderId); - } -} diff --git a/app/code/Magento/Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php b/app/code/Magento/Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php deleted file mode 100644 index cdf9041510b45..0000000000000 --- a/app/code/Magento/Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php +++ /dev/null @@ -1,40 +0,0 @@ -paymentMethodMapping = $paymentMapping; - } - - /** - * Gets the Sygnifyd payment method by the order's payment method. - * - * @param string $paymentMethod - * @return string - */ - public function getSignifydPaymentMethodCode($paymentMethod) - { - return $this->paymentMethodMapping->get($paymentMethod, ''); - } -} diff --git a/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php b/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php deleted file mode 100644 index 5c3f23bb92729..0000000000000 --- a/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php +++ /dev/null @@ -1,88 +0,0 @@ -getElementsByTagName(self::$paymentMethodNodeType); - $paymentsList = []; - foreach ($paymentMethods as $paymentMethod) { - $paymentsList += $this->getPaymentMethodMapping($paymentMethod); - } - - return $paymentsList; - } - - /** - * Adds a payment method as key and a Sygnifyd payment method as value - * in the payment list array - * - * @param \DOMElement $payment - * @return array - * @throws ValidationSchemaException - */ - private function getPaymentMethodMapping(\DOMElement $payment) - { - $paymentMethodCode = $this->readSubnodeValue($payment, self::$magentoCodeNodeType); - $signifyPaymentMethodCode = $this->readSubnodeValue($payment, self::$signifydCodeNodeType); - - return [$paymentMethodCode => $signifyPaymentMethodCode]; - } - - /** - * Reads node value by node type - * - * @param \DOMElement $element - * @param string $subNodeType - * @return mixed - * @throws ValidationSchemaException - */ - private function readSubnodeValue(\DOMElement $element, $subNodeType) - { - $domList = $element->getElementsByTagName($subNodeType); - if (empty($domList[0])) { - throw new ValidationSchemaException(__('Only single entrance of "%1" node is required.', $subNodeType)); - } - - $subNodeValue = trim($domList[0]->nodeValue); - if (!$subNodeValue) { - throw new ValidationSchemaException(__('Not empty value for "%1" node is required.', $subNodeType)); - } - - return $subNodeValue; - } -} diff --git a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php deleted file mode 100644 index 5be5ccbc5e55a..0000000000000 --- a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php +++ /dev/null @@ -1,109 +0,0 @@ -config = $config; - $this->objectManager = $objectManager; - $this->avsDefaultAdapter = $avsDefaultAdapter; - $this->cvvDefaultAdapter = $cvvDefaultAdapter; - } - - /** - * Creates instance of CVV code verification. - * Exception will be thrown if CVV mapper does not implement PaymentVerificationInterface. - * - * @param string $paymentCode - * @return PaymentVerificationInterface - * @throws ConfigurationMismatchException - */ - public function createPaymentCvv($paymentCode) - { - return $this->create($this->cvvDefaultAdapter, $paymentCode, 'cvv_ems_adapter'); - } - - /** - * Creates instance of AVS code verification. - * Exception will be thrown if AVS mapper does not implement PaymentVerificationInterface. - * - * @param string $paymentCode - * @return PaymentVerificationInterface - * @throws ConfigurationMismatchException - */ - public function createPaymentAvs($paymentCode) - { - return $this->create($this->avsDefaultAdapter, $paymentCode, 'avs_ems_adapter'); - } - - /** - * Creates instance of PaymentVerificationInterface. - * Default implementation will be returned if payment method does not implement PaymentVerificationInterface. - * - * @param PaymentVerificationInterface $defaultAdapter - * @param string $paymentCode - * @param string $configKey - * @return PaymentVerificationInterface - * @throws ConfigurationMismatchException If payment verification instance - * does not implement PaymentVerificationInterface. - */ - private function create(PaymentVerificationInterface $defaultAdapter, $paymentCode, $configKey) - { - $this->config->setMethodCode($paymentCode); - $verificationClass = $this->config->getValue($configKey); - if ($verificationClass === null) { - return $defaultAdapter; - } - $mapper = $this->objectManager->create($verificationClass); - if (!$mapper instanceof PaymentVerificationInterface) { - throw new ConfigurationMismatchException( - __('%1 must implement %2', $verificationClass, PaymentVerificationInterface::class) - ); - } - return $mapper; - } -} diff --git a/app/code/Magento/Signifyd/Model/PredefinedVerificationCode.php b/app/code/Magento/Signifyd/Model/PredefinedVerificationCode.php deleted file mode 100644 index 618d74b2a52e9..0000000000000 --- a/app/code/Magento/Signifyd/Model/PredefinedVerificationCode.php +++ /dev/null @@ -1,37 +0,0 @@ -code = $code; - } - - /** - * @inheritdoc - */ - public function getCode(OrderPaymentInterface $orderPayment) - { - return $this->code; - } -} diff --git a/app/code/Magento/Signifyd/Model/QuoteSession/Adminhtml/BackendSession.php b/app/code/Magento/Signifyd/Model/QuoteSession/Adminhtml/BackendSession.php deleted file mode 100644 index 9be02719545c7..0000000000000 --- a/app/code/Magento/Signifyd/Model/QuoteSession/Adminhtml/BackendSession.php +++ /dev/null @@ -1,40 +0,0 @@ -backendQuoteSession = $backendQuoteSession; - } - - /** - * @inheritdoc - */ - public function getQuote() - { - return $this->backendQuoteSession->getQuote(); - } -} diff --git a/app/code/Magento/Signifyd/Model/QuoteSession/FrontendSession.php b/app/code/Magento/Signifyd/Model/QuoteSession/FrontendSession.php deleted file mode 100644 index 44c226ae4a47e..0000000000000 --- a/app/code/Magento/Signifyd/Model/QuoteSession/FrontendSession.php +++ /dev/null @@ -1,39 +0,0 @@ -checkoutSession = $checkoutSession; - } - - /** - * @inheritdoc - */ - public function getQuote() - { - return $this->checkoutSession->getQuote(); - } -} diff --git a/app/code/Magento/Signifyd/Model/QuoteSession/QuoteSessionInterface.php b/app/code/Magento/Signifyd/Model/QuoteSession/QuoteSessionInterface.php deleted file mode 100644 index 14958ac65a6ee..0000000000000 --- a/app/code/Magento/Signifyd/Model/QuoteSession/QuoteSessionInterface.php +++ /dev/null @@ -1,19 +0,0 @@ -_init('signifyd_case', 'entity_id'); - } -} diff --git a/app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity/Collection.php b/app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity/Collection.php deleted file mode 100644 index 92e233dd42dbc..0000000000000 --- a/app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity/Collection.php +++ /dev/null @@ -1,24 +0,0 @@ -_init(CaseEntity::class, CaseResourceModel::class); - } -} diff --git a/app/code/Magento/Signifyd/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php b/app/code/Magento/Signifyd/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php deleted file mode 100644 index 360225ae37b7b..0000000000000 --- a/app/code/Magento/Signifyd/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php +++ /dev/null @@ -1,54 +0,0 @@ -caseEntity = $caseEntity; - } - - /** - * @inheritdoc - */ - public function getIds($mainTableName, $gridTableName) - { - $connection = $this->caseEntity->getConnection(); - $select = $connection->select() - ->from($this->caseEntity->getMainTable(), ['order_id']) - ->joinLeft( - [$gridTableName => $connection->getTableName($gridTableName)], - sprintf( - '%s.%s = %s.%s', - $this->caseEntity->getMainTable(), - 'order_id', - $gridTableName, - 'entity_id' - ), - [] - ) - ->where('guarantee_disposition != signifyd_guarantee_status'); - - return $connection->fetchAll($select, [], \Zend_Db::FETCH_COLUMN); - } -} diff --git a/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php b/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php deleted file mode 100644 index fff42b300be58..0000000000000 --- a/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php +++ /dev/null @@ -1,55 +0,0 @@ -globalConfig = $globalConfig; - $this->entityGrid = $entityGrid; - } - - /** - * Handles synchronous updating order entity in grid. - * - * Works only if asynchronous grid indexing is disabled - * in global settings. - * - * @param int $orderId - * @return void - */ - public function update($orderId) - { - if (!$this->globalConfig->getValue('dev/grid/async_indexing')) { - $this->entityGrid->refresh($orderId); - } - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiCallException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiCallException.php deleted file mode 100644 index 73338c8ea4d62..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiCallException.php +++ /dev/null @@ -1,39 +0,0 @@ -requestData = $requestData; - parent::__construct($message, $code, $previous); - } - - /** - * Gets request data for unsuccessful request in JSON format - * @return string - */ - public function getRequestData() - { - return $this->requestData; - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php deleted file mode 100644 index 2d6d57a510ae3..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php +++ /dev/null @@ -1,49 +0,0 @@ -requestBuilder = $requestBuilder; - } - - /** - * Perform call to Signifyd API. - * - * Method returns associative array that corresponds to successful result. - * Current implementation do not expose details in case of failure. - * - * @param string $url - * @param string $method - * @param array $params - * @param int|null $storeId - * @return array - */ - public function makeApiCall($url, $method, array $params = [], $storeId = null): array - { - $result = $this->requestBuilder->doRequest($url, $method, $params, $storeId); - - return $result; - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Client/HttpClientFactory.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Client/HttpClientFactory.php deleted file mode 100644 index 2a9b933b98b5d..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Client/HttpClientFactory.php +++ /dev/null @@ -1,146 +0,0 @@ -config = $config; - $this->clientFactory = $clientFactory; - $this->dataEncoder = $dataEncoder; - } - - /** - * Creates and configures HTTP client. - * - * @param string $url - * @param string $method - * @param array $params - * @param int|null $storeId - * @return ZendClient - */ - public function create($url, $method, array $params = [], $storeId = null): ZendClient - { - $apiKey = $this->getApiKey($storeId); - $apiUrl = $this->buildFullApiUrl($url, $storeId); - - $client = $this->createNewClient(); - $client->setHeaders( - self::$authorizationType, - sprintf('Basic %s', base64_encode($apiKey)) - ); - if (!empty($params)) { - $encodedData = $this->dataEncoder->encode($params); - $client->setRawData($encodedData, self::$jsonDataType); - } - $client->setMethod($method); - $client->setUri($apiUrl); - - return $client; - } - - /** - * @return ZendClient - */ - private function createNewClient() - { - return $this->clientFactory->create(); - } - - /** - * Signifyd API key for merchant account. - * - * @see https://www.signifyd.com/docs/api/#/introduction/authentication - * @param int|null $storeId - * @return string - */ - private function getApiKey($storeId): string - { - return $this->config->getApiKey($storeId); - } - - /** - * Full URL for Singifyd API based on relative URL. - * - * @param string $url - * @param int|null $storeId - * @return string - */ - private function buildFullApiUrl($url, $storeId): string - { - $baseApiUrl = $this->getBaseApiUrl($storeId); - $fullUrl = $baseApiUrl . self::$urlSeparator . ltrim($url, self::$urlSeparator); - - return $fullUrl; - } - - /** - * Base Sigifyd API URL without trailing slash. - * - * @param int|null $storeId - * @return string - */ - private function getBaseApiUrl($storeId): string - { - $baseApiUrl = $this->config->getApiUrl($storeId); - - return rtrim($baseApiUrl, self::$urlSeparator); - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Client/RequestBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Client/RequestBuilder.php deleted file mode 100644 index ee079a74d345f..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Client/RequestBuilder.php +++ /dev/null @@ -1,63 +0,0 @@ -clientCreator = $clientCreator; - $this->requestSender = $requestSender; - $this->responseHandler = $responseHandler; - } - - /** - * Creates HTTP client for API call. - * - * @param string $url - * @param string $method - * @param array $params - * @param int|null $storeId - * @return array - */ - public function doRequest($url, $method, array $params = [], $storeId = null): array - { - $client = $this->clientCreator->create($url, $method, $params, $storeId); - $response = $this->requestSender->send($client, $storeId); - $result = $this->responseHandler->handle($response); - - return $result; - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Client/RequestSender.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Client/RequestSender.php deleted file mode 100644 index a63331e055c1c..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Client/RequestSender.php +++ /dev/null @@ -1,74 +0,0 @@ -debuggerFactory = $debuggerFactory; - } - - /** - * Sends HTTP request to Signifyd API with configured client. - * - * Each request/response pair is handled by debugger. - * If debug mode for Signifyd integration enabled in configuration - * debug information is recorded to debug.log. - * - * @param ZendClient $client - * @param int|null $storeId - * @return \Zend_Http_Response - * @throws ApiCallException - */ - public function send(ZendClient $client, $storeId = null): \Zend_Http_Response - { - try { - $response = $client->request(); - - $this->debuggerFactory->create($storeId)->success( - $client->getUri(true), - $client->getLastRequest(), - $response->getStatus() . ' ' . $response->getMessage(), - $response->getBody() - ); - - return $response; - } catch (\Exception $e) { - $this->debuggerFactory->create($storeId)->failure( - $client->getUri(true), - $client->getLastRequest(), - $e - ); - - throw new ApiCallException( - 'Unable to process Signifyd API: ' . $e->getMessage(), - $e->getCode(), - $e, - $client->getLastRequest() - ); - } - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Client/ResponseHandler.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Client/ResponseHandler.php deleted file mode 100644 index 614e59b7c29a2..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Client/ResponseHandler.php +++ /dev/null @@ -1,124 +0,0 @@ - 'Bad Request - The request could not be parsed. Response: %s', - 401 => 'Unauthorized - user is not logged in, could not be authenticated. Response: %s', - 403 => 'Forbidden - Cannot access resource. Response: %s', - 404 => 'Not Found - resource does not exist. Response: %s', - 409 => 'Conflict - with state of the resource on server. Can occur with (too rapid) PUT requests. Response: %s', - 500 => 'Server error. Response: %s' - ]; - - /** - * Unexpected Signifyd API response message. - * - * @var string - */ - private static $unexpectedResponse = 'Unexpected Signifyd API response code "%s" with content "%s".'; - - /** - * @var DecoderInterface - */ - private $dataDecoder; - - /** - * ResponseHandler constructor. - * - * @param DecoderInterface $dataDecoder - */ - public function __construct( - DecoderInterface $dataDecoder - ) { - $this->dataDecoder = $dataDecoder; - } - - /** - * Reads result of successful operation and throws exception in case of any failure. - * - * @param \Zend_Http_Response $response - * @return array - * @throws ApiCallException - */ - public function handle(\Zend_Http_Response $response) - { - $responseCode = $response->getStatus(); - - if (!in_array($responseCode, self::$successResponseCodes)) { - $errorMessage = $this->buildApiCallFailureMessage($response); - throw new ApiCallException($errorMessage); - } - - $responseBody = (string)$response->getBody(); - - if (self::$phpVersionId < 70000 && empty($responseBody)) { - /* - * Only since PHP 7.0 empty string treated as JSON syntax error - * http://php.net/manual/en/function.json-decode.php - */ - throw new ApiCallException('Response is not valid JSON: Decoding failed: Syntax error'); - } - - try { - $decodedResponseBody = $this->dataDecoder->decode($responseBody); - } catch (\Exception $e) { - throw new ApiCallException( - 'Response is not valid JSON: ' . $e->getMessage(), - $e->getCode(), - $e - ); - } - - return $decodedResponseBody; - } - - /** - * Error message for request rejected by Signify. - * - * @param \Zend_Http_Response $response - * @return string - */ - private function buildApiCallFailureMessage(\Zend_Http_Response $response) - { - $responseBody = $response->getBody(); - - if (key_exists($response->getStatus(), self::$failureResponses)) { - return sprintf(self::$failureResponses[$response->getStatus()], $responseBody); - } - - return sprintf( - self::$unexpectedResponse, - $response->getStatus(), - $responseBody - ); - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/BlackHole.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/BlackHole.php deleted file mode 100644 index 7057313b5e415..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/BlackHole.php +++ /dev/null @@ -1,33 +0,0 @@ - Configuration > Sales > Fraud Detection > Signifyd > Debug) - */ -class DebuggerFactory -{ - /** - * @var ObjectManagerInterface - */ - private $objectManager; - - /** - * @var Config - */ - private $config; - - /** - * DebuggerFactory constructor. - * - * @param ObjectManagerInterface $objectManager - * @param Config $config - */ - public function __construct( - ObjectManagerInterface $objectManager, - Config $config - ) { - $this->objectManager = $objectManager; - $this->config = $config; - } - - /** - * Create debugger instance - * - * @param int|null $storeId - * @return DebuggerInterface - */ - public function create($storeId = null): DebuggerInterface - { - if (!$this->config->isDebugModeEnabled($storeId)) { - return $this->objectManager->get(BlackHole::class); - } - - return $this->objectManager->get(Log::class); - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/DebuggerInterface.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/DebuggerInterface.php deleted file mode 100644 index f4a2f9cc56a8f..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/DebuggerInterface.php +++ /dev/null @@ -1,35 +0,0 @@ -logger = $logger; - } - - /** - * {@inheritdoc} - */ - public function success($requestUrl, $requestData, $responseStatus, $responseBody) - { - $requestInfo = $this->buildRequestInfo($requestUrl, $requestData); - $responseInfo = $this->buildResponseInfo($responseStatus, $responseBody); - - $info = $requestInfo - . $responseInfo; - - $this->writeToLog($info); - } - - /** - * {@inheritdoc} - */ - public function failure($requestUrl, $requestData, Exception $exception) - { - $requestInfo = $this->buildRequestInfo($requestUrl, $requestData); - $exceptionInfo = $this->buildExceptionInfo($exception); - - $info = $requestInfo - . $exceptionInfo; - - $this->writeToLog($info); - } - - /** - * Build string with request URL and body - * - * @param string $requestUrl - * @param string $requestData - * @return string - */ - private function buildRequestInfo($requestUrl, $requestData) - { - $infoContent = $this->buildInfoSection('URL', $requestUrl) - . $this->buildInfoSection('Body', $requestData); - - $info = $this->buildInfoSection('Request', $infoContent); - return $info; - } - - /** - * Build string with response status code and body - * - * @param string $responseStatus - * @param string $responseBody - * @return string - */ - private function buildResponseInfo($responseStatus, $responseBody) - { - $infoContent = $this->buildInfoSection('Status', $responseStatus) - . $this->buildInfoSection('Body', $responseBody); - - $info = $this->buildInfoSection('Response', $infoContent); - return $info; - } - - /** - * Build string with exception information - * - * @param Exception $exception - * @return string - */ - private function buildExceptionInfo(Exception $exception) - { - $infoContent = (string)$exception; - $info = $this->buildInfoSection('Exception', $infoContent); - return $info; - } - - /** - * Write debug information to log file (var/log/debug.log by default) - * - * @param string $info - * @return void - */ - private function writeToLog($info) - { - $logMessage = $this->buildInfoSection('Signifyd API integration debug info', $info); - $this->logger->debug($logMessage); - } - - /** - * Build unified debug section string - * - * @param string $title - * @param string $content - * @return string - */ - private function buildInfoSection($title, $content) - { - $formattedInfo = $title . ":\n" - . $this->addIndent($content) . "\n"; - return $formattedInfo; - } - - /** - * Add indent to each line in content - * - * @param string $content - * @param string $indent - * @return string - */ - private function addIndent($content, $indent = ' ') - { - $contentLines = explode("\n", $content); - $contentLinesWithIndent = array_map(function ($line) use ($indent) { - return $indent . $line; - }, $contentLines); - $content = implode("\n", $contentLinesWithIndent); - return $content; - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php deleted file mode 100644 index 9f7a053c58724..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php +++ /dev/null @@ -1,225 +0,0 @@ -createCaseBuilder = $createCaseBuilder; - $this->apiClient = $apiClient; - $this->orderRepository = $orderRepository; - $this->caseRepository = $caseRepository; - } - - /** - * Returns id of created case (investigation) on Signifyd service - * @see https://www.signifyd.com/docs/api/#/reference/cases/create-a-case - * - * @param int $orderId - * @return int Signifyd case (investigation) identifier - * @throws GatewayException - */ - public function createCase($orderId) - { - $caseParams = $this->createCaseBuilder->build($orderId); - $storeId = $this->getStoreIdFromOrder($orderId); - - $caseCreationResult = $this->apiClient->makeApiCall( - '/cases', - 'POST', - $caseParams, - $storeId - ); - - if (!isset($caseCreationResult['investigationId'])) { - throw new GatewayException('Expected field "investigationId" missed.'); - } - - return (int)$caseCreationResult['investigationId']; - } - - /** - * Returns guaranty decision result - * @see https://www.signifyd.com/docs/api/#/reference/guarantees/submit-a-case-for-guarantee - * - * @param int $signifydCaseId - * @return string - * @throws GatewayException - */ - public function submitCaseForGuarantee($signifydCaseId) - { - $storeId = $this->getStoreIdFromCase($signifydCaseId); - $guaranteeCreationResult = $this->apiClient->makeApiCall( - '/guarantees', - 'POST', - [ - 'caseId' => $signifydCaseId, - ], - $storeId - ); - - $disposition = $this->processDispositionResult($guaranteeCreationResult); - return $disposition; - } - - /** - * Sends request to cancel guarantee and returns disposition. - * - * @see https://www.signifyd.com/docs/api/#/reference/guarantees/submit-a-case-for-guarantee/cancel-guarantee - * @param int $caseId - * @return string - * @throws GatewayException - */ - public function cancelGuarantee($caseId) - { - $storeId = $this->getStoreIdFromCase($caseId); - $result = $this->apiClient->makeApiCall( - '/cases/' . $caseId . '/guarantee', - 'PUT', - [ - 'guaranteeDisposition' => self::GUARANTEE_CANCELED - ], - $storeId - ); - - $disposition = $this->processDispositionResult($result); - if ($disposition !== self::GUARANTEE_CANCELED) { - throw new GatewayException("API returned unexpected disposition: $disposition."); - } - - return $disposition; - } - - /** - * Processes result from Signifyd API. - * Throws the GatewayException is result does not contain guarantee disposition in response or - * disposition has unknown status. - * - * @param array $result - * @return string - * @throws GatewayException - */ - private function processDispositionResult(array $result) - { - if (!isset($result['disposition'])) { - throw new GatewayException('Expected field "disposition" missed.'); - } - - $disposition = strtoupper($result['disposition']); - - if (!in_array($disposition, [ - self::GUARANTEE_APPROVED, - self::GUARANTEE_DECLINED, - self::GUARANTEE_PENDING, - self::GUARANTEE_CANCELED, - self::GUARANTEE_IN_REVIEW, - self::GUARANTEE_UNREQUESTED - ])) { - throw new GatewayException( - sprintf('API returns unknown guaranty disposition "%s".', $disposition) - ); - } - - return $disposition; - } - - /** - * Returns store id by case. - * - * @param int $caseId - * @return int|null - */ - private function getStoreIdFromCase(int $caseId) - { - $case = $this->caseRepository->getByCaseId($caseId); - $orderId = $case->getOrderId(); - - return $this->getStoreIdFromOrder($orderId); - } - - /** - * Returns store id from order. - * - * @param int $orderId - * @return int|null - */ - private function getStoreIdFromOrder(int $orderId) - { - $order = $this->orderRepository->get($orderId); - - return $order->getStoreId(); - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/GatewayException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/GatewayException.php deleted file mode 100644 index 666217f8ccc85..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/GatewayException.php +++ /dev/null @@ -1,14 +0,0 @@ - $this->getStreetLine(1, $address->getStreet()), - 'unit' => $this->getStreetLine(2, $address->getStreet()), - 'city' => $address->getCity(), - 'provinceCode' => $address->getRegionCode(), - 'postalCode' => $address->getPostcode(), - 'countryCode' => $address->getCountryId() - ]; - } - - /** - * Get street line by number - * - * @param int $number - * @param string[]|null $street - * @return string - */ - private function getStreetLine($number, $street) - { - $lines = is_array($street) ? $street : []; - - return $lines[$number - 1] ?? ''; - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CardBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CardBuilder.php deleted file mode 100644 index 5e3a1a83e7aeb..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CardBuilder.php +++ /dev/null @@ -1,56 +0,0 @@ -addressBuilder = $addressBuilder; - } - - /** - * Returns card data params based on payment and billing address info - * - * @param Order $order - * @return array - */ - public function build(Order $order) - { - $result = []; - $address = $order->getBillingAddress(); - if ($address === null) { - return $result; - } - - $payment = $order->getPayment(); - $result = [ - 'card' => [ - 'cardHolderName' => $address->getFirstname() . ' ' . $address->getLastname(), - 'last4' => $payment->getCcLast4(), - 'expiryMonth' => $payment->getCcExpMonth(), - 'expiryYear' => $payment->getCcExpYear(), - 'billingAddress' => $this->addressBuilder->build($address) - ] - ]; - - return $result; - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/ClientVersionBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/ClientVersionBuilder.php deleted file mode 100644 index 8db06473b96d8..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/ClientVersionBuilder.php +++ /dev/null @@ -1,50 +0,0 @@ -productMetadata = $productMetadata; - } - - /** - * Returns version info - * - * @return array - */ - public function build() - { - return [ - 'platformAndClient' => [ - 'storePlatform' => $this->productMetadata->getName() . ' ' . $this->productMetadata->getEdition(), - 'storePlatformVersion' => $this->productMetadata->getVersion(), - 'signifydClientApp' => $this->productMetadata->getName(), - 'signifydClientAppVersion' => self::$clientVersion, - ] - ]; - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php deleted file mode 100644 index 3e41003d47842..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php +++ /dev/null @@ -1,131 +0,0 @@ -orderFactory = $orderFactory; - $this->purchaseBuilder = $purchaseBuilder; - $this->cardBuilder = $cardBuilder; - $this->recipientBuilder = $recipientBuilder; - $this->sellerBuilder = $sellerBuilder; - $this->clientVersionBuilder = $clientVersionBuilder; - $this->userAccountBuilder = $userAccountBuilder; - } - - /** - * @inheritdoc - */ - public function build($orderId) - { - /* @var $order \Magento\Sales\Model\Order */ - $order = $this->orderFactory->create()->load($orderId); - - return $this->removeEmptyValues( - array_merge( - $this->purchaseBuilder->build($order), - $this->cardBuilder->build($order), - $this->recipientBuilder->build($order), - $this->userAccountBuilder->build($order), - $this->sellerBuilder->build($order), - $this->clientVersionBuilder->build() - ) - ); - } - - /** - * Remove empty and null values. - * - * @param array $data - * @return array - */ - private function removeEmptyValues($data) - { - foreach ($data as $key => $value) { - if (is_array($value)) { - $data[$key] = $this->removeEmptyValues($data[$key]); - } - - if ($this->isEmpty($data[$key])) { - unset($data[$key]); - } - } - - return $data; - } - - /** - * Empty values are null, empty string and empty array. - * - * @param mixed $value - * @return bool - */ - private function isEmpty($value) - { - return $value === null || (is_array($value) && empty($value)); - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php deleted file mode 100644 index 56662f69e7c5a..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php +++ /dev/null @@ -1,22 +0,0 @@ -dateTimeFactory = $dateTimeFactory; - $this->scope = $scope; - $this->signifydOrderSessionId = $signifydOrderSessionId; - $this->paymentVerificationFactory = $paymentVerificationFactory; - $this->paymentMethodMapper = $paymentMethodMapper; - } - - /** - * Returns purchase data params - * - * @param Order $order - * @return array - * @throws ConfigurationMismatchException - */ - public function build(Order $order) - { - $orderPayment = $order->getPayment(); - $createdAt = $this->dateTimeFactory->create( - $order->getCreatedAt(), - new \DateTimeZone('UTC') - ); - - $result = [ - 'purchase' => [ - 'orderSessionId' => $this->signifydOrderSessionId->get($order->getQuoteId()), - 'browserIpAddress' => $order->getRemoteIp(), - 'orderId' => $order->getIncrementId(), - 'createdAt' => $createdAt->format(\DateTime::ATOM), - 'paymentGateway' => $this->getPaymentGateway($orderPayment->getMethod()), - 'transactionId' => $orderPayment->getLastTransId(), - 'currency' => $order->getOrderCurrencyCode(), - 'avsResponseCode' => $this->getAvsCode($orderPayment), - 'cvvResponseCode' => $this->getCvvCode($orderPayment), - 'orderChannel' => $this->getOrderChannel(), - 'totalPrice' => $order->getGrandTotal(), - 'paymentMethod' => $this->paymentMethodMapper - ->getSignifydPaymentMethodCode($orderPayment->getMethod()) - ], - ]; - - $shippingDescription = $order->getShippingDescription(); - if ($shippingDescription !== null) { - $result['purchase']['shipments'] = [ - [ - 'shipper' => $this->getShipper($order->getShippingDescription()), - 'shippingMethod' => $this->getShippingMethod($order->getShippingDescription()), - 'shippingPrice' => $order->getShippingAmount() - ] - ]; - } - - $products = $this->getProducts($order); - if (!empty($products)) { - $result['purchase']['products'] = $products; - } - - return $result; - } - - /** - * Returns the products purchased in the transaction. - * - * @param Order $order - * @return array - */ - private function getProducts(Order $order) - { - $result = []; - foreach ($order->getAllItems() as $orderItem) { - $result[] = [ - 'itemId' => $orderItem->getSku(), - 'itemName' => $orderItem->getName(), - 'itemPrice' => $orderItem->getPrice(), - 'itemQuantity' => (int)$orderItem->getQtyOrdered(), - 'itemUrl' => $orderItem->getProduct()->getProductUrl(), - 'itemWeight' => $orderItem->getProduct()->getWeight() - ]; - } - - return $result; - } - - /** - * Returns the name of the shipper - * - * @param string $shippingDescription - * @return string - */ - private function getShipper($shippingDescription) - { - $result = explode(' - ', $shippingDescription, 2); - - return count($result) == 2 ? $result[0] : ''; - } - - /** - * Returns the type of the shipment method used - * - * @param string $shippingDescription - * @return string - */ - private function getShippingMethod($shippingDescription) - { - $result = explode(' - ', $shippingDescription, 2); - - return count($result) == 2 ? $result[1] : ''; - } - - /** - * Returns the gateway that processed the transaction. For PayPal orders should be paypal_account. - * - * @param string $gatewayCode - * @return string - */ - private function getPaymentGateway($gatewayCode) - { - $payPalCodeList = [ - 'paypal_express', - 'braintree_paypal', - 'payflowpro', - 'payflow_express', - 'payflow_link', - 'payflow_advanced', - 'hosted_pro', - ]; - return in_array($gatewayCode, $payPalCodeList) ? 'paypal_account' : $gatewayCode; - } - - /** - * Returns WEB for web-orders, PHONE for orders created by Admin - * - * @return string - */ - private function getOrderChannel() - { - return $this->scope->getCurrentScope() === Area::AREA_ADMINHTML ? 'PHONE' : 'WEB'; - } - - /** - * Gets AVS code for order payment method. - * - * @param OrderPaymentInterface $orderPayment - * @return string - * @throws ConfigurationMismatchException - */ - private function getAvsCode(OrderPaymentInterface $orderPayment) - { - $avsAdapter = $this->paymentVerificationFactory->createPaymentAvs($orderPayment->getMethod()); - return $avsAdapter->getCode($orderPayment); - } - - /** - * Gets CVV code for order payment method. - * - * @param OrderPaymentInterface $orderPayment - * @return string - * @throws ConfigurationMismatchException - */ - private function getCvvCode(OrderPaymentInterface $orderPayment) - { - $cvvAdapter = $this->paymentVerificationFactory->createPaymentCvv($orderPayment->getMethod()); - return $cvvAdapter->getCode($orderPayment); - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/RecipientBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/RecipientBuilder.php deleted file mode 100644 index d9d26c8943b88..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/RecipientBuilder.php +++ /dev/null @@ -1,55 +0,0 @@ -addressBuilder = $addressBuilder; - } - - /** - * Returns recipient data params based on shipping address - * - * @param Order $order - * @return array - */ - public function build(Order $order) - { - $result = []; - $address = $order->getShippingAddress(); - if ($address === null) { - return $result; - } - - $result = [ - 'recipient' => [ - 'fullName' => $address->getName(), - 'confirmationEmail' => $address->getEmail(), - 'confirmationPhone' => $address->getTelephone(), - 'organization' => $address->getCompany(), - 'deliveryAddress' => $this->addressBuilder->build($address) - ] - ]; - - return $result; - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php deleted file mode 100644 index b2cf0401b247f..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php +++ /dev/null @@ -1,136 +0,0 @@ -scopeConfig = $scopeConfig; - $this->regionFactory = $regionFactory; - } - - /** - * Returns seller data params - * - * @param Order $order - * @return array - */ - public function build(Order $order) - { - $store = $order->getStore(); - - return [ - 'seller' => [ - 'name' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_NAME, $store), - 'domain' => $this->getPublicDomain($store), - 'shipFromAddress' => [ - 'streetAddress' => $this->getConfigValue(Shipment::XML_PATH_STORE_ADDRESS1, $store), - 'unit' => $this->getConfigValue(Shipment::XML_PATH_STORE_ADDRESS2, $store), - 'city' => $this->getConfigValue(Shipment::XML_PATH_STORE_CITY, $store), - 'provinceCode' => $this->getRegionCodeById( - $this->getConfigValue(Shipment::XML_PATH_STORE_REGION_ID, $store) - ), - 'postalCode' => $this->getConfigValue(Shipment::XML_PATH_STORE_ZIP, $store), - 'countryCode' => $this->getConfigValue(Shipment::XML_PATH_STORE_COUNTRY_ID, $store), - ], - 'corporateAddress' => [ - 'streetAddress' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_STREET_LINE1, $store), - 'unit' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_STREET_LINE2, $store), - 'city' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_CITY, $store), - 'provinceCode' => $this->getRegionCodeById( - $this->getConfigValue(Information::XML_PATH_STORE_INFO_REGION_CODE, $store) - ), - 'postalCode' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_POSTCODE, $store), - 'countryCode' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_COUNTRY_CODE, $store), - ] - ] - ]; - } - - /** - * Returns region code by id - * - * @param int $regionId - * @return string - */ - private function getRegionCodeById($regionId) - { - if (!isset($this->regionCodes[$regionId])) { - $this->regionCodes[$regionId] = $this->regionFactory->create()->load($regionId)->getCode(); - } - - return $this->regionCodes[$regionId]; - } - - /** - * Returns value from config - * - * @param string $value - * @param StoreInterface $store - * @return mixed - */ - private function getConfigValue($value, StoreInterface $store) - { - return $this->scopeConfig->getValue( - $value, - ScopeInterface::SCOPE_STORE, - $store - ); - } - - /** - * Returns public domain name - * - * @param StoreInterface $store - * @return string|null null if no DNS records corresponding to a current host found - */ - private function getPublicDomain(StoreInterface $store) - { - $baseUrl = $store->getBaseUrl(); - $domain = parse_url($baseUrl, PHP_URL_HOST); - if (\function_exists('checkdnsrr') && false === \checkdnsrr($domain)) { - return null; - } - - return $domain; - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php deleted file mode 100644 index 0da49b85da869..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php +++ /dev/null @@ -1,100 +0,0 @@ -customerRepository = $customerRepository; - $this->dateTimeFactory = $dateTimeFactory; - $this->customerOrders = $customerOrders; - } - - /** - * Returns user account data params. - * Only for registered customers. - * - * @param Order $order - * @return array - */ - public function build(Order $order) - { - $result = []; - - $customerId = $order->getCustomerId(); - if (null === $customerId) { - return $result; - } - - $customer = $this->customerRepository->getById($customerId); - $result = [ - 'userAccount' => [ - 'email' => $customer->getEmail(), - 'username' => $customer->getEmail(), - 'phone' => $order->getBillingAddress()->getTelephone(), - 'accountNumber' => $customerId, - 'createdDate' => $this->formatDate($customer->getCreatedAt()), - 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt()) - ] - ]; - - $ordersInfo = $this->customerOrders->getAggregatedOrdersInfo($customerId); - if (isset($ordersInfo['aggregateOrderCount'])) { - $result['userAccount']['aggregateOrderCount'] = $ordersInfo['aggregateOrderCount']; - } - if (isset($ordersInfo['aggregateOrderDollars'])) { - $result['userAccount']['aggregateOrderDollars'] = $ordersInfo['aggregateOrderDollars']; - } - - return $result; - } - - /** - * Returns date formatted according to ISO8601. - * - * @param string $date - * @return string - */ - private function formatDate($date) - { - $result = $this->dateTimeFactory->create( - $date, - new \DateTimeZone('UTC') - ); - - return $result->format(\DateTime::ATOM); - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php deleted file mode 100644 index f77db737473c0..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php +++ /dev/null @@ -1,64 +0,0 @@ -data = $data; - $this->eventTopic = $eventTopic; - } - - /** - * Returns decoded webhook request body. - * - * @return array - */ - public function getData() - { - return $this->data; - } - - /** - * Returns event topic identifier. - * - * @return string - */ - public function getEventTopic() - { - return $this->eventTopic; - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php deleted file mode 100644 index 50389102359b1..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php +++ /dev/null @@ -1,65 +0,0 @@ -dataDecoder = $decoder; - $this->webhookMessageFactory = $webhookMessageFactory; - } - - /** - * Returns webhook message data object. - * - * @param WebhookRequest $request - * @return WebhookMessage - * @throws \InvalidArgumentException - */ - public function read(WebhookRequest $request) - { - try { - $decodedData = $this->dataDecoder->decode($request->getBody()); - } catch (\Exception $e) { - throw new \InvalidArgumentException( - 'Webhook request body is not valid JSON: ' . $e->getMessage(), - $e->getCode(), - $e - ); - } - - $webhookMessage = $this->webhookMessageFactory->create( - [ - 'data' => $decodedData, - 'eventTopic' => $request->getEventTopic() - ] - ); - - return $webhookMessage; - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php deleted file mode 100644 index 214ccf0eeb70f..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php +++ /dev/null @@ -1,58 +0,0 @@ -request = $request; - } - - /** - * Returns Base64 encoded output of the HMAC SHA256 encoding of the JSON body of the message. - * - * @return string - */ - public function getHash() - { - return (string)$this->request->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256'); - } - - /** - * Returns event topic identifier. - * - * @return string - */ - public function getEventTopic() - { - return (string)$this->request->getHeader('X-SIGNIFYD-TOPIC'); - } - - /** - * Returns raw data from the request body. - * - * @return string - */ - public function getBody() - { - return (string)$this->request->getContent(); - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestValidator.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestValidator.php deleted file mode 100644 index 274ef2f854684..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestValidator.php +++ /dev/null @@ -1,113 +0,0 @@ -config = $config; - $this->decoder = $decoder; - } - - /** - * Validates webhook request. - * - * @param WebhookRequest $webhookRequest - * @return bool - */ - public function validate(WebhookRequest $webhookRequest) - { - $body = $webhookRequest->getBody(); - $eventTopic = $webhookRequest->getEventTopic(); - $hash = $webhookRequest->getHash(); - - return $this->isValidTopic($eventTopic) - && $this->isValidBody($body) - && $this->isValidHash($eventTopic, $body, $hash); - } - - /** - * Checks if value of topic identifier is in allowed list - * - * @param string $topic topic identifier. - * @return bool - */ - private function isValidTopic($topic) - { - return in_array($topic, $this->allowedTopicValues); - } - - /** - * Verifies a webhook request body is valid JSON and not empty. - * - * @param string $body - * @return bool - */ - private function isValidBody($body) - { - try { - $decodedBody = $this->decoder->decode($body); - } catch (\Exception $e) { - return false; - } - - return !empty($decodedBody); - } - - /** - * Verifies a webhook request has in fact come from SIGNIFYD. - * - * @param string $eventTopic - * @param string $body - * @param string $hash - * @return bool - */ - private function isValidHash($eventTopic, $body, $hash) - { - // In the case that this is a webhook test, the encoding ABCDE is allowed - $apiKey = $eventTopic == 'cases/test' ? 'ABCDE' : $this->config->getApiKey(); - $actualHash = base64_encode(hash_hmac('sha256', $body, $apiKey, true)); - - return $hash === $actualHash; - } -} diff --git a/app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php b/app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php deleted file mode 100644 index 52746bc4ec6c5..0000000000000 --- a/app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php +++ /dev/null @@ -1,39 +0,0 @@ -identityGenerator = $identityGenerator; - } - - /** - * Returns unique identifier through generation uuid by quote id. - * - * @param int $quoteId - * @return string - */ - public function get($quoteId) - { - return $this->identityGenerator->generateIdForData($quoteId); - } -} diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php deleted file mode 100644 index 7c451a129cccd..0000000000000 --- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php +++ /dev/null @@ -1,112 +0,0 @@ -signifydIntegrationConfig = $signifydIntegrationConfig; - $this->caseCreationService = $caseCreationService; - $this->logger = $logger; - } - - /** - * {@inheritdoc} - */ - public function execute(Observer $observer) - { - $orders = $this->extractOrders( - $observer->getEvent() - ); - - if (null === $orders) { - return; - } - - foreach ($orders as $order) { - $storeId = $order->getStoreId(); - if ($this->signifydIntegrationConfig->isActive($storeId)) { - $this->createCaseForOrder($order); - } - } - } - - /** - * Creates Signifyd case for single order with online payment method. - * - * @param OrderInterface $order - * @return void - */ - private function createCaseForOrder($order) - { - $orderId = $order->getEntityId(); - if (null === $orderId - || $order->getPayment()->getMethodInstance()->isOffline() - || $order->getState() === Order::STATE_PENDING_PAYMENT) { - return; - } - - try { - $this->caseCreationService->createForOrder($orderId); - } catch (AlreadyExistsException $e) { - $this->logger->error($e->getMessage()); - } - } - - /** - * Returns Orders entity list from Event data container - * - * @param Event $event - * @return OrderInterface[]|null - */ - private function extractOrders(Event $event) - { - $order = $event->getData('order'); - if (null !== $order) { - return [$order]; - } - - return $event->getData('orders'); - } -} diff --git a/app/code/Magento/Signifyd/Plugin/OrderPlugin.php b/app/code/Magento/Signifyd/Plugin/OrderPlugin.php deleted file mode 100644 index 663409d0eb824..0000000000000 --- a/app/code/Magento/Signifyd/Plugin/OrderPlugin.php +++ /dev/null @@ -1,52 +0,0 @@ -guaranteeCancelingService = $guaranteeCancelingService; - } - - /** - * Performs Signifyd guarantee cancel operation after order canceling - * if cancel order operation was successful. - * - * @see Order::cancel - * @param Order $order - * @param OrderInterface $result - * @return OrderInterface - */ - public function afterCancel(Order $order, $result) - { - if ($order->isCanceled()) { - $this->guaranteeCancelingService->cancelForOrder( - $order->getEntityId() - ); - } - - return $result; - } -} diff --git a/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php b/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php deleted file mode 100644 index 17cf4d7e7dbe9..0000000000000 --- a/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php +++ /dev/null @@ -1,67 +0,0 @@ -guaranteeCancelingService = $guaranteeCancelingService; - } - - /** - * Performs Signifyd guarantee cancel operation after payment denying. - * - * @see MethodInterface::denyPayment - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * - * @param MethodInterface $subject - * @param MethodInterface|bool $result - * @param InfoInterface $payment - * @return bool|MethodInterface - */ - public function afterDenyPayment(MethodInterface $subject, $result, InfoInterface $payment) - { - if ($this->isPaymentDenied($payment, $result)) { - $this->guaranteeCancelingService->cancelForOrder($payment->getParentId()); - } - - return $result; - } - - /** - * Checks if deny payment operation was successful. - * - * Result not false check for payment methods using AbstractMethod. - * Transaction is closed check for payment methods using Gateway. - * - * @param InfoInterface $payment - * @param MethodInterface $result - * @return bool - */ - private function isPaymentDenied($payment, $result) - { - return $result !== false || $payment->getIsTransactionClosed(); - } -} diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md deleted file mode 100644 index 8048716bed444..0000000000000 --- a/app/code/Magento/Signifyd/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# Magento_Signifyd module - -## Overview - -The Magento_Signifyd module provides integration with the [Signifyd](https://www.signifyd.com/) fraud protection system. The integration is based on the Signifyd API; see the [Signifyd API docs](https://www.signifyd.com/docs/api/#/introduction/) for technical details. - -The module implementation allows to: - - - create a [Signifyd case](https://www.signifyd.com/docs/api/#/reference/cases) for a placed order - - automatically receive a [Signifyd guarantee](https://www.signifyd.com/docs/api/#/reference/guarantees) for a created case - - automatically cancel a guarantee when the order is canceled - -## Extensibility - -The Magento_Signifyd module does not add own Events, Layouts, and UI Components as extension points. - -### Public API - -The following interfaces (marked with the `@api` annotation) provide methods that allow to: - -`Magento\Signifyd\Api\Data\CaseInterface` (common abstraction for the Signifyd case entity): - -- set or retrieve all case data fields - -`Magento\Signifyd\Api\CaseManagementInterface`: - -- create a new case entity -- retrieve the existing case entity for a specified order - -`Magento\Signifyd\Api\CaseCreationServiceInterface`: - -- create a case entity for a specified order -- send a request through the Signifyd API to create a new case - -`Magento\Signifyd\Api\CaseRepositoryInterface`: - -- describe methods to work with a case entity - -`Magento\Signifyd\Api\GuaranteeCreationServiceInterface`: - -- send a request through the Signifyd API to create a new case guarantee - -`Magento\Signifyd\Api\GuaranteeCancelingServiceInterface`: -- send a request through the Signifyd API to cancel the Signifyd case guarantee - -`Magento\Signifyd\Api\Data\CaseSearchResultsInterface`: - -- might be used by `Magento\Signifyd\Api\CaseRepositoryInterface` to retrieve a list of case entities by specific conditions - -For information about a public API in Magento 2, see [Public interfaces & APIs](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/api-concepts.html). - -## Additional information - -### Webhooks - -To update the entity data for a case or guarantee, the Magento_Signifyd module uses the [Signifyd Webhooks](https://www.signifyd.com/docs/api/#/reference/webhooks) mechanism. - -The newly created case entities have the `PENDING` status for a case and a guarantee. After receiving Webhook, both statuses are changed to appropriate Signifyd statuses. - -### Debug mode - -The Debug Mode may be enabled in the module configuration. This logs the communication data between the Magento_Signifyd module and the Signifyd service in this file: - - var/log/debug.log - -### Backward incompatible changes - -The Magento_Signifyd module does not introduce backward incompatible changes. - -You can track [backward incompatible changes in patch releases](https://devdocs.magento.com/guides/v2.3/release-notes/backward-incompatible-changes/reference.html). - -### Processing supplementary payment information - -To improve the accuracy of Signifyd's transaction estimation, you may perform these operations (links lead to the Magento Developer Documentation Portal): - -- [Provide custom AVS/CVV mapping](https://devdocs.magento.com/guides/v2.3/payments-integrations/signifyd/signifyd.html#provide-avscvv-response-codes) - -- [Retrieve payment method for a placed order](https://devdocs.magento.com/guides/v2.3/payments-integrations/signifyd/signifyd.html#retrieve-payment-method-for-a-placed-order) diff --git a/app/code/Magento/Signifyd/Test/Mftf/LICENSE.txt b/app/code/Magento/Signifyd/Test/Mftf/LICENSE.txt deleted file mode 100644 index 49525fd99da9c..0000000000000 --- a/app/code/Magento/Signifyd/Test/Mftf/LICENSE.txt +++ /dev/null @@ -1,48 +0,0 @@ - -Open Software License ("OSL") v. 3.0 - -This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: - -Licensed under the Open Software License version 3.0 - - 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: - - 1. to reproduce the Original Work in copies, either alone or as part of a collective work; - - 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; - - 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; - - 4. to perform the Original Work publicly; and - - 5. to display the Original Work publicly. - - 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. - - 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. - - 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. - - 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). - - 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. - - 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. - - 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. - - 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). - - 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. - - 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. - - 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. - - 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. - - 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - - 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. - - 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magento/Signifyd/Test/Mftf/LICENSE_AFL.txt b/app/code/Magento/Signifyd/Test/Mftf/LICENSE_AFL.txt deleted file mode 100644 index f39d641b18a19..0000000000000 --- a/app/code/Magento/Signifyd/Test/Mftf/LICENSE_AFL.txt +++ /dev/null @@ -1,48 +0,0 @@ - -Academic Free License ("AFL") v. 3.0 - -This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: - -Licensed under the Academic Free License version 3.0 - - 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: - - 1. to reproduce the Original Work in copies, either alone or as part of a collective work; - - 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; - - 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License; - - 4. to perform the Original Work publicly; and - - 5. to display the Original Work publicly. - - 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. - - 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. - - 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. - - 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). - - 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. - - 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. - - 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. - - 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). - - 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. - - 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. - - 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. - - 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. - - 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - - 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. - - 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. diff --git a/app/code/Magento/Signifyd/Test/Mftf/Page/AdminFraudProtectionPage.xml b/app/code/Magento/Signifyd/Test/Mftf/Page/AdminFraudProtectionPage.xml deleted file mode 100644 index 07b58b8594843..0000000000000 --- a/app/code/Magento/Signifyd/Test/Mftf/Page/AdminFraudProtectionPage.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - -
- - diff --git a/app/code/Magento/Signifyd/Test/Mftf/README.md b/app/code/Magento/Signifyd/Test/Mftf/README.md deleted file mode 100644 index 9391d7b314ea5..0000000000000 --- a/app/code/Magento/Signifyd/Test/Mftf/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Signifyd Functional Tests - -The Functional Test Module for **Magento Signifyd** module. diff --git a/app/code/Magento/Signifyd/Test/Mftf/Section/AdminSignifydConfigurationSection.xml b/app/code/Magento/Signifyd/Test/Mftf/Section/AdminSignifydConfigurationSection.xml deleted file mode 100644 index 618e9d520dd87..0000000000000 --- a/app/code/Magento/Signifyd/Test/Mftf/Section/AdminSignifydConfigurationSection.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - -
- - - -
-
diff --git a/app/code/Magento/Signifyd/Test/Mftf/Test/AdminSignifydConfigDependentOnActiveFieldTest.xml b/app/code/Magento/Signifyd/Test/Mftf/Test/AdminSignifydConfigDependentOnActiveFieldTest.xml deleted file mode 100644 index e3275d4097c63..0000000000000 --- a/app/code/Magento/Signifyd/Test/Mftf/Test/AdminSignifydConfigDependentOnActiveFieldTest.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - <description value="Signifyd system configs dependent by Enable this Solution field."/> - <severity value="MINOR"/> - </annotations> - <before> - <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> - <magentoCLI command="config:set fraud_protection/signifyd/active 1" stepKey="enableSignifyd"/> - </before> - - <after> - <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> - <magentoCLI command="config:set fraud_protection/signifyd/active 0" stepKey="disableSignifyd"/> - </after> - - <amOnPage url="{{AdminFraudProtectionPage.url}}" stepKey="openFraudProtectionPagePage" /> - <conditionalClick dependentSelector="{{AdminSignifydConfigurationSection.enabled}}" visible="false" selector="{{AdminSignifydConfigurationSection.head}}" stepKey="openCollapsibleBlock"/> - <seeInField selector="{{AdminSignifydConfigurationSection.url}}" userInput="https://api.signifyd.com/v2/" stepKey="seeApiUrlField"/> - <selectOption selector="{{AdminSignifydConfigurationSection.enabled}}" userInput="0" stepKey="disableSignifydOption"/> - <dontSeeElement selector="{{AdminSignifydConfigurationSection.url}}" stepKey="dontSeeApiUrlField"/> - </test> -</tests> diff --git a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php deleted file mode 100644 index 164cd8018fb69..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php +++ /dev/null @@ -1,150 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Block\Adminhtml; - -use Magento\Framework\App\RequestInterface; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Framework\View\Element\Template\Context; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Block\Adminhtml\CaseInfo; -use Magento\Signifyd\Model\CaseManagement; -use Magento\Signifyd\Model\Config; -use PHPUnit_Framework_MockObject_MockObject as MockObject; - -/** - * Tests for Signifyd block information. - * - * Class CaseInfoTest - */ -class CaseInfoTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var CaseInterface|MockObject - */ - private $caseEntity; - - /** - * @var CaseInfo - */ - private $caseInfo; - - /** - * @var Context|MockObject - */ - private $context; - - /** - * @var Config|MockObject - */ - private $config; - - /** - * @var CaseManagement|MockObject - */ - private $caseManagement; - - /** - * @var RequestInterface|MockObject - */ - private $request; - - /** - * @inheritdoc - */ - protected function setUp() - { - $objectManager = new ObjectManager($this); - - $this->context = $this->getMockBuilder(Context::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->request = $this->getMockBuilder(RequestInterface::class) - ->getMockForAbstractClass(); - - $this->context->expects(self::once()) - ->method('getRequest') - ->willReturn($this->request); - - $this->config = $this->getMockBuilder(Config::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->caseManagement = $this->getMockBuilder(CaseManagement::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->caseEntity = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->setMethods(['getScore']) - ->getMockForAbstractClass(); - - $this->caseInfo = $objectManager->getObject(CaseInfo::class, [ - 'context' => $this->context, - 'config' => $this->config, - 'caseManagement' => $this->caseManagement - ]); - } - - /** - * Checks label according to Signifyd Guarantee Disposition. - * - * @param string $guaranteeDisposition - * @param string $expectedLabel - * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseGuaranteeDisposition() - * @dataProvider getGuaranteeLabelDataProvider - */ - public function testGetGuaranteeDisposition($guaranteeDisposition, $expectedLabel) - { - $this->caseManagement->expects(self::once()) - ->method('getByOrderId') - ->willReturn($this->caseEntity); - - $this->caseEntity->expects(self::atLeastOnce()) - ->method('getGuaranteeDisposition') - ->willReturn($guaranteeDisposition); - - self::assertEquals( - $expectedLabel, - $this->caseInfo->getCaseGuaranteeDisposition() - ); - } - - /** - * Case Guarantee Disposition and corresponding label data provider. - * - * @return array - */ - public function getGuaranteeLabelDataProvider() - { - return [ - [CaseInterface::GUARANTEE_APPROVED, __('Approved')], - [CaseInterface::GUARANTEE_DECLINED, __('Declined')], - [CaseInterface::GUARANTEE_PENDING, __('Pending')], - [CaseInterface::GUARANTEE_CANCELED, __('Canceled')], - [CaseInterface::GUARANTEE_IN_REVIEW, __('In Review')], - [CaseInterface::GUARANTEE_UNREQUESTED, __('Unrequested')], - ['Unregistered', ''] - ]; - } - - /** - * Checks case property getter with empty case. - * - * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseProperty - */ - public function testCasePropertyWithEmptyCase() - { - $this->caseManagement->expects(self::once()) - ->method('getByOrderId') - ->willReturn(null); - - self::assertEquals( - '', - $this->caseInfo->getCaseGuaranteeDisposition() - ); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php deleted file mode 100644 index 8b98be338b973..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php +++ /dev/null @@ -1,374 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Controller\Webhooks; - -use Magento\Framework\App\Action\Context; -use Magento\Framework\App\Response\Http as ResponseHttp; -use Magento\Framework\App\Response\RedirectInterface; -use Magento\Framework\Exception\LocalizedException; -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Controller\Webhooks\Handler; -use Magento\Signifyd\Model\CaseServices\UpdatingService; -use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory; -use Magento\Signifyd\Model\Config; -use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessage; -use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessageReader; -use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequest; -use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequestValidator; -use PHPUnit_Framework_MockObject_MockObject as MockObject; -use Psr\Log\LoggerInterface; - -/** - * Class IndexTest - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class HandlerTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var Handler - */ - private $controller; - - /** - * @var LoggerInterface|MockObject - */ - private $logger; - - /** - * @var RedirectInterface|MockObject - */ - private $redirect; - - /** - * @var ResponseHttp|MockObject - */ - private $response; - - /** - * @var Context|MockObject - */ - private $context; - - /** - * @var WebhookRequest|MockObject - */ - private $webhookRequest; - - /** - * @var WebhookMessageReader|MockObject - */ - private $webhookMessageReader; - - /** - * @var WebhookRequestValidator|MockObject - */ - private $webhookRequestValidator; - - /** - * @var UpdatingServiceFactory|MockObject - */ - private $caseUpdatingServiceFactory; - - /** - * @var CaseRepositoryInterface|MockObject - */ - private $caseRepository; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->context = $this->getMockBuilder(Context::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->webhookRequest = $this->getMockBuilder(WebhookRequest::class) - ->disableOriginalConstructor() - ->getMock(); - $this->webhookMessageReader = $this->getMockBuilder(WebhookMessageReader::class) - ->disableOriginalConstructor() - ->getMock(); - $this->webhookRequestValidator = $this->getMockBuilder(WebhookRequestValidator::class) - ->disableOriginalConstructor() - ->getMock(); - $this->caseUpdatingServiceFactory = $this->getMockBuilder(UpdatingServiceFactory::class) - ->disableOriginalConstructor() - ->getMock(); - $this->logger = $this->getMockBuilder(LoggerInterface::class) - ->getMockForAbstractClass(); - - $this->response = $this->getMockBuilder(ResponseHttp::class) - ->disableOriginalConstructor() - ->getMock(); - $this->context->expects($this->once()) - ->method('getResponse') - ->willReturn($this->response); - $this->redirect = $this->getMockBuilder(RedirectInterface::class) - ->getMockForAbstractClass(); - $this->context->expects($this->once()) - ->method('getRedirect') - ->willReturn($this->redirect); - $this->caseRepository = $this->getMockBuilder(CaseRepositoryInterface::class) - ->disableOriginalConstructor() - ->setMethods(['getByCaseId']) - ->getMockForAbstractClass(); - - $config = $this->getMockBuilder(Config::class) - ->disableOriginalConstructor() - ->setMethods(['isDebugModeEnabled', 'getByCaseId']) - ->getMock(); - $config->expects(self::any()) - ->method('getByCaseId') - ->willReturn(false); - - $this->controller = new Handler( - $this->context, - $this->webhookRequest, - $this->logger, - $this->webhookMessageReader, - $this->caseUpdatingServiceFactory, - $this->webhookRequestValidator, - $this->caseRepository, - $config - ); - } - - /** - * Successful case - */ - public function testExecuteSuccessfully() - { - $eventTopic = 'cases/creation'; - $caseId = 1; - $data = ['score' => 200, 'caseId' => $caseId]; - - $this->webhookRequestValidator->expects($this->once()) - ->method('validate') - ->willReturn(true); - - $webhookMessage = $this->getMockBuilder(WebhookMessage::class) - ->disableOriginalConstructor() - ->getMock(); - $webhookMessage->expects($this->exactly(2)) - ->method('getEventTopic') - ->willReturn($eventTopic); - $webhookMessage->expects($this->once()) - ->method('getData') - ->willReturn($data); - $this->webhookMessageReader->expects($this->once()) - ->method('read') - ->with($this->webhookRequest) - ->willReturn($webhookMessage); - - $caseEntity = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->caseRepository->expects(self::once()) - ->method('getByCaseId') - ->with(self::equalTo($caseId)) - ->willReturn($caseEntity); - - $caseUpdatingService = $this->getMockBuilder(UpdatingService::class) - ->disableOriginalConstructor() - ->getMock(); - $caseUpdatingService->expects($this->once()) - ->method('update') - ->with($caseEntity, $data); - - $this->caseUpdatingServiceFactory->expects($this->once()) - ->method('create') - ->with($eventTopic) - ->willReturn($caseUpdatingService); - - $this->controller->execute(); - } - - /** - * Case when there is exception while updating case - */ - public function testExecuteCaseUpdatingServiceException() - { - $eventTopic = 'cases/creation'; - $caseId = 1; - $data = ['score' => 200, 'caseId' => $caseId]; - - $this->webhookRequestValidator->expects($this->once()) - ->method('validate') - ->willReturn(true); - - $webhookMessage = $this->getMockBuilder(WebhookMessage::class) - ->disableOriginalConstructor() - ->getMock(); - $webhookMessage->expects($this->exactly(2)) - ->method('getEventTopic') - ->willReturn($eventTopic); - $webhookMessage->expects($this->once()) - ->method('getData') - ->willReturn($data); - $this->webhookMessageReader->expects($this->once()) - ->method('read') - ->with($this->webhookRequest) - ->willReturn($webhookMessage); - - $caseEntity = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->caseRepository->expects(self::once()) - ->method('getByCaseId') - ->with(self::equalTo($caseId)) - ->willReturn($caseEntity); - - $caseUpdatingService = $this->getMockBuilder(UpdatingService::class) - ->disableOriginalConstructor() - ->getMock(); - $caseUpdatingService->expects($this->once()) - ->method('update') - ->with($caseEntity, $data) - ->willThrowException(new LocalizedException(__('Error'))); - - $this->caseUpdatingServiceFactory->expects($this->once()) - ->method('create') - ->with($eventTopic) - ->willReturn($caseUpdatingService); - - $this->response->expects($this->once()) - ->method('setHttpResponseCode') - ->with(400); - $this->logger->expects($this->once()) - ->method('critical'); - - $this->controller->execute(); - } - - /** - * Case when webhook request validation fails - */ - public function testExecuteRequestValidationFails() - { - $this->webhookRequestValidator->expects($this->once()) - ->method('validate') - ->willReturn(false); - $this->redirect->expects($this->once()) - ->method('redirect') - ->with($this->response, 'noroute', []); - $this->webhookMessageReader->expects($this->never()) - ->method('read'); - $this->caseUpdatingServiceFactory->expects($this->never()) - ->method('create'); - - $this->controller->execute(); - } - - /** - * Case when webhook request has test event topic. - */ - public function testExecuteWithTestEventTopic() - { - $this->webhookRequestValidator->expects($this->once()) - ->method('validate') - ->willReturn(true); - $this->redirect->expects($this->never()) - ->method('redirect'); - - $webhookMessage = $this->getMockBuilder(WebhookMessage::class) - ->disableOriginalConstructor() - ->getMock(); - $webhookMessage->expects($this->once()) - ->method('getEventTopic') - ->willReturn('cases/test'); - $webhookMessage->expects($this->never()) - ->method('getData'); - - $this->webhookMessageReader->expects($this->once()) - ->method('read') - ->with($this->webhookRequest) - ->willReturn($webhookMessage); - - $this->caseUpdatingServiceFactory->expects($this->never()) - ->method('create'); - - $this->controller->execute(); - } - - /** - * Checks a test case when received input data does not contain Signifyd case id. - * - * @covers \Magento\Signifyd\Controller\Webhooks\Handler::execute - */ - public function testExecuteWithMissedCaseId() - { - $this->webhookRequestValidator->expects(self::once()) - ->method('validate') - ->willReturn(true); - - $webhookMessage = $this->getMockBuilder(WebhookMessage::class) - ->disableOriginalConstructor() - ->getMock(); - $webhookMessage->expects($this->once()) - ->method('getEventTopic') - ->willReturn('cases/creation'); - $webhookMessage->expects(self::once()) - ->method('getData') - ->willReturn([ - 'orderId' => '1000101' - ]); - - $this->webhookMessageReader->expects(self::once()) - ->method('read') - ->with($this->webhookRequest) - ->willReturn($webhookMessage); - - $this->redirect->expects(self::once()) - ->method('redirect') - ->with($this->response, 'noroute', []); - - $this->controller->execute(); - } - - /** - * Checks a case when Signifyd case entity not found. - * - * @covers \Magento\Signifyd\Controller\Webhooks\Handler::execute - */ - public function testExecuteWithNotFoundCaseEntity() - { - $caseId = 123; - - $this->webhookRequestValidator->expects(self::once()) - ->method('validate') - ->willReturn(true); - - $webhookMessage = $this->getMockBuilder(WebhookMessage::class) - ->disableOriginalConstructor() - ->setMethods(['getData']) - ->getMock(); - $webhookMessage->expects(self::once()) - ->method('getData') - ->willReturn([ - 'orderId' => '1000101', - 'caseId' => $caseId - ]); - - $this->webhookMessageReader->expects(self::once()) - ->method('read') - ->with($this->webhookRequest) - ->willReturn($webhookMessage); - - $this->caseRepository->expects(self::once()) - ->method('getByCaseId') - ->with(self::equalTo($caseId)) - ->willReturn(null); - - $this->redirect->expects(self::once()) - ->method('redirect') - ->with($this->response, 'noroute', []); - - $this->controller->execute(); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php deleted file mode 100644 index f0184c032b550..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php +++ /dev/null @@ -1,167 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\CaseServices; - -use Magento\Framework\ObjectManagerInterface; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Signifyd\Model\CaseServices\StubUpdatingService; -use Magento\Signifyd\Model\CaseServices\UpdatingService; -use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory; -use Magento\Signifyd\Model\Config; -use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory; -use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface; -use PHPUnit_Framework_MockObject_MockObject as MockObject; - -/** - * Contains tests for case updating service factory. - */ -class UpdatingServiceFactoryTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var UpdatingServiceFactory - */ - private $factory; - - /** - * @var Config|MockObject - */ - private $config; - - /** - * @var ObjectManagerInterface|MockObject - */ - private $fakeObjectManager; - - /** - * @var GeneratorFactory|MockObject - */ - private $generatorFactory; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->config = $this->getMockBuilder(Config::class) - ->disableOriginalConstructor() - ->setMethods(['isActive']) - ->getMock(); - - $this->fakeObjectManager = $this->getMockBuilder(ObjectManagerInterface::class) - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMockForAbstractClass(); - - $this->generatorFactory = $this->getMockBuilder(GeneratorFactory::class) - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - - $objectManager = new ObjectManager($this); - $this->factory = $objectManager->getObject(UpdatingServiceFactory::class, [ - 'objectManager' => $this->fakeObjectManager, - 'generatorFactory' => $this->generatorFactory, - 'config' => $this->config - ]); - } - - /** - * Checks type of instance for updating service if Signifyd is not enabled. - * - * @covers \Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory::create - */ - public function testCreateWithInactiveConfig() - { - $type = 'cases/creation'; - $this->config->expects(self::once()) - ->method('isActive') - ->willReturn(false); - - $this->fakeObjectManager->expects(self::once()) - ->method('create') - ->with(StubUpdatingService::class) - ->willReturn(new StubUpdatingService()); - - $instance = $this->factory->create($type); - static::assertInstanceOf(StubUpdatingService::class, $instance); - } - - /** - * Checks type of instance for updating service if test type is received. - * - * @covers \Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory::create - */ - public function testCreateWithTestType() - { - $type = 'cases/test'; - $this->config->expects(self::once()) - ->method('isActive') - ->willReturn(true); - - $this->fakeObjectManager->expects(self::once()) - ->method('create') - ->with(StubUpdatingService::class) - ->willReturn(new StubUpdatingService()); - - $instance = $this->factory->create($type); - static::assertInstanceOf(StubUpdatingService::class, $instance); - } - - /** - * Checks exception type and message for unknown case type. - * - * @covers \Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory::create - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Specified message type does not supported. - */ - public function testCreateWithException() - { - $type = 'cases/unknown'; - $this->config->expects(self::once()) - ->method('isActive') - ->willReturn(true); - - $this->generatorFactory->expects(self::once()) - ->method('create') - ->with($type) - ->willThrowException(new \InvalidArgumentException('Specified message type does not supported.')); - - $this->factory->create($type); - } - - /** - * Checks if factory creates correct instance of case updating service. - * - * @covers \Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory::create - */ - public function testCreate() - { - $type = 'case/creation'; - $this->config->expects(self::once()) - ->method('isActive') - ->willReturn(true); - - $messageGenerator = $this->getMockBuilder(GeneratorInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->generatorFactory->expects(self::once()) - ->method('create') - ->with($type) - ->willReturn($messageGenerator); - - $service = $this->getMockBuilder(UpdatingService::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->fakeObjectManager->expects(self::once()) - ->method('create') - ->with(UpdatingService::class, ['messageGenerator' => $messageGenerator]) - ->willReturn($service); - - $result = $this->factory->create($type); - static::assertInstanceOf(UpdatingService::class, $result); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php deleted file mode 100644 index 6eb7e5c37d5fc..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php +++ /dev/null @@ -1,316 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\CaseServices; - -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Model\CaseServices\UpdatingService; -use Magento\Signifyd\Model\CommentsHistoryUpdater; -use Magento\Signifyd\Model\MessageGenerators\GeneratorException; -use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface; -use Magento\Signifyd\Model\OrderStateService; -use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater; -use PHPUnit_Framework_MockObject_MockObject as MockObject; - -/** - * Contains tests with different negative and positive scenarios for case updating service. - */ -class UpdatingServiceTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var UpdatingService - */ - private $service; - - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var GeneratorInterface|MockObject - */ - private $messageGenerator; - - /** - * @var CaseRepositoryInterface|MockObject - */ - private $caseRepository; - - /** - * @var CommentsHistoryUpdater|MockObject - */ - private $commentsHistoryUpdater; - - /** - * @var OrderGridUpdater|MockObject - */ - private $orderGridUpdater; - - /** - * @var OrderStateService|MockObject - */ - private $orderStateService; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->objectManager = new ObjectManager($this); - - $this->messageGenerator = $this->getMockBuilder(GeneratorInterface::class) - ->disableOriginalConstructor() - ->setMethods(['generate']) - ->getMock(); - - $this->caseRepository = $this->getMockBuilder(CaseRepositoryInterface::class) - ->disableOriginalConstructor() - ->setMethods(['getByCaseId']) - ->getMockForAbstractClass(); - - $this->commentsHistoryUpdater = $this->getMockBuilder(CommentsHistoryUpdater::class) - ->disableOriginalConstructor() - ->setMethods(['addComment']) - ->getMock(); - - $this->orderGridUpdater = $this->getMockBuilder(OrderGridUpdater::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->orderStateService = $this->getMockBuilder(OrderStateService::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->service = $this->objectManager->getObject(UpdatingService::class, [ - 'messageGenerator' => $this->messageGenerator, - 'caseRepository' => $this->caseRepository, - 'commentsHistoryUpdater' => $this->commentsHistoryUpdater, - 'orderGridUpdater' => $this->orderGridUpdater, - 'orderStateService' => $this->orderStateService - ]); - } - - /** - * Checks a test case when Signifyd case is empty entity. - * - * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update - * @expectedException \Magento\Framework\Exception\LocalizedException - * @expectedExceptionMessage The case entity should not be empty. - */ - public function testUpdateWithEmptyCaseEntity() - { - $data = []; - $caseEntity = $this->withCaseEntity(null, 123, $data); - - $this->service->update($caseEntity, $data); - } - - /** - * Checks a test case when Signifyd case id is not specified for a case entity. - * - * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update - * @expectedException \Magento\Framework\Exception\LocalizedException - * @expectedExceptionMessage The case entity should not be empty. - */ - public function testUpdateWithEmptyCaseId() - { - $data = [ - 'caseId' => 123 - ]; - $caseEntity = $this->withCaseEntity(1, null, $data); - - $this->service->update($caseEntity, $data); - } - - /** - * Checks as test case when service cannot save Signifyd case entity - * - * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update - * @expectedException \Magento\Framework\Exception\LocalizedException - * @expectedExceptionMessage Cannot update Case entity. - */ - public function testUpdateWithFailedCaseSaving() - { - $caseId = 123; - $data = [ - 'caseId' => $caseId, - 'status' => CaseInterface::STATUS_OPEN, - 'orderId' => '10000012', - 'score' => 500 - ]; - - $caseEntity = $this->withCaseEntity(1, $caseId, $data); - - $this->caseRepository->expects(self::once()) - ->method('save') - ->willThrowException(new \Exception('Something wrong.')); - - $this->service->update($caseEntity, $data); - } - - /** - * Checks as test case when message generator throws an exception - * - * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update - * @expectedException \Magento\Framework\Exception\LocalizedException - * @expectedExceptionMessage Cannot update Case entity. - */ - public function testUpdateWithExceptionFromMessageGenerator() - { - $caseId = 123; - $data = [ - 'caseId' => $caseId - ]; - - $caseEntity = $this->withCaseEntity(1, $caseId, $data); - - $this->caseRepository->expects(self::never()) - ->method('save') - ->with($caseEntity) - ->willReturn($caseEntity); - - $this->messageGenerator->expects(self::once()) - ->method('generate') - ->with($data) - ->willThrowException(new GeneratorException(__('Cannot generate message.'))); - - $this->service->update($caseEntity, $data); - } - - /** - * Checks a test case when comments history updater throws an exception. - * - * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update - * @expectedException \Magento\Framework\Exception\LocalizedException - * @expectedExceptionMessage Cannot update Case entity. - */ - public function testUpdateWithFailedCommentSaving() - { - $caseId = 123; - $data = [ - 'caseId' => $caseId, - 'orderId' => 1 - ]; - - $caseEntity = $this->withCaseEntity(1, $caseId, $data); - - $this->caseRepository->expects(self::once()) - ->method('save') - ->with($caseEntity) - ->willReturn($caseEntity); - - $this->orderGridUpdater->expects(self::once()) - ->method('update') - ->with($data['orderId']); - - $message = __('Message is generated.'); - $this->messageGenerator->expects(self::once()) - ->method('generate') - ->with($data) - ->willReturn($message); - - $this->commentsHistoryUpdater->expects(self::once()) - ->method('addComment') - ->with($caseEntity, $message) - ->willThrowException(new \Exception('Something wrong')); - - $this->service->update($caseEntity, $data); - } - - /** - * Checks a test case when Signifyd case entity is successfully updated and message stored in comments history. - * - * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update - */ - public function testUpdate() - { - $caseId = 123; - $data = [ - 'caseId' => $caseId, - 'orderId' => 1 - ]; - - $caseEntity = $this->withCaseEntity(21, $caseId, $data); - - $caseEntitySaved = clone $caseEntity; - $caseEntitySaved->expects(self::once()) - ->method('getGuaranteeDisposition') - ->willReturn('APPROVED'); - - $this->caseRepository->expects(self::once()) - ->method('save') - ->with($caseEntity) - ->willReturn($caseEntitySaved); - - $message = __('Message is generated.'); - $this->messageGenerator->expects(self::once()) - ->method('generate') - ->with($data) - ->willReturn($message); - - $this->orderGridUpdater->expects(self::once()) - ->method('update') - ->with($data['orderId']); - - $this->commentsHistoryUpdater->expects(self::once()) - ->method('addComment') - ->with($caseEntitySaved, $message); - - $this->orderStateService->expects(self::once()) - ->method('updateByCase') - ->with($caseEntitySaved); - - $this->service->update($caseEntity, $data); - } - - /** - * Create mock for case entity with common scenarios. - * - * @param $caseEntityId - * @param $caseId - * @param array $data - * @return CaseInterface|MockObject - */ - private function withCaseEntity($caseEntityId, $caseId, array $data = []) - { - /** @var CaseInterface|MockObject $caseEntity */ - $caseEntity = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->setMethods([ - 'getEntityId', 'getCaseId', 'getOrderId', - 'setCaseId', 'setStatus', 'setOrderId', 'setScore' - ]) - ->getMockForAbstractClass(); - - $caseEntity->expects(self::any()) - ->method('getEntityId') - ->willReturn($caseEntityId); - $caseEntity->expects(self::any()) - ->method('getCaseId') - ->willReturn($caseId); - - foreach ($data as $property => $value) { - $method = 'set' . ucfirst($property); - if ($property === 'orderId') { - $caseEntity->expects(self::never()) - ->method($method); - } - $caseEntity->expects(self::any()) - ->method($method) - ->with(self::equalTo($value)) - ->willReturnSelf(); - - $method = 'get' . ucfirst($property); - $caseEntity->expects(self::any()) - ->method($method) - ->willReturn($value); - } - - return $caseEntity; - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php deleted file mode 100644 index 5cbb3d8d93cdd..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php +++ /dev/null @@ -1,176 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model; - -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Sales\Api\Data\OrderStatusHistoryInterface; -use Magento\Sales\Model\Order\Status\HistoryFactory; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Model\CommentsHistoryUpdater; -use PHPUnit_Framework_MockObject_MockObject as MockObject; -use Magento\Sales\Api\OrderStatusHistoryRepositoryInterface; - -/** - * Contains tests for comments history updater class. - */ -class CommentsHistoryUpdaterTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var int - */ - private static $orderId = 123; - - /** - * @var string - */ - private static $message = 'Case is created.'; - - /** - * @var string - */ - private static $status = 'On Hold'; - - /** - * @var CommentsHistoryUpdater - */ - private $updater; - - /** - * @var HistoryFactory|MockObject - */ - private $historyFactory; - - /** - * @var CaseInterface|MockObject - */ - private $caseEntity; - - /** - * @var OrderStatusHistoryInterface|MockObject - */ - private $historyEntity; - - /** - * @var OrderStatusHistoryRepositoryInterface|MockObject - */ - private $historyRepository; - - /** - * @inheritdoc - */ - protected function setUp() - { - $objectManager = new ObjectManager($this); - - $this->historyFactory = $this->getMockBuilder(HistoryFactory::class) - ->disableOriginalConstructor() - ->setMethods(['create', 'save']) - ->getMock(); - - $this->historyRepository = $this->getMockBuilder(OrderStatusHistoryRepositoryInterface::class) - ->getMockForAbstractClass(); - - $this->caseEntity = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->setMethods(['getOrderId']) - ->getMockForAbstractClass(); - - $this->initCommentMock(); - - $this->updater = $objectManager->getObject(CommentsHistoryUpdater::class, [ - 'historyFactory' => $this->historyFactory, - 'historyRepository' => $this->historyRepository - ]); - } - - /** - * Checks a test case when updater throws an exception while saving history comment. - * - * @covers \Magento\Signifyd\Model\CommentsHistoryUpdater::addComment - * @expectedException \Exception - */ - public function testAddCommentWithException() - { - $this->caseEntity->expects(self::once()) - ->method('getOrderId') - ->willReturn(self::$orderId); - - $this->historyEntity->method('setStatus') - ->with('') - ->willReturnSelf(); - $this->historyRepository->expects(self::once()) - ->method('save') - ->with($this->historyEntity) - ->willThrowException(new \Exception('Cannot save comment message.')); - - $this->updater->addComment($this->caseEntity, __(self::$message)); - } - - /** - * Checks a test case when updater successfully saves history comment. - * - * @covers \Magento\Signifyd\Model\CommentsHistoryUpdater::addComment - */ - public function testAddComment() - { - $this->caseEntity->expects(self::once()) - ->method('getOrderId') - ->willReturn(self::$orderId); - - $this->historyEntity->method('setStatus') - ->with(self::$status) - ->willReturnSelf(); - $this->historyRepository->expects(self::once()) - ->method('save') - ->with($this->historyEntity) - ->willReturnSelf(); - - $this->updater->addComment($this->caseEntity, __(self::$message), self::$status); - } - - /** - * Checks a test when message does not specified. - * - * @covers \Magento\Signifyd\Model\CommentsHistoryUpdater::addComment - */ - public function testAddCommentWithoutMessage() - { - $this->caseEntity->expects(self::never()) - ->method('getOrderId'); - - $this->historyFactory->expects(self::never()) - ->method('save'); - - $phrase = ''; - $this->updater->addComment($this->caseEntity, __($phrase)); - } - - /** - * Creates mock object for history entity. - * - * @return void - */ - private function initCommentMock() - { - $this->historyEntity = $this->getMockBuilder(OrderStatusHistoryInterface::class) - ->disableOriginalConstructor() - ->setMethods(['setParentId', 'setComment', 'setEntityName', 'save']) - ->getMockForAbstractClass(); - - $this->historyFactory->method('create') - ->willReturn($this->historyEntity); - - $this->historyEntity->method('setParentId') - ->with(self::$orderId) - ->willReturnSelf(); - $this->historyEntity->method('setComment') - ->with(self::$message) - ->willReturnSelf(); - $this->historyEntity->method('setEntityName') - ->with('order') - ->willReturnSelf(); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php deleted file mode 100644 index 02d3b4b9ad7a7..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php +++ /dev/null @@ -1,267 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model; - -use Magento\Directory\Model\Currency; -use Magento\Framework\Api\FilterBuilder; -use Magento\Framework\Api\SearchCriteriaBuilder; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Sales\Api\Data\OrderSearchResultInterface; -use Magento\Sales\Model\Order; -use Magento\Signifyd\Model\CustomerOrders; -use PHPUnit_Framework_MockObject_MockObject as MockObject; -use Magento\Sales\Api\OrderRepositoryInterface; -use Psr\Log\LoggerInterface; - -/** - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class CustomerOrdersTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var int - */ - private static $customerId = 1; - - /** - * Order amount in EUR - * @var int - */ - private static $eurAmount = 100; - - /** - * Order amount in UAH - * @var int - */ - private static $uahAmount = 270; - - /** - * Order amount in USD - * @var int - */ - private static $usdAmount = 50; - - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var FilterBuilder|MockObject - */ - private $filterBuilder; - - /** - * @var Currency|MockObject - */ - private $eurCurrency; - - /** - * @var Currency|MockObject - */ - private $uahCurrency; - - /** - * @var CustomerOrders - */ - private $model; - - /** - * @var OrderRepositoryInterface|MockObject - */ - private $orderRepository; - - /** - * @var SearchCriteriaBuilder|MockObject - */ - private $searchCriteriaBuilder; - - /** - * @var LoggerInterface|MockObject - */ - private $logger; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->objectManager = new ObjectManager($this); - - $this->orderRepository = $this->getMockBuilder(OrderRepositoryInterface::class) - ->getMockForAbstractClass(); - - $this->logger = $this->getMockBuilder(LoggerInterface::class) - ->getMockForAbstractClass(); - - $this->filterBuilder = $this->getMockBuilder(FilterBuilder::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->searchCriteriaBuilder = $this->getMockBuilder(SearchCriteriaBuilder::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->model = $this->objectManager->getObject(CustomerOrders::class, [ - 'filterBuilder' => $this->filterBuilder, - 'orderRepository' => $this->orderRepository, - 'searchCriteriaBuilder' => $this->searchCriteriaBuilder, - 'logger' => $this->logger - ]); - - $this->initCurrencies(); - $this->initOrderRepository(); - - $this->objectManager->setBackwardCompatibleProperty( - $this->model, - 'currencies', - ['EUR' => $this->eurCurrency, 'UAH' => $this->uahCurrency] - ); - } - - /** - * @covers \Magento\Signifyd\Model\CustomerOrders::getAggregatedOrdersInfo() - */ - public function testGetCountAndTotalAmount() - { - $this->eurCurrency->expects($this->once()) - ->method('convert') - ->with(self::$eurAmount, 'USD') - ->willReturn(109); - - $this->uahCurrency->expects($this->once()) - ->method('convert') - ->with(self::$uahAmount, 'USD') - ->willReturn(10.35); - - $actual = $this->model->getAggregatedOrdersInfo(self::$customerId); - - static::assertEquals(3, $actual['aggregateOrderCount']); - static::assertEquals(169.35, $actual['aggregateOrderDollars']); - } - - /** - * Test case when required currency rate is absent and exception is thrown - * @covers \Magento\Signifyd\Model\CustomerOrders::getAggregatedOrdersInfo() - */ - public function testGetCountAndTotalAmountNegative() - { - $this->eurCurrency->expects($this->once()) - ->method('convert') - ->with(self::$eurAmount, 'USD') - ->willReturn(109); - - $this->uahCurrency->expects($this->once()) - ->method('convert') - ->with(self::$uahAmount, 'USD') - ->willThrowException(new \Exception()); - - $this->logger->expects($this->once()) - ->method('error'); - - $actual = $this->model->getAggregatedOrdersInfo(self::$customerId); - - $this->assertNull($actual['aggregateOrderCount']); - $this->assertNull($actual['aggregateOrderDollars']); - } - - /** - * Populate order repository with mocked orders - */ - private function initOrderRepository() - { - $this->filterBuilder->expects($this->once()) - ->method('setField') - ->willReturnSelf(); - $this->filterBuilder->expects($this->once()) - ->method('setValue') - ->willReturnSelf(); - $filter = $this->getMockBuilder(\Magento\Framework\Api\Filter::class) - ->disableOriginalConstructor() - ->getMock(); - $this->filterBuilder->expects($this->once()) - ->method('create') - ->willReturn($filter); - - $searchCriteria = $this->getMockBuilder(\Magento\Framework\Api\SearchCriteria::class) - ->disableOriginalConstructor() - ->getMock(); - $this->searchCriteriaBuilder->expects($this->once()) - ->method('create') - ->willReturn($searchCriteria); - - $orderSearchResult = $this->getMockBuilder(OrderSearchResultInterface::class) - ->getMockForAbstractClass(); - $orderSearchResult->expects($this->once()) - ->method('getItems') - ->willReturn($this->getOrders()); - $this->orderRepository->expects($this->once()) - ->method('getList') - ->willReturn($orderSearchResult); - } - - /** - * Creates mocks for currencies - * @return void - */ - private function initCurrencies() - { - $this->eurCurrency = $this->getMockBuilder(Currency::class) - ->disableOriginalConstructor() - ->setMethods(['convert']) - ->getMock(); - - $this->uahCurrency = $this->getMockBuilder(Currency::class) - ->disableOriginalConstructor() - ->setMethods(['convert']) - ->getMock(); - } - - /** - * Get list of mocked orders with different currencies - * @return array - */ - private function getOrders() - { - $eurOrder = $this->getMockBuilder(Order::class) - ->disableOriginalConstructor() - ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode']) - ->getMock(); - - $eurOrder->expects($this->once()) - ->method('getBaseGrandTotal') - ->willReturn(self::$eurAmount); - $eurOrder->expects($this->once()) - ->method('getBaseCurrencyCode') - ->willReturn('EUR'); - - $uahOrder = $this->getMockBuilder(Order::class) - ->disableOriginalConstructor() - ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode']) - ->getMock(); - - $uahOrder->expects($this->once()) - ->method('getBaseGrandTotal') - ->willReturn(self::$uahAmount); - $uahOrder->expects($this->once()) - ->method('getBaseCurrencyCode') - ->willReturn('UAH'); - - $usdOrder = $this->getMockBuilder(Order::class) - ->disableOriginalConstructor() - ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode']) - ->getMock(); - - $usdOrder->expects($this->once()) - ->method('getBaseGrandTotal') - ->willReturn(self::$usdAmount); - $usdOrder->expects($this->once()) - ->method('getBaseCurrencyCode') - ->willReturn('USD'); - - return [$usdOrder, $eurOrder, $uahOrder]; - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php deleted file mode 100644 index f7b4e473a0ec8..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php +++ /dev/null @@ -1,154 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\Guarantee; - -use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Sales\Api\Data\OrderInterface; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Model\CaseEntity; -use Magento\Signifyd\Model\CaseManagement; -use Magento\Signifyd\Model\Guarantee\CancelGuaranteeAbility; - -/** - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class CancelGuaranteeAbilityTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var OrderRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $orderRepository; - - /** - * @var CaseManagement|\PHPUnit_Framework_MockObject_MockObject - */ - private $caseManagement; - - /** - * @var CancelGuaranteeAbility - */ - private $cancelGuaranteeAbility; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->orderRepository = $this->getMockBuilder(OrderRepositoryInterface::class) - ->getMockForAbstractClass(); - - $this->caseManagement = $this->getMockBuilder(CaseManagement::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->cancelGuaranteeAbility = new CancelGuaranteeAbility( - $this->caseManagement, - $this->orderRepository - ); - } - - /** - * Success test for Cancel Guarantee Request button - */ - public function testIsAvailableSuccess() - { - $orderId = 123; - - /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */ - $case = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $case->expects($this->once()) - ->method('getGuaranteeDisposition') - ->willReturn(CaseEntity::GUARANTEE_APPROVED); - - $this->caseManagement->expects($this->once()) - ->method('getByOrderId') - ->with($orderId) - ->willReturn($case); - - /** @var OrderInterface|\PHPUnit_Framework_MockObject_MockObject $order */ - $order = $this->getMockBuilder(OrderInterface::class) - ->getMockForAbstractClass(); - - $this->orderRepository->expects($this->once()) - ->method('get') - ->with($orderId) - ->willReturn($order); - - $this->assertTrue($this->cancelGuaranteeAbility->isAvailable($orderId)); - } - - /** - * Tests case when Case entity doesn't exist for order - */ - public function testIsAvailableWithNullCase() - { - $orderId = 123; - - $this->caseManagement->expects($this->once()) - ->method('getByOrderId') - ->with($orderId) - ->willReturn(null); - - $this->assertFalse($this->cancelGuaranteeAbility->isAvailable($orderId)); - } - - /** - * Tests case when Guarantee Disposition has Canceled states. - */ - public function testIsAvailableWithCanceledGuarantee() - { - $orderId = 123; - - /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */ - $case = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $case->expects($this->once()) - ->method('getGuaranteeDisposition') - ->willReturn(CaseEntity::GUARANTEE_CANCELED); - - $this->caseManagement->expects($this->once()) - ->method('getByOrderId') - ->with($orderId) - ->willReturn($case); - - $this->assertFalse($this->cancelGuaranteeAbility->isAvailable($orderId)); - } - - /** - * Tests case when order does not exist. - */ - public function testIsAvailableWithNullOrder() - { - $orderId = 123; - - /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */ - $case = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $case->expects($this->once()) - ->method('getGuaranteeDisposition') - ->willReturn(CaseEntity::GUARANTEE_APPROVED); - - $this->caseManagement->expects($this->once()) - ->method('getByOrderId') - ->with($orderId) - ->willReturn($case); - - $this->orderRepository->expects($this->once()) - ->method('get') - ->with($orderId) - ->willThrowException(new NoSuchEntityException()); - - $this->assertFalse($this->cancelGuaranteeAbility->isAvailable($orderId)); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php deleted file mode 100644 index f8f1d4a4522c9..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php +++ /dev/null @@ -1,215 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\Guarantee; - -use Magento\Signifyd\Api\CaseManagementInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Model\CaseServices\StubUpdatingService; -use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory; -use Magento\Signifyd\Model\Guarantee\CancelGuaranteeAbility; -use Magento\Signifyd\Model\Guarantee\CancelingService; -use Magento\Signifyd\Model\SignifydGateway\Gateway; -use Magento\Signifyd\Model\SignifydGateway\GatewayException; -use PHPUnit_Framework_MockObject_MockObject as MockObject; -use Psr\Log\LoggerInterface; - -/** - * Contains test cases for Signifyd guarantee canceling service. - */ -class CancelingServiceTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var int - */ - private static $orderId = 23; - - /** - * @var int - */ - private static $caseId = 123; - - /** - * @var CancelingService - */ - private $service; - - /** - * @var CaseManagementInterface|MockObject - */ - private $caseManagement; - - /** - * @var UpdatingServiceFactory|MockObject - */ - private $updatingFactory; - - /** - * @var Gateway|MockObject - */ - private $gateway; - - /** - * @var CancelGuaranteeAbility|MockObject - */ - private $guaranteeAbility; - - /** - * @var LoggerInterface|MockObject - */ - private $logger; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->caseManagement = $this->getMockBuilder(CaseManagementInterface::class) - ->disableOriginalConstructor() - ->setMethods(['getByOrderId']) - ->getMockForAbstractClass(); - - $this->updatingFactory = $this->getMockBuilder(UpdatingServiceFactory::class) - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - - $this->gateway = $this->getMockBuilder(Gateway::class) - ->disableOriginalConstructor() - ->setMethods(['cancelGuarantee']) - ->getMock(); - - $this->guaranteeAbility = $this->getMockBuilder(CancelGuaranteeAbility::class) - ->disableOriginalConstructor() - ->setMethods(['isAvailable']) - ->getMock(); - - $this->logger = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->setMethods(['error']) - ->getMockForAbstractClass(); - - $this->service = new CancelingService( - $this->caseManagement, - $this->updatingFactory, - $this->gateway, - $this->guaranteeAbility, - $this->logger - ); - } - - /** - * Checks a test case, when validation for a guarantee is failed. - * - * @covers \Magento\Signifyd\Model\Guarantee\CancelingService::cancelForOrder - */ - public function testCancelForOrderWithUnavailableDisposition() - { - $this->guaranteeAbility->expects(self::once()) - ->method('isAvailable') - ->with(self::equalTo(self::$orderId)) - ->willReturn(false); - - $this->caseManagement->expects(self::never()) - ->method('getByOrderId'); - - $this->gateway->expects(self::never()) - ->method('cancelGuarantee'); - - $this->logger->expects(self::never()) - ->method('error'); - - $this->updatingFactory->expects(self::never()) - ->method('create'); - - $result = $this->service->cancelForOrder(self::$orderId); - self::assertFalse($result); - } - - /** - * Checks a test case, when request to Signifyd API fails. - * - * @covers \Magento\Signifyd\Model\Guarantee\CancelingService::cancelForOrder - */ - public function testCancelForOrderWithFailedRequest() - { - $this->withCaseEntity(); - - $this->gateway->expects(self::once()) - ->method('cancelGuarantee') - ->with(self::equalTo(self::$caseId)) - ->willThrowException(new GatewayException('Something wrong.')); - - $this->logger->expects(self::once()) - ->method('error') - ->with(self::equalTo('Something wrong.')); - - $this->updatingFactory->expects(self::never()) - ->method('create'); - - $result = $this->service->cancelForOrder(self::$orderId); - self::assertFalse($result); - } - - /** - * Checks a test case, when request to Signifyd successfully processed and case entity has been updated. - * - * @covers \Magento\Signifyd\Model\Guarantee\CancelingService::cancelForOrder - */ - public function testCancelForOrder() - { - $case = $this->withCaseEntity(); - - $this->gateway->expects(self::once()) - ->method('cancelGuarantee') - ->with(self::equalTo(self::$caseId)) - ->willReturn(CaseInterface::GUARANTEE_CANCELED); - - $this->logger->expects(self::never()) - ->method('error'); - - $service = $this->getMockBuilder(StubUpdatingService::class) - ->setMethods(['update']) - ->getMock(); - $this->updatingFactory->expects(self::once()) - ->method('create') - ->willReturn($service); - - $service->expects(self::once()) - ->method('update') - ->with(self::equalTo($case), self::equalTo(['guaranteeDisposition' => CaseInterface::GUARANTEE_CANCELED])); - - $result = $this->service->cancelForOrder(self::$orderId); - self::assertTrue($result); - } - - /** - * Gets mock for a case entity. - * - * @return CaseInterface|MockObject - */ - private function withCaseEntity() - { - $this->guaranteeAbility->expects(self::once()) - ->method('isAvailable') - ->with(self::equalTo(self::$orderId)) - ->willReturn(true); - - $caseEntity = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->setMethods(['getCaseId']) - ->getMockForAbstractClass(); - - $this->caseManagement->expects(self::once()) - ->method('getByOrderId') - ->with(self::equalTo(self::$orderId)) - ->willReturn($caseEntity); - - $caseEntity->expects(self::once()) - ->method('getCaseId') - ->willReturn(self::$caseId); - return $caseEntity; - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php deleted file mode 100644 index 6b7a6112a932e..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php +++ /dev/null @@ -1,260 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\Guarantee; - -use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Framework\Intl\DateTimeFactory; -use Magento\Sales\Api\Data\OrderInterface; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\Sales\Model\Order; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Model\CaseManagement; -use Magento\Signifyd\Model\Guarantee\CreateGuaranteeAbility; - -/** - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class CreateGuaranteeAbilityTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var DateTimeFactory - */ - private $dateTimeFactory; - - /** - * @var OrderRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $orderRepository; - - /** - * @var CaseManagement|\PHPUnit_Framework_MockObject_MockObject - */ - private $caseManagement; - - /** - * @var CreateGuaranteeAbility - */ - private $createGuaranteeAbility; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->dateTimeFactory = new DateTimeFactory(); - $this->orderRepository = $this->getMockBuilder(OrderRepositoryInterface::class) - ->getMockForAbstractClass(); - $this->caseManagement = $this->getMockBuilder(CaseManagement::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->createGuaranteeAbility = new CreateGuaranteeAbility( - $this->caseManagement, - $this->orderRepository, - $this->dateTimeFactory - ); - } - - public function testIsAvailableSuccess() - { - $orderId = 123; - $orderCreatedAt = $this->getDateAgo(6); - - /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */ - $case = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $case->expects($this->once()) - ->method('isGuaranteeEligible') - ->willReturn(true); - - $this->caseManagement->expects($this->once()) - ->method('getByOrderId') - ->with($orderId) - ->willReturn($case); - - /** @var OrderInterface|\PHPUnit_Framework_MockObject_MockObject $order */ - $order = $this->getMockBuilder(OrderInterface::class) - ->getMockForAbstractClass(); - $order->expects($this->once()) - ->method('getState') - ->willReturn(Order::STATE_COMPLETE); - $order->expects($this->once()) - ->method('getCreatedAt') - ->willReturn($orderCreatedAt); - - $this->orderRepository->expects($this->once()) - ->method('get') - ->with($orderId) - ->willReturn($order); - - $this->assertTrue($this->createGuaranteeAbility->isAvailable($orderId)); - } - - /** - * Tests case when Case entity doesn't exist for order - */ - public function testIsAvailableWithNullCase() - { - $orderId = 123; - - $this->caseManagement->expects($this->once()) - ->method('getByOrderId') - ->with($orderId) - ->willReturn(null); - - $this->assertFalse($this->createGuaranteeAbility->isAvailable($orderId)); - } - - /** - * Tests case when GuaranteeEligible for Case is false - */ - public function testIsAvailableWithGuarantyEligibleFalse() - { - $orderId = 123; - - /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */ - $case = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $case->expects($this->once()) - ->method('isGuaranteeEligible') - ->willReturn(false); - - $this->caseManagement->expects($this->once()) - ->method('getByOrderId') - ->with($orderId) - ->willReturn($case); - - $this->assertFalse($this->createGuaranteeAbility->isAvailable($orderId)); - } - - /** - * Tests case when GuaranteeEligible for Case is false - */ - public function testIsAvailableWithNullOrder() - { - $orderId = 123; - - /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */ - $case = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $case->expects($this->once()) - ->method('isGuaranteeEligible') - ->willReturn(true); - - $this->caseManagement->expects($this->once()) - ->method('getByOrderId') - ->with($orderId) - ->willReturn($case); - - $this->orderRepository->expects($this->once()) - ->method('get') - ->with($orderId) - ->willThrowException(new NoSuchEntityException()); - - $this->assertFalse($this->createGuaranteeAbility->isAvailable($orderId)); - } - - /** - * Tests case when order has Canceled Or Closed states. - * - * @param string $state - * @dataProvider isAvailableWithCanceledOrderDataProvider - */ - public function testIsAvailableWithCanceledOrder($state) - { - $orderId = 123; - - /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */ - $case = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $case->expects($this->once()) - ->method('isGuaranteeEligible') - ->willReturn(true); - - $this->caseManagement->expects($this->once()) - ->method('getByOrderId') - ->with($orderId) - ->willReturn($case); - - /** @var OrderInterface|\PHPUnit_Framework_MockObject_MockObject $order */ - $order = $this->getMockBuilder(OrderInterface::class) - ->getMockForAbstractClass(); - $order->expects($this->once()) - ->method('getState') - ->willReturn($state); - - $this->orderRepository->expects($this->once()) - ->method('get') - ->with($orderId) - ->willReturn($order); - - $this->assertFalse($this->createGuaranteeAbility->isAvailable($orderId)); - } - - /** - * @return array - */ - public function isAvailableWithCanceledOrderDataProvider() - { - return [ - [Order::STATE_CANCELED], [Order::STATE_CLOSED] - ]; - } - - public function testIsAvailableWithOldOrder() - { - $orderId = 123; - $orderCreatedAt = $this->getDateAgo(8); - - /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */ - $case = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $case->expects($this->once()) - ->method('isGuaranteeEligible') - ->willReturn(true); - - $this->caseManagement->expects($this->once()) - ->method('getByOrderId') - ->with($orderId) - ->willReturn($case); - - /** @var OrderInterface|\PHPUnit_Framework_MockObject_MockObject $order */ - $order = $this->getMockBuilder(OrderInterface::class) - ->getMockForAbstractClass(); - $order->expects($this->once()) - ->method('getState') - ->willReturn(Order::STATE_COMPLETE); - $order->expects($this->once()) - ->method('getCreatedAt') - ->willReturn($orderCreatedAt); - - $this->orderRepository->expects($this->once()) - ->method('get') - ->with($orderId) - ->willReturn($order); - - $this->assertFalse($this->createGuaranteeAbility->isAvailable($orderId)); - } - - /** - * Returns date N days ago - * - * @param int $days number of days that will be deducted from the current date - * @return string - */ - private function getDateAgo($days) - { - $createdAtTime = $this->dateTimeFactory->create('now', new \DateTimeZone('UTC')); - $createdAtTime->sub(new \DateInterval('P' . $days . 'D')); - - return $createdAtTime->format('Y-m-d h:i:s'); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php deleted file mode 100644 index db64b38375fe1..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php +++ /dev/null @@ -1,253 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\Guarantee; - -use Magento\Signifyd\Api\CaseManagementInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory; -use Magento\Signifyd\Model\CaseServices\UpdatingServiceInterface; -use Magento\Signifyd\Model\Guarantee\CreateGuaranteeAbility; -use Magento\Signifyd\Model\Guarantee\CreationService; -use Magento\Signifyd\Model\SignifydGateway\Gateway; -use Magento\Signifyd\Model\SignifydGateway\GatewayException; -use PHPUnit_Framework_MockObject_MockObject as MockObject; -use \PHPUnit\Framework\TestCase as TestCase; -use Psr\Log\LoggerInterface; - -class CreationServiceTest extends TestCase -{ - /** - * @var CreationService|MockObject - */ - private $service; - - /** - * @var CaseManagementInterface|MockObject - */ - private $caseManagement; - - /** - * @var UpdatingServiceInterface|MockObject - */ - private $caseUpdatingService; - - /** - * @var Gateway|MockObject - */ - private $gateway; - - /** - * @var LoggerInterface|MockObject - */ - private $logger; - - /** - * @var CreateGuaranteeAbility|MockObject - */ - private $createGuaranteeAbility; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->caseManagement = $this->getMockBuilder(CaseManagementInterface::class) - ->getMockForAbstractClass(); - - $caseUpdatingServiceFactory = $this->getMockBuilder(UpdatingServiceFactory::class) - ->disableOriginalConstructor() - ->getMock(); - $this->caseUpdatingService = $this->getMockBuilder(UpdatingServiceInterface::class) - ->getMockForAbstractClass(); - $caseUpdatingServiceFactory - ->method('create') - ->willReturn($this->caseUpdatingService); - - $this->gateway = $this->getMockBuilder(Gateway::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->createGuaranteeAbility = $this->getMockBuilder(CreateGuaranteeAbility::class) - ->disableOriginalConstructor() - ->setMethods(['isAvailable']) - ->getMock(); - - $this->logger = $this->getMockBuilder(LoggerInterface::class) - ->getMockForAbstractClass(); - - $this->service = new CreationService( - $this->caseManagement, - $caseUpdatingServiceFactory, - $this->gateway, - $this->createGuaranteeAbility, - $this->logger - ); - } - - /** - * Checks a test case, when guarantee ability checker does not allow to submit case for a guarantee. - * - * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder - */ - public function testCreateForOrderWithNotEligibleCase() - { - $orderId = 1; - - $this->createGuaranteeAbility->expects(self::once()) - ->method('isAvailable') - ->with($orderId) - ->willReturn(false); - - $this->caseManagement->expects(self::never()) - ->method('getByOrderId'); - - $this->gateway->expects(self::never()) - ->method('submitCaseForGuarantee'); - - $result = $this->service->createForOrder($orderId); - self::assertFalse($result); - } - - public function testCreateForOrderWitCase() - { - $dummyOrderId = 1; - $dummyCaseId = 42; - $this->withCaseEntityExistsForOrderId( - $dummyOrderId, - [ - 'caseId' => $dummyCaseId, - ] - ); - - $this->gateway - ->expects($this->once()) - ->method('submitCaseForGuarantee'); - - $this->service->createForOrder($dummyOrderId); - } - - public function testCreateForOrderWithGatewayFailure() - { - $dummyOrderId = 1; - $dummyCaseId = 42; - $dummyGatewayFailureMessage = 'Everything fails sometimes'; - $this->withCaseEntityExistsForOrderId( - $dummyOrderId, - [ - 'caseId' => $dummyCaseId, - ] - ); - $this->withGatewayFailure($dummyGatewayFailureMessage); - - $this->logger - ->expects($this->once()) - ->method('error') - ->with($this->equalTo($dummyGatewayFailureMessage)); - $this->caseUpdatingService - ->expects($this->never()) - ->method('update'); - - $result = $this->service->createForOrder($dummyOrderId); - $this->assertEquals( - false, - $result, - 'Service should return false in case of gateway failure' - ); - } - - public function testCreateForOrderWithGatewaySuccess() - { - $dummyOrderId = 1; - $dummyCaseId = 42; - $dummyGuaranteeDisposition = 'foo'; - $caseEntity = $this->withCaseEntityExistsForOrderId( - $dummyOrderId, - [ - 'caseId' => $dummyCaseId, - ] - ); - $this->withGatewaySuccess($dummyGuaranteeDisposition); - - $this->caseUpdatingService - ->expects($this->once()) - ->method('update') - ->with($caseEntity, $this->equalTo([ - 'caseId' => $dummyCaseId, - 'guaranteeDisposition' => $dummyGuaranteeDisposition, - ])); - - $this->service->createForOrder($dummyOrderId); - } - - public function testCreateForOrderWithCaseUpdate() - { - $dummyOrderId = 1; - $dummyCaseId = 42; - $dummyGuaranteeDisposition = 'foo'; - $this->withCaseEntityExistsForOrderId( - $dummyOrderId, - [ - 'caseId' => $dummyCaseId, - ] - ); - $this->withGatewaySuccess($dummyGuaranteeDisposition); - - $result = $this->service->createForOrder($dummyOrderId); - $this->assertEquals( - true, - $result, - 'Service should return true in case if case update service is called' - ); - } - - /** - * @param $orderId - * @param array $caseData - * @return MockObject - */ - private function withCaseEntityExistsForOrderId($orderId, array $caseData = []) - { - $this->createGuaranteeAbility->expects(self::once()) - ->method('isAvailable') - ->with(self::equalTo($orderId)) - ->willReturn(true); - - $dummyCaseEntity = $this->getMockBuilder(CaseInterface::class) - ->getMockForAbstractClass(); - foreach ($caseData as $caseProperty => $casePropertyValue) { - $dummyCaseEntity - ->method('get' . ucfirst($caseProperty)) - ->willReturn($casePropertyValue); - } - - $this->caseManagement - ->method('getByOrderId') - ->with($this->equalTo($orderId)) - ->willReturn($dummyCaseEntity); - - return $dummyCaseEntity; - } - - /** - * @param $failureMessage - */ - private function withGatewayFailure($failureMessage) - { - $this->gateway - ->method('submitCaseForGuarantee') - ->willThrowException(new GatewayException($failureMessage)); - } - - /** - * @param $gatewayResult - */ - private function withGatewaySuccess($gatewayResult) - { - $this->gateway - ->method('submitCaseForGuarantee') - ->willReturn($gatewayResult); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php deleted file mode 100644 index ba14036cd68d0..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php +++ /dev/null @@ -1,148 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators; - -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Model\MessageGenerators\CaseRescore; -use PHPUnit_Framework_MockObject_MockObject as MockObject; - -/** - * Tests for Signifyd CaseRescore message generator. - * - * Class CaseRescoreTest - */ -class CaseRescoreTest extends \PHPUnit\Framework\TestCase -{ - private static $data = [ - 'caseId' => 100, - 'score' => 200 - ]; - - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var CaseRepositoryInterface|MockObject - */ - private $caseRepository; - - /** - * @var CaseRescore|MockObject - */ - private $caseRescore; - - /** - * @var CaseInterface|MockObject - */ - private $case; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->case = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->objectManager = new ObjectManager($this); - $this->caseRepository = $this->getMockBuilder(CaseRepositoryInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [ - 'caseRepository' => $this->caseRepository - ]); - } - - /** - * Data array without required attribute caseId. - * - * @expectedException \Magento\Signifyd\Model\MessageGenerators\GeneratorException - * @expectedExceptionMessage The "caseId" should not be empty - */ - public function testGenerateEmptyCaseIdException() - { - $this->caseRescore->generate([]); - } - - /** - * Case entity was not found in DB. - * - * @expectedException \Magento\Signifyd\Model\MessageGenerators\GeneratorException - * @expectedExceptionMessage Case entity not found. - */ - public function testGenerateNotFoundException() - { - $this->caseRepository->expects($this->once()) - ->method('getByCaseId') - ->with(self::$data['caseId']) - ->willReturn(null); - - $this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [ - 'caseRepository' => $this->caseRepository - ]); - - $this->caseRescore->generate(self::$data); - } - - /** - * Generate case message with not empty previous score. - */ - public function testGenerateWithPreviousScore() - { - $this->case->expects($this->once()) - ->method('getScore') - ->willReturn(self::$data['score']); - - $this->caseRepository->expects($this->once()) - ->method('getByCaseId') - ->with(self::$data['caseId']) - ->willReturn($this->case); - - $this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [ - 'caseRepository' => $this->caseRepository - ]); - - $phrase = __( - 'Case Update: New score for the order is %1. Previous score was %2.', - self::$data['score'], - self::$data['score'] - ); - - $message = $this->caseRescore->generate(self::$data); - - $this->assertEquals($phrase, $message); - } - - /** - * Generate case message with empty previous score. - */ - public function testGenerateWithoutPreviousScore() - { - $this->caseRepository->expects($this->once()) - ->method('getByCaseId') - ->with(self::$data['caseId']) - ->willReturn($this->case); - - $this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [ - 'caseRepository' => $this->caseRepository - ]); - - $phrase = __( - 'Case Update: New score for the order is %1. Previous score was %2.', - self::$data['score'], - null - ); - - $message = $this->caseRescore->generate(self::$data); - - $this->assertEquals($phrase, $message); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php deleted file mode 100644 index 50f87df3b694f..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators; - -use Magento\Framework\ObjectManagerInterface; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Signifyd\Model\MessageGenerators\PatternGenerator; -use Magento\Signifyd\Model\MessageGenerators\CaseRescore; -use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory; -use PHPUnit_Framework_MockObject_MockObject as MockObject; - -/** - * Contains tests for messages generators factory. - */ -class GeneratorFactoryTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var GeneratorFactory - */ - private $factory; - - /** - * @var ObjectManagerInterface|MockObject - */ - private $fakeObjectManager; - - /** - * @inheritdoc - */ - protected function setUp() - { - $objectManager = new ObjectManager($this); - - $this->fakeObjectManager = $this->getMockBuilder(ObjectManagerInterface::class) - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMockForAbstractClass(); - - $this->factory = $objectManager->getObject(GeneratorFactory::class, [ - 'objectManager' => $this->fakeObjectManager - ]); - } - - /** - * Checks if factory returns correct instance of message generator. - * - * @covers \Magento\Signifyd\Model\MessageGenerators\GeneratorFactory::create - * @param string $type - * @param string $className - * @dataProvider typeDataProvider - */ - public function testCreate($type, $className) - { - $generator = $this->getMockBuilder($className) - ->disableOriginalConstructor() - ->getMock(); - - $this->fakeObjectManager->expects(self::once()) - ->method('create') - ->with($className) - ->willReturn($generator); - - $instance = $this->factory->create($type); - self::assertInstanceOf($className, $instance); - } - - /** - * Get list of available messages generators types and equal class names. - * - * @return array - */ - public function typeDataProvider() - { - return [ - ['cases/creation', PatternGenerator::class], - ['cases/review', PatternGenerator::class], - ['cases/rescore', CaseRescore::class], - ['guarantees/completion', PatternGenerator::class], - ['guarantees/creation', PatternGenerator::class], - ['guarantees/cancel', PatternGenerator::class], - ]; - } - - /** - * Checks correct exception message for unknown type of message generator. - * - * @covers \Magento\Signifyd\Model\MessageGenerators\GeneratorFactory::create - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Specified message type does not supported. - */ - public function testCreateWithException() - { - $type = 'cases/unknown'; - $this->factory->create($type); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php deleted file mode 100644 index 9d5f71f657a1e..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators; - -use Magento\Signifyd\Model\MessageGenerators\PatternGenerator; - -/** - * Contains tests for different variations like empty data, wrong required arguments, or bad placeholders. - */ -class PatternGeneratorTest extends \PHPUnit\Framework\TestCase -{ - /** - * Checks an exception if generators does not receives required data. - * - * @covers \Magento\Signifyd\Model\MessageGenerators\PatternGenerator::generate - * @expectedException \Magento\Signifyd\Model\MessageGenerators\GeneratorException - * @expectedExceptionMessage The "caseId" should not be empty. - */ - public function testGenerateThrowsException() - { - $data = []; - $generator = new PatternGenerator('Signifyd Case %1 has been created for order.', ['caseId']); - $generator->generate($data); - } - - /** - * Checks cases with different template placeholders and input data. - * - * @covers \Magento\Signifyd\Model\MessageGenerators\PatternGenerator::generate - * @param string $template - * @param array $requiredFields - * @param string $expected - * @dataProvider messageDataProvider - */ - public function testGenerate($template, array $requiredFields, $expected) - { - $data = [ - 'caseId' => 123, - 'reviewDisposition' => 'Good', - 'guaranteeDisposition' => 'Approved', - 'score' => 500, - 'case_score' => 300 - ]; - - $generator = new PatternGenerator($template, $requiredFields); - $actual = $generator->generate($data); - self::assertEquals($expected, $actual); - } - - /** - * Get list of variations with message templates, required fields and expected generated messages. - * - * @return array - */ - public function messageDataProvider() - { - return [ - [ - 'Signifyd Case %1 has been created for order.', - ['caseId'], - 'Signifyd Case 123 has been created for order.' - ], - [ - 'Case Update: Case Review was completed. Review Deposition is %1.', - ['reviewDisposition'], - 'Case Update: Case Review was completed. Review Deposition is Good.' - ], - [ - 'Case Update: New score for the order is %1. Previous score was %2.', - ['score', 'case_score'], - 'Case Update: New score for the order is 500. Previous score was 300.' - ], - [ - 'Case Update: Case is submitted for guarantee.', - [], - 'Case Update: Case is submitted for guarantee.' - ], - ]; - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php deleted file mode 100644 index 3a567a79891f8..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php +++ /dev/null @@ -1,204 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model; - -use Magento\Sales\Api\OrderManagementInterface; -use Magento\Sales\Model\Order; -use Magento\Sales\Model\OrderFactory; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Model\CommentsHistoryUpdater; -use Magento\Signifyd\Model\OrderStateService; -use PHPUnit_Framework_MockObject_MockObject as MockObject; - -class OrderStateServiceTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var int - */ - private static $orderId = 123; - - /** - * @var OrderFactory|MockObject - */ - private $orderFactory; - - /** - * @var OrderManagementInterface|MockObject - */ - private $orderManagement; - - /** - * @var CommentsHistoryUpdater|MockObject - */ - private $commentsHistoryUpdater; - - /** - * @var CaseInterface|MockObject - */ - private $caseEntity; - - /** - * @var Order|MockObject - */ - private $order; - - /** - * @var OrderStateService - */ - private $orderStateService; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->orderManagement = $this->getMockBuilder(OrderManagementInterface::class) - ->getMockForAbstractClass(); - - $this->commentsHistoryUpdater = $this->getMockBuilder(CommentsHistoryUpdater::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->orderFactory = $this->getMockBuilder(OrderFactory::class) - ->setMethods(['create']) - ->disableOriginalConstructor() - ->getMock(); - - $this->order = $this->getMockBuilder(Order::class) - ->disableOriginalConstructor() - ->getMock(); - $this->order->expects($this->once()) - ->method('load') - ->willReturnSelf(); - - $this->orderFactory->expects($this->once()) - ->method('create') - ->willReturn($this->order); - - $this->caseEntity = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $this->caseEntity->expects($this->once()) - ->method('getOrderId') - ->willReturn(self::$orderId); - - $this->orderStateService = new OrderStateService( - $this->orderFactory, - $this->orderManagement, - $this->commentsHistoryUpdater - ); - } - - /** - * Tests update order state flow when case guarantee disposition is PENDING. - * - * @param bool $canHold - * @param bool $hold - * @param int $addCommentCall - * @dataProvider updateByCaseWithGuaranteePendingDataProvider - */ - public function testUpdateByCaseWithGuaranteePending($canHold, $hold, $addCommentCall) - { - $this->caseEntity->expects($this->once()) - ->method('getGuaranteeDisposition') - ->willReturn(CaseInterface::GUARANTEE_PENDING); - $this->order->expects($this->any()) - ->method('canHold') - ->willReturn($canHold); - $this->orderManagement->expects($this->any()) - ->method('hold') - ->willReturn($hold); - $this->commentsHistoryUpdater->expects($this->exactly($addCommentCall)) - ->method('addComment') - ->with( - $this->caseEntity, - __('Awaiting the Signifyd guarantee disposition.'), - Order::STATE_HOLDED - ); - - $this->orderStateService->updateByCase($this->caseEntity); - } - - /** - * @return array - */ - public function updateByCaseWithGuaranteePendingDataProvider() - { - return [ - ['canHold' => true, 'hold' => true, 'addCommentCall' => 1], - ['canHold' => false, 'hold' => true, 'addCommentCall' => 0], - ['canHold' => true, 'hold' => false, 'addCommentCall' => 0], - ]; - } - - /** - * Tests update order state flow when case guarantee disposition is APPROVED. - * - * @param bool $canUnhold - * @param int $unholdCall - * @dataProvider updateByCaseWithGuaranteeApprovedDataProvider - */ - public function testUpdateByCaseWithGuaranteeApproved($canUnhold, $unholdCall) - { - $this->caseEntity->expects($this->once()) - ->method('getGuaranteeDisposition') - ->willReturn(CaseInterface::GUARANTEE_APPROVED); - $this->order->expects($this->any()) - ->method('canUnhold') - ->willReturn($canUnhold); - $this->orderManagement->expects($this->exactly($unholdCall)) - ->method('unHold'); - $this->commentsHistoryUpdater->expects($this->never()) - ->method('addComment'); - - $this->orderStateService->updateByCase($this->caseEntity); - } - - /** - * @return array - */ - public function updateByCaseWithGuaranteeApprovedDataProvider() - { - return [ - ['canUnhold' => true, 'unholdCall' => 1], - ['canUnhold' => false, 'unholdCall' => 0] - ]; - } - - /** - * Tests update order state flow when case guarantee disposition is DECLINED. - * - * @param bool $canHold - * @param int $holdCall - * @dataProvider updateByCaseWithGuaranteeDeclinedDataProvider - */ - public function testUpdateByCaseWithGuaranteeDeclined($canHold, $holdCall) - { - $this->caseEntity->expects($this->once()) - ->method('getGuaranteeDisposition') - ->willReturn(CaseInterface::GUARANTEE_DECLINED); - $this->order->expects($this->any()) - ->method('canHold') - ->willReturn($canHold); - $this->orderManagement->expects($this->exactly($holdCall)) - ->method('hold'); - $this->commentsHistoryUpdater->expects($this->never()) - ->method('addComment'); - - $this->orderStateService->updateByCase($this->caseEntity); - } - - /** - * @return array - */ - public function updateByCaseWithGuaranteeDeclinedDataProvider() - { - return [ - ['canHold' => true, 'holdCall' => 1], - ['canHold' => false, 'holdCall' => 0] - ]; - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php deleted file mode 100644 index 319229e326c4b..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\PaymentMethodMapper; - -use Magento\Signifyd\Model\PaymentMethodMapper\XmlToArrayConfigConverter; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Framework\Config\Dom\ValidationSchemaException; - -class XmlToArrayConfigConverterTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var XmlToArrayConfigConverter - */ - private $converter; - - /** - * @var string - */ - private $filePath; - - public function setUp() - { - $this->filePath = realpath(__DIR__) . '/_files/'; - - $objectManagerHelper = new ObjectManager($this); - $this->converter = $objectManagerHelper->getObject( - XmlToArrayConfigConverter::class - ); - } - - public function testConvert() - { - $testDom = $this->filePath . 'signifyd_payment_mapping.xml'; - $dom = new \DOMDocument(); - $dom->load($testDom); - $mapping = $this->converter->convert($dom); - $expectedArray = include $this->filePath . 'expected_array.php'; - - $this->assertEquals($expectedArray, $mapping); - } - - /** - * @expectedException \Magento\Framework\Config\Dom\ValidationSchemaException - * @expectedExceptionMessage Only single entrance of "magento_code" node is required. - */ - public function testConvertEmptyPaymentMethodException() - { - $dom = new \DOMDocument(); - $element = $dom->createElement('payment_method'); - $subelement = $dom->createElement('signifyd_code', 'test'); - $element->appendChild($subelement); - $dom->appendChild($element); - - $this->converter->convert($dom); - } - - /** - * @expectedException \Magento\Framework\Config\Dom\ValidationSchemaException - * @expectedExceptionMessage Not empty value for "signifyd_code" node is required. - */ - public function testConvertEmptySygnifydPaymentMethodException() - { - $dom = new \DOMDocument(); - $element = $dom->createElement('payment_method'); - $subelement = $dom->createElement('magento_code', 'test'); - $subelement2 = $dom->createElement('signifyd_code', ''); - $element->appendChild($subelement); - $element->appendChild($subelement2); - $dom->appendChild($element); - - $this->converter->convert($dom); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php deleted file mode 100644 index f5d3436ae6b7b..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -return [ - 'payment_method_1' => 'PAYMENT_CARD', - 'payment_method_2' => 'PAYPAL_ACCOUNT', - 'payment_method_3' => 'CHECK', - 'payment_method_4' => 'CASH', - 'payment_method_5' => 'FREE' -]; diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/signifyd_payment_mapping.xml deleted file mode 100644 index f70763e22c418..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/signifyd_payment_mapping.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" ?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Signifyd:etc/payment_mapping.xsd"> - <payment_method_list> - <payment_method> - <magento_code>payment_method_1</magento_code> - <signifyd_code>PAYMENT_CARD</signifyd_code> - </payment_method> - <payment_method> - <magento_code>payment_method_2</magento_code> - <signifyd_code>PAYPAL_ACCOUNT</signifyd_code> - </payment_method> - <payment_method> - <magento_code>payment_method_3</magento_code> - <signifyd_code>CHECK</signifyd_code> - </payment_method> - <payment_method> - <magento_code>payment_method_4</magento_code> - <signifyd_code>CASH</signifyd_code> - </payment_method> - <payment_method> - <magento_code>payment_method_5</magento_code> - <signifyd_code>FREE</signifyd_code> - </payment_method> - </payment_method_list> -</config> diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php deleted file mode 100644 index b0f9239d43bfa..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php +++ /dev/null @@ -1,222 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model; - -use Magento\Framework\ObjectManagerInterface; -use Magento\Payment\Api\PaymentVerificationInterface; -use Magento\Signifyd\Model\PaymentVerificationFactory; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use PHPUnit_Framework_MockObject_MockObject as MockObject; -use Magento\Payment\Gateway\ConfigInterface; - -class PaymentVerificationFactoryTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var PaymentVerificationFactory - */ - private $factory; - - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var ObjectManagerInterface|MockObject - */ - private $fakeObjectManager; - - /** - * @var ConfigInterface|MockObject - */ - private $config; - - /** - * @var PaymentVerificationInterface|MockObject - */ - private $avsDefaultAdapter; - - /** - * @var PaymentVerificationInterface|MockObject - */ - private $cvvDefaultAdapter; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->objectManager = new ObjectManager($this); - - $this->fakeObjectManager = $this->getMockBuilder(ObjectManagerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->config = $this->getMockBuilder(ConfigInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->avsDefaultAdapter = $this->getMockBuilder(PaymentVerificationInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->cvvDefaultAdapter = $this->getMockBuilder(PaymentVerificationInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->factory = $this->objectManager->getObject(PaymentVerificationFactory::class, [ - 'objectManager' => $this->fakeObjectManager, - 'config' => $this->config, - 'avsDefaultAdapter' => $this->avsDefaultAdapter, - 'cvvDefaultAdapter' => $this->cvvDefaultAdapter - ]); - } - - /** - * Checks a test case when factory creates CVV mapper for provided payment method. - * - * @covers \Magento\Signifyd\Model\PaymentVerificationFactory::createPaymentCvv - */ - public function testCreatePaymentCvv() - { - $paymentMethodCode = 'exists_payment'; - - $this->config->expects(self::once()) - ->method('setMethodCode') - ->with(self::equalTo($paymentMethodCode)) - ->willReturnSelf(); - - $this->config->expects(self::once()) - ->method('getValue') - ->with('cvv_ems_adapter') - ->willReturn(PaymentVerificationInterface::class); - - /** @var PaymentVerificationInterface|MockObject $cvvAdapter */ - $cvvAdapter = $this->getMockBuilder(PaymentVerificationInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->fakeObjectManager->expects(self::once()) - ->method('create') - ->with(self::equalTo(PaymentVerificationInterface::class)) - ->willReturn($cvvAdapter); - - $mapper = $this->factory->createPaymentCvv($paymentMethodCode); - self::assertInstanceOf(PaymentVerificationInterface::class, $mapper); - } - - /** - * Checks a test case, when provided payment method does not have cvv mapper. - * - * @covers \Magento\Signifyd\Model\PaymentVerificationFactory::createPaymentCvv - */ - public function testCreateDefaultCvvMapper() - { - $paymentMethodCode = 'non_exists_payment'; - - $this->config->expects(self::once()) - ->method('setMethodCode') - ->with(self::equalTo($paymentMethodCode)) - ->willReturnSelf(); - - $this->config->expects(self::once()) - ->method('getValue') - ->with('cvv_ems_adapter') - ->willReturn(null); - - $this->fakeObjectManager->expects(self::never()) - ->method('create'); - - $mapper = $this->factory->createPaymentCvv($paymentMethodCode); - self::assertSame($this->cvvDefaultAdapter, $mapper); - } - - /** - * Checks a test case, when mapper implementation does not corresponding to PaymentVerificationInterface. - * - * @covers \Magento\Signifyd\Model\PaymentVerificationFactory::createPaymentCvv - * @expectedException \Magento\Framework\Exception\ConfigurationMismatchException - * @expectedExceptionMessage stdClass must implement Magento\Payment\Api\PaymentVerificationInterface - */ - public function testCreateWithUnsupportedImplementation() - { - $paymentMethodCode = 'exists_payment'; - - $this->config->expects(self::once()) - ->method('setMethodCode') - ->with(self::equalTo($paymentMethodCode)) - ->willReturnSelf(); - - $this->config->expects(self::once()) - ->method('getValue') - ->with('cvv_ems_adapter') - ->willReturn(\stdClass::class); - - $cvvAdapter = new \stdClass(); - $this->fakeObjectManager->expects(self::once()) - ->method('create') - ->with(self::equalTo(\stdClass::class)) - ->willReturn($cvvAdapter); - - $this->factory->createPaymentCvv($paymentMethodCode); - } - - /** - * Checks a test case when factory creates AVS mapper for provided payment method. - * - * @covers \Magento\Signifyd\Model\PaymentVerificationFactory::createPaymentAvs - */ - public function testCreatePaymentAvs() - { - $paymentMethodCode = 'exists_payment'; - - $this->config->expects(self::once()) - ->method('setMethodCode') - ->with(self::equalTo($paymentMethodCode)) - ->willReturnSelf(); - - $this->config->expects(self::once()) - ->method('getValue') - ->with('avs_ems_adapter') - ->willReturn(PaymentVerificationInterface::class); - - $avsAdapter = $this->getMockBuilder(PaymentVerificationInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->fakeObjectManager->expects(self::once()) - ->method('create') - ->with(self::equalTo(PaymentVerificationInterface::class)) - ->willReturn($avsAdapter); - - $mapper = $this->factory->createPaymentAvs($paymentMethodCode); - self::assertInstanceOf(PaymentVerificationInterface::class, $mapper); - } - - /** - * Checks a test case when provided payment method does not support - */ - public function testCreateDefaultAvsMapper() - { - $paymentMethodCode = 'non_exists_payment'; - - $this->config->expects(self::once()) - ->method('setMethodCode') - ->with(self::equalTo($paymentMethodCode)) - ->willReturnSelf(); - - $this->config->expects(self::once()) - ->method('getValue') - ->with('avs_ems_adapter') - ->willReturn(null); - - $this->fakeObjectManager->expects(self::never()) - ->method('create'); - - $mapper = $this->factory->createPaymentAvs($paymentMethodCode); - self::assertSame($this->avsDefaultAdapter, $mapper); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php deleted file mode 100644 index 885c9f018a488..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\SalesOrderGrid; - -use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Sales\Model\ResourceModel\GridInterface; -use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater; -use PHPUnit_Framework_MockObject_MockObject as MockObject; - -class OrderGridUpdaterTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var GridInterface|MockObject - */ - private $orderGrid; - - /** - * @var ScopeConfigInterface|MockObject - */ - private $globalConfig; - - /** - * @var OrderGridUpdater - */ - private $model; - - /** - * Sets up testing class and dependency mocks. - */ - protected function setUp() - { - $this->orderGrid = $this->getMockBuilder(GridInterface::class) - ->getMockForAbstractClass(); - $this->globalConfig = $this->getMockBuilder(ScopeConfigInterface::class) - ->getMockForAbstractClass(); - - $this->model = new OrderGridUpdater($this->orderGrid, $this->globalConfig); - } - - public function testUpdateInSyncMode() - { - $orderId = 1; - - $this->globalConfig->expects($this->once()) - ->method('getValue') - ->with('dev/grid/async_indexing', 'default', null) - ->willReturn(false); - $this->orderGrid->expects($this->once()) - ->method('refresh') - ->with($orderId); - - $this->model->update($orderId); - } - - public function testUpdateInAsyncMode() - { - $orderId = 1; - - $this->globalConfig->expects($this->once()) - ->method('getValue') - ->with('dev/grid/async_indexing', 'default', null) - ->willReturn(true); - $this->orderGrid->expects($this->never()) - ->method('refresh') - ->with($orderId); - - $this->model->update($orderId); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php deleted file mode 100644 index 4aefd63355773..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php +++ /dev/null @@ -1,131 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\SignifydGateway\Client; - -use Magento\Signifyd\Model\SignifydGateway\Client\HttpClientFactory; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Signifyd\Model\Config; -use Magento\Framework\HTTP\ZendClient; -use Magento\Framework\HTTP\ZendClientFactory; -use Magento\Framework\Json\EncoderInterface; -use \PHPUnit_Framework_MockObject_MockObject as MockObject; - -class HttpClientFactoryTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var string - */ - private static $dummy = 'dummy'; - - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var Config - */ - private $config; - - /** - * @var ZendClientFactory|MockObject - */ - private $clientFactory; - - /** - * @var ZendClient|MockObject - */ - private $client; - - /** - * @var EncoderInterface|MockObject - */ - private $dataEncoder; - - /** - * @var ZendClient|MockObject - */ - private $httpClient; - - public function setUp() - { - $this->objectManager = new ObjectManager($this); - - $this->config = $this->getMockBuilder(Config::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->client = $this->getMockBuilder(ZendClient::class) - ->disableOriginalConstructor() - ->setMethods(['setHeaders', 'setMethod', 'setUri', 'setRawData']) - ->getMock(); - - $this->clientFactory = $this->getMockBuilder(ZendClientFactory::class) - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - - $this->clientFactory->expects($this->once()) - ->method('create') - ->willReturn($this->client); - - $this->dataEncoder = $this->getMockBuilder(EncoderInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->httpClient = $this->objectManager->getObject(HttpClientFactory::class, [ - 'config' => $this->config, - 'clientFactory' => $this->clientFactory, - 'dataEncoder' => $this->dataEncoder - ]); - } - - public function testCreateHttpClient() - { - $this->config->expects($this->once()) - ->method('getApiKey') - ->willReturn('testKey'); - - $this->config->expects($this->once()) - ->method('getApiUrl') - ->willReturn('testUrl'); - - $client = $this->httpClient->create('url', 'method'); - - $this->assertInstanceOf(ZendClient::class, $client); - } - - public function testCreateWithParams() - { - $param = ['id' => 1]; - $storeId = 1; - $json = '{"id":1}'; - - $this->config->expects($this->once()) - ->method('getApiKey') - ->with($storeId) - ->willReturn('testKey'); - - $this->config->expects($this->once()) - ->method('getApiUrl') - ->with($storeId) - ->willReturn(self::$dummy); - - $this->dataEncoder->expects($this->once()) - ->method('encode') - ->with($this->equalTo($param)) - ->willReturn($json); - - $this->client->expects($this->once()) - ->method('setRawData') - ->with($this->equalTo($json), 'application/json') - ->willReturnSelf(); - - $client = $this->httpClient->create('url', 'method', $param, $storeId); - - $this->assertInstanceOf(ZendClient::class, $client); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php deleted file mode 100644 index 1ee55d7ad150c..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php +++ /dev/null @@ -1,182 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\SignifydGateway\Client; - -use Magento\Signifyd\Model\SignifydGateway\Client\ResponseHandler; -use Magento\Framework\Json\DecoderInterface; -use Magento\Signifyd\Model\SignifydGateway\ApiCallException; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use \Zend_Http_Response as Response; -use \PHPUnit_Framework_MockObject_MockObject as MockObject; - -class ResponseHandlerTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var string - */ - private static $errorMessage = 'Some error'; - - /** - * @var string - */ - private static $testJson = '{"id": 1}'; - - /** - * @var int - */ - private static $successfulCode = 200; - - /** - * @var int - */ - private static $phpVersionId = 50000; - - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var ResponseHandler|MockObject - */ - private $responseHandler; - - /** - * @var DecoderInterface|MockObject - */ - private $dataDecoder; - - /** - * @var Response|MockObject - */ - private $response; - - public function setUp() - { - $this->objectManager = new ObjectManager($this); - - $this->dataDecoder = $this->getMockBuilder(DecoderInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->response = $this->getMockBuilder(Response::class) - ->disableOriginalConstructor() - ->setMethods(['getStatus', 'getBody']) - ->getMock(); - - $this->responseHandler = $this->objectManager->getObject(ResponseHandler::class, [ - 'dataDecoder' => $this->dataDecoder - ]); - } - - /** - * @dataProvider errorsProvider - */ - public function testHandleFailureMessage($code, $message) - { - $this->response->expects($this->any()) - ->method('getStatus') - ->willReturn($code); - - $this->response->expects($this->once()) - ->method('getBody') - ->willReturn(self::$errorMessage); - - try { - $this->responseHandler->handle($this->response); - } catch (ApiCallException $e) { - $this->assertEquals($e->getMessage(), sprintf($message, self::$errorMessage)); - } - } - - /** - * @return array - */ - public function errorsProvider() - { - return [ - [400, 'Bad Request - The request could not be parsed. Response: %s'], - [401, 'Unauthorized - user is not logged in, could not be authenticated. Response: %s'], - [403, 'Forbidden - Cannot access resource. Response: %s'], - [404, 'Not Found - resource does not exist. Response: %s'], - [ - 409, - 'Conflict - with state of the resource on server. Can occur with (too rapid) PUT requests. Response: %s' - ], - [500, 'Server error. Response: %s'] - ]; - } - - /** - * @expectedException \Magento\Signifyd\Model\SignifydGateway\ApiCallException - * @expectedExceptionMessage Response is not valid JSON: Decoding failed: Syntax error - */ - public function testHandleEmptyJsonException() - { - $this->response->expects($this->any()) - ->method('getStatus') - ->willReturn(self::$successfulCode); - - $this->response->expects($this->once()) - ->method('getBody') - ->willReturn(''); - - $r = new \ReflectionObject($this->responseHandler); - $prop = $r->getProperty('phpVersionId'); - $prop->setAccessible(true); - $prop->setValue(self::$phpVersionId); - - $this->responseHandler->handle($this->response); - } - - /** - * @expectedException \Magento\Signifyd\Model\SignifydGateway\ApiCallException - * @expectedExceptionMessage Response is not valid JSON: Some error - */ - public function testHandleInvalidJson() - { - $this->response->expects($this->any()) - ->method('getStatus') - ->willReturn(self::$successfulCode); - - $this->response->expects($this->once()) - ->method('getBody') - ->willReturn('param'); - - $this->dataDecoder = $this->getMockBuilder(DecoderInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->dataDecoder->expects($this->once()) - ->method('decode') - ->with('param') - ->willThrowException(new \Exception(self::$errorMessage, 30)); - - $this->responseHandler = $this->objectManager->getObject(ResponseHandler::class, [ - 'dataDecoder' => $this->dataDecoder - ]); - - $this->responseHandler->handle($this->response); - } - - public function testHandle() - { - $this->response->expects($this->any()) - ->method('getStatus') - ->willReturn(self::$successfulCode); - - $this->response->expects($this->once()) - ->method('getBody') - ->willReturn(self::$testJson); - - $this->dataDecoder->expects($this->once()) - ->method('decode') - ->willReturn(json_decode(self::$testJson, 1)); - - $decodedResponseBody = $this->responseHandler->handle($this->response); - $this->assertEquals($decodedResponseBody, ['id' => 1]); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php deleted file mode 100644 index ba82ff4619ad3..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php +++ /dev/null @@ -1,448 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\SignifydGateway; - -use Magento\Sales\Api\Data\OrderInterface; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use PHPUnit_Framework_MockObject_MockObject as MockObject; -use Magento\Signifyd\Model\SignifydGateway\Gateway; -use Magento\Signifyd\Model\SignifydGateway\GatewayException; -use Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilderInterface; -use Magento\Signifyd\Model\SignifydGateway\ApiClient; -use Magento\Signifyd\Model\SignifydGateway\ApiCallException; - -class GatewayTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var CreateCaseBuilderInterface|MockObject - */ - private $createCaseBuilder; - - /** - * @var ApiClient|MockObject - */ - private $apiClient; - - /** - * @var Gateway - */ - private $gateway; - - /** - * @var OrderRepositoryInterface|MockObject - */ - private $orderRepository; - - /** - * @var CaseRepositoryInterface|MockObject - */ - private $caseRepository; - - public function setUp() - { - $this->createCaseBuilder = $this->getMockBuilder(CreateCaseBuilderInterface::class) - ->getMockForAbstractClass(); - - $this->apiClient = $this->getMockBuilder(ApiClient::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->orderRepository = $this->getMockBuilder(OrderRepositoryInterface::class) - ->getMockForAbstractClass(); - - $this->caseRepository= $this->getMockBuilder(CaseRepositoryInterface::class) - ->getMockForAbstractClass(); - - $this->gateway = new Gateway( - $this->createCaseBuilder, - $this->apiClient, - $this->orderRepository, - $this->caseRepository - ); - } - - public function testCreateCaseForSpecifiedOrder() - { - $dummyOrderId = 1; - $dummyStoreId = 2; - $dummySignifydInvestigationId = 42; - - $this->withOrderEntity($dummyOrderId, $dummyStoreId); - $this->apiClient - ->method('makeApiCall') - ->willReturn([ - 'investigationId' => $dummySignifydInvestigationId - ]); - - $this->createCaseBuilder - ->expects($this->atLeastOnce()) - ->method('build') - ->with($this->equalTo($dummyOrderId)) - ->willReturn([]); - - $result = $this->gateway->createCase($dummyOrderId); - $this->assertEquals(42, $result); - } - - public function testCreateCaseCallsValidApiMethod() - { - $dummyOrderId = 1; - $dummyStoreId = 2; - $dummySignifydInvestigationId = 42; - - $this->withOrderEntity($dummyOrderId, $dummyStoreId); - $this->createCaseBuilder - ->method('build') - ->willReturn([]); - - $this->apiClient - ->expects($this->atLeastOnce()) - ->method('makeApiCall') - ->with( - $this->equalTo('/cases'), - $this->equalTo('POST'), - $this->isType('array'), - $this->equalTo($dummyStoreId) - ) - ->willReturn([ - 'investigationId' => $dummySignifydInvestigationId - ]); - - $result = $this->gateway->createCase($dummyOrderId); - $this->assertEquals(42, $result); - } - - public function testCreateCaseNormalFlow() - { - $dummyOrderId = 1; - $dummyStoreId = 2; - $dummySignifydInvestigationId = 42; - - $this->withOrderEntity($dummyOrderId, $dummyStoreId); - $this->createCaseBuilder - ->method('build') - ->willReturn([]); - $this->apiClient - ->method('makeApiCall') - ->willReturn([ - 'investigationId' => $dummySignifydInvestigationId - ]); - - $returnedInvestigationId = $this->gateway->createCase($dummyOrderId); - $this->assertEquals( - $dummySignifydInvestigationId, - $returnedInvestigationId, - 'Method must return value specified in "investigationId" response parameter' - ); - } - - public function testCreateCaseWithFailedApiCall() - { - $dummyOrderId = 1; - $dummyStoreId = 2; - $apiCallFailureMessage = 'Api call failed'; - - $this->withOrderEntity($dummyOrderId, $dummyStoreId); - $this->createCaseBuilder - ->method('build') - ->willReturn([]); - $this->apiClient - ->method('makeApiCall') - ->willThrowException(new ApiCallException($apiCallFailureMessage)); - - $this->expectException(GatewayException::class); - $this->expectExceptionMessage($apiCallFailureMessage); - $this->gateway->createCase($dummyOrderId); - } - - public function testCreateCaseWithMissedResponseRequiredData() - { - $dummyOrderId = 1; - $dummyStoreId = 2; - - $this->withOrderEntity($dummyOrderId, $dummyStoreId); - $this->createCaseBuilder - ->method('build') - ->willReturn([]); - $this->apiClient - ->method('makeApiCall') - ->willReturn([ - 'someOtherParameter' => 'foo', - ]); - - $this->expectException(GatewayException::class); - $this->gateway->createCase($dummyOrderId); - } - - public function testCreateCaseWithAdditionalResponseData() - { - $dummyOrderId = 1; - $dummyStoreId = 2; - $dummySignifydInvestigationId = 42; - - $this->withOrderEntity($dummyOrderId, $dummyStoreId); - $this->createCaseBuilder - ->method('build') - ->willReturn([]); - $this->apiClient - ->method('makeApiCall') - ->willReturn([ - 'investigationId' => $dummySignifydInvestigationId, - 'someOtherParameter' => 'foo', - ]); - - $returnedInvestigationId = $this->gateway->createCase($dummyOrderId); - $this->assertEquals( - $dummySignifydInvestigationId, - $returnedInvestigationId, - 'Method must return value specified in "investigationId" response parameter and ignore any other parameters' - ); - } - - public function testSubmitCaseForGuaranteeCallsValidApiMethod() - { - $dummySygnifydCaseId = 42; - $dummyStoreId = 1; - $dummyDisposition = 'APPROVED'; - - $this->withCaseEntity($dummySygnifydCaseId, $dummyStoreId); - $this->apiClient - ->expects($this->atLeastOnce()) - ->method('makeApiCall') - ->with( - $this->equalTo('/guarantees'), - $this->equalTo('POST'), - $this->equalTo([ - 'caseId' => $dummySygnifydCaseId - ]), - $this->equalTo($dummyStoreId) - )->willReturn([ - 'disposition' => $dummyDisposition - ]); - - $result = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId); - $this->assertEquals('APPROVED', $result); - } - - public function testSubmitCaseForGuaranteeWithFailedApiCall() - { - $dummySygnifydCaseId = 42; - $dummyStoreId = 1; - $apiCallFailureMessage = 'Api call failed'; - - $this->withCaseEntity($dummySygnifydCaseId, $dummyStoreId); - $this->apiClient - ->method('makeApiCall') - ->willThrowException(new ApiCallException($apiCallFailureMessage)); - - $this->expectException(GatewayException::class); - $this->expectExceptionMessage($apiCallFailureMessage); - $result = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId); - $this->assertEquals('Api call failed', $result); - } - - public function testSubmitCaseForGuaranteeReturnsDisposition() - { - $dummySygnifydCaseId = 42; - $dummyStoreId = 1; - $dummyDisposition = 'APPROVED'; - $dummyGuaranteeId = 123; - $dummyRereviewCount = 0; - - $this->withCaseEntity($dummySygnifydCaseId, $dummyStoreId); - $this->apiClient - ->method('makeApiCall') - ->willReturn([ - 'guaranteeId' => $dummyGuaranteeId, - 'disposition' => $dummyDisposition, - 'rereviewCount' => $dummyRereviewCount, - ]); - - $actualDisposition = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId); - $this->assertEquals( - $dummyDisposition, - $actualDisposition, - 'Method must return guarantee disposition retrieved in Signifyd API response as a result' - ); - } - - public function testSubmitCaseForGuaranteeWithMissedDisposition() - { - $dummySygnifydCaseId = 42; - $dummyStoreId = 1; - $dummyGuaranteeId = 123; - $dummyRereviewCount = 0; - - $this->withCaseEntity($dummySygnifydCaseId, $dummyStoreId); - $this->apiClient - ->method('makeApiCall') - ->willReturn([ - 'guaranteeId' => $dummyGuaranteeId, - 'rereviewCount' => $dummyRereviewCount, - ]); - - $this->expectException(GatewayException::class); - $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId); - } - - public function testSubmitCaseForGuaranteeWithUnexpectedDisposition() - { - $dummySygnifydCaseId = 42; - $dummyStoreId = 1; - $dummyUnexpectedDisposition = 'UNEXPECTED'; - - $this->withCaseEntity($dummySygnifydCaseId, $dummyStoreId); - $this->apiClient - ->method('makeApiCall') - ->willReturn([ - 'disposition' => $dummyUnexpectedDisposition, - ]); - - $this->expectException(GatewayException::class); - $result = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId); - $this->assertEquals('UNEXPECTED', $result); - } - - /** - * @dataProvider supportedGuaranteeDispositionsProvider - */ - public function testSubmitCaseForGuaranteeWithExpectedDisposition($dummyExpectedDisposition) - { - $dummySygnifydCaseId = 42; - $dummyStoreId = 1; - - $this->withCaseEntity($dummySygnifydCaseId, $dummyStoreId); - $this->apiClient - ->method('makeApiCall') - ->willReturn([ - 'disposition' => $dummyExpectedDisposition, - ]); - - try { - $result = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId); - $this->assertEquals($dummyExpectedDisposition, $result); - } catch (GatewayException $e) { - $this->fail(sprintf( - 'Expected disposition "%s" was not accepted with message "%s"', - $dummyExpectedDisposition, - $e->getMessage() - )); - } - } - - /** - * Checks a test case when guarantee for a case is successfully canceled - * - * @covers \Magento\Signifyd\Model\SignifydGateway\Gateway::cancelGuarantee - */ - public function testCancelGuarantee() - { - $caseId = 123; - $dummyStoreId = 1; - - $this->withCaseEntity($caseId, $dummyStoreId); - $this->apiClient->expects(self::once()) - ->method('makeApiCall') - ->with( - '/cases/' . $caseId . '/guarantee', - 'PUT', - ['guaranteeDisposition' => Gateway::GUARANTEE_CANCELED], - $dummyStoreId - ) - ->willReturn( - ['disposition' => Gateway::GUARANTEE_CANCELED] - ); - - $result = $this->gateway->cancelGuarantee($caseId); - self::assertEquals(Gateway::GUARANTEE_CANCELED, $result); - } - - /** - * Checks a case when API request returns unexpected guarantee disposition. - * - * @covers \Magento\Signifyd\Model\SignifydGateway\Gateway::cancelGuarantee - * @expectedException \Magento\Signifyd\Model\SignifydGateway\GatewayException - * @expectedExceptionMessage API returned unexpected disposition: DECLINED. - */ - public function testCancelGuaranteeWithUnexpectedDisposition() - { - $caseId = 123; - $dummyStoreId = 1; - - $this->withCaseEntity($caseId, $dummyStoreId); - $this->apiClient->expects(self::once()) - ->method('makeApiCall') - ->with( - '/cases/' . $caseId . '/guarantee', - 'PUT', - ['guaranteeDisposition' => Gateway::GUARANTEE_CANCELED], - $dummyStoreId - ) - ->willReturn(['disposition' => Gateway::GUARANTEE_DECLINED]); - - $result = $this->gateway->cancelGuarantee($caseId); - $this->assertEquals(Gateway::GUARANTEE_CANCELED, $result); - } - - /** - * @return array - */ - public function supportedGuaranteeDispositionsProvider() - { - return [ - 'APPROVED' => ['APPROVED'], - 'DECLINED' => ['DECLINED'], - 'PENDING' => ['PENDING'], - 'CANCELED' => ['CANCELED'], - 'IN_REVIEW' => ['IN_REVIEW'], - 'UNREQUESTED' => ['UNREQUESTED'], - ]; - } - - /** - * Specifies order entity mock execution. - * - * @param int $orderId - * @param int $storeId - * @return void - */ - private function withOrderEntity(int $orderId, int $storeId): void - { - $orderEntity = $this->getMockBuilder(OrderInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $orderEntity->method('getStoreId') - ->willReturn($storeId); - $this->orderRepository->method('get') - ->with($orderId) - ->willReturn($orderEntity); - } - - /** - * Specifies case entity mock execution. - * - * @param int $caseId - * @param int $storeId - * @return void - */ - private function withCaseEntity(int $caseId, int $storeId): void - { - $orderId = 1; - - $caseEntity = $this->getMockBuilder(CaseInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $caseEntity->method('getOrderId') - ->willReturn($orderId); - $this->caseRepository->method('getByCaseId') - ->with($caseId) - ->willReturn($caseEntity); - - $this->withOrderEntity($orderId, $storeId); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php deleted file mode 100644 index 0dfdf4980fb58..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\SignifydGateway\Response; - -use Magento\Framework\Json\DecoderInterface; -use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequest; -use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessageReader; -use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessage; -use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessageFactory; - -/** - * Class WebhookMessageReaderTest - */ -class WebhookMessageReaderTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var WebhookMessageReader - */ - private $model; - - /** - * @var DecoderInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $decoder; - - /** - * @var WebhookMessageFactory|\PHPUnit_Framework_MockObject_MockObject - */ - private $webhookMessageFactory; - - /** - * @var WebhookRequest|\PHPUnit_Framework_MockObject_MockObject - */ - private $webhookRequest; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->decoder = $this->getMockBuilder(DecoderInterface::class) - ->getMockForAbstractClass(); - - $this->webhookMessageFactory = $this->getMockBuilder(WebhookMessageFactory::class) - ->setMethods(['create']) - ->disableOriginalConstructor() - ->getMock(); - - $this->webhookRequest = $this->getMockBuilder(WebhookRequest::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->model = new WebhookMessageReader( - $this->decoder, - $this->webhookMessageFactory - ); - } - - /** - * Tests successful reading webhook message from request. - * - */ - public function testReadSuccess() - { - $rawBody = 'body'; - $topic = 'topic'; - $decodedData = ['status' => "DISMISSED", 'orderId' => '19418']; - - $this->webhookRequest->expects($this->once()) - ->method('getBody') - ->willReturn($rawBody); - $this->webhookRequest->expects($this->once()) - ->method('getEventTopic') - ->willReturn('topic'); - $this->decoder->expects($this->once()) - ->method('decode') - ->with($rawBody) - ->willReturn($decodedData); - $webhookMessage = $this->getMockBuilder(WebhookMessage::class) - ->disableOriginalConstructor() - ->getMock(); - $this->webhookMessageFactory->expects($this->once()) - ->method('create') - ->with( - [ - 'data' => $decodedData, - 'eventTopic' => $topic - ] - ) - ->willReturn($webhookMessage); - - $this->assertEquals( - $webhookMessage, - $this->model->read($this->webhookRequest) - ); - } - - /** - * Tests reading failure webhook message from request. - * - * @expectedException \InvalidArgumentException - */ - public function testReadFail() - { - $this->decoder->expects($this->once()) - ->method('decode') - ->willThrowException(new \Exception('Error')); - - $this->model->read($this->webhookRequest); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php deleted file mode 100644 index 5ae6b95a77548..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php +++ /dev/null @@ -1,231 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model\SignifydGateway\Response; - -use Magento\Framework\Json\DecoderInterface; -use Magento\Signifyd\Model\Config; -use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequestValidator; -use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequest; - -/** - * Class WebhookRequestValidatorTest - */ -class WebhookRequestValidatorTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var WebhookRequestValidator - */ - private $model; - - /** - * @var Config|\PHPUnit_Framework_MockObject_MockObject - */ - private $config; - - /** - * @var DecoderInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $decoder; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->config = $this->getMockBuilder(Config::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->decoder = $this->getMockBuilder(DecoderInterface::class) - ->getMockForAbstractClass(); - - $this->model = new WebhookRequestValidator( - $this->config, - $this->decoder - ); - } - - /** - * Tests successful cases. - * - * @param string $body - * @param string $topic - * @param string $hash - * @param int$callConfigCount - * @dataProvider validateSuccessDataProvider - */ - public function testValidateSuccess($body, $topic, $hash, $callConfigCount) - { - $this->config->expects($this->exactly($callConfigCount)) - ->method('getApiKey') - ->willReturn('GpFZZnxGgIxuI8BazSm3v6eGK'); - - $this->decoder->expects($this->once()) - ->method('decode') - ->with($body) - ->willReturn(['status' => "DISMISSED", 'orderId' => '19418']); - - $webhookRequest = $this->createWebhookRequest($body, $topic, $hash); - - $this->assertTrue( - $this->model->validate($webhookRequest) - ); - } - - /** - * @case 1. All data are correct, event topic has real value - * @case 2. All data are correct, event topic has test value - * @return array - */ - public function validateSuccessDataProvider() - { - return [ - 1 => [ - 'body' => '{ status: "DISMISSED", orderId: "19418" }', - 'topic' => 'cases/creation', - 'hash' => 'KWR8Bzu3tinEpDviw1opWSMJGFqfpA79nNGp0TEYM6Q=', - 'callConfigCount' => 1 - ], - 2 => [ - 'body' => '{ status: "DISMISSED", orderId: "19418" }', - 'topic' => 'cases/test', - 'hash' => '6npAahliNbzYo/Qi4+g+JeqPhLFgg19sIbuxDLmvobw=', - 'callConfigCount' => 0 - ] - ]; - } - - /** - * Case with wrong event topic - * - * @param string $topic - * @dataProvider validationTopicFailsDataProvider - */ - public function testValidationTopicFails($topic) - { - $body = '{ status: "DISMISSED", orderId: "19418" }'; - $hash = 'KWR8Bzu3tinEpDviw1opWSMJGFqfpA79nNGp0TEYM6Q='; - - $this->config->expects($this->never()) - ->method('getApiKey'); - - $this->decoder->expects($this->never()) - ->method('decode'); - - $webhookRequest = $this->createWebhookRequest($body, $topic, $hash); - - $this->assertFalse( - $this->model->validate($webhookRequest), - 'Negative webhook event topic value validation fails' - ); - } - - /** - * @return array - */ - public function validationTopicFailsDataProvider() - { - return [ - ['wrong topic' => 'bla-bla-topic'], - ['empty topic' => ''] - ]; - } - - /** - * Case with wrong webhook request body - * - * @param string $body - * @dataProvider validationBodyFailsDataProvider - */ - public function testValidationBodyFails($body) - { - $topic = 'cases/creation'; - $hash = 'KWR8Bzu3tinEpDviw1opWSMJGFqfpA79nNGp0TEYM6Q='; - $webhookRequest = $this->createWebhookRequest($body, $topic, $hash); - - $this->config->expects($this->never()) - ->method('getApiKey'); - - if (empty($body)) { - $this->decoder->expects($this->once()) - ->method('decode') - ->with($body) - ->willReturn(''); - } else { - $this->decoder->expects($this->once()) - ->method('decode') - ->with($body) - ->willThrowException(new \Exception('Error')); - } - - $this->assertFalse( - $this->model->validate($webhookRequest), - 'Negative webhook request body validation fails' - ); - } - - /** - * @return array - */ - public function validationBodyFailsDataProvider() - { - return [ - ['Empty request body' => ''], - ['Bad request body' => '{ bad data}'] - ]; - } - - /** - * Case with wrong hash - */ - public function testValidationHashFails() - { - $topic = 'cases/creation'; - $body = '{ status: "DISMISSED", orderId: "19418" }'; - $hash = 'wrong hash'; - $webhookRequest = $this->createWebhookRequest($body, $topic, $hash); - - $this->config->expects($this->once()) - ->method('getApiKey') - ->willReturn('GpFZZnxGgIxuI8BazSm3v6eGK'); - - $this->decoder->expects($this->once()) - ->method('decode') - ->with($body) - ->willReturn(['status' => "DISMISSED", 'orderId' => '19418']); - - $this->assertFalse( - $this->model->validate($webhookRequest), - 'Negative webhook hash validation fails' - ); - } - - /** - * Returns mocked WebhookRequest - * - * @param string $body - * @param string $topic - * @param string $hash - * @return WebhookRequest|\PHPUnit_Framework_MockObject_MockObject - */ - private function createWebhookRequest($body, $topic, $hash) - { - $webhookRequest = $this->getMockBuilder(WebhookRequest::class) - ->disableOriginalConstructor() - ->getMock(); - $webhookRequest->expects($this->once()) - ->method('getBody') - ->willReturn($body); - $webhookRequest->expects($this->once()) - ->method('getEventTopic') - ->willReturn($topic); - $webhookRequest->expects($this->once()) - ->method('getHash') - ->willReturn($hash); - - return $webhookRequest; - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php deleted file mode 100644 index 9d3061f240c21..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Model; - -use Magento\Checkout\Model\Session as CheckoutSession; -use Magento\Framework\DataObject\IdentityGeneratorInterface; -use Magento\Signifyd\Model\SignifydOrderSessionId; -use PHPUnit_Framework_MockObject_MockObject as MockObject; - -/** - * Class SignifydOrderSessionIdTest tests that SignifydOrderSessionId class dependencies - * follow the contracts. - */ -class SignifydOrderSessionIdTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var SignifydOrderSessionId - */ - private $signifydOrderSessionId; - - /** - * @var IdentityGeneratorInterface|MockObject - */ - private $identityGenerator; - - /** - * Sets up testing class and dependency mocks. - */ - protected function setUp() - { - $this->identityGenerator = $this->getMockBuilder(IdentityGeneratorInterface::class) - ->getMockForAbstractClass(); - - $this->signifydOrderSessionId = new SignifydOrderSessionId($this->identityGenerator); - } - - /** - * Tests method by passing quoteId parameter - * - * @covers \Magento\Signifyd\Model\SignifydOrderSessionId::get - */ - public function testGetByQuoteId() - { - $quoteId = 1; - $signifydOrderSessionId = 'asdfzxcv'; - - $this->identityGenerator->expects(self::once()) - ->method('generateIdForData') - ->with($quoteId) - ->willReturn($signifydOrderSessionId); - - $this->assertEquals( - $signifydOrderSessionId, - $this->signifydOrderSessionId->get($quoteId) - ); - } -} diff --git a/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php b/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php deleted file mode 100644 index d63831b1d4a8e..0000000000000 --- a/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php +++ /dev/null @@ -1,284 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Unit\Observer; - -use Magento\Framework\Event; -use Magento\Framework\Event\Observer; -use Magento\Framework\Exception\AlreadyExistsException; -use Magento\Payment\Model\MethodInterface; -use Magento\Sales\Api\Data\OrderInterface; -use Magento\Sales\Model\Order; -use Magento\Sales\Model\Order\Payment; -use Magento\Signifyd\Api\CaseCreationServiceInterface; -use Magento\Signifyd\Model\Config; -use Magento\Signifyd\Observer\PlaceOrder; -use PHPUnit_Framework_MockObject_MockObject as MockObject; -use Psr\Log\LoggerInterface; - -class PlaceOrderTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var Config|MockObject - */ - private $config; - - /** - * @var CaseCreationServiceInterface|MockObject - */ - private $creationService; - - /** - * @var LoggerInterface|MockObject - */ - private $logger; - - /** - * @var Observer|MockObject - */ - private $observer; - - /** - * @var Event|MockObject - */ - private $event; - - /** - * @var OrderInterface|MockObject - */ - private $orderEntity; - - /** - * @var PlaceOrder - */ - private $placeOrder; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->config = $this->getMockBuilder(Config::class) - ->disableOriginalConstructor() - ->setMethods(['isActive']) - ->getMock(); - - $this->logger = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->creationService = $this->getMockBuilder(CaseCreationServiceInterface::class) - ->disableOriginalConstructor() - ->setMethods(['createForOrder']) - ->getMock(); - - $this->observer = $this->getMockBuilder(Observer::class) - ->disableOriginalConstructor() - ->setMethods(['getEvent']) - ->getMock(); - - $this->event = $this->getMockBuilder(Event::class) - ->disableOriginalConstructor() - ->setMethods(['getData']) - ->getMock(); - - $this->placeOrder = new PlaceOrder( - $this->config, - $this->creationService, - $this->logger - ); - } - - /** - * Checks a test case when Signifyd module is disabled. - * - * @covers \Magento\Signifyd\Observer\PlaceOrder::execute - */ - public function testExecuteWithDisabledModule() - { - $orderId = 1; - $storeId = 2; - $this->withActiveSignifydIntegration(false, $storeId); - $this->withOrderEntity($orderId, $storeId); - - $this->creationService->expects(self::never()) - ->method('createForOrder'); - - $this->placeOrder->execute($this->observer); - } - - /** - * Checks a test case when the observer event returns empty an order entity. - * - * @covers \Magento\Signifyd\Observer\PlaceOrder::execute - */ - public function testExecuteWithoutOrder() - { - $this->withActiveSignifydIntegration(true); - $this->withOrderEntity(null, null); - - $this->creationService->expects(self::never()) - ->method('createForOrder'); - - $this->placeOrder->execute($this->observer); - } - - /** - * Checks a test case when the order placed with offline payment method. - * - * @covers \Magento\Signifyd\Observer\PlaceOrder::execute - */ - public function testExecuteWithOfflinePayment() - { - $orderId = 1; - $storeId = 2; - $this->withActiveSignifydIntegration(true, $storeId); - $this->withOrderEntity($orderId, $storeId); - $this->withAvailablePaymentMethod(false); - - $this->creationService->expects(self::never()) - ->method('createForOrder'); - - $this->placeOrder->execute($this->observer); - } - - /** - * Checks a test case when case creation service fails. - * - * @covers \Magento\Signifyd\Observer\PlaceOrder::execute - */ - public function testExecuteWithFailedCaseCreation() - { - $orderId = 1; - $storeId = 2; - $exceptionMessage = __('Case with the same order id already exists.'); - - $this->withActiveSignifydIntegration(true, $storeId); - $this->withOrderEntity($orderId, $storeId); - $this->withAvailablePaymentMethod(true); - - $this->creationService->method('createForOrder') - ->with(self::equalTo($orderId)) - ->willThrowException(new AlreadyExistsException($exceptionMessage)); - - $this->logger->method('error') - ->with(self::equalTo($exceptionMessage)); - - $result = $this->placeOrder->execute($this->observer); - $this->assertNull($result); - } - - /** - * Checks a test case when observer successfully calls case creation service. - * - * @covers \Magento\Signifyd\Observer\PlaceOrder::execute - */ - public function testExecute() - { - $orderId = 1; - $storeId = 2; - - $this->withActiveSignifydIntegration(true, $storeId); - $this->withOrderEntity($orderId, $storeId); - $this->withAvailablePaymentMethod(true); - - $this->creationService - ->method('createForOrder') - ->with(self::equalTo($orderId)); - - $this->logger->expects(self::never()) - ->method('error'); - - $this->placeOrder->execute($this->observer); - } - - public function testExecuteWithOrderPendingPayment() - { - $orderId = 1; - $storeId = 2; - - $this->withActiveSignifydIntegration(true, $storeId); - $this->withOrderEntity($orderId, $storeId); - $this->orderEntity->method('getState') - ->willReturn(Order::STATE_PENDING_PAYMENT); - $this->withAvailablePaymentMethod(true); - - $this->creationService->expects(self::never()) - ->method('createForOrder'); - - $this->placeOrder->execute($this->observer); - } - - /** - * Specifies order entity mock execution. - * - * @param int|null $orderId - * @param int|null $storeId - * @return void - */ - private function withOrderEntity($orderId, $storeId): void - { - $this->orderEntity = $this->getMockBuilder(OrderInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->orderEntity->method('getEntityId') - ->willReturn($orderId); - $this->orderEntity->method('getStoreId') - ->willReturn($storeId); - - $this->observer->method('getEvent') - ->willReturn($this->event); - - $this->event->method('getData') - ->with('order') - ->willReturn($this->orderEntity); - } - - /** - * Specifies config mock execution. - * - * @param bool $isActive - * @param int|null $storeId - * @return void - */ - private function withActiveSignifydIntegration(bool $isActive, $storeId = null): void - { - $this->config->method('isActive') - ->with($storeId) - ->willReturn($isActive); - } - - /** - * Specifies payment method mock execution. - * - * @param bool $isAvailable - * @return void - */ - private function withAvailablePaymentMethod($isAvailable) - { - /** @var MethodInterface|MockObject $paymentMethod */ - $paymentMethod = $this->getMockBuilder(MethodInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - /** - * The code depends on implementation but not interface - * because order payment implements two interfaces - */ - /** @var Payment|MockObject $orderPayment */ - $orderPayment = $this->getMockBuilder(Payment::class) - ->disableOriginalConstructor() - ->getMock(); - $this->orderEntity->method('getPayment') - ->willReturn($orderPayment); - - $orderPayment->method('getMethodInstance') - ->willReturn($paymentMethod); - - $paymentMethod->method('isOffline') - ->willReturn(!$isAvailable); - } -} diff --git a/app/code/Magento/Signifyd/Ui/Component/Listing/Column/Guarantee/Options.php b/app/code/Magento/Signifyd/Ui/Component/Listing/Column/Guarantee/Options.php deleted file mode 100644 index 1e6234a8e27a9..0000000000000 --- a/app/code/Magento/Signifyd/Ui/Component/Listing/Column/Guarantee/Options.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Ui\Component\Listing\Column\Guarantee; - -use Magento\Framework\Escaper; -use Magento\Framework\Data\OptionSourceInterface; -use Magento\Signifyd\Api\Data\CaseInterface; - -/** - * Class Options - */ -class Options implements OptionSourceInterface -{ - /** - * @var Escaper - */ - private $escaper; - - /** - * Constructor - * - * @param Escaper $escaper - */ - public function __construct(Escaper $escaper) - { - $this->escaper = $escaper; - } - - /** - * {@inheritdoc} - */ - public function toOptionArray() - { - return [ - [ - 'value' => CaseInterface::GUARANTEE_DECLINED, - 'label' => $this->escaper->escapeHtml(__('Declined')) - ], - [ - 'value' => CaseInterface::GUARANTEE_APPROVED, - 'label' => $this->escaper->escapeHtml(__('Approved')) - ], - [ - 'value' => CaseInterface::GUARANTEE_CANCELED, - 'label' => $this->escaper->escapeHtml(__('Canceled')) - ], - [ - 'value' => CaseInterface::GUARANTEE_PENDING, - 'label' => $this->escaper->escapeHtml(__('Pending')) - ] - ]; - } -} diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json deleted file mode 100644 index c0214e9a2813c..0000000000000 --- a/app/code/Magento/Signifyd/composer.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "magento/module-signifyd", - "description": "Submitting Case Entry to Signifyd on Order Creation", - "config": { - "sort-packages": true - }, - "require": { - "magento/framework": "*", - "magento/module-backend": "*", - "magento/module-checkout": "*", - "magento/module-config": "*", - "magento/module-customer": "*", - "magento/module-directory": "*", - "magento/module-payment": "*", - "magento/module-sales": "*", - "magento/module-store": "*", - "php": "~7.1.3||~7.2.0||~7.3.0" - }, - "suggest": { - "magento/module-config": "*" - }, - "type": "magento2-module", - "license": [ - "OSL-3.0", - "AFL-3.0" - ], - "autoload": { - "files": [ - "registration.php" - ], - "psr-4": { - "Magento\\Signifyd\\": "" - } - } -} diff --git a/app/code/Magento/Signifyd/etc/acl.xml b/app/code/Magento/Signifyd/etc/acl.xml deleted file mode 100644 index 32f0493fbcad9..0000000000000 --- a/app/code/Magento/Signifyd/etc/acl.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd"> - <acl> - <resources> - <resource id="Magento_Backend::admin"> - <resource id="Magento_Backend::stores"> - <resource id="Magento_Backend::stores_settings"> - <resource id="Magento_Config::config"> - <resource id="Magento_Sales::fraud_protection" title="Fraud Protection Section" translate="title" /> - </resource> - </resource> - </resource> - </resource> - </resources> - </acl> -</config> diff --git a/app/code/Magento/Signifyd/etc/adminhtml/di.xml b/app/code/Magento/Signifyd/etc/adminhtml/di.xml deleted file mode 100644 index c771d67216d43..0000000000000 --- a/app/code/Magento/Signifyd/etc/adminhtml/di.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> - <preference for="Magento\Signifyd\Model\QuoteSession\QuoteSessionInterface" type="Magento\Signifyd\Model\QuoteSession\Adminhtml\BackendSession" /> -</config> diff --git a/app/code/Magento/Signifyd/etc/adminhtml/routes.xml b/app/code/Magento/Signifyd/etc/adminhtml/routes.xml deleted file mode 100644 index c078ab3c8c4c1..0000000000000 --- a/app/code/Magento/Signifyd/etc/adminhtml/routes.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd"> - <router id="admin"> - <route id="signifyd" frontName="signifyd"> - <module name="Magento_Signifyd" before="Magento_Backend" /> - </route> - </router> -</config> diff --git a/app/code/Magento/Signifyd/etc/adminhtml/system.xml b/app/code/Magento/Signifyd/etc/adminhtml/system.xml deleted file mode 100644 index 182a67e4e1f35..0000000000000 --- a/app/code/Magento/Signifyd/etc/adminhtml/system.xml +++ /dev/null @@ -1,77 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> - <system> - <section id="fraud_protection" translate="label" type="text" sortOrder="410" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Fraud Protection</label> - <tab>sales</tab> - <resource>Magento_Sales::fraud_protection</resource> - <group id="signifyd" type="text" sortOrder="10" showInDefault="1" showInWebsite="1"> - <fieldset_css>signifyd-logo-header</fieldset_css> - <group id="about" translate="label comment" sortOrder="15" showInDefault="1" showInWebsite="1"> - <frontend_model>Magento\Signifyd\Block\Adminhtml\System\Config\Fieldset\Info</frontend_model> - <fieldset_css>signifyd-about-header</fieldset_css> - <label><![CDATA[Protect your store from fraud with Guaranteed Fraud Protection by Signifyd.]]></label> - <comment><![CDATA[Signifyd automatically reviews your orders for fraud, telling you in seconds which orders to ship, and which to reject. - We back our approvals with 100% chargeback protection, reimbursing you the full order amount plus fees should you ever receive a fraudulent chargeback. - <p>Benefits:<ul> - <li>Grow your business without fear of fraud</li> - <li>Accept more orders and maximize your revenue</li> - <li>Automate order review and shift fraud off your plate</li></ul></p>]]> - </comment> - <more_url>https://www.signifyd.com/magento-guaranteed-fraud-protection</more_url> - </group> - <group id="config" translate="label comment" sortOrder="15" showInDefault="1" showInWebsite="1"> - <fieldset_css>signifyd-about-header</fieldset_css> - <label>Configuration</label> - <comment><![CDATA[<a href="https://www.signifyd.com/resources/manual/magento-2/signifyd-on-magento-integration-guide/" target="_blank">View our setup guide</a> for step-by-step instructions on how to integrate Signifyd with Magento.<br />For support contact <a href="mailto:support@signifyd.com">support@signifyd.com</a>.]]> - </comment> - <field id="active" translate="label" type="select" showInDefault="1" showInWebsite="1"> - <label>Enable this Solution</label> - <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> - <config_path>fraud_protection/signifyd/active</config_path> - </field> - <field id="api_key" translate="label" type="obscure" sortOrder="20" showInDefault="1" showInWebsite="1"> - <label>API Key</label> - <comment><![CDATA[Your API key can be found on the <a href="http://signifyd.com/settings" target="_blank">settings page</a> in the Signifyd console.]]></comment> - <config_path>fraud_protection/signifyd/api_key</config_path> - <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> - <depends> - <field id="active">1</field> - </depends> - </field> - <field id="api_url" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1"> - <label>API URL</label> - <config_path>fraud_protection/signifyd/api_url</config_path> - <comment>Don’t change unless asked to do so.</comment> - <depends> - <field id="active">1</field> - </depends> - </field> - <field id="debug" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1"> - <label>Debug</label> - <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> - <config_path>fraud_protection/signifyd/debug</config_path> - <depends> - <field id="active">1</field> - </depends> - </field> - <field id="webhook_url" translate="label comment" type="text" sortOrder="50" showInDefault="1" showInWebsite="1"> - <label>Webhook URL</label> - <comment><![CDATA[Your webhook URL will be used to <a href="https://app.signifyd.com/settings/notifications" target="_blank">configure</a> a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento.]]></comment> - <attribute type="handler_url">signifyd/webhooks/handler</attribute> - <frontend_model>Magento\Signifyd\Block\Adminhtml\System\Config\Field\WebhookUrl</frontend_model> - <depends> - <field id="active">1</field> - </depends> - </field> - </group> - </group> - </section> - </system> -</config> diff --git a/app/code/Magento/Signifyd/etc/config.xml b/app/code/Magento/Signifyd/etc/config.xml deleted file mode 100644 index 804342a14bb08..0000000000000 --- a/app/code/Magento/Signifyd/etc/config.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd"> - <default> - <fraud_protection> - <signifyd> - <active>0</active> - <api_url>https://api.signifyd.com/v2/</api_url> - <api_key backend_model="Magento\Config\Model\Config\Backend\Encrypted" /> - <debug>0</debug> - </signifyd> - </fraud_protection> - </default> -</config> diff --git a/app/code/Magento/Signifyd/etc/db_schema.xml b/app/code/Magento/Signifyd/etc/db_schema.xml deleted file mode 100644 index 8d47321c38b29..0000000000000 --- a/app/code/Magento/Signifyd/etc/db_schema.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> - <table name="signifyd_case" resource="sales" engine="innodb" comment="signifyd_case"> - <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true" - comment="Entity_id"/> - <column xsi:type="int" name="order_id" padding="10" unsigned="true" nullable="true" identity="false" - comment="Order_id"/> - <column xsi:type="int" name="case_id" padding="10" unsigned="true" nullable="true" identity="false" - comment="Case_id"/> - <column xsi:type="boolean" name="guarantee_eligible" nullable="true" comment="Guarantee_eligible"/> - <column xsi:type="varchar" name="guarantee_disposition" nullable="true" length="32" default="PENDING" - comment="Guarantee_disposition"/> - <column xsi:type="varchar" name="status" nullable="true" length="32" default="PENDING" comment="Status"/> - <column xsi:type="int" name="score" padding="10" unsigned="true" nullable="true" identity="false" - comment="Score"/> - <column xsi:type="text" name="associated_team" nullable="true" comment="Associated_team"/> - <column xsi:type="varchar" name="review_disposition" nullable="true" length="32" comment="Review_disposition"/> - <column xsi:type="timestamp" name="created_at" on_update="false" nullable="true" comment="Created_at"/> - <column xsi:type="timestamp" name="updated_at" on_update="false" nullable="true" comment="Updated_at"/> - <constraint xsi:type="primary" referenceId="PRIMARY"> - <column name="entity_id"/> - </constraint> - <constraint xsi:type="foreign" referenceId="SIGNIFYD_CASE_ORDER_ID_SALES_ORDER_ENTITY_ID" table="signifyd_case" - column="order_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" referenceId="SIGNIFYD_CASE_ORDER_ID"> - <column name="order_id"/> - </constraint> - <constraint xsi:type="unique" referenceId="SIGNIFYD_CASE_CASE_ID"> - <column name="case_id"/> - </constraint> - </table> - <table name="sales_order_grid" resource="sales" comment="Sales Flat Order Grid"> - <column xsi:type="varchar" name="signifyd_guarantee_status" nullable="true" length="32" - comment="Signifyd Guarantee Disposition Status"/> - </table> -</schema> diff --git a/app/code/Magento/Signifyd/etc/db_schema_whitelist.json b/app/code/Magento/Signifyd/etc/db_schema_whitelist.json deleted file mode 100644 index 69d164b23d9e7..0000000000000 --- a/app/code/Magento/Signifyd/etc/db_schema_whitelist.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "signifyd_case": { - "column": { - "entity_id": true, - "order_id": true, - "case_id": true, - "guarantee_eligible": true, - "guarantee_disposition": true, - "status": true, - "score": true, - "associated_team": true, - "review_disposition": true, - "created_at": true, - "updated_at": true - }, - "constraint": { - "PRIMARY": true, - "SIGNIFYD_CASE_ORDER_ID_SALES_ORDER_ENTITY_ID": true, - "SIGNIFYD_CASE_ORDER_ID": true, - "SIGNIFYD_CASE_CASE_ID": true - } - }, - "sales_order_grid": { - "column": { - "signifyd_guarantee_status": true - } - } -} \ No newline at end of file diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml deleted file mode 100644 index e82e8f84b3584..0000000000000 --- a/app/code/Magento/Signifyd/etc/di.xml +++ /dev/null @@ -1,105 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> - <preference for="Magento\Signifyd\Api\Data\CaseInterface" type="Magento\Signifyd\Model\CaseEntity" /> - <preference for="Magento\Signifyd\Api\CaseRepositoryInterface" type="Magento\Signifyd\Model\CaseRepository" /> - <preference for="Magento\Signifyd\Api\CaseManagementInterface" type="Magento\Signifyd\Model\CaseManagement" /> - <preference for="Magento\Signifyd\Api\Data\CaseSearchResultsInterface" type="Magento\Signifyd\Model\CaseSearchResults" /> - <preference for="Magento\Signifyd\Api\CaseCreationServiceInterface" type="Magento\Signifyd\Model\CaseServices\CreationService" /> - <preference for="Magento\Signifyd\Api\GuaranteeCreationServiceInterface" type="Magento\Signifyd\Model\Guarantee\CreationService" /> - <preference for="Magento\Signifyd\Api\GuaranteeCancelingServiceInterface" type="Magento\Signifyd\Model\Guarantee\CancelingService" /> - <preference for="Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilderInterface" type="Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilder" /> - - <virtualType name="SignifydAvsDefaultMapper" type="Magento\Signifyd\Model\PredefinedVerificationCode" /> - <virtualType name="SignifydCvvDefaultMapper" type="Magento\Signifyd\Model\PredefinedVerificationCode" /> - - <type name="Magento\Signifyd\Model\PaymentVerificationFactory"> - <arguments> - <argument name="config" xsi:type="object">Magento\Payment\Gateway\Config\Config</argument> - <argument name="avsDefaultAdapter" xsi:type="object">SignifydAvsDefaultMapper</argument> - <argument name="cvvDefaultAdapter" xsi:type="object">SignifydCvvDefaultMapper</argument> - </arguments> - </type> - <type name="Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater"> - <arguments> - <argument name="entityGrid" xsi:type="object">Magento\Sales\Model\ResourceModel\Order\Grid</argument> - </arguments> - </type> - <virtualType name="SignifydIdListProvider" type="Magento\Sales\Model\ResourceModel\Provider\NotSyncedDataProvider"> - <arguments> - <argument name="providers" xsi:type="array"> - <item name="signifyd" xsi:type="string">Magento\Signifyd\Model\SalesOrderGrid\NotSyncedOrderIdListProvider</item> - </argument> - </arguments> - </virtualType> - <virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid"> - <arguments> - <argument name="idListProvider" xsi:type="object">SignifydIdListProvider</argument> - <argument name="joins" xsi:type="array"> - <item name="signifyd_case" xsi:type="array"> - <item name="table" xsi:type="string">signifyd_case</item> - <item name="origin_column" xsi:type="string">entity_id</item> - <item name="target_column" xsi:type="string">order_id</item> - </item> - </argument> - <argument name="columns" xsi:type="array"> - <item name="signifyd_guarantee_status" xsi:type="string">signifyd_case.guarantee_disposition</item> - </argument> - </arguments> - </virtualType> - <type name="Magento\Signifyd\Model\ResourceModel\CaseEntity"> - <arguments> - <argument name="connectionName" xsi:type="string">sales</argument> - </arguments> - </type> - <virtualType name="PaymentMapperSchemaLocator" type="Magento\Framework\Config\GenericSchemaLocator"> - <arguments> - <argument name="moduleName" xsi:type="string">Magento_Signifyd</argument> - <argument name="schema" xsi:type="string">signifyd_payment_mapping.xsd</argument> - </arguments> - </virtualType> - <virtualType name="PaymentMapperConfigReader" type="Magento\Framework\Config\Reader\Filesystem"> - <arguments> - <argument name="converter" xsi:type="object">Magento\Signifyd\Model\PaymentMethodMapper\XmlToArrayConfigConverter</argument> - <argument name="schemaLocator" xsi:type="object">PaymentMapperSchemaLocator</argument> - <argument name="fileName" xsi:type="string">signifyd_payment_mapping.xml</argument> - <argument name="idAttributes" xsi:type="array"> - <item name="/config/payment_method_list/payment_method" xsi:type="string">name</item> - </argument> - </arguments> - </virtualType> - <virtualType name="PaymentMethodConfigData" type="Magento\Framework\Config\Data"> - <arguments> - <argument name="reader" xsi:type="object">PaymentMapperConfigReader</argument> - <argument name="cacheId" xsi:type="string">signifyd_payment_list_cache</argument> - </arguments> - </virtualType> - <type name="Magento\Signifyd\Model\PaymentMethodMapper\PaymentMethodMapper"> - <arguments> - <argument name="paymentMapping" xsi:type="object">PaymentMethodConfigData</argument> - </arguments> - </type> - <type name="Magento\Config\Model\Config\TypePool"> - <arguments> - <argument name="sensitive" xsi:type="array"> - <item name="fraud_protection/signifyd/api_key" xsi:type="string">1</item> - <item name="fraud_protection/signifyd/api_url" xsi:type="string">1</item> - </argument> - <argument name="environment" xsi:type="array"> - <item name="fraud_protection/signifyd/api_key" xsi:type="string">1</item> - <item name="fraud_protection/signifyd/api_url" xsi:type="string">1</item> - </argument> - </arguments> - </type> - <type name="Magento\Sales\Model\Order"> - <plugin name="cancelGuaranteeAfterOrderCancel" type="Magento\Signifyd\Plugin\OrderPlugin" /> - </type> - <type name="Magento\Payment\Model\MethodInterface"> - <plugin name="cancelGuaranteeAfterPaymentDeny" type="Magento\Signifyd\Plugin\PaymentPlugin" /> - </type> -</config> diff --git a/app/code/Magento/Signifyd/etc/events.xml b/app/code/Magento/Signifyd/etc/events.xml deleted file mode 100644 index d44665f9fb97b..0000000000000 --- a/app/code/Magento/Signifyd/etc/events.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> - <event name="checkout_submit_all_after"> - <observer name="signifyd_place_order_observer" instance="Magento\Signifyd\Observer\PlaceOrder" /> - </event> - <event name="paypal_checkout_success"> - <observer name="signifyd_place_order_checkout_success_observer" instance="Magento\Signifyd\Observer\PlaceOrder" /> - </event> - <event name="checkout_onepage_controller_success_action"> - <observer name="signifyd_place_order_checkout_success_observer" instance="Magento\Signifyd\Observer\PlaceOrder" /> - </event> -</config> diff --git a/app/code/Magento/Signifyd/etc/frontend/di.xml b/app/code/Magento/Signifyd/etc/frontend/di.xml deleted file mode 100644 index 08a690d1a9930..0000000000000 --- a/app/code/Magento/Signifyd/etc/frontend/di.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> - <preference for="Magento\Signifyd\Model\QuoteSession\QuoteSessionInterface" type="Magento\Signifyd\Model\QuoteSession\FrontendSession" /> -</config> diff --git a/app/code/Magento/Signifyd/etc/frontend/routes.xml b/app/code/Magento/Signifyd/etc/frontend/routes.xml deleted file mode 100644 index 5803f59d8624b..0000000000000 --- a/app/code/Magento/Signifyd/etc/frontend/routes.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd"> - <router id="standard"> - <route id="signifyd" frontName="signifyd"> - <module name="Magento_Signifyd" /> - </route> - </router> -</config> diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml deleted file mode 100644 index 264f295e8c528..0000000000000 --- a/app/code/Magento/Signifyd/etc/module.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="Magento_Signifyd" > - <sequence> - <module name="Magento_Sales" /> - <module name="Magento_Store" /> - <module name="Magento_Customer" /> - <module name="Magento_Directory" /> - <module name="Magento_Checkout" /> - <module name="Magento_Backend" /> - <module name="Magento_Payment" /> - </sequence> - </module> -</config> diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml deleted file mode 100644 index 9ff952d04925d..0000000000000 --- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml +++ /dev/null @@ -1,82 +0,0 @@ -<?xml version="1.0" ?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - /** - * Custom payment method might adds a block in payment_method_list e.g. - * <payment_method name="custom_payment_method"> - * <magento_code>custom_payment_method</magento_code> - * <signifyd_code>PAYMENT_CARD</signifyd_code> - * </payment_method> - * Appropriate value for the <signifyd_code> tag from Signifyd documentation: - * @see https://www.signifyd.com/docs/api/#/reference/webhooks/manage-single-webhooks/create-a-case - * Create a Case -> Request -> ATTRIBUTES -> paymentMethod - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Signifyd:etc/signifyd_payment_mapping.xsd"> - <payment_method_list> - <payment_method name="braintree"> - <magento_code>braintree</magento_code> - <signifyd_code>PAYMENT_CARD</signifyd_code> - </payment_method> - <payment_method name="braintree_paypal"> - <magento_code>braintree_paypal</magento_code> - <signifyd_code>PAYPAL_ACCOUNT</signifyd_code> - </payment_method> - <payment_method name="paypal_express"> - <magento_code>paypal_express</magento_code> - <signifyd_code>PAYPAL_ACCOUNT</signifyd_code> - </payment_method> - <payment_method name="paypal_express_bml"> - <magento_code>paypal_express_bml</magento_code> - <signifyd_code>PAYPAL_ACCOUNT</signifyd_code> - </payment_method> - <payment_method name="payflow_express"> - <magento_code>payflow_express</magento_code> - <signifyd_code>PAYPAL_ACCOUNT</signifyd_code> - </payment_method> - <payment_method name="payflow_express_bml"> - <magento_code>payflow_express_bml</magento_code> - <signifyd_code>PAYPAL_ACCOUNT</signifyd_code> - </payment_method> - <payment_method name="payflowpro"> - <magento_code>payflowpro</magento_code> - <signifyd_code>PAYMENT_CARD</signifyd_code> - </payment_method> - <payment_method name="payflow_link"> - <magento_code>payflow_link</magento_code> - <signifyd_code>PAYMENT_CARD</signifyd_code> - </payment_method> - <payment_method name="payflow_advanced"> - <magento_code>payflow_advanced</magento_code> - <signifyd_code>PAYMENT_CARD</signifyd_code> - </payment_method> - <payment_method name="hosted_pro"> - <magento_code>hosted_pro</magento_code> - <signifyd_code>PAYMENT_CARD</signifyd_code> - </payment_method> - <payment_method name="authorizenet_directpost"> - <magento_code>authorizenet_directpost</magento_code> - <signifyd_code>PAYMENT_CARD</signifyd_code> - </payment_method> - <payment_method name="worldpay"> - <magento_code>worldpay</magento_code> - <signifyd_code>PAYMENT_CARD</signifyd_code> - </payment_method> - <payment_method name="eway"> - <magento_code>eway</magento_code> - <signifyd_code>PAYMENT_CARD</signifyd_code> - </payment_method> - <payment_method name="cybersource"> - <magento_code>cybersource</magento_code> - <signifyd_code>PAYMENT_CARD</signifyd_code> - </payment_method> - <payment_method name="free"> - <magento_code>free</magento_code> - <signifyd_code>FREE</signifyd_code> - </payment_method> - </payment_method_list> -</config> diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd deleted file mode 100644 index bb3b3036d0c9c..0000000000000 --- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" ?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <xs:element name="config"> - <xs:complexType> - <xs:sequence> - <xs:element minOccurs="1" maxOccurs="unbounded" name="payment_method_list" type="payment_method_list"/> - </xs:sequence> - </xs:complexType> - </xs:element> - <xs:complexType name="payment_method_list"> - <xs:sequence> - <xs:element minOccurs="1" maxOccurs="unbounded" name="payment_method" type="payment_method"/> - </xs:sequence> - </xs:complexType> - <xs:complexType name="payment_method"> - <xs:sequence> - <xs:element minOccurs="1" name="magento_code"/> - <xs:element minOccurs="1" name="signifyd_code"/> - </xs:sequence> - <xs:attribute name="name" type="xs:string" use="optional"> - <xs:annotation> - <xs:documentation> - Element's unique identifier. - </xs:documentation> - </xs:annotation> - </xs:attribute> - </xs:complexType> -</xs:schema> diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv deleted file mode 100644 index 40772188dac9e..0000000000000 --- a/app/code/Magento/Signifyd/i18n/en_US.csv +++ /dev/null @@ -1,46 +0,0 @@ -OPEN,Open -PROCESSING,Processing -FLAGGED,Flagged -DISMISSED,Dismissed -HELD,Held -GOOD,Good -FRAUDULENT,Fraudulent -UNSET,Unset -NULL,Unset -APPROVED,Approved -DECLINED,Declined -PENDING,Pending -CANCELED,Canceled -IN_REVIEW,"In review" -Approved,Approved -Declined,Declined -Pending,Pending -Canceled,Canceled -"In Review","In Review" -Unrequested,Unrequested -"Learn more","Learn more" -"This order already has associated case entity","This order already has associated case entity" -"The case entity should not be empty.","The case entity should not be empty." -"Cannot update Case entity.","Cannot update Case entity." -"The ""%1"" should not be empty.","The ""%1"" should not be empty." -"Case entity not found.","Case entity not found." -"Case Update: New score for the order is %1. Previous score was %2.","Case Update: New score for the order is %1. Previous score was %2." -"Awaiting the Signifyd guarantee disposition.","Awaiting the Signifyd guarantee disposition." -"Only single entrance of ""%1"" node is required.","Only single entrance of ""%1"" node is required." -"Not empty value for ""%1"" node is required.","Not empty value for ""%1"" node is required." -"%1 must implement %2","%1 must implement %2" -Error,Error -"Cannot generate message.","Cannot generate message." -"Message is generated.","Message is generated." -"Case with the same order id already exists.","Case with the same order id already exists." -"Fraud Protection Information","Fraud Protection Information" -"Signifyd Guarantee Decision","Signifyd Guarantee Decision" -"Fraud Protection Section","Fraud Protection Section" -"Fraud Protection","Fraud Protection" -"Protect your store from fraud with Guaranteed Fraud Protection by Signifyd.","Protect your store from fraud with Guaranteed Fraud Protection by Signifyd." -Configuration,Configuration -"Enable this Solution","Enable this Solution" -"API Key","API Key" -"API URL","API URL" -Debug,Debug -"Webhook URL","Webhook URL" diff --git a/app/code/Magento/Signifyd/registration.php b/app/code/Magento/Signifyd/registration.php deleted file mode 100644 index e7fa9cfd2f9b3..0000000000000 --- a/app/code/Magento/Signifyd/registration.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -use Magento\Framework\Component\ComponentRegistrar; - -ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_Signifyd', __DIR__); diff --git a/app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml b/app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml deleted file mode 100644 index ad62b2c6e01cf..0000000000000 --- a/app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - <body> - <referenceBlock name="order_additional_info"> - <block class="Magento\Signifyd\Block\Adminhtml\CaseInfo" name="order_case_info" template="Magento_Signifyd::case_info.phtml"/> - </referenceBlock> - </body> -</page> diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml deleted file mode 100644 index 07f1b2c2e4ae6..0000000000000 --- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml +++ /dev/null @@ -1,31 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -?> -<?php /** @var $block Magento\Signifyd\Block\Adminhtml\CaseInfo */ ?> -<?php -if ($block->isEmptyCase()) { - return ''; -} -?> -<section class="admin__page-section order-case-info"> - <div class="admin__page-section-title"> - <span class="title"><?= $block->escapeHtml(__('Fraud Protection Information')) ?></span> - </div> - <div class="admin__page-section-content"> - <div class="admin__page-section-item case-information"> - <div class="admin__table-wrapper"> - <table class="admin__table-secondary order-case-table"> - <tbody> - <tr> - <th class="col-guarantee-disposition"><?= $block->escapeHtml(__('Signifyd Guarantee Decision')) ?></th> - <td class="col-guarantee-disposition"><?= $block->escapeHtml($block->getCaseGuaranteeDisposition()) ?></td> - </tr> - </tbody> - </table> - </div> - </div> - </div> -</section> diff --git a/app/code/Magento/Signifyd/view/adminhtml/ui_component/sales_order_grid.xml b/app/code/Magento/Signifyd/view/adminhtml/ui_component/sales_order_grid.xml deleted file mode 100644 index 91053d617f31f..0000000000000 --- a/app/code/Magento/Signifyd/view/adminhtml/ui_component/sales_order_grid.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ /** - ~ * Copyright © Magento, Inc. All rights reserved. - ~ * See COPYING.txt for license details. - ~ */ - --> -<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> - <columns name="sales_order_columns"> - <column name="signifyd_guarantee_status" component="Magento_Ui/js/grid/columns/select"> - <settings> - <filter>select</filter> - <options class="Magento\Signifyd\Ui\Component\Listing\Column\Guarantee\Options"/> - <visible>true</visible> - <dataType>select</dataType> - <label translate="true">Signifyd Guarantee Decision</label> - </settings> - </column> - </columns> -</listing> diff --git a/app/code/Magento/Signifyd/view/adminhtml/web/images/logo.png b/app/code/Magento/Signifyd/view/adminhtml/web/images/logo.png deleted file mode 100644 index 7c6645e7c6c93e6ee1a2a5d14ad1b7e95c07ff2b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5218 zcmaJ_c|25Y`xk|geG7>(b~0udV`l7(HCu?3Vwkbc7-q)4WX+(mRzk8bk*%^k$QoI) z6bd1`l!QE_=r?-nd7nRipZ9#uxzBy>^Zj1e_qy)uI)9vaOLIdu79kcoIyyFEBeWIm z{(^R$VP>R_8|C8kw3{GB|02bj=t>E|kZ^Q5SfVoyXiUJk;jC~NY>;m+PMwa9VZ+1b zBITl)DawUN0Ar3Y;6Q>8jZH_Vt`+Emaq+@YfX+BK4{r_7MpG*Y=z-M$*{PU8%zX54 z?jA<LB%F1yxs6M(mkSaL($WN~2cl>O2sjD`7)Zc-lTm>hpkH=TwE5ApA_({kLh;f7 z{YTVAGfSWzk%R-PfRz<oAW$d}4hKVFDsVXTEKmsoRZ@h|PPhUThEjo}lvIJg4-m~8 z3G0foLL2<{MSIc!xl<@UC`HA9fB<lSGMGqmQ-mUs$Ris{N(wZD0y)T=f(cacCX4^E zfX0zsNFF{E5282l$Rfs>=tt22(Ukrt1cHy5**}K8$-fgtOPOLI#zzqfhA0vUM{)f^ zlPOlX|H}A((PWz-ADp5Uj!g6;xzP5*Rs0W`mb?G$=noL<@(<3(kA(jfC)Py~hsP0c z-V`!T6!e!OnsSr{$%D3m7(ANj;&=4c7_9;F^Yg%>RM1Kg1X2lxRMs^>>q4POC`<>T zf`p)zp(+rB9^%N^k%4~`X)9nXjSEBT=oui8$_8kNJ`}1CN5FNVNIfJJse({eRY5}k zaE-mm6pXhE?#Ss8*W<rjrT@uA>5*_43Xx<(B;x;+iZLGVN2ZXDmVtWKaG;DC#>K;% zLL|G(9_{6CwK$T8KMrd^A`*bVHUs7HFAcu}$3m2$F0NQ*1%xX`Ndbd{K@|`<XPAPs zimJ0R%mt3Yz>uKdWbD7P_9u7<6hW&~RTxB72?9qzp$H`<9RpPr2ogaXAUdibMVcC{ z3yR`F!Q+0HsScj<dxrNoDistS<LySvi2@eqit)o!K$>I^H*XKuAgsFLQ4!)jXz*XN z|1cH*W$)MWzpC~RlGX}G(|>x9_V7;^<Gg9DOQQ8?sNX|bIyz2(F<QqaaPpG_Ae48B z?^;M~b`}r)qBi(>RD$qLU>wkB1n91R3&eYZ>p4UF<b$`JERXo)dDW8(WbA6>K)?hR zP*-U#Gd)PiSeJHu#>2DB{OdQ?pGi7OJ?<Is=JpC|ofUPhRi1U&*lXQw5j6Yu@%@D- zLUaXO?;Bg9=W5oi#cIO1&;k`s0q(BzLus6BsaJeBsCpFLRZbjL_ul#wW@Tr_{O%T) zyk2IzIxUXxpM$tSY;cHu)_p7Hd3LlG`V^Y!c#c>G=X2^~sx>u<ODnJy)gU->?{1P9 zd-PA;9+BwPXd@j7U<c<I6@-S*%XhJNJuj!Wt8MSEv^Z^zPYg>Q(qB=Yj_alR#4v1% zis;>BMLTr%uW)V{hi@bbwDn6;*HdS!v{{$7E#;f`_9HiX!l-h)3;NCFq<4VOqz~^v zoQeR{7@u!}=*pux!dWVP_>2@$Z8hxvZMHb&InI+kuDbdJfwSLy=nE+_$6LDL1IIF< zSN#uI&nFleI;`WGCcGI&JlCDd;2nE;A;97mw!XwGb`mdmsEt&t7ICeFI!%2^b+|Wc z2mEV$D_DyyCjHAUb@LNlsPQrRc`_EpZ*#C|_u#r%TzJI5yU#xM_;~jFFI_PqB!NyF zxsevCeRJrgZtY?*{x77m8<Fp#_Lz=K6`WuYJCP$NAXyC-wnHrYQR`!O#HpuZc20A8 z*<{NjH;9~5oaJ18z=h{wnb}W8az(=0=Ho*!pOZO&RcDXEE|t{Z;XyfZJ42j>IX3M$ zrc!q%r{yJ8Qhb6)-~qG#;~~~fQu;qQYtWIt$qqx`n>Xfm$sMG4(S?*PVcmD1OMK}J zOTTkzfowA$C3AaH+J3Zu*Dk4v9xEm@vz++UzEW;8Xcdn!DRQ_tnD(uOh5l4xwZjm* zRl0&)_d6MTQQ5VdRWk4O=ifHie%Us*!vn!Xx1g=#ejlzic}N#_-O&yrWL$Bz&gbsL zi41}qXY8X>s%lX}-HzYbC`J$C)-t6=qSfbQ?oF?XiRxpO?)Pp&Le)5~ovLb|>$FJ5 zsISfKI{fW<FH|#Dq&p)nea9YjCroWgPuc}Jsv=OhqO+x*U!TDA`HK(1Gu%!dlez<n zZ|9M`pYNnj0&B$VAgO))2qI}sjq79)Z=#I3p|ka~8-=yPtRrXMrwJZBd)vBKK%siO zrFhpdou9)n2e1D88x|g|cTx;7^QF>$unqsl0hXL6T=zU{6ZSf~KuNXaR7l3uy}OK^ z$|6`#NfX9-zgzec$yUJ(sp)|y(pD&^B1u-EPpDycb<N8pma<`g-Jwmv6MZF^Q2FgC z5}bQ?r((1CBzI4p&BY-%xkWS239-vq`iSqB@-ME$@3W=gAE(Q{7paeIZi}z7sA=-< zEbe--cJO}K9Sfh>zy(xsbw%Yo3A2%;bgrWBO0hoE9+hX0H*8_uIkO<iey<$iI~M#U z^Vwohu_uV_-p6P;&Zlqt_tfTn#rF5IBCO|sDv6dW6s8YpTvSTiVDd>d3sxQK(e!Ev zoV(K-E*!_A)z7=Enkex#A)5%&@UqI>I5^Ym!R>F#SK)54l~eV$|1)%^yR!ZRP--;l ze3|W~jWyY`RofV065s8sc<gyO5zkWq4Ve`QYd{isd0}?&<D0!Lov3%xJ&Bi%S%)hO zxRXEeu*NJN6aBWhL~V-MAvjPrB~ftgYfI$8+s`Gm((h+pLsCs;b|mtyhL@*F_`Gx$ z9bpsf6AMmOypUZLUl1XbDY=vTLF6Ikkof}Uv(K^;`>;@oxex^|clR9I;u*kn*tzR( zepdAf_wGw6PMKWGdegDuUnLQDKW|(+)V@F(*^X05@;4-dFDWG#!$I9?$Bt!Zy+VVp z^GzyLk+?;u&A5QJ=ob}df^OGX+VTLz{$lhnH?qOs`J$TNx^ZaA8Y8Fgte?h$s_(@I zluN8!Ud;Q#g%7exeUijp7g-qiO(B~{{98k5O?2Z`4*smGo^?T~)uCbX8UyjePtw0* zA&hKejVAtzB0`K~cYK(~&aGJ7-&U$J0gW+tb!zd5i{Yxc#vPL<TwAIgm~%=1Q3^yd z`@)^mQ3Rlux`45aHB(Yg!Nj*8TL^^x=!A#KtzzTai(|QKBM&4-%Ow}@c5E5DqulaM zAi>&!XWI;Wtmf8v-soE4<I|lZ+xiWAZKA+Lef>HepS}_jslM8D8-0y;yo|&zT`}Z| zW8gn&rV&j5^4?i=jf{)<p>7~vudV4_b~AzjsgYf%YosqTq6wV%F+^2%c(gjLtNPF| zqR~Pb(D~#Ie!Ts$U_twMZd#(qVDO2b4^F&XxuWT=uMfa16_w8Ra!AO^#8|4mJk_yp z-LbX6jhkNY2~6Sk6sBIi1`?{uj0_FBeYnU&SQYG5tG#Brjg;~Bg4wnWZtQFKA{o&7 zFyyd+pk$HKJMru(;bn<RH%`97mg?*?yuq=X8}DL$_WpthI)lpFy?2AY-!+!gvbpfx zO<vH5`*rhUmM^7In<d8McXhY7KEbql`j&nqS2Jbq9>}I_caSJR##ear$a2f6t@3=a zR*=x3ZI^b6Yy$U&MYAbY#S<F?c=mGrSUE>YB)GVj>umOuM_;PtB{$^TFVr3~Z+-;I zP*-mc9@krVm^}UWCo8sq-Ts(_K7`xGJyBgrqZ-_{n2(uu-F3^6wzi+&qin_2i<o82 z_Z6^l(kP~D9_u~XS=`|#DtmRGf|d>EDCb95n5dq>p_O5DL*P@!3V2InJ{*tpx9@2C zls_mKZAEtaKEPHTw8g)g;&W_}R|>ayp=+>>FgpfUNjHLWNhJw!U12<(RD|IL_!@A< zTjrZ=b9%LJ7mB{jX^r0#a$t+~ME57m-RX03&pI>oHuB-&mt2Nn=(D#IA<I2zy+@`+ zZl?piA9$RLw`n+t25R|wo)@?oCF}fkBxUI}+LlSW-`7$F&?fNtE8s;6xQ?kw`<ih? zE$6_g+y*`KTiq#T$`>7>*T>gCyH|h(Gg6t-DpB;x`=ZA*3?sf?m3Eq*`{>kPb9nmM zfW-{w*kJGlXY3M{vFS57`~{n{yUDG}h>hCd_S7(Or-^ip+%iJ<hf=nPNf&<cZcwo} zW3PkEQ~%dDR$DoDOR1@KbRx|a!)UJyeB4u`s0?KYL(Zh~vH4D~?60rlKDm}a&dJy| z_l^`5b%Ev<4$)add?KBF*MaL@_upJM0NaAgiq}4oUrl{_Pi1*Nz<NPUUaP~w^A;>o zB{;Z&S3zzF-A4Va)uy~#ap`(|cdhrPWHRp+K-ucIv;u`e;8cW(Wp_Ii+`+ir6Uwq3 z7tV6}*4J1=e^W$w9q2Id?%P*<u#lNWb}xb@^($+K*|1^}r?8)9(2AS^2RL>x)#kxF zKAt|iSA0TL0nerrnc+Y%dD|)uP`gr$8zpFH(j}OsaGqH^C7$teq(;8#_0A7|2g$iR z$-2ez3JPA|Cf^O+%+!7JG%u3cTy%%EQ1~Xpe1U^sqQ07e3p*r3X7meZSj(*sjNcGU zQZv`LS5irJ16PCgH$N~L=y1(wtD!Nh!v%`N8RzpJRm#;~DfbI@GDB*FD6igF2fFRQ zD6nuGtD!Tf45!<YcM$`mZ84hL^db^W4N5EF9pi%Km{;%9EbSKq?n4uGa;U*x;nI1M zUvoNLhM#P{yi0wwFwM~Xp(SGrdFJL*{z~&3rCKuz{2$yrnp+v^vqQ4E$KTLC_p|f~ z`2_u<0bbTcr_-;y0-=OaN7yY0Y{9I)ee%GiEyHJS+(&O(ZIm!+IynJ<@GKd@meAT# zp5J9mY<|shSn`m4U{XDBe^NdXv(R-D;ytZrDQLxXe*Ns=1i8dFLmbopRR!Yl!WhEW zxXcFYYl@T^u%6{nsUz@<eC4jBvp*1)J}o3I$#gvMb(TY{LE>QH%vf&OYq_-tg;J(# zAGsYp^8>EzKZ&qvY9gO`l$-7>B0Sd32r@^Xa$f*VAmHW^PnisLOkUX=F{|2_8i;yV z!x>gT_II%EP^MUTw>I#en5yoUSFdZGdKHLmv8m|Nij%QXYwjh!_{_i9i&?eiV7G#^ z<Q6z_<%M$2?^oxmsKk~OdVh8at=*bRbk54do0o&hn*6H`T6`l<HaDN!$=5!yNz8og zp<eN_0g$SeLslI|{s??)qH%KRr)5&e<vzL`BQ55W1{)Et9tya(IV?Uk{y3-VF02x( z17)wb{9qSqUELZLHk)3dcnFXkK^Q-com6$7Sw7bw5h)ZW@KR}Kmngziu1t)PfZa-7 zo-Wc^DIHCAuWLBG=KbkAq-OU#mAOXy!6Hj(`-}5#<b!VR{0QzK?%+*n9V+OsPjI<Y zFDOiE1@YkExQGNF=c+hkQ%vhf|7FK3uQnsFjS@`LMOOl_kV1c%82`T*M-VWD<mM~F zX*1?9%vDc=F^iAkBKr~-v~L4$7UaeIHtYs*jNVmNYb-aUkFx_M8IK2)6<$(kUnuLe z!vjj>W;)KHDle@nj5!(!#9Wz@tz~IU(i1}JF155q%XQXV$WSeXq)9OW#cQ0Ol$Ppd zH~<>!8ttv}?oQgQzD9DCHn_{3T9X7cbAO}Htjo0KITMzy`{6j&|D=XZ<~dY|aXkaK zCwmxIW`LKP?9-e}+QM52&=W$^fcws5_piD2Ie&o;)uB#B_ED3^Q+ZQoPUqISXRZX^ zz76m1{2R;pRr6R2K;{|Ilu~x_`DPhGl0zuuaVcxVeVtgk;E~x+7{^SlysD-fgm$LT zw1gLX<U2aTOD$pPpw#-j${T99Qq>Rknh`4-&U~Al#8K2Ew%P<W@iTpqWe4WkVSeQo zPIJdBJsaS;``Bujf<+o;GTY8qintHA$R%00Snnh*LvM7<N<+Xt&#XG8u9NcL0Mtz( zDB&0G&?u|;H*?H;@K;RYhi$xbsSUy&t#p511H{Cev}lE_ZtC#c_C(m)ar6@>*n@2% zx0I^oD_|2gIn^Z_7j~TY#6KJho=_gJaE$I&ENUpyfUW=7kv!pkT9UD)JQ``_eSNjf zXi)EPwg|lxZo``I5qXzS@?CmB`kU*~jhe^(2QQvby_$9I!OuJ<FPjudIaelE$-T`^ zxxb6XSG?M`<;$n}vPJdfgG*v($~7zJ9jNmoh5~;Hfq(%UNo78TK)(47FIcKe&%<Vm zfZ#@Wy#z}?NzpN0QSRxobexs?+42-HOa0FrL1Wc2-#tE^HGD9w-5M5D8j$O(Hm9y; z&lSIWpYb3il65n^@1zvjp)WV)fYEl}rr2@xlCkySXw~`lZymms;oszXHD!l$S+$1T zRHEg)IuW%J$_Ff%Oq_G3NlM&|L7`&saEQG2XhMFsd|YMRmYg`n;%xPV@Z<^luqn}q zmBQ?Pjgg�XR{6;SJx?rQR~alI+~G`a8p+x4$P!Mh-6hh`l-cx#%KxIrM8`)xv>Y b#4);)59=<+A+s!w{`wi~o1-groud8^wIwiR diff --git a/app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js b/app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js deleted file mode 100644 index f55170336ca03..0000000000000 --- a/app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -define([ - 'mageUtils', - 'Magento_Ui/js/form/components/button' -], function (utils, Button) { - 'use strict'; - - return Button.extend({ - - /** - * Creates and submits form for Guarantee create/cancel - */ - sendRequest: function () { - utils.submit({ - url: this.requestURL, - data: this.data - }); - } - }); -}); diff --git a/app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml deleted file mode 100644 index 30472ae5e9ae9..0000000000000 --- a/app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - <body> - <referenceBlock name="head.components"> - <block class="Magento\Signifyd\Block\Fingerprint" name="signifyd.fingerprint" /> - </referenceBlock> - </body> -</page> diff --git a/app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml b/app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml deleted file mode 100644 index 30472ae5e9ae9..0000000000000 --- a/app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - <body> - <referenceBlock name="head.components"> - <block class="Magento\Signifyd\Block\Fingerprint" name="signifyd.fingerprint" /> - </referenceBlock> - </body> -</page> diff --git a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml deleted file mode 100644 index 657043b895f60..0000000000000 --- a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml +++ /dev/null @@ -1,16 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -/** @var $block Magento\Signifyd\Block\Fingerprint */ -?> -<?php if ($block->isModuleActive()) : ?> - <script - async - id="sig-api" - data-order-session-id="<?= $block->escapeHtml($block->getSignifydOrderSessionId()) ?>" - src="https://cdn-scripts.signifyd.com/api/script-tag.js"> - </script> -<?php endif; ?> diff --git a/app/design/adminhtml/Magento/backend/Magento_Signifyd/web/css/source/_module.less b/app/design/adminhtml/Magento/backend/Magento_Signifyd/web/css/source/_module.less deleted file mode 100644 index 3f0875da552a3..0000000000000 --- a/app/design/adminhtml/Magento/backend/Magento_Signifyd/web/css/source/_module.less +++ /dev/null @@ -1,7 +0,0 @@ -// /** -// * Copyright © Magento, Inc. All rights reserved. -// * See COPYING.txt for license details. -// */ - -@import 'module/_order.less'; -@import 'module/_config.less'; diff --git a/app/design/adminhtml/Magento/backend/Magento_Signifyd/web/css/source/module/_config.less b/app/design/adminhtml/Magento/backend/Magento_Signifyd/web/css/source/module/_config.less deleted file mode 100644 index b66c9c753aa83..0000000000000 --- a/app/design/adminhtml/Magento/backend/Magento_Signifyd/web/css/source/module/_config.less +++ /dev/null @@ -1,25 +0,0 @@ -// /** -// * Copyright © Magento, Inc. All rights reserved. -// * See COPYING.txt for license details. -// */ - -@image-signifyd-logo-path: '../Magento_Signifyd/images/logo.png'; - -// -// Outer slider of configuration -// -.signifyd-logo-header { - > .entry-edit-head { - > a:after { - content: url(@image-signifyd-logo-path); - } - } - - ul { - margin-left: 5em; - } - - .webhook-url { - word-break: break-all; - } -} diff --git a/app/design/adminhtml/Magento/backend/Magento_Signifyd/web/css/source/module/_order.less b/app/design/adminhtml/Magento/backend/Magento_Signifyd/web/css/source/module/_order.less deleted file mode 100644 index d0ae877b3f18c..0000000000000 --- a/app/design/adminhtml/Magento/backend/Magento_Signifyd/web/css/source/module/_order.less +++ /dev/null @@ -1,23 +0,0 @@ -// /** -// * Copyright © Magento, Inc. All rights reserved. -// * See COPYING.txt for license details. -// */ - -// -// Order Case Info -// --------------------------------------------- - -.order-case-table { - &:extend(.abs-order-tables all); - &:extend(.abs-order-tbody-border all); -} - -// -// Layout -// --------------------------------------------- -.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) { - .case-information { - float: left; - #mix-grid .width(6,12); - } -} diff --git a/composer.json b/composer.json index 50e8db204f051..708ef7e4c15cb 100644 --- a/composer.json +++ b/composer.json @@ -241,7 +241,6 @@ "magento/module-send-friend": "*", "magento/module-send-friend-graph-ql": "*", "magento/module-shipping": "*", - "magento/module-signifyd": "*", "magento/module-sitemap": "*", "magento/module-store": "*", "magento/module-store-graph-ql": "*", diff --git a/composer.lock b/composer.lock index f6894e3c31d09..3b92c901aac8e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "dc4c877a835fbea7420d8477ade2fe4f", + "content-hash": "9e13134f3e209140ec6c43092c189da9", "packages": [ { "name": "braintree/braintree_php", @@ -9962,12 +9962,12 @@ }, "require-dev": { "predis/predis": "~1.0", - "symfony/expression-language": "^3.4|^4.0|^5.0" + "symfony/expression-language": "^4.4|^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -9994,7 +9994,7 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2020-02-13T19:40:01+00:00" + "time": "2020-01-04T13:00:46+00:00" }, { "name": "symfony/mime", diff --git a/dev/tests/functional/credentials.xml.dist b/dev/tests/functional/credentials.xml.dist index 01e3a35be9a2d..89ea0f23ef30e 100644 --- a/dev/tests/functional/credentials.xml.dist +++ b/dev/tests/functional/credentials.xml.dist @@ -79,6 +79,4 @@ <field path="payment/paypal_alternative_payment_methods/express_checkout_us/express_checkout_required/express_checkout_required_express_checkout/api_username" value="" /> <field path="payment/paypal_alternative_payment_methods/express_checkout_us/express_checkout_required/express_checkout_required_express_checkout/api_password" value="" /> <field path="payment/paypal_alternative_payment_methods/express_checkout_us/express_checkout_required/express_checkout_required_express_checkout/api_signature" value="" /> - - <field path="fraud_protection/signifyd/api_key" value="" /> </replace> diff --git a/dev/tests/functional/etc/repository_replacer_payments.xml b/dev/tests/functional/etc/repository_replacer_payments.xml index a0ecca61eb372..2b20e7220f537 100644 --- a/dev/tests/functional/etc/repository_replacer_payments.xml +++ b/dev/tests/functional/etc/repository_replacer_payments.xml @@ -21,11 +21,4 @@ <field name="password" xsi:type="string">AUTHORIZENET_PASSWORD</field> </dataset> </repository> - - <repository class="Magento\Signifyd\Test\Repository\SignifydAccount"> - <dataset name="sandbox_default"> - <field name="email" xsi:type="string">SIGNIFYD_EMAIL</field> - <field name="password" xsi:type="string">SIGNIFYD_PASSWORD</field> - </dataset> - </repository> </config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/Grid.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/Grid.php deleted file mode 100644 index 54f580f48dcf4..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/Grid.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Block\Adminhtml\Order; - -use Magento\Ui\Test\Block\Adminhtml\DataGrid; - -/** - * Admin Data Grid for managing "Sales Order" entities. - */ -class Grid extends DataGrid -{ - /** - * Filters array mapping. - * - * @var array - */ - protected $filters = [ - 'id' => [ - 'selector' => '[name="increment_id"]', - ], - 'status' => [ - 'selector' => '[name="status"]', - 'input' => 'select', - ], - 'signifyd_guarantee_status' => [ - 'selector' => '[name="signifyd_guarantee_status"]', - 'input' => 'select' - ] - ]; -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/View/FraudProtection.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/View/FraudProtection.php deleted file mode 100644 index e2b4e6f748977..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/View/FraudProtection.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Block\Adminhtml\Order\View; - -use Magento\Mtf\Block\Block; - -/** - * Information about fraud protection on order page. - */ -class FraudProtection extends Block -{ - /** - * Case Guarantee Disposition. - * - * @var string - */ - private $caseGuaranteeDisposition = 'td.col-guarantee-disposition'; - - /** - * Get Case Guarantee Disposition status. - * - * @return string - */ - public function getCaseGuaranteeDisposition() - { - return $this->_rootElement->find($this->caseGuaranteeDisposition)->getText(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseInfo.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseInfo.php deleted file mode 100644 index 1529755fdc3c9..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseInfo.php +++ /dev/null @@ -1,245 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Block\SignifydConsole; - -use Magento\Mtf\Block\Block; - -/** - * Case information block. - */ -class CaseInfo extends Block -{ - /** - * Css selector of "Flag Case As Good" button. - * - * @var string - */ - private $flagCaseAsGoodButton = '[class*="flag-case-good"]'; - - /** - * Css selector of "Flag Case As Bad" button. - * - * @var string - */ - private $flagCaseAsBadButton = '[class*="flag-case-bad"]'; - - /** - * Css selector of guarantee status. - * - * @var string - */ - private $guaranteeDisposition = '[class*="guarantee-status"]'; - - /** - * Css selector of CVV response description. - * - * @var string - */ - private $cvvResponseDescription = '[ng-bind="caseOrderSummary.cvvResponseDescription"]'; - - /** - * Css selector of CVV response code. - * - * @var string - */ - private $cvvResponseCode = '[ng-bind="caseOrderSummary.cvvResponseCode"]'; - - /** - * Css selector of AVS response description. - * - * @var string - */ - private $avsResponseDescription = '[ng-bind="caseOrderSummary.avsResponseDescription"]'; - - /** - * Css selector of AVS response code. - * - * @var string - */ - private $avsResponseCode = '[ng-bind="caseOrderSummary.avsResponseCode"]'; - - /** - * Css selector of displayed case order id. - * - * @var string - */ - private $orderId = '[ng-bind="currentCase.caseIdDisplay"]'; - - /** - * Css selector of displayed order amount. - * - * @var string - */ - private $orderAmount = '[ng-bind*="currentCase.orderTotalAmount"]'; - - /** - * Locator value for order amount currency. - * - * @var string - */ - private $orderAmountCurrency = '[ng-bind*="currentCase.currency"]'; - - /** - * Css selector of displayed card holder name. - * - * @var string - */ - private $cardHolder = '[data-dropdown="peopleLinks0_card_holders"]'; - - /** - * Css selector of displayed billing address. - * - * @var string - */ - private $billingAddress = '[data-dropdown="streetLinks0"]'; - - /** - * Locator value for "No analysis available" block in "Device" container. - * - * @var string - */ - private $noDeviceAnalysisAvailable = '[ng-hide^="caseAnalysis.deviceAnalysis.details.length"]'; - - /** - * Locator value for "Shipping Price" block. - * - * @var string - */ - private $shippingPrice = '[ng-if="shipment.shippingPrice"]'; - - /** - * Check if device data are present. - * - * @return bool - */ - public function isAvailableDeviceData() - { - return !$this->_rootElement->find($this->noDeviceAnalysisAvailable)->isVisible(); - } - - /** - * Returns shipping price. - * - * @return string - */ - public function getShippingPrice() - { - return $this->_rootElement->find($this->shippingPrice)->getText(); - } - - /** - * Flags case as good or bad. - * - * @param string $flagType - * @return void - */ - public function flagCase($flagType) - { - $flagSelector = ($flagType === 'Good') - ? $this->flagCaseAsGoodButton - : $this->flagCaseAsBadButton; - - $this->_rootElement->find($flagSelector)->click(); - } - - /** - * Flags case as bad. - * - * @return void - */ - public function flagCaseAsBad() - { - $this->_rootElement->find($this->flagCaseAsBadButton)->click(); - } - - /** - * Gets guarantee disposition. - * - * @return string - */ - public function getGuaranteeDisposition() - { - return $this->_rootElement->find($this->guaranteeDisposition)->getText(); - } - - /** - * Gets CVV response. - * - * @return string - */ - public function getCvvResponse() - { - return sprintf( - '%s (%s)', - $this->_rootElement->find($this->cvvResponseDescription)->getText(), - $this->_rootElement->find($this->cvvResponseCode)->getText() - ); - } - - /** - * Gets AVS response. - * - * @return string - */ - public function getAvsResponse() - { - return sprintf( - '%s (%s)', - $this->_rootElement->find($this->avsResponseDescription)->getText(), - $this->_rootElement->find($this->avsResponseCode)->getText() - ); - } - - /** - * Gets displayed order id. - * - * @return string - */ - public function getOrderId() - { - return $this->_rootElement->find($this->orderId)->getText(); - } - - /** - * Gets displayed order amount. - * - * @return string - */ - public function getOrderAmount() - { - return $this->_rootElement->find($this->orderAmount)->getText(); - } - - /** - * Returns displayed order amount currency. - * - * @return string - */ - public function getOrderAmountCurrency() - { - return $this->_rootElement->find($this->orderAmountCurrency)->getText(); - } - - /** - * Gets displayed card holder name. - * - * @return string - */ - public function getCardHolder() - { - return $this->_rootElement->find($this->cardHolder)->getText(); - } - - /** - * Gets displayed billing address. - * - * @return string - */ - public function getBillingAddress() - { - return $this->_rootElement->find($this->billingAddress)->getText(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseSearch.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseSearch.php deleted file mode 100644 index 16621f9a0cd48..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseSearch.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Block\SignifydConsole; - -use Magento\Mtf\Block\Form; - -/** - * Side block with case search and cases list. - */ -class CaseSearch extends Form -{ - /** - * Css selector of search input. - * - * @var string - */ - private $searchBar = '[id=queueSearchBar]'; - - /** - * Css selector of search submit button. - * - * @var string - */ - private $submitButton = '[type=submit]'; - - /** - * Css selector of searched element in cases list. - * - * @var string - */ - private $selectCaseLink = 'ul[case-list=cases] li[case-list-case=case] a'; - - /** - * Locator for resolving applied filters list. - * - * @var string - */ - private $appliedFilters = '.app-taglist > ul > li > a'; - - /** - * Locator for loading spinner. - * - * @var string - */ - private $spinner = '.cases-loading-spinner'; - - /** - * Fill search input with customer name and submit. - * - * @param string $customerName - * @return void - */ - public function searchCaseByCustomerName($customerName) - { - $this->resetFilters(); - $this->_rootElement->find($this->searchBar)->setValue($customerName); - $this->_rootElement->find($this->submitButton)->click(); - $this->waitLoadingSpinner(); - } - - /** - * Reset applied filters. - * - * @return void - */ - private function resetFilters(): void - { - $filters = $this->_rootElement->getElements($this->appliedFilters); - if (!empty($filters)) { - foreach ($filters as $filter) { - $filter->click(); - $this->waitLoadingSpinner(); - } - } - } - - /** - * Wait until loading spinner disappeared. - * - * @return void - */ - private function waitLoadingSpinner(): void - { - $this->waitForElementNotVisible($this->spinner); - } - - /** - * Checks if any case is visible. - * - * @return bool - */ - public function isAnyCaseVisible(): bool - { - return $this->_rootElement->find($this->selectCaseLink)->isVisible(); - } - - /** - * Select searched case. - * - * @return void - */ - public function selectCase() - { - $this->_rootElement->find($this->selectCaseLink)->click(); - } - - /** - * Waiting of case page loading. - * - * @return void - */ - public function waitForLoading() - { - $this->waitForElementVisible($this->searchBar); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/SignifydLogin.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/SignifydLogin.php deleted file mode 100644 index 7705a67360e55..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/SignifydLogin.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Block\SignifydConsole; - -use Magento\Mtf\Block\Form; -use Magento\Mtf\Client\Element\SimpleElement; -use Magento\Mtf\Fixture\FixtureInterface; - -/** - * Signifyd login block. - */ -class SignifydLogin extends Form -{ - /** - * Css selector of Signifyd login button. - * - * @var string - */ - private $loginButton = '[type=submit]'; - - /** - * Locator for admin form notification window. - * - * @var string - */ - private $notificationCloseButton = '.wm-close-button'; - - /** - * @inheritdoc - */ - public function fill(FixtureInterface $fixture, SimpleElement $element = null) - { - $this->closeNotification(); - - return parent::fill($fixture, $element); - } - - /** - * Login to Signifyd. - * - * @return void - */ - public function login() - { - $this->closeNotification(); - $this->_rootElement->find($this->loginButton)->click(); - } - - /** - * Close notification popup. - * - * @return void - */ - private function closeNotification(): void - { - $notification = $this->browser->find($this->notificationCloseButton); - if ($notification->isVisible()) { - $notification->click(); - } - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/Webhooks.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/Webhooks.php deleted file mode 100644 index 424d5681c07c6..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/Webhooks.php +++ /dev/null @@ -1,216 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Block\SignifydConsole; - -use Magento\Mtf\Block\Block; -use Magento\Mtf\Client\ElementInterface; -use Magento\Mtf\Client\Locator; - -/** - * Signifyd webhook addition block. - */ -class Webhooks extends Block -{ - /** - * Map of webhook event select option values on names of events in webhook grid. - * - * @var array - */ - private $webhookEventOptionsMap = [ - 'CASE_CREATION' => 'Case Creation', - 'CASE_REVIEW' => 'Case Review', - 'GUARANTEE_COMPLETION' => 'Guarantee Completion' - ]; - - /** - * XPath selector of webhook element added into grid. - * - * @var string - */ - private $webhookAddedElement = '//table[@id="webhooks"]//tr[./td/span/text()="%s" and ./td/span/text()="%s"]'; - - /** - * Css selector of webhook url input. - * - * @var string - */ - private $webhookUrl = '[id="webhookUrl"]'; - - /** - * XPath selector of test team select option. - * - * @var string - */ - private $webhookTeamOption = './/select[@id="webhookTeams"]//option[text()="%s"]'; - - /** - * Css selector of webhook event select option. - * - * @var string - */ - private $webhookEventOption = 'select[id="webhookEvent"] option[value="%s"]'; - - /** - * Css selector of webhook addition button. - * - * @var string - */ - private $webhookAddButton = '[id="addWebhook"] [type=submit]'; - - /** - * Css selector of delete button in element of webhook grid. - * - * @var string - */ - private $webhookDeleteButton = '[class*="webhook-delete"]'; - - /** - * Css selector of confirming button for deleting webhook. - * - * @var string - */ - private $webhookDeleteConfirmButton = '[class="appriseOuter"] button[value="ok"]'; - - /** - * Creates new set of webhooks, if it not exists. - * - * @param string $team - * @return void - */ - public function create($team) - { - $handlerUrl = $this->getHandlerUrl(); - - foreach ($this->webhookEventOptionsMap as $webhookEventCode => $webhookEventName) { - if ($this->getWebhook($team, $webhookEventName)) { - continue; - } - - $this->addWebhook($handlerUrl, $webhookEventCode, $team); - } - } - - /** - * Deletes set of webhooks. - * - * @param string $team - * @return void - */ - public function cleanup($team) - { - foreach ($this->webhookEventOptionsMap as $webhookEventName) { - if ($webhook = $this->getWebhook($team, $webhookEventName)) { - $this->deleteWebhook($webhook); - } - } - } - - /** - * Gets webhook if exists. - * - * @param string $team - * @param string $webhookEventName - * @return ElementInterface|null - */ - private function getWebhook($team, $webhookEventName) - { - $webhook = $this->_rootElement->find( - sprintf($this->webhookAddedElement, $team, $webhookEventName), - Locator::SELECTOR_XPATH - ); - - return $webhook->isPresent() ? $webhook : null; - } - - /** - * Delete webhook element with confirmation popup. - * - * @param ElementInterface $webhook - * @return void - */ - private function deleteWebhook(ElementInterface $webhook) - { - $webhook->find($this->webhookDeleteButton)->click(); - $this->_rootElement->find($this->webhookDeleteConfirmButton)->click(); - } - - /** - * Sets webhook data and add it. - * - * @param string $handlerUrl - * @param string $webhookEventCode - * @param string $team - * @return void - */ - private function addWebhook( - $handlerUrl, - $webhookEventCode, - $team - ) { - $this->setEvent($webhookEventCode); - $this->setTeam($team); - $this->setUrl($handlerUrl); - $this->submit(); - } - - /** - * Sets appropriate webhook event select option by code. - * - * @param string $webhookEventCode - * @return void - */ - private function setEvent($webhookEventCode) - { - $this->_rootElement->find( - sprintf($this->webhookEventOption, $webhookEventCode) - )->click(); - } - - /** - * Sets test team select option. - * - * @param string $team - * @return void - */ - private function setTeam($team) - { - $this->_rootElement->find( - sprintf($this->webhookTeamOption, $team), - Locator::SELECTOR_XPATH - )->click(); - } - - /** - * Sets webhook handler url input value. - * - * @param string $handlerUrl - * @return void - */ - private function setUrl($handlerUrl) - { - $this->_rootElement->find($this->webhookUrl)->setValue($handlerUrl); - } - - /** - * Add webhook element. - * - * @return void - */ - private function submit() - { - $this->_rootElement->find($this->webhookAddButton)->click(); - } - - /** - * Gets webhook handler url. - * - * @return string - */ - private function getHandlerUrl() - { - return $_ENV['app_frontend_url'] . 'signifyd/webhooks/handler'; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php deleted file mode 100644 index f85e77a5c421b..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Constraint; - -use Magento\Mtf\Constraint\AbstractConstraint; -use Magento\Sales\Test\Page\Adminhtml\OrderIndex; -use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; - -/** - * Assert that comment about awaiting the Signifyd guarantee disposition - * exists in Comments History section on order page in Admin. - */ -class AssertAwaitingSignifydGuaranteeInCommentsHistory extends AbstractConstraint -{ - /** - * Expected history comment. - */ - private $historyComment = 'Awaiting the Signifyd guarantee disposition.'; - - /** - * Expected history status. - */ - private $historyCommentStatus = 'On Hold'; - - /** - * @param SalesOrderView $salesOrderView - * @param OrderIndex $salesOrder - * @param string $orderId - * @return void - */ - public function processAssert( - SalesOrderView $salesOrderView, - OrderIndex $salesOrder, - $orderId - ) { - $salesOrder->open(); - $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - - /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ - $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); - $orderComments = $infoTab->getCommentsHistoryBlock()->getComments(); - - $key = array_search( - $this->historyComment, - array_column($orderComments, 'comment') - ); - - \PHPUnit\Framework\Assert::assertNotFalse( - $key, - 'There is no message about awaiting the Signifyd guarantee disposition' . - ' in Comments History section for the order #' . $orderId - ); - - \PHPUnit\Framework\Assert::assertEquals( - $this->historyCommentStatus, - $orderComments[$key]['status'], - 'Message about awaiting the Signifyd guarantee disposition' . - ' doesn\'t have status "'. $this->historyCommentStatus.'"' . - ' in Comments History section for the order #' . $orderId - ); - } - - /** - * @inheritdoc - */ - public function toString() - { - return "Message about awaiting the Signifyd guarantee disposition is available in Comments History section."; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnAdmin.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnAdmin.php deleted file mode 100644 index 298b957131395..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnAdmin.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Constraint; - -use Magento\Sales\Test\Page\Adminhtml\OrderIndex; -use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; -use Magento\Mtf\Constraint\AbstractConstraint; -use Magento\Signifyd\Test\Fixture\SignifydData; - -/** - * Assert that Order Case Entity is correct on order page in Admin. - */ -class AssertCaseInfoOnAdmin extends AbstractConstraint -{ - /** - * Customized order view page. - * - * @var SalesOrderView - */ - private $orderView; - - /** - * Signifyd data fixture. - * - * @var SignifydData - */ - private $signifydData; - - /** - * Order id. - * - * @var string - */ - private $orderId; - - /** - * Assert that Signifyd Case information is correct in Admin. - * - * @param SalesOrderView $orderView - * @param OrderIndex $salesOrder - * @param SignifydData $signifydData - * @param string $orderId - * @return void - */ - public function processAssert( - SalesOrderView $orderView, - OrderIndex $salesOrder, - SignifydData $signifydData, - $orderId - ) { - $salesOrder->open(); - $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - - $this->orderView = $orderView; - $this->signifydData = $signifydData; - $this->orderId = $orderId; - - $this->checkCaseGuaranteeDisposition(); - } - - /** - * Checks case guarantee disposition is correct. - * - * @return void - */ - private function checkCaseGuaranteeDisposition() - { - \PHPUnit\Framework\Assert::assertEquals( - $this->signifydData->getGuaranteeDisposition(), - $this->orderView->getFraudProtectionBlock()->getCaseGuaranteeDisposition(), - 'Case Guarantee Disposition status is wrong for order #' . $this->orderId - ); - } - - /** - * @inheritdoc - */ - public function toString() - { - return 'Signifyd Case information is correct in Admin.'; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnSignifydConsole.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnSignifydConsole.php deleted file mode 100644 index a8a1f735d004c..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnSignifydConsole.php +++ /dev/null @@ -1,214 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Constraint; - -use Magento\Mtf\Constraint\AbstractConstraint; -use Magento\Signifyd\Test\Fixture\SignifydAddress; -use Magento\Signifyd\Test\Fixture\SignifydData; -use Magento\Signifyd\Test\Page\SignifydConsole\SignifydCases; - -/** - * Assert that order information is correct on Signifyd case info page. - */ -class AssertCaseInfoOnSignifydConsole extends AbstractConstraint -{ - /** - * Signifyd cases page. - * - * @var SignifydCases - */ - private $signifydCases; - - /** - * @param SignifydCases $signifydCases - * @param SignifydAddress $billingAddress - * @param SignifydData $signifydData - * @param array $prices - * @param string $orderId - * @param string $customerFullName - * @return void - */ - public function processAssert( - SignifydCases $signifydCases, - SignifydAddress $billingAddress, - SignifydData $signifydData, - array $prices, - $orderId, - $customerFullName - ) { - $this->signifydCases = $signifydCases; - - $this->checkDeviceData(); - $this->checkShippingPrice($signifydData->getShippingPrice()); - $this->checkGuaranteeDisposition($signifydData->getGuaranteeDisposition()); - $cvvResponse = $signifydData->getCvvResponse(); - if (isset($cvvResponse)) { - $this->checkCvvResponse($cvvResponse); - } - $this->checkAvsResponse($signifydData->getAvsResponse()); - $this->checkOrderId($orderId); - $this->checkOrderAmount($prices['grandTotal']); - $this->checkOrderAmountCurrency($prices['grandTotalCurrency']); - $this->checkCardHolder($customerFullName); - $this->checkBillingAddress($billingAddress); - } - - /** - * Checks device data are present. - * - * @return void - */ - private function checkDeviceData() - { - \PHPUnit\Framework\Assert::assertTrue( - $this->signifydCases->getCaseInfoBlock()->isAvailableDeviceData(), - 'Device data are not available on case page in Signifyd console.' - ); - } - - /** - * Checks shipping price is correct. - * - * @param string $shippingPrice - * @return void - */ - private function checkShippingPrice($shippingPrice) - { - \PHPUnit\Framework\Assert::assertContains( - $shippingPrice, - $this->signifydCases->getCaseInfoBlock()->getShippingPrice(), - 'Shipping price is incorrect on case page in Signifyd console.' - ); - } - - /** - * Checks guarantee disposition is correct. - * - * @param string $guaranteeDisposition - * @return void - */ - private function checkGuaranteeDisposition($guaranteeDisposition) - { - \PHPUnit\Framework\Assert::assertEquals( - $guaranteeDisposition, - $this->signifydCases->getCaseInfoBlock()->getGuaranteeDisposition(), - 'Guarantee disposition is incorrect on case page in Signifyd console.' - ); - } - - /** - * Checks CVV response is correct. - * - * @param string $cvvResponse - * @return void - */ - private function checkCvvResponse($cvvResponse) - { - \PHPUnit\Framework\Assert::assertEquals( - $cvvResponse, - $this->signifydCases->getCaseInfoBlock()->getCvvResponse(), - 'CVV response is incorrect on case page in Signifyd console.' - ); - } - - /** - * Checks AVS response is correct. - * - * @param string $avsResponse - * @return void - */ - private function checkAvsResponse($avsResponse) - { - \PHPUnit\Framework\Assert::assertEquals( - $avsResponse, - $this->signifydCases->getCaseInfoBlock()->getAvsResponse(), - 'AVS response is incorrect on case page in Signifyd console.' - ); - } - - /** - * Checks order id is correct. - * - * @param string $orderId - * @return void - */ - private function checkOrderId($orderId) - { - \PHPUnit\Framework\Assert::assertEquals( - $orderId, - $this->signifydCases->getCaseInfoBlock()->getOrderId(), - 'Order id is incorrect on case page in Signifyd console.' - ); - } - - /** - * Checks order amount is correct. - * - * @param string $amount - * @return void - */ - private function checkOrderAmount($amount) - { - \PHPUnit\Framework\Assert::assertEquals( - number_format($amount, 2), - $this->signifydCases->getCaseInfoBlock()->getOrderAmount(), - 'Order amount is incorrect on case page in Signifyd console.' - ); - } - - /** - * Checks order amount currency is correct. - * - * @param string $currency - * @return void - */ - private function checkOrderAmountCurrency($currency) - { - \PHPUnit\Framework\Assert::assertEquals( - $currency, - $this->signifydCases->getCaseInfoBlock()->getOrderAmountCurrency(), - 'Order amount currency is incorrect on case page in Signifyd console.' - ); - } - - /** - * Checks card holder is correct. - * - * @param string $customerFullName - * @return void - */ - private function checkCardHolder($customerFullName) - { - \PHPUnit\Framework\Assert::assertEquals( - $customerFullName, - $this->signifydCases->getCaseInfoBlock()->getCardHolder(), - 'Card holder name is incorrect on case page in Signifyd console.' - ); - } - - /** - * Checks billing address is correct. - * - * @param SignifydAddress $billingAddress - * @return void - */ - private function checkBillingAddress(SignifydAddress $billingAddress) - { - \PHPUnit\Framework\Assert::assertContains( - $billingAddress->getStreet(), - $this->signifydCases->getCaseInfoBlock()->getBillingAddress(), - 'Billing address is incorrect on case page in Signifyd console.' - ); - } - - /** - * @inheritdoc - */ - public function toString() - { - return 'Case information is correct on case page in Signifyd console.'; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInCommentsHistory.php deleted file mode 100644 index ea919f9410d4d..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInCommentsHistory.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Constraint; - -use Magento\Sales\Test\Page\Adminhtml\OrderIndex; -use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; -use Magento\Mtf\Constraint\AbstractConstraint; - -/** - * Assert that comment about created Signifyd Case - * exists in Comments History section on order page in Admin. - */ -class AssertSignifydCaseInCommentsHistory extends AbstractConstraint -{ - /** - * Pattern of message about created Signifyd Case in order. - */ - const CASE_CREATED_PATTERN = '/Signifyd Case (\d)+ has been created for order\./'; - - /** - * @param SalesOrderView $salesOrderView - * @param OrderIndex $salesOrder - * @param string $orderId - * @return void - */ - public function processAssert( - SalesOrderView $salesOrderView, - OrderIndex $salesOrder, - $orderId - ) { - $salesOrder->open(); - $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - - /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ - $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); - $orderComments = $infoTab->getCommentsHistoryBlock()->getComments(); - $commentsMessages = array_column($orderComments, 'comment'); - - \PHPUnit\Framework\Assert::assertRegExp( - self::CASE_CREATED_PATTERN, - implode('. ', $commentsMessages), - 'Signifyd case is not created for the order #' . $orderId - ); - } - - /** - * @inheritdoc - */ - public function toString() - { - return "Message about Signifyd Case is available in Comments History section."; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInOrdersGrid.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInOrdersGrid.php deleted file mode 100644 index bdf3598d4f46a..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInOrdersGrid.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Constraint; - -use Magento\Signifyd\Test\Fixture\SignifydData; -use Magento\Signifyd\Test\Page\Adminhtml\OrdersGrid; -use Magento\Mtf\Constraint\AbstractConstraint; - -/** - * Assert that Signifyd Guarantee Status is present in Orders grid. - */ -class AssertSignifydCaseInOrdersGrid extends AbstractConstraint -{ - /** - * @param string $orderId - * @param OrdersGrid $ordersGrid - * @param SignifydData $signifydData - * @return void - */ - public function processAssert( - $orderId, - OrdersGrid $ordersGrid, - SignifydData $signifydData - ) { - $filter = [ - 'id' => $orderId, - 'signifyd_guarantee_status' => $signifydData->getGuaranteeDisposition() - ]; - - $errorMessage = implode(', ', $filter); - - $ordersGrid->open(); - - \PHPUnit\Framework\Assert::assertTrue( - $ordersGrid->getSignifydOrdersGrid()->isRowVisible(array_filter($filter)), - 'Order with following data \'' . $errorMessage . '\' is absent in orders grid.' - ); - } - - /** - * @inheritdoc - */ - public function toString() - { - return 'Signifyd guarantee status is displayed in sales orders grid.'; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php deleted file mode 100644 index 618d77885736c..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Constraint; - -use Magento\Mtf\Constraint\AbstractConstraint; -use Magento\Sales\Test\Page\Adminhtml\OrderIndex; -use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; - -/** - * Assert that comment about created Signifyd Case guarantee - * has been cancelled exists in Comments History section on order page in Admin. - */ -class AssertSignifydGuaranteeCancelInCommentsHistory extends AbstractConstraint -{ - /** - * Signifyd case guarantee cancel message in order view. - */ - private $guaranteeCancelMessage = 'Case Update: Case guarantee has been cancelled.'; - - /** - * @param SalesOrderView $salesOrderView - * @param OrderIndex $salesOrder - * @param string $orderId - * @return void - */ - public function processAssert( - SalesOrderView $salesOrderView, - OrderIndex $salesOrder, - $orderId - ) { - $salesOrder->open(); - $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - - /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ - $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); - $orderComments = $infoTab->getCommentsHistoryBlock()->getComments(); - $commentsMessages = array_column($orderComments, 'comment'); - - \PHPUnit\Framework\Assert::assertContains( - $this->guaranteeCancelMessage, - implode('. ', $commentsMessages), - 'There is no message regarding Signifyd guarantee cancel in Comments History section for the order #' - . $orderId - ); - } - - /** - * @inheritdoc - */ - public function toString() - { - return "Message about Signifyd guarantee cancel is available in Comments History section."; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAccount.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAccount.xml deleted file mode 100644 index 8b1455811d003..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAccount.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> - <fixture name="signifyd_account" - module="Magento_Signifyd" - type="virtual" - repository_class="Magento\Signifyd\Test\Repository\SignifydAccount" - class="Magento\Signifyd\Test\Fixture\SignifydAccount"> - <field name="email" /> - <field name="password" /> - </fixture> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress.xml deleted file mode 100644 index 02b5cc8211d89..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> - <fixture name="signifydAddress" - module="Magento_Signifyd" - class="Magento\Signifyd\Test\Fixture\SignifydAddress" - extends="\Magento\Customer\Test\Fixture\Address"> - <field name="firstname" source="Magento\Signifyd\Test\Fixture\SignifydAddress\Firstname" is_required="1" /> - </fixture> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress/Firstname.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress/Firstname.php deleted file mode 100644 index 9e4930484eef0..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress/Firstname.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\Fixture\SignifydAddress; - -use Magento\Mtf\Fixture\DataSource; - -/** - * Source handler for `firstname` field in shipping address fixture. - */ -class Firstname extends DataSource -{ - /** - * @param string $data - */ - public function __construct($data = '') - { - $this->data = $data; - } - - /** - * Add isolation for `firstname` field. - * - * @param null $key - * @return string - */ - public function getData($key = null) - { - $this->data = str_replace('%signifyd_isolation%', $this->generateIsolation(), $this->data); - - return parent::getData($key); - } - - /** - * Generates character isolation. - * - * @param int $length - * @return string - */ - private function generateIsolation($length = 10) - { - return substr(str_shuffle(str_repeat("abcdefghijklmnopqrstuvwxyz", $length)), 0, $length); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydData.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydData.xml deleted file mode 100644 index 23ee2cddf434a..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydData.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> - <fixture name="signifyd_data" - module="Magento_Signifyd" - type="virtual" - repository_class="Magento\Signifyd\Test\Repository\SignifydData" - class="Magento\Signifyd\Test\Fixture\SignifydData"> - <field name="team" /> - <field name="caseFlag" /> - <field name="guaranteeDisposition" /> - <field name="cvvResponse" /> - <field name="avsResponse" /> - <field name="shippingPrice" /> - </fixture> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/OrdersGrid.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/OrdersGrid.xml deleted file mode 100644 index 749d91c3ed395..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/OrdersGrid.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="ordersGrid" area="Adminhtml" mca="sales/order" module="Magento_Signifyd"> - <block name="signifydOrdersGrid" class="Magento\Signifyd\Test\Block\Adminhtml\Order\Grid" locator="//div[contains(@data-bind, 'sales_order_grid')]" strategy="xpath" /> - </page> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/SalesOrderView.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/SalesOrderView.xml deleted file mode 100644 index 36d77723dfcee..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/SalesOrderView.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="SalesOrderView" area="Adminhtml" mca="sales/order/view"> - <block name="fraudProtectionBlock" class="Magento\Signifyd\Test\Block\Adminhtml\Order\View\FraudProtection" locator=".admin__page-section.order-case-info" strategy="css selector" /> - </page> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydCases.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydCases.xml deleted file mode 100644 index cfe889bb8de44..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydCases.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="SignifydCases" area="SignifydConsole" mca="https://app.signifyd.com/cases" module="Magento_Signifyd"> - <block name="caseSearchBlock" class="Magento\Signifyd\Test\Block\SignifydConsole\CaseSearch" locator="[class$=app-sidebar]" strategy="css selector" /> - <block name="caseInfoBlock" class="Magento\Signifyd\Test\Block\SignifydConsole\CaseInfo" locator="[class*=app-wrapper]" strategy="css selector" /> - </page> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydLogin.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydLogin.xml deleted file mode 100644 index 5fe5da6d28013..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydLogin.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="SignifydLogin" area="SignifydConsole" mca="https://app.signifyd.com/login" module="Magento_Signifyd"> - <block name="loginBlock" class="Magento\Signifyd\Test\Block\SignifydConsole\SignifydLogin" locator="[id=loginForm]" strategy="css selector" /> - </page> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydNotifications.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydNotifications.xml deleted file mode 100644 index dd12f14c28800..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydNotifications.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="SignifydNotifications" area="SignifydConsole" mca="https://app.signifyd.com/settings/notifications" module="Magento_Signifyd"> - <block name="webhooksBlock" class="Magento\Signifyd\Test\Block\SignifydConsole\Webhooks" locator="[id=body]" strategy="css selector" /> - </page> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Address.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Address.xml deleted file mode 100644 index a534cbc6107fe..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Address.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" ?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> - <repository class="Magento\Customer\Test\Repository\Address"> - <dataset name="signifyd_us_shipping_address"> - <field name="firstname" xsi:type="string">John%signifyd_isolation%</field> - <field name="lastname" xsi:type="string">Doe</field> - <field name="company" xsi:type="string">Magento</field> - <field name="city" xsi:type="string">Culver City</field> - <field name="street" xsi:type="string">6161 West Centinela Avenue</field> - <field name="telephone" xsi:type="string">555-55-555-55</field> - <field name="country_id" xsi:type="string">United States</field> - <field name="region_id" xsi:type="string">California</field> - <field name="postcode" xsi:type="string">90230</field> - </dataset> - </repository> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/ConfigData.xml deleted file mode 100644 index 2af46f077b304..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/ConfigData.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> - <repository class="Magento\Config\Test\Repository\ConfigData"> - <dataset name="signifyd"> - <field name="fraud_protection/signifyd/active" xsi:type="array"> - <item name="scope" xsi:type="string">fraud_protection</item> - <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string">Yes</item> - <item name="value" xsi:type="number">1</item> - </field> - <field name="fraud_protection/signifyd/config/api_key" xsi:type="array"> - <item name="scope" xsi:type="string">fraud_protection</item> - <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> - <item name="value" xsi:type="string">SIGNIFYD_CONFIG_API_KEY</item> - </field> - <field name="fraud_protection/signifyd/api_url" xsi:type="array"> - <item name="scope" xsi:type="string">fraud_protection</item> - <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> - <item name="value" xsi:type="string">https://api.signifyd.com/v2/</item> - </field> - <field name="fraud_protection/signifyd/debug" xsi:type="array"> - <item name="scope" xsi:type="string">fraud_protection</item> - <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string">Yes</item> - <item name="value" xsi:type="number">1</item> - </field> - </dataset> - <dataset name="signifyd_rollback"> - <field name="fraud_protection/signifyd/active" xsi:type="array"> - <item name="scope" xsi:type="string">fraud_protection</item> - <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string">Yes</item> - <item name="value" xsi:type="number">0</item> - </field> - </dataset> - </repository> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Customer.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Customer.xml deleted file mode 100644 index b45e3d01b8ec8..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Customer.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" ?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> - <repository class="Magento\Customer\Test\Repository\Customer"> - <dataset name="signifyd_approve_us_customer"> - <field name="firstname" xsi:type="string">John</field> - <field name="lastname" xsi:type="string">Doe</field> - <field name="email" xsi:type="string">testapprove@magento.com</field> - <field name="password" xsi:type="string">123123^q</field> - <field name="password_confirmation" xsi:type="string">123123^q</field> - </dataset> - <dataset name="signifyd_decline_us_customer"> - <field name="firstname" xsi:type="string">John</field> - <field name="lastname" xsi:type="string">Doe</field> - <field name="email" xsi:type="string">testdecline@magento.com</field> - <field name="password" xsi:type="string">123123^q</field> - <field name="password_confirmation" xsi:type="string">123123^q</field> - </dataset> - </repository> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydAccount.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydAccount.xml deleted file mode 100644 index 4d3dd5229eae3..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydAccount.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" ?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> - <repository class="Magento\Signifyd\Test\Repository\SignifydAccount"> - <dataset name="sandbox_default"> - <field name="email" xsi:type="string">SIGNIFYD_EMAIL</field> - <field name="password" xsi:type="string">SIGNIFYD_PASSWORD</field> - </dataset> - </repository> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydData.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydData.xml deleted file mode 100644 index 02037534b0149..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydData.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" ?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> - <repository class="Magento\Signifyd\Test\Repository\SignifydData"> - <dataset name="signifyd_guarantee_approve"> - <field name="team" xsi:type="string">autotest</field> - <field name="caseFlag" xsi:type="string">Good</field> - <field name="guaranteeDisposition" xsi:type="string">Approved</field> - <field name="cvvResponse" xsi:type="string">CVV2 Match (M)</field> - <field name="avsResponse" xsi:type="string">Full match (Y)</field> - <field name="shippingPrice" xsi:type="string">USD 5.00</field> - </dataset> - <dataset name="signifyd_guarantee_decline"> - <field name="team" xsi:type="string">autotest</field> - <field name="caseFlag" xsi:type="string">Bad</field> - <field name="guaranteeDisposition" xsi:type="string">Declined</field> - <field name="cvvResponse" xsi:type="string">CVV2 Match (M)</field> - <field name="avsResponse" xsi:type="string">Full match (Y)</field> - <field name="shippingPrice" xsi:type="string">USD 5.00</field> - </dataset> - <dataset name="signifyd_guarantee_fraudulent"> - <field name="team" xsi:type="string">autotest</field> - <field name="caseFlag" xsi:type="string">Bad</field> - <field name="guaranteeDisposition" xsi:type="string">Declined</field> - <field name="shippingPrice" xsi:type="string">GBP 10.00</field> - </dataset> - </repository> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php deleted file mode 100644 index 1dd742c9f7096..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\TestCase; - -use Magento\Mtf\TestCase\Scenario; - -/** - * * Preconditions: - * 1. Configure shipping method. - * 2. Configure payment method. - * 3. Configure Signifyd fraud protection tool - * 4. Create products. - * 5. Create and setup customer. - * - * Steps: - * 1. Log in to Signifyd account. - * 2. Remove all existing webhooks by test team. - * 3. Add new webhook set. - * 4. Log in Storefront. - * 5. Add products to the Shopping Cart. - * 6. Click the 'Proceed to Checkout' button. - * 7. Fill shipping information. - * 8. Select shipping method. - * 9. Select Hosted Pro method. - * 10. Click 'Continue' button. - * 11. Specify credit card data in Paypal iframe. - * 12. Click 'Pay Now' button. - * 13. Log in to Signifyd account and search for created case. - * 14. Open created case. - * 15. Click "Flag case as bad" button. - * 16. Perform case info assertions. - * 17. Log in to Admin. - * 18. Proceed to order grid. - * 19. Perform Signifyd guarantee status assertions. - * 20. Proceed to order view. - * 21. Perform order status and case info assertions. - * 22. Click Accept Payment button. - * 23. Perform remaining assertions. - * - * @group Signifyd - * @ZephyrId MAGETWO-65333 - */ -class AcceptPaymentWithSignifydGuaranteeDeclinedTest extends Scenario -{ - /* tags */ - const MVP = 'yes'; - const TEST_TYPE = '3rd_party_test_single_flow'; - const SEVERITY = 'S2'; - /* end tags */ - - /** - * Runs one page checkout test. - * - * @return void - */ - public function test() - { - $this->executeScenario(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml deleted file mode 100644 index 6391081e5e161..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> - <testCase name="Magento\Signifyd\Test\TestCase\AcceptPaymentWithSignifydGuaranteeDeclinedTest" - summary="One Page Checkout with Signifyd, PayPal Payments Pro Hosted Solution with Fraud filters triggered."> - <variation name="AcceptPaymentWithSignifydGuaranteeDeclinedWithHostedProVariation1" summary="Accept order placed within PayPal Payments Pro Hosted Solution with Fraud filters triggered and Signifyd Guarantee Declined" ticketId="MAGETWO-65333"> - <data name="products/0" xsi:type="string">catalogProductSimple::product_100_dollar</data> - <data name="customer/dataset" xsi:type="string">signifyd_decline_us_customer</data> - <data name="checkoutMethod" xsi:type="string">login</data> - <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> - <data name="shipping/shipping_method" xsi:type="string">Fixed</data> - <data name="payment/method" xsi:type="string">hosted_pro</data> - <data name="prices" xsi:type="array"> - <item name="grandTotal" xsi:type="string">210.00</item> - <item name="grandTotalCurrency" xsi:type="string">GBP</item> - </data> - <data name="creditCardClass" xsi:type="string">credit_card_hostedpro</data> - <data name="creditCard/dataset" xsi:type="string">visa_hosted_pro</data> - <data name="isVaultPresent" xsi:type="boolean">false</data> - <data name="configData" xsi:type="string">merchant_country_gb, hosted_pro, config_base_currency_gb, signifyd</data> - <data name="placeOrderStatus" xsi:type="string">Suspected Fraud</data> - <data name="signifydAddress/dataset" xsi:type="string">signifyd_us_shipping_address</data> - <data name="signifydAccount/dataset" xsi:type="string">sandbox_default</data> - <data name="signifydData/dataset" xsi:type="string">signifyd_guarantee_fraudulent</data> - <data name="status" xsi:type="string">Processing</data> - <data name="tag" xsi:type="string">test_type:3rd_party_test_single_flow, severity:S2</data> - <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> - <constraint name="Magento\Signifyd\Test\Constraint\AssertSignifydCaseInCommentsHistory" /> - <constraint name="Magento\Sales\Test\Constraint\AssertAcceptPaymentMessageInCommentsHistory" /> - <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> - </variation> - </testCase> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php deleted file mode 100644 index 5ca76ff70479f..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\TestCase; - -use Magento\Mtf\TestCase\Scenario; - -/** - * Preconditions: - * 1. Configure shipping method. - * 2. Configure payment method. - * 3. Configure Signifyd fraud protection tool - * 4. Create products. - * 5. Create and setup customer. - * - * Steps: - * 1. Log in to Signifyd account. - * 2. Remove all existing webhooks by test team. - * 3. Add new webhook set. - * 4. Log in Storefront. - * 5. Add products to the Shopping Cart. - * 6. Click the 'Proceed to Checkout' button. - * 7. Fill shipping information. - * 8. Select shipping method. - * 9. Select payment method. - * 10. Specify credit card data. - * 11. Click 'Place order' button. - * 12. Search for created case. - * 13. Open created case. - * 14. Click "Flag case as good" or "Flag case as bad" button. - * 15. Perform case info assertions. - * 16. Log in to Admin. - * 17. Proceed to order grid. - * 18. Perform Signifyd guarantee status assertions. - * 19. Proceed to order view. - * 20. Perform order status and case info assertions. - * 21. Click Cancel button. - * 22. Perform remaining assertions. - * - * @group Signifyd - * @ZephyrId MAGETWO-62120, MAGETWO-63221, MAGETWO-64305, MAGETWO-65253 - */ -class CreateSignifydGuaranteeAndCancelOrderTest extends Scenario -{ - /* tags */ - const MVP = 'yes'; - const TEST_TYPE = '3rd_party_test_single_flow'; - const SEVERITY = 'S1'; - /* end tags */ - - /** - * Runs one page checkout test. - * - * @return void - */ - public function test() - { - $this->executeScenario(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml deleted file mode 100644 index 082627fe5821d..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> - <testCase name="Magento\Signifyd\Test\TestCase\CreateSignifydGuaranteeAndCancelOrderTest" - summary="One Page Checkout with Signifyd and cancel order."> - <variation name="CreateSignifydGuaranteeAndCancelOrderWithBraintreeVariation1" - summary="Cancel order placed within Braintree credit card with Signifyd approved guarantee." - ticketId="MAGETWO-62120,MAGETWO-63221"> - <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> - <data name="checkoutMethod" xsi:type="string">login</data> - <data name="customer/dataset" xsi:type="string">signifyd_approve_us_customer</data> - <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> - <data name="shipping/shipping_method" xsi:type="string">Fixed</data> - <data name="payment/method" xsi:type="string">braintree</data> - <data name="paymentForm" xsi:type="string">braintree</data> - <data name="prices/grandTotal" xsi:type="string">15.00</data> - <data name="prices/grandTotalCurrency" xsi:type="string">USD</data> - <data name="creditCard/dataset" xsi:type="string">visa_default</data> - <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> - <data name="configData" xsi:type="string">braintree,signifyd</data> - <data name="placeOrderStatus" xsi:type="string">Processing</data> - <data name="signifydAddress/dataset" xsi:type="string">signifyd_us_shipping_address</data> - <data name="signifydAccount/dataset" xsi:type="string">sandbox_default</data> - <data name="signifydData/dataset" xsi:type="string">signifyd_guarantee_approve</data> - <data name="tag" xsi:type="string">test_type:3rd_party_test_single_flow, severity:S1</data> - <constraint name="Magento\Sales\Test\Constraint\AssertAuthorizationInCommentsHistory" /> - <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> - <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCanceled" /> - <constraint name="Magento\Sales\Test\Constraint\AssertCancelInCommentsHistory" /> - <constraint name="Magento\Signifyd\Test\Constraint\AssertSignifydCaseInCommentsHistory" /> - <constraint name="Magento\Signifyd\Test\Constraint\AssertAwaitingSignifydGuaranteeInCommentsHistory" /> - <constraint name="Magento\Signifyd\Test\Constraint\AssertSignifydGuaranteeCancelInCommentsHistory" /> - </variation> - <variation name="CreateSignifydGuaranteeAndCancelOrderWithBraintreeVariation2" - summary="Cancel order placed within Braintree credit card with Signifyd declined guarantee." - ticketId="MAGETWO-64305, MAGETWO-65253"> - <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> - <data name="checkoutMethod" xsi:type="string">login</data> - <data name="customer/dataset" xsi:type="string">signifyd_decline_us_customer</data> - <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> - <data name="shipping/shipping_method" xsi:type="string">Fixed</data> - <data name="payment/method" xsi:type="string">braintree</data> - <data name="paymentForm" xsi:type="string">braintree</data> - <data name="prices/grandTotal" xsi:type="string">15.00</data> - <data name="prices/grandTotalCurrency" xsi:type="string">USD</data> - <data name="creditCard/dataset" xsi:type="string">visa_default</data> - <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> - <data name="configData" xsi:type="string">braintree,signifyd</data> - <data name="placeOrderStatus" xsi:type="string">On Hold</data> - <data name="signifydAddress/dataset" xsi:type="string">signifyd_us_shipping_address</data> - <data name="signifydAccount/dataset" xsi:type="string">sandbox_default</data> - <data name="signifydData/dataset" xsi:type="string">signifyd_guarantee_decline</data> - <data name="tag" xsi:type="string">test_type:3rd_party_test_single_flow, severity:S1</data> - <constraint name="Magento\Sales\Test\Constraint\AssertAuthorizationInCommentsHistory" /> - <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> - <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCanceled" /> - <constraint name="Magento\Sales\Test\Constraint\AssertCancelInCommentsHistory" /> - <constraint name="Magento\Signifyd\Test\Constraint\AssertSignifydCaseInCommentsHistory" /> - <constraint name="Magento\Signifyd\Test\Constraint\AssertAwaitingSignifydGuaranteeInCommentsHistory" /> - </variation> - </testCase> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php deleted file mode 100644 index 698861da26018..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\TestCase; - -use Magento\Mtf\TestCase\Scenario; - -/** - * * Preconditions: - * 1. Configure shipping method. - * 2. Configure payment method. - * 3. Configure Signifyd fraud protection tool - * 4. Create products. - * 5. Create and setup customer. - * - * Steps: - * 1. Log in to Signifyd account. - * 2. Remove all existing webhooks by test team. - * 3. Add new webhook set. - * 4. Log in Storefront. - * 5. Add products to the Shopping Cart. - * 6. Click the 'Proceed to Checkout' button. - * 7. Fill shipping information. - * 8. Select shipping method. - * 9. Select Hosted Pro method. - * 10. Click 'Continue' button. - * 11. Specify credit card data in Paypal iframe. - * 12. Click 'Pay Now' button. - * 13. Log in to Signifyd account and search for created case. - * 14. Open created case. - * 15. Click "Flag case as bad" button. - * 16. Perform case info assertions. - * 17. Log in to Admin. - * 18. Proceed to order grid. - * 19. Perform Signifyd guarantee status assertions. - * 20. Proceed to order view. - * 21. Perform order status and case info assertions. - * 22. Click Deny Payment button. - * 23. Perform remaining assertions. - * - * @group Signifyd - * @ZephyrId MAGETWO-65332 - */ -class DenyPaymentWithSignifydGuaranteeDeclinedTest extends Scenario -{ - /* tags */ - const MVP = 'yes'; - const TEST_TYPE = '3rd_party_test_single_flow'; - const SEVERITY = 'S2'; - /* end tags */ - - /** - * Runs one page checkout test. - * - * @return void - */ - public function test() - { - $this->executeScenario(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml deleted file mode 100644 index 5496619fe1bf9..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> - <testCase name="Magento\Signifyd\Test\TestCase\DenyPaymentWithSignifydGuaranteeDeclinedTest" - summary="One Page Checkout with Signifyd, PayPal Payments Pro Hosted Solution with Fraud filters triggered."> - <variation name="DenyPaymentWithSignifydGuaranteeDeclinedWithHostedProVariation1" summary="Deny order placed within PayPal Payments Pro Hosted Solution with Fraud filters triggered and Signifyd Guarantee Declined" ticketId="MAGETWO-65332"> - <data name="products/0" xsi:type="string">catalogProductSimple::product_100_dollar</data> - <data name="customer/dataset" xsi:type="string">signifyd_decline_us_customer</data> - <data name="checkoutMethod" xsi:type="string">login</data> - <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> - <data name="shipping/shipping_method" xsi:type="string">Fixed</data> - <data name="payment/method" xsi:type="string">hosted_pro</data> - <data name="prices" xsi:type="array"> - <item name="grandTotal" xsi:type="string">210.00</item> - <item name="grandTotalCurrency" xsi:type="string">GBP</item> - </data> - <data name="creditCardClass" xsi:type="string">credit_card_hostedpro</data> - <data name="creditCard/dataset" xsi:type="string">visa_hosted_pro</data> - <data name="isVaultPresent" xsi:type="boolean">false</data> - <data name="configData" xsi:type="string">merchant_country_gb, hosted_pro, config_base_currency_gb, signifyd</data> - <data name="placeOrderStatus" xsi:type="string">Suspected Fraud</data> - <data name="status" xsi:type="string">Canceled</data> - <data name="signifydAddress/dataset" xsi:type="string">signifyd_us_shipping_address</data> - <data name="signifydAccount/dataset" xsi:type="string">sandbox_default</data> - <data name="signifydData/dataset" xsi:type="string">signifyd_guarantee_fraudulent</data> - <data name="tag" xsi:type="string">test_type:3rd_party_test_single_flow, severity:S2</data> - <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> - <constraint name="Magento\Signifyd\Test\Constraint\AssertSignifydCaseInCommentsHistory" /> - <constraint name="Magento\Sales\Test\Constraint\AssertDenyPaymentMessageInCommentsHistory" /> - <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> - <constraint name="Magento\Signifyd\Test\Constraint\AssertSignifydGuaranteeCancelInCommentsHistory" /> - </variation> - </testCase> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/OpenOrderGridStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/OpenOrderGridStep.php deleted file mode 100644 index 409dffc8340b7..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/OpenOrderGridStep.php +++ /dev/null @@ -1,173 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\TestStep; - -use Magento\Mtf\TestStep\TestStepInterface; -use Magento\Sales\Test\Page\Adminhtml\OrderIndex; -use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; -use Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect as AssertOrderStatus; -use Magento\Signifyd\Test\Constraint\AssertSignifydCaseInOrdersGrid as AssertOrdersGrid; -use Magento\Signifyd\Test\Constraint\AssertCaseInfoOnAdmin; -use Magento\Signifyd\Test\Fixture\SignifydData; -use Magento\Signifyd\Test\Page\Adminhtml\OrdersGrid; - -/** - * Open order grid step. - */ -class OpenOrderGridStep implements TestStepInterface -{ - /** - * Magento order status assertion. - * - * @var AssertOrderStatus - */ - private $assertOrderStatus; - - /** - * Case information on Magento Admin assertion. - * - * @var AssertCaseInfoOnAdmin - */ - private $assertCaseInfo; - - /** - * Case information on Magento order grid assertion. - * - * @var AssertOrdersGrid - */ - private $assertOrdersGrid; - - /** - * Magento order status. - * - * @var string - */ - private $placeOrderStatus; - - /** - * Magento order id. - * - * @var int - */ - private $orderId; - - /** - * Order View Page. - * - * @var SalesOrderView - */ - private $salesOrderView; - - /** - * Orders grid page. - * - * @var OrdersGrid - */ - private $ordersGrid; - - /** - * Signifyd data fixture. - * - * @var array - */ - private $signifydData; - - /** - * Orders Page. - * - * @var OrderIndex - */ - private $orderIndex; - - /** - * @param string $placeOrderStatus - * @param int $orderId - * @param OrderIndex $orderIndex - * @param SalesOrderView $salesOrderView - * @param OrdersGrid $ordersGrid - * @param AssertOrderStatus $assertOrderStatus - * @param AssertCaseInfoOnAdmin $assertCaseInfo - * @param AssertOrdersGrid $assertOrdersGrid - * @param SignifydData $signifydData - */ - public function __construct( - $placeOrderStatus, - $orderId, - OrderIndex $orderIndex, - SalesOrderView $salesOrderView, - OrdersGrid $ordersGrid, - AssertOrderStatus $assertOrderStatus, - AssertCaseInfoOnAdmin $assertCaseInfo, - AssertOrdersGrid $assertOrdersGrid, - SignifydData $signifydData - ) { - $this->placeOrderStatus = $placeOrderStatus; - $this->orderId = $orderId; - $this->orderIndex = $orderIndex; - $this->salesOrderView = $salesOrderView; - $this->ordersGrid = $ordersGrid; - $this->assertOrderStatus = $assertOrderStatus; - $this->assertCaseInfo = $assertCaseInfo; - $this->assertOrdersGrid = $assertOrdersGrid; - $this->signifydData = $signifydData; - } - - /** - * Open order. - * - * @return void - */ - public function run() - { - $this->checkOrdersGrid(); - $this->checkCaseInfo(); - $this->checkOrderStatus(); - } - - /** - * Run assert to check Signifyd Case Disposition status in orders grid. - * - * @return void - */ - private function checkOrdersGrid() - { - $this->assertOrdersGrid->processAssert( - $this->orderId, - $this->ordersGrid, - $this->signifydData - ); - } - - /** - * Run assert to check order status is valid. - * - * @return void - */ - private function checkOrderStatus() - { - $this->assertOrderStatus->processAssert( - $this->placeOrderStatus, - $this->orderId, - $this->orderIndex, - $this->salesOrderView - ); - } - - /** - * Run assert to check Signifyd Case information is correct in Admin. - * - * @return void - */ - private function checkCaseInfo() - { - $this->assertCaseInfo->processAssert( - $this->salesOrderView, - $this->orderIndex, - $this->signifydData, - $this->orderId - ); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCancelOrderStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCancelOrderStep.php deleted file mode 100644 index 54f4dd75223e0..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCancelOrderStep.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\TestStep; - -use Magento\Mtf\TestStep\TestStepFactory; -use Magento\Mtf\TestStep\TestStepInterface; -use Magento\Sales\Test\Fixture\OrderInjectable; -use Magento\Sales\Test\Page\Adminhtml\OrderIndex; -use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; -use Magento\Sales\Test\TestStep\CancelOrderStep; -use Magento\Sales\Test\TestStep\DenyPaymentStep; -use Magento\Sales\Test\TestStep\UnholdOrderStep; - -/** - * Rollback step for Signifyd scenarios. - */ -class SignifydCancelOrderStep implements TestStepInterface -{ - /** - * Order index page. - * - * @var OrderIndex - */ - private $orderIndex; - - /** - * Order fixture. - * - * @var OrderInjectable - */ - private $order; - - /** - * Order View page. - * - * @var SalesOrderView - */ - private $salesOrderView; - - /** - * Test step factory. - * - * @var TestStepFactory - */ - private $testStepFactory; - - /** - * @param OrderIndex $orderIndex - * @param OrderInjectable $order - * @param SalesOrderView $salesOrderView - * @param TestStepFactory $testStepFactory - */ - public function __construct( - OrderIndex $orderIndex, - OrderInjectable $order, - SalesOrderView $salesOrderView, - TestStepFactory $testStepFactory - ) { - $this->orderIndex = $orderIndex; - $this->order = $order; - $this->salesOrderView = $salesOrderView; - $this->testStepFactory = $testStepFactory; - } - - /** - * @inheritdoc - */ - public function run() - { - $this->orderIndex->open(); - $this->orderIndex->getSalesOrderGrid() - ->searchAndOpen(['id' => $this->order->getId()]); - - switch ($this->salesOrderView->getOrderInfoBlock()->getOrderStatus()) { - case 'Suspected Fraud': - $this->getStepInstance(DenyPaymentStep::class)->run(); - break; - case 'On Hold': - $this->getStepInstance(UnholdOrderStep::class)->run(); - $this->getStepInstance(CancelOrderStep::class)->run(); - break; - case 'Canceled': - break; - default: - $this->getStepInstance(CancelOrderStep::class)->run(); - } - } - - /** - * Creates test step instance with preset params. - * - * @param string $class - * @return TestStepInterface - */ - private function getStepInstance($class) - { - return $this->testStepFactory->create( - $class, - ['order' => $this->order] - ); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php deleted file mode 100644 index 5fec5988d2c9f..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\TestStep; - -use Magento\Customer\Test\Fixture\Customer; -use Magento\Customer\Test\TestStep\CreateCustomerStep; -use Magento\Customer\Test\TestStep\DeleteCustomerStep; -use Magento\Mtf\TestStep\TestStepFactory; -use Magento\Mtf\TestStep\TestStepInterface; - -/** - * Customized create customer step with remove cleanup. - */ -class SignifydCreateCustomerStep implements TestStepInterface -{ - /** - * Customer fixture. - * - * @var Customer - */ - private $customer; - - /** - * Test step factory. - * - * @var TestStepFactory - */ - private $testStepFactory; - - /** - * @param Customer $customer - * @param TestStepFactory $testStepFactory - */ - public function __construct( - Customer $customer, - TestStepFactory $testStepFactory - ) { - $this->customer = $customer; - $this->testStepFactory = $testStepFactory; - } - - /** - * Run step flow. - * - * @return void - */ - public function run() - { - $this->getStepInstance(CreateCustomerStep::class)->run(); - } - - /** - * @return void - */ - public function cleanup() - { - $this->getStepInstance(CreateCustomerStep::class)->cleanup(); - $this->getStepInstance(DeleteCustomerStep::class)->run(); - } - - /** - * Creates test step instance with preset params. - * - * @param string $class - * @return TestStepInterface - */ - private function getStepInstance($class) - { - return $this->testStepFactory->create( - $class, - ['customer' => $this->customer] - ); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydFillShippingAddressStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydFillShippingAddressStep.php deleted file mode 100644 index 0b1dda1d0a46a..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydFillShippingAddressStep.php +++ /dev/null @@ -1,70 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\TestStep; - -use Magento\Checkout\Test\TestStep\FillShippingAddressStep; -use Magento\Checkout\Test\Page\CheckoutOnepage; -use Magento\Mtf\Fixture\FixtureFactory; -use Magento\Customer\Test\Fixture\Customer; -use Magento\Mtf\ObjectManager; -use Magento\Signifyd\Test\Fixture\SignifydAddress; - -/** - * Class SignifydFillShippingAddressStep only overrides type of $shippingAddress. - * - * We cannot configure Checkout_FillShippingAddressStep this via di.xml, - * because 'source' handler Firstname, specified in SignifydAddress - * fixture did not apply when the step was called from testcase.xml scenario. - * - * Note. When fixture was called directly in the class constructor, - * source handlers applied correctly. - */ -class SignifydFillShippingAddressStep extends FillShippingAddressStep -{ - /** - * @var SignifydAddress|null - */ - private $signifydAddress; - - /** - * @param CheckoutOnepage $checkoutOnepage - * @param Customer $customer - * @param ObjectManager $objectManager - * @param FixtureFactory $fixtureFactory - * @param SignifydAddress|null $signifydAddress - * @param null $shippingAddressCustomer - */ - public function __construct( - CheckoutOnepage $checkoutOnepage, - Customer $customer, - ObjectManager $objectManager, - FixtureFactory $fixtureFactory, - SignifydAddress $signifydAddress = null, - $shippingAddressCustomer = null - ) { - parent::__construct( - $checkoutOnepage, - $customer, - $objectManager, - $fixtureFactory, - $signifydAddress, - $shippingAddressCustomer - ); - $this->signifydAddress = $signifydAddress; - } - - /** - * @inheritdoc - */ - public function run() - { - parent::run(); - - return [ - 'signifydAddress' => $this->signifydAddress, - ]; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydLoginStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydLoginStep.php deleted file mode 100644 index 3dd1b94d6b505..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydLoginStep.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\TestStep; - -use Magento\Mtf\TestStep\TestStepInterface; -use Magento\Signifyd\Test\Fixture\SignifydAccount; -use Magento\Signifyd\Test\Page\SignifydConsole\SignifydCases; -use Magento\Signifyd\Test\Page\SignifydConsole\SignifydLogin; - -/** - * Login into Signifyd console step. - */ -class SignifydLoginStep implements TestStepInterface -{ - /** - * Signifyd account fixture. - * - * @var SignifydAccount - */ - private $signifydAccount; - - /** - * Signifyd login page. - * - * @var SignifydLogin - */ - private $signifydLogin; - - /** - * Signifyd cases page. - * - * @var SignifydCases - */ - private $signifydCases; - - /** - * @param SignifydAccount $signifydAccount - * @param SignifydLogin $signifydLogin - * @param SignifydCases $signifydCases - */ - public function __construct( - SignifydAccount $signifydAccount, - SignifydLogin $signifydLogin, - SignifydCases $signifydCases - ) { - $this->signifydAccount = $signifydAccount; - $this->signifydLogin = $signifydLogin; - $this->signifydCases = $signifydCases; - } - - /** - * @inheritdoc - */ - public function run() - { - $this->signifydLogin->open(); - - if ($this->signifydLogin->getLoginBlock()->isVisible()) { - $this->signifydLogin->getLoginBlock()->fill($this->signifydAccount); - $this->signifydLogin->getLoginBlock()->login(); - } - - $this->signifydCases->getCaseSearchBlock()->waitForLoading(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydObserveCaseStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydObserveCaseStep.php deleted file mode 100644 index c00c81fa237e0..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydObserveCaseStep.php +++ /dev/null @@ -1,165 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\TestStep; - -use Magento\Mtf\TestStep\TestStepFactory; -use Magento\Mtf\TestStep\TestStepInterface; -use Magento\Sales\Test\Fixture\OrderInjectable; -use Magento\Signifyd\Test\Constraint\AssertCaseInfoOnSignifydConsole; -use Magento\Signifyd\Test\Fixture\SignifydAddress; -use Magento\Signifyd\Test\Fixture\SignifydData; -use Magento\Signifyd\Test\Page\SignifydConsole\SignifydCases; -use Magento\Signifyd\Test\Page\SignifydConsole\SignifydNotifications; - -/** - * Observe case information in Signifyd console step. - */ -class SignifydObserveCaseStep implements TestStepInterface -{ - /** - * Case information on Signifyd console assertion. - * - * @var AssertCaseInfoOnSignifydConsole - */ - private $assertCaseInfo; - - /** - * Billing address fixture. - * - * @var SignifydAddress - */ - private $signifydAddress; - - /** - * Signifyd cases page. - * - * @var SignifydCases - */ - private $signifydCases; - - /** - * Signifyd notifications page. - * - * @var SignifydNotifications - */ - private $signifydNotifications; - - /** - * Signifyd data fixture. - * - * @var array - */ - private $signifydData; - - /** - * Prices list. - * - * @var array - */ - private $prices; - - /** - * Order fixture. - * - * @var string - */ - private $order; - - /** - * Test step factory. - * - * @var TestStepFactory - */ - private $testStepFactory; - - /** - * @var int - */ - private $searchAttempts = 10; - - /** - * @param AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole - * @param SignifydAddress $signifydAddress - * @param SignifydCases $signifydCases - * @param SignifydNotifications $signifydNotifications - * @param SignifydData $signifydData - * @param OrderInjectable $order - * @param TestStepFactory $testStepFactory - * @param array $prices - */ - public function __construct( - AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole, - SignifydAddress $signifydAddress, - SignifydCases $signifydCases, - SignifydNotifications $signifydNotifications, - SignifydData $signifydData, - OrderInjectable $order, - TestStepFactory $testStepFactory, - array $prices - ) { - $this->assertCaseInfo = $assertCaseInfoOnSignifydConsole; - $this->signifydAddress = $signifydAddress; - $this->signifydCases = $signifydCases; - $this->signifydNotifications = $signifydNotifications; - $this->signifydData = $signifydData; - $this->order = $order; - $this->testStepFactory = $testStepFactory; - $this->prices = $prices; - } - - /** - * @inheritdoc - */ - public function run() - { - $this->signifydCases->open(); - // Search case few times because it can appear with delay. - for ($attempts = $this->searchAttempts; $attempts > 0; $attempts--) { - $this->signifydCases->getCaseSearchBlock() - ->searchCaseByCustomerName($this->signifydAddress->getFirstname()); - if ($this->signifydCases->getCaseSearchBlock()->isAnyCaseVisible()) { - break; - } - sleep(3); - } - - $this->signifydCases->getCaseSearchBlock()->selectCase(); - $this->signifydCases->getCaseInfoBlock()->flagCase($this->signifydData->getCaseFlag()); - - $this->assertCaseInfo->processAssert( - $this->signifydCases, - $this->signifydAddress, - $this->signifydData, - $this->prices, - $this->order->getId(), - $this->getCustomerFullName($this->signifydAddress) - ); - } - - /** - * Cancel order if test fails, or in the end of variation. - * - * @return void - */ - public function cleanup() - { - $this->testStepFactory->create( - SignifydCancelOrderStep::class, - ['order' => $this->order] - )->run(); - } - - /** - * Gets customer full name. - * - * @param SignifydAddress $billingAddress - * @return string - */ - private function getCustomerFullName(SignifydAddress $billingAddress) - { - return sprintf('%s %s', $billingAddress->getFirstname(), $billingAddress->getLastname()); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydSetWebhookHandlersStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydSetWebhookHandlersStep.php deleted file mode 100644 index 2b630b8c1dac8..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydSetWebhookHandlersStep.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\TestStep; - -use Magento\Mtf\TestStep\TestStepInterface; -use Magento\Signifyd\Test\Fixture\SignifydData; -use Magento\Signifyd\Test\Page\SignifydConsole\SignifydNotifications; - -/** - * Set webhook handlers in Signifyd console step. - */ -class SignifydSetWebhookHandlersStep implements TestStepInterface -{ - /** - * Signifyd Notifications page. - * - * @var SignifydNotifications - */ - private $signifydNotifications; - - /** - * Signifyd data fixture. - * - * @var array - */ - private $signifydData; - - /** - * @param SignifydNotifications $signifydNotifications - * @param SignifydData $signifydData - */ - public function __construct( - SignifydNotifications $signifydNotifications, - SignifydData $signifydData - ) { - $this->signifydNotifications = $signifydNotifications; - $this->signifydData = $signifydData; - } - - /** - * @inheritdoc - */ - public function run() - { - $this->signifydNotifications->open(); - $this->signifydNotifications->getWebhooksBlock() - ->create($this->signifydData->getTeam()); - } - - /** - * Removes webhooks if test fails, or in the end of variation execution. - * - * @return void - */ - public function cleanup() - { - $this->signifydNotifications->open(); - $this->signifydNotifications->getWebhooksBlock() - ->cleanup($this->signifydData->getTeam()); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/UnholdAndCancelOrderStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/UnholdAndCancelOrderStep.php deleted file mode 100644 index 0c90b1b76937b..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/UnholdAndCancelOrderStep.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Test\TestStep; - -use Magento\Mtf\TestStep\TestStepFactory; -use Magento\Mtf\TestStep\TestStepInterface; -use Magento\Sales\Test\Fixture\OrderInjectable; -use Magento\Sales\Test\TestStep\CancelOrderStep; -use Magento\Sales\Test\TestStep\UnholdOrderStep; - -/** - * Unhold and cancel order. - */ -class UnholdAndCancelOrderStep implements TestStepInterface -{ - /** - * Magento order status. - * - * @var string - */ - private $placeOrderStatus; - - /** - * Order fixture. - * - * @var OrderInjectable - */ - private $order; - - /** - * Test step factory. - * - * @var TestStepFactory - */ - private $testStepFactory; - - /** - * @param string $placeOrderStatus - * @param OrderInjectable $order - * @param TestStepFactory $testStepFactory - */ - public function __construct( - $placeOrderStatus, - OrderInjectable $order, - TestStepFactory $testStepFactory - ) { - $this->placeOrderStatus = $placeOrderStatus; - $this->order = $order; - $this->testStepFactory = $testStepFactory; - } - - /** - * Cancel order step. - * - * If order was held - unhold and then cancel the order. - * - * @return void - */ - public function run() - { - if ($this->placeOrderStatus === 'On Hold') { - $this->getStepInstance(UnholdOrderStep::class)->run(); - } - - $this->getStepInstance(CancelOrderStep::class)->run(); - } - - /** - * Creates test step instance with preset params. - * - * @param string $class - * @return TestStepInterface - */ - private function getStepInstance($class) - { - return $this->testStepFactory->create( - $class, - ['order' => $this->order] - ); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/di.xml deleted file mode 100644 index 2ba4b6c97d33f..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/di.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> - <type name="Magento\Signifyd\Test\Constraint\AssertCaseInfoOnAdmin"> - <arguments> - <argument name="severity" xsi:type="string">S1</argument> - </arguments> - </type> - <type name="Magento\Signifyd\Test\Constraint\AssertCaseInfoOnSignifydConsole"> - <arguments> - <argument name="severity" xsi:type="string">S1</argument> - </arguments> - </type> - <type name="Magento\Signifyd\Test\Constraint\AssertSignifydCaseInCommentsHistory"> - <arguments> - <argument name="severity" xsi:type="string">S1</argument> - </arguments> - </type> - <type name="Magento\Signifyd\Test\Constraint\AssertSignifydCaseInOrdersGrid"> - <arguments> - <argument name="severity" xsi:type="string">S1</argument> - </arguments> - </type> - <type name="Magento\Signifyd\Test\Constraint\AssertSignifydGuaranteeCancelInCommentsHistory"> - <arguments> - <argument name="severity" xsi:type="string">S2</argument> - </arguments> - </type> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/testcase.xml deleted file mode 100644 index cfbd2e6ace2b4..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/testcase.xml +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/TestCase/etc/testcase.xsd"> - <scenario name="CreateSignifydGuaranteeAndCancelOrderTest" firstStep="signifydLogin"> - <step name="signifydLogin" module="Magento_Signifyd" next="signifydSetWebhookHandlers" /> - <step name="signifydSetWebhookHandlers" module="Magento_Signifyd" next="setupConfiguration" /> - <step name="setupConfiguration" module="Magento_Config" next="createProducts" /> - <step name="createProducts" module="Magento_Catalog" next="addProductsToTheCart" /> - <step name="addProductsToTheCart" module="Magento_Checkout" next="proceedToCheckoutFromMiniShoppingCart" /> - <step name="proceedToCheckoutFromMiniShoppingCart" module="Magento_Checkout" next="signifydCreateCustomer" /> - <step name="signifydCreateCustomer" module="Magento_Signifyd" next="selectCheckoutMethod" /> - <step name="selectCheckoutMethod" module="Magento_Checkout" next="signifydFillShippingAddress" /> - <step name="signifydFillShippingAddress" module="Magento_Signifyd" next="fillShippingMethod" /> - <step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod" /> - <step name="selectPaymentMethod" module="Magento_Checkout" next="placeOrder" /> - <step name="placeOrder" module="Magento_Checkout" next="signifydObserveCase" /> - <step name="signifydObserveCase" module="Magento_Signifyd" next="openOrderGrid" /> - <step name="openOrderGrid" module="Magento_Signifyd" next="unholdAndCancelOrder" /> - <step name="unholdAndCancelOrder" module="Magento_Signifyd" /> - </scenario> - <scenario name="AcceptPaymentWithSignifydGuaranteeDeclinedTest" firstStep="signifydLogin"> - <step name="signifydLogin" module="Magento_Signifyd" next="signifydSetWebhookHandlers" /> - <step name="signifydSetWebhookHandlers" module="Magento_Signifyd" next="setupConfiguration" /> - <step name="setupConfiguration" module="Magento_Config" next="createProducts" /> - <step name="createProducts" module="Magento_Catalog" next="addProductsToTheCart" /> - <step name="addProductsToTheCart" module="Magento_Checkout" next="proceedToCheckoutFromMiniShoppingCart" /> - <step name="proceedToCheckoutFromMiniShoppingCart" module="Magento_Checkout" next="signifydCreateCustomer" /> - <step name="signifydCreateCustomer" module="Magento_Signifyd" next="selectCheckoutMethod" /> - <step name="selectCheckoutMethod" module="Magento_Checkout" next="signifydFillShippingAddress" /> - <step name="signifydFillShippingAddress" module="Magento_Signifyd" next="fillShippingMethod" /> - <step name="fillShippingMethod" module="Magento_Checkout" next="placeOrderWithHostedPro" /> - <step name="placeOrderWithHostedPro" module="Magento_Paypal" next="signifydObserveCase" /> - <step name="signifydObserveCase" module="Magento_Signifyd" next="openOrderGrid" /> - <step name="openOrderGrid" module="Magento_Signifyd" next="acceptPayment" /> - <step name="acceptPayment" module="Magento_Sales" /> - </scenario> - <scenario name="DenyPaymentWithSignifydGuaranteeDeclinedTest" firstStep="signifydLogin"> - <step name="signifydLogin" module="Magento_Signifyd" next="signifydSetWebhookHandlers" /> - <step name="signifydSetWebhookHandlers" module="Magento_Signifyd" next="setupConfiguration" /> - <step name="setupConfiguration" module="Magento_Config" next="createProducts" /> - <step name="createProducts" module="Magento_Catalog" next="addProductsToTheCart" /> - <step name="addProductsToTheCart" module="Magento_Checkout" next="proceedToCheckoutFromMiniShoppingCart" /> - <step name="proceedToCheckoutFromMiniShoppingCart" module="Magento_Checkout" next="signifydCreateCustomer" /> - <step name="signifydCreateCustomer" module="Magento_Signifyd" next="selectCheckoutMethod" /> - <step name="selectCheckoutMethod" module="Magento_Checkout" next="signifydFillShippingAddress" /> - <step name="signifydFillShippingAddress" module="Magento_Signifyd" next="fillShippingMethod" /> - <step name="fillShippingMethod" module="Magento_Checkout" next="placeOrderWithHostedPro" /> - <step name="placeOrderWithHostedPro" module="Magento_Paypal" next="signifydObserveCase" /> - <step name="signifydObserveCase" module="Magento_Signifyd" next="openOrderGrid" /> - <step name="openOrderGrid" module="Magento_Signifyd" next="denyPayment" /> - <step name="denyPayment" module="Magento_Sales" /> - </scenario> -</config> diff --git a/dev/tests/integration/testsuite/Magento/Framework/Composer/_files/testFromCreateProject/composer.lock b/dev/tests/integration/testsuite/Magento/Framework/Composer/_files/testFromCreateProject/composer.lock index e723549288cda..69b6d314ee64d 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Composer/_files/testFromCreateProject/composer.lock +++ b/dev/tests/integration/testsuite/Magento/Framework/Composer/_files/testFromCreateProject/composer.lock @@ -8437,45 +8437,6 @@ ], "description": "N/A" }, - { - "name": "magento/module-signifyd", - "version": "100.3.1", - "dist": { - "type": "zip", - "url": "https://repo.magento.com/archives/magento/module-signifyd/magento-module-signifyd-100.3.1.0.zip", - "reference": null, - "shasum": "768442b807e31bacfb5bbf914e155bac3ca88dde" - }, - "require": { - "magento/framework": "102.0.*", - "magento/module-backend": "101.0.*", - "magento/module-checkout": "100.3.*", - "magento/module-config": "101.1.*", - "magento/module-customer": "102.0.*", - "magento/module-directory": "100.3.*", - "magento/module-payment": "100.3.*", - "magento/module-sales": "102.0.*", - "magento/module-store": "101.0.*", - "php": "~7.1.3||~7.2.0" - }, - "suggest": { - "magento/module-config": "101.1.*" - }, - "type": "magento2-module", - "autoload": { - "files": [ - "registration.php" - ], - "psr-4": { - "Magento\\Signifyd\\": "" - } - }, - "license": [ - "OSL-3.0", - "AFL-3.0" - ], - "description": "Submitting Case Entry to Signifyd on Order Creation" - }, { "name": "magento/module-sitemap", "version": "100.3.1", @@ -9816,7 +9777,6 @@ "magento/module-send-friend": "100.3.1", "magento/module-send-friend-graph-ql": "100.3.0", "magento/module-shipping": "100.3.1", - "magento/module-signifyd": "100.3.1", "magento/module-sitemap": "100.3.1", "magento/module-store": "101.0.1", "magento/module-store-graph-ql": "100.3.1", diff --git a/dev/tests/integration/testsuite/Magento/Framework/Composer/_files/testSkeleton/composer.lock b/dev/tests/integration/testsuite/Magento/Framework/Composer/_files/testSkeleton/composer.lock index 2e2fa561fa4cc..151c2b5eca565 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Composer/_files/testSkeleton/composer.lock +++ b/dev/tests/integration/testsuite/Magento/Framework/Composer/_files/testSkeleton/composer.lock @@ -8437,45 +8437,6 @@ ], "description": "N/A" }, - { - "name": "magento/module-signifyd", - "version": "100.3.1", - "dist": { - "type": "zip", - "url": "https://repo.magento.com/archives/magento/module-signifyd/magento-module-signifyd-100.3.1.0.zip", - "reference": null, - "shasum": "768442b807e31bacfb5bbf914e155bac3ca88dde" - }, - "require": { - "magento/framework": "102.0.*", - "magento/module-backend": "101.0.*", - "magento/module-checkout": "100.3.*", - "magento/module-config": "101.1.*", - "magento/module-customer": "102.0.*", - "magento/module-directory": "100.3.*", - "magento/module-payment": "100.3.*", - "magento/module-sales": "102.0.*", - "magento/module-store": "101.0.*", - "php": "~7.1.3||~7.2.0" - }, - "suggest": { - "magento/module-config": "101.1.*" - }, - "type": "magento2-module", - "autoload": { - "files": [ - "registration.php" - ], - "psr-4": { - "Magento\\Signifyd\\": "" - } - }, - "license": [ - "OSL-3.0", - "AFL-3.0" - ], - "description": "Submitting Case Entry to Signifyd on Order Creation" - }, { "name": "magento/module-sitemap", "version": "100.3.1", @@ -9816,7 +9777,6 @@ "magento/module-send-friend": "100.3.1", "magento/module-send-friend-graph-ql": "100.3.0", "magento/module-shipping": "100.3.1", - "magento/module-signifyd": "100.3.1", "magento/module-sitemap": "100.3.1", "magento/module-store": "101.0.1", "magento/module-store-graph-ql": "100.3.1", diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php deleted file mode 100644 index 7607526b1389e..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Block\Adminhtml; - -use Magento\Framework\App\RequestInterface; -use Magento\Framework\ObjectManagerInterface; -use Magento\Framework\View\Element\Template\Context; -use Magento\Sales\Model\Order; -use Magento\TestFramework\Helper\Bootstrap; - -class CaseInfoTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var ObjectManagerInterface - */ - private $objectManager; - - /** - * @var Order - */ - private $order; - - /** - * @var \Magento\Framework\View\LayoutFactory - */ - protected $layoutFactory; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->objectManager = Bootstrap::getObjectManager(); - $this->order = $this->objectManager->create(Order::class); - $this->layoutFactory = $this->objectManager->get(\Magento\Framework\View\LayoutFactory::class); - } - - /** - * Checks that block has contents when case entity for order is exists - * even if Signifyd module is inactive. - * - * @magentoConfigFixture current_store fraud_protection/signifyd/active 0 - * @magentoDataFixture Magento/Signifyd/_files/case.php - * @magentoAppArea adminhtml - */ - public function testModuleIsInactive() - { - $this->order->loadByIncrementId('100000001'); - - self::assertNotEmpty($this->getBlock()->toHtml()); - } - - /** - * Checks that block does not give contents - * if there is no case entity created for order. - * - * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseEntity - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php - * @magentoAppArea adminhtml - */ - public function testCaseEntityNotExists() - { - $this->order->loadByIncrementId('100000001'); - - self::assertEmpty($this->getBlock()->toHtml()); - } - - /** - * Checks that: - * - block give contents - * - block contents guarantee decision field - * - * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getScoreClass - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - * @magentoDataFixture Magento/Signifyd/_files/case.php - * @magentoAppArea adminhtml - */ - public function testCaseEntityExists() - { - $this->order->loadByIncrementId('100000001'); - - $block = $this->getBlock(); - self::assertNotEmpty($block->toHtml()); - self::assertContains((string) $block->getCaseGuaranteeDisposition(), $block->toHtml()); - } - - /** - * Gets block. - * - * @return CaseInfo - */ - private function getBlock() - { - $layout = $this->layoutFactory->create(); - - $layout->addContainer('order_additional_info', 'Container'); - - /** @var CaseInfo $block */ - $block = $layout->addBlock(CaseInfo::class, 'order_case_info', 'order_additional_info'); - $block->setAttribute('context', $this->getContext()); - $block->setTemplate('Magento_Signifyd::case_info.phtml'); - - return $block; - } - - /** - * Creates template context with necessary order id param. - * - * @return Context - */ - private function getContext() - { - /** @var RequestInterface $request */ - $request = $this->objectManager->get(RequestInterface::class); - $request->setParams(['order_id' => $this->order->getEntityId()]); - - return $this->objectManager->create(Context::class, ['request' => $request]); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php deleted file mode 100644 index 1efbb8b6d33e4..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Block; - -use Magento\Framework\App\Area; -use Magento\Framework\App\ObjectManager; -use Magento\Framework\View\LayoutInterface; -use Magento\TestFramework\Helper\Bootstrap; - -class FingerprintTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @inheritdoc - */ - protected function setUp() - { - $bootstrap = Bootstrap::getInstance(); - $bootstrap->loadArea(Area::AREA_FRONTEND); - - $this->objectManager = Bootstrap::getObjectManager(); - } - - /** - * Checks if session id attribute is present when the module is enabled. - * - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - */ - public function testSessionIdPresent() - { - self::assertContains('data-order-session-id', $this->getBlockContents()); - } - - /** - * Checks if block is an empty when the module is disabled. - * - * @magentoConfigFixture current_store fraud_protection/signifyd/active 0 - */ - public function testBlockEmpty() - { - self::assertEmpty($this->getBlockContents()); - } - - /** - * Renders block contents. - * - * @return string - */ - private function getBlockContents() - { - $block = $this->objectManager->get(LayoutInterface::class) - ->createBlock(Fingerprint::class); - - return $block->fetchView($block->getTemplateFile()); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php deleted file mode 100644 index 667cb079f9096..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Controller\Webhooks; - -use Magento\TestFramework\TestCase\AbstractController; -use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequest; -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Sales\Api\Data\OrderStatusHistoryInterface; -use Magento\Sales\Api\OrderRepositoryInterface; - -/** - * Class tests handling webhook post from Signifyd service. - */ -class HandlerTest extends AbstractController -{ - /** - * @var string - */ - private static $entryPoint = 'signifyd/webhooks/handler'; - - /** - * Tests handling webhook message of cases/rescore type. - * Checks updated case entity and comment in order history. - * - * @covers \Magento\Signifyd\Controller\Webhooks\Handler::execute - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - * @magentoConfigFixture current_store fraud_protection/signifyd/api_key ApFZZvxGgIxuP8BazSm3v8eGN - * @magentoDataFixture Magento/Signifyd/_files/case.php - */ - public function testExecuteSuccess() - { - $caseId = 123; - $webhookRequest = $this->getWebhookRequest(); - $this->_objectManager->addSharedInstance($webhookRequest, WebhookRequest::class); - - $this->dispatch(self::$entryPoint); - - /** @var CaseRepositoryInterface $caseManagement */ - $caseRepository = $this->_objectManager->get(CaseRepositoryInterface::class); - /** @var CaseInterface $caseEntity */ - $caseEntity = $caseRepository->getByCaseId($caseId); - $orderEntityId = $caseEntity->getOrderId(); - - self::assertNotEmpty($caseEntity); - self::assertEquals('2017-01-06 12:47:03', $caseEntity->getCreatedAt()); - self::assertEquals('2017-01-06 12:47:03', $caseEntity->getUpdatedAt()); - self::assertEquals('Magento', $caseEntity->getAssociatedTeam()['teamName']); - self::assertEquals(true, $caseEntity->isGuaranteeEligible()); - self::assertEquals(CaseInterface::STATUS_OPEN, $caseEntity->getStatus()); - self::assertEquals($orderEntityId, $caseEntity->getOrderId()); - - /** @var OrderRepositoryInterface $orderRepository */ - $orderRepository = $this->_objectManager->get(OrderRepositoryInterface::class); - $order = $orderRepository->get($caseEntity->getOrderId()); - $histories = $order->getStatusHistories(); - self::assertNotEmpty($histories); - - /** @var OrderStatusHistoryInterface $caseCreationComment */ - $caseComment = array_pop($histories); - self::assertInstanceOf(OrderStatusHistoryInterface::class, $caseComment); - - self::assertEquals( - "Case Update: New score for the order is 384. Previous score was 553.", - $caseComment->getComment() - ); - - $this->_objectManager->removeSharedInstance(WebhookRequest::class); - } - - /** - * Tests handling webhook message of cases/test type. - * Controller should response with code 200. - * - * @covers \Magento\Signifyd\Controller\Webhooks\Handler::execute - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - */ - public function testExecuteTestSuccess() - { - $webhookRequest = $this->getTestWebhookRequest(); - $this->_objectManager->addSharedInstance($webhookRequest, WebhookRequest::class); - $this->dispatch(self::$entryPoint); - $this->assertEquals(200, $this->getResponse()->getHttpResponseCode()); - $this->_objectManager->removeSharedInstance(WebhookRequest::class); - } - - /** - * Returns mocked WebhookRequest - * - * @return WebhookRequest|\PHPUnit\Framework\MockObject_MockObject - */ - private function getWebhookRequest() - { - $webhookRequest = $this->getMockBuilder(WebhookRequest::class) - ->disableOriginalConstructor() - ->getMock(); - $webhookRequest->expects($this->any()) - ->method('getBody') - ->willReturn(file_get_contents(__DIR__ . '/../../_files/webhook_body.json')); - $webhookRequest->expects($this->any()) - ->method('getEventTopic') - ->willReturn('cases/rescore'); - $webhookRequest->expects($this->any()) - ->method('getHash') - ->willReturn('m/X29RcHWPSCDPgQuSXjnyTfKISJDopcdGbVsRLeqy8='); - - return $webhookRequest; - } - - /** - * Returns mocked test WebhookRequest - * - * @return WebhookRequest|\PHPUnit\Framework\MockObject_MockObject - */ - private function getTestWebhookRequest() - { - $webhookRequest = $this->getMockBuilder(WebhookRequest::class) - ->disableOriginalConstructor() - ->getMock(); - $webhookRequest->expects($this->any()) - ->method('getBody') - ->willReturn(file_get_contents(__DIR__ . '/../../_files/webhook_body.json')); - $webhookRequest->expects($this->any()) - ->method('getEventTopic') - ->willReturn('cases/test'); - $webhookRequest->expects($this->any()) - ->method('getHash') - ->willReturn('wyG0r9mOmv1IqVlN6ZqJ5sgA635yKW6lbSsqlYF2b8U='); - - return $webhookRequest; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php deleted file mode 100644 index 30603baf867ff..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Model; - -use Magento\Framework\Api\SearchCriteriaBuilder; -use Magento\Framework\App\ObjectManager; -use Magento\Sales\Api\Data\OrderInterface; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\TestFramework\Helper\Bootstrap; - -/** - * Contains test methods for case management service - */ -class CaseManagementTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var CaseManagement - */ - private $caseManagement; - - /** - * @var ObjectManager - */ - private $objectManager; - - protected function setup() - { - $this->objectManager = Bootstrap::getObjectManager(); - $this->caseManagement = $this->objectManager->get(CaseManagement::class); - } - - /** - * @covers \Magento\Signifyd\Model\CaseManagement::create - * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php - */ - public function testCreate() - { - $order = $this->getOrder(); - $case = $this->caseManagement->create($order->getEntityId()); - - self::assertNotEmpty($case->getEntityId()); - self::assertEquals(CaseInterface::STATUS_PENDING, $case->getStatus()); - self::assertEquals(CaseInterface::GUARANTEE_PENDING, $case->getGuaranteeDisposition()); - } - - /** - * @covers \Magento\Signifyd\Model\CaseManagement::getByOrderId - * @magentoDataFixture Magento/Signifyd/_files/case.php - */ - public function testGetByOrderId() - { - $order = $this->getOrder(); - $case = $this->caseManagement->getByOrderId($order->getEntityId()); - - self::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus()); - self::assertEquals(CaseInterface::DISPOSITION_GOOD, $case->getReviewDisposition()); - self::assertEquals('2016-12-12 15:17:17', $case->getCreatedAt()); - self::assertEquals('2016-12-12 19:23:16', $case->getUpdatedAt()); - } - - /** - * Get stored order - * @return OrderInterface - */ - private function getOrder() - { - /** @var SearchCriteriaBuilder $searchCriteriaBuilder */ - $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class); - $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001') - ->create(); - - $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); - $orders = $orderRepository->getList($searchCriteria) - ->getItems(); - - /** @var OrderInterface $order */ - return array_pop($orders); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php deleted file mode 100644 index ca98a20b15bec..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php +++ /dev/null @@ -1,148 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Model; - -use Magento\Framework\Api\FilterBuilder; -use Magento\Framework\Api\SearchCriteriaBuilder; -use Magento\Framework\App\ObjectManager; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\TestFramework\Helper\Bootstrap; - -/** - * Testing case repository - */ -class CaseRepositoryTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var FilterBuilder - */ - private $filterBuilder; - - /** - * @var SearchCriteriaBuilder - */ - private $searchCriteriaBuilder; - - /** - * @var CaseRepository - */ - private $repository; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->objectManager = Bootstrap::getObjectManager(); - $this->filterBuilder = $this->objectManager->get(FilterBuilder::class); - $this->searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class); - $this->repository = $this->objectManager->get(CaseRepository::class); - } - - /** - * @covers \Magento\Signifyd\Model\CaseRepository::delete - * @magentoDataFixture Magento/Signifyd/_files/case.php - */ - public function testDelete() - { - $filters = [ - $this->filterBuilder->setField('case_id') - ->setValue(123) - ->create() - ]; - $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create(); - $cases = $this->repository->getList($searchCriteria) - ->getItems(); - - $case = array_pop($cases); - $this->repository->delete($case); - - self::assertEmpty($this->repository->getList($searchCriteria)->getItems()); - } - - /** - * @covers \Magento\Signifyd\Model\CaseRepository::getById - * @magentoDataFixture Magento/Signifyd/_files/case.php - */ - public function testGetById() - { - $filters = [ - $this->filterBuilder->setField('case_id') - ->setValue(123) - ->create() - ]; - $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create(); - $cases = $this->repository->getList($searchCriteria) - ->getItems(); - - $case = array_pop($cases); - - $found = $this->repository->getById($case->getEntityId()); - - self::assertNotEmpty($found->getEntityId()); - self::assertEquals($case->getEntityId(), $found->getEntityId()); - self::assertEquals($case->getOrderId(), $found->getOrderId()); - } - - /** - * @covers \Magento\Signifyd\Model\CaseRepository::getList - * @magentoDataFixture Magento/Signifyd/_files/multiple_cases.php - */ - public function testGetListDateInterval() - { - $startDateInterval = [ - $this->filterBuilder->setField('created_at') - ->setConditionType('gteq') - ->setValue('2016-12-01 00:00:01') - ->create() - ]; - $endDateInterval = [ - $this->filterBuilder->setField('created_at') - ->setConditionType('lteq') - ->setValue('2016-12-03 23:59:59') - ->create() - ]; - - $this->searchCriteriaBuilder->addFilters($startDateInterval); - $searchCriteria = $this->searchCriteriaBuilder->addFilters($endDateInterval)->create(); - $items = $this->repository->getList($searchCriteria) - ->getItems(); - - self::assertCount(3, $items); - - for ($i = 1; $i < 4; $i ++) { - $current = array_shift($items); - self::assertEquals($i, $current->getCaseId()); - } - } - - /** - * @covers \Magento\Signifyd\Model\CaseRepository::getList - * @magentoDataFixture Magento/Signifyd/_files/multiple_cases.php - */ - public function testGetListStatusProcessing() - { - $filters = [ - $this->filterBuilder->setField('status') - ->setValue(CaseInterface::STATUS_PROCESSING) - ->create() - ]; - - $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create(); - $items = $this->repository->getList($searchCriteria) - ->getItems(); - - self::assertCount(1, $items); - - $case = array_pop($items); - self::assertEquals(123, $case->getCaseId()); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php deleted file mode 100644 index 6cf1e0bfddc9a..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php +++ /dev/null @@ -1,245 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Model\CaseServices; - -use Magento\Framework\Api\SearchCriteriaBuilder; -use Magento\Framework\App\ObjectManager; -use Magento\Sales\Api\Data\OrderInterface; -use Magento\Sales\Api\Data\OrderStatusHistoryInterface; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\Sales\Model\Order; -use Magento\Sales\Model\ResourceModel\Order\Grid\Collection; -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Model\SignifydGateway\ApiCallException; -use Magento\Signifyd\Model\SignifydGateway\ApiClient; -use Magento\Signifyd\Model\SignifydGateway\Client\RequestBuilder; -use Magento\Signifyd\Model\SignifydGateway\Gateway; -use Magento\TestFramework\Helper\Bootstrap; -use PHPUnit\Framework\MockObject_MockObject as MockObject; -use Psr\Log\LoggerInterface; - -/** - * Class tests interaction with Signifyd Case creation service - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class CreationServiceTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var OrderInterface - */ - private $order; - - /** - * @var RequestBuilder|MockObject - */ - private $requestBuilder; - - /** - * @var LoggerInterface|MockObject - */ - private $logger; - - /** - * @var CreationService - */ - private $service; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->objectManager = Bootstrap::getObjectManager(); - - $this->requestBuilder = $this->getMockBuilder(RequestBuilder::class) - ->disableOriginalConstructor() - ->setMethods(['doRequest']) - ->getMock(); - - $apiClient = $this->objectManager->create( - ApiClient::class, - ['requestBuilder' => $this->requestBuilder] - ); - - $gateway = $this->objectManager->create( - Gateway::class, - ['apiClient' => $apiClient] - ); - - $this->logger = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->setMethods(['error']) - ->getMockForAbstractClass(); - - $this->service = $this->objectManager->create( - CreationService::class, - [ - 'signifydGateway' => $gateway, - 'logger' => $this->logger - ] - ); - } - - /** - * @covers \Magento\Signifyd\Model\CaseServices\CreationService::createForOrder - * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php - */ - public function testCreateForOrderWithEmptyResponse() - { - $order = $this->getOrder(); - $exceptionMessage = 'Response is not valid JSON: Decoding failed: Syntax error'; - - $this->requestBuilder->expects(self::once()) - ->method('doRequest') - ->willThrowException(new ApiCallException($exceptionMessage)); - - $this->logger->expects(self::once()) - ->method('error') - ->with($exceptionMessage); - - $result = $this->service->createForOrder($order->getEntityId()); - self::assertTrue($result); - } - - /** - * @covers \Magento\Signifyd\Model\CaseServices\CreationService::createForOrder - * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php - */ - public function testCreateForOrderWithBadResponse() - { - $order = $this->getOrder(); - $responseData = [ - 'messages' => [ - 'Something wrong' - ] - ]; - $exceptionMessage = 'Bad Request - The request could not be parsed. Response: ' . json_encode($responseData); - - $this->requestBuilder->expects(self::once()) - ->method('doRequest') - ->willThrowException(new ApiCallException($exceptionMessage)); - - $this->logger->expects(self::once()) - ->method('error') - ->with($exceptionMessage); - - $result = $this->service->createForOrder($order->getEntityId()); - self::assertTrue($result); - } - - /** - * @covers \Magento\Signifyd\Model\CaseServices\CreationService::createForOrder - * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php - */ - public function testCreateOrderWithEmptyInvestigationId() - { - $order = $this->getOrder(); - - $this->requestBuilder->expects(self::once()) - ->method('doRequest') - ->willReturn([]); - - $this->logger->expects(self::once()) - ->method('error') - ->with('Expected field "investigationId" missed.'); - - $result = $this->service->createForOrder($order->getEntityId()); - self::assertTrue($result); - } - - /** - * @covers \Magento\Signifyd\Model\CaseServices\CreationService::createForOrder - * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php - */ - public function testCreateForOrder() - { - $order = $this->getOrder(); - - $this->requestBuilder->expects(self::once()) - ->method('doRequest') - ->willReturn(['investigationId' => 123123]); - - $this->logger->expects(self::never()) - ->method('error'); - - $result = $this->service->createForOrder($order->getEntityId()); - self::assertTrue($result); - - /** @var CaseRepositoryInterface $caseRepository */ - $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class); - $caseEntity = $caseRepository->getByCaseId(123123); - $gridGuarantyStatus = $this->getOrderGridGuarantyStatus($caseEntity->getOrderId()); - - self::assertNotEmpty($caseEntity); - self::assertEquals($order->getEntityId(), $caseEntity->getOrderId()); - self::assertEquals( - $gridGuarantyStatus, - $caseEntity->getGuaranteeDisposition(), - 'Signifyd guaranty status in sales_order_grid table does not match case entity guaranty status' - ); - - /** @var OrderRepositoryInterface $orderRepository */ - $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); - $order = $orderRepository->get($caseEntity->getOrderId()); - self::assertEquals(Order::STATE_HOLDED, $order->getState()); - - $histories = $order->getStatusHistories(); - self::assertNotEmpty($histories); - - /** @var OrderStatusHistoryInterface $orderHoldComment */ - $orderHoldComment = array_pop($histories); - self::assertInstanceOf(OrderStatusHistoryInterface::class, $orderHoldComment); - self::assertEquals("Awaiting the Signifyd guarantee disposition.", $orderHoldComment->getComment()); - } - - /** - * Get stored order - * - * @return OrderInterface - */ - private function getOrder() - { - if ($this->order === null) { - - /** @var SearchCriteriaBuilder $searchCriteriaBuilder */ - $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class); - $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001') - ->create(); - - $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); - $orders = $orderRepository->getList($searchCriteria) - ->getItems(); - - $this->order = array_pop($orders); - } - - return $this->order; - } - - /** - * Returns value of signifyd_guarantee_status column from sales order grid - * - * @param int $orderEntityId - * @return string|null - */ - private function getOrderGridGuarantyStatus($orderEntityId) - { - /** @var Collection $orderGridCollection */ - $orderGridCollection = $this->objectManager->get(Collection::class); - - $items = $orderGridCollection->addFilter($orderGridCollection->getIdFieldName(), $orderEntityId) - ->getItems(); - $result = array_pop($items); - - return isset($result['signifyd_guarantee_status']) ? $result['signifyd_guarantee_status'] : null; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php deleted file mode 100644 index 50e510ca072be..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php +++ /dev/null @@ -1,186 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Model\CaseServices; - -use Magento\Framework\App\ObjectManager; -use Magento\Sales\Api\Data\OrderStatusHistoryInterface; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\Sales\Model\Order; -use Magento\Sales\Model\ResourceModel\Order\Grid\Collection; -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory; -use Magento\TestFramework\Helper\Bootstrap; - -/** - * Contains tests for case entity updating service. - */ -class UpdatingServiceTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var UpdatingService - */ - private $service; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->objectManager = Bootstrap::getObjectManager(); - - /** @var GeneratorFactory $messageFactory */ - $messageFactory = $this->objectManager->get(GeneratorFactory::class); - $messageGenerator = $messageFactory->create('cases/creation'); - - $this->service = $this->objectManager->create(UpdatingService::class, [ - 'messageGenerator' => $messageGenerator - ]); - } - - /** - * Checks case updating flow and messages in order comments history. - * Also checks that order is unholded when case guarantee disposition is APPROVED. - * - * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update - * @magentoDataFixture Magento/Signifyd/_files/case.php - */ - public function testUpdate() - { - $caseId = 123; - $data = [ - 'caseId' => $caseId, - 'score' => 750, - 'orderId' => '100000001', - 'reviewDisposition' => CaseInterface::DISPOSITION_FRAUDULENT, - 'associatedTeam' => [ - 'teamName' => 'AnyTeam', - 'teamId' => 26, - 'getAutoDismiss' => true, - 'getTeamDismissalDays' => 2 - ], - 'createdAt' => '2017-01-05T14:23:26-0800', - 'updatedAt' => '2017-01-05T14:44:26-0800', - 'guaranteeDisposition' => CaseInterface::GUARANTEE_APPROVED - ]; - - /** @var CaseRepositoryInterface $caseRepository */ - $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class); - /** @var CaseInterface $caseEntity */ - $caseEntity = $caseRepository->getByCaseId($caseId); - - $this->service->update($caseEntity, $data); - - $caseEntity = $caseRepository->getByCaseId($caseId); - $orderEntityId = $caseEntity->getOrderId(); - $gridGuarantyStatus = $this->getOrderGridGuarantyStatus($orderEntityId); - - self::assertNotEmpty($caseEntity); - self::assertEquals('2017-01-05 22:23:26', $caseEntity->getCreatedAt()); - self::assertEquals(CaseInterface::GUARANTEE_APPROVED, $caseEntity->getGuaranteeDisposition()); - self::assertEquals('AnyTeam', $caseEntity->getAssociatedTeam()['teamName']); - self::assertEquals(true, $caseEntity->isGuaranteeEligible()); - self::assertEquals(CaseInterface::STATUS_PROCESSING, $caseEntity->getStatus()); - self::assertEquals($orderEntityId, $caseEntity->getOrderId()); - self::assertEquals( - $gridGuarantyStatus, - $caseEntity->getGuaranteeDisposition(), - 'Signifyd guaranty status in sales_order_grid table does not match case entity guaranty status' - ); - - /** @var OrderRepositoryInterface $orderRepository */ - $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); - $order = $orderRepository->get($caseEntity->getOrderId()); - self::assertEquals(Order::STATE_PROCESSING, $order->getState()); - $histories = $order->getStatusHistories(); - self::assertNotEmpty($histories); - - /** @var OrderStatusHistoryInterface $caseCreationComment */ - $caseCreationComment = array_pop($histories); - self::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment); - self::assertEquals("Signifyd Case $caseId has been created for order.", $caseCreationComment->getComment()); - } - - /** - * Checks that order is holded when case guarantee disposition is DECLINED. - * - * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update - * @magentoDataFixture Magento/Signifyd/_files/approved_case.php - */ - public function testOrderStateAfterDeclinedGuaranteeDisposition() - { - $caseId = 123; - $data = [ - 'caseId' => $caseId, - 'orderId' => '100000001', - 'guaranteeDisposition' => CaseInterface::GUARANTEE_DECLINED - ]; - - /** @var CaseRepositoryInterface $caseRepository */ - $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class); - $caseEntity = $caseRepository->getByCaseId($caseId); - - $this->service->update($caseEntity, $data); - - /** @var OrderRepositoryInterface $orderRepository */ - $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); - $order = $orderRepository->get($caseEntity->getOrderId()); - - self::assertEquals(Order::STATE_HOLDED, $order->getState()); - } - - /** - * Checks that order doesn't become holded - * when previous case guarantee disposition was DECLINED - * and webhook without guarantee disposition was received. - * - * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update - * @magentoDataFixture Magento/Signifyd/_files/declined_case.php - */ - public function testOrderStateAfterWebhookWithoutGuaranteeDisposition() - { - $caseId = 123; - $data = [ - 'caseId' => $caseId, - 'orderId' => '100000001' - ]; - - /** @var CaseRepositoryInterface $caseRepository */ - $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class); - $caseEntity = $caseRepository->getByCaseId($caseId); - - $this->service->update($caseEntity, $data); - - /** @var OrderRepositoryInterface $orderRepository */ - $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); - $order = $orderRepository->get($caseEntity->getOrderId()); - - self::assertEquals(Order::STATE_PROCESSING, $order->getState()); - } - - /** - * Returns value of signifyd_guarantee_status column from sales order grid - * - * @param int $orderEntityId - * @return string|null - */ - private function getOrderGridGuarantyStatus($orderEntityId) - { - /** @var Collection $orderGridCollection */ - $orderGridCollection = $this->objectManager->get(Collection::class); - - $items = $orderGridCollection->addFilter($orderGridCollection->getIdFieldName(), $orderEntityId) - ->getItems(); - $result = array_pop($items); - - return isset($result['signifyd_guarantee_status']) ? $result['signifyd_guarantee_status'] : null; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php deleted file mode 100644 index 2cc7a9a1f240a..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php +++ /dev/null @@ -1,158 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Model\Guarantee; - -use Magento\Framework\App\ObjectManager; -use Magento\Sales\Api\Data\OrderStatusHistoryInterface; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Model\SignifydGateway\Gateway; -use Magento\Signifyd\Model\SignifydGateway\GatewayException; -use Magento\TestFramework\Helper\Bootstrap; -use PHPUnit\Framework\MockObject_MockObject as MockObject; -use Psr\Log\LoggerInterface; - -/** - * Contains test cases for canceling Signifyd guarantee flow. - */ -class CancelingServiceTest extends \PHPUnit\Framework\TestCase -{ - private static $caseId = 123; - - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var Gateway|MockObject - */ - private $gateway; - - /** - * @var LoggerInterface|MockObject - */ - private $logger; - - /** - * @var CancelingService; - */ - private $service; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->objectManager = Bootstrap::getObjectManager(); - - $this->gateway = $this->getMockBuilder(Gateway::class) - ->disableOriginalConstructor() - ->setMethods(['cancelGuarantee']) - ->getMock(); - - $this->logger = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->service = $this->objectManager->create(CancelingService::class, [ - 'gateway' => $this->gateway, - 'logger' => $this->logger - ]); - } - - /** - * Checks a test case, when Signifyd guarantee was canceled. - * - * @covers \Magento\Signifyd\Model\Guarantee\CancelingService::cancelForOrder - * @magentoDataFixture Magento/Signifyd/_files/case.php - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - */ - public function testCancelForOrderWithCanceledGuarantee() - { - /** @var CaseRepositoryInterface $caseRepository */ - $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class); - $caseEntity = $caseRepository->getByCaseId(self::$caseId); - $caseEntity->setGuaranteeDisposition(CaseInterface::GUARANTEE_CANCELED); - $caseRepository->save($caseEntity); - - $this->gateway->expects(self::never()) - ->method('cancelGuarantee'); - - $this->logger->expects(self::never()) - ->method('error'); - - $result = $this->service->cancelForOrder($caseEntity->getOrderId()); - self::assertFalse($result); - } - - /** - * Checks a test case, when Signifyd gateway throws an exception. - * - * @covers \Magento\Signifyd\Model\Guarantee\CancelingService::cancelForOrder - * @magentoDataFixture Magento/Signifyd/_files/approved_case.php - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - */ - public function testCancelForOrderWithFailedRequest() - { - $exceptionMessage = 'Something wrong.'; - /** @var CaseRepositoryInterface $caseRepository */ - $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class); - $caseEntity = $caseRepository->getByCaseId(self::$caseId); - - $this->gateway->expects(self::once()) - ->method('cancelGuarantee') - ->with(self::equalTo(self::$caseId)) - ->willThrowException(new GatewayException($exceptionMessage)); - - $this->logger->expects(self::once()) - ->method('error') - ->with(self::equalTo($exceptionMessage)); - - $result = $this->service->cancelForOrder($caseEntity->getOrderId()); - self::assertFalse($result); - } - - /** - * Checks a test case, when request to cancel is submitted and case entity is updated successfully. - * - * @covers \Magento\Signifyd\Model\Guarantee\CancelingService::cancelForOrder - * @magentoDataFixture Magento/Signifyd/_files/approved_case.php - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - */ - public function testCancelForOrder() - { - /** @var CaseRepositoryInterface $caseRepository */ - $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class); - $caseEntity = $caseRepository->getByCaseId(self::$caseId); - - $this->gateway->expects(self::once()) - ->method('cancelGuarantee') - ->with(self::equalTo(self::$caseId)) - ->willReturn(CaseInterface::GUARANTEE_CANCELED); - - $this->logger->expects(self::never()) - ->method('error'); - - $result = $this->service->cancelForOrder($caseEntity->getOrderId()); - self::assertTrue($result); - - $updatedCase = $caseRepository->getByCaseId(self::$caseId); - self::assertEquals(CaseInterface::GUARANTEE_CANCELED, $updatedCase->getGuaranteeDisposition()); - - /** @var OrderRepositoryInterface $orderRepository */ - $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); - $order = $orderRepository->get($updatedCase->getOrderId()); - $histories = $order->getStatusHistories(); - self::assertNotEmpty($histories); - - /** @var OrderStatusHistoryInterface $caseCreationComment */ - $caseCreationComment = array_pop($histories); - self::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment); - self::assertEquals('Case Update: Case guarantee has been cancelled.', $caseCreationComment->getComment()); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php deleted file mode 100644 index 157e3270648b3..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php +++ /dev/null @@ -1,155 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Model\Guarantee; - -use Magento\Framework\App\ObjectManager; -use Magento\Sales\Api\Data\OrderStatusHistoryInterface; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Model\SignifydGateway\Gateway; -use Magento\Signifyd\Model\SignifydGateway\GatewayException; -use Magento\TestFramework\Helper\Bootstrap; -use PHPUnit\Framework\MockObject_MockObject as MockObject; -use Psr\Log\LoggerInterface; - -/** - * Contains positive and negative test cases for Signifyd case guarantee creation flow. - */ -class CreationServiceTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var CreationService - */ - private $service; - - /** - * @var Gateway|MockObject - */ - private $gateway; - - /** - * @var LoggerInterface|MockObject - */ - private $logger; - - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @inheritdoc - */ - protected function setUp() - { - /** @var ObjectManager $objectManager */ - $this->objectManager = Bootstrap::getObjectManager(); - - $this->gateway = $this->getMockBuilder(Gateway::class) - ->disableOriginalConstructor() - ->setMethods(['submitCaseForGuarantee']) - ->getMock(); - - $this->logger = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->service = $this->objectManager->create(CreationService::class, [ - 'gateway' => $this->gateway, - 'logger' => $this->logger - ]); - } - - /** - * Checks a test case, when Signifyd case entity cannot be found - * for a specified order. - * - * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder - */ - public function testCreateWithoutCaseEntity() - { - $orderId = 123; - - $this->gateway->expects(self::never()) - ->method('submitCaseForGuarantee'); - - $result = $this->service->createForOrder($orderId); - self::assertFalse($result); - } - - /** - * Checks a test case, when request is failing. - * - * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder - * @magentoDataFixture Magento/Signifyd/_files/case.php - */ - public function testCreateWithFailedRequest() - { - $caseEntity = $this->getCaseEntity(); - - $this->gateway->expects(self::once()) - ->method('submitCaseForGuarantee') - ->willThrowException(new GatewayException('Something wrong')); - - $this->logger->expects(self::once()) - ->method('error') - ->with('Something wrong'); - - $result = $this->service->createForOrder($caseEntity->getOrderId()); - self::assertFalse($result); - } - - /** - * Checks a test case, when case entity is updated successfully. - * - * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder - * @magentoDataFixture Magento/Signifyd/_files/case.php - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - */ - public function testCreate() - { - $caseEntity = $this->getCaseEntity(); - - $this->gateway->expects(self::once()) - ->method('submitCaseForGuarantee') - ->with($caseEntity->getCaseId()) - ->willReturn(CaseInterface::GUARANTEE_IN_REVIEW); - - $this->logger->expects(self::never()) - ->method('error'); - - $result = $this->service->createForOrder($caseEntity->getOrderId()); - self::assertTrue($result); - - $updatedCase = $this->getCaseEntity(); - self::assertEquals(CaseInterface::GUARANTEE_IN_REVIEW, $updatedCase->getGuaranteeDisposition()); - self::assertEquals(CaseInterface::STATUS_PROCESSING, $updatedCase->getStatus()); - - /** @var OrderRepositoryInterface $orderRepository */ - $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); - $order = $orderRepository->get($updatedCase->getOrderId()); - $histories = $order->getStatusHistories(); - self::assertNotEmpty($histories); - - /** @var OrderStatusHistoryInterface $caseCreationComment */ - $caseCreationComment = array_pop($histories); - self::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment); - self::assertEquals('Case Update: Case is submitted for guarantee.', $caseCreationComment->getComment()); - } - - /** - * Gets case entity. - * - * @return \Magento\Signifyd\Api\Data\CaseInterface|null - */ - private function getCaseEntity() - { - /** @var CaseRepositoryInterface $caseRepository */ - $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class); - return $caseRepository->getByCaseId(123); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php deleted file mode 100644 index 594c065185ac7..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php +++ /dev/null @@ -1,291 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Model\SignifydGateway\Request; - -use Magento\Framework\Config\ScopeInterface; -use Magento\Signifyd\Model\SignifydOrderSessionId; -use Magento\TestFramework\Helper\Bootstrap; -use Magento\Framework\App\Area; -use Magento\Framework\Intl\DateTimeFactory; -use Magento\Framework\ObjectManagerInterface; -use Magento\Sales\Model\Order; -use Magento\Customer\Api\CustomerRepositoryInterface; -use Magento\Framework\App\ProductMetadataInterface; - -/** - * Class CreateCaseBuilderTest - * @magentoAppIsolation enabled - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class CreateCaseBuilderTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var ObjectManagerInterface - */ - private $objectManager; - - /** - * @var CreateCaseBuilder - */ - private $caseBuilder; - - /** - * @var DateTimeFactory - */ - private $dateTimeFactory; - - /** - * Initial setup - */ - protected function setUp() - { - $bootstrap = Bootstrap::getInstance(); - $bootstrap->loadArea(Area::AREA_FRONTEND); - $this->objectManager = Bootstrap::getObjectManager(); - $this->dateTimeFactory = $this->objectManager->create(DateTimeFactory::class); - $this->caseBuilder = $this->objectManager->create(CreateCaseBuilder::class); - } - - /** - * Test builder on order with customer, simple product, frontend area, - * PayPal gateway, shipping and billing addresses, with two orders - * - * @covers \Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilder::build() - * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testCreateCaseBuilderWithFullSetOfData() - { - /** @var Order $order */ - $order = $this->objectManager->create(Order::class); - $order->loadByIncrementId('100000001'); - - $orderItems = $order->getAllItems(); - $payment = $order->getPayment(); - $billingAddress = $order->getBillingAddress(); - $shippingAddress = $order->getShippingAddress(); - - /** @var CustomerRepositoryInterface $customerRepository */ - $customerRepository = $this->objectManager->create(CustomerRepositoryInterface::class); - $customer = $customerRepository->getById($order->getCustomerId()); - - $productMetadata = $this->objectManager->create(ProductMetadataInterface::class); - - /** @var SignifydOrderSessionId $signifydOrderSessionId */ - $signifydOrderSessionId = $this->objectManager->create(SignifydOrderSessionId::class); - - $expected = [ - 'purchase' => [ - 'orderSessionId' => $signifydOrderSessionId->get($order->getQuoteId()), - 'browserIpAddress' => $order->getRemoteIp(), - 'orderId' => $order->getIncrementId(), - 'createdAt' => date('c', strtotime(date('Y-m-d 00:00:55'))), - 'paymentGateway' => 'paypal_account', - 'transactionId' => $payment->getLastTransId(), - 'currency' => $order->getOrderCurrencyCode(), - 'avsResponseCode' => '', - 'cvvResponseCode' => '', - 'orderChannel' => 'WEB', - 'totalPrice' => $order->getGrandTotal(), - 'shipments' => [ - 0 => [ - 'shipper' => 'Flat Rate', - 'shippingMethod' => 'Fixed', - 'shippingPrice' => $order->getShippingAmount() - ] - ], - 'products' => [ - 0 => [ - 'itemId' => $orderItems[0]->getSku(), - 'itemName' => $orderItems[0]->getName(), - 'itemPrice' => $orderItems[0]->getPrice(), - 'itemQuantity' => $orderItems[0]->getQtyOrdered(), - 'itemUrl' => $orderItems[0]->getProduct()->getProductUrl(), - 'itemWeight' => $orderItems[0]->getProduct()->getWeight() - ], - 1 => [ - 'itemId' => $orderItems[1]->getSku(), - 'itemName' => $orderItems[1]->getName(), - 'itemPrice' => $orderItems[1]->getPrice(), - 'itemQuantity' => $orderItems[1]->getQtyOrdered(), - 'itemUrl' => $orderItems[1]->getProduct()->getProductUrl(), - 'itemWeight' => $orderItems[1]->getProduct()->getWeight() - ] - ], - 'paymentMethod' => 'PAYPAL_ACCOUNT' - ], - 'card' => [ - 'cardHolderName' => 'firstname lastname', - 'last4' => $payment->getCcLast4(), - 'expiryMonth' => $payment->getCcExpMonth(), - 'expiryYear' => $payment->getCcExpYear(), - 'billingAddress' => [ - 'streetAddress' => 'street', - 'city' => $billingAddress->getCity(), - 'provinceCode' => $billingAddress->getRegionCode(), - 'postalCode' => $billingAddress->getPostcode(), - 'countryCode' => $billingAddress->getCountryId(), - 'unit' => '' - ] - ], - 'recipient' => [ - 'fullName' => $shippingAddress->getName(), - 'confirmationEmail' => $shippingAddress->getEmail(), - 'confirmationPhone' => $shippingAddress->getTelephone(), - 'deliveryAddress' => [ - 'streetAddress' => '6161 West Centinela Avenue', - 'unit' => 'app. 33', - 'city' => $shippingAddress->getCity(), - 'provinceCode' => $shippingAddress->getRegionCode(), - 'postalCode' => $shippingAddress->getPostcode(), - 'countryCode' => $shippingAddress->getCountryId() - ] - ], - 'userAccount' => [ - 'email' => $customer->getEmail(), - 'username' => $customer->getEmail(), - 'phone' => $order->getBillingAddress()->getTelephone(), - 'accountNumber' => $customer->getId(), - 'createdDate' => $this->formatDate($customer->getCreatedAt()), - 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt()), - 'aggregateOrderCount' => 2, - 'aggregateOrderDollars' => 150.0 - ], - 'seller' => $this->getSellerData(), - 'platformAndClient' => [ - 'storePlatform' => $productMetadata->getName() . ' ' . $productMetadata->getEdition(), - 'storePlatformVersion' => $productMetadata->getVersion(), - 'signifydClientApp' => $productMetadata->getName(), - 'signifydClientAppVersion' => '1.0' - ] - ]; - - self::assertEquals( - $expected, - $this->caseBuilder->build($order->getEntityId()) - ); - } - - /** - * Test builder on order with guest, virtual product, admin area, - * none PayPal gateway, no shipping address, without credit card data - * - * @covers \Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilder::build() - * @magentoDataFixture Magento/Signifyd/_files/order_with_guest_and_virtual_product.php - */ - public function testCreateCaseBuilderWithVirtualProductAndGuest() - { - /** @var Order $order */ - $order = $this->objectManager->create(Order::class); - $order->loadByIncrementId('100000002'); - - $scope = $this->objectManager->get(ScopeInterface::class); - $scope->setCurrentScope(Area::AREA_ADMINHTML); - - $orderItems = $order->getAllItems(); - $product = $orderItems[0]->getProduct(); - $payment = $order->getPayment(); - $billingAddress = $order->getBillingAddress(); - $productMetadata = $this->objectManager->create(ProductMetadataInterface::class); - - /** @var SignifydOrderSessionId $quoteSessionId */ - $quoteSessionId = $this->objectManager->create(SignifydOrderSessionId::class); - - $expected = [ - 'purchase' => [ - 'orderSessionId' => $quoteSessionId->get($order->getQuoteId()), - 'browserIpAddress' => $order->getRemoteIp(), - 'orderId' => $order->getIncrementId(), - 'createdAt' => '2016-12-12T12:00:55+00:00', - 'paymentGateway' => $payment->getMethod(), - 'transactionId' => $payment->getLastTransId(), - 'currency' => $order->getOrderCurrencyCode(), - 'avsResponseCode' => 'Y', - 'cvvResponseCode' => 'M', - 'orderChannel' => 'PHONE', - 'totalPrice' => $order->getGrandTotal(), - 'products' => [ - 0 => [ - 'itemId' => $orderItems[0]->getSku(), - 'itemName' => $orderItems[0]->getName(), - 'itemPrice' => $orderItems[0]->getPrice(), - 'itemQuantity' => $orderItems[0]->getQtyOrdered(), - 'itemUrl' => $product->getProductUrl() - ], - ], - 'paymentMethod' => 'PAYMENT_CARD' - ], - 'card' => [ - 'cardHolderName' => 'firstname lastname', - 'billingAddress' => [ - 'streetAddress' => 'street', - 'city' => $billingAddress->getCity(), - 'provinceCode' => $billingAddress->getRegionCode(), - 'postalCode' => $billingAddress->getPostcode(), - 'countryCode' => $billingAddress->getCountryId(), - 'unit' => '' - ] - ], - 'seller' => $this->getSellerData(), - 'platformAndClient' => [ - 'storePlatform' => $productMetadata->getName() . ' ' . $productMetadata->getEdition(), - 'storePlatformVersion' => $productMetadata->getVersion(), - 'signifydClientApp' => $productMetadata->getName(), - 'signifydClientAppVersion' => '1.0' - ] - ]; - - self::assertEquals( - $expected, - $this->caseBuilder->build($order->getEntityId()) - ); - } - - /** - * Return seller data according to fixture - * - * @return array - */ - private function getSellerData() - { - return [ - 'name' => 'Sample Store', - 'domain' => 'm2.com', - 'shipFromAddress' => [ - 'streetAddress' => '6161 West Centinela Avenue', - 'unit' => 'app. 111', - 'city' => 'Culver City', - 'provinceCode' => 'AE', - 'postalCode' => '90230', - 'countryCode' => 'US', - ], - 'corporateAddress' => [ - 'streetAddress' => '5th Avenue', - 'unit' => '75', - 'city' => 'New York', - 'provinceCode' => 'MH', - 'postalCode' => '19032', - 'countryCode' => 'US', - ], - ]; - } - - /** - * Format date in ISO8601 - * - * @param string $date - * @return string - */ - private function formatDate($date) - { - $result = $this->dateTimeFactory->create( - $date, - new \DateTimeZone('UTC') - ); - - return $result->format(\DateTime::ATOM); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php deleted file mode 100644 index e547187be5ed7..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php +++ /dev/null @@ -1,218 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Observer; - -use Magento\Framework\Api\SearchCriteriaBuilder; -use Magento\Framework\App\ObjectManager; -use Magento\Framework\Event; -use Magento\Framework\Event\Observer; -use Magento\Sales\Api\Data\OrderInterface; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\Signifyd\Api\CaseCreationServiceInterface; -use Magento\Store\Api\StoreRepositoryInterface; -use Magento\Store\Model\StoreManagerInterface; -use Magento\TestFramework\Helper\Bootstrap; -use PHPUnit\Framework\MockObject_MockObject as MockObject; -use Psr\Log\LoggerInterface; - -/** - * Test for Magento\Signifyd\Observer\PlaceOrderTest class. - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class PlaceOrderTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var CaseCreationServiceInterface|MockObject - */ - private $creationService; - - /** - * @var LoggerInterface|MockObject - */ - private $logger; - - /** - * @var PlaceOrder - */ - private $placeOrder; - - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->objectManager = Bootstrap::getObjectManager(); - - $this->creationService = $this->getMockBuilder(CaseCreationServiceInterface::class) - ->disableOriginalConstructor() - ->setMethods(['createForOrder']) - ->getMock(); - - $this->logger = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->placeOrder = $this->objectManager->create(PlaceOrder::class, [ - 'caseCreationService' => $this->creationService, - 'logger' => $this->logger - ]); - } - - /** - * Checks a case when order placed with offline payment method. - * - * @covers \Magento\Signifyd\Observer\PlaceOrder::execute - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php - */ - public function testExecuteWithOfflinePayment() - { - $order = $this->getOrder('100000005'); - $this->creationService->expects(self::never()) - ->method('createForOrder'); - - $event = $this->objectManager->create( - Event::class, - [ - 'data' => ['order' => $order] - ] - ); - - /** @var Observer $observer */ - $observer = $this->objectManager->get(Observer::class); - $observer->setEvent($event); - - $this->placeOrder->execute($observer); - } - - /** - * Checks a test case when order placed with online payment method. - * - * @covers \Magento\Signifyd\Observer\PlaceOrder::execute - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php - */ - public function testExecute() - { - $order = $this->getOrder('100000001'); - - $this->creationService->expects(self::once()) - ->method('createForOrder') - ->with(self::equalTo($order->getEntityId())); - - $event = $this->objectManager->create( - Event::class, - [ - 'data' => ['order' => $order], - ] - ); - - /** @var Observer $observer */ - $observer = $this->objectManager->get(Observer::class); - $observer->setEvent($event); - - $this->placeOrder->execute($observer); - } - - /** - * Signifyd is enabled for default store. - * Checks a test case when order placed with website where signifyd is disabled. - * - * @return void - * @covers \Magento\Signifyd\Observer\PlaceOrder::execute - * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php - * @magentoDataFixture Magento/Signifyd/_files/website_configuration.php - */ - public function testExecuteWithWebsiteConfiguration(): void - { - /** @var StoreRepositoryInterface $storeRepository */ - $storeRepository = $this->objectManager->get(StoreRepositoryInterface::class); - $store = $storeRepository->get('test_second_store'); - - /** @var StoreManagerInterface $storeManager */ - $storeManager = $this->objectManager->get(StoreManagerInterface::class); - $storeManager->setCurrentStore($store->getId()); - - $order = $this->getOrder('100000001'); - $order->setStoreId($store->getId()); - - $this->creationService->expects(self::never()) - ->method('createForOrder'); - - $event = $this->objectManager->create( - Event::class, - [ - 'data' => ['order' => $order], - ] - ); - - /** @var Observer $observer */ - $observer = $this->objectManager->get(Observer::class); - $observer->setEvent($event); - - $this->placeOrder->execute($observer); - } - - /** - * Checks a test case when observer event contains two orders: - * one order with offline payment and one order with online payment. - * - * @covers \Magento\Signifyd\Observer\PlaceOrder::execute - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php - */ - public function testExecuteWithMultipleOrders() - { - $orderWithOnlinePayment = $this->getOrder('100000001'); - $orderWithOfflinePayment = $this->getOrder('100000005'); - - // this service mock should be called only once for the order with online payment method. - $this->creationService->expects(self::once()) - ->method('createForOrder') - ->with(self::equalTo($orderWithOnlinePayment->getEntityId())); - - $event = $this->objectManager->create( - Event::class, - [ - 'data' => ['orders' => [$orderWithOfflinePayment, $orderWithOnlinePayment]] - ] - ); - - /** @var Observer $observer */ - $observer = $this->objectManager->get(Observer::class); - $observer->setEvent($event); - - $this->placeOrder->execute($observer); - } - - /** - * Gets stored order. - * - * @param string $incrementId - * @return OrderInterface - */ - private function getOrder($incrementId) - { - /** @var SearchCriteriaBuilder $searchCriteriaBuilder */ - $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class); - $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, $incrementId) - ->create(); - - $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); - $orders = $orderRepository->getList($searchCriteria) - ->getItems(); - - $order = array_pop($orders); - - return $order; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php deleted file mode 100644 index 7c1af95bdb89c..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Plugin; - -use Magento\Framework\Api\SearchCriteriaBuilder; -use Magento\Sales\Api\Data\OrderInterface; -use Magento\Sales\Api\OrderManagementInterface; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Model\SignifydGateway\ApiClient; -use Magento\TestFramework\Helper\Bootstrap; -use Magento\TestFramework\ObjectManager; -use PHPUnit\Framework\MockObject_MockObject as MockObject; - -class CancelOrderTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var int - */ - private static $caseId = 123; - - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var ApiClient|MockObject - */ - private $apiClient; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->objectManager = Bootstrap::getObjectManager(); - - $this->apiClient = $this->getMockBuilder(ApiClient::class) - ->disableOriginalConstructor() - ->setMethods(['makeApiCall']) - ->getMock(); - - $this->objectManager->addSharedInstance($this->apiClient, ApiClient::class); - } - - /** - * @inheritdoc - */ - protected function tearDown() - { - $this->objectManager->removeSharedInstance(ApiClient::class); - } - - /** - * Checks a test case, when order has been cancelled - * and calls plugin to cancel Signifyd case guarantee. - * - * @covers \Magento\Signifyd\Plugin\OrderPlugin::afterCancel - * @magentoDataFixture Magento/Signifyd/_files/approved_case.php - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - */ - public function testAfterCancel() - { - $order = $this->getOrder(); - - $this->apiClient->expects(self::once()) - ->method('makeApiCall') - ->with( - self::equalTo('/cases/' . self::$caseId . '/guarantee'), - 'PUT', - [ - 'guaranteeDisposition' => CaseInterface::GUARANTEE_CANCELED - ] - ) - ->willReturn([ - 'disposition' => CaseInterface::GUARANTEE_CANCELED - ]); - - /** @var OrderManagementInterface $orderService */ - $orderService = $this->objectManager->get(OrderManagementInterface::class); - $orderService->cancel($order->getEntityId()); - - /** @var CaseRepositoryInterface $caseRepository */ - $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class); - $case = $caseRepository->getByCaseId(self::$caseId); - - self::assertEquals(CaseInterface::GUARANTEE_CANCELED, $case->getGuaranteeDisposition()); - } - - /** - * Get stored order. - * - * @return OrderInterface - */ - private function getOrder() - { - /** @var SearchCriteriaBuilder $searchCriteriaBuilder */ - $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class); - $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001') - ->create(); - - $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); - $orders = $orderRepository->getList($searchCriteria) - ->getItems(); - - /** @var OrderInterface $order */ - return array_pop($orders); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php deleted file mode 100644 index 72da71a630dff..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php +++ /dev/null @@ -1,209 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Signifyd\Plugin; - -use Magento\Framework\Api\SearchCriteriaBuilder; -use Magento\Framework\Registry; -use Magento\Payment\Model\Info as PaymentInfo; -use Magento\Paypal\Model\Api\Nvp; -use Magento\Paypal\Model\Config; -use Magento\Paypal\Model\Express; -use Magento\Paypal\Model\Info; -use Magento\Paypal\Model\Pro; -use Magento\Paypal\Model\ProFactory; -use Magento\Sales\Api\Data\OrderInterface; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Model\SignifydGateway\ApiClient; -use Magento\TestFramework\Helper\Bootstrap; -use Magento\TestFramework\ObjectManager; -use PHPUnit\Framework\MockObject_MockObject as MockObject; - -/** - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class DenyPaymentTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var int - */ - private static $caseId = 123; - - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var ApiClient|MockObject - */ - private $apiClient; - - /** - * @var Registry - */ - private $registry; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->objectManager = Bootstrap::getObjectManager(); - - $this->apiClient = $this->getMockBuilder(ApiClient::class) - ->disableOriginalConstructor() - ->setMethods(['makeApiCall']) - ->getMock(); - - $this->registry = $this->objectManager->get(Registry::class); - - $this->objectManager->addSharedInstance($this->apiClient, ApiClient::class); - } - - /** - * @inheritdoc - */ - protected function tearDown() - { - $this->objectManager->removeSharedInstance(ApiClient::class); - } - - /** - * Checks a test case, when payment has been denied - * and calls plugin to cancel Signifyd case guarantee. - * - * @covers \Magento\Signifyd\Plugin\PaymentPlugin::afterDenyPayment - * @magentoDataFixture Magento/Signifyd/_files/approved_case.php - * @magentoConfigFixture current_store fraud_protection/signifyd/active 1 - */ - public function testAfterDenyPayment() - { - $order = $this->getOrder(); - $this->registry->register('current_order', $order); - - $this->apiClient->expects(self::once()) - ->method('makeApiCall') - ->with( - self::equalTo('/cases/' . self::$caseId . '/guarantee'), - 'PUT', - [ - 'guaranteeDisposition' => CaseInterface::GUARANTEE_CANCELED - ] - ) - ->willReturn([ - 'disposition' => CaseInterface::GUARANTEE_CANCELED - ]); - - /** @var \Magento\Sales\Model\Order\Payment $payment */ - $payment = $order->getPayment(); - $payment->setData('method_instance', $this->getMethodInstance()); - $payment->deny(); - - /** @var CaseRepositoryInterface $caseRepository */ - $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class); - $case = $caseRepository->getByCaseId(self::$caseId); - - self::assertEquals(CaseInterface::GUARANTEE_CANCELED, $case->getGuaranteeDisposition()); - } - - /** - * Get stored order. - * - * @return OrderInterface - */ - private function getOrder() - { - /** @var SearchCriteriaBuilder $searchCriteriaBuilder */ - $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class); - $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001') - ->create(); - - $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); - $orders = $orderRepository->getList($searchCriteria) - ->getItems(); - - /** @var OrderInterface $order */ - return array_pop($orders); - } - - /** - * Gets payment method instance. - * - * @return Express - */ - private function getMethodInstance() - { - /** @var PaymentInfo $infoInstance */ - $infoInstance = $this->objectManager->get(PaymentInfo::class); - $infoInstance->setAdditionalInformation( - Info::PAYMENT_STATUS_GLOBAL, - Info::PAYMENTSTATUS_PENDING - ); - $infoInstance->setAdditionalInformation( - Info::PENDING_REASON_GLOBAL, - Info::PAYMENTSTATUS_PENDING - ); - - /** @var Express $methodInstance */ - $methodInstance = $this->objectManager->create( - Express::class, - ['proFactory' => $this->getProFactory()] - ); - $methodInstance->setData('info_instance', $infoInstance); - - return $methodInstance; - } - - /** - * Gets Pro factory mock. - * - * @return ProFactory|MockObject - */ - protected function getProFactory() - { - $pro = $this->getMockBuilder(Pro::class) - ->disableOriginalConstructor() - ->setMethods(['getApi', 'setMethod', 'getConfig', '__wakeup', 'reviewPayment']) - ->getMock(); - $nvpClient = $this->getMockBuilder(Nvp::class) - ->disableOriginalConstructor() - ->getMock(); - - $pro->method('getConfig') - ->willReturn($this->getConfig()); - $pro->method('getApi') - ->willReturn($nvpClient); - $pro->method('reviewPayment') - ->willReturn(true); - - $proFactory = $this->getMockBuilder(ProFactory::class) - ->disableOriginalConstructor() - ->getMock(); - $proFactory->method('create') - ->willReturn($pro); - - return $proFactory; - } - - /** - * Gets config mock. - * - * @return Config|MockObject - */ - protected function getConfig() - { - $config = $this->getMockBuilder(Config::class) - ->disableOriginalConstructor() - ->getMock(); - $config->method('getValue') - ->with('payment_action') - ->willReturn(Config::PAYMENT_ACTION_AUTH); - - return $config; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/approved_case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/approved_case.php deleted file mode 100644 index eaa3622c04e0e..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/approved_case.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Api\Data\CaseInterfaceFactory; - -require __DIR__ . '/order_with_customer_and_two_simple_products.php'; - -/** @var CaseInterfaceFactory $caseFactory */ -$caseFactory = $objectManager->get(CaseInterfaceFactory::class); - -$associatedTeam = [ - 'teamName' => 'Some Team', - 'teamId' => 123, - 'getAutoDismiss' => true, - 'getTeamDismissalDays' => 3 -]; - -/** @var CaseInterface $case */ -$case = $caseFactory->create(); -$case->setCaseId(123) - ->setGuaranteeEligible(false) - ->setGuaranteeDisposition(CaseInterface::GUARANTEE_APPROVED) - ->setStatus(CaseInterface::STATUS_PROCESSING) - ->setScore(553) - ->setOrderId($order->getEntityId()) - ->setAssociatedTeam($associatedTeam) - ->setReviewDisposition(CaseInterface::DISPOSITION_GOOD) - ->setCreatedAt('2016-12-12T15:17:17+0000') - ->setUpdatedAt('2016-12-12T19:23:16+0000'); - -/** @var CaseRepositoryInterface $caseRepository */ -$caseRepository = $objectManager->get(CaseRepositoryInterface::class); -$caseRepository->save($case); diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php deleted file mode 100644 index 4102233f6fb1f..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -use Magento\Sales\Api\OrderManagementInterface; -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Api\Data\CaseInterfaceFactory; - -require __DIR__ . '/order_with_customer_and_two_simple_products.php'; - -/** @var OrderManagementInterface $orderManagement */ -$orderManagement = $objectManager->create(OrderManagementInterface::class); -$orderManagement->hold($order->getEntityId()); - -/** @var CaseInterfaceFactory $caseFactory */ -$caseFactory = $objectManager->get(CaseInterfaceFactory::class); - -$associatedTeam = [ - 'teamName' => 'Some Team', - 'teamId' => 123, - 'getAutoDismiss' => true, - 'getTeamDismissalDays' => 3 -]; - -/** @var CaseInterface $case */ -$case = $caseFactory->create(); -$case->setCaseId(123) - ->setGuaranteeEligible(true) - ->setStatus(CaseInterface::STATUS_PROCESSING) - ->setScore(553) - ->setOrderId($order->getEntityId()) - ->setAssociatedTeam($associatedTeam) - ->setReviewDisposition(CaseInterface::DISPOSITION_GOOD) - ->setGuaranteeDisposition(CaseInterface::GUARANTEE_PENDING) - ->setCreatedAt('2016-12-12T15:17:17+0000') - ->setUpdatedAt('2016-12-12T19:23:16+0000'); - -/** @var CaseRepositoryInterface $caseRepository */ -$caseRepository = $objectManager->get(CaseRepositoryInterface::class); -$caseRepository->save($case); diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/customer.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/customer.php deleted file mode 100644 index 7c5f34cd203fa..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/customer.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -use Magento\Customer\Model\Customer; -use Magento\TestFramework\Helper\Bootstrap; -use Magento\Customer\Api\Data\CustomerInterface; -use Magento\Customer\Model\CustomerRegistry; - -$objectManager = Bootstrap::getObjectManager(); -/** @var CustomerRegistry $customerRegistry */ -$customerRegistry = $objectManager->get(CustomerRegistry::class); -$customer = $objectManager->create(Customer::class); - -/** @var CustomerInterface $customer */ -$customer->setWebsiteId(1) - ->setId(1) - ->setEmail('customer@example.com') - ->setGroupId(1) - ->setStoreId(1) - ->setPrefix('Mr.') - ->setFirstname('John') - ->setMiddlename('A') - ->setLastname('Smith') - ->setSuffix('Esq.') - ->setDefaultBilling(1) - ->setDefaultShipping(1) - ->setTaxvat('12') - ->setGender(0) - ->setCreatedAt('2016-12-12T11:00:00+0000') - ->setUpdatedAt('2016-12-12T11:05:00+0000'); - -$customer->isObjectNew(true); -$customer->save(); - -$customerRegistry->remove($customer->getId()); diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/declined_case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/declined_case.php deleted file mode 100644 index 041cdb0291d83..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/declined_case.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -use Magento\Signifyd\Api\CaseRepositoryInterface; -use Magento\Signifyd\Api\Data\CaseInterface; -use Magento\Signifyd\Api\Data\CaseInterfaceFactory; - -require __DIR__ . '/order_with_customer_and_two_simple_products.php'; - -/** @var CaseInterfaceFactory $caseFactory */ -$caseFactory = $objectManager->get(CaseInterfaceFactory::class); - -$associatedTeam = [ - 'teamName' => 'Some Team', - 'teamId' => 123, - 'getAutoDismiss' => true, - 'getTeamDismissalDays' => 3 -]; - -/** @var CaseInterface $case */ -$case = $caseFactory->create(); -$case->setCaseId(123) - ->setGuaranteeEligible(false) - ->setGuaranteeDisposition(CaseInterface::GUARANTEE_DECLINED) - ->setStatus(CaseInterface::STATUS_PROCESSING) - ->setScore(553) - ->setOrderId($order->getEntityId()) - ->setAssociatedTeam($associatedTeam) - ->setReviewDisposition(CaseInterface::DISPOSITION_FRAUDULENT) - ->setCreatedAt('2016-12-12T15:17:17+0000') - ->setUpdatedAt('2016-12-12T19:23:16+0000'); - -/** @var CaseRepositoryInterface $caseRepository */ -$caseRepository = $objectManager->get(CaseRepositoryInterface::class); -$caseRepository->save($case); diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/multiple_cases.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/multiple_cases.php deleted file mode 100644 index 4930906954148..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/multiple_cases.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -use Magento\Signifyd\Api\Data\CaseInterface; - -require __DIR__ . '/case.php'; - -for ($i = 1; $i < 4; $i ++) { - $newOrder = clone $order; - $newOrder->setEntityId(null) - ->setIncrementId($order->getIncrementId() + $i); - - $orderRepository->save($newOrder); - - $newCase = clone $case; - $newCase->setEntityId(null) - ->setCaseId($i) - ->setOrderId($newOrder->getEntityId()) - ->setStatus(CaseInterface::STATUS_OPEN) - ->setCreatedAt('2016-12-0' . $i . 'T15:' . $i . ':17+0000') - ->setUpdatedAt('2016-12-12T0' . $i . ':23:16+0000') - ->setId(null); - - $caseRepository->save($newCase); -} diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php deleted file mode 100644 index 49a0a2d33e236..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -use Magento\Sales\Model\Order; -use Magento\Sales\Model\Order\Payment; -use Magento\Sales\Model\Order\Address; -use Magento\Sales\Model\Order\Item; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\TestFramework\Helper\Bootstrap; - -require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php'; -require __DIR__ . '/../../../Magento/Customer/_files/customer.php'; -require __DIR__ . '/store.php'; - -$addressData = include __DIR__ . '/../../../Magento/Sales/_files/address_data.php'; - -$objectManager = Bootstrap::getObjectManager(); - -$billingAddress = $objectManager->create(Address::class, ['data' => $addressData]); -$billingAddress->setAddressType('billing'); - -$shippingAddress = clone $billingAddress; -$shippingAddress->setId(null) - ->setAddressType('shipping') - ->setStreet(['6161 West Centinela Avenue', 'app. 33']) - ->setFirstname('John') - ->setLastname('Doe') - ->setShippingMethod('flatrate_flatrate'); - -$payment = $objectManager->create(Payment::class); -$payment->setMethod('paypal_express') - ->setLastTransId('00001') - ->setCcLast4('1234') - ->setCcExpMonth('01') - ->setCcExpYear('21'); - -/** @var Item $orderItem */ -$orderItem1 = $objectManager->create(Item::class); -$orderItem1->setProductId($product->getId()) - ->setSku($product->getSku()) - ->setName($product->getName()) - ->setQtyOrdered(1) - ->setBasePrice($product->getPrice()) - ->setPrice($product->getPrice()) - ->setRowTotal($product->getPrice()) - ->setProductType($product->getTypeId()); - -/** @var Item $orderItem */ -$orderItem2 = $objectManager->create(Item::class); -$orderItem2->setProductId($product->getId()) - ->setSku('simple2') - ->setName('Simple product') - ->setPrice(100) - ->setQtyOrdered(2) - ->setBasePrice($product->getPrice()) - ->setPrice($product->getPrice()) - ->setRowTotal($product->getPrice()) - ->setProductType($product->getTypeId()); - -$orderAmount = 100; -$customerEmail = $billingAddress->getEmail(); - -/** @var Order $order */ -$order = $objectManager->create(Order::class); -$order->setIncrementId('100000001') - ->setState(Order::STATE_PROCESSING) - ->setStatus(Order::STATE_PROCESSING) - ->setCustomerId($customer->getId()) - ->setCustomerIsGuest(false) - ->setRemoteIp('127.0.0.1') - ->setCreatedAt(date('Y-m-d 00:00:55')) - ->setOrderCurrencyCode('USD') - ->setBaseCurrencyCode('USD') - ->setSubtotal($orderAmount) - ->setGrandTotal($orderAmount) - ->setBaseSubtotal($orderAmount) - ->setBaseGrandTotal($orderAmount) - ->setCustomerEmail($customerEmail) - ->setBillingAddress($billingAddress) - ->setShippingAddress($shippingAddress) - ->setShippingDescription('Flat Rate - Fixed') - ->setShippingAmount(10) - ->setStoreId($store->getId()) - ->addItem($orderItem1) - ->addItem($orderItem2) - ->setPayment($payment) - ->setQuoteId(1); - -/** @var OrderRepositoryInterface $orderRepository */ -$orderRepository = $objectManager->get(OrderRepositoryInterface::class); -$orderRepository->save($order); - -$orderAmount2 = 50; -$payment2 = $objectManager->create(Payment::class); -$payment2->setMethod('checkmo'); -/** @var Order $order2 */ -$order2 = $objectManager->create(Order::class); -$order2->setIncrementId('100000005') - ->setCustomerId($customer->getId()) - ->setCustomerIsGuest(false) - ->setRemoteIp('127.0.0.1') - ->setCreatedAt('2016-12-12T12:00:55+0000') - ->setOrderCurrencyCode('USD') - ->setBaseCurrencyCode('USD') - ->setGrandTotal($orderAmount2) - ->setBaseGrandTotal($orderAmount2) - ->setCustomerEmail($customerEmail) - ->setBillingAddress($billingAddress) - ->setShippingAddress($shippingAddress) - ->setShippingDescription('Flat Rate - Fixed') - ->setShippingAmount(10) - ->setStoreId($store->getId()) - ->addItem($orderItem1) - ->setPayment($payment2) - ->setQuoteId(2); - -$orderRepository->save($order2); diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php deleted file mode 100644 index ba0e92687dc17..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -use Magento\Sales\Model\Order; -use Magento\Sales\Model\Order\Payment; -use Magento\Sales\Model\Order\Address; -use Magento\Sales\Model\Order\Item; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\TestFramework\Helper\Bootstrap; -use Magento\Sales\Api\Data\OrderPaymentInterface; - -require __DIR__ . '/../../../Magento/Catalog/_files/product_virtual.php'; -require __DIR__ . '/store.php'; -$addressData = include __DIR__ . '/../../../Magento/Sales/_files/address_data.php'; - -$objectManager = Bootstrap::getObjectManager(); - -$billingAddress = $objectManager->create(Address::class, ['data' => $addressData]); -$billingAddress->setAddressType('billing'); - -/** @var OrderPaymentInterface $payment */ -$payment = $objectManager->create(Payment::class); -$payment->setMethod('braintree') - ->setLastTransId('00001') - ->setAdditionalInformation('avsPostalCodeResponseCode', 'M') - ->setAdditionalInformation('avsStreetAddressResponseCode', 'M') - ->setAdditionalInformation('cvvResponseCode', 'M'); - -/** @var Item $orderItem */ -$orderItem1 = $objectManager->create(Item::class); -$orderItem1->setProductId($product->getId()) - ->setSku($product->getSku()) - ->setName($product->getName()) - ->setQtyOrdered(1) - ->setBasePrice($product->getPrice()) - ->setPrice($product->getPrice()) - ->setRowTotal($product->getPrice()) - ->setProductType($product->getTypeId()); - -$orderAmount = 100; -$customerEmail = $billingAddress->getEmail(); - -/** @var Order $order */ -$order = $objectManager->create(Order::class); -$order->setIncrementId('100000002') - ->setState(Order::STATE_PROCESSING) - ->setStatus(Order::STATE_PROCESSING) - ->setCustomerIsGuest(true) - ->setRemoteIp('127.0.0.1') - ->setCreatedAt('2016-12-12T12:00:55+0000') - ->setOrderCurrencyCode('USD') - ->setBaseCurrencyCode('USD') - ->setSubtotal($orderAmount) - ->setGrandTotal($orderAmount) - ->setBaseSubtotal($orderAmount) - ->setBaseGrandTotal($orderAmount) - ->setCustomerEmail($customerEmail) - ->setBillingAddress($billingAddress) - ->setStoreId($store->getId()) - ->addItem($orderItem1) - ->setPayment($payment) - ->setQuoteId(1); - -/** @var OrderRepositoryInterface $orderRepository */ -$orderRepository = $objectManager->get(OrderRepositoryInterface::class); -$orderRepository->save($order); diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php deleted file mode 100644 index b814263bdc5ef..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -use Magento\Store\Model\Store; -use Magento\Store\Model\Information; -use Magento\Store\Model\ScopeInterface; -use Magento\Store\Model\StoreManagerInterface; -use Magento\Sales\Model\Order\Shipment; -use Magento\Framework\App\Config\MutableScopeConfigInterface; -use Magento\TestFramework\Helper\Bootstrap; - -$objectManager = Bootstrap::getObjectManager(); -$store = $objectManager->get(StoreManagerInterface::class)->getStore(); -/** @var MutableScopeConfigInterface $mutableConfig */ -$mutableConfig = $objectManager->get(MutableScopeConfigInterface::class); -$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_NAME, 'Sample Store', ScopeInterface::SCOPE_STORE); -$mutableConfig->setValue(Store::XML_PATH_UNSECURE_BASE_LINK_URL, 'http://m2.com/', ScopeInterface::SCOPE_STORE); -$mutableConfig->setValue(Shipment::XML_PATH_STORE_ADDRESS1, '6161 West Centinela Avenue', ScopeInterface::SCOPE_STORE); -$mutableConfig->setValue(Shipment::XML_PATH_STORE_ADDRESS2, 'app. 111', ScopeInterface::SCOPE_STORE); -$mutableConfig->setValue(Shipment::XML_PATH_STORE_CITY, 'Culver City', ScopeInterface::SCOPE_STORE); -$mutableConfig->setValue(Shipment::XML_PATH_STORE_REGION_ID, 10, ScopeInterface::SCOPE_STORE); -$mutableConfig->setValue(Shipment::XML_PATH_STORE_ZIP, '90230', ScopeInterface::SCOPE_STORE); -$mutableConfig->setValue(Shipment::XML_PATH_STORE_COUNTRY_ID, 'US', ScopeInterface::SCOPE_STORE); - -$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_STREET_LINE1, '5th Avenue', ScopeInterface::SCOPE_STORE); -$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_STREET_LINE2, '75', ScopeInterface::SCOPE_STORE); -$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_CITY, 'New York', ScopeInterface::SCOPE_STORE); -$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_REGION_CODE, 30, ScopeInterface::SCOPE_STORE); -$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_POSTCODE, '19032', ScopeInterface::SCOPE_STORE); -$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_COUNTRY_CODE, 'US', ScopeInterface::SCOPE_STORE); diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/webhook_body.json b/dev/tests/integration/testsuite/Magento/Signifyd/_files/webhook_body.json deleted file mode 100644 index 4308c8bf833ef..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/webhook_body.json +++ /dev/null @@ -1 +0,0 @@ -{"investigationId":123,"analysisUrl":"https://signifyd.com/v2/cases/185088720/analysis","entriesUrl":"https://signifyd.com/v2/cases/185088720/entries","notesUrl":"https://signifyd.com/v2/cases/185088720/notes","orderUrl":"https://signifyd.com/v2/cases/185088720/order","currency":"USD","uuid":"368df42c-d25f-44ef-a1d9-92755f743901","createdAt":"2017-01-06T12:47:03+0000","updatedAt":"2017-01-06T12:47:03+0000","status":"OPEN","caseId":123,"score":384,"headline":"John Doe","orderId":"000000003","adjustedScore":385,"orderDate":"2017-01-06T12:46:58+0000","orderAmount":5.85,"orderOutcome":"SUCCESSFUL","associatedTeam":{"teamName":"Magento","teamId":7940},"testInvestigation":true,"reviewDisposition":null} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/website_configuration.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/website_configuration.php deleted file mode 100644 index e53b0431503e7..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/website_configuration.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -use Magento\Config\Model\Config; -use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Store\Model\ResourceModel\Store as StoreResourceModel; -use Magento\Store\Model\ResourceModel\Website as WebsiteResourceModel; -use Magento\Store\Model\ScopeInterface; -use Magento\Store\Model\Store; -use Magento\Store\Model\StoreManagerInterface; -use Magento\Store\Model\Website; -use Magento\TestFramework\Helper\Bootstrap; - -$objectManager = Bootstrap::getObjectManager(); - -/** @var $website Website */ -$website = $objectManager->create(Website::class); -$website->setData(['code' => 'test_website', 'name' => 'Test Website', 'default_group_id' => '1', 'is_default' => '0']); -$websiteResourceModel = $objectManager->create(WebsiteResourceModel::class); -$websiteResourceModel->save($website); - -$websiteId = $website->getId(); -$store = $objectManager->create(Store::class); -$groupId = Bootstrap::getObjectManager()->get(StoreManagerInterface::class) - ->getWebsite() - ->getDefaultGroupId(); -$store->setCode('test_second_store') - ->setWebsiteId($websiteId) - ->setGroupId($groupId) - ->setName('Test Second Store') - ->setSortOrder(10) - ->setIsActive(1); -$storeResourceModel = $objectManager->create(StoreResourceModel::class); -$storeResourceModel->save($store); - -/* Refresh stores memory cache */ -$objectManager->get(StoreManagerInterface::class)->reinitStores(); - -$processConfigData = function (Config $config, array $data) { - foreach ($data as $key => $value) { - $config->setDataByPath($key, $value); - $config->save(); - } -}; - -// save signifyd configuration for the default scope -$configData = [ - 'fraud_protection/signifyd/active' => '1', -]; -/** @var Config $defConfig */ -$defConfig = $objectManager->create(Config::class); -$defConfig->setScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT); -$processConfigData($defConfig, $configData); - -// save signifyd website config data -$websiteConfigData = [ - 'fraud_protection/signifyd/active' => '0', -]; -/** @var Config $websiteConfig */ -$websiteConfig = $objectManager->create(Config::class); -$websiteConfig->setScope(ScopeInterface::SCOPE_WEBSITES); -$websiteConfig->setWebsite($websiteId); -$processConfigData($websiteConfig, $websiteConfigData); diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/website_configuration_rollback.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/website_configuration_rollback.php deleted file mode 100644 index 9b731813fea3b..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/website_configuration_rollback.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Framework\App\Config\Storage\WriterInterface; -use Magento\Store\Api\WebsiteRepositoryInterface; -use Magento\Store\Model\ScopeInterface; -use Magento\Store\Model\Store; -use Magento\Store\Model\Website; -use Magento\TestFramework\Helper\Bootstrap; - -$objectManager = Bootstrap::getObjectManager(); - -$deleteConfigData = function (WriterInterface $writer, $scope, $scopeId) { - $configData = [ - 'fraud_protection/signifyd/active', - ]; - foreach ($configData as $path) { - $writer->delete($path, $scope, $scopeId); - } -}; - -/** @var WriterInterface $configWriter */ -$configWriter = $objectManager->get(WriterInterface::class); -$deleteConfigData($configWriter, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null); - -/** @var WebsiteRepositoryInterface $websiteRepository */ -$websiteRepository = $objectManager->get(WebsiteRepositoryInterface::class); -$website = $websiteRepository->get('test_website'); -$deleteConfigData($configWriter, ScopeInterface::SCOPE_WEBSITES, $website->getId()); - -$website = $objectManager->create(Website::class); -/** @var $website Website */ -if ($website->load('test_website', 'code')->getId()) { - $website->delete(); -} -$store = $objectManager->create(Store::class); -if ($store->load('test_second_store', 'code')->getId()) { - $store->delete(); -} diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/_files/skip_blocks_ce.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/_files/skip_blocks_ce.php index 229207aa03899..7a8f04d0160ff 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/_files/skip_blocks_ce.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/_files/skip_blocks_ce.php @@ -20,5 +20,6 @@ // Fails because of dependence on registry \Magento\Reminder\Block\Adminhtml\Reminder\Edit\Tab\Customers::class, \Magento\LayeredNavigation\Block\Navigation::class, - \Magento\LayeredNavigation\Block\Navigation\State::class + \Magento\LayeredNavigation\Block\Navigation\State::class, + \Magento\Paypal\Block\Express\InContext\Minicart\Button::class, ]; diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/_files/skip_template_blocks_ce.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/_files/skip_template_blocks_ce.php index 91d74b0908078..1edb23738820f 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/_files/skip_template_blocks_ce.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/_files/skip_template_blocks_ce.php @@ -12,4 +12,5 @@ \Magento\Reminder\Block\Adminhtml\Reminder\Edit\Tab\Customers::class, \Magento\LayeredNavigation\Block\Navigation::class, \Magento\LayeredNavigation\Block\Navigation\State::class, + \Magento\Paypal\Block\Express\InContext\Minicart\Button::class, ]; diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js deleted file mode 100644 index a9d9fe8d08047..0000000000000 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -define([ - 'jquery' -], function ($) { - 'use strict'; - - /*eslint max-nested-callbacks: ["error", 5]*/ - describe('Signifyd device fingerprint client script', function () { - var originalTimeout; - - beforeEach(function () { - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 12000; - }); - - afterEach(function () { - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - }); - - it('SIGNIFYD_GLOBAL object initialization check', function (done) { - var script = document.createElement('script'); - - script.setAttribute('src', 'https://cdn-scripts.signifyd.com/api/script-tag.js'); - script.setAttribute('id', 'sig-api'); - script.setAttribute('type', 'text/javascript'); - script.setAttribute('async', ''); - script.setAttribute('data-order-session-id', 'mage-jasmin-test'); - - $(document.body).append(script); - - setTimeout(function () { - var signifyd = window.SIGNIFYD_GLOBAL; - - expect(signifyd).toBeDefined(); - expect(typeof signifyd).toBe('object'); - expect(signifyd.scriptTagHasLoaded).toBeDefined(); - expect(typeof signifyd.scriptTagHasLoaded).toBe('function'); - expect(signifyd.scriptTagHasLoaded()).toBe(true); - done(); - }, 10000); - }); - }); -}); diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/exception_hierarchy.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/exception_hierarchy.txt index 8eb3392476400..195c88274ae4a 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/exception_hierarchy.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/exception_hierarchy.txt @@ -10,6 +10,4 @@ \Magento\Framework\DB\DataConverter\DataConversionException \Magento\Framework\DB\FieldDataConversionException \Magento\Catalog\Model\Product\Image\NotLoadInfoImageException -\Magento\Signifyd\Model\SignifydGateway\GatewayException -\Magento\Signifyd\Model\SignifydGateway\ApiCallException \Magento\Framework\MessageQueue\ConnectionLostException diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php index f2411cdad86de..168ac5cde16cb 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php @@ -201,4 +201,5 @@ ['Magento\MysqlMq\Model\Resource', 'Magento\MysqlMq\Model\ResourceModel'], ['Magento\BulkOperations', 'Magento\AsynchronousOperations'], ['Zend', 'Laminas'], + ['Magento\Signifyd'], ]; From c6fe33a2a0616189dfa0a08b00ab7342c69fae5a Mon Sep 17 00:00:00 2001 From: Myroslav Dobra <dmaraptor@gmail.com> Date: Fri, 27 Mar 2020 11:05:47 +0200 Subject: [PATCH 5/7] MC-32478: [TSG] [PR] Stabilization 2.4-develop-pr18 --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index 3b92c901aac8e..f3dff26fbcf88 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9e13134f3e209140ec6c43092c189da9", + "content-hash": "bf5e456936a97bb395035fb5eceab844", "packages": [ { "name": "braintree/braintree_php", @@ -9962,12 +9962,12 @@ }, "require-dev": { "predis/predis": "~1.0", - "symfony/expression-language": "^4.4|^5.0" + "symfony/expression-language": "^3.4|^4.0|^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -9994,7 +9994,7 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2020-01-04T13:00:46+00:00" + "time": "2020-02-13T19:40:01+00:00" }, { "name": "symfony/mime", From f9a0eb45426f09af6aa9350863b8f0f1f3ccea42 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra <dmaraptor@gmail.com> Date: Mon, 30 Mar 2020 09:18:00 +0300 Subject: [PATCH 6/7] MC-32478: [TSG] [PR] Stabilization 2.4-develop-pr18 --- composer.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index d3cdaa36326f6..550de1d904aec 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3b2c88252ab70b75998cb4e200257796", + "content-hash": "b801d92bd57ad3f2d51d2b264e9c37ac", "packages": [ { "name": "braintree/braintree_php", From 65543b405af358f63c3adef07e116b1cfac6da5c Mon Sep 17 00:00:00 2001 From: Myroslav Dobra <dmaraptor@gmail.com> Date: Tue, 31 Mar 2020 13:26:16 +0300 Subject: [PATCH 7/7] MC-32938: [Unit] Magento.Framework.Stdlib.Test.Unit.DateTime.DateTimeTest.testGtmOffset failed after Daylight Saving Time changed --- .../Framework/Stdlib/Test/Unit/DateTime/DateTimeTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeTest.php index 3c7f49671d74a..4f003c4b8ba10 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeTest.php @@ -50,7 +50,8 @@ public function testGtmOffset() { /** @var TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject $timezone */ $timezone = $this->getMockBuilder(TimezoneInterface::class)->getMock(); - $timezone->method('getConfigTimezone')->willReturn('Europe/Amsterdam'); + // Asia/Tbilisi timezone have no DST + $timezone->method('getConfigTimezone')->willReturn('Asia/Tbilisi'); /** @var DateTime|\PHPUnit_Framework_MockObject_MockObject $dateTime */ $dateTime = $this->getMockBuilder(DateTime::class) @@ -58,7 +59,7 @@ public function testGtmOffset() ->setMethods(null) ->getMock(); - $this->assertEquals(3600, $dateTime->getGmtOffset()); + $this->assertEquals(14400, $dateTime->getGmtOffset()); } /**