From 2008b357dc607084e6cae20a3d0d3dee07979578 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 12 Dec 2016 08:50:26 -0600
Subject: [PATCH 001/225] MAGETWO-61910: Create module and configuration
---
app/code/Magento/Signifyd/LICENSE.txt | 48 +++++++++++++++++++
app/code/Magento/Signifyd/LICENSE_AFL.txt | 48 +++++++++++++++++++
app/code/Magento/Signifyd/README.md | 1 +
app/code/Magento/Signifyd/composer.json | 22 +++++++++
app/code/Magento/Signifyd/etc/acl.xml | 22 +++++++++
.../Magento/Signifyd/etc/adminhtml/system.xml | 42 ++++++++++++++++
app/code/Magento/Signifyd/etc/config.xml | 15 ++++++
.../Magento/Signifyd/etc/frontend/routes.xml | 14 ++++++
app/code/Magento/Signifyd/etc/module.xml | 14 ++++++
app/code/Magento/Signifyd/registration.php | 11 +++++
composer.json | 1 +
11 files changed, 238 insertions(+)
create mode 100644 app/code/Magento/Signifyd/LICENSE.txt
create mode 100644 app/code/Magento/Signifyd/LICENSE_AFL.txt
create mode 100644 app/code/Magento/Signifyd/README.md
create mode 100644 app/code/Magento/Signifyd/composer.json
create mode 100644 app/code/Magento/Signifyd/etc/acl.xml
create mode 100644 app/code/Magento/Signifyd/etc/adminhtml/system.xml
create mode 100644 app/code/Magento/Signifyd/etc/config.xml
create mode 100644 app/code/Magento/Signifyd/etc/frontend/routes.xml
create mode 100644 app/code/Magento/Signifyd/etc/module.xml
create mode 100644 app/code/Magento/Signifyd/registration.php
diff --git a/app/code/Magento/Signifyd/LICENSE.txt b/app/code/Magento/Signifyd/LICENSE.txt
new file mode 100644
index 0000000000000..49525fd99da9c
--- /dev/null
+++ b/app/code/Magento/Signifyd/LICENSE.txt
@@ -0,0 +1,48 @@
+
+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
new file mode 100644
index 0000000000000..f39d641b18a19
--- /dev/null
+++ b/app/code/Magento/Signifyd/LICENSE_AFL.txt
@@ -0,0 +1,48 @@
+
+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/README.md b/app/code/Magento/Signifyd/README.md
new file mode 100644
index 0000000000000..3cd2b4a30a858
--- /dev/null
+++ b/app/code/Magento/Signifyd/README.md
@@ -0,0 +1 @@
+The Magento_Signifyd module implements the integration with the Signifyd fraud prevention service.
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
new file mode 100644
index 0000000000000..9f0c56a845f37
--- /dev/null
+++ b/app/code/Magento/Signifyd/composer.json
@@ -0,0 +1,22 @@
+{
+ "name": "magento/module-signifyd",
+ "description": "Submitting Case Entry to Signifyd on Order Creation",
+ "require": {
+ "php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
+ "magento/framework": "100.2.*",
+ "magento/module-sales": "100.2.*"
+ },
+ "type": "magento2-module",
+ "version": "100.2.0-dev",
+ "license": [
+ "proprietary"
+ ],
+ "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
new file mode 100644
index 0000000000000..ab6db0dce88c2
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/acl.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/system.xml b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
new file mode 100644
index 0000000000000..14ae7d73e0e48
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+ Fraud Protection
+ sales
+ Magento_Sales::fraud_protection
+
+ Signifyd
+
+ Enable this Solution
+ Magento\Config\Model\Config\Source\Yesno
+ fraud_protection/signifyd/active
+
+
+ API Key
+ http://signifyd.com/settings/teams after you create a Signifyd account]]>
+ fraud_protection/signifyd/api_key
+ Magento\Config\Model\Config\Backend\Encrypted
+
+
+ API URL
+ fraud_protection/signifyd/api_url
+
+ Don’t change unless asked to do so.
+
+
+
+ Debug
+ Magento\Config\Model\Config\Source\Yesno
+ fraud_protection/signifyd/debug
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/config.xml b/app/code/Magento/Signifyd/etc/config.xml
new file mode 100644
index 0000000000000..b16f0903c2d1f
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/config.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+ 0
+ https://api.signifiyd.com/v2/
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/frontend/routes.xml b/app/code/Magento/Signifyd/etc/frontend/routes.xml
new file mode 100644
index 0000000000000..8a6c5b4e22c1d
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/frontend/routes.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
new file mode 100644
index 0000000000000..1ee26044bbef4
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/registration.php b/app/code/Magento/Signifyd/registration.php
new file mode 100644
index 0000000000000..d7c40b5aa176a
--- /dev/null
+++ b/app/code/Magento/Signifyd/registration.php
@@ -0,0 +1,11 @@
+
Date: Fri, 9 Dec 2016 02:31:15 -0600
Subject: [PATCH 002/225] MAGETWO-61913: Create request builders
- Create builder interface
---
.../Model/Request/CreateCaseBuilder.php | 34 ++++++
.../Request/CreateCaseBuilderInterface.php | 20 ++++
.../Model/Request/PurchaseBuilder.php | 102 ++++++++++++++++++
3 files changed, 156 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
new file mode 100644
index 0000000000000..055f78aa401b9
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
@@ -0,0 +1,34 @@
+purchaseBuilder = $purchaseBuilder;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function build($orderId)
+ {
+ return $this->purchaseBuilder;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php
new file mode 100644
index 0000000000000..63a302509cf76
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php
@@ -0,0 +1,20 @@
+orderRepository = $orderRepository;
+ $this->dateTimeFactory = $dateTimeFactory;
+ $this->scope = $scope;
+ }
+
+ /**
+ * Returns purchase data params
+ *
+ * @param int $orderId
+ * @return array
+ */
+ public function build($orderId)
+ {
+ /** @var \Magento\Sales\Model\Order $order */
+ $order = $this->orderRepository->get($orderId);
+ $orderPayment = $order->getPayment();
+ $createdAt = $this->dateTimeFactory->create(
+ $order->getCreatedAt(),
+ new \DateTimeZone('UTC')
+ );
+
+
+ return [
+ 'purchase' => [
+ 'browserIpAddress' => $order->getRemoteIp(),
+ 'shipments' => [
+ 'shippingPrice' => $order->getShippingAmount()
+
+ ],
+ 'orderId' => $order->getEntityId(),
+ 'createdAt' => $createdAt->format(\DateTime::ISO8601),
+ 'paymentGateway' => $this->getPaymentGateway($orderPayment->getMethod()),
+ 'transactionId' => $orderPayment->getLastTransId(),
+ 'currency' => $order->getOrderCurrencyCode(),
+ 'orderChannel' => $this->getOrderChannel(),
+ 'totalPrice' => $order->getGrandTotal(),
+ ],
+ ];
+ }
+
+ /**
+ * Returns the gateway that processed the transaction. For PayPal orders use paypal_account.
+ *
+ * @param string $gatewayCode
+ * @return string
+ */
+ private function getPaymentGateway($gatewayCode)
+ {
+ return (bool)substr_count($gatewayCode, 'paypal') ? 'paypal_account' : $gatewayCode;
+ }
+
+ /**
+ * Returns WEB for web-orders, PHONE for orders created by Admin
+ *
+ * @return string
+ */
+ private function getOrderChannel()
+ {
+ return $this->scope->getCurrentScope() === 'adminhtml' ? 'PHONE' : 'WEB';
+ }
+}
From 9a9fded72409649eda318d24fa03ff6d191dea6d Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 9 Dec 2016 09:06:57 -0600
Subject: [PATCH 003/225] MAGETWO-61967: Generate orderSessionId on backend
---
.../Magento/Signifyd/Model/OrderSessionId.php | 56 ++++++++++++++++
.../Signifyd/Model/Ui/ConfigProvider.php | 46 +++++++++++++
.../Test/Unit/Model/OrderSessionIdTest.php | 62 ++++++++++++++++++
.../Test/Unit/Model/Ui/ConfigProviderTest.php | 64 +++++++++++++++++++
app/code/Magento/Signifyd/etc/frontend/di.xml | 16 +++++
5 files changed, 244 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Model/OrderSessionId.php
create mode 100644 app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
create mode 100644 app/code/Magento/Signifyd/etc/frontend/di.xml
diff --git a/app/code/Magento/Signifyd/Model/OrderSessionId.php b/app/code/Magento/Signifyd/Model/OrderSessionId.php
new file mode 100644
index 0000000000000..22be3c6911493
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/OrderSessionId.php
@@ -0,0 +1,56 @@
+checkoutSession = $checkoutSession;
+ }
+
+ /**
+ * Generate the unique ID for the user's browsing session
+ *
+ * @return string
+ */
+ public function generate()
+ {
+ return sha1($this->getQuote()->getId() . $this->getQuote()->getCreatedAt());
+ }
+
+ /**
+ * Get current quote
+ *
+ * @return \Magento\Quote\Model\Quote
+ */
+ private function getQuote()
+ {
+ if ($this->quote === null) {
+ $this->quote = $this->checkoutSession->getQuote();
+ }
+
+ return $this->quote;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php b/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php
new file mode 100644
index 0000000000000..4b690a0234e1d
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php
@@ -0,0 +1,46 @@
+orderSessionId = $orderSessionId;
+ }
+
+ /**
+ * Retrieve assoc array of checkout configuration
+ *
+ * @return array
+ */
+ public function getConfig()
+ {
+ return [
+ 'fraud' => [
+ self::SIGNIFYD_CODE => [
+ 'orderSessionId' => $this->orderSessionId->generate()
+ ]
+ ]
+ ];
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php
new file mode 100644
index 0000000000000..7057956a8edaf
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php
@@ -0,0 +1,62 @@
+checkoutSession = $this->getMockBuilder(Session::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->quote = $this->getMockBuilder(Quote::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->orderSessionId = new OrderSessionId($this->checkoutSession);
+ }
+
+ public function testGenerate()
+ {
+ $this->checkoutSession->expects(static::once())
+ ->method('getQuote')
+ ->willReturn($this->quote);
+
+ $this->quote->expects(static::once())
+ ->method('getId')
+ ->willReturn(self::QUOTE_ID);
+ $this->quote->expects(static::once())
+ ->method('getCreatedAt')
+ ->willReturn(self::QUOTE_CREATED_AT);
+
+ static::assertSame(self::HASH, $this->orderSessionId->generate());
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
new file mode 100644
index 0000000000000..66e7f8be34b19
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
@@ -0,0 +1,64 @@
+orderSessionId = $this->getMockBuilder(OrderSessionId::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->configProvider = new ConfigProvider($this->orderSessionId);
+ }
+
+ /**
+ * @dataProvider getConfigDataProvider
+ */
+ public function testGetConfig($expected)
+ {
+ $this->orderSessionId->expects(static::once())
+ ->method('generate')
+ ->willReturn(self::HASH);
+
+ static::assertSame($expected, $this->configProvider->getConfig());
+ }
+
+ /**
+ * @return array
+ */
+ public function getConfigDataProvider()
+ {
+ return [
+ [
+ [
+ 'fraud' => [
+ ConfigProvider::SIGNIFYD_CODE => [
+ 'orderSessionId' => self::HASH
+ ]
+ ]
+ ]
+ ]
+ ];
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/frontend/di.xml b/app/code/Magento/Signifyd/etc/frontend/di.xml
new file mode 100644
index 0000000000000..a81fde778a02a
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/frontend/di.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+ - Magento\Signifyd\Model\Ui\ConfigProvider
+
+
+
+
From adda6aa136f22f61c99ce4d2921f5045304fb381 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 12 Dec 2016 03:16:56 -0600
Subject: [PATCH 004/225] MAGETWO-61913: Create request builders
- Creates card, recipient and purchase builders
---
.../Signifyd/Model/Request/AddressBuilder.php | 44 ++++++
.../Signifyd/Model/Request/CardBuilder.php | 54 ++++++++
.../Model/Request/CreateCaseBuilder.php | 39 +++++-
.../Model/Request/PurchaseBuilder.php | 127 +++++++++++++++---
.../Model/Request/RecipientBuilder.php | 53 ++++++++
5 files changed, 292 insertions(+), 25 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/CardBuilder.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
diff --git a/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php b/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
new file mode 100644
index 0000000000000..621058e7f2c67
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
@@ -0,0 +1,44 @@
+ $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
+ */
+ public function getStreetLine($number, $street)
+ {
+ $lines = is_array($street) ? $street : [];
+
+ return isset($lines[$number - 1]) ? $lines[$number - 1] : '';
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Request/CardBuilder.php b/app/code/Magento/Signifyd/Model/Request/CardBuilder.php
new file mode 100644
index 0000000000000..ec3e08f428b50
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/CardBuilder.php
@@ -0,0 +1,54 @@
+addressBuilder = $addressBuilder;
+ }
+
+ /**
+ * Returns card data params
+ *
+ * @param Order $order
+ * @return array
+ */
+ public function build(Order $order)
+ {
+ $result = [];
+ $address = $order->getBillingAddress();
+ if ($address === null) {
+ return $result;
+ }
+
+ $payment = $order->getPayment();
+ $result = [
+ '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/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
index 055f78aa401b9..346aa7a91465e 100644
--- a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
@@ -5,23 +5,49 @@
*/
namespace Magento\Signifyd\Model\Request;
+use Magento\Sales\Model\OrderFactory;
+
/**
- * Class CreateCaseBuilder
+ * Handles the conversion from Magento Order to Signifyd Case.
*/
class CreateCaseBuilder implements CreateCaseBuilderInterface
{
+ /**
+ * @var OrderFactory
+ */
+ private $orderFactory;
+
/**
* @var PurchaseBuilder
*/
private $purchaseBuilder;
/**
+ * @var CardBuilder
+ */
+ private $cardBuilder;
+
+ /**
+ * @var RecipientBuilder
+ */
+ private $recipientBuilder;
+
+ /**
+ * @param OrderFactory $orderFactory
* @param PurchaseBuilder $purchaseBuilder
+ * @param CardBuilder $cardBuilder
+ * @param RecipientBuilder $recipientBuilder
*/
public function __construct(
- PurchaseBuilder $purchaseBuilder
+ OrderFactory $orderFactory,
+ PurchaseBuilder $purchaseBuilder,
+ CardBuilder $cardBuilder,
+ RecipientBuilder $recipientBuilder
) {
+ $this->orderFactory = $orderFactory;
$this->purchaseBuilder = $purchaseBuilder;
+ $this->cardBuilder = $cardBuilder;
+ $this->recipientBuilder = $recipientBuilder;
}
/**
@@ -29,6 +55,13 @@ public function __construct(
*/
public function build($orderId)
{
- return $this->purchaseBuilder;
+ /* @var $order \Magento\Sales\Model\Order */
+ $order = $this->orderFactory->create()->load($orderId);
+
+ return array_merge(
+ $this->purchaseBuilder->build($order),
+ $this->cardBuilder->build($order),
+ $this->recipientBuilder->build($order)
+ );
}
}
diff --git a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
index ca1560d65c44a..46e691b8032f9 100644
--- a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
@@ -5,20 +5,15 @@
*/
namespace Magento\Signifyd\Model\Request;
-use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Config\ScopeInterface;
+use Magento\Sales\Model\Order;
/**
* Prepare data related to purchase event represented in Case Creation request.
*/
class PurchaseBuilder
{
- /**
- * @var OrderRepositoryInterface
- */
- private $orderRepository;
-
/**
* @var DateTimeFactory
*/
@@ -30,16 +25,13 @@ class PurchaseBuilder
private $scope;
/**
- * @param OrderRepositoryInterface $orderRepository
* @param DateTimeFactory $dateTimeFactory
* @param ScopeInterface $scope
*/
public function __construct(
- OrderRepositoryInterface $orderRepository,
DateTimeFactory $dateTimeFactory,
ScopeInterface $scope
) {
- $this->orderRepository = $orderRepository;
$this->dateTimeFactory = $dateTimeFactory;
$this->scope = $scope;
}
@@ -47,27 +39,20 @@ public function __construct(
/**
* Returns purchase data params
*
- * @param int $orderId
+ * @param Order $order
* @return array
*/
- public function build($orderId)
+ public function build(Order $order)
{
- /** @var \Magento\Sales\Model\Order $order */
- $order = $this->orderRepository->get($orderId);
$orderPayment = $order->getPayment();
$createdAt = $this->dateTimeFactory->create(
$order->getCreatedAt(),
new \DateTimeZone('UTC')
);
-
- return [
+ $result = [
'purchase' => [
'browserIpAddress' => $order->getRemoteIp(),
- 'shipments' => [
- 'shippingPrice' => $order->getShippingAmount()
-
- ],
'orderId' => $order->getEntityId(),
'createdAt' => $createdAt->format(\DateTime::ISO8601),
'paymentGateway' => $this->getPaymentGateway($orderPayment->getMethod()),
@@ -77,21 +62,119 @@ public function build($orderId)
'totalPrice' => $order->getGrandTotal(),
],
];
+
+ $shipments = $this->getShipments($order);
+ if (!empty($shipments)) {
+ $result['purchase']['shipments'] = $shipments;
+ }
+
+ $products = $this->getProducts($order);
+ if (!empty($products)) {
+ $result['purchase']['products'] = $products;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Gets 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' => $orderItem->getQtyOrdered(),
+ 'itemUrl' => $orderItem->getProduct()->getProductUrl(),
+ 'itemWeight' => $orderItem->getProduct()->getWeight()
+ ];
+ }
+
+ return $result;
+ }
+
+ /**
+ * Gets the shipments associated with this purchase.
+ *
+ * @param Order $order
+ * @return array
+ */
+ private function getShipments(Order $order)
+ {
+ $result = [];
+ $shipper = $this->getShipper($order->getShippingDescription());
+ $shippingMethod = $this->getShippingMethod($order->getShippingDescription());
+
+ $shipmentList = $order->getShipmentsCollection();
+ /** @var \Magento\Sales\Api\Data\ShipmentInterface $shipment */
+ foreach ($shipmentList as $shipment) {
+ $totalPrice = 0;
+ foreach ($shipment->getItems() as $shipmentItem) {
+ $totalPrice += $shipmentItem->getPrice();
+ }
+
+ $item = [
+ 'shipper' => $shipper,
+ 'shippingMethod' => $shippingMethod,
+ 'shippingPrice' => $totalPrice
+ ];
+
+ $tracks = $shipment->getTracks();
+ if (!empty($tracks)) {
+ $item['trackingNumber'] = end($tracks)->getTrackNumber();
+ }
+
+ $result[] = $item;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Gets the name of the shipper
+ *
+ * @param $shippingDescription
+ * @return string
+ */
+ private function getShipper($shippingDescription)
+ {
+ $result = explode(' - ', $shippingDescription, 2);
+
+ return count($result) == 2 ? $result[0] : '';
+ }
+
+ /**
+ * Gets the type of the shipment method used
+ *
+ * @param $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 use paypal_account.
+ * Gets the gateway that processed the transaction. For PayPal orders use paypal_account.
*
* @param string $gatewayCode
* @return string
*/
private function getPaymentGateway($gatewayCode)
{
- return (bool)substr_count($gatewayCode, 'paypal') ? 'paypal_account' : $gatewayCode;
+ return strstr($gatewayCode, 'paypal') === false ? $gatewayCode : 'paypal_account';
}
/**
- * Returns WEB for web-orders, PHONE for orders created by Admin
+ * Gets WEB for web-orders, PHONE for orders created by Admin
*
* @return string
*/
diff --git a/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php b/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
new file mode 100644
index 0000000000000..38cb79d32de2b
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
@@ -0,0 +1,53 @@
+addressBuilder = $addressBuilder;
+ }
+
+ /**
+ * Returns recipient data params
+ *
+ * @param Order $order
+ * @return array
+ */
+ public function build(Order $order)
+ {
+ $result = [];
+ $address = $order->getShippingAddress();
+ if ($address === null) {
+ return $result;
+ }
+
+ $result = [
+ 'fullName' => $address->getName(),
+ 'confirmationEmail' => $address->getEmail(),
+ 'confirmationPhone' => $address->getTelephone(),
+ 'organization' => $address->getCompany(),
+ 'deliveryAddress' => $this->addressBuilder->build($address)
+ ];
+
+ return $result;
+ }
+}
From a64ec0b80ef160c4d59dfd7826a036b3a19679b3 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 04:16:39 -0600
Subject: [PATCH 005/225] MAGETWO-61967: Generate orderSessionId on backend
- Added Checkout module dependency
---
app/code/Magento/Signifyd/composer.json | 3 ++-
app/code/Magento/Signifyd/etc/module.xml | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 9f0c56a845f37..cc8bd9d228508 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -4,7 +4,8 @@
"require": {
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"magento/framework": "100.2.*",
- "magento/module-sales": "100.2.*"
+ "magento/module-sales": "100.2.*",
+ "magento/module-checkout": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 1ee26044bbef4..82eb61e9ff0a8 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,6 +9,7 @@
+
From 546fc8af8ab8b04e27f1c7c3991f1eea13e41840 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 12 Dec 2016 05:00:00 -0600
Subject: [PATCH 006/225] MAGETWO-61925: Create case entity infrastructure
- Added API interfaces for Sygnifyd integration
- Added implementation of API interfaces
- Covered Sygnifyd management by integration tests
---
.../Signifyd/Api/CaseManagementInterface.php | 31 +++
.../Signifyd/Api/CaseRepositoryInterface.php | 32 +++
.../Signifyd/Api/Data/CaseInterface.php | 227 ++++++++++++++++++
.../Magento/Signifyd/Model/CaseEntity.php | 205 ++++++++++++++++
.../Magento/Signifyd/Model/CaseManagement.php | 57 +++++
.../Magento/Signifyd/Model/CaseRepository.php | 56 +++++
.../Magento/Signifyd/Setup/InstallSchema.php | 64 +++++
app/code/Magento/Signifyd/etc/constraints.xml | 14 ++
app/code/Magento/Signifyd/etc/di.xml | 39 +++
app/code/Magento/Signifyd/i18n/en_US.csv | 13 +
.../Signifyd/Model/CaseManagementTest.php | 93 +++++++
.../Magento/Signifyd/_files/case.php | 31 +++
12 files changed, 862 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Api/CaseManagementInterface.php
create mode 100644 app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
create mode 100644 app/code/Magento/Signifyd/Api/Data/CaseInterface.php
create mode 100644 app/code/Magento/Signifyd/Model/CaseEntity.php
create mode 100644 app/code/Magento/Signifyd/Model/CaseManagement.php
create mode 100644 app/code/Magento/Signifyd/Model/CaseRepository.php
create mode 100644 app/code/Magento/Signifyd/Setup/InstallSchema.php
create mode 100644 app/code/Magento/Signifyd/etc/constraints.xml
create mode 100644 app/code/Magento/Signifyd/etc/di.xml
create mode 100644 app/code/Magento/Signifyd/i18n/en_US.csv
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
new file mode 100644
index 0000000000000..c4d6005011b93
--- /dev/null
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -0,0 +1,31 @@
+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 getGuaranteeEligible()
+ {
+ return $this->getData('guarantee_eligible');
+ }
+
+ /**
+ * @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()
+ {
+ return (int) $this->getData('associated_team');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setAssociatedTeam($teamId)
+ {
+ $this->setData('associated_team', (int) $teamId);
+ 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;
+ }
+
+ /**
+ * Gets updating datetime for a case
+ * @return string
+ */
+ public function getUpdatedAt()
+ {
+ return $this->getData('updated_at');
+ }
+
+ /**
+ * Sets updating datetime for a case
+ * @param $datetime
+ * @return $this
+ */
+ 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
new file mode 100644
index 0000000000000..9269d8622dfab
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -0,0 +1,57 @@
+caseRepository = $caseRepository;
+ $this->caseFactory = $caseFactory;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function create($orderId)
+ {
+ $case = $this->caseFactory->create(
+ ['data' => ['order_id' => $orderId, 'status' => CaseInterface::STATUS_PROCESSING]]
+ );
+ return $this->caseRepository->save($case);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getByOrderId($orderId)
+ {
+ return $this->caseRepository->getById($orderId);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/CaseRepository.php b/app/code/Magento/Signifyd/Model/CaseRepository.php
new file mode 100644
index 0000000000000..916cbe6136817
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/CaseRepository.php
@@ -0,0 +1,56 @@
+entityManager = $entityManager;
+ $this->caseFactory = $caseFactory;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function save(CaseInterface $case)
+ {
+ return $this->entityManager->save($case);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getById($orderId)
+ {
+ $case = $this->caseFactory->create();
+ return $this->entityManager->load($case, $orderId);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
new file mode 100644
index 0000000000000..c12399e669394
--- /dev/null
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -0,0 +1,64 @@
+startSetup()->getConnection();
+
+ $table = $connection->newTable($setup->getTable(static::$table));
+ $table->addColumn(
+ 'entity_id',
+ Table::TYPE_INTEGER,
+ null,
+ ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true]
+ );
+ $table->addColumn('order_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
+ $table->addColumn('case_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
+ $table->addColumn('guarantee_eligible', Table::TYPE_BOOLEAN, null);
+ $table->addColumn('guarantee_disposition', Table::TYPE_TEXT, 32);
+ $table->addColumn('status', Table::TYPE_TEXT, 32, ['default' => CaseInterface::STATUS_PROCESSING]);
+ $table->addColumn('score', Table::TYPE_INTEGER, null, ['unsigned' => true]);
+ $table->addColumn('associated_team', Table::TYPE_INTEGER, null, ['unsigned' => true]);
+ $table->addColumn('review_disposition', Table::TYPE_TEXT, 32);
+ $table->addColumn('created_at', Table::TYPE_TIMESTAMP);
+ $table->addColumn('updated_at', Table::TYPE_TIMESTAMP);
+ $table->addForeignKey(
+ $setup->getFkName(
+ $setup->getTable(static::$table),
+ 'order_id',
+ $setup->getTable('sales_order'),
+ 'entity_id'
+ ),
+ 'order_id',
+ $setup->getTable('sales_order'),
+ 'entity_id',
+ Table::ACTION_SET_NULL
+ );
+ $connection->createTable($table);
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/constraints.xml b/app/code/Magento/Signifyd/etc/constraints.xml
new file mode 100644
index 0000000000000..4947f84a5adc9
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/constraints.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
new file mode 100644
index 0000000000000..3abcaad08a639
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+ -
+
- Magento\Framework\EntityManager\Operation\Read
+ - Magento\Framework\EntityManager\Operation\Create
+ - Magento\Framework\EntityManager\Operation\Update
+
+
+
+
+
+
+
+
+
+
+ -
+
- signifyd_case
+ - order_id
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
new file mode 100644
index 0000000000000..2785e217040ca
--- /dev/null
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -0,0 +1,13 @@
+"OPEN","Open"
+"PROCESSING","Processing"
+"FLAGGED","Flagged"
+"DISMISSED","Dismissed"
+"HELD","Held"
+"GOOD","Good"
+"FRAUDULENT","Fraudulent"
+"UNSET","Unset"
+"APPROVED","Approved"
+"DECLINED","Declined"
+"PENDING","Pending"
+"CANCELED","Canceled"
+"IN_REVIEW","In review"
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
new file mode 100644
index 0000000000000..c81a18a8afc99
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
@@ -0,0 +1,93 @@
+objectManager = Bootstrap::getObjectManager();
+ $this->caseManagement = $this->objectManager->get(CaseManagement::class);
+ }
+
+ /**
+ * @covers \Magento\Signifyd\Model\CaseManagement::create
+ * @magentoDataFixture Magento/Signifyd/_files/order.php
+ */
+ public function testCreate()
+ {
+ $order = $this->getOrder();
+ $case = $this->caseManagement->create($order->getEntityId());
+
+ static::assertNotEmpty($case->getEntityId());
+ static::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus());
+ }
+
+ /**
+ * @covers \Magento\Signifyd\Model\CaseManagement::getByOrderId
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ */
+ public function testGetByOrderId()
+ {
+ $order = $this->getOrder();
+ $case = $this->caseManagement->getByOrderId($order->getEntityId());
+
+ static::assertEquals(CaseInterface::GUARANTEE_PENDING, $case->getGuaranteeDisposition());
+ static::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus());
+ static::assertEquals(CaseInterface::DISPOSITION_GOOD, $case->getReviewDisposition());
+ static::assertEquals('2016-12-12 15:17:17', $case->getCreatedAt());
+ static::assertEquals('2016-12-12 19:23:16', $case->getUpdatedAt());
+ }
+
+ /**
+ * Get stored order
+ * @return OrderInterface
+ */
+ private function getOrder()
+ {
+ /** @var FilterBuilder $filterBuilder */
+ $filterBuilder = $this->objectManager->get(FilterBuilder::class);
+ $filters = [
+ $filterBuilder->setField(OrderInterface::INCREMENT_ID)
+ ->setValue('100000001')
+ ->create()
+ ];
+
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ ->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/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
new file mode 100644
index 0000000000000..2ec61edef8f39
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -0,0 +1,31 @@
+get(CaseInterfaceFactory::class);
+
+/** @var CaseInterface $case */
+$case = $caseFactory->create();
+$case->setCaseId(123)
+ ->setGuaranteeEligible(true)
+ ->setGuaranteeDisposition(CaseInterface::GUARANTEE_PENDING)
+ ->setStatus(CaseInterface::STATUS_PROCESSING)
+ ->setScore(553)
+ ->setOrderId($order->getEntityId())
+ ->setAssociatedTeam(124)
+ ->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);
+
From b1ce254d6d1643a771e9d90876c6e504ed3f6bf3 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 12 Dec 2016 05:15:19 -0600
Subject: [PATCH 007/225] MAGETWO-61925: Create case entity infrastructure
- Fixed failed static tests
---
app/code/Magento/Signifyd/Api/Data/CaseInterface.php | 4 +++-
app/code/Magento/Signifyd/Model/CaseEntity.php | 2 +-
.../integration/testsuite/Magento/Signifyd/_files/case.php | 1 -
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index 1a1358836003f..f1c4980d7fe2a 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -16,6 +16,7 @@ interface CaseInterface
/**#@+
* Constants for case available statuses
*/
+
/**
* Open status
*/
@@ -67,6 +68,7 @@ interface CaseInterface
/**#@+
* Constants for case available review dispositions
*/
+
/**
* Review disposition is good
*/
@@ -112,7 +114,7 @@ public function setCaseId($id);
* Gets value, which indicates if a guarantee can be requested for a case
* @return boolean
*/
- public function getGuaranteeEligible();
+ public function isGuaranteeEligible();
/**
* Sets value-indicator about guarantee availability for a case
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index 05f77fa752547..4dd028e5b74ab 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -50,7 +50,7 @@ public function setCaseId($id)
/**
* @inheritdoc
*/
- public function getGuaranteeEligible()
+ public function isGuaranteeEligible()
{
return $this->getData('guarantee_eligible');
}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
index 2ec61edef8f39..148c831a9f2d7 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -28,4 +28,3 @@
/** @var CaseRepositoryInterface $caseRepository */
$caseRepository = $objectManager->get(CaseRepositoryInterface::class);
$caseRepository->save($case);
-
From 7da30556276cab8474dc5f7786233f5bed322540 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 12 Dec 2016 05:26:08 -0600
Subject: [PATCH 008/225] MAGETWO-61925: Create case entity infrastructure
- Fixed failed static test
---
app/code/Magento/Signifyd/Api/Data/CaseInterface.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index f1c4980d7fe2a..9a85652f3d57c 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -40,6 +40,7 @@ interface CaseInterface
/**#@+
* Constants for guarantee available statuses
*/
+
/**
* Approved status
*/
From 65604fdd4181d2b12d82080664b88818d3474164 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 05:48:33 -0600
Subject: [PATCH 009/225] MAGETWO-61967: Generate orderSessionId on backend
- Removed hard dependency on checkout session
- Used identity generator instead of sha1 hash
---
.../Magento/Signifyd/Model/OrderSessionId.php | 30 ++++++++++++-----
.../Signifyd/Model/Ui/ConfigProvider.php | 2 +-
.../Test/Unit/Model/OrderSessionIdTest.php | 33 +++++++++++++------
.../Test/Unit/Model/Ui/ConfigProviderTest.php | 4 +--
.../Magento/Signifyd/etc/adminhtml/di.xml | 14 ++++++++
app/code/Magento/Signifyd/etc/frontend/di.xml | 5 +++
6 files changed, 66 insertions(+), 22 deletions(-)
create mode 100644 app/code/Magento/Signifyd/etc/adminhtml/di.xml
diff --git a/app/code/Magento/Signifyd/Model/OrderSessionId.php b/app/code/Magento/Signifyd/Model/OrderSessionId.php
index 22be3c6911493..96356f81dd287 100644
--- a/app/code/Magento/Signifyd/Model/OrderSessionId.php
+++ b/app/code/Magento/Signifyd/Model/OrderSessionId.php
@@ -5,7 +5,8 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Checkout\Model\Session;
+use Magento\Framework\DataObject\IdentityGeneratorInterface;
+use Magento\Framework\Session\SessionManagerInterface;
/**
* Class OrderSessionId
@@ -13,9 +14,9 @@
class OrderSessionId
{
/**
- * @var Session
+ * @var SessionManagerInterface
*/
- private $checkoutSession;
+ private $session;
/**
* @var \Magento\Quote\Model\Quote
@@ -23,11 +24,20 @@ class OrderSessionId
private $quote;
/**
- * @param Session $checkoutSession
+ * @var IdentityGeneratorInterface
*/
- public function __construct(Session $checkoutSession)
- {
- $this->checkoutSession = $checkoutSession;
+ private $identityGenerator;
+
+ /**
+ * @param SessionManagerInterface $session
+ * @param IdentityGeneratorInterface $identityGenerator
+ */
+ public function __construct(
+ SessionManagerInterface $session,
+ IdentityGeneratorInterface $identityGenerator
+ ) {
+ $this->session = $session;
+ $this->identityGenerator = $identityGenerator;
}
/**
@@ -37,7 +47,9 @@ public function __construct(Session $checkoutSession)
*/
public function generate()
{
- return sha1($this->getQuote()->getId() . $this->getQuote()->getCreatedAt());
+ return $this->identityGenerator->generateIdForData(
+ $this->getQuote()->getId() . $this->getQuote()->getCreatedAt()
+ );
}
/**
@@ -48,7 +60,7 @@ public function generate()
private function getQuote()
{
if ($this->quote === null) {
- $this->quote = $this->checkoutSession->getQuote();
+ $this->quote = $this->session->getQuote();
}
return $this->quote;
diff --git a/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php b/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php
index 4b690a0234e1d..af6555a4329db 100644
--- a/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php
+++ b/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php
@@ -36,7 +36,7 @@ public function __construct(OrderSessionId $orderSessionId)
public function getConfig()
{
return [
- 'fraud' => [
+ 'fraud_protection' => [
self::SIGNIFYD_CODE => [
'orderSessionId' => $this->orderSessionId->generate()
]
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php
index 7057956a8edaf..32a8e3b6a7426 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php
@@ -5,7 +5,8 @@
*/
namespace Magento\Signifyd\Test\Unit\Model;
-use Magento\Checkout\Model\Session;
+use Magento\Framework\DataObject\IdentityGeneratorInterface;
+use Magento\Framework\Session\SessionManagerInterface;
use Magento\Quote\Model\Quote;
use Magento\Signifyd\Model\OrderSessionId;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
@@ -14,7 +15,7 @@ class OrderSessionIdTest extends \PHPUnit_Framework_TestCase
{
const QUOTE_ID = 1;
const QUOTE_CREATED_AT = '1970-01-01 00:00:00';
- const HASH = 'ede3c2f59fabe6dee8d1fefb5580200884ff1f16';
+ const HASH = 'hash';
/**
* @var OrderSessionId
@@ -22,31 +23,39 @@ class OrderSessionIdTest extends \PHPUnit_Framework_TestCase
private $orderSessionId;
/**
- * @var Session|MockObject
+ * @var SessionManagerInterface|MockObject
*/
- private $checkoutSession;
+ private $session;
/**
* @var Quote|MockObject
*/
private $quote;
- public function setUp()
+ /**
+ * @var IdentityGeneratorInterface|MockObject
+ */
+ private $identityGenerator;
+
+ protected function setUp()
{
- $this->checkoutSession = $this->getMockBuilder(Session::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->session = $this->getMockBuilder(SessionManagerInterface::class)
+ ->setMethods(['getQuote'])
+ ->getMockForAbstractClass();
$this->quote = $this->getMockBuilder(Quote::class)
->disableOriginalConstructor()
->getMock();
- $this->orderSessionId = new OrderSessionId($this->checkoutSession);
+ $this->identityGenerator = $this->getMockBuilder(IdentityGeneratorInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->orderSessionId = new OrderSessionId($this->session, $this->identityGenerator);
}
public function testGenerate()
{
- $this->checkoutSession->expects(static::once())
+ $this->session->expects(static::once())
->method('getQuote')
->willReturn($this->quote);
@@ -57,6 +66,10 @@ public function testGenerate()
->method('getCreatedAt')
->willReturn(self::QUOTE_CREATED_AT);
+ $this->identityGenerator->expects(static::once())
+ ->method('generateIdForData')
+ ->willReturn('hash');
+
static::assertSame(self::HASH, $this->orderSessionId->generate());
}
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
index 66e7f8be34b19..bfae3b8773cba 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
@@ -11,7 +11,7 @@
class ConfigProviderTest extends \PHPUnit_Framework_TestCase
{
- const HASH = 'ede3c2f59fabe6dee8d1fefb5580200884ff1f16';
+ const HASH = 'hash';
/**
* @var ConfigProvider
@@ -52,7 +52,7 @@ public function getConfigDataProvider()
return [
[
[
- 'fraud' => [
+ 'fraud_protection' => [
ConfigProvider::SIGNIFYD_CODE => [
'orderSessionId' => self::HASH
]
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/di.xml b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
new file mode 100644
index 0000000000000..2509a0be47376
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+ Magento\Backend\Model\Session\Quote
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/frontend/di.xml b/app/code/Magento/Signifyd/etc/frontend/di.xml
index a81fde778a02a..b5a97f00ac3a4 100644
--- a/app/code/Magento/Signifyd/etc/frontend/di.xml
+++ b/app/code/Magento/Signifyd/etc/frontend/di.xml
@@ -13,4 +13,9 @@
+
+
+ Magento\Checkout\Model\Session
+
+
From c56be06630ee6bb310b27a2404753e391dc79aba Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 05:55:44 -0600
Subject: [PATCH 010/225] MAGETWO-61967: Generate orderSessionId on backend
- Removed module.xml dependency
---
.../Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php | 2 +-
app/code/Magento/Signifyd/etc/module.xml | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
index bfae3b8773cba..99f4c23e70cbd 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
@@ -23,7 +23,7 @@ class ConfigProviderTest extends \PHPUnit_Framework_TestCase
*/
private $orderSessionId;
- public function setUp()
+ protected function setUp()
{
$this->orderSessionId = $this->getMockBuilder(OrderSessionId::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 82eb61e9ff0a8..1ee26044bbef4 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,7 +9,6 @@
-
From 3f89bd07bdd46470b38ac4caf364f4447b81722c Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 12 Dec 2016 11:35:10 -0600
Subject: [PATCH 011/225] MAGETWO-61913: Create request builders
- Add seller, clientVersion and userAccount builders
---
.../Signifyd/Model/Request/AddressBuilder.php | 2 +-
.../Model/Request/ClientVersionBuilder.php | 43 +++++
.../Model/Request/CreateCaseBuilder.php | 34 +++-
.../Signifyd/Model/Request/CustomerOrders.php | 66 +++++++
.../Model/Request/PurchaseBuilder.php | 4 +-
.../Signifyd/Model/Request/SellerBuilder.php | 85 +++++++++
.../Model/Request/UserAccountBuilder.php | 168 ++++++++++++++++++
7 files changed, 396 insertions(+), 6 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/CustomerOrders.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
diff --git a/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php b/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
index 621058e7f2c67..2d2b4ac28f6f2 100644
--- a/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
@@ -35,7 +35,7 @@ public function build(OrderAddressInterface $address)
* @param string[]|null $street
* @return string
*/
- public function getStreetLine($number, $street)
+ private function getStreetLine($number, $street)
{
$lines = is_array($street) ? $street : [];
diff --git a/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php b/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
new file mode 100644
index 0000000000000..4c8f4e843163a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
@@ -0,0 +1,43 @@
+productMetadata = $productMetadata;
+ }
+
+ /**
+ * Returns version info
+ *
+ * @return array
+ */
+ public function build()
+ {
+ return [
+ 'clientVersion' => [
+ 'platform' => $this->productMetadata->getName() . ' ' . $this->productMetadata->getEdition(),
+ 'platformVersion' => $this->productMetadata->getVersion()
+ ]
+ ];
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
index 346aa7a91465e..926c5354af57a 100644
--- a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
@@ -8,7 +8,8 @@
use Magento\Sales\Model\OrderFactory;
/**
- * Handles the conversion from Magento Order to Signifyd Case.
+ * Handles the conversion from Magento Order to Signifyd Case
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CreateCaseBuilder implements CreateCaseBuilderInterface
{
@@ -32,22 +33,46 @@ class CreateCaseBuilder implements CreateCaseBuilderInterface
*/
private $recipientBuilder;
+ /**
+ * @var SellerBuilder
+ */
+ private $sellerBuilder;
+
+ /**
+ * @var ClientVersionBuilder
+ */
+ private $clientVersionBuilder;
+
+ /**
+ * @var UserAccountBuilder
+ */
+ private $userAccountBuilder;
+
/**
* @param OrderFactory $orderFactory
* @param PurchaseBuilder $purchaseBuilder
* @param CardBuilder $cardBuilder
* @param RecipientBuilder $recipientBuilder
+ * @param SellerBuilder $sellerBuilder
+ * @param ClientVersionBuilder $clientVersionBuilder
+ * @param UserAccountBuilder $userAccountBuilder
*/
public function __construct(
OrderFactory $orderFactory,
PurchaseBuilder $purchaseBuilder,
CardBuilder $cardBuilder,
- RecipientBuilder $recipientBuilder
+ RecipientBuilder $recipientBuilder,
+ SellerBuilder $sellerBuilder,
+ ClientVersionBuilder $clientVersionBuilder,
+ UserAccountBuilder $userAccountBuilder
) {
$this->orderFactory = $orderFactory;
$this->purchaseBuilder = $purchaseBuilder;
$this->cardBuilder = $cardBuilder;
$this->recipientBuilder = $recipientBuilder;
+ $this->sellerBuilder = $sellerBuilder;
+ $this->clientVersionBuilder = $clientVersionBuilder;
+ $this->userAccountBuilder = $userAccountBuilder;
}
/**
@@ -61,7 +86,10 @@ public function build($orderId)
return array_merge(
$this->purchaseBuilder->build($order),
$this->cardBuilder->build($order),
- $this->recipientBuilder->build($order)
+ $this->recipientBuilder->build($order),
+ $this->userAccountBuilder->build($order),
+ $this->sellerBuilder->build($order),
+ $this->clientVersionBuilder->build()
);
}
}
diff --git a/app/code/Magento/Signifyd/Model/Request/CustomerOrders.php b/app/code/Magento/Signifyd/Model/Request/CustomerOrders.php
new file mode 100644
index 0000000000000..26322a745b8ee
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/CustomerOrders.php
@@ -0,0 +1,66 @@
+searchCriteriaBuilder = $searchCriteriaBuilder;
+ $this->filterBuilder = $filterBuilder;
+ $this->orderRepository = $orderRepository;
+ }
+
+ /**
+ * Gets customer orders
+ *
+ * @param int $customerId
+ * @return \Magento\Sales\Api\Data\OrderInterface[]
+ */
+ public function get($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();
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
index 46e691b8032f9..215c5f39a172d 100644
--- a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
@@ -139,7 +139,7 @@ private function getShipments(Order $order)
/**
* Gets the name of the shipper
*
- * @param $shippingDescription
+ * @param string $shippingDescription
* @return string
*/
private function getShipper($shippingDescription)
@@ -152,7 +152,7 @@ private function getShipper($shippingDescription)
/**
* Gets the type of the shipment method used
*
- * @param $shippingDescription
+ * @param string $shippingDescription
* @return string
*/
private function getShippingMethod($shippingDescription)
diff --git a/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php b/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
new file mode 100644
index 0000000000000..62977c6d81e51
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
@@ -0,0 +1,85 @@
+scopeConfig = $scopeConfig;
+ }
+
+ /**
+ * 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' => parse_url($store->getBaseUrl(), PHP_URL_HOST),
+ '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->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->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),
+ ]
+ ]
+ ];
+ }
+
+ /**
+ * Gets 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
+ );
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
new file mode 100644
index 0000000000000..198b57d3e238e
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
@@ -0,0 +1,168 @@
+customerRepository = $customerRepository;
+ $this->dateTimeFactory = $dateTimeFactory;
+ $this->logger = $logger;
+ $this->currencyFactory = $currencyFactory;
+ $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 = [
+ 'email' => $customer->getEmail(),
+ 'username' => $customer->getEmail(),
+ 'phone' => $order->getBillingAddress()->getTelephone(),
+ 'accountNumber' => $customerId,
+ 'createdDate' => $this->formatDate($customer->getCreatedAt()),
+ 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt())
+ ];
+
+ $customerOrders = $this->customerOrders->get($customerId);
+ if (!empty($customerOrders)) {
+ try {
+ $orderTotalDollars = 0.0;
+ foreach ($customerOrders as $order) {
+ $orderTotalDollars += $this->getUsdOrderTotal(
+ $order->getBaseGrandTotal(),
+ $order->getBaseCurrencyCode()
+ );
+ }
+ $result['aggregateOrderCount'] = count($customerOrders);
+ $result['aggregateOrderDollars'] = $orderTotalDollars;
+ } catch (\Exception $e) {
+ $this->logger->error($e->getMessage());
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Get currency by currency code
+ *
+ * @param string|null $currencyCode
+ * @return \Magento\Directory\Model\Currency
+ */
+ private function getCurrencyByCode($currencyCode)
+ {
+ if (isset($this->currencies[$currencyCode])) {
+ return $this->currencies[$currencyCode];
+ }
+
+ /** @var \Magento\Directory\Model\Currency $currency */
+ $currency = $this->currencyFactory->create();
+ $this->currencies[$currencyCode] = $currency->load($currencyCode);
+
+ return $this->currencies[$currencyCode];
+ }
+
+ /**
+ * 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::ISO8601);
+ }
+}
From 58493f3afff0b8d2dbc2fcb3e26badfac13993a6 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 04:16:39 -0600
Subject: [PATCH 012/225] MAGETWO-61967: Generate orderSessionId on backend
- Added Checkout module dependency
---
app/code/Magento/Signifyd/etc/module.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 1ee26044bbef4..82eb61e9ff0a8 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,6 +9,7 @@
+
From 84bc7af4730d8cff3770ba320b6d86699eec609d Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 05:55:44 -0600
Subject: [PATCH 013/225] MAGETWO-61967: Generate orderSessionId on backend
- Removed module.xml dependency
---
app/code/Magento/Signifyd/etc/module.xml | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 82eb61e9ff0a8..1ee26044bbef4 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,7 +9,6 @@
-
From e416c6bdf508b7359d44ea60819721a768e43527 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 13 Dec 2016 06:22:45 -0600
Subject: [PATCH 014/225] MAGETWO-61925: Create case entity infrastructure
- Replaced entity manager by resource model
---
.../Signifyd/Api/CaseRepositoryInterface.php | 20 ++++-
.../Signifyd/Api/Data/CaseInterface.php | 5 ++
.../Api/Data/CaseSearchResultsInterface.php | 31 +++++++
.../Magento/Signifyd/Model/CaseEntity.php | 17 +++-
.../Magento/Signifyd/Model/CaseManagement.php | 39 +++++++--
.../Magento/Signifyd/Model/CaseRepository.php | 83 ++++++++++++++++---
.../Model/ResourceModel/CaseEntity.php | 22 +++++
.../ResourceModel/CaseEntity/Collection.php | 24 ++++++
.../Magento/Signifyd/Setup/InstallSchema.php | 2 +-
app/code/Magento/Signifyd/etc/di.xml | 28 +------
.../Signifyd/Model/CaseManagementTest.php | 2 +-
11 files changed, 223 insertions(+), 50 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
create mode 100644 app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity.php
create mode 100644 app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity/Collection.php
diff --git a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
index 5c869fc05392d..99ca62e99643e 100644
--- a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
@@ -7,7 +7,7 @@
use Magento\Framework\Api\SearchCriteria;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Api\Data\CaseSearchResultInterface;
+use Magento\Signifyd\Api\Data\CaseSearchResultsInterface;
/**
* Signifyd Case repository interface
@@ -25,8 +25,22 @@ public function save(CaseInterface $case);
/**
* Gets case entity by order id
- * @param int $orderId
+ * @param int $id
* @return CaseInterface
*/
- public function getById($orderId);
+ public function getById($id);
+
+ /**
+ * Deletes case entity
+ * @param CaseInterface $case
+ * @return bool
+ */
+ public function delete(CaseInterface $case);
+
+ /**
+ * Gets list of case entities
+ * @param SearchCriteria $searchCriteria
+ * @return CaseSearchResultsInterface
+ */
+ public function getList(SearchCriteria $searchCriteria);
}
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index 9a85652f3d57c..ffcfd3f118eb9 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -22,6 +22,11 @@ interface CaseInterface
*/
const STATUS_OPEN = 'OPEN';
+ /**
+ * Pending status
+ */
+ const STATUS_PENDING = 'PENDING';
+
/**
* Processing status
*/
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
new file mode 100644
index 0000000000000..6113411a73e01
--- /dev/null
+++ b/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
@@ -0,0 +1,31 @@
+_init(ResourceModel\CaseEntity::class);
+ }
+
/**
* @inheritdoc
*/
diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php
index 9269d8622dfab..3e31e0af1d883 100644
--- a/app/code/Magento/Signifyd/Model/CaseManagement.php
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Signifyd\Model;
+use Magento\Framework\Api\FilterBuilder;
+use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
@@ -25,15 +27,33 @@ class CaseManagement implements CaseManagementInterface
*/
private $caseFactory;
+ /**
+ * @var FilterBuilder
+ */
+ private $filterBuilder;
+
+ /**
+ * @var SearchCriteriaBuilder
+ */
+ private $searchCriteriaBuilder;
+
/**
* CaseManagement constructor.
* @param CaseRepositoryInterface $caseRepository
* @param CaseInterfaceFactory $caseFactory
+ * @param FilterBuilder $filterBuilder
+ * @param SearchCriteriaBuilder $searchCriteriaBuilder
*/
- public function __construct(CaseRepositoryInterface $caseRepository, CaseInterfaceFactory $caseFactory)
- {
+ public function __construct(
+ CaseRepositoryInterface $caseRepository,
+ CaseInterfaceFactory $caseFactory,
+ FilterBuilder $filterBuilder,
+ SearchCriteriaBuilder $searchCriteriaBuilder
+ ) {
$this->caseRepository = $caseRepository;
$this->caseFactory = $caseFactory;
+ $this->searchCriteriaBuilder = $searchCriteriaBuilder;
+ $this->filterBuilder = $filterBuilder;
}
/**
@@ -41,9 +61,9 @@ public function __construct(CaseRepositoryInterface $caseRepository, CaseInterfa
*/
public function create($orderId)
{
- $case = $this->caseFactory->create(
- ['data' => ['order_id' => $orderId, 'status' => CaseInterface::STATUS_PROCESSING]]
- );
+ $case = $this->caseFactory->create();
+ $case->setOrderId($orderId)
+ ->setStatus(CaseInterface::STATUS_PENDING);
return $this->caseRepository->save($case);
}
@@ -52,6 +72,13 @@ public function create($orderId)
*/
public function getByOrderId($orderId)
{
- return $this->caseRepository->getById($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
index 916cbe6136817..e9e326a459dd5 100644
--- a/app/code/Magento/Signifyd/Model/CaseRepository.php
+++ b/app/code/Magento/Signifyd/Model/CaseRepository.php
@@ -6,10 +6,15 @@
namespace Magento\Signifyd\Model;
use Magento\Framework\Api\SearchCriteria;
-use Magento\Framework\EntityManager\EntityManager;
+use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Api\Data\CaseInterfaceFactory;
+use Magento\Signifyd\Api\Data\CaseSearchResultsInterface;
+use Magento\Signifyd\Api\Data\CaseSearchResultsInterfaceFactory;
+use Magento\Signifyd\Model\ResourceModel\CaseEntity as CaseResourceModel;
+use Magento\Signifyd\Model\ResourceModel\CaseEntity\Collection;
+use Magento\Signifyd\Model\ResourceModel\CaseEntity\CollectionFactory;
/**
* Repository for Case interface
@@ -17,24 +22,50 @@
class CaseRepository implements CaseRepositoryInterface
{
/**
- * @var EntityManager
+ * @var CollectionProcessorInterface
*/
- private $entityManager;
+ private $collectionProcessor;
+
+ /**
+ * @var CollectionFactory
+ */
+ private $collectionFactory;
+
+ /**
+ * @var CaseSearchResultsInterfaceFactory
+ */
+ private $searchResultsFactory;
/**
* @var CaseInterfaceFactory
*/
private $caseFactory;
+ /**
+ * @var CaseResourceModel
+ */
+ private $resourceModel;
+
/**
* CaseRepository constructor.
- * @param EntityManager $entityManager
+ * @param CollectionProcessorInterface $collectionProcessor
+ * @param CollectionFactory $collectionFactory
+ * @param CaseSearchResultsInterfaceFactory $searchResultsFactory
* @param CaseInterfaceFactory $caseFactory
+ * @param CaseResourceModel $resourceModel
*/
- public function __construct(EntityManager $entityManager, CaseInterfaceFactory $caseFactory)
- {
- $this->entityManager = $entityManager;
+ public function __construct(
+ CollectionProcessorInterface $collectionProcessor,
+ CollectionFactory $collectionFactory,
+ CaseSearchResultsInterfaceFactory $searchResultsFactory,
+ CaseInterfaceFactory $caseFactory,
+ CaseResourceModel $resourceModel
+ ) {
+ $this->collectionProcessor = $collectionProcessor;
+ $this->collectionFactory = $collectionFactory;
+ $this->searchResultsFactory = $searchResultsFactory;
$this->caseFactory = $caseFactory;
+ $this->resourceModel = $resourceModel;
}
/**
@@ -42,15 +73,47 @@ public function __construct(EntityManager $entityManager, CaseInterfaceFactory $
*/
public function save(CaseInterface $case)
{
- return $this->entityManager->save($case);
+ /** @var CaseEntity $case */
+ $this->resourceModel->save($case);
+ return $case;
}
/**
* @inheritdoc
*/
- public function getById($orderId)
+ public function getById($id)
{
+ /** @var CaseEntity $case */
$case = $this->caseFactory->create();
- return $this->entityManager->load($case, $orderId);
+ $this->resourceModel->load($case, $id);
+ return $case;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function delete(CaseInterface $case)
+ {
+ $this->resourceModel->delete($case);
+ return true;
+ }
+
+ /**
+ * Gets list of case entities
+ * @param SearchCriteria $searchCriteria
+ * @return CaseSearchResultsInterface
+ */
+ public function getList(SearchCriteria $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/ResourceModel/CaseEntity.php b/app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity.php
new file mode 100644
index 0000000000000..c86f97812900d
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity.php
@@ -0,0 +1,22 @@
+_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
new file mode 100644
index 0000000000000..d8e999516a294
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity/Collection.php
@@ -0,0 +1,24 @@
+_init(CaseEntity::class, CaseResourceModel::class);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index c12399e669394..dfd9a7cfcab19 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -41,7 +41,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
$table->addColumn('case_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('guarantee_eligible', Table::TYPE_BOOLEAN, null);
$table->addColumn('guarantee_disposition', Table::TYPE_TEXT, 32);
- $table->addColumn('status', Table::TYPE_TEXT, 32, ['default' => CaseInterface::STATUS_PROCESSING]);
+ $table->addColumn('status', Table::TYPE_TEXT, 32, ['default' => CaseInterface::STATUS_PENDING]);
$table->addColumn('score', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('associated_team', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('review_disposition', Table::TYPE_TEXT, 32);
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 3abcaad08a639..6b49c74337868 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -9,31 +9,5 @@
-
-
-
-
-
- -
-
- Magento\Framework\EntityManager\Operation\Read
- - Magento\Framework\EntityManager\Operation\Create
- - Magento\Framework\EntityManager\Operation\Update
-
-
-
-
-
-
-
-
-
-
- -
-
- signifyd_case
- - order_id
-
-
-
-
-
+
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
index c81a18a8afc99..fe85408204dfd 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
@@ -45,7 +45,7 @@ public function testCreate()
$case = $this->caseManagement->create($order->getEntityId());
static::assertNotEmpty($case->getEntityId());
- static::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus());
+ static::assertEquals(CaseInterface::STATUS_PENDING, $case->getStatus());
}
/**
From b632d5fdf3139a0e17e051723ffff38e90ca897e Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 13 Dec 2016 06:28:08 -0600
Subject: [PATCH 015/225] MAGETWO-61913: Create request builders
- Update builders
---
.../Signifyd/Model/Request/CardBuilder.php | 12 +++--
.../Model/Request/ClientVersionBuilder.php | 8 +--
.../Model/Request/CreateCaseBuilder.php | 40 ++++++++++++---
.../Model/Request/PurchaseBuilder.php | 49 ++++---------------
.../Model/Request/RecipientBuilder.php | 12 +++--
.../Signifyd/Model/Request/SellerBuilder.php | 39 +++++++++++++--
.../Model/Request/UserAccountBuilder.php | 19 ++++---
7 files changed, 107 insertions(+), 72 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/Request/CardBuilder.php b/app/code/Magento/Signifyd/Model/Request/CardBuilder.php
index ec3e08f428b50..2c931924d9c2a 100644
--- a/app/code/Magento/Signifyd/Model/Request/CardBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/CardBuilder.php
@@ -42,11 +42,13 @@ public function build(Order $order)
$payment = $order->getPayment();
$result = [
- 'cardHolderName' => $address->getFirstname() . ' ' . $address->getLastname(),
- 'last4' => $payment->getCcLast4(),
- 'expiryMonth' => $payment->getCcExpMonth(),
- 'expiryYear' => $payment->getCcExpYear(),
- 'billingAddress' => $this->addressBuilder->build($address),
+ '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/Request/ClientVersionBuilder.php b/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
index 4c8f4e843163a..25ee03da20dc1 100644
--- a/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Signifyd\Model\Request;
-use Magento\Framework\App\ProductMetadata;
+use Magento\Framework\App\ProductMetadataInterface;
/**
* Class ClientVersionBuilder
@@ -13,15 +13,15 @@
class ClientVersionBuilder
{
/**
- * @var ProductMetadata
+ * @var ProductMetadataInterface
*/
private $productMetadata;
/**
- * @param ProductMetadata $productMetadata
+ * @param ProductMetadataInterface $productMetadata
*/
public function __construct(
- ProductMetadata $productMetadata
+ ProductMetadataInterface $productMetadata
) {
$this->productMetadata = $productMetadata;
}
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
index 926c5354af57a..5abaeffc01b01 100644
--- a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
@@ -83,13 +83,39 @@ public function build($orderId)
/* @var $order \Magento\Sales\Model\Order */
$order = $this->orderFactory->create()->load($orderId);
- return 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()
+ 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 ($data[$key] === null ||
+ $data[$key] === '' ||
+ (is_array($data[$key]) && empty($data[$key]))
+ ) {
+ unset($data[$key]);
+ }
+ }
+
+ return $data;
+ }
}
diff --git a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
index 215c5f39a172d..f64bf75c30e14 100644
--- a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
@@ -63,9 +63,15 @@ public function build(Order $order)
],
];
- $shipments = $this->getShipments($order);
- if (!empty($shipments)) {
- $result['purchase']['shipments'] = $shipments;
+ $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);
@@ -99,43 +105,6 @@ private function getProducts(Order $order)
return $result;
}
- /**
- * Gets the shipments associated with this purchase.
- *
- * @param Order $order
- * @return array
- */
- private function getShipments(Order $order)
- {
- $result = [];
- $shipper = $this->getShipper($order->getShippingDescription());
- $shippingMethod = $this->getShippingMethod($order->getShippingDescription());
-
- $shipmentList = $order->getShipmentsCollection();
- /** @var \Magento\Sales\Api\Data\ShipmentInterface $shipment */
- foreach ($shipmentList as $shipment) {
- $totalPrice = 0;
- foreach ($shipment->getItems() as $shipmentItem) {
- $totalPrice += $shipmentItem->getPrice();
- }
-
- $item = [
- 'shipper' => $shipper,
- 'shippingMethod' => $shippingMethod,
- 'shippingPrice' => $totalPrice
- ];
-
- $tracks = $shipment->getTracks();
- if (!empty($tracks)) {
- $item['trackingNumber'] = end($tracks)->getTrackNumber();
- }
-
- $result[] = $item;
- }
-
- return $result;
- }
-
/**
* Gets the name of the shipper
*
diff --git a/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php b/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
index 38cb79d32de2b..510276d1cc75c 100644
--- a/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
@@ -41,11 +41,13 @@ public function build(Order $order)
}
$result = [
- 'fullName' => $address->getName(),
- 'confirmationEmail' => $address->getEmail(),
- 'confirmationPhone' => $address->getTelephone(),
- 'organization' => $address->getCompany(),
- 'deliveryAddress' => $this->addressBuilder->build($address)
+ '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/Request/SellerBuilder.php b/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
index 62977c6d81e51..21b319421d57c 100644
--- a/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Signifyd\Model\Request;
+use Magento\Directory\Model\RegionFactory;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Shipment;
@@ -24,13 +25,26 @@ class SellerBuilder
*/
private $scopeConfig;
+ /**
+ * @var RegionFactory
+ */
+ private $regionFactory;
+
+ /**
+ * @var array
+ */
+ private $regionCodes = [];
+
/**
* @param ScopeConfigInterface $scopeConfig
+ * @param RegionFactory $regionFactory
*/
public function __construct(
- ScopeConfigInterface $scopeConfig
+ ScopeConfigInterface $scopeConfig,
+ RegionFactory $regionFactory
) {
$this->scopeConfig = $scopeConfig;
+ $this->regionFactory = $regionFactory;
}
/**
@@ -51,7 +65,9 @@ public function build(Order $order)
'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->getConfigValue(Shipment::XML_PATH_STORE_REGION_ID, $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),
],
@@ -59,7 +75,9 @@ public function build(Order $order)
'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->getConfigValue(Information::XML_PATH_STORE_INFO_REGION_CODE, $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),
]
@@ -67,6 +85,21 @@ public function build(Order $order)
];
}
+ /**
+ * Get 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];
+ }
+
/**
* Gets value from config
*
diff --git a/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
index 198b57d3e238e..c3296984be6b5 100644
--- a/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
@@ -36,6 +36,7 @@ class UserAccountBuilder
* @var array
*/
private $currencies = [];
+
/**
* @var CustomerOrders
*/
@@ -85,12 +86,14 @@ public function build(Order $order)
$customer = $this->customerRepository->getById($customerId);
$result = [
- 'email' => $customer->getEmail(),
- 'username' => $customer->getEmail(),
- 'phone' => $order->getBillingAddress()->getTelephone(),
- 'accountNumber' => $customerId,
- 'createdDate' => $this->formatDate($customer->getCreatedAt()),
- 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt())
+ 'userAccount' => [
+ 'email' => $customer->getEmail(),
+ 'username' => $customer->getEmail(),
+ 'phone' => $order->getBillingAddress()->getTelephone(),
+ 'accountNumber' => $customerId,
+ 'createdDate' => $this->formatDate($customer->getCreatedAt()),
+ 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt())
+ ]
];
$customerOrders = $this->customerOrders->get($customerId);
@@ -103,8 +106,8 @@ public function build(Order $order)
$order->getBaseCurrencyCode()
);
}
- $result['aggregateOrderCount'] = count($customerOrders);
- $result['aggregateOrderDollars'] = $orderTotalDollars;
+ $result['userAccount']['aggregateOrderCount'] = count($customerOrders);
+ $result['userAccount']['aggregateOrderDollars'] = $orderTotalDollars;
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
}
From 8746dcbb75d4469a6234364ea6e5a717a15ac822 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 13 Dec 2016 06:34:30 -0600
Subject: [PATCH 016/225] MAGETWO-61925: Create case entity infrastructure
- Fixed failed static test
---
app/code/Magento/Signifyd/Model/CaseEntity.php | 7 ++-----
app/code/Magento/Signifyd/Model/CaseRepository.php | 2 ++
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index b3a7b05ac217a..85783da3308da 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -197,8 +197,7 @@ public function setCreatedAt($datetime)
}
/**
- * Gets updating datetime for a case
- * @return string
+ * @inheritdoc
*/
public function getUpdatedAt()
{
@@ -206,9 +205,7 @@ public function getUpdatedAt()
}
/**
- * Sets updating datetime for a case
- * @param $datetime
- * @return $this
+ * @inheritdoc
*/
public function setUpdatedAt($datetime)
{
diff --git a/app/code/Magento/Signifyd/Model/CaseRepository.php b/app/code/Magento/Signifyd/Model/CaseRepository.php
index e9e326a459dd5..723dea8421167 100644
--- a/app/code/Magento/Signifyd/Model/CaseRepository.php
+++ b/app/code/Magento/Signifyd/Model/CaseRepository.php
@@ -18,6 +18,8 @@
/**
* Repository for Case interface
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CaseRepository implements CaseRepositoryInterface
{
From 5bb77275376c21eab05ba136936409acc98a3964 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 13 Dec 2016 07:51:03 -0600
Subject: [PATCH 017/225] MAGETWO-61913: Create request builders
- Replace ISO8601 with ATOM
---
app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php | 2 +-
app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
index f64bf75c30e14..16de64b869cd1 100644
--- a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
@@ -54,7 +54,7 @@ public function build(Order $order)
'purchase' => [
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
- 'createdAt' => $createdAt->format(\DateTime::ISO8601),
+ 'createdAt' => $createdAt->format(\DateTime::ATOM),
'paymentGateway' => $this->getPaymentGateway($orderPayment->getMethod()),
'transactionId' => $orderPayment->getLastTransId(),
'currency' => $order->getOrderCurrencyCode(),
diff --git a/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
index c3296984be6b5..6cb33697488f6 100644
--- a/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
@@ -166,6 +166,6 @@ private function formatDate($date)
new \DateTimeZone('UTC')
);
- return $result->format(\DateTime::ISO8601);
+ return $result->format(\DateTime::ATOM);
}
}
From bec36977b6a254b343827b2d5f838323c3466373 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 13 Dec 2016 07:59:27 -0600
Subject: [PATCH 018/225] MAGETWO-61913: Create request builders
- integration tests
---
.../Model/Request/CreateCaseBuilderTest.php | 108 ++++++++++++++++++
.../Magento/Signifyd/_files/order.php | 77 +++++++++++++
2 files changed, 185 insertions(+)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
new file mode 100644
index 0000000000000..bda6802572507
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
@@ -0,0 +1,108 @@
+loadArea(Area::AREA_FRONTEND);
+ $this->objectManager = Bootstrap::getObjectManager();
+
+ $this->order = $this->objectManager->create(Order::class);
+ $this->order->loadByIncrementId(self::ORDER_INCREMENT_ID);
+
+ $this->caseBuilder = $this->objectManager->create(CreateCaseBuilder::class);
+ $this->builderData = $this->caseBuilder->build($this->order->getEntityId());
+ }
+
+ /**
+ * Check the stability purchaseBuilder
+ *
+ * @magentoDataFixture Magento/Signifyd/_files/order.php
+ */
+ public function testPurchaseBuilder()
+ {
+ $orderMethod = 'paypal_account';
+ $orderChannel = 'WEB';
+ $shippingProvider = 'Flat Rate';
+ $shippingMethod = 'Fixed';
+
+ $purchaseData = $this->builderData['purchase'];
+
+ $dateTimeFactory = $this->objectManager->get(DateTimeFactory::class);
+ $createdAt = $dateTimeFactory->create(
+ $this->order->getCreatedAt(),
+ new \DateTimeZone('UTC')
+ );
+
+ $orderPayment = $this->order->getPayment();
+
+ $orderItems = $this->order->getAllItems();
+ $product = $orderItems[0]->getProduct();
+ $purchaseProducts = $purchaseData['products'][0];
+
+ static::assertEquals($this->order->getRemoteIp(), $purchaseData['browserIpAddress']);
+ static::assertEquals($shippingProvider, $purchaseData['shipments'][0]['shipper']);
+ static::assertEquals($shippingMethod, $purchaseData['shipments'][0]['shippingMethod']);
+ //static::assertEquals($this->order->getShippingAmount(), $purchaseData['shipments'][0]['shippingPrice']);
+ static::assertEquals($this->order->getEntityId(), $purchaseData['orderId']);
+ static::assertEquals($createdAt->format(\DateTime::ISO8601), $purchaseData['createdAt']);
+
+ static::assertEquals($orderMethod, $purchaseData['paymentGateway']);
+ static::assertEquals($orderPayment->getLastTransId(), $purchaseData['transactionId']);
+ static::assertEquals($this->order->getOrderCurrencyCode(), $purchaseData['currency']);
+ static::assertEquals($orderChannel, $purchaseData['orderChannel']);
+ static::assertEquals($this->order->getGrandTotal(), $purchaseData['totalPrice']);
+
+ //static::assertEquals($product->getSku(), $purchaseProducts['itemId']);
+ //static::assertEquals($product->getName(), $purchaseProducts['itemName']);
+ static::assertEquals($orderItems[0]->getPrice(), $purchaseProducts['itemPrice']);
+ static::assertEquals($orderItems[0]->getQtyOrdered(), $purchaseProducts['itemQuantity']);
+ static::assertEquals($product->getProductUrl(), $purchaseProducts['itemUrl']);
+ static::assertEquals($product->getWeight(), $purchaseProducts['itemWeight']);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
new file mode 100644
index 0000000000000..762c952b36743
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
@@ -0,0 +1,77 @@
+create(Address::class, ['data' => $addressData]);
+$billingAddress->setAddressType('billing');
+
+$shippingAddress = clone $billingAddress;
+$shippingAddress->setid(null)
+ ->setAddressType('shipping')
+ ->setShippingMethod('flatrate_flatrate');
+
+$payment = $objectManager->create(Payment::class);
+$payment->setMethod(PaypalConfig::METHOD_WPP_EXPRESS);
+
+/** @var Item $orderItem */
+$orderItem = $objectManager->create(Item::class);
+$orderItem->setProductId($product->getId())
+ ->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('100000001')
+ ->setState(Order::STATE_PROCESSING)
+ ->setStatus(Order::STATE_PROCESSING)
+ ->setCreatedAt('2016-12-12T12:00:55+0000')
+ ->setBaseGrandTotal($orderAmount)
+ ->setSubtotal($orderAmount)
+ ->setGrandTotal($orderAmount)
+ ->setBaseSubtotal($orderAmount)
+ ->setBaseGrandTotal($orderAmount)
+ ->setCustomerIsGuest(true)
+ ->setCustomerEmail($customerEmail)
+ ->setBillingAddress($billingAddress)
+ ->setShippingAddress($shippingAddress)
+ ->setShippingDescription('Flat Rate - Fixed')
+ ->setShippingAmount(10)
+ ->setStoreId($objectManager->get(StoreManagerInterface::class)->getStore()->getId())
+ ->addItem($orderItem)
+ ->setPayment($payment);
+
+/** @var OrderRepositoryInterface $orderRepository */
+$orderRepository = $objectManager->get(OrderRepositoryInterface::class);
+$orderRepository->save($order);
+
+$shipmentItem = $objectManager->create(\Magento\Sales\Model\Order\Shipment\Item::class);
+$shipmentItem->setOrderItem($orderItem);
+
+/** @var \Magento\Sales\Model\Order\Shipment $shipment */
+$shipment = $objectManager->create(\Magento\Sales\Model\Order\Shipment::class);
+$shipment->setOrder($order)
+ ->addItem($shipmentItem)
+ ->setShipmentStatus(\Magento\Sales\Model\Order\Shipment::STATUS_NEW)
+ ->save();
From adfe3918834fd4b566697c3c6b0188b6813eb6fd Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 13 Dec 2016 08:17:07 -0600
Subject: [PATCH 019/225] MAGETWO-61913: Create request builders
- Declare Store dependency
---
app/code/Magento/Signifyd/composer.json | 2 +-
app/code/Magento/Signifyd/etc/module.xml | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index cc8bd9d228508..69a42f2aa3336 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -5,7 +5,7 @@
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"magento/framework": "100.2.*",
"magento/module-sales": "100.2.*",
- "magento/module-checkout": "100.2.*"
+ "magento/module-store": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 1ee26044bbef4..aa2d26414b484 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,6 +9,7 @@
+
From e68affec3721065c6df0876312752c238c2c2082 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 13 Dec 2016 09:44:34 -0600
Subject: [PATCH 020/225] MAGETWO-61925: Create case entity infrastructure
- Updated interface annotation
- Added integration test for case repository
---
.../Signifyd/Api/CaseManagementInterface.php | 2 +-
.../Signifyd/Model/CaseRepositoryTest.php | 148 ++++++++++++++++++
.../Signifyd/_files/multiple_cases.php | 27 ++++
3 files changed, 176 insertions(+), 1 deletion(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/multiple_cases.php
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index c4d6005011b93..cced6d2e4afe3 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -18,7 +18,7 @@ interface CaseManagementInterface
/**
* Creates new Case entity
* @param string $orderId
- * @return void
+ * @return CaseInterface
*/
public function create($orderId);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php
new file mode 100644
index 0000000000000..05a2eb443b248
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php
@@ -0,0 +1,148 @@
+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);
+
+ static::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());
+
+ static::assertNotEmpty($found->getEntityId());
+ static::assertEquals($case->getEntityId(), $found->getEntityId());
+ static::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();
+
+ static::assertCount(3, $items);
+
+ for ($i = 1; $i < 4; $i ++) {
+ $current = array_shift($items);
+ static::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();
+
+ static::assertCount(1, $items);
+
+ $case = array_pop($items);
+ static::assertEquals(123, $case->getCaseId());
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/multiple_cases.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/multiple_cases.php
new file mode 100644
index 0000000000000..e0c0f61310077
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/multiple_cases.php
@@ -0,0 +1,27 @@
+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);
+}
From e4be7f2b00447a03ce11079eb80708ce2e709bce Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 13 Dec 2016 12:06:39 -0600
Subject: [PATCH 021/225] MAGETWO-61913: Create request builders
- integration test
---
.../Model/Request/CreateCaseBuilderTest.php | 108 ++++++++++++------
.../Magento/Signifyd/_files/customer.php | 38 ++++++
.../Magento/Signifyd/_files/order.php | 29 +++--
3 files changed, 130 insertions(+), 45 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/customer.php
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
index bda6802572507..9186b6c6f0932 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
@@ -10,6 +10,7 @@
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\ObjectManagerInterface;
use Magento\Sales\Model\Order;
+use Magento\Customer\Api\CustomerRepositoryInterface;
/**
* Class PurchaseBuilderTest
@@ -66,43 +67,78 @@ protected function setUp()
*/
public function testPurchaseBuilder()
{
- $orderMethod = 'paypal_account';
- $orderChannel = 'WEB';
- $shippingProvider = 'Flat Rate';
- $shippingMethod = 'Fixed';
-
- $purchaseData = $this->builderData['purchase'];
-
- $dateTimeFactory = $this->objectManager->get(DateTimeFactory::class);
- $createdAt = $dateTimeFactory->create(
- $this->order->getCreatedAt(),
- new \DateTimeZone('UTC')
- );
-
- $orderPayment = $this->order->getPayment();
-
$orderItems = $this->order->getAllItems();
$product = $orderItems[0]->getProduct();
- $purchaseProducts = $purchaseData['products'][0];
-
- static::assertEquals($this->order->getRemoteIp(), $purchaseData['browserIpAddress']);
- static::assertEquals($shippingProvider, $purchaseData['shipments'][0]['shipper']);
- static::assertEquals($shippingMethod, $purchaseData['shipments'][0]['shippingMethod']);
- //static::assertEquals($this->order->getShippingAmount(), $purchaseData['shipments'][0]['shippingPrice']);
- static::assertEquals($this->order->getEntityId(), $purchaseData['orderId']);
- static::assertEquals($createdAt->format(\DateTime::ISO8601), $purchaseData['createdAt']);
-
- static::assertEquals($orderMethod, $purchaseData['paymentGateway']);
- static::assertEquals($orderPayment->getLastTransId(), $purchaseData['transactionId']);
- static::assertEquals($this->order->getOrderCurrencyCode(), $purchaseData['currency']);
- static::assertEquals($orderChannel, $purchaseData['orderChannel']);
- static::assertEquals($this->order->getGrandTotal(), $purchaseData['totalPrice']);
-
- //static::assertEquals($product->getSku(), $purchaseProducts['itemId']);
- //static::assertEquals($product->getName(), $purchaseProducts['itemName']);
- static::assertEquals($orderItems[0]->getPrice(), $purchaseProducts['itemPrice']);
- static::assertEquals($orderItems[0]->getQtyOrdered(), $purchaseProducts['itemQuantity']);
- static::assertEquals($product->getProductUrl(), $purchaseProducts['itemUrl']);
- static::assertEquals($product->getWeight(), $purchaseProducts['itemWeight']);
+ $payment = $this->order->getPayment();
+ $billingAddress = $this->order->getBillingAddress();
+ $shippingAddress = $this->order->getShippingAddress();
+
+ $customerRepository = $this->objectManager->create(CustomerRepositoryInterface::class);
+ $customer = $customerRepository->getById(1);
+
+ $expected = [
+ 'purchase' => [
+ 'browserIpAddress' => $this->order->getRemoteIp(),
+ 'orderId' => $this->order->getEntityId(),
+ 'createdAt' => '2016-12-12T12:00:55+00:00',
+ 'paymentGateway' => 'paypal_account',
+ 'transactionId' => $payment->getLastTransId(),
+ 'currency' => $this->order->getOrderCurrencyCode(),
+ 'orderChannel' => 'WEB',
+ 'totalPrice' => $this->order->getGrandTotal(),
+ 'shipments' => [
+ 0 => [
+ 'shipper' => 'Flat Rate',
+ 'shippingMethod' => 'Fixed',
+ 'shippingPrice' => $this->order->getShippingAmount()
+ ]
+ ],
+ 'products' => [
+ 0 => [
+ 'itemId' => $orderItems[0]->getSku(),
+ 'itemName' => $orderItems[0]->getName(),
+ 'itemPrice' => $orderItems[0]->getPrice(),
+ 'itemQuantity' => $orderItems[0]->getQtyOrdered(),
+ 'itemUrl' => $product->getProductUrl(),
+ 'itemWeight' => $product->getWeight()
+ ]
+ ]
+ ],
+ '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()
+ ]
+ ],
+ 'recipient' => [
+ 'fullName' => $shippingAddress->getName(),
+ 'confirmationEmail' => $shippingAddress->getEmail(),
+ 'confirmationPhone' => $shippingAddress->getTelephone(),
+ 'deliveryAddress' => [
+ 'streetAddress' => 'street',
+ 'city' => $shippingAddress->getCity(),
+ 'provinceCode' => $shippingAddress->getRegionCode(),
+ 'postalCode' => $shippingAddress->getPostcode(),
+ 'countryCode' => $shippingAddress->getCountryId()
+ ]
+ ],
+ 'userAccount' => [
+ 'email' => $customer->getEmail(),
+ 'username' => $customer->getEmail(),
+ 'phone' => $this->order->getBillingAddress()->getTelephone(),
+ 'accountNumber' => $customer->getId(),
+ 'createdDate' => '2016-12-12 11:00:00+00:00',
+ 'lastUpdateDate' => '2016-12-12 11:05:00+00:00'
+ ]
+ ];
+
+ static::assertEquals($expected['userAccount'], $this->builderData['userAccount']);
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/customer.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/customer.php
new file mode 100644
index 0000000000000..df9a814b2ec5b
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/customer.php
@@ -0,0 +1,38 @@
+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/order.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
index 762c952b36743..285f2a28394bd 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
@@ -11,10 +11,13 @@
use Magento\Store\Model\StoreManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Paypal\Model\Config as PaypalConfig;
+use Magento\Sales\Model\Order\Shipment\Item as ShipmentItem;
+use Magento\Sales\Model\Order\Shipment;
require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php';
+require __DIR__ . '/customer.php';
-$addressData = include __DIR__ . '/../../../Magento/Sales/_files/address_data.php';
+$addressData = require __DIR__ . '/../../../Magento/Sales/_files/address_data.php';
$objectManager = Bootstrap::getObjectManager();
@@ -22,16 +25,22 @@
$billingAddress->setAddressType('billing');
$shippingAddress = clone $billingAddress;
-$shippingAddress->setid(null)
+$shippingAddress->setId(null)
->setAddressType('shipping')
->setShippingMethod('flatrate_flatrate');
$payment = $objectManager->create(Payment::class);
-$payment->setMethod(PaypalConfig::METHOD_WPP_EXPRESS);
+$payment->setMethod(PaypalConfig::METHOD_WPP_EXPRESS)
+ ->setLastTransId('00001')
+ ->setCcLast4('1234')
+ ->setCcExpMonth('01')
+ ->setCcExpYear('21');
/** @var Item $orderItem */
$orderItem = $objectManager->create(Item::class);
$orderItem->setProductId($product->getId())
+ ->setSku($product->getSku())
+ ->setName($product->getName())
->setQtyOrdered(1)
->setBasePrice($product->getPrice())
->setPrice($product->getPrice())
@@ -46,13 +55,13 @@
$order->setIncrementId('100000001')
->setState(Order::STATE_PROCESSING)
->setStatus(Order::STATE_PROCESSING)
+ ->setRemoteIp('127.0.0.1')
->setCreatedAt('2016-12-12T12:00:55+0000')
- ->setBaseGrandTotal($orderAmount)
+ ->setOrderCurrencyCode('USD')
->setSubtotal($orderAmount)
->setGrandTotal($orderAmount)
->setBaseSubtotal($orderAmount)
->setBaseGrandTotal($orderAmount)
- ->setCustomerIsGuest(true)
->setCustomerEmail($customerEmail)
->setBillingAddress($billingAddress)
->setShippingAddress($shippingAddress)
@@ -60,18 +69,20 @@
->setShippingAmount(10)
->setStoreId($objectManager->get(StoreManagerInterface::class)->getStore()->getId())
->addItem($orderItem)
- ->setPayment($payment);
+ ->setPayment($payment)
+ ->setCustomerId(1)
+ ->setCustomerIsGuest(false);
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $objectManager->get(OrderRepositoryInterface::class);
$orderRepository->save($order);
-$shipmentItem = $objectManager->create(\Magento\Sales\Model\Order\Shipment\Item::class);
+$shipmentItem = $objectManager->create(ShipmentItem::class);
$shipmentItem->setOrderItem($orderItem);
/** @var \Magento\Sales\Model\Order\Shipment $shipment */
-$shipment = $objectManager->create(\Magento\Sales\Model\Order\Shipment::class);
+$shipment = $objectManager->create(Shipment::class);
$shipment->setOrder($order)
->addItem($shipmentItem)
- ->setShipmentStatus(\Magento\Sales\Model\Order\Shipment::STATUS_NEW)
+ ->setShipmentStatus(Shipment::STATUS_NEW)
->save();
From 530c5f04abff932f313cddea96a3feca0315c6b3 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 14 Dec 2016 04:55:01 -0600
Subject: [PATCH 022/225] MAGETWO-61913: Create request builders
- Make filtering empty values more obvious
---
.../Signifyd/Model/Request/CreateCaseBuilder.php | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
index 5abaeffc01b01..b108bfa8cade6 100644
--- a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
@@ -108,14 +108,22 @@ private function removeEmptyValues($data)
$data[$key] = $this->removeEmptyValues($data[$key]);
}
- if ($data[$key] === null ||
- $data[$key] === '' ||
- (is_array($data[$key]) && empty($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 || $value === '' || (is_array($value) && empty($value));
+ }
}
From a8b0a39b70ad982223c7beafc3ac56d1102ab050 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 14 Dec 2016 05:05:04 -0600
Subject: [PATCH 023/225] MAGETWO-61913: Create request builders
- integration test
---
.../Model/Request/CreateCaseBuilderTest.php | 69 +++++++++++++++++--
.../Magento/Signifyd/_files/order.php | 38 +++++++---
.../Magento/Signifyd/_files/store.php | 31 +++++++++
3 files changed, 120 insertions(+), 18 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
index 9186b6c6f0932..2ca933376d66c 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
@@ -11,7 +11,7 @@
use Magento\Framework\ObjectManagerInterface;
use Magento\Sales\Model\Order;
use Magento\Customer\Api\CustomerRepositoryInterface;
-
+use Magento\Framework\App\ProductMetadataInterface;
/**
* Class PurchaseBuilderTest
* @magentoAppIsolation enabled
@@ -44,6 +44,11 @@ class CreateCaseBuilderTest extends \PHPUnit_Framework_TestCase
*/
private $builderData;
+ /**
+ * @var DateTimeFactory
+ */
+ private $dateTimeFactory;
+
/**
* Initial setup
*/
@@ -53,6 +58,8 @@ protected function setUp()
$bootstrap->loadArea(Area::AREA_FRONTEND);
$this->objectManager = Bootstrap::getObjectManager();
+ $this->dateTimeFactory = $this->objectManager->create(DateTimeFactory::class);
+
$this->order = $this->objectManager->create(Order::class);
$this->order->loadByIncrementId(self::ORDER_INCREMENT_ID);
@@ -72,9 +79,9 @@ public function testPurchaseBuilder()
$payment = $this->order->getPayment();
$billingAddress = $this->order->getBillingAddress();
$shippingAddress = $this->order->getShippingAddress();
-
$customerRepository = $this->objectManager->create(CustomerRepositoryInterface::class);
- $customer = $customerRepository->getById(1);
+ $customer = $customerRepository->getById($this->order->getCustomerId());
+ $productMetadata = $this->objectManager->create(ProductMetadataInterface::class);
$expected = [
'purchase' => [
@@ -101,6 +108,14 @@ public function testPurchaseBuilder()
'itemQuantity' => $orderItems[0]->getQtyOrdered(),
'itemUrl' => $product->getProductUrl(),
'itemWeight' => $product->getWeight()
+ ],
+ 1 => [
+ 'itemId' => 'simple2',
+ 'itemName' => 'Simple product',
+ 'itemPrice' => $orderItems[1]->getPrice(),
+ 'itemQuantity' => $orderItems[1]->getQtyOrdered(),
+ 'itemUrl' => $product->getProductUrl(),
+ 'itemWeight' => $product->getWeight()
]
]
],
@@ -122,7 +137,7 @@ public function testPurchaseBuilder()
'confirmationEmail' => $shippingAddress->getEmail(),
'confirmationPhone' => $shippingAddress->getTelephone(),
'deliveryAddress' => [
- 'streetAddress' => 'street',
+ 'streetAddress' => '6161 West Centinela Avenue',
'city' => $shippingAddress->getCity(),
'provinceCode' => $shippingAddress->getRegionCode(),
'postalCode' => $shippingAddress->getPostcode(),
@@ -134,11 +149,51 @@ public function testPurchaseBuilder()
'username' => $customer->getEmail(),
'phone' => $this->order->getBillingAddress()->getTelephone(),
'accountNumber' => $customer->getId(),
- 'createdDate' => '2016-12-12 11:00:00+00:00',
- 'lastUpdateDate' => '2016-12-12 11:05:00+00:00'
+ 'createdDate' => $this->formatDate($customer->getCreatedAt()),
+ 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt())
+ ],
+ 'seller' => [
+ 'name' => 'Sample Store',
+ 'domain' => 'm2.com',
+ 'shipFromAddress' => [
+ 'streetAddress' => '6161 West Centinela Avenue',
+ 'unit' => 'app. 111',
+ 'city' => 'Culver City',
+ 'provinceCode' => 'AE',
+ 'postalCode' => '90230',
+ 'countryCode' => 1,
+ ],
+ 'corporateAddress' => [
+ 'streetAddress' => '5th Avenue',
+ 'unit' => '75',
+ 'city' => 'New York',
+ 'provinceCode' => 'MH',
+ 'postalCode' => '19032',
+ 'countryCode' => 1,
+ ],
+ ],
+ 'clientVersion' => [
+ 'platform' => $productMetadata->getName() . ' ' . $productMetadata->getEdition(),
+ 'platformVersion' => $productMetadata->getVersion()
]
];
- static::assertEquals($expected['userAccount'], $this->builderData['userAccount']);
+ static::assertEquals($expected, $this->builderData);
+ }
+
+ /**
+ * 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/_files/order.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
index 285f2a28394bd..092b31553f3a7 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
@@ -8,14 +8,14 @@
use Magento\Sales\Model\Order\Address;
use Magento\Sales\Model\Order\Item;
use Magento\Sales\Api\OrderRepositoryInterface;
-use Magento\Store\Model\StoreManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Paypal\Model\Config as PaypalConfig;
use Magento\Sales\Model\Order\Shipment\Item as ShipmentItem;
use Magento\Sales\Model\Order\Shipment;
require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php';
-require __DIR__ . '/customer.php';
+require __DIR__ . '/../../../Magento/Customer/_files/customer.php';
+require __DIR__ . '/store.php';
$addressData = require __DIR__ . '/../../../Magento/Sales/_files/address_data.php';
@@ -27,6 +27,9 @@
$shippingAddress = clone $billingAddress;
$shippingAddress->setId(null)
->setAddressType('shipping')
+ ->setStreet('6161 West Centinela Avenue')
+ ->setFirstname('John')
+ ->setLastname('Doe')
->setShippingMethod('flatrate_flatrate');
$payment = $objectManager->create(Payment::class);
@@ -37,8 +40,8 @@
->setCcExpYear('21');
/** @var Item $orderItem */
-$orderItem = $objectManager->create(Item::class);
-$orderItem->setProductId($product->getId())
+$orderItem1 = $objectManager->create(Item::class);
+$orderItem1->setProductId($product->getId())
->setSku($product->getSku())
->setName($product->getName())
->setQtyOrdered(1)
@@ -47,6 +50,18 @@
->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();
@@ -55,6 +70,8 @@
$order->setIncrementId('100000001')
->setState(Order::STATE_PROCESSING)
->setStatus(Order::STATE_PROCESSING)
+ ->setCustomerId($customer->getId())
+ ->setCustomerIsGuest(false)
->setRemoteIp('127.0.0.1')
->setCreatedAt('2016-12-12T12:00:55+0000')
->setOrderCurrencyCode('USD')
@@ -67,20 +84,19 @@
->setShippingAddress($shippingAddress)
->setShippingDescription('Flat Rate - Fixed')
->setShippingAmount(10)
- ->setStoreId($objectManager->get(StoreManagerInterface::class)->getStore()->getId())
- ->addItem($orderItem)
- ->setPayment($payment)
- ->setCustomerId(1)
- ->setCustomerIsGuest(false);
+ ->setStoreId($store->getId())
+ ->addItem($orderItem1)
+ ->addItem($orderItem2)
+ ->setPayment($payment);
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $objectManager->get(OrderRepositoryInterface::class);
$orderRepository->save($order);
$shipmentItem = $objectManager->create(ShipmentItem::class);
-$shipmentItem->setOrderItem($orderItem);
+$shipmentItem->setOrderItem($orderItem1);
-/** @var \Magento\Sales\Model\Order\Shipment $shipment */
+/** @var Shipment $shipment */
$shipment = $objectManager->create(Shipment::class);
$shipment->setOrder($order)
->addItem($shipmentItem)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php
new file mode 100644
index 0000000000000..9a20bb1982069
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php
@@ -0,0 +1,31 @@
+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, 1, 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, 1, ScopeInterface::SCOPE_STORE);
From c03f1a9ae74b5842976b839002d4b87b00dc75a9 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 08:27:07 -0600
Subject: [PATCH 024/225] MAGETWO-61914: Create case request to Signifyd
- created Signifyd API gateway
- some builders modified to not trigger validation errors on Signifyd side
- request builders moved to gateway namespace
---
.../Api/CaseCreationServiceInterface.php | 26 ++
.../Signifyd/Model/CaseCreationService.php | 68 ++++++
app/code/Magento/Signifyd/Model/Config.php | 91 +++++++
.../Request/AddressBuilder.php | 2 +-
.../Request/CardBuilder.php | 2 +-
.../Request/ClientVersionBuilder.php | 2 +-
.../Request/CreateCaseBuilder.php | 2 +-
.../Request/CreateCaseBuilderInterface.php | 2 +-
.../Request/CustomerOrders.php | 2 +-
.../Request/PurchaseBuilder.php | 4 +-
.../Request/RecipientBuilder.php | 2 +-
.../Request/SellerBuilder.php | 21 +-
.../Request/UserAccountBuilder.php | 2 +-
.../SignifydApiCallException.php | 14 ++
.../SignifydGateway/SignifydApiClient.php | 222 ++++++++++++++++++
.../SignifydApiResponseException.php | 14 ++
.../Model/SignifydGateway/SignifydGateway.php | 63 +++++
.../SignifydGatewayException.php | 14 ++
.../Magento/Signifyd/Observer/PlaceOrder.php | 83 +++++++
app/code/Magento/Signifyd/etc/config.xml | 10 +-
app/code/Magento/Signifyd/etc/di.xml | 2 +
app/code/Magento/Signifyd/etc/events.xml | 12 +
app/code/Magento/Signifyd/etc/module.xml | 1 +
.../Request/CreateCaseBuilderTest.php | 4 +-
24 files changed, 647 insertions(+), 18 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
create mode 100644 app/code/Magento/Signifyd/Model/CaseCreationService.php
create mode 100644 app/code/Magento/Signifyd/Model/Config.php
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/AddressBuilder.php (94%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/CardBuilder.php (95%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/ClientVersionBuilder.php (93%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/CreateCaseBuilder.php (98%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/CreateCaseBuilderInterface.php (85%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/CustomerOrders.php (96%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/PurchaseBuilder.php (97%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/RecipientBuilder.php (95%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/SellerBuilder.php (88%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/UserAccountBuilder.php (98%)
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
create mode 100644 app/code/Magento/Signifyd/Observer/PlaceOrder.php
create mode 100644 app/code/Magento/Signifyd/etc/events.xml
rename dev/tests/integration/testsuite/Magento/Signifyd/Model/{ => SignifydGateway}/Request/CreateCaseBuilderTest.php (98%)
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
new file mode 100644
index 0000000000000..d1bddc29d76f8
--- /dev/null
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -0,0 +1,26 @@
+caseManagement = $caseManagement;
+ $this->signifydGateway = $signifydGateway;
+ $this->logger = $logger;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function createForOrder($orderId)
+ {
+ $this->caseManagement->create($orderId);
+ try {
+ $this->signifydGateway->createCase($orderId);
+ } catch (SignifydGatewayException $e) {
+ $this->logger->error($e->getMessage());
+ }
+
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Model/Config.php b/app/code/Magento/Signifyd/Model/Config.php
new file mode 100644
index 0000000000000..b6af0aaef3a59
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Config.php
@@ -0,0 +1,91 @@
+scopeConfig = $scopeConfig;
+ $this->encryptor = $encryptor;
+ }
+
+ /**
+ * If this config option set to false no Signifyd integration should be available
+ * (only possibility to configure Signifyd setting in admin)
+ *
+ * @return bool
+ */
+ public function isEnabled()
+ {
+ $enabled = $this->scopeConfig->isSetFlag('fraud_protection/signifyd/active');
+ return $enabled;
+ }
+
+ /**
+ * Signifyd API Key used for authentication.
+ *
+ * @see https://www.signifyd.com/docs/api/#/introduction/authentication
+ * @see https://app.signifyd.com/settings
+ *
+ * @return string
+ */
+ public function getApiKey()
+ {
+ $encryptedApiKey = $this->scopeConfig->getValue('fraud_protection/signifyd/api_key');
+ $apiKey = $this->encryptor->decrypt($encryptedApiKey);
+ return $apiKey;
+ }
+
+ /**
+ * Base URL to Signifyd REST API.
+ * Usually equals to https://api.signifyd.com/v2 and should not be changed
+ *
+ * @return string
+ */
+ public function getApiUrl()
+ {
+ $apiUrl = $this->scopeConfig->getValue('fraud_protection/signifyd/api_url');
+ return $apiUrl;
+ }
+
+ /**
+ * If is "true" extra information about interaction with Signifyd API are written to debug.log file
+ *
+ * @return bool
+ */
+ public function isDebugModeEnabled()
+ {
+ $debugModeEnabled = $this->scopeConfig->isSetFlag('fraud_protection/signifyd/debug');
+ return $debugModeEnabled;
+ }
+
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/AddressBuilder.php
similarity index 94%
rename from app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/AddressBuilder.php
index 2d2b4ac28f6f2..76ac256a1efa6 100644
--- a/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/AddressBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Sales\Api\Data\OrderAddressInterface;
diff --git a/app/code/Magento/Signifyd/Model/Request/CardBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CardBuilder.php
similarity index 95%
rename from app/code/Magento/Signifyd/Model/Request/CardBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/CardBuilder.php
index 2c931924d9c2a..5e50c637a2bff 100644
--- a/app/code/Magento/Signifyd/Model/Request/CardBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CardBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Sales\Model\Order;
diff --git a/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/ClientVersionBuilder.php
similarity index 93%
rename from app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/ClientVersionBuilder.php
index 25ee03da20dc1..b9c514a41f3d8 100644
--- a/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/ClientVersionBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\App\ProductMetadataInterface;
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
similarity index 98%
rename from app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
index b108bfa8cade6..2248e8089c5a2 100644
--- a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Sales\Model\OrderFactory;
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
similarity index 85%
rename from app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
index 63a302509cf76..c18f7b0216a3d 100644
--- a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
/**
* Interface CreateCaseBuilderInterface
diff --git a/app/code/Magento/Signifyd/Model/Request/CustomerOrders.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
similarity index 96%
rename from app/code/Magento/Signifyd/Model/Request/CustomerOrders.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
index 26322a745b8ee..fb80837c2c1ed 100644
--- a/app/code/Magento/Signifyd/Model/Request/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
diff --git a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
similarity index 97%
rename from app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 16de64b869cd1..3d5cb1e3cc92d 100644
--- a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Config\ScopeInterface;
@@ -96,7 +96,7 @@ private function getProducts(Order $order)
'itemId' => $orderItem->getSku(),
'itemName' => $orderItem->getName(),
'itemPrice' => $orderItem->getPrice(),
- 'itemQuantity' => $orderItem->getQtyOrdered(),
+ 'itemQuantity' => (int)$orderItem->getQtyOrdered(),
'itemUrl' => $orderItem->getProduct()->getProductUrl(),
'itemWeight' => $orderItem->getProduct()->getWeight()
];
diff --git a/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/RecipientBuilder.php
similarity index 95%
rename from app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/RecipientBuilder.php
index 510276d1cc75c..81212c7b1c02a 100644
--- a/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/RecipientBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Sales\Model\Order;
diff --git a/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php
similarity index 88%
rename from app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php
index 21b319421d57c..f3129e441a5a9 100644
--- a/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Directory\Model\RegionFactory;
use Magento\Framework\App\Config\ScopeConfigInterface;
@@ -60,7 +60,7 @@ public function build(Order $order)
return [
'seller' => [
'name' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_NAME, $store),
- 'domain' => parse_url($store->getBaseUrl(), PHP_URL_HOST),
+ 'domain' => $this->getPublicDomain($store),
'shipFromAddress' => [
'streetAddress' => $this->getConfigValue(Shipment::XML_PATH_STORE_ADDRESS1, $store),
'unit' => $this->getConfigValue(Shipment::XML_PATH_STORE_ADDRESS2, $store),
@@ -115,4 +115,21 @@ private function getConfigValue($value, StoreInterface $store)
$store
);
}
+
+ /**
+ * @param StoreInterface $store
+ *
+ * @return string|null
+ */
+ 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/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
similarity index 98%
rename from app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
index 6cb33697488f6..a3f7cead80605 100644
--- a/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Sales\Model\Order;
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
new file mode 100644
index 0000000000000..e62ece8946926
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
@@ -0,0 +1,14 @@
+config = $config;
+ $this->clientFactory = $clientFactory;
+ $this->dataEncoder = $dataEncoder;
+ $this->dataDecoder = $dataDecoder;
+ }
+
+ /**
+ * 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 $url
+ * @param $method
+ * @param array $params
+ * @return array
+ * @throws SignifydApiCallException
+ * @throws SignifydApiResponseException
+ */
+ public function makeApiCall($url, $method, array $params = [])
+ {
+ try {
+ $response = $this->sendRequest($url, $method, $params);
+ } catch (\Exception $e) {
+ throw new SignifydApiCallException(
+ 'Unable to call Signifyd API: ' . $e->getMessage(),
+ $e->getCode(),
+ $e
+ );
+ }
+ $result = $this->handleResponse($response);
+ return $result;
+ }
+
+ /**
+ * Send HTTP request to Signifyd API.
+ *
+ * @param $url
+ * @param $method
+ * @param array $params
+ * @return \Zend_Http_Response
+ * @throws SignifydApiCallException
+ */
+ private function sendRequest($url, $method, array $params = [])
+ {
+ $apiKey = $this->getApiKey();
+ $apiUrl = $this->buildFullApiUrl($url);
+
+ $client = $this->createNewClient();
+ $client->setHeaders(
+ 'Authorization',
+ sprintf('Basic %s', $apiKey)
+ );
+// $client->setHeaders(
+// 'Accept-encoding',
+// 'identity'
+// );
+ if (!empty($params)) {
+ $encodedData = $this->dataEncoder->encode($params);
+ $client->setRawData($encodedData, 'application/json');
+ }
+ $client->setMethod($method);
+ $client->setUri($apiUrl);
+
+ $response = $client->request();
+ return $response;
+ }
+
+ /**
+ * Read result of successful operation and throw exception in case of any failure.
+ *
+ * @param \Zend_Http_Response $response
+ *
+ * @return mixed
+ * @throws SignifydApiCallException
+ * @throws SignifydApiResponseException
+ */
+ private function handleResponse(\Zend_Http_Response $response)
+ {
+ $responseBody = $response->getBody();
+
+ switch ($response->getStatus()) {
+ case 200:
+ case 201:
+ case 204:
+ try {
+ $decodedResponseBody = $this->dataDecoder->decode($responseBody);
+ } catch (\Exception $e) {
+ throw new SignifydApiResponseException('Signifyd API response is not valid JSON.');
+ }
+ return $decodedResponseBody;
+ case 400:
+ throw new SignifydApiCallException(
+ 'Bad Request - The request could not be parsed. Response: ' . $responseBody
+ );
+ case 404:
+ throw new SignifydApiCallException(
+ 'Not Found - resource does not exist. Response: ' . $responseBody
+ );
+ case 409:
+ throw new SignifydApiCallException(
+ 'Conflict - with state of the resource on server. Can occur with (too rapid) PUT requests.' .
+ 'Response: ' . $responseBody
+ );
+ case 401:
+ throw new SignifydApiCallException(
+ 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody
+ );
+ case 403:
+ throw new SignifydApiCallException(
+ 'Forbidden - Cannot access resource. Response: ' . $responseBody
+ );
+ case 500:
+ throw new SignifydApiCallException('Server error.');
+ default:
+ throw new SignifydApiResponseException(
+ sprintf('Unexpected Signifyd API response code "%s"', $response->getStatus())
+ );
+ }
+ }
+
+ /**
+ * @return ZendClient
+ */
+ private function createNewClient()
+ {
+ return $this->clientFactory->create();
+ }
+
+ /**
+ * Returns Signifyd API key for merchant account
+ * @see https://www.signifyd.com/docs/api/#/introduction/authentication
+ *
+ * @return string
+ */
+ private function getApiKey()
+ {
+ return $this->config->getApiKey();
+ }
+
+ /**
+ * Builds full URL for Singifyd API based on relative URL
+ *
+ * @param $url
+ * @return string
+ */
+ private function buildFullApiUrl($url)
+ {
+ $baseApiUrl = $this->getBaseApiUrl();
+ $fullUrl = $baseApiUrl . '/' . ltrim($url, '/');
+ return $fullUrl;
+ }
+
+ /**
+ * Returns Base Sigifyd API URL without trailing slash
+ *
+ * @return string
+ */
+ private function getBaseApiUrl()
+ {
+ $baseApiUrl = $this->config->getApiUrl();
+ return rtrim($baseApiUrl, '/');
+ }
+
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
new file mode 100644
index 0000000000000..cd6d9113e2119
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
@@ -0,0 +1,14 @@
+createCaseBuilder = $createCaseBuilder;
+ $this->apiClient = $apiClient;
+ }
+
+ /**
+ * @param $orderId
+ * @return int Signifyd case (investigation) identifier
+ * @throws SignifydGatewayException
+ */
+ public function createCase($orderId)
+ {
+ $caseParams = $this->createCaseBuilder->build($orderId);
+
+ $caseCreationResult = $this->apiClient->makeApiCall(
+ '/cases',
+ 'POST',
+ $caseParams
+ );
+
+ if (!isset($caseCreationResult['investigationId'])) {
+ throw new SignifydGatewayException('Expected field "investigationId" missed.');
+ }
+
+ return (int)$caseCreationResult['investigationId'];
+ }
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
new file mode 100644
index 0000000000000..d1d46a7d79445
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
@@ -0,0 +1,14 @@
+signifydIntegrationConfig = $signifydIntegrationConfig;
+ $this->caseCreationService = $caseCreationService;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function execute(Observer $observer)
+ {
+ $event = $observer->getEvent();
+ $order = $this->extractOrder($event);
+
+ if (null === $order) {
+ return;
+ }
+
+ $orderId = $order->getEntityId();
+ if (null === $order) {
+ return;
+ }
+
+ if (!$this->signifydIntegrationConfig->isEnabled()) {
+ return;
+ }
+
+ $this->caseCreationService->createForOrder($orderId);
+ }
+
+ /**
+ * Fetch Order entity from Event data container
+ *
+ * @param Event $event
+ * @return OrderInterface|null
+ */
+ private function extractOrder(Event $event)
+ {
+ return $event->getData('order');
+ }
+
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/etc/config.xml b/app/code/Magento/Signifyd/etc/config.xml
index b16f0903c2d1f..7ff088dcb0321 100644
--- a/app/code/Magento/Signifyd/etc/config.xml
+++ b/app/code/Magento/Signifyd/etc/config.xml
@@ -7,9 +7,11 @@
-->
-
- 0
- https://api.signifiyd.com/v2/
-
+
+
+ 0
+ https://api.signifyd.com/v2/
+
+
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 6b49c74337868..81d157887f7e1 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -10,4 +10,6 @@
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/etc/events.xml b/app/code/Magento/Signifyd/etc/events.xml
new file mode 100644
index 0000000000000..dd4fff95b8c4a
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/events.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index aa2d26414b484..40335d45f28a5 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,6 +9,7 @@
+
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
similarity index 98%
rename from dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
rename to dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 2ca933376d66c..516ecd329bf7e 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\App\Area;
@@ -15,7 +15,7 @@
/**
* Class PurchaseBuilderTest
* @magentoAppIsolation enabled
- * @package Magento\Signifyd\Model\Request\CreateCaseBuilder
+ * @package Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilder
*/
class CreateCaseBuilderTest extends \PHPUnit_Framework_TestCase
{
From 1293ed46280eceab7b15ce98ce4a143637ea0519 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 09:09:23 -0600
Subject: [PATCH 025/225] MAGETWO-61914: Create case request to Signifyd
- Removed debugging code
---
.../Signifyd/Model/SignifydGateway/SignifydApiClient.php | 4 ----
1 file changed, 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
index b485f54dc16d7..ba2e778b4ef93 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
@@ -108,10 +108,6 @@ private function sendRequest($url, $method, array $params = [])
'Authorization',
sprintf('Basic %s', $apiKey)
);
-// $client->setHeaders(
-// 'Accept-encoding',
-// 'identity'
-// );
if (!empty($params)) {
$encodedData = $this->dataEncoder->encode($params);
$client->setRawData($encodedData, 'application/json');
From 66f4b1cf401583be7ebb3d1f85d7ccf892bd8398 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 09:23:52 -0600
Subject: [PATCH 026/225] MAGETWO-61914: Create case request to Signifyd
- fixed issue with not encrypted API key
---
.../Signifyd/Model/SignifydGateway/SignifydApiClient.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
index ba2e778b4ef93..b2a7be8b752f7 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
@@ -106,7 +106,7 @@ private function sendRequest($url, $method, array $params = [])
$client = $this->createNewClient();
$client->setHeaders(
'Authorization',
- sprintf('Basic %s', $apiKey)
+ sprintf('Basic %s', base64_encode($apiKey))
);
if (!empty($params)) {
$encodedData = $this->dataEncoder->encode($params);
From 88254012115c326993745aadf31ab9910f97db99 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 09:46:43 -0600
Subject: [PATCH 027/225] MAGETWO-61914: Create case request to Signifyd
- fixed configuration reading
---
app/code/Magento/Signifyd/Model/Config.php | 34 ++++++++++++----------
app/code/Magento/Signifyd/etc/config.xml | 2 ++
2 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/Config.php b/app/code/Magento/Signifyd/Model/Config.php
index b6af0aaef3a59..af3f26b80b5ca 100644
--- a/app/code/Magento/Signifyd/Model/Config.php
+++ b/app/code/Magento/Signifyd/Model/Config.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Model;
use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\Framework\Encryption\EncryptorInterface;
+use Magento\Store\Model\ScopeInterface;
/**
* Signifyd integration configuration.
@@ -20,22 +20,13 @@ class Config
*/
private $scopeConfig;
- /**
- * @var EncryptorInterface
- */
- private $encryptor;
-
/**
* Config constructor.
*
* @param ScopeConfigInterface $scopeConfig
*/
- public function __construct(
- ScopeConfigInterface $scopeConfig,
- EncryptorInterface $encryptor
- ) {
+ public function __construct(ScopeConfigInterface $scopeConfig) {
$this->scopeConfig = $scopeConfig;
- $this->encryptor = $encryptor;
}
/**
@@ -46,7 +37,10 @@ public function __construct(
*/
public function isEnabled()
{
- $enabled = $this->scopeConfig->isSetFlag('fraud_protection/signifyd/active');
+ $enabled = $this->scopeConfig->isSetFlag(
+ 'fraud_protection/signifyd/active',
+ ScopeInterface::SCOPE_STORE
+ );
return $enabled;
}
@@ -60,8 +54,10 @@ public function isEnabled()
*/
public function getApiKey()
{
- $encryptedApiKey = $this->scopeConfig->getValue('fraud_protection/signifyd/api_key');
- $apiKey = $this->encryptor->decrypt($encryptedApiKey);
+ $apiKey = $this->scopeConfig->getValue(
+ 'fraud_protection/signifyd/api_key',
+ ScopeInterface::SCOPE_STORE
+ );
return $apiKey;
}
@@ -73,7 +69,10 @@ public function getApiKey()
*/
public function getApiUrl()
{
- $apiUrl = $this->scopeConfig->getValue('fraud_protection/signifyd/api_url');
+ $apiUrl = $this->scopeConfig->getValue(
+ 'fraud_protection/signifyd/api_url',
+ ScopeInterface::SCOPE_STORE
+ );
return $apiUrl;
}
@@ -84,7 +83,10 @@ public function getApiUrl()
*/
public function isDebugModeEnabled()
{
- $debugModeEnabled = $this->scopeConfig->isSetFlag('fraud_protection/signifyd/debug');
+ $debugModeEnabled = $this->scopeConfig->isSetFlag(
+ 'fraud_protection/signifyd/debug',
+ ScopeInterface::SCOPE_STORE
+ );
return $debugModeEnabled;
}
diff --git a/app/code/Magento/Signifyd/etc/config.xml b/app/code/Magento/Signifyd/etc/config.xml
index 7ff088dcb0321..da606e2361c40 100644
--- a/app/code/Magento/Signifyd/etc/config.xml
+++ b/app/code/Magento/Signifyd/etc/config.xml
@@ -11,6 +11,8 @@
0
https://api.signifyd.com/v2/
+
+ 0
From 0cff549863237c9d968c5a94494da5cb1403784a Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 14 Dec 2016 10:05:49 -0600
Subject: [PATCH 028/225] MAGETWO-61913: Create request builders
- Update CreateCaseBuilderTest
---
.../Request/PurchaseBuilder.php | 3 +-
.../Request/CreateCaseBuilderTest.php | 189 ++++++++++++------
.../Magento/Signifyd/_files/case.php | 2 +-
...with_customer_and_two_simple_products.php} | 42 ++--
.../order_with_guest_and_virtual_product.php | 62 ++++++
.../Magento/Signifyd/_files/store.php | 6 +-
6 files changed, 228 insertions(+), 76 deletions(-)
rename dev/tests/integration/testsuite/Magento/Signifyd/_files/{order.php => order_with_customer_and_two_simple_products.php} (73%)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 3d5cb1e3cc92d..fdb683e61631f 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway\Request;
+use Magento\Framework\App\Area;
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Config\ScopeInterface;
use Magento\Sales\Model\Order;
@@ -149,6 +150,6 @@ private function getPaymentGateway($gatewayCode)
*/
private function getOrderChannel()
{
- return $this->scope->getCurrentScope() === 'adminhtml' ? 'PHONE' : 'WEB';
+ return $this->scope->getCurrentScope() === Area::AREA_ADMINHTML ? 'PHONE' : 'WEB';
}
}
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
index 516ecd329bf7e..8d7a88c6c884c 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway\Request;
+use Magento\Framework\Config\ScopeInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\App\Area;
use Magento\Framework\Intl\DateTimeFactory;
@@ -12,38 +13,24 @@
use Magento\Sales\Model\Order;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Framework\App\ProductMetadataInterface;
+
/**
- * Class PurchaseBuilderTest
+ * Class CreateCaseBuilderTest
* @magentoAppIsolation enabled
- * @package Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilder
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CreateCaseBuilderTest extends \PHPUnit_Framework_TestCase
{
- /**
- * Order increment ID
- */
- const ORDER_INCREMENT_ID = '100000001';
-
/**
* @var ObjectManagerInterface
*/
private $objectManager;
- /**
- * @var Order
- */
- private $order;
-
/**
* @var CreateCaseBuilder
*/
private $caseBuilder;
- /**
- * @var array
- */
- private $builderData;
-
/**
* @var DateTimeFactory
*/
@@ -57,47 +44,51 @@ protected function setUp()
$bootstrap = Bootstrap::getInstance();
$bootstrap->loadArea(Area::AREA_FRONTEND);
$this->objectManager = Bootstrap::getObjectManager();
-
$this->dateTimeFactory = $this->objectManager->create(DateTimeFactory::class);
-
- $this->order = $this->objectManager->create(Order::class);
- $this->order->loadByIncrementId(self::ORDER_INCREMENT_ID);
-
$this->caseBuilder = $this->objectManager->create(CreateCaseBuilder::class);
- $this->builderData = $this->caseBuilder->build($this->order->getEntityId());
}
/**
- * Check the stability purchaseBuilder
+ * Test builder on order with customer, simple product, frontend area,
+ * PayPal gateway, shipping and billing addresses, with two orders
*
- * @magentoDataFixture Magento/Signifyd/_files/order.php
+ * @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 testPurchaseBuilder()
+ public function testCreateCaseBuilderWithFullSetOfData()
{
- $orderItems = $this->order->getAllItems();
+ /** @var Order $order */
+ $order = $this->objectManager->create(Order::class);
+ $order->loadByIncrementId('100000001');
+
+ $orderItems = $order->getAllItems();
$product = $orderItems[0]->getProduct();
- $payment = $this->order->getPayment();
- $billingAddress = $this->order->getBillingAddress();
- $shippingAddress = $this->order->getShippingAddress();
+ $payment = $order->getPayment();
+ $billingAddress = $order->getBillingAddress();
+ $shippingAddress = $order->getShippingAddress();
+
+ /** @var CustomerRepositoryInterface $customerRepository */
$customerRepository = $this->objectManager->create(CustomerRepositoryInterface::class);
- $customer = $customerRepository->getById($this->order->getCustomerId());
+ $customer = $customerRepository->getById($order->getCustomerId());
+
$productMetadata = $this->objectManager->create(ProductMetadataInterface::class);
$expected = [
'purchase' => [
- 'browserIpAddress' => $this->order->getRemoteIp(),
- 'orderId' => $this->order->getEntityId(),
+ 'browserIpAddress' => $order->getRemoteIp(),
+ 'orderId' => $order->getEntityId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
'paymentGateway' => 'paypal_account',
'transactionId' => $payment->getLastTransId(),
- 'currency' => $this->order->getOrderCurrencyCode(),
+ 'currency' => $order->getOrderCurrencyCode(),
'orderChannel' => 'WEB',
- 'totalPrice' => $this->order->getGrandTotal(),
+ 'totalPrice' => $order->getGrandTotal(),
'shipments' => [
0 => [
'shipper' => 'Flat Rate',
'shippingMethod' => 'Fixed',
- 'shippingPrice' => $this->order->getShippingAmount()
+ 'shippingPrice' => $order->getShippingAmount()
]
],
'products' => [
@@ -138,6 +129,7 @@ public function testPurchaseBuilder()
'confirmationPhone' => $shippingAddress->getTelephone(),
'deliveryAddress' => [
'streetAddress' => '6161 West Centinela Avenue',
+ 'unit' => 'app. 33',
'city' => $shippingAddress->getCity(),
'provinceCode' => $shippingAddress->getRegionCode(),
'postalCode' => $shippingAddress->getPostcode(),
@@ -147,38 +139,119 @@ public function testPurchaseBuilder()
'userAccount' => [
'email' => $customer->getEmail(),
'username' => $customer->getEmail(),
- 'phone' => $this->order->getBillingAddress()->getTelephone(),
+ 'phone' => $order->getBillingAddress()->getTelephone(),
'accountNumber' => $customer->getId(),
'createdDate' => $this->formatDate($customer->getCreatedAt()),
- 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt())
+ 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt()),
+ 'aggregateOrderCount' => 2,
+ 'aggregateOrderDollars' => 150.0
],
- 'seller' => [
- 'name' => 'Sample Store',
- 'domain' => 'm2.com',
- 'shipFromAddress' => [
- 'streetAddress' => '6161 West Centinela Avenue',
- 'unit' => 'app. 111',
- 'city' => 'Culver City',
- 'provinceCode' => 'AE',
- 'postalCode' => '90230',
- 'countryCode' => 1,
- ],
- 'corporateAddress' => [
- 'streetAddress' => '5th Avenue',
- 'unit' => '75',
- 'city' => 'New York',
- 'provinceCode' => 'MH',
- 'postalCode' => '19032',
- 'countryCode' => 1,
- ],
+ 'seller' => $this->getSellerData(),
+ 'clientVersion' => [
+ 'platform' => $productMetadata->getName() . ' ' . $productMetadata->getEdition(),
+ 'platformVersion' => $productMetadata->getVersion()
+ ]
+ ];
+
+
+ static::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);
+
+ $expected = [
+ 'purchase' => [
+ 'browserIpAddress' => $order->getRemoteIp(),
+ 'orderId' => $order->getEntityId(),
+ 'createdAt' => '2016-12-12T12:00:55+00:00',
+ 'paymentGateway' => $payment->getMethod(),
+ 'transactionId' => $payment->getLastTransId(),
+ 'currency' => $order->getOrderCurrencyCode(),
+ '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()
+ ],
+ ]
+ ],
+ 'card' => [
+ 'cardHolderName' => 'firstname lastname',
+ 'billingAddress' => [
+ 'streetAddress' => 'street',
+ 'city' => $billingAddress->getCity(),
+ 'provinceCode' => $billingAddress->getRegionCode(),
+ 'postalCode' => $billingAddress->getPostcode(),
+ 'countryCode' => $billingAddress->getCountryId()
+ ]
],
+ 'seller' => $this->getSellerData(),
'clientVersion' => [
'platform' => $productMetadata->getName() . ' ' . $productMetadata->getEdition(),
'platformVersion' => $productMetadata->getVersion()
]
];
- static::assertEquals($expected, $this->builderData);
+ static::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',
+ ],
+ ];
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
index 148c831a9f2d7..de635ba750399 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -7,7 +7,7 @@
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Api\Data\CaseInterfaceFactory;
-require __DIR__ . '/order.php';
+require __DIR__ . '/order_with_customer_and_two_simple_products.php';
/** @var CaseInterfaceFactory $caseFactory */
$caseFactory = $objectManager->get(CaseInterfaceFactory::class);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
similarity index 73%
rename from dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
rename to dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
index 092b31553f3a7..53ab5fd724e45 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
@@ -9,15 +9,13 @@
use Magento\Sales\Model\Order\Item;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;
-use Magento\Paypal\Model\Config as PaypalConfig;
-use Magento\Sales\Model\Order\Shipment\Item as ShipmentItem;
-use Magento\Sales\Model\Order\Shipment;
require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php';
require __DIR__ . '/../../../Magento/Customer/_files/customer.php';
require __DIR__ . '/store.php';
-$addressData = require __DIR__ . '/../../../Magento/Sales/_files/address_data.php';
+$addressData = include __DIR__ . '/../../../Magento/Sales/_files/address_data.php';
+
$objectManager = Bootstrap::getObjectManager();
@@ -27,13 +25,13 @@
$shippingAddress = clone $billingAddress;
$shippingAddress->setId(null)
->setAddressType('shipping')
- ->setStreet('6161 West Centinela Avenue')
+ ->setStreet(['6161 West Centinela Avenue', 'app. 33'])
->setFirstname('John')
->setLastname('Doe')
->setShippingMethod('flatrate_flatrate');
$payment = $objectManager->create(Payment::class);
-$payment->setMethod(PaypalConfig::METHOD_WPP_EXPRESS)
+$payment->setMethod('paypal_express')
->setLastTransId('00001')
->setCcLast4('1234')
->setCcExpMonth('01')
@@ -75,6 +73,7 @@
->setRemoteIp('127.0.0.1')
->setCreatedAt('2016-12-12T12:00:55+0000')
->setOrderCurrencyCode('USD')
+ ->setBaseCurrencyCode('USD')
->setSubtotal($orderAmount)
->setGrandTotal($orderAmount)
->setBaseSubtotal($orderAmount)
@@ -93,12 +92,27 @@
$orderRepository = $objectManager->get(OrderRepositoryInterface::class);
$orderRepository->save($order);
-$shipmentItem = $objectManager->create(ShipmentItem::class);
-$shipmentItem->setOrderItem($orderItem1);
+$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);
-/** @var Shipment $shipment */
-$shipment = $objectManager->create(Shipment::class);
-$shipment->setOrder($order)
- ->addItem($shipmentItem)
- ->setShipmentStatus(Shipment::STATUS_NEW)
- ->save();
+$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
new file mode 100644
index 0000000000000..fa0d00be90497
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php
@@ -0,0 +1,62 @@
+create(Address::class, ['data' => $addressData]);
+$billingAddress->setAddressType('billing');
+
+$payment = $objectManager->create(Payment::class);
+$payment->setMethod('braintree')
+ ->setLastTransId('00001');
+
+/** @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);
+
+/** @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
index 9a20bb1982069..e27f9a4e7370c 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php
@@ -10,7 +10,9 @@
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);
@@ -21,11 +23,11 @@
$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, 1, 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, 1, ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_COUNTRY_CODE, 'US', ScopeInterface::SCOPE_STORE);
From ce95f1de80d53d1c8f23e82098c8b572d775a8c7 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 11:00:54 -0600
Subject: [PATCH 029/225] MAGETWO-61914: Create case request to Signifyd
- Refactoring: apply code standards
---
.../Api/CaseCreationServiceInterface.php | 5 +-
.../Signifyd/Model/CaseCreationService.php | 3 +-
app/code/Magento/Signifyd/Model/Config.php | 6 +-
.../SignifydGateway/Request/SellerBuilder.php | 1 -
.../SignifydApiCallException.php | 2 +-
.../SignifydGateway/SignifydApiClient.php | 85 +++++++++++--------
.../SignifydApiResponseException.php | 2 +-
.../Model/SignifydGateway/SignifydGateway.php | 4 +-
.../SignifydGatewayException.php | 2 +-
.../Magento/Signifyd/Observer/PlaceOrder.php | 3 +-
10 files changed, 60 insertions(+), 53 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
index d1bddc29d76f8..939f64409a577 100644
--- a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -18,9 +18,8 @@ interface CaseCreationServiceInterface
/**
* Create new case for order with specified id.
*
- * @param $orderId
+ * @param int $orderId
* @return bool
*/
public function createForOrder($orderId);
-
-}
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseCreationService.php
index d876fe6585cc0..8c761a1c8fee0 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseCreationService.php
@@ -64,5 +64,4 @@ public function createForOrder($orderId)
return true;
}
-
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/Config.php b/app/code/Magento/Signifyd/Model/Config.php
index af3f26b80b5ca..f99480386293a 100644
--- a/app/code/Magento/Signifyd/Model/Config.php
+++ b/app/code/Magento/Signifyd/Model/Config.php
@@ -25,7 +25,8 @@ class Config
*
* @param ScopeConfigInterface $scopeConfig
*/
- public function __construct(ScopeConfigInterface $scopeConfig) {
+ public function __construct(ScopeConfigInterface $scopeConfig)
+ {
$this->scopeConfig = $scopeConfig;
}
@@ -89,5 +90,4 @@ public function isDebugModeEnabled()
);
return $debugModeEnabled;
}
-
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php
index f3129e441a5a9..9b8af9535407c 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php
@@ -131,5 +131,4 @@ private function getPublicDomain(StoreInterface $store)
return $domain;
}
-
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
index e62ece8946926..ea1a1f73dfa1b 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
@@ -11,4 +11,4 @@
class SignifydApiCallException extends SignifydGatewayException
{
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
index b2a7be8b752f7..7c70bf8770ab3 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
@@ -44,7 +44,7 @@ class SignifydApiClient
* Class uses client factory to instantiate new client for interacting with API.
* All requests and responses are processed by JSON encoder and decoder.
*
- * @aparm Config $config
+ * @param Config $config
* @param ZendClientFactory $clientFactory
* @param EncoderInterface $dataEncoder
* @param DecoderInterface $dataDecoder
@@ -67,8 +67,8 @@ public function __construct(
* Method returns associative array that corresponds to successful result.
* Current implementation do not expose details in case of failure.
*
- * @param $url
- * @param $method
+ * @param string $url
+ * @param string $method
* @param array $params
* @return array
* @throws SignifydApiCallException
@@ -92,8 +92,8 @@ public function makeApiCall($url, $method, array $params = [])
/**
* Send HTTP request to Signifyd API.
*
- * @param $url
- * @param $method
+ * @param string $url
+ * @param string $method
* @param array $params
* @return \Zend_Http_Response
* @throws SignifydApiCallException
@@ -124,50 +124,62 @@ private function sendRequest($url, $method, array $params = [])
*
* @param \Zend_Http_Response $response
*
- * @return mixed
+ * @return array
* @throws SignifydApiCallException
* @throws SignifydApiResponseException
*/
private function handleResponse(\Zend_Http_Response $response)
{
+ $responseCode = $response->getStatus();
+ $successResponseCodes = [200, 201, 204];
+
+ if (!in_array($responseCode, $successResponseCodes)) {
+ $errorMessage = $this->buildApiCallFailureMesage($response);
+ throw new SignifydApiResponseException($errorMessage);
+ }
+
$responseBody = $response->getBody();
+ try {
+ $decodedResponseBody = $this->dataDecoder->decode($responseBody);
+ } catch (\Exception $e) {
+ throw new SignifydApiResponseException(
+ 'Signifyd API response is not valid JSON: ' . $e->getMessage(),
+ $e->getCode(),
+ $e
+ );
+ }
+ return $decodedResponseBody;
+ }
+
+ /**
+ * Make error message for request rejected by Signify
+ *
+ * @param \Zend_Http_Response $response
+ * @return string
+ */
+ private function buildApiCallFailureMesage(\Zend_Http_Response $response)
+ {
+ $responseBody = $response->getBody();
switch ($response->getStatus()) {
- case 200:
- case 201:
- case 204:
- try {
- $decodedResponseBody = $this->dataDecoder->decode($responseBody);
- } catch (\Exception $e) {
- throw new SignifydApiResponseException('Signifyd API response is not valid JSON.');
- }
- return $decodedResponseBody;
case 400:
- throw new SignifydApiCallException(
- 'Bad Request - The request could not be parsed. Response: ' . $responseBody
- );
+ return 'Bad Request - The request could not be parsed. Response: ' . $responseBody;
case 404:
- throw new SignifydApiCallException(
- 'Not Found - resource does not exist. Response: ' . $responseBody
- );
+ return 'Not Found - resource does not exist. Response: ' . $responseBody;
case 409:
- throw new SignifydApiCallException(
- 'Conflict - with state of the resource on server. Can occur with (too rapid) PUT requests.' .
- 'Response: ' . $responseBody
- );
+ return 'Conflict - with state of the resource on server. Can occur with (too rapid) PUT requests.' .
+ 'Response: ' . $responseBody;
case 401:
- throw new SignifydApiCallException(
- 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody
- );
+ 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody;
case 403:
- throw new SignifydApiCallException(
- 'Forbidden - Cannot access resource. Response: ' . $responseBody
- );
+ 'Forbidden - Cannot access resource. Response: ' . $responseBody;
case 500:
- throw new SignifydApiCallException('Server error.');
+ return 'Server error.';
default:
- throw new SignifydApiResponseException(
- sprintf('Unexpected Signifyd API response code "%s"', $response->getStatus())
+ return sprintf(
+ 'Unexpected Signifyd API response code "%s" with content "%s".',
+ $response->getStatus(),
+ $responseBody
);
}
}
@@ -194,7 +206,7 @@ private function getApiKey()
/**
* Builds full URL for Singifyd API based on relative URL
*
- * @param $url
+ * @param string $url
* @return string
*/
private function buildFullApiUrl($url)
@@ -214,5 +226,4 @@ private function getBaseApiUrl()
$baseApiUrl = $this->config->getApiUrl();
return rtrim($baseApiUrl, '/');
}
-
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
index cd6d9113e2119..a353537074fea 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
@@ -11,4 +11,4 @@
class SignifydApiResponseException extends SignifydGatewayException
{
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php
index 0626f727168b0..0975b9359aab6 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php
@@ -40,7 +40,7 @@ public function __construct(
}
/**
- * @param $orderId
+ * @param int $orderId
* @return int Signifyd case (investigation) identifier
* @throws SignifydGatewayException
*/
@@ -60,4 +60,4 @@ public function createCase($orderId)
return (int)$caseCreationResult['investigationId'];
}
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
index d1d46a7d79445..7deb44fba132d 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
@@ -11,4 +11,4 @@
class SignifydGatewayException extends \Exception
{
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index 80309e7bbd497..aa9d0d39e5988 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -79,5 +79,4 @@ private function extractOrder(Event $event)
{
return $event->getData('order');
}
-
-}
\ No newline at end of file
+}
From 23848c66c70fed745aadb7ecdcb3da444a1dfdd0 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 11:17:19 -0600
Subject: [PATCH 030/225] MAGETWO-61914: Create case request to Signifyd
- Refactoring: renamed gateway classes
---
.../Signifyd/Model/CaseCreationService.php | 12 ++++++------
...ewayException.php => ApiCallException.php} | 2 +-
.../{SignifydApiClient.php => ApiClient.php} | 19 +++++++++----------
...Exception.php => ApiResponseException.php} | 2 +-
.../{SignifydGateway.php => Gateway.php} | 16 ++++++++--------
...onseException.php => GatewayException.php} | 2 +-
6 files changed, 26 insertions(+), 27 deletions(-)
rename app/code/Magento/Signifyd/Model/SignifydGateway/{SignifydGatewayException.php => ApiCallException.php} (81%)
rename app/code/Magento/Signifyd/Model/SignifydGateway/{SignifydApiClient.php => ApiClient.php} (93%)
rename app/code/Magento/Signifyd/Model/SignifydGateway/{SignifydApiCallException.php => ApiResponseException.php} (77%)
rename app/code/Magento/Signifyd/Model/SignifydGateway/{SignifydGateway.php => Gateway.php} (77%)
rename app/code/Magento/Signifyd/Model/SignifydGateway/{SignifydApiResponseException.php => GatewayException.php} (76%)
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseCreationService.php
index 8c761a1c8fee0..2dc76f4e74d4f 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseCreationService.php
@@ -7,8 +7,8 @@
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
-use Magento\Signifyd\Model\SignifydGateway\SignifydGateway;
-use Magento\Signifyd\Model\SignifydGateway\SignifydGatewayException;
+use Magento\Signifyd\Model\SignifydGateway\Gateway;
+use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Psr\Log\LoggerInterface;
/**
@@ -24,7 +24,7 @@ class CaseCreationService implements CaseCreationServiceInterface
private $caseManagement;
/**
- * @var SignifydGateway;
+ * @var Gateway;
*/
private $signifydGateway;
@@ -37,12 +37,12 @@ class CaseCreationService implements CaseCreationServiceInterface
* CaseCreationService constructor.
*
* @param CaseManagementInterface $caseManagement
- * @param SignifydGateway $signifydGateway
+ * @param Gateway $signifydGateway
* @param LoggerInterface $logger
*/
public function __construct(
CaseManagementInterface $caseManagement,
- SignifydGateway $signifydGateway,
+ Gateway $signifydGateway,
LoggerInterface $logger
) {
$this->caseManagement = $caseManagement;
@@ -58,7 +58,7 @@ public function createForOrder($orderId)
$this->caseManagement->create($orderId);
try {
$this->signifydGateway->createCase($orderId);
- } catch (SignifydGatewayException $e) {
+ } catch (GatewayException $e) {
$this->logger->error($e->getMessage());
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiCallException.php
similarity index 81%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/ApiCallException.php
index 7deb44fba132d..5aaa44e2f0bb7 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiCallException.php
@@ -8,7 +8,7 @@
/**
* Exception of interacation with Signifyd API
*/
-class SignifydGatewayException extends \Exception
+class ApiCallException extends GatewayException
{
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
similarity index 93%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 7c70bf8770ab3..a489c99f500a3 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -16,7 +16,7 @@
*
* Encapsulates Signifyd API protocol.
*/
-class SignifydApiClient
+class ApiClient
{
/**
* @var Config
@@ -39,7 +39,7 @@ class SignifydApiClient
private $dataDecoder;
/**
- * SignifydApiClient constructor.
+ * ApiClient constructor.
*
* Class uses client factory to instantiate new client for interacting with API.
* All requests and responses are processed by JSON encoder and decoder.
@@ -71,15 +71,15 @@ public function __construct(
* @param string $method
* @param array $params
* @return array
- * @throws SignifydApiCallException
- * @throws SignifydApiResponseException
+ * @throws ApiCallException
+ * @throws ApiResponseException
*/
public function makeApiCall($url, $method, array $params = [])
{
try {
$response = $this->sendRequest($url, $method, $params);
} catch (\Exception $e) {
- throw new SignifydApiCallException(
+ throw new ApiCallException(
'Unable to call Signifyd API: ' . $e->getMessage(),
$e->getCode(),
$e
@@ -96,7 +96,6 @@ public function makeApiCall($url, $method, array $params = [])
* @param string $method
* @param array $params
* @return \Zend_Http_Response
- * @throws SignifydApiCallException
*/
private function sendRequest($url, $method, array $params = [])
{
@@ -125,8 +124,8 @@ private function sendRequest($url, $method, array $params = [])
* @param \Zend_Http_Response $response
*
* @return array
- * @throws SignifydApiCallException
- * @throws SignifydApiResponseException
+ * @throws ApiCallException
+ * @throws ApiResponseException
*/
private function handleResponse(\Zend_Http_Response $response)
{
@@ -135,14 +134,14 @@ private function handleResponse(\Zend_Http_Response $response)
if (!in_array($responseCode, $successResponseCodes)) {
$errorMessage = $this->buildApiCallFailureMesage($response);
- throw new SignifydApiResponseException($errorMessage);
+ throw new ApiCallException($errorMessage);
}
$responseBody = $response->getBody();
try {
$decodedResponseBody = $this->dataDecoder->decode($responseBody);
} catch (\Exception $e) {
- throw new SignifydApiResponseException(
+ throw new ApiResponseException(
'Signifyd API response is not valid JSON: ' . $e->getMessage(),
$e->getCode(),
$e
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiResponseException.php
similarity index 77%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/ApiResponseException.php
index ea1a1f73dfa1b..80bbe02b17b34 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiResponseException.php
@@ -8,7 +8,7 @@
/**
* Exception of interacation with Signifyd API
*/
-class SignifydApiCallException extends SignifydGatewayException
+class ApiResponseException extends GatewayException
{
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
similarity index 77%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
index 0975b9359aab6..2ffefb65937ee 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
@@ -6,14 +6,14 @@
namespace Magento\Signifyd\Model\SignifydGateway;
use Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilderInterface;
-use Magento\Signifyd\Model\SignifydGateway\SignifydApiClient;
+use Magento\Signifyd\Model\SignifydGateway\ApiClient;
/**
* Signifyd Gateway.
*
* Encapsulates interaction with Signifyd API.
*/
-class SignifydGateway
+class Gateway
{
/**
* @var CreateCaseBuilderInterface
@@ -21,19 +21,19 @@ class SignifydGateway
private $createCaseBuilder;
/**
- * @var SignifydApiClient
+ * @var ApiClient
*/
private $apiClient;
/**
- * SignifydGateway constructor.
+ * Gateway constructor.
*
* @param CreateCaseBuilderInterface $createCaseBuilder
- * @param SignifydApiClient $apiClient
+ * @param ApiClient $apiClient
*/
public function __construct(
CreateCaseBuilderInterface $createCaseBuilder,
- SignifydApiClient $apiClient
+ ApiClient $apiClient
) {
$this->createCaseBuilder = $createCaseBuilder;
$this->apiClient = $apiClient;
@@ -42,7 +42,7 @@ public function __construct(
/**
* @param int $orderId
* @return int Signifyd case (investigation) identifier
- * @throws SignifydGatewayException
+ * @throws GatewayException
*/
public function createCase($orderId)
{
@@ -55,7 +55,7 @@ public function createCase($orderId)
);
if (!isset($caseCreationResult['investigationId'])) {
- throw new SignifydGatewayException('Expected field "investigationId" missed.');
+ throw new GatewayException('Expected field "investigationId" missed.');
}
return (int)$caseCreationResult['investigationId'];
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/GatewayException.php
similarity index 76%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/GatewayException.php
index a353537074fea..21066f8872d32 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/GatewayException.php
@@ -8,7 +8,7 @@
/**
* Exception of interacation with Signifyd API
*/
-class SignifydApiResponseException extends SignifydGatewayException
+class GatewayException extends \Exception
{
}
From a2d512ef53e767184a4e44e4f79e23fef1536204 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 11:30:27 -0600
Subject: [PATCH 031/225] MAGETWO-61914: Create case request to Signifyd
- fixed refactoring issues
---
.../Magento/Signifyd/Api/CaseCreationServiceInterface.php | 2 +-
app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php | 4 ++--
.../Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 1 -
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
index 939f64409a577..2118652f31a7d 100644
--- a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -22,4 +22,4 @@ interface CaseCreationServiceInterface
* @return bool
*/
public function createForOrder($orderId);
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index a489c99f500a3..5de361eec7975 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -169,9 +169,9 @@ private function buildApiCallFailureMesage(\Zend_Http_Response $response)
return 'Conflict - with state of the resource on server. Can occur with (too rapid) PUT requests.' .
'Response: ' . $responseBody;
case 401:
- 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody;
+ return 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody;
case 403:
- 'Forbidden - Cannot access resource. Response: ' . $responseBody;
+ return 'Forbidden - Cannot access resource. Response: ' . $responseBody;
case 500:
return 'Server error.';
default:
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
index 8d7a88c6c884c..2665e9756e0f3 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -153,7 +153,6 @@ public function testCreateCaseBuilderWithFullSetOfData()
]
];
-
static::assertEquals(
$expected,
$this->caseBuilder->build($order->getEntityId())
From 2393f41d654a04e483be3f633e93271100638bf4 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 14 Dec 2016 11:34:44 -0600
Subject: [PATCH 032/225] MAGETWO-61929: Create integration tests
- Added test to cover case for orders with different currencies
---
.../Request/UserAccountBuilderTest.php | 247 ++++++++++++++++++
1 file changed, 247 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
diff --git a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
new file mode 100644
index 0000000000000..a5d6ea624c1a6
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
@@ -0,0 +1,247 @@
+objectManager = new ObjectManager($this);
+
+ $this->customerOrdersService = $this->getMockBuilder(CustomerOrders::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['get'])
+ ->getMock();
+
+ $this->customerRepository = $this->getMockBuilder(CustomerRepositoryInterface::class)
+ ->setMethods(['getById'])
+ ->getMockForAbstractClass();
+
+ $dateTimeFactory = new DateTimeFactory();
+
+ $this->builder = $this->objectManager->getObject(UserAccountBuilder::class, [
+ 'customerRepository' => $this->customerRepository,
+ 'dateTimeFactory' => $dateTimeFactory,
+ 'customerOrders' => $this->customerOrdersService
+ ]);
+
+ $this->initCurrencies();
+
+ $this->objectManager->setBackwardCompatibleProperty(
+ $this->builder,
+ 'currencies',
+ ['EUR' => $this->eurCurrency, 'UAH' => $this->uahCurrency]
+ );
+ }
+
+ /**
+ * @covers \Magento\Signifyd\Model\SignifydGateway\Request\UserAccountBuilder::build
+ */
+ public function testBuild()
+ {
+ $order = $this->getOrder();
+
+ $customer = $this->getMockBuilder(CustomerInterface::class)
+ ->setMethods(['getEmail', 'getCreatedAt', 'getUpdatedAt'])
+ ->getMockForAbstractClass();
+ $customer->expects(static::exactly(2))
+ ->method('getEmail')
+ ->willReturn('jonh.doe@testmage.com');
+ $customer->expects(static::once())
+ ->method('getCreatedAt')
+ ->willReturn('2016-10-12 12:23:12');
+ $customer->expects(static::once())
+ ->method('getUpdatedAt')
+ ->willReturn('2016-12-14 18:19:00');
+
+ $this->customerRepository->expects(static::once())
+ ->method('getById')
+ ->with(self::$customerId)
+ ->willReturn($customer);
+
+ $orders = $this->getOrders();
+ $this->customerOrdersService->expects(static::once())
+ ->method('get')
+ ->with(self::$customerId)
+ ->willReturn($orders);
+
+ $this->eurCurrency->expects(static::once())
+ ->method('convert')
+ ->with(self::$eurAmount, 'USD')
+ ->willReturn(109);
+
+ $this->uahCurrency->expects(static::once())
+ ->method('convert')
+ ->with(self::$uahAmount, 'USD')
+ ->willReturn(10.35);
+
+ $actual = $this->builder->build($order);
+
+ static::assertEquals(3, $actual['userAccount']['aggregateOrderCount']);
+ static::assertEquals(169.35, $actual['userAccount']['aggregateOrderDollars']);
+ }
+
+ /**
+ * 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();
+ }
+
+ /**
+ * Creates order mock
+ * @return Order|MockObject
+ */
+ private function getOrder()
+ {
+ $order = $this->getMockBuilder(Order::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getBillingAddress', 'getCustomerId'])
+ ->getMock();
+
+ $order->expects(static::once())
+ ->method('getCustomerId')
+ ->willReturn(self::$customerId);
+
+ $billingAddress = $this->getMockBuilder(OrderAddressInterface::class)
+ ->setMethods(['getTelephone'])
+ ->getMockForAbstractClass();
+ $billingAddress->expects(static::once())
+ ->method('getTelephone')
+ ->willReturn('444-444-44');
+
+ $order->expects(static::once())
+ ->method('getBillingAddress')
+ ->willReturn($billingAddress);
+
+ return $order;
+ }
+
+ /**
+ * 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(static::once())
+ ->method('getBaseGrandTotal')
+ ->willReturn(self::$eurAmount);
+ $eurOrder->expects(static::once())
+ ->method('getBaseCurrencyCode')
+ ->willReturn('EUR');
+
+ $uahOrder = $this->getMockBuilder(Order::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode'])
+ ->getMock();
+
+ $uahOrder->expects(static::once())
+ ->method('getBaseGrandTotal')
+ ->willReturn(self::$uahAmount);
+ $uahOrder->expects(static::once())
+ ->method('getBaseCurrencyCode')
+ ->willReturn('UAH');
+
+ $usdOrder = $this->getMockBuilder(Order::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode'])
+ ->getMock();
+
+ $usdOrder->expects(static::once())
+ ->method('getBaseGrandTotal')
+ ->willReturn(self::$usdAmount);
+ $usdOrder->expects(static::once())
+ ->method('getBaseCurrencyCode')
+ ->willReturn('USD');
+
+ return [$eurOrder, $uahOrder, $usdOrder];
+ }
+}
From 8ad50801ef6a1195f9527612c2400b63d2699c23 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 15 Dec 2016 04:13:21 -0600
Subject: [PATCH 033/225] MAGETWO-61914: Create case request to Signifyd
- improved observer implementation in case of disabled Signifyd integration
---
app/code/Magento/Signifyd/Observer/PlaceOrder.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index aa9d0d39e5988..2eba75225ffcd 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -50,6 +50,10 @@ public function __construct(
*/
public function execute(Observer $observer)
{
+ if (!$this->signifydIntegrationConfig->isEnabled()) {
+ return;
+ }
+
$event = $observer->getEvent();
$order = $this->extractOrder($event);
@@ -62,10 +66,6 @@ public function execute(Observer $observer)
return;
}
- if (!$this->signifydIntegrationConfig->isEnabled()) {
- return;
- }
-
$this->caseCreationService->createForOrder($orderId);
}
From 66c5ba85f54538cb4ed31787bf9103985b58b5d8 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 15 Dec 2016 04:14:37 -0600
Subject: [PATCH 034/225] MAGETWO-61914: Create case request to Signifyd
- fixed typo in guard condition
---
app/code/Magento/Signifyd/Observer/PlaceOrder.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index 2eba75225ffcd..f59dc7769e310 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -62,7 +62,7 @@ public function execute(Observer $observer)
}
$orderId = $order->getEntityId();
- if (null === $order) {
+ if (null === $orderId) {
return;
}
From bc5f1d89317a6caf7d0cd65a78dcb5ec89975df7 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 15 Dec 2016 04:18:55 -0600
Subject: [PATCH 035/225] MAGETWO-61914: Create case request to Signifyd
- declared used dependecies
---
app/code/Magento/Signifyd/composer.json | 5 ++++-
app/code/Magento/Signifyd/etc/module.xml | 2 ++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 69a42f2aa3336..5f18eff9001c2 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -5,7 +5,10 @@
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"magento/framework": "100.2.*",
"magento/module-sales": "100.2.*",
- "magento/module-store": "100.2.*"
+ "magento/module-store": "100.2.*",
+ "magento/module-checkout": "100.2.*",
+ "magento/module-customer": "100.2.*",
+ "magento/module-directory": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 40335d45f28a5..0a84948b522f7 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -11,6 +11,8 @@
+
+
From ef31feadf1ff3510124d2952c3059ec97136ec58 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 15 Dec 2016 04:32:23 -0600
Subject: [PATCH 036/225] MAGETWO-61914: Create case request to Signifyd
- removed edundant dependencies
---
app/code/Magento/Signifyd/composer.json | 1 -
app/code/Magento/Signifyd/etc/module.xml | 1 -
2 files changed, 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 5f18eff9001c2..920086ebd0106 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -6,7 +6,6 @@
"magento/framework": "100.2.*",
"magento/module-sales": "100.2.*",
"magento/module-store": "100.2.*",
- "magento/module-checkout": "100.2.*",
"magento/module-customer": "100.2.*",
"magento/module-directory": "100.2.*"
},
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 0a84948b522f7..565ee18b92142 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,7 +9,6 @@
-
From fe2bf20ba62fe4380804bd7f691ffce45bd3778b Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 16 Dec 2016 04:28:06 -0600
Subject: [PATCH 037/225] MAGETWO-61968: Create component for frontend
(cherry picked from commit 7b65337)
---
.../Magento/Signifyd/Block/Fingerprint.php | 71 +++++++++++++++++++
.../frontend/layout/checkout_index_index.xml | 14 ++++
.../view/frontend/templates/fingerprint.phtml | 17 +++++
.../Signifyd/Block/FingerprintTest.php | 61 ++++++++++++++++
.../Signifyd/frontend/js/Fingerprint.test.js | 38 ++++++++++
5 files changed, 201 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Block/Fingerprint.php
create mode 100644 app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml
create mode 100644 app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js
diff --git a/app/code/Magento/Signifyd/Block/Fingerprint.php b/app/code/Magento/Signifyd/Block/Fingerprint.php
new file mode 100644
index 0000000000000..07b6df02cf103
--- /dev/null
+++ b/app/code/Magento/Signifyd/Block/Fingerprint.php
@@ -0,0 +1,71 @@
+orderSessionId = $orderSessionId;
+ $this->config = $config;
+ }
+
+ /**
+ * Retrieves per-order session id.
+ *
+ * @return string
+ */
+ public function getOrderSessionId()
+ {
+ return $this->orderSessionId->generate();
+ }
+
+ /**
+ * Checks if module is enabled.
+ *
+ * @return boolean
+ */
+ public function isModuleEnabled()
+ {
+ return $this->config->isEnabled();
+ }
+}
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
new file mode 100644
index 0000000000000..07b04cc41d1bf
--- /dev/null
+++ b/app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
new file mode 100644
index 0000000000000..e15632ca9d4af
--- /dev/null
+++ b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
@@ -0,0 +1,17 @@
+
+isModuleEnabled()): ?>
+
+
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
new file mode 100644
index 0000000000000..1f7c71ba7b2c4
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
@@ -0,0 +1,61 @@
+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() {
+ static::assertRegExp('/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() {
+ static::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/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
new file mode 100644
index 0000000000000..e9a9122eadb85
--- /dev/null
+++ b/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js
@@ -0,0 +1,38 @@
+/**
+ * Copyright © 2016 Magento. 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 () {
+
+ 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);
+
+ }, 12000);
+ });
+});
From 73652d5bb8bec5b3adf7ec459c062a045f8ae87e Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 16 Dec 2016 05:00:04 -0600
Subject: [PATCH 038/225] MAGETWO-61968: Create component for frontend
- static tests fix
---
.../view/frontend/templates/fingerprint.phtml | 1 -
.../Magento/Signifyd/Block/FingerprintTest.php | 11 +++++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
index e15632ca9d4af..7d0e645afba01 100644
--- a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
+++ b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
@@ -9,7 +9,6 @@
isModuleEnabled()): ?>
\ No newline at end of file
From 2ff10581e9240beb38981307db4b1f63f11ba772 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 19 Dec 2016 04:06:43 -0600
Subject: [PATCH 048/225] MAGETWO-61969: Add fingerprint to case builder
- Refactoring of quote session id generation
---
.../Magento/Signifyd/Model/QuoteSessionId.php | 5 +++--
.../Request/PurchaseBuilder.php | 14 +++++++-------
.../Test/Unit/Model/QuoteSessionIdTest.php | 19 +++++++++++++++++--
.../Request/CreateCaseBuilderTest.php | 14 +++++++-------
4 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/QuoteSessionId.php b/app/code/Magento/Signifyd/Model/QuoteSessionId.php
index 044836f6a54a6..e36e7f27b8efa 100644
--- a/app/code/Magento/Signifyd/Model/QuoteSessionId.php
+++ b/app/code/Magento/Signifyd/Model/QuoteSessionId.php
@@ -42,12 +42,13 @@ public function __construct(
/**
* Generates unique identifier by quote id.
*
+ * @param int|null $quoteId
* @return string
*/
- public function generate()
+ public function generate($quoteId = null)
{
return $this->identityGenerator->generateIdForData(
- $this->quoteSession->getQuote()->getId()
+ $quoteId ? : $this->quoteSession->getQuote()->getId()
);
}
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 5224a28830f96..de10249970cde 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -6,10 +6,10 @@
namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\App\Area;
-use Magento\Framework\DataObject\IdentityGeneratorInterface;
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Config\ScopeInterface;
use Magento\Sales\Model\Order;
+use Magento\Signifyd\Model\QuoteSessionId;
/**
* Prepare data related to purchase event represented in case creation request.
@@ -27,23 +27,23 @@ class PurchaseBuilder
private $scope;
/**
- * @var IdentityGeneratorInterface
+ * @var QuoteSessionId
*/
- private $identityGenerator;
+ private $quoteSessionId;
/**
* @param DateTimeFactory $dateTimeFactory
* @param ScopeInterface $scope
- * @param IdentityGeneratorInterface $identityGenerator
+ * @param QuoteSessionId $quoteSessionId
*/
public function __construct(
DateTimeFactory $dateTimeFactory,
ScopeInterface $scope,
- IdentityGeneratorInterface $identityGenerator
+ QuoteSessionId $quoteSessionId
) {
$this->dateTimeFactory = $dateTimeFactory;
$this->scope = $scope;
- $this->identityGenerator = $identityGenerator;
+ $this->quoteSessionId = $quoteSessionId;
}
/**
@@ -62,7 +62,7 @@ public function build(Order $order)
$result = [
'purchase' => [
- 'orderSessionId' => $this->identityGenerator->generateIdForData($order->getQuoteId()),
+ 'orderSessionId' => $this->quoteSessionId->generate($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => $createdAt->format(\DateTime::ATOM),
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
index cd6e1f82c9b98..4601939fe2057 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
@@ -18,6 +18,8 @@
*/
class QuoteSessionIdTest extends \PHPUnit_Framework_TestCase
{
+ const QUOTE_ID = 1;
+
/**
* @var QuoteSessionId
*/
@@ -48,11 +50,24 @@ protected function setUp()
}
/**
- * Sets up general expectations for method.
+ * Tests method by passing quoteId parameter
+ *
+ * @covers \Magento\Signifyd\Model\QuoteSessionId::generate
+ */
+ public function testGenerateByQuoteId()
+ {
+ $this->identityGenerator->expects(static::once())
+ ->method('generateIdForData');
+
+ $this->quoteSessionId->generate(self::QUOTE_ID);
+ }
+
+ /**
+ * Tests method by getting quoteId from session
*
* @covers \Magento\Signifyd\Model\QuoteSessionId::generate
*/
- public function testGenerateQuoteSessionId()
+ public function testGenerateByQuoteSession()
{
$quote = $this->getMockBuilder(CartInterface::class)
->getMockForAbstractClass();
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
index 9367a483fc2dc..9f1119954b311 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\Config\ScopeInterface;
-use Magento\Framework\DataObject\IdentityGeneratorInterface;
+use Magento\Signifyd\Model\QuoteSessionId;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\App\Area;
use Magento\Framework\Intl\DateTimeFactory;
@@ -75,12 +75,12 @@ public function testCreateCaseBuilderWithFullSetOfData()
$productMetadata = $this->objectManager->create(ProductMetadataInterface::class);
- /** @var IdentityGeneratorInterface $identityGenerator */
- $identityGenerator = $this->objectManager->create(IdentityGeneratorInterface::class);
+ /** @var QuoteSessionId $quoteSessionId */
+ $quoteSessionId = $this->objectManager->create(QuoteSessionId::class);
$expected = [
'purchase' => [
- 'orderSessionId' => $identityGenerator->generateIdForData($order->getQuoteId()),
+ 'orderSessionId' => $quoteSessionId->generate($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
@@ -186,12 +186,12 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
$billingAddress = $order->getBillingAddress();
$productMetadata = $this->objectManager->create(ProductMetadataInterface::class);
- /** @var IdentityGeneratorInterface $identityGenerator */
- $identityGenerator = $this->objectManager->create(IdentityGeneratorInterface::class);
+ /** @var QuoteSessionId $quoteSessionId */
+ $quoteSessionId = $this->objectManager->create(QuoteSessionId::class);
$expected = [
'purchase' => [
- 'orderSessionId' => $identityGenerator->generateIdForData($order->getQuoteId()),
+ 'orderSessionId' => $quoteSessionId->generate($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
From 02345a47ac6b1671e25a85186635708136357432 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 23 Dec 2016 07:22:37 -0600
Subject: [PATCH 049/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- static and acceptance tests fix
---
app/code/Magento/Signifyd/etc/di.xml | 1 +
app/code/Magento/Signifyd/etc/module.xml | 2 ++
2 files changed, 3 insertions(+)
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 81d157887f7e1..df5214ba14c52 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -12,4 +12,5 @@
+
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 565ee18b92142..2db123b053108 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -12,6 +12,8 @@
+
+
From 56a6573801e0bffb94a0df5f4d2804b2fc439809 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 19 Dec 2016 05:56:50 -0600
Subject: [PATCH 050/225] MAGETWO-61969: Add fingerprint to case builder
- Refactor name of quote session id getter method
---
app/code/Magento/Signifyd/Block/Fingerprint.php | 2 +-
.../Model/QuoteSession/QuoteSessionInterface.php | 4 +---
.../Magento/Signifyd/Model/QuoteSessionId.php | 6 +++---
.../SignifydGateway/Request/PurchaseBuilder.php | 2 +-
.../Test/Unit/Model/QuoteSessionIdTest.php | 12 ++++++------
app/code/Magento/Signifyd/composer.json | 4 +++-
.../view/frontend/templates/fingerprint.phtml | 16 +++++++++-------
.../Request/CreateCaseBuilderTest.php | 4 ++--
8 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Fingerprint.php b/app/code/Magento/Signifyd/Block/Fingerprint.php
index 0e541f9036eba..ed14d75e7a16f 100644
--- a/app/code/Magento/Signifyd/Block/Fingerprint.php
+++ b/app/code/Magento/Signifyd/Block/Fingerprint.php
@@ -56,7 +56,7 @@ public function __construct(
*/
public function getQuoteSessionId()
{
- return $this->quoteSessionId->generate();
+ return $this->quoteSessionId->get();
}
/**
diff --git a/app/code/Magento/Signifyd/Model/QuoteSession/QuoteSessionInterface.php b/app/code/Magento/Signifyd/Model/QuoteSession/QuoteSessionInterface.php
index 9a68341596b65..dafaf680ee39d 100644
--- a/app/code/Magento/Signifyd/Model/QuoteSession/QuoteSessionInterface.php
+++ b/app/code/Magento/Signifyd/Model/QuoteSession/QuoteSessionInterface.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Model\QuoteSession;
-use Magento\Quote\Api\Data\CartInterface;
-
/**
* Interface QuoteSessionInterface
*/
@@ -15,7 +13,7 @@ interface QuoteSessionInterface
/**
* Returns quote from session.
*
- * @return CartInterface
+ * @return \Magento\Quote\Api\Data\CartInterface
*/
public function getQuote();
}
diff --git a/app/code/Magento/Signifyd/Model/QuoteSessionId.php b/app/code/Magento/Signifyd/Model/QuoteSessionId.php
index e36e7f27b8efa..004fff462b16d 100644
--- a/app/code/Magento/Signifyd/Model/QuoteSessionId.php
+++ b/app/code/Magento/Signifyd/Model/QuoteSessionId.php
@@ -9,7 +9,7 @@
use Magento\Signifyd\Model\QuoteSession\QuoteSessionInterface;
/**
- * Class SessionId generate uuid by quote id.
+ * Class SessionId encapsulate generation of uuid by quote id.
*/
class QuoteSessionId
{
@@ -40,12 +40,12 @@ public function __construct(
}
/**
- * Generates unique identifier by quote id.
+ * Gets unique identifier through generation uuid by quote id.
*
* @param int|null $quoteId
* @return string
*/
- public function generate($quoteId = null)
+ public function get($quoteId = null)
{
return $this->identityGenerator->generateIdForData(
$quoteId ? : $this->quoteSession->getQuote()->getId()
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index de10249970cde..8a83cc64ad1de 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -62,7 +62,7 @@ public function build(Order $order)
$result = [
'purchase' => [
- 'orderSessionId' => $this->quoteSessionId->generate($order->getQuoteId()),
+ 'orderSessionId' => $this->quoteSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => $createdAt->format(\DateTime::ATOM),
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
index 4601939fe2057..e4cdad26ec204 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
@@ -52,22 +52,22 @@ protected function setUp()
/**
* Tests method by passing quoteId parameter
*
- * @covers \Magento\Signifyd\Model\QuoteSessionId::generate
+ * @covers \Magento\Signifyd\Model\QuoteSessionId::get
*/
- public function testGenerateByQuoteId()
+ public function testGetByQuoteId()
{
$this->identityGenerator->expects(static::once())
->method('generateIdForData');
- $this->quoteSessionId->generate(self::QUOTE_ID);
+ $this->quoteSessionId->get(self::QUOTE_ID);
}
/**
* Tests method by getting quoteId from session
*
- * @covers \Magento\Signifyd\Model\QuoteSessionId::generate
+ * @covers \Magento\Signifyd\Model\QuoteSessionId::get
*/
- public function testGenerateByQuoteSession()
+ public function testGetByQuoteSession()
{
$quote = $this->getMockBuilder(CartInterface::class)
->getMockForAbstractClass();
@@ -81,6 +81,6 @@ public function testGenerateByQuoteSession()
$quote->expects(static::once())
->method('getId');
- $this->quoteSessionId->generate();
+ $this->quoteSessionId->get();
}
}
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 920086ebd0106..cf9b2311bbba5 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -7,7 +7,9 @@
"magento/module-sales": "100.2.*",
"magento/module-store": "100.2.*",
"magento/module-customer": "100.2.*",
- "magento/module-directory": "100.2.*"
+ "magento/module-directory": "100.2.*",
+ "magento/module-checkout": "100.2.*",
+ "magento/module-backend": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
diff --git a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
index e3388531c4670..a9f5a9dd476da 100644
--- a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
+++ b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
@@ -4,13 +4,15 @@
* See COPYING.txt for license details.
*/
+// @codingStandardsIgnoreFile
+
/** @var $block Magento\Signifyd\Block\Fingerprint */
?>
isModuleEnabled()): ?>
-
-
\ No newline at end of file
+
+
\ No newline at end of file
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
index 9f1119954b311..2201a4ed6a3aa 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -80,7 +80,7 @@ public function testCreateCaseBuilderWithFullSetOfData()
$expected = [
'purchase' => [
- 'orderSessionId' => $quoteSessionId->generate($order->getQuoteId()),
+ 'orderSessionId' => $quoteSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
@@ -191,7 +191,7 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
$expected = [
'purchase' => [
- 'orderSessionId' => $quoteSessionId->generate($order->getQuoteId()),
+ 'orderSessionId' => $quoteSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
From 0bd394012087714743ce3637d1e70fa651d78d1c Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Mon, 19 Dec 2016 04:35:59 -0600
Subject: [PATCH 051/225] MAGETWO-61928: Handle response
- fixed debugger issue after refactoring: exception thrown during respone handling should not be recorded to debug info as failure of API call, we should write API response instead
---
.../Model/SignifydGateway/ApiClient.php | 74 ++++++++++++-------
1 file changed, 47 insertions(+), 27 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 0887c384e901d..86e424b45bc62 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -85,31 +85,9 @@ public function __construct(
*/
public function makeApiCall($url, $method, array $params = [])
{
- try {
- $client = $this->getRequestClient($url, $method, $params);
- $response = $client->request();
- $result = $this->handleResponse($response);
-
- $this->debuggerFactory->create()->success(
- $client->getUri(true),
- $client->getLastRequest(),
- $response->getStatus() . ' ' . $response->getMessage(),
- $response->getBody()
- );
- } catch (\Exception $e) {
- $this->debuggerFactory->create()->failure(
- $client->getUri(true),
- $client->getLastRequest(),
- $e
- );
-
- throw new ApiCallException(
- 'Unable to process Signifyd API: ' . $e->getMessage(),
- $e->getCode(),
- $e,
- $client->getLastRequest()
- );
- }
+ $client = $this->buildRequestClient($url, $method, $params);
+ $response = $this->sendRequest($client);
+ $result = $this->handleResponse($response);
return $result;
}
@@ -119,9 +97,9 @@ public function makeApiCall($url, $method, array $params = [])
* @param string $url
* @param string $method
* @param array $params
- * @return \Zend_Http_Client
+ * @return ZendClient
*/
- private function getRequestClient($url, $method, array $params = [])
+ private function buildRequestClient($url, $method, array $params = [])
{
$apiKey = $this->getApiKey();
$apiUrl = $this->buildFullApiUrl($url);
@@ -141,6 +119,48 @@ private function getRequestClient($url, $method, array $params = [])
return $client;
}
+ /**
+ * Send 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
+ *
+ * @return \Zend_Http_Response
+ * @throws ApiCallException
+ */
+ private function sendRequest(ZendClient $client)
+ {
+
+ try {
+ $response = $client->request();
+
+ $this->debuggerFactory->create()->success(
+ $client->getUri(true),
+ $client->getLastRequest(),
+ $response->getStatus() . ' ' . $response->getMessage(),
+ $response->getBody()
+ );
+
+ return $response;
+ } catch (\Exception $e) {
+ $this->debuggerFactory->create()->failure(
+ $client->getUri(true),
+ $client->getLastRequest(),
+ $e
+ );
+
+ throw new ApiCallException(
+ 'Unable to process Signifyd API: ' . $e->getMessage(),
+ $e->getCode(),
+ $e,
+ $client->getLastRequest()
+ );
+ }
+ }
+
/**
* Read result of successful operation and throw exception in case of any failure.
*
From 811706517af7353e0354b8bb7dd95f68132999fc Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 20 Dec 2016 03:36:58 -0600
Subject: [PATCH 052/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Updates error messages in CaseCreationServiceTest
---
.../Magento/Signifyd/Model/CaseCreationServiceTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
index a200d93c6618b..effee790eaa2a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
@@ -117,7 +117,7 @@ public function testCreateForOrderWithEmptyResponse()
$this->logger->expects(static::once())
->method('error')
- ->with('Unable to process Signifyd API: Response is not valid JSON: Decoding failed: Syntax error');
+ ->with('Response is not valid JSON: Decoding failed: Syntax error');
$result = $this->service->createForOrder($order->getEntityId());
static::assertTrue($result);
@@ -152,7 +152,7 @@ public function testCreateForOrderWithBadResponse()
$this->logger->expects(static::once())
->method('error')
->with(
- 'Unable to process Signifyd API: Bad Request - The request could not be parsed. Response: ' .
+ 'Bad Request - The request could not be parsed. Response: ' .
json_encode($responseData)
);
From 70b6d80eebc7fcf534239c1d955796a987d437f3 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 20 Dec 2016 10:55:10 -0600
Subject: [PATCH 053/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Fix bug with multishipping place order
- Rename QuoteSessionId to SignifydOrderSessionId
- Update annotations
---
.../Magento/Signifyd/Block/Fingerprint.php | 42 ++++++---
.../Magento/Signifyd/Model/CaseManagement.php | 3 +-
.../Magento/Signifyd/Model/CaseRepository.php | 7 +-
app/code/Magento/Signifyd/Model/Config.php | 2 +-
.../Magento/Signifyd/Model/QuoteSessionId.php | 54 ------------
.../Model/SignifydGateway/ApiClient.php | 28 +++---
.../Request/CreateCaseBuilderInterface.php | 6 +-
.../Request/PurchaseBuilder.php | 14 +--
.../Signifyd/Model/SignifydOrderSessionId.php | 39 +++++++++
.../Magento/Signifyd/Observer/PlaceOrder.php | 34 +++++---
app/code/Magento/Signifyd/README.md | 2 +-
.../Test/Unit/Model/QuoteSessionIdTest.php | 86 -------------------
.../Unit/Model/SignifydOrderSessionIdTest.php | 60 +++++++++++++
.../Magento/Signifyd/etc/adminhtml/system.xml | 6 +-
.../Magento/Signifyd/etc/frontend/routes.xml | 14 ---
.../view/frontend/templates/fingerprint.phtml | 4 +-
.../Request/CreateCaseBuilderTest.php | 12 +--
17 files changed, 187 insertions(+), 226 deletions(-)
delete mode 100644 app/code/Magento/Signifyd/Model/QuoteSessionId.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
delete mode 100644 app/code/Magento/Signifyd/etc/frontend/routes.xml
diff --git a/app/code/Magento/Signifyd/Block/Fingerprint.php b/app/code/Magento/Signifyd/Block/Fingerprint.php
index ed14d75e7a16f..babceee2e1423 100644
--- a/app/code/Magento/Signifyd/Block/Fingerprint.php
+++ b/app/code/Magento/Signifyd/Block/Fingerprint.php
@@ -8,55 +8,69 @@
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Signifyd\Model\Config;
-use Magento\Signifyd\Model\QuoteSessionId;
+use Magento\Signifyd\Model\QuoteSession\QuoteSessionInterface;
+use Magento\Signifyd\Model\SignifydOrderSessionId;
/**
- * Class Fingerprint
+ * Provides data for Signifyd device fingerprinting script.
+ *
+ * Signifyd’s device fingerprinting solution uniquely tracks and identifies devices
+ * used to transact on your site, increasing your protection from fraud.
+ *
+ * @see https://www.signifyd.com/docs/api/#/reference/device-fingerprint/create-a-case
*/
class Fingerprint extends Template
{
/**
- * @var QuoteSessionId
+ * @var SignifydOrderSessionId
*/
- private $quoteSessionId;
+ private $signifydOrderSessionId;
/**
* @var Config
*/
private $config;
+ /**
+ * @var QuoteSessionInterface
+ */
+ private $quoteSession;
+
/**
* @var string
*/
protected $_template = 'fingerprint.phtml';
/**
- * Constructor
- *
* @param Context $context
* @param Config $config
- * @param QuoteSessionId $orderSessionId
+ * @param SignifydOrderSessionId $signifydOrderSessionId
+ * @param QuoteSessionInterface $quoteSession
* @param array $data
*/
public function __construct(
Context $context,
Config $config,
- QuoteSessionId $orderSessionId,
+ SignifydOrderSessionId $signifydOrderSessionId,
+ QuoteSessionInterface $quoteSession,
array $data = []
) {
parent::__construct($context, $data);
- $this->quoteSessionId = $orderSessionId;
+ $this->signifydOrderSessionId = $signifydOrderSessionId;
$this->config = $config;
+ $this->quoteSession = $quoteSession;
}
/**
- * Retrieves per-order session id.
+ * Returns a unique Signifyd order session id.
*
* @return string
*/
- public function getQuoteSessionId()
+ public function getSignifydOrderSessionId()
{
- return $this->quoteSessionId->get();
+ $quoteId = $this->quoteSession->getQuote()->getId();
+
+ return $this->signifydOrderSessionId->get($quoteId);
}
/**
@@ -64,8 +78,8 @@ public function getQuoteSessionId()
*
* @return boolean
*/
- public function isModuleEnabled()
+ public function isModuleActive()
{
- return $this->config->isEnabled();
+ return $this->config->isActive();
}
}
diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php
index 3e31e0af1d883..504b52b85a74a 100644
--- a/app/code/Magento/Signifyd/Model/CaseManagement.php
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -13,7 +13,8 @@
use Magento\Signifyd\Api\Data\CaseInterfaceFactory;
/**
- * Implementation of case management interface
+ *
+ * Default case management implementation
*/
class CaseManagement implements CaseManagementInterface
{
diff --git a/app/code/Magento/Signifyd/Model/CaseRepository.php b/app/code/Magento/Signifyd/Model/CaseRepository.php
index 723dea8421167..f18ffc47356d9 100644
--- a/app/code/Magento/Signifyd/Model/CaseRepository.php
+++ b/app/code/Magento/Signifyd/Model/CaseRepository.php
@@ -77,6 +77,7 @@ public function save(CaseInterface $case)
{
/** @var CaseEntity $case */
$this->resourceModel->save($case);
+
return $case;
}
@@ -88,6 +89,7 @@ public function getById($id)
/** @var CaseEntity $case */
$case = $this->caseFactory->create();
$this->resourceModel->load($case, $id);
+
return $case;
}
@@ -97,13 +99,12 @@ public function getById($id)
public function delete(CaseInterface $case)
{
$this->resourceModel->delete($case);
+
return true;
}
/**
- * Gets list of case entities
- * @param SearchCriteria $searchCriteria
- * @return CaseSearchResultsInterface
+ * @inheritdoc
*/
public function getList(SearchCriteria $searchCriteria)
{
diff --git a/app/code/Magento/Signifyd/Model/Config.php b/app/code/Magento/Signifyd/Model/Config.php
index f99480386293a..b7c2afe4cb109 100644
--- a/app/code/Magento/Signifyd/Model/Config.php
+++ b/app/code/Magento/Signifyd/Model/Config.php
@@ -36,7 +36,7 @@ public function __construct(ScopeConfigInterface $scopeConfig)
*
* @return bool
*/
- public function isEnabled()
+ public function isActive()
{
$enabled = $this->scopeConfig->isSetFlag(
'fraud_protection/signifyd/active',
diff --git a/app/code/Magento/Signifyd/Model/QuoteSessionId.php b/app/code/Magento/Signifyd/Model/QuoteSessionId.php
deleted file mode 100644
index 004fff462b16d..0000000000000
--- a/app/code/Magento/Signifyd/Model/QuoteSessionId.php
+++ /dev/null
@@ -1,54 +0,0 @@
-quoteSession = $quoteSession;
- $this->identityGenerator = $identityGenerator;
- }
-
- /**
- * Gets unique identifier through generation uuid by quote id.
- *
- * @param int|null $quoteId
- * @return string
- */
- public function get($quoteId = null)
- {
- return $this->identityGenerator->generateIdForData(
- $quoteId ? : $this->quoteSession->getQuote()->getId()
- );
- }
-}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 86e424b45bc62..3b14773b3fd25 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -14,8 +14,6 @@
use Exception;
/**
- * Signifyd API Client.
- *
* Encapsulates Signifyd API protocol.
*/
class ApiClient
@@ -46,8 +44,6 @@ class ApiClient
private $debuggerFactory;
/**
- * ApiClient constructor.
- *
* Class uses client factory to instantiate new client for interacting with API.
* All requests and responses are processed by JSON encoder and decoder.
*
@@ -92,7 +88,7 @@ public function makeApiCall($url, $method, array $params = [])
}
/**
- * Init HTTP client for processing requests to Signifyd API.
+ * Returns HTTP client configured with request for API call.
*
* @param string $url
* @param string $method
@@ -120,14 +116,13 @@ private function buildRequestClient($url, $method, array $params = [])
}
/**
- * Send HTTP request to Signifyd API with configured client
+ * Send 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
- *
* @return \Zend_Http_Response
* @throws ApiCallException
*/
@@ -165,7 +160,6 @@ private function sendRequest(ZendClient $client)
* Read result of successful operation and throw exception in case of any failure.
*
* @param \Zend_Http_Response $response
- *
* @return array
* @throws ApiCallException
*/
@@ -194,7 +188,7 @@ private function handleResponse(\Zend_Http_Response $response)
}
/**
- * Make error message for request rejected by Signify
+ * Make error message for request rejected by Signify.
*
* @param \Zend_Http_Response $response
* @return string
@@ -205,15 +199,15 @@ private function buildApiCallFailureMessage(\Zend_Http_Response $response)
switch ($response->getStatus()) {
case 400:
return 'Bad Request - The request could not be parsed. Response: ' . $responseBody;
+ case 401:
+ return 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody;
+ case 403:
+ return 'Forbidden - Cannot access resource. Response: ' . $responseBody;
case 404:
return 'Not Found - resource does not exist. Response: ' . $responseBody;
case 409:
return 'Conflict - with state of the resource on server. Can occur with (too rapid) PUT requests.' .
'Response: ' . $responseBody;
- case 401:
- return 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody;
- case 403:
- return 'Forbidden - Cannot access resource. Response: ' . $responseBody;
case 500:
return 'Server error.';
default:
@@ -234,9 +228,9 @@ private function createNewClient()
}
/**
- * Returns Signifyd API key for merchant account
- * @see https://www.signifyd.com/docs/api/#/introduction/authentication
+ * Returns Signifyd API key for merchant account.
*
+ * @see https://www.signifyd.com/docs/api/#/introduction/authentication
* @return string
*/
private function getApiKey()
@@ -245,7 +239,7 @@ private function getApiKey()
}
/**
- * Builds full URL for Singifyd API based on relative URL
+ * Builds full URL for Singifyd API based on relative URL.
*
* @param string $url
* @return string
@@ -258,7 +252,7 @@ private function buildFullApiUrl($url)
}
/**
- * Returns Base Sigifyd API URL without trailing slash
+ * Returns Base Sigifyd API URL without trailing slash.
*
* @return string
*/
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
index e75a8aa9dbcfc..aa5e4ce48485b 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
@@ -5,10 +5,12 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway\Request;
+
+
/**
- * Signifyd case creation request builder interface
+ * Collects information about order and build array with parameters required by Signifyd API.
*
- * Retrieves params for case creation request API call based on order ID
+ * @see https://www.signifyd.com/docs/api/#/reference/cases/create-a-case
*/
interface CreateCaseBuilderInterface
{
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 8a83cc64ad1de..6f39369bc6752 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -9,7 +9,7 @@
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Config\ScopeInterface;
use Magento\Sales\Model\Order;
-use Magento\Signifyd\Model\QuoteSessionId;
+use Magento\Signifyd\Model\SignifydOrderSessionId;
/**
* Prepare data related to purchase event represented in case creation request.
@@ -27,23 +27,23 @@ class PurchaseBuilder
private $scope;
/**
- * @var QuoteSessionId
+ * @var SignifydOrderSessionId
*/
- private $quoteSessionId;
+ private $signifydOrderSessionId;
/**
* @param DateTimeFactory $dateTimeFactory
* @param ScopeInterface $scope
- * @param QuoteSessionId $quoteSessionId
+ * @param SignifydOrderSessionId $signifydOrderSessionId
*/
public function __construct(
DateTimeFactory $dateTimeFactory,
ScopeInterface $scope,
- QuoteSessionId $quoteSessionId
+ SignifydOrderSessionId $signifydOrderSessionId
) {
$this->dateTimeFactory = $dateTimeFactory;
$this->scope = $scope;
- $this->quoteSessionId = $quoteSessionId;
+ $this->signifydOrderSessionId = $signifydOrderSessionId;
}
/**
@@ -62,7 +62,7 @@ public function build(Order $order)
$result = [
'purchase' => [
- 'orderSessionId' => $this->quoteSessionId->get($order->getQuoteId()),
+ 'orderSessionId' => $this->signifydOrderSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => $createdAt->format(\DateTime::ATOM),
diff --git a/app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php b/app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php
new file mode 100644
index 0000000000000..b5f0fcee06ccd
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php
@@ -0,0 +1,39 @@
+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
index f59dc7769e310..1d0a51167dc34 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -14,7 +14,7 @@
use Magento\Signifyd\Api\CaseCreationServiceInterface;
/**
- * Place Order
+ * Place Order observer.
*
* Observer should be triggered when new order is created and placed.
* If Signifyd integration enabled in configuration then new case will be created.
@@ -50,33 +50,39 @@ public function __construct(
*/
public function execute(Observer $observer)
{
- if (!$this->signifydIntegrationConfig->isEnabled()) {
+ if (!$this->signifydIntegrationConfig->isActive()) {
return;
}
- $event = $observer->getEvent();
- $order = $this->extractOrder($event);
+ $orders = $this->extractOrders(
+ $observer->getEvent()
+ );
- if (null === $order) {
+ if (null === $orders) {
return;
}
- $orderId = $order->getEntityId();
- if (null === $orderId) {
- return;
+ foreach ($orders as $order) {
+ $orderId = $order->getEntityId();
+ if (null !== $orderId) {
+ $this->caseCreationService->createForOrder($orderId);
+ }
}
-
- $this->caseCreationService->createForOrder($orderId);
}
/**
- * Fetch Order entity from Event data container
+ * Returns Orders entity list from Event data container
*
* @param Event $event
- * @return OrderInterface|null
+ * @return OrderInterface[]|null
*/
- private function extractOrder(Event $event)
+ private function extractOrders(Event $event)
{
- return $event->getData('order');
+ $order = $event->getData('order');
+ if (null !== $order) {
+ return [$order];
+ }
+
+ return $event->getData('orders');
}
}
diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md
index 3cd2b4a30a858..5159d4c6951c4 100644
--- a/app/code/Magento/Signifyd/README.md
+++ b/app/code/Magento/Signifyd/README.md
@@ -1 +1 @@
-The Magento_Signifyd module implements the integration with the Signifyd fraud prevention service.
+The Magento_Signifyd module implements the integration with the [Signifyd](https://www.signifyd.com/docs/api/) fraud prevention service.
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
deleted file mode 100644
index e4cdad26ec204..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
+++ /dev/null
@@ -1,86 +0,0 @@
-quoteSession = $this->getMockBuilder(QuoteSessionInterface::class)
- ->getMockForAbstractClass();
-
- $this->identityGenerator = $this->getMockBuilder(IdentityGeneratorInterface::class)
- ->getMockForAbstractClass();
-
- $this->quoteSessionId = new QuoteSessionId($this->quoteSession, $this->identityGenerator);
- }
-
- /**
- * Tests method by passing quoteId parameter
- *
- * @covers \Magento\Signifyd\Model\QuoteSessionId::get
- */
- public function testGetByQuoteId()
- {
- $this->identityGenerator->expects(static::once())
- ->method('generateIdForData');
-
- $this->quoteSessionId->get(self::QUOTE_ID);
- }
-
- /**
- * Tests method by getting quoteId from session
- *
- * @covers \Magento\Signifyd\Model\QuoteSessionId::get
- */
- public function testGetByQuoteSession()
- {
- $quote = $this->getMockBuilder(CartInterface::class)
- ->getMockForAbstractClass();
-
- $this->identityGenerator->expects(static::once())
- ->method('generateIdForData');
-
- $this->quoteSession->expects(static::once())
- ->method('getQuote')
- ->willReturn($quote);
- $quote->expects(static::once())
- ->method('getId');
-
- $this->quoteSessionId->get();
- }
-}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
new file mode 100644
index 0000000000000..f8a36ef172dc5
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
@@ -0,0 +1,60 @@
+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(static::once())
+ ->method('generateIdForData')
+ ->with($quoteId)
+ ->willReturn($signifydOrderSessionId);
+
+ $this->assertEquals(
+ $signifydOrderSessionId,
+ $this->signifydOrderSessionId->get($quoteId)
+ );
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/system.xml b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
index 14ae7d73e0e48..a1ecbfcdff95c 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/system.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
@@ -13,7 +13,7 @@
Magento_Sales::fraud_protection
Signifyd
-
+
Enable this Solution
Magento\Config\Model\Config\Source\Yesno
fraud_protection/signifyd/active
@@ -27,9 +27,7 @@
API URL
fraud_protection/signifyd/api_url
-
- Don’t change unless asked to do so.
-
+ Don’t change unless asked to do so.
Debug
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 8a6c5b4e22c1d..0000000000000
--- a/app/code/Magento/Signifyd/etc/frontend/routes.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
index a9f5a9dd476da..609391c2d695d 100644
--- a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
+++ b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
@@ -8,11 +8,11 @@
/** @var $block Magento\Signifyd\Block\Fingerprint */
?>
-isModuleEnabled()): ?>
+isModuleActive()): ?>
\ No newline at end of file
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
index 2201a4ed6a3aa..61dc67b7f7808 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\Config\ScopeInterface;
-use Magento\Signifyd\Model\QuoteSessionId;
+use Magento\Signifyd\Model\SignifydOrderSessionId;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\App\Area;
use Magento\Framework\Intl\DateTimeFactory;
@@ -75,12 +75,12 @@ public function testCreateCaseBuilderWithFullSetOfData()
$productMetadata = $this->objectManager->create(ProductMetadataInterface::class);
- /** @var QuoteSessionId $quoteSessionId */
- $quoteSessionId = $this->objectManager->create(QuoteSessionId::class);
+ /** @var SignifydOrderSessionId $signifydOrderSessionId */
+ $signifydOrderSessionId = $this->objectManager->create(SignifydOrderSessionId::class);
$expected = [
'purchase' => [
- 'orderSessionId' => $quoteSessionId->get($order->getQuoteId()),
+ 'orderSessionId' => $signifydOrderSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
@@ -186,8 +186,8 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
$billingAddress = $order->getBillingAddress();
$productMetadata = $this->objectManager->create(ProductMetadataInterface::class);
- /** @var QuoteSessionId $quoteSessionId */
- $quoteSessionId = $this->objectManager->create(QuoteSessionId::class);
+ /** @var SignifydOrderSessionId $quoteSessionId */
+ $quoteSessionId = $this->objectManager->create(SignifydOrderSessionId::class);
$expected = [
'purchase' => [
From b504a588ad0306c40c886a38f991cac4dd6af3c7 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 23 Dec 2016 07:23:59 -0600
Subject: [PATCH 054/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Move CreateCaseBuilderInterface preference from global to frontend area
---
app/code/Magento/Signifyd/etc/di.xml | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index df5214ba14c52..81d157887f7e1 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -12,5 +12,4 @@
-
\ No newline at end of file
From 176d11efa3c198c1b57fe05a8ecbf67ac4657f46 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 20 Dec 2016 11:36:44 -0600
Subject: [PATCH 055/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- code review comments
---
.../Api/CaseCreationServiceInterface.php | 1 +
.../Signifyd/Api/CaseManagementInterface.php | 10 +-
.../Signifyd/Api/CaseRepositoryInterface.php | 12 +-
.../Signifyd/Api/Data/CaseInterface.php | 129 +++++++-----------
.../Api/Data/CaseSearchResultsInterface.php | 6 +-
.../Signifyd/Model/CaseCreationService.php | 11 +-
.../Magento/Signifyd/Setup/InstallSchema.php | 11 ++
7 files changed, 90 insertions(+), 90 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
index 2118652f31a7d..7141d76371c06 100644
--- a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -20,6 +20,7 @@ interface CaseCreationServiceInterface
*
* @param int $orderId
* @return bool
+ * @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
*/
public function createForOrder($orderId);
}
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index cced6d2e4afe3..40f1dcc11b54f 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -9,23 +9,25 @@
/**
* Signifyd management interface
- * Allows to performs operations with Signifyd cases
+ * Allows to performs operations with Signifyd cases.
*
* @api
*/
interface CaseManagementInterface
{
/**
- * Creates new Case entity
+ * Creates new Case entity linked to order id.
+ *
* @param string $orderId
* @return CaseInterface
*/
public function create($orderId);
/**
- * Gets Case entity
+ * Gets Case entity associated with order id.
+ *
* @param string $orderId
- * @return CaseInterface
+ * @return CaseInterface|null
*/
public function getByOrderId($orderId);
}
diff --git a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
index 99ca62e99643e..0e63e9283ad28 100644
--- a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
@@ -17,28 +17,32 @@
interface CaseRepositoryInterface
{
/**
- * Saves case entity
+ * Saves case entity.
+ *
* @param CaseInterface $case
* @return CaseInterface
*/
public function save(CaseInterface $case);
/**
- * Gets case entity by order id
+ * Gets case entity by order id.
+ *
* @param int $id
* @return CaseInterface
*/
public function getById($id);
/**
- * Deletes case entity
+ * Deletes case entity.
+ *
* @param CaseInterface $case
* @return bool
*/
public function delete(CaseInterface $case);
/**
- * Gets list of case entities
+ * Gets list of case entities.
+ *
* @param SearchCriteria $searchCriteria
* @return CaseSearchResultsInterface
*/
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index ffcfd3f118eb9..6a58effa19e4f 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Api\Data;
/**
- * Interface Signifyd Case entity
+ * Signifyd Case entity interface
*
* @api
* @see https://www.signifyd.com/docs/api/#/reference/cases/retrieve-a-case/get-a-case
@@ -16,218 +16,191 @@ interface CaseInterface
/**#@+
* Constants for case available statuses
*/
-
- /**
- * Open status
- */
const STATUS_OPEN = 'OPEN';
-
- /**
- * Pending status
- */
const STATUS_PENDING = 'PENDING';
-
- /**
- * Processing status
- */
const STATUS_PROCESSING = 'PROCESSING';
-
- /**
- * Flagged status
- */
const STATUS_FLAGGED = 'FLAGGED';
-
- /**
- * Dismissed status
- */
const STATUS_DISMISSED = 'DISMISSED';
+ /**#@-*/
/**#@+
* Constants for guarantee available statuses
*/
-
- /**
- * Approved status
- */
const GUARANTEE_APPROVED = 'APPROVED';
-
- /**
- * Declined status
- */
const GUARANTEE_DECLINED = 'DECLINED';
-
- /**
- * Pending status
- */
const GUARANTEE_PENDING = 'PENDING';
-
- /**
- * Canceled status
- */
const GUARANTEE_CANCELED = 'CANCELED';
-
- /**
- * In review status
- */
const GUARANTEE_IN_REVIEW = 'IN_REVIEW';
+ /**#@-*/
/**#@+
* Constants for case available review dispositions
*/
-
- /**
- * Review disposition is good
- */
const DISPOSITION_GOOD = 'GOOD';
-
- /**
- * Review disposition is fraud
- */
const DISPOSITION_FRAUDULENT = 'FRAUDULENT';
-
- /**
- * Review disposition is not set
- */
const DISPOSITION_UNSET = 'UNSET';
+ /**#@-*/
/**
- * Gets case entity id
+ * Returns local case entity identifier.
+ *
* @return int
*/
public function getEntityId();
/**
- * Sets case entity id
+ * Sets local case entity id.
+ *
* @param int $id
* @return $this
*/
public function setEntityId($id);
/**
- * Gets Signifyd case id
+ * Returns Signifyd case identifier.
+ *
* @return int
*/
public function getCaseId();
/**
- * Sets Signifyd case id
+ * Sets Signifyd case id.
+ *
* @param int $id
* @return $this
*/
public function setCaseId($id);
/**
- * Gets value, which indicates if a guarantee can be requested for a case
+ * Returns value, which indicates if a guarantee can be requested for a case.
+ *
* @return boolean
*/
public function isGuaranteeEligible();
/**
- * Sets value-indicator about guarantee availability for a case
+ * Sets value-indicator about guarantee availability for a case.
+ *
* @param bool $guaranteeEligible
* @return $this
*/
public function setGuaranteeEligible($guaranteeEligible);
/**
- * Gets decision state of the guarantee
+ * Returns decision state of the guarantee.
+ *
* @return string
*/
public function getGuaranteeDisposition();
/**
- * Sets decision state of the guarantee
+ * Sets decision state of the guarantee.
+ *
* @param string $disposition
* @return $this
*/
public function setGuaranteeDisposition($disposition);
/**
- * Gets case status
+ * Returns case status.
+ *
* @return string
*/
public function getStatus();
/**
- * Sets case status
+ * Sets case status.
+ *
* @param string $status
* @return $this
*/
public function setStatus($status);
/**
- * Gets value, which indicates the likelihood that the order is fraud
+ * Returns value, which indicates the likelihood that the order is fraud.
+ *
* @return int
*/
public function getScore();
/**
- * Sets risk level value
+ * Sets risk level value.
+ *
* @param int $score
* @return $this
*/
public function setScore($score);
/**
- * Get order id for a case
+ * Get order id for a case.
+ *
* @return int
*/
public function getOrderId();
/**
- * Sets order id for a case
+ * Sets order id for a case.
+ *
* @param int $orderId
* @return $this
*/
public function setOrderId($orderId);
/**
- * Gets id of team associated with a case
- * @return int
+ * Returns data about a team associated with a case.
+ *
+ * @return array
*/
public function getAssociatedTeam();
/**
- * Sets case associated team id
- * @param int $teamId
+ * Sets team data associated with a case.
+ *
+ * @param array $team
* @return $this
*/
- public function setAssociatedTeam($teamId);
+ public function setAssociatedTeam(array $team);
/**
- * Gets disposition of an agent's opinion after reviewing the case
+ * Returns disposition of an agent's opinion after reviewing the case.
+ *
* @return string
*/
public function getReviewDisposition();
/**
- * Sets case disposition
+ * Sets case disposition.
+ *
* @param string $disposition
* @return $this
*/
public function setReviewDisposition($disposition);
/**
- * Gets creation datetime for a case
+ * Returns creation datetime for a case.
+ *
* @return string
*/
public function getCreatedAt();
/**
- * Sets creation datetime for a case
+ * Sets creation datetime for a case.
+ *
* @param string $datetime in DATE_ATOM format
* @return $this
*/
public function setCreatedAt($datetime);
/**
- * Gets updating datetime for a case
+ * Returns updating datetime for a case.
+ *
* @return string
*/
public function getUpdatedAt();
/**
- * Sets updating datetime for a case
+ * Sets updating datetime for a case.
+ *
* @param string $datetime in DATE_ATOM format
* @return $this
*/
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
index 6113411a73e01..451206f1b3d15 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
@@ -8,21 +8,21 @@
use Magento\Framework\Api\SearchResultsInterface;
/**
- * Interface for case search results
+ * Retrieve and set list of case entities.
*
* @api
*/
interface CaseSearchResultsInterface extends SearchResultsInterface
{
/**
- * Gets collection items.
+ * Gets collection of case entities.
*
* @return \Magento\Signifyd\Api\Data\CaseInterface[]
*/
public function getItems();
/**
- * Sets collection items.
+ * Sets collection of case entities.
*
* @param \Magento\Signifyd\Api\Data\CaseInterface[] $items
* @return $this
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseCreationService.php
index 27fb33a80345c..dcbbbf11554be 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseCreationService.php
@@ -5,6 +5,9 @@
*/
namespace Magento\Signifyd\Model;
+use Magento\Framework\Exception\AlreadyExistsException;
+use Magento\Framework\DB\Adapter\DuplicateException;
+use Magento\Framework\Phrase;
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
@@ -56,7 +59,12 @@ public function __construct(
*/
public function createForOrder($orderId)
{
- $this->caseManagement->create($orderId);
+ try {
+ $this->caseManagement->create($orderId);
+ } catch (DuplicateException $e) {
+ throw new AlreadyExistsException(new Phrase('This order already has associated case entity'), $e);
+ }
+
try {
$this->signifydGateway->createCase($orderId);
} catch (ApiCallException $e) {
@@ -64,6 +72,7 @@ public function createForOrder($orderId)
} catch (GatewayException $e) {
$this->logger->error($e->getMessage());
}
+
return true;
}
}
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index dfd9a7cfcab19..5b5f807e1f520 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -47,6 +47,17 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
$table->addColumn('review_disposition', Table::TYPE_TEXT, 32);
$table->addColumn('created_at', Table::TYPE_TIMESTAMP);
$table->addColumn('updated_at', Table::TYPE_TIMESTAMP);
+
+ $table->addIndex(
+ $setup->getIdxName(
+ $setup->getTable(static::$table),
+ 'order_id',
+ \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
+ ),
+ 'order_id',
+ ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
+ );
+
$table->addForeignKey(
$setup->getFkName(
$setup->getTable(static::$table),
From 9d0a5a18ab3e6ffeca40d22e7a3abd47d1146ac6 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 03:53:15 -0600
Subject: [PATCH 056/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- refactor associated team to array
---
app/code/Magento/Signifyd/Model/CaseEntity.php | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index 85783da3308da..8502ac5a51b95 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -5,8 +5,10 @@
*/
namespace Magento\Signifyd\Model;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\Model\AbstractModel;
use Magento\Signifyd\Api\Data\CaseInterface;
+use Magento\Framework\Serialize\SerializerInterface;
/**
* Implementation of Signifyd Case interface
@@ -18,11 +20,17 @@ class CaseEntity extends AbstractModel implements CaseInterface
*/
protected $_eventPrefix = 'signifyd_case';
+ /**
+ * @var SerializerInterface
+ */
+ protected $serializer;
+
/**
* @inheritdoc
*/
protected function _construct()
{
+ $this->serializer = ObjectManager::getInstance()->get(SerializerInterface::class);
$this->_init(ResourceModel\CaseEntity::class);
}
@@ -150,15 +158,16 @@ public function setOrderId($orderId)
*/
public function getAssociatedTeam()
{
- return (int) $this->getData('associated_team');
+ $teamData = $this->getData('associated_team');
+ return empty($teamData) ? array() : $this->serializer->unserialize($teamData);
}
/**
* @inheritdoc
*/
- public function setAssociatedTeam($teamId)
+ public function setAssociatedTeam(array $team)
{
- $this->setData('associated_team', (int) $teamId);
+ $this->setData('associated_team', $this->serializer->serialize($team));
return $this;
}
From 805fce3366a0ff72d1f36263ceafa3a754b2523c Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 07:35:32 -0600
Subject: [PATCH 057/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- refactor according to review
---
.../Signifyd/Api/CaseManagementInterface.php | 1 +
.../Signifyd/Model/CaseCreationService.php | 9 +----
.../Magento/Signifyd/Model/CaseManagement.php | 8 ++++-
.../Magento/Signifyd/Observer/PlaceOrder.php | 35 ++++++++++++++++---
.../Magento/Signifyd/Setup/InstallSchema.php | 2 +-
.../Signifyd/Block/FingerprintTest.php | 2 +-
.../Request/CreateCaseBuilderTest.php | 4 +--
7 files changed, 43 insertions(+), 18 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index 40f1dcc11b54f..09c2e8c0e164c 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -20,6 +20,7 @@ interface CaseManagementInterface
*
* @param string $orderId
* @return CaseInterface
+ * @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
*/
public function create($orderId);
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseCreationService.php
index dcbbbf11554be..c544ab30d6b35 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseCreationService.php
@@ -5,9 +5,6 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\Exception\AlreadyExistsException;
-use Magento\Framework\DB\Adapter\DuplicateException;
-use Magento\Framework\Phrase;
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
@@ -59,11 +56,7 @@ public function __construct(
*/
public function createForOrder($orderId)
{
- try {
- $this->caseManagement->create($orderId);
- } catch (DuplicateException $e) {
- throw new AlreadyExistsException(new Phrase('This order already has associated case entity'), $e);
- }
+ $this->caseManagement->create($orderId);
try {
$this->signifydGateway->createCase($orderId);
diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php
index 504b52b85a74a..8705f9a812ae3 100644
--- a/app/code/Magento/Signifyd/Model/CaseManagement.php
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -11,6 +11,8 @@
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Api\Data\CaseInterfaceFactory;
+use Magento\Framework\Exception\AlreadyExistsException;
+use Magento\Framework\DB\Adapter\DuplicateException;
/**
*
@@ -65,7 +67,11 @@ public function create($orderId)
$case = $this->caseFactory->create();
$case->setOrderId($orderId)
->setStatus(CaseInterface::STATUS_PENDING);
- return $this->caseRepository->save($case);
+ try {
+ return $this->caseRepository->save($case);
+ } catch (DuplicateException $e) {
+ throw new AlreadyExistsException(__('This order already has associated case entity'), $e);
+ }
}
/**
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index 1d0a51167dc34..ef037ca7cd8e4 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -12,6 +12,8 @@
use Magento\Signifyd\Model\Config;
use Magento\Signifyd\Api\CaseCreationServiceInterface;
+use Psr\Log\LoggerInterface;
+use Magento\Framework\Exception\AlreadyExistsException;
/**
* Place Order observer.
@@ -31,18 +33,26 @@ class PlaceOrder implements ObserverInterface
*/
private $caseCreationService;
+ /**
+ * @var LoggerInterface
+ */
+ private $logger;
+
/**
* PlaceOrder constructor.
*
* @param Config $signifydIntegrationConfig
* @param CaseCreationServiceInterface $caseCreationService
+ * @param LoggerInterface $logger
*/
public function __construct(
Config $signifydIntegrationConfig,
- CaseCreationServiceInterface $caseCreationService
+ CaseCreationServiceInterface $caseCreationService,
+ LoggerInterface $logger
) {
$this->signifydIntegrationConfig = $signifydIntegrationConfig;
$this->caseCreationService = $caseCreationService;
+ $this->logger = $logger;
}
/**
@@ -63,10 +73,25 @@ public function execute(Observer $observer)
}
foreach ($orders as $order) {
- $orderId = $order->getEntityId();
- if (null !== $orderId) {
- $this->caseCreationService->createForOrder($orderId);
- }
+ $this->createCaseForOrder($order);
+ }
+ }
+
+ /**
+ * Creates signifyd case for single order
+ *
+ * @param OrderInterface $order
+ */
+ private function createCaseForOrder($order) {
+ $orderId = $order->getEntityId();
+ if (null !== $orderId) {
+ return;
+ }
+
+ try {
+ $this->caseCreationService->createForOrder($orderId);
+ } catch (AlreadyExistsException $e) {
+ $this->logger->error($e->getMessage());
}
}
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index 5b5f807e1f520..deb313c66a828 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -43,7 +43,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
$table->addColumn('guarantee_disposition', Table::TYPE_TEXT, 32);
$table->addColumn('status', Table::TYPE_TEXT, 32, ['default' => CaseInterface::STATUS_PENDING]);
$table->addColumn('score', Table::TYPE_INTEGER, null, ['unsigned' => true]);
- $table->addColumn('associated_team', Table::TYPE_INTEGER, null, ['unsigned' => true]);
+ $table->addColumn('associated_team', Table::TYPE_TEXT, '64k');
$table->addColumn('review_disposition', Table::TYPE_TEXT, 32);
$table->addColumn('created_at', Table::TYPE_TIMESTAMP);
$table->addColumn('updated_at', Table::TYPE_TIMESTAMP);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
index 2cdd3c1d67a3c..6708af55dddf9 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
@@ -36,7 +36,7 @@ protected function setUp()
*/
public function testSessionIdPresent()
{
- static::assertRegExp('/data-order-session-id=\"[^\"]+\"/', $this->getBlockContents());
+ static::assertContains('data-order-session-id', $this->getBlockContents());
}
/**
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
index 61dc67b7f7808..de0ddc7c1f03f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -106,8 +106,8 @@ public function testCreateCaseBuilderWithFullSetOfData()
'itemWeight' => $product->getWeight()
],
1 => [
- 'itemId' => 'simple2',
- 'itemName' => 'Simple product',
+ 'itemId' => $orderItems[1]->getSku(),
+ 'itemName' => $orderItems[1]->getName(),
'itemPrice' => $orderItems[1]->getPrice(),
'itemQuantity' => $orderItems[1]->getQtyOrdered(),
'itemUrl' => $product->getProductUrl(),
From bfc5f475dc8fec24f9dcc331fd3249861009fbe9 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 08:49:26 -0600
Subject: [PATCH 058/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- replace orderId with orderIncrementId
- fixes for integration tests
- db schema update
---
.../Signifyd/Api/Data/CaseInterface.php | 15 +++++++++++++++
.../Magento/Signifyd/Model/CaseEntity.php | 19 ++++++++++++++++++-
.../Request/PurchaseBuilder.php | 2 +-
.../Magento/Signifyd/Setup/InstallSchema.php | 1 +
.../Request/CreateCaseBuilderTest.php | 4 ++--
.../Magento/Signifyd/_files/case.php | 9 ++++++++-
6 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index 6a58effa19e4f..cd1122e276c87 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -146,6 +146,21 @@ public function getOrderId();
*/
public function setOrderId($orderId);
+ /**
+ * Returns order increment id for a case.
+ *
+ * @return string
+ */
+ public function getOrderIncrementId();
+
+ /**
+ * Sets order increment id for a case.
+ *
+ * @param string $orderIncrementId
+ * @return $this
+ */
+ public function setOrderIncrementId($orderIncrementId);
+
/**
* Returns data about a team associated with a case.
*
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index 8502ac5a51b95..efccab18da65b 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -153,13 +153,30 @@ public function setOrderId($orderId)
return $this;
}
+ /**
+ * @inheritdoc
+ */
+ public function getOrderIncrementId()
+ {
+ return (string) $this->getData('order_increment_id');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setOrderIncrementId($orderIncrementId)
+ {
+ $this->setData('order_increment_id', (string) $orderIncrementId);
+ return $this;
+ }
+
/**
* @inheritdoc
*/
public function getAssociatedTeam()
{
$teamData = $this->getData('associated_team');
- return empty($teamData) ? array() : $this->serializer->unserialize($teamData);
+ return empty($teamData) ? [] : $this->serializer->unserialize($teamData);
}
/**
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 6f39369bc6752..81d601898373d 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -64,7 +64,7 @@ public function build(Order $order)
'purchase' => [
'orderSessionId' => $this->signifydOrderSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
- 'orderId' => $order->getEntityId(),
+ 'orderId' => $order->getIncrementId(),
'createdAt' => $createdAt->format(\DateTime::ATOM),
'paymentGateway' => $this->getPaymentGateway($orderPayment->getMethod()),
'transactionId' => $orderPayment->getLastTransId(),
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index deb313c66a828..61e26eb3bb46a 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -38,6 +38,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true]
);
$table->addColumn('order_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
+ $table->addColumn('order_increment_id', Table::TYPE_TEXT, 32);
$table->addColumn('case_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('guarantee_eligible', Table::TYPE_BOOLEAN, null);
$table->addColumn('guarantee_disposition', Table::TYPE_TEXT, 32);
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
index de0ddc7c1f03f..d37d6fd6f8a7f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -82,7 +82,7 @@ public function testCreateCaseBuilderWithFullSetOfData()
'purchase' => [
'orderSessionId' => $signifydOrderSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
- 'orderId' => $order->getEntityId(),
+ 'orderId' => $order->getIncrementId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
'paymentGateway' => 'paypal_account',
'transactionId' => $payment->getLastTransId(),
@@ -193,7 +193,7 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
'purchase' => [
'orderSessionId' => $quoteSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
- 'orderId' => $order->getEntityId(),
+ 'orderId' => $order->getIncrementId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
'paymentGateway' => $payment->getMethod(),
'transactionId' => $payment->getLastTransId(),
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
index de635ba750399..09f81b14725d1 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -12,6 +12,13 @@
/** @var CaseInterfaceFactory $caseFactory */
$caseFactory = $objectManager->get(CaseInterfaceFactory::class);
+$associatedTeam = array(
+ 'teamName' => 'Some Team',
+ 'teamId' => 123,
+ 'getAutoDismiss' => true,
+ 'getTeamDismissalDays' => 3
+);
+
/** @var CaseInterface $case */
$case = $caseFactory->create();
$case->setCaseId(123)
@@ -20,7 +27,7 @@
->setStatus(CaseInterface::STATUS_PROCESSING)
->setScore(553)
->setOrderId($order->getEntityId())
- ->setAssociatedTeam(124)
+ ->setAssociatedTeam($associatedTeam)
->setReviewDisposition(CaseInterface::DISPOSITION_GOOD)
->setCreatedAt('2016-12-12T15:17:17+0000')
->setUpdatedAt('2016-12-12T19:23:16+0000');
From d7398bb7d160d8cbb31d1aa2d610723258998550 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 09:46:08 -0600
Subject: [PATCH 059/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- fixes for static tests
---
app/code/Magento/Signifyd/Observer/PlaceOrder.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index ef037ca7cd8e4..f5468d1aef667 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -81,8 +81,10 @@ public function execute(Observer $observer)
* Creates signifyd case for single order
*
* @param OrderInterface $order
+ * @return void
*/
- private function createCaseForOrder($order) {
+ private function createCaseForOrder($order)
+ {
$orderId = $order->getEntityId();
if (null !== $orderId) {
return;
From 54e6652ec01c007adf5424b8d011a5a8f6487e5e Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 09:19:27 -0600
Subject: [PATCH 060/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Move customer orders total processing logic from UserAccountBuilder to CustomerOrders model
---
.../Request/CustomerOrders.php | 109 ++++++-
.../Request/UserAccountBuilder.php | 87 +-----
.../Request/CustomerOrdersTest.php | 269 ++++++++++++++++++
.../Request/UserAccountBuilderTest.php | 247 ----------------
4 files changed, 386 insertions(+), 326 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
index 5fed6ebc99ab7..64d538e4c7cdb 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
@@ -5,13 +5,14 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway\Request;
+use Magento\Directory\Model\CurrencyFactory;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
/**
- * Collects customer orders
+ * Provides information about customer orders.
*/
class CustomerOrders
{
@@ -30,6 +31,26 @@ class CustomerOrders
*/
private $orderRepository;
+ /**
+ * @var \Psr\Log\LoggerInterface
+ */
+ private $logger;
+
+ /**
+ * @var CurrencyFactory
+ */
+ private $currencyFactory;
+
+ /**
+ * @var array
+ */
+ private $currencies = [];
+
+ /**
+ * @var string
+ */
+ private static $usdCurrencyCode = 'USD';
+
/**
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param FilterBuilder $filterBuilder
@@ -38,21 +59,64 @@ class CustomerOrders
public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
FilterBuilder $filterBuilder,
- OrderRepositoryInterface $orderRepository
+ OrderRepositoryInterface $orderRepository,
+ CurrencyFactory $currencyFactory,
+ \Psr\Log\LoggerInterface $logger
) {
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->filterBuilder = $filterBuilder;
$this->orderRepository = $orderRepository;
+ $this->logger = $logger;
+ $this->currencyFactory = $currencyFactory;
}
/**
- * Returns customer orders
+ * 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 getCountAndTotalAmount($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 $customerId
* @return \Magento\Sales\Api\Data\OrderInterface[]
*/
- public function get($customerId)
+ private function getCustomerOrders($customerId)
{
$filters = [
$this->filterBuilder->setField(OrderInterface::CUSTOMER_ID)->setValue($customerId)->create()
@@ -63,4 +127,41 @@ public function get($customerId)
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 \Magento\Directory\Model\Currency
+ */
+ private function getCurrencyByCode($currencyCode)
+ {
+ if (isset($this->currencies[$currencyCode])) {
+ return $this->currencies[$currencyCode];
+ }
+
+ /** @var \Magento\Directory\Model\Currency $currency */
+ $currency = $this->currencyFactory->create();
+ $this->currencies[$currencyCode] = $currency->load($currencyCode);
+
+ return $this->currencies[$currencyCode];
+ }
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
index 7133942741360..ac9bff2a14171 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
@@ -8,7 +8,7 @@
use Magento\Sales\Model\Order;
/**
- * Prepare details based on registered user account info
+ * Prepares details based on registered user account info
*/
class UserAccountBuilder
{
@@ -22,49 +22,23 @@ class UserAccountBuilder
*/
private $dateTimeFactory;
- /**
- * @var \Psr\Log\LoggerInterface
- */
- private $logger;
-
- /**
- * @var \Magento\Directory\Model\CurrencyFactory
- */
- private $currencyFactory;
-
- /**
- * @var array
- */
- private $currencies = [];
-
/**
* @var CustomerOrders
*/
private $customerOrders;
- /**
- * @var string
- */
- private static $usdCurrencyCode = 'USD';
-
/**
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
* @param CustomerOrders $customerOrders
- * @param \Psr\Log\LoggerInterface $logger
- * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
* @param \Magento\Framework\Intl\DateTimeFactory $dateTimeFactory
*/
public function __construct(
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
CustomerOrders $customerOrders,
- \Magento\Framework\Intl\DateTimeFactory $dateTimeFactory,
- \Psr\Log\LoggerInterface $logger,
- \Magento\Directory\Model\CurrencyFactory $currencyFactory
+ \Magento\Framework\Intl\DateTimeFactory $dateTimeFactory
) {
$this->customerRepository = $customerRepository;
$this->dateTimeFactory = $dateTimeFactory;
- $this->logger = $logger;
- $this->currencyFactory = $currencyFactory;
$this->customerOrders = $customerOrders;
}
@@ -96,65 +70,28 @@ public function build(Order $order)
]
];
- $customerOrders = $this->customerOrders->get($customerId);
- if (!empty($customerOrders)) {
- try {
- $orderTotalDollars = 0.0;
- foreach ($customerOrders as $order) {
- $orderTotalDollars += $this->getUsdOrderTotal(
- $order->getBaseGrandTotal(),
- $order->getBaseCurrencyCode()
- );
- }
- $result['userAccount']['aggregateOrderCount'] = count($customerOrders);
- $result['userAccount']['aggregateOrderDollars'] = $orderTotalDollars;
- } catch (\Exception $e) {
- $this->logger->error($e->getMessage());
- }
+ $ordersInfo = $this->customerOrders->getCountAndTotalAmount($customerId);
+ if ($this->isNotEmptyCustomerOrdersInfo($ordersInfo)) {
+ $result['userAccount']['aggregateOrderCount'] = $ordersInfo['aggregateOrderCount'];
+ $result['userAccount']['aggregateOrderDollars'] = $ordersInfo['aggregateOrderDollars'];
}
return $result;
}
/**
- * Returns amount in USD
+ * Checks if customer aggregated orders count and total amount are available.
*
- * @param float $amount
- * @param string $currency
- * @return float
+ * @param array $ordersInfo
+ * @return bool
*/
- private function getUsdOrderTotal($amount, $currency)
+ private function isNotEmptyCustomerOrdersInfo(array $ordersInfo)
{
- 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 \Magento\Directory\Model\Currency
- */
- private function getCurrencyByCode($currencyCode)
- {
- if (isset($this->currencies[$currencyCode])) {
- return $this->currencies[$currencyCode];
- }
-
- /** @var \Magento\Directory\Model\Currency $currency */
- $currency = $this->currencyFactory->create();
- $this->currencies[$currencyCode] = $currency->load($currencyCode);
-
- return $this->currencies[$currencyCode];
+ return null !== $ordersInfo['aggregateOrderCount'] && null !== $ordersInfo['aggregateOrderDollars'];
}
/**
- * Returns date formatted according to ISO8601
+ * Returns date formatted according to ISO8601.
*
* @param string $date
* @return string
diff --git a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
new file mode 100644
index 0000000000000..1e6d792d962f7
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
@@ -0,0 +1,269 @@
+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\SignifydGateway\Request\CustomerOrders::getCountAndTotalAmount()
+ */
+ 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->getCountAndTotalAmount(1);
+
+ 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\SignifydGateway\Request\CustomerOrders::getCountAndTotalAmount()
+ */
+ 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->getCountAndTotalAmount(1);
+
+ $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/SignifydGateway/Request/UserAccountBuilderTest.php b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
deleted file mode 100644
index a5d6ea624c1a6..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
+++ /dev/null
@@ -1,247 +0,0 @@
-objectManager = new ObjectManager($this);
-
- $this->customerOrdersService = $this->getMockBuilder(CustomerOrders::class)
- ->disableOriginalConstructor()
- ->setMethods(['get'])
- ->getMock();
-
- $this->customerRepository = $this->getMockBuilder(CustomerRepositoryInterface::class)
- ->setMethods(['getById'])
- ->getMockForAbstractClass();
-
- $dateTimeFactory = new DateTimeFactory();
-
- $this->builder = $this->objectManager->getObject(UserAccountBuilder::class, [
- 'customerRepository' => $this->customerRepository,
- 'dateTimeFactory' => $dateTimeFactory,
- 'customerOrders' => $this->customerOrdersService
- ]);
-
- $this->initCurrencies();
-
- $this->objectManager->setBackwardCompatibleProperty(
- $this->builder,
- 'currencies',
- ['EUR' => $this->eurCurrency, 'UAH' => $this->uahCurrency]
- );
- }
-
- /**
- * @covers \Magento\Signifyd\Model\SignifydGateway\Request\UserAccountBuilder::build
- */
- public function testBuild()
- {
- $order = $this->getOrder();
-
- $customer = $this->getMockBuilder(CustomerInterface::class)
- ->setMethods(['getEmail', 'getCreatedAt', 'getUpdatedAt'])
- ->getMockForAbstractClass();
- $customer->expects(static::exactly(2))
- ->method('getEmail')
- ->willReturn('jonh.doe@testmage.com');
- $customer->expects(static::once())
- ->method('getCreatedAt')
- ->willReturn('2016-10-12 12:23:12');
- $customer->expects(static::once())
- ->method('getUpdatedAt')
- ->willReturn('2016-12-14 18:19:00');
-
- $this->customerRepository->expects(static::once())
- ->method('getById')
- ->with(self::$customerId)
- ->willReturn($customer);
-
- $orders = $this->getOrders();
- $this->customerOrdersService->expects(static::once())
- ->method('get')
- ->with(self::$customerId)
- ->willReturn($orders);
-
- $this->eurCurrency->expects(static::once())
- ->method('convert')
- ->with(self::$eurAmount, 'USD')
- ->willReturn(109);
-
- $this->uahCurrency->expects(static::once())
- ->method('convert')
- ->with(self::$uahAmount, 'USD')
- ->willReturn(10.35);
-
- $actual = $this->builder->build($order);
-
- static::assertEquals(3, $actual['userAccount']['aggregateOrderCount']);
- static::assertEquals(169.35, $actual['userAccount']['aggregateOrderDollars']);
- }
-
- /**
- * 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();
- }
-
- /**
- * Creates order mock
- * @return Order|MockObject
- */
- private function getOrder()
- {
- $order = $this->getMockBuilder(Order::class)
- ->disableOriginalConstructor()
- ->setMethods(['getBillingAddress', 'getCustomerId'])
- ->getMock();
-
- $order->expects(static::once())
- ->method('getCustomerId')
- ->willReturn(self::$customerId);
-
- $billingAddress = $this->getMockBuilder(OrderAddressInterface::class)
- ->setMethods(['getTelephone'])
- ->getMockForAbstractClass();
- $billingAddress->expects(static::once())
- ->method('getTelephone')
- ->willReturn('444-444-44');
-
- $order->expects(static::once())
- ->method('getBillingAddress')
- ->willReturn($billingAddress);
-
- return $order;
- }
-
- /**
- * 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(static::once())
- ->method('getBaseGrandTotal')
- ->willReturn(self::$eurAmount);
- $eurOrder->expects(static::once())
- ->method('getBaseCurrencyCode')
- ->willReturn('EUR');
-
- $uahOrder = $this->getMockBuilder(Order::class)
- ->disableOriginalConstructor()
- ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode'])
- ->getMock();
-
- $uahOrder->expects(static::once())
- ->method('getBaseGrandTotal')
- ->willReturn(self::$uahAmount);
- $uahOrder->expects(static::once())
- ->method('getBaseCurrencyCode')
- ->willReturn('UAH');
-
- $usdOrder = $this->getMockBuilder(Order::class)
- ->disableOriginalConstructor()
- ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode'])
- ->getMock();
-
- $usdOrder->expects(static::once())
- ->method('getBaseGrandTotal')
- ->willReturn(self::$usdAmount);
- $usdOrder->expects(static::once())
- ->method('getBaseCurrencyCode')
- ->willReturn('USD');
-
- return [$eurOrder, $uahOrder, $usdOrder];
- }
-}
From b5977eba43fdb419610bf1605ac768915a4d95bf Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 09:22:56 -0600
Subject: [PATCH 061/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Remove empty lines
---
.../Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
index 1e6d792d962f7..db89c9748bcc4 100644
--- a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
@@ -112,8 +112,6 @@ protected function setUp()
'logger' => $this->logger
]);
-
-
$this->initCurrencies();
$this->initOrderRepository();
From ffa18a7745b3f4e1d19fb524259c7559fe2f1f70 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 10:05:10 -0600
Subject: [PATCH 062/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- fixes for static tests
---
.../Signifyd/Model/SignifydGateway/Request/CustomerOrders.php | 2 ++
.../integration/testsuite/Magento/Signifyd/_files/case.php | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
index 64d538e4c7cdb..e757e16d4ae3f 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
@@ -55,6 +55,8 @@ class CustomerOrders
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param FilterBuilder $filterBuilder
* @param OrderRepositoryInterface $orderRepository
+ * @param CurrencyFactory $currencyFactory
+ * @param \Psr\Log\LoggerInterface $logger
*/
public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
index 09f81b14725d1..0bd47cb790d9e 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -12,12 +12,12 @@
/** @var CaseInterfaceFactory $caseFactory */
$caseFactory = $objectManager->get(CaseInterfaceFactory::class);
-$associatedTeam = array(
+$associatedTeam = [
'teamName' => 'Some Team',
'teamId' => 123,
'getAutoDismiss' => true,
'getTeamDismissalDays' => 3
-);
+];
/** @var CaseInterface $case */
$case = $caseFactory->create();
From 9eb9ef937be60d3324ae0c0cc1f6320fdadcc50c Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 10:02:23 -0600
Subject: [PATCH 063/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Change CustomOrders namespace
---
.../Request => }/CustomerOrders.php | 16 +++++++++-------
.../Request/UserAccountBuilder.php | 3 ++-
.../Request => Model}/CustomerOrdersTest.php | 12 ++++++------
3 files changed, 17 insertions(+), 14 deletions(-)
rename app/code/Magento/Signifyd/Model/{SignifydGateway/Request => }/CustomerOrders.php (94%)
rename app/code/Magento/Signifyd/Test/Unit/{SignifydGateway/Request => Model}/CustomerOrdersTest.php (94%)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php b/app/code/Magento/Signifyd/Model/CustomerOrders.php
similarity index 94%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
rename to app/code/Magento/Signifyd/Model/CustomerOrders.php
index e757e16d4ae3f..bcfea4403c930 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/CustomerOrders.php
@@ -3,16 +3,19 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\SignifydGateway\Request;
+namespace Magento\Signifyd\Model;
use Magento\Directory\Model\CurrencyFactory;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
+use Psr\Log\LoggerInterface;
/**
* Provides information about customer orders.
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CustomerOrders
{
@@ -32,7 +35,7 @@ class CustomerOrders
private $orderRepository;
/**
- * @var \Psr\Log\LoggerInterface
+ * @var LoggerInterface
*/
private $logger;
@@ -56,21 +59,20 @@ class CustomerOrders
* @param FilterBuilder $filterBuilder
* @param OrderRepositoryInterface $orderRepository
* @param CurrencyFactory $currencyFactory
- * @param \Psr\Log\LoggerInterface $logger
+ * @param LoggerInterface $logger
*/
public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
FilterBuilder $filterBuilder,
OrderRepositoryInterface $orderRepository,
CurrencyFactory $currencyFactory,
- \Psr\Log\LoggerInterface $logger
+ LoggerInterface $logger
) {
-
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->filterBuilder = $filterBuilder;
$this->orderRepository = $orderRepository;
- $this->logger = $logger;
$this->currencyFactory = $currencyFactory;
+ $this->logger = $logger;
}
/**
@@ -83,7 +85,7 @@ public function __construct(
* @param int $customerId
* @return array
*/
- public function getCountAndTotalAmount($customerId)
+ public function getAggregatedOrdersInfo($customerId)
{
$result = [
'aggregateOrderCount' => null,
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
index ac9bff2a14171..5e02f108714c7 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
@@ -6,6 +6,7 @@
namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Sales\Model\Order;
+use Magento\Signifyd\Model\CustomerOrders;
/**
* Prepares details based on registered user account info
@@ -70,7 +71,7 @@ public function build(Order $order)
]
];
- $ordersInfo = $this->customerOrders->getCountAndTotalAmount($customerId);
+ $ordersInfo = $this->customerOrders->getAggregatedOrdersInfo($customerId);
if ($this->isNotEmptyCustomerOrdersInfo($ordersInfo)) {
$result['userAccount']['aggregateOrderCount'] = $ordersInfo['aggregateOrderCount'];
$result['userAccount']['aggregateOrderDollars'] = $ordersInfo['aggregateOrderDollars'];
diff --git a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
similarity index 94%
rename from app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
rename to app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
index db89c9748bcc4..8798431f46873 100644
--- a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Unit\SignifydGateway\Request;
+namespace Magento\Signifyd\Test\Unit\Model;
use Magento\Directory\Model\Currency;
use Magento\Framework\Api\FilterBuilder;
@@ -11,7 +11,7 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Sales\Api\Data\OrderSearchResultInterface;
use Magento\Sales\Model\Order;
-use Magento\Signifyd\Model\SignifydGateway\Request\CustomerOrders;
+use Magento\Signifyd\Model\CustomerOrders;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Magento\Sales\Api\OrderRepositoryInterface;
use Psr\Log\LoggerInterface;
@@ -123,7 +123,7 @@ protected function setUp()
}
/**
- * @covers \Magento\Signifyd\Model\SignifydGateway\Request\CustomerOrders::getCountAndTotalAmount()
+ * @covers \Magento\Signifyd\Model\CustomerOrders::getCountAndTotalAmount()
*/
public function testGetCountAndTotalAmount()
{
@@ -137,7 +137,7 @@ public function testGetCountAndTotalAmount()
->with(self::$uahAmount, 'USD')
->willReturn(10.35);
- $actual = $this->model->getCountAndTotalAmount(1);
+ $actual = $this->model->getAggregatedOrdersInfo(self::$customerId);
static::assertEquals(3, $actual['aggregateOrderCount']);
static::assertEquals(169.35, $actual['aggregateOrderDollars']);
@@ -145,7 +145,7 @@ public function testGetCountAndTotalAmount()
/**
* Test case when required currency rate is absent and exception is thrown
- * @covers \Magento\Signifyd\Model\SignifydGateway\Request\CustomerOrders::getCountAndTotalAmount()
+ * @covers \Magento\Signifyd\Model\CustomerOrders::getCountAndTotalAmount()
*/
public function testGetCountAndTotalAmountNegative()
{
@@ -162,7 +162,7 @@ public function testGetCountAndTotalAmountNegative()
$this->logger->expects($this->once())
->method('error');
- $actual = $this->model->getCountAndTotalAmount(1);
+ $actual = $this->model->getAggregatedOrdersInfo(self::$customerId);
$this->assertNull($actual['aggregateOrderCount']);
$this->assertNull($actual['aggregateOrderDollars']);
From 267473ab32cb27087a9bf220696ca29932607e5e Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 10:19:58 -0600
Subject: [PATCH 064/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Import all class names in CustomerOrders
---
app/code/Magento/Signifyd/Model/CustomerOrders.php | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/CustomerOrders.php b/app/code/Magento/Signifyd/Model/CustomerOrders.php
index bcfea4403c930..2865e60ae3801 100644
--- a/app/code/Magento/Signifyd/Model/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/CustomerOrders.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Signifyd\Model;
+use Exception;
+use Magento\Directory\Model\Currency;
use Magento\Directory\Model\CurrencyFactory;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -106,7 +108,7 @@ public function getAggregatedOrdersInfo($customerId)
'aggregateOrderCount' => count($customerOrders),
'aggregateOrderDollars' => $orderTotalDollars
];
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->logger->error($e->getMessage());
}
}
@@ -118,7 +120,7 @@ public function getAggregatedOrdersInfo($customerId)
* Returns customer orders.
*
* @param $customerId
- * @return \Magento\Sales\Api\Data\OrderInterface[]
+ * @return OrderInterface[]
*/
private function getCustomerOrders($customerId)
{
@@ -154,7 +156,7 @@ private function getUsdOrderTotal($amount, $currency)
* Returns currency by currency code.
*
* @param string|null $currencyCode
- * @return \Magento\Directory\Model\Currency
+ * @return Currency
*/
private function getCurrencyByCode($currencyCode)
{
@@ -162,7 +164,7 @@ private function getCurrencyByCode($currencyCode)
return $this->currencies[$currencyCode];
}
- /** @var \Magento\Directory\Model\Currency $currency */
+ /** @var Currency $currency */
$currency = $this->currencyFactory->create();
$this->currencies[$currencyCode] = $currency->load($currencyCode);
From c20914e5ddd7e2aaa060b7f2dd5bc686c43975ad Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 10:37:24 -0600
Subject: [PATCH 065/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- flow fix
---
app/code/Magento/Signifyd/Observer/PlaceOrder.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index f5468d1aef667..5f3d858e5cfec 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -86,7 +86,7 @@ public function execute(Observer $observer)
private function createCaseForOrder($order)
{
$orderId = $order->getEntityId();
- if (null !== $orderId) {
+ if (null === $orderId) {
return;
}
From 97ff576257f753bd3615bb61aeb12f22f3f92e39 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 10:56:45 -0600
Subject: [PATCH 066/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Refactor UserAccountBuilder
---
.../Request/UserAccountBuilder.php | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
index 5e02f108714c7..60806e0ee05da 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
@@ -72,25 +72,16 @@ public function build(Order $order)
];
$ordersInfo = $this->customerOrders->getAggregatedOrdersInfo($customerId);
- if ($this->isNotEmptyCustomerOrdersInfo($ordersInfo)) {
+ if (isset($ordersInfo['aggregateOrderCount'])) {
$result['userAccount']['aggregateOrderCount'] = $ordersInfo['aggregateOrderCount'];
+ }
+ if (isset($ordersInfo['aggregateOrderDollars'])) {
$result['userAccount']['aggregateOrderDollars'] = $ordersInfo['aggregateOrderDollars'];
}
return $result;
}
- /**
- * Checks if customer aggregated orders count and total amount are available.
- *
- * @param array $ordersInfo
- * @return bool
- */
- private function isNotEmptyCustomerOrdersInfo(array $ordersInfo)
- {
- return null !== $ordersInfo['aggregateOrderCount'] && null !== $ordersInfo['aggregateOrderDollars'];
- }
-
/**
* Returns date formatted according to ISO8601.
*
From 4e5650b3d42526bed907c35134b67936b7c1ae89 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 10:51:27 -0600
Subject: [PATCH 067/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- fixes according to review comments
---
.../Model/SignifydGateway/Request/CreateCaseBuilder.php | 8 ++++----
.../Request/CreateCaseBuilderInterface.php | 4 +---
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
index 1e2f35f7838bc..06f3a601889c9 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
@@ -8,9 +8,9 @@
use Magento\Sales\Model\OrderFactory;
/**
- * Signifyd case creation request builder
+ * Signifyd case creation request builder.
*
- * Handles the conversion from Magento Order to Signifyd Case
+ * Handles the conversion from Magento Order to Signifyd Case.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CreateCaseBuilder implements CreateCaseBuilderInterface
@@ -98,7 +98,7 @@ public function build($orderId)
}
/**
- * Remove empty and null values
+ * Remove empty and null values.
*
* @param array $data
* @return array
@@ -119,7 +119,7 @@ private function removeEmptyValues($data)
}
/**
- * Empty values are null, empty string and empty array
+ * Empty values are null, empty string and empty array.
*
* @param mixed $value
* @return bool
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
index aa5e4ce48485b..13d119d7fe441 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
@@ -5,10 +5,8 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway\Request;
-
-
/**
- * Collects information about order and build array with parameters required by Signifyd API.
+ * Collects information about order and build array with parameters required by Signifyd API
*
* @see https://www.signifyd.com/docs/api/#/reference/cases/create-a-case
*/
From fcd12408abd490f435becbce2ac97f2b02f84281 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 11:31:15 -0600
Subject: [PATCH 068/225] MAGETWO-62506: Stabilization
- Fix static tests
---
.../Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
index 8798431f46873..5e03d8806f5af 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
@@ -123,7 +123,7 @@ protected function setUp()
}
/**
- * @covers \Magento\Signifyd\Model\CustomerOrders::getCountAndTotalAmount()
+ * @covers \Magento\Signifyd\Model\CustomerOrders::getAggregatedOrdersInfo()
*/
public function testGetCountAndTotalAmount()
{
@@ -145,7 +145,7 @@ public function testGetCountAndTotalAmount()
/**
* Test case when required currency rate is absent and exception is thrown
- * @covers \Magento\Signifyd\Model\CustomerOrders::getCountAndTotalAmount()
+ * @covers \Magento\Signifyd\Model\CustomerOrders::getAggregatedOrdersInfo()
*/
public function testGetCountAndTotalAmountNegative()
{
From 38a479aac0dd831f40805a64113062de12286da7 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 22 Dec 2016 02:22:52 -0600
Subject: [PATCH 069/225] MAGETWO-62506: Stabilization
- Fix static tests
---
app/code/Magento/Signifyd/Model/CustomerOrders.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/CustomerOrders.php b/app/code/Magento/Signifyd/Model/CustomerOrders.php
index 2865e60ae3801..58f563c56df7c 100644
--- a/app/code/Magento/Signifyd/Model/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/CustomerOrders.php
@@ -119,7 +119,7 @@ public function getAggregatedOrdersInfo($customerId)
/**
* Returns customer orders.
*
- * @param $customerId
+ * @param int $customerId
* @return OrderInterface[]
*/
private function getCustomerOrders($customerId)
From e22aba50ffacd395bdfdf793c0ae22244048ba5e Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 11:34:43 -0600
Subject: [PATCH 070/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- remove orderIncrementId
---
.../Magento/Signifyd/Api/Data/CaseInterface.php | 15 ---------------
app/code/Magento/Signifyd/Model/CaseEntity.php | 17 -----------------
.../Magento/Signifyd/Setup/InstallSchema.php | 1 -
3 files changed, 33 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index cd1122e276c87..6a58effa19e4f 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -146,21 +146,6 @@ public function getOrderId();
*/
public function setOrderId($orderId);
- /**
- * Returns order increment id for a case.
- *
- * @return string
- */
- public function getOrderIncrementId();
-
- /**
- * Sets order increment id for a case.
- *
- * @param string $orderIncrementId
- * @return $this
- */
- public function setOrderIncrementId($orderIncrementId);
-
/**
* Returns data about a team associated with a case.
*
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index efccab18da65b..a59763e091383 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -153,23 +153,6 @@ public function setOrderId($orderId)
return $this;
}
- /**
- * @inheritdoc
- */
- public function getOrderIncrementId()
- {
- return (string) $this->getData('order_increment_id');
- }
-
- /**
- * @inheritdoc
- */
- public function setOrderIncrementId($orderIncrementId)
- {
- $this->setData('order_increment_id', (string) $orderIncrementId);
- return $this;
- }
-
/**
* @inheritdoc
*/
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index 61e26eb3bb46a..deb313c66a828 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -38,7 +38,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true]
);
$table->addColumn('order_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
- $table->addColumn('order_increment_id', Table::TYPE_TEXT, 32);
$table->addColumn('case_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('guarantee_eligible', Table::TYPE_BOOLEAN, null);
$table->addColumn('guarantee_disposition', Table::TYPE_TEXT, 32);
From 9ff05cd78584212fd9a5e31f62d5eab1791be578 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Thu, 22 Dec 2016 05:22:03 -0600
Subject: [PATCH 071/225] MAGETWO-62506: Stabilization
- Add device fingerprint script to cart page
---
.../view/frontend/layout/checkout_cart_index.xml | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml
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
new file mode 100644
index 0000000000000..07b04cc41d1bf
--- /dev/null
+++ b/app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
From b1e4f5a344064ee7f0defabc47e0af695fa4fb00 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 23 Dec 2016 07:31:11 -0600
Subject: [PATCH 072/225] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- di refactoring
---
app/code/Magento/Signifyd/etc/adminhtml/di.xml | 6 +-----
app/code/Magento/Signifyd/etc/frontend/di.xml | 6 +-----
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/di.xml b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
index c41b360bb5f78..4c7abb1d830bb 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/di.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
@@ -6,9 +6,5 @@
*/
-->
-
-
- Magento\Signifyd\Model\QuoteSession\Adminhtml\BackendSession
-
-
+
diff --git a/app/code/Magento/Signifyd/etc/frontend/di.xml b/app/code/Magento/Signifyd/etc/frontend/di.xml
index 8da5b4e010161..d0702e9c4c5ce 100644
--- a/app/code/Magento/Signifyd/etc/frontend/di.xml
+++ b/app/code/Magento/Signifyd/etc/frontend/di.xml
@@ -13,9 +13,5 @@
-
-
- Magento\Signifyd\Model\QuoteSession\FrontendSession
-
-
+
From 8f1f4f4f2818b11c0c3f747934a80ffc6d31ea4d Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 29 Dec 2016 06:31:11 -0600
Subject: [PATCH 073/225] MAGETWO-62738:
Magento\Signifyd\Model\CaseCreationServiceTest failed on mainline develop
- fixed issue with BiC in json_decode in PHP7.0
---
.../Signifyd/Model/SignifydGateway/ApiClient.php | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 3b14773b3fd25..19b2b78a932b2 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -173,7 +173,16 @@ private function handleResponse(\Zend_Http_Response $response)
throw new ApiCallException($errorMessage);
}
- $responseBody = $response->getBody();
+ $responseBody = (string)$response->getBody();
+
+ if (PHP_VERSION_ID < 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) {
From f3e6cb2acf7edb1c3fc5bb73a1bc57a65e54f1f8 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 29 Dec 2016 07:17:44 -0600
Subject: [PATCH 074/225] MAGETWO-62738:
Magento\Signifyd\Model\CaseCreationServiceTest failed on mainline develop
- Fixed failed static test
---
.../Magento/Signifyd/Model/SignifydGateway/ApiClient.php | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 19b2b78a932b2..8fc17cf1ac293 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -5,13 +5,12 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway;
-use Magento\Signifyd\Model\Config;
-use Magento\Framework\HTTP\ZendClientFactory;
use Magento\Framework\HTTP\ZendClient;
-use Magento\Framework\Json\EncoderInterface;
+use Magento\Framework\HTTP\ZendClientFactory;
use Magento\Framework\Json\DecoderInterface;
+use Magento\Framework\Json\EncoderInterface;
+use Magento\Signifyd\Model\Config;
use Magento\Signifyd\Model\SignifydGateway\Debugger\DebuggerFactory;
-use Exception;
/**
* Encapsulates Signifyd API protocol.
From d2aa505df50a8f4cc13b0dd468c0e0ccee7971ac Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 29 Dec 2016 07:22:56 -0600
Subject: [PATCH 075/225] MAGETWO-62738:
Magento\Signifyd\Model\CaseCreationServiceTest failed on mainline develop
- Added suppress
---
app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 8fc17cf1ac293..566f08b498105 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -14,6 +14,8 @@
/**
* Encapsulates Signifyd API protocol.
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ApiClient
{
From 2c55b17c24c90f0a0c7a30fe9b143fc4732346bd Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Tue, 3 Jan 2017 08:49:55 -0600
Subject: [PATCH 076/225] MAGETWO-62883: Update copyright year to 2017
- Changed copyright year
---
app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 566f08b498105..48d48ae4f81d4 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -1,6 +1,6 @@
Date: Wed, 4 Jan 2017 06:19:21 -0600
Subject: [PATCH 077/225] MAGETWO-62803: Signifyd webhook controller
- Added webhook controller
- Added webhook message validator
---
.../Signifyd/Controller/Webhooks/Index.php | 91 ++++++++++++++
.../Response/RawRequestBody.php | 22 ++++
.../Response/ResponseValidator.php | 112 ++++++++++++++++++
.../SignifydGateway/Response/Webhook.php | 74 ++++++++++++
.../Response/WebhookException.php | 14 +++
.../Response/WebhookFactory.php | 80 +++++++++++++
.../Magento/Signifyd/etc/frontend/routes.xml | 14 +++
7 files changed, 407 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Controller/Webhooks/Index.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/ResponseValidator.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookFactory.php
create mode 100644 app/code/Magento/Signifyd/etc/frontend/routes.xml
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Index.php b/app/code/Magento/Signifyd/Controller/Webhooks/Index.php
new file mode 100644
index 0000000000000..2385e221038c8
--- /dev/null
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Index.php
@@ -0,0 +1,91 @@
+rawRequestBody = $rawRequestBody;
+ $this->config = $config;
+ $this->logger = $logger;
+ $this->webhookFactory = $webhookFactory;
+ }
+
+ /**
+ * Processes webhook message data and updates case entity
+ *
+ * @return void
+ */
+ public function execute()
+ {
+ if ($this->config->isActive() === false) {
+ return;
+ }
+
+ /** @var \Magento\Framework\App\Request\Http $request */
+ $request = $this->getRequest();
+ $hash = $request->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256');
+ $topic = $request->getHeader('X-SIGNIFYD-TOPIC');
+ $rawResponseBody = $this->rawRequestBody->get();
+
+ try {
+ $webhook = $this->webhookFactory->create($rawResponseBody, $hash, $topic);
+ if ($webhook->isTest()) {
+ return;
+ }
+ } catch (WebhookException $e) {
+ $this->getResponse()->setHttpResponseCode(400);
+ $this->logger->error($e->getMessage());
+ }
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php
new file mode 100644
index 0000000000000..ec77193ba3e5f
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php
@@ -0,0 +1,22 @@
+config = $config;
+ }
+
+ /**
+ * Validates webhook response.
+ *
+ * @param string $rawResponseBody
+ * @param string $hash Base64 encoded output of the HMAC SHA256 encoding of the JSON body of the message.
+ * @param string $topic event topic identifier.
+ * @return bool
+ */
+ public function validate($rawResponseBody, $hash, $topic)
+ {
+ if ($this->isValidTopic($topic) === false) {
+ $this->errorMessages[] = 'Value of X-SIGNIFYD-TOPIC header is not allowed';
+ }
+
+ if (empty($rawResponseBody)) {
+ $this->errorMessages[] = 'Webhook message is empty';
+ }
+
+ if ($this->isValidHmacSha256($rawResponseBody, $hash, $topic) === false) {
+ $this->errorMessages[] = 'X-SIGNIFYD-SEC-HMAC-SHA256 header verification fails';
+ }
+
+ return empty($this->errorMessages);
+
+ }
+
+ /**
+ * Returns error message if validation fails
+ *
+ * @return string
+ */
+ public function getErrorMessage()
+ {
+ return !empty($this->errorMessages) ? implode('; ', $this->errorMessages) : '';
+ }
+
+ /**
+ * 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 message has in fact come from SIGNIFYD.
+ *
+ * @param string $rawResponseBody
+ * @param string $hash X-SIGNIFYD-SEC-HMAC-SHA256 header is included in each webhook POST message.
+ * @param string $topic topic identifier.
+ * @return bool
+ */
+ private function isValidHmacSha256($rawResponseBody, $hash, $topic)
+ {
+ // In the case that this is a webhook test, the encoding ABCDE is allowed
+ $apiKey = $topic == 'cases/test' ? 'ABCDE' : $this->config->getApiKey();
+ $check = base64_encode(hash_hmac('sha256', $rawResponseBody, $apiKey, true));
+
+ return $check === $hash;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
new file mode 100644
index 0000000000000..128daad8e08e4
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
@@ -0,0 +1,74 @@
+body = $body;
+ $this->topic = $topic;
+ }
+
+ /**
+ * Returns webhook body
+ *
+ * @return array
+ */
+ public function getBody()
+ {
+ return $this->body;
+ }
+
+ /**
+ * Returns event topic identifier
+ *
+ * @return string
+ */
+ public function getTopic()
+ {
+ return $this->topic;
+ }
+
+ /**
+ * Checks if webhook is a test
+ *
+ * @return bool
+ */
+ public function isTest()
+ {
+ return $this->topic === 'cases/test';
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php
new file mode 100644
index 0000000000000..8820e1be006dd
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php
@@ -0,0 +1,14 @@
+objectManager = $objectManager;
+ $this->responseValidator = $responseValidator;
+ $this->dataDecoder = $decoder;
+ }
+
+
+ /**
+ * Create webhook data object.
+ *
+ * @param string $rawResponseBody
+ * @param string $hash Base64 encoded output of the HMAC SHA256 encoding of the JSON body of the message.
+ * @param string $topic event topic identifier.
+ * @return Webhook
+ * @throws WebhookException if data validation fails
+ */
+ public function create($rawResponseBody, $hash, $topic)
+ {
+
+ if (!$this->responseValidator->validate($rawResponseBody, $hash, $topic)) {
+ throw new WebhookException(
+ $this->responseValidator->getErrorMessage()
+ );
+ }
+
+ try {
+ $decodedResponseBody = $this->dataDecoder->decode($rawResponseBody);
+ } catch (\Exception $e) {
+ throw new WebhookException(
+ 'Webhook message body is not valid JSON: ' . $e->getMessage(),
+ $e->getCode(),
+ $e
+ );
+ }
+
+ return $this->objectManager->create(
+ Webhook::class,
+ ['topic' => $topic, 'body' => $decodedResponseBody]
+ );
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/frontend/routes.xml b/app/code/Magento/Signifyd/etc/frontend/routes.xml
new file mode 100644
index 0000000000000..c7101ae29f069
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/frontend/routes.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
From 26d89451b4b812174868e4859819efb860c55ee2 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 4 Jan 2017 06:46:38 -0600
Subject: [PATCH 078/225] MAGETWO-62803: Signifyd webhook controller
- Fix static
---
.../Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php | 2 +-
.../Model/SignifydGateway/Response/WebhookException.php | 2 +-
.../Signifyd/Model/SignifydGateway/Response/WebhookFactory.php | 1 -
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
index 128daad8e08e4..db251c83c407c 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
@@ -1,6 +1,6 @@
dataDecoder = $decoder;
}
-
/**
* Create webhook data object.
*
From 589f63e1f99a6c14ef0b936b209ebea4a9619145 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 4 Jan 2017 10:44:01 -0600
Subject: [PATCH 079/225] MAGETWO-62806: Update case entity
- Added messages generators for comments history
- Added service for case updating
- Covered case updating by integration test
---
.../Signifyd/Api/CaseManagementInterface.php | 8 ++
.../Magento/Signifyd/Model/CaseEntity.php | 2 +-
.../Magento/Signifyd/Model/CaseManagement.php | 16 +++
.../Signifyd/Model/CaseUpdatingService.php | 120 ++++++++++++++++++
.../Model/CaseUpdatingServiceFactory.php | 93 ++++++++++++++
.../Model/MessageGeneratorException.php | 16 +++
.../Model/MessageGeneratorInterface.php | 23 ++++
.../Model/MessageGenerators/CaseCreation.php | 44 +++++++
.../Model/MessageGenerators/CaseRescore.php | 62 +++++++++
.../Model/MessageGenerators/CaseReview.php | 31 +++++
.../MessageGenerators/GuaranteeCompletion.php | 28 ++++
.../Model/Validators/CaseDataValidator.php | 29 +++++
app/code/Magento/Signifyd/i18n/en_US.csv | 9 +-
.../Model/CaseUpdatingServiceTest.php | 100 +++++++++++++++
14 files changed, 579 insertions(+), 2 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/CaseUpdatingService.php
create mode 100644 app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGeneratorException.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
create mode 100644 app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index 09c2e8c0e164c..2cf5db226cbff 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -31,4 +31,12 @@ public function create($orderId);
* @return CaseInterface|null
*/
public function getByOrderId($orderId);
+
+ /**
+ * Gets Case entity by received case (investigation) id.
+ *
+ * @param $caseId
+ * @return CaseInterface|null
+ */
+ public function getByCaseId($caseId);
}
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index a59763e091383..00951b6bb55f5 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -23,7 +23,7 @@ class CaseEntity extends AbstractModel implements CaseInterface
/**
* @var SerializerInterface
*/
- protected $serializer;
+ private $serializer;
/**
* @inheritdoc
diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php
index 8705f9a812ae3..0af87b9b89d3f 100644
--- a/app/code/Magento/Signifyd/Model/CaseManagement.php
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -88,4 +88,20 @@ public function getByOrderId($orderId)
$items = $this->caseRepository->getList($searchCriteria)->getItems();
return !empty($items) ? array_pop($items) : null;
}
+
+ /**
+ * @inheritdoc
+ */
+ public function getByCaseId($caseId)
+ {
+ $filters = [
+ $this->filterBuilder->setField('case_id')
+ ->setValue($caseId)
+ ->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/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
new file mode 100644
index 0000000000000..474ade3ce8797
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -0,0 +1,120 @@
+messageGenerator = $messageGenerator;
+ $this->caseManagement = $caseManagement;
+ $this->caseRepository = $caseRepository;
+ $this->historyFactory = $historyFactory;
+ $this->logger = $logger;
+ $this->caseDataValidator = $caseDataValidator;
+ }
+
+ /**
+ * Updates Signifyd Case entity by received data.
+ *
+ * @param DataObject $data
+ * @throws LocalizedException
+ * @throws NotFoundException
+ */
+ public function update(DataObject $data)
+ {
+ if (!$this->caseDataValidator->validate($data)) {
+ throw new LocalizedException(__('The "%1" should not be empty.', 'caseId'));
+ }
+
+ $case = $this->caseManagement->getByCaseId($data->getData('caseId'));
+ if ($case === null) {
+ throw new NotFoundException(__('Case entity not found.'));
+ }
+
+ try {
+ $case->setGuaranteeEligible($data->getData('guaranteeEligible'))
+ ->setStatus($data->getData('status'))
+ ->setReviewDisposition($data->getData('reviewDisposition'))
+ ->setAssociatedTeam($data->getData('associatedTeam'))
+ ->setCreatedAt($data->getData('createdAt'))
+ ->setUpdatedAt($data->getData('updatedAt'))
+ ->setScore($data->getData('score'))
+ ->setGuaranteeDisposition($data->getData('guaranteeDisposition'));
+ $this->caseRepository->save($case);
+
+ // add comment to order history
+ $message = $this->messageGenerator->generate($data);
+ /** @var \Magento\Sales\Api\Data\OrderStatusHistoryInterface $history */
+ $history = $this->historyFactory->create();
+ $history->setParentId($case->getOrderId())
+ ->setComment($message)
+ ->save();
+
+ } catch (\Exception $e) {
+ $this->logger->error($e->getMessage());
+ throw new LocalizedException(__('Cannot update Case entity.'), $e);
+ }
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
new file mode 100644
index 0000000000000..c2bb54a4dc95d
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
@@ -0,0 +1,93 @@
+objectManager = $objectManager;
+ }
+
+ /**
+ * Creates instance of service updating case.
+ * As param retrieves type of message generator.
+ *
+ * @param string $type
+ * @return CaseUpdatingService
+ */
+ public function create($type)
+ {
+ switch ($type) {
+ case self::$caseCreation:
+ $className = CaseCreation::class;
+ break;
+ case self::$caseRescore:
+ $className = CaseRescore::class;
+ break;
+ case self::$caseReview:
+ $className = CaseReview::class;
+ break;
+ case self::$guaranteeCompletion:
+ $className = GuaranteeCompletion::class;
+ break;
+ default:
+ throw new \InvalidArgumentException('Specified message type does not supported.');
+ }
+
+ $messageGenerator = $this->objectManager->get($className);
+ $service = $this->objectManager->create(CaseUpdatingService::class, [
+ 'messageGenerator' => $messageGenerator
+ ]);
+
+ return $service;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGeneratorException.php b/app/code/Magento/Signifyd/Model/MessageGeneratorException.php
new file mode 100644
index 0000000000000..3958595bc1f45
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGeneratorException.php
@@ -0,0 +1,16 @@
+caseDataValidator = $caseDataValidator;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function generate(DataObject $data)
+ {
+ if (!$this->caseDataValidator->validate($data)) {
+ throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
+ }
+
+ return __('Signifyd Case %1 has been created for order.', $data->getData('caseId'));
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
new file mode 100644
index 0000000000000..81765a66e278b
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -0,0 +1,62 @@
+caseManagement = $caseManagement;
+ $this->caseDataValidator = $caseDataValidator;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function generate(DataObject $data)
+ {
+ if (!$this->caseDataValidator->validate($data)) {
+ throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
+ }
+
+ $caseEntity = $this->caseManagement->getByCaseId($data->getData('caseId'));
+
+ if ($caseEntity === null) {
+ throw new MessageGeneratorException(__('Case entity not found.'));
+ }
+
+ return __(
+ 'Case Update: New score for the order is %1. Previous score was %2.',
+ $data->getData('score'),
+ $caseEntity->getScore()
+ );
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
new file mode 100644
index 0000000000000..06cedd4ad42fb
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
@@ -0,0 +1,31 @@
+getData('reviewDisposition'))) {
+ throw new MessageGeneratorException(__('The "%1" should not be empty.', 'reviewDisposition'));
+ }
+
+ return __(
+ 'Case Update: Case Review was completed. Review Deposition is %1.',
+ __($data->getData('reviewDisposition'))
+ );
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
new file mode 100644
index 0000000000000..051a48f68c7bb
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
@@ -0,0 +1,28 @@
+getData('guaranteeDisposition'))) {
+ throw new MessageGeneratorException(__('The "%1" should not be empty.', 'guaranteeDisposition'));
+ }
+
+ return __('Case Update: Guarantee Disposition is %1.', __($data->getData('guaranteeDisposition')));
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php b/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
new file mode 100644
index 0000000000000..1b44d26ec5f23
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
@@ -0,0 +1,29 @@
+getData('caseId'))) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index 2785e217040ca..a10f12073987f 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -6,8 +6,15 @@
"GOOD","Good"
"FRAUDULENT","Fraudulent"
"UNSET","Unset"
+"NULL","Unset"
"APPROVED","Approved"
"DECLINED","Declined"
"PENDING","Pending"
"CANCELED","Canceled"
-"IN_REVIEW","In review"
\ No newline at end of file
+"IN_REVIEW","In review"
+"Case Update: Case Review was completed. Review Deposition is %1.","Case Update: Case Review was completed. Review Deposition is %1."
+"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."
+"Signifyd Case %1 has been created for order.","Signifyd Case %1 has been created for order."
+"The "%1" should not be empty.","The "%1" should not be empty."
+"Case entity not found.","Case entity not found."
+"Cannot update Case entity.","Cannot update Case entity."
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
new file mode 100644
index 0000000000000..750178e718e76
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
@@ -0,0 +1,100 @@
+objectManager = Bootstrap::getObjectManager();
+
+ $messageGenerator = $this->objectManager->create(CaseCreation::class);
+
+ $logger = $this->getMockBuilder(LoggerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->service = $this->objectManager->create(CaseUpdatingService::class, [
+ 'messageGenerator' => $messageGenerator,
+ 'logger' => $logger
+ ]);
+ }
+
+ /**
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ */
+ public function testUpdate()
+ {
+ $caseId = 123;
+ $data = new DataObject(
+ [
+ 'caseId' => $caseId,
+ 'guaranteeEligible' => true,
+ 'status' => CaseInterface::STATUS_DISMISSED,
+ 'score' => 750,
+ '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
+ ]
+ );
+
+ $this->service->update($data);
+
+ /** @var CaseManagementInterface $caseManagement */
+ $caseManagement = $this->objectManager->get(CaseManagementInterface::class);
+ $caseEntity = $caseManagement->getByCaseId($caseId);
+
+ static::assertNotEmpty($caseEntity);
+ static::assertEquals('2017-01-05 22:23:26', $caseEntity->getCreatedAt());
+ static::assertEquals(CaseInterface::GUARANTEE_APPROVED, $caseEntity->getGuaranteeDisposition());
+ static::assertEquals('AnyTeam', $caseEntity->getAssociatedTeam()['teamName']);
+
+ /** @var OrderRepositoryInterface $orderRepository */
+ $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
+ $order = $orderRepository->get($caseEntity->getOrderId());
+ $histories = $order->getStatusHistories();
+ static::assertNotEmpty($histories);
+
+ /** @var OrderStatusHistoryInterface $caseCreationComment */
+ $caseCreationComment = array_pop($histories);
+ static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
+ static::assertEquals("Signifyd Case $caseId has been created for order.", $caseCreationComment->getComment());
+ }
+}
From d718021567fc45d21157e13d6532c7eeab951acb Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 4 Jan 2017 10:52:08 -0600
Subject: [PATCH 080/225] MAGETWO-62806: Update case entity
- Updated method annotations
---
app/code/Magento/Signifyd/Api/CaseManagementInterface.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index 2cf5db226cbff..1e72b30e30110 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -18,7 +18,7 @@ interface CaseManagementInterface
/**
* Creates new Case entity linked to order id.
*
- * @param string $orderId
+ * @param int $orderId
* @return CaseInterface
* @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
*/
@@ -27,7 +27,7 @@ public function create($orderId);
/**
* Gets Case entity associated with order id.
*
- * @param string $orderId
+ * @param int $orderId
* @return CaseInterface|null
*/
public function getByOrderId($orderId);
@@ -35,7 +35,7 @@ public function getByOrderId($orderId);
/**
* Gets Case entity by received case (investigation) id.
*
- * @param $caseId
+ * @param int $caseId
* @return CaseInterface|null
*/
public function getByCaseId($caseId);
From 6d2a03216f699351093bde0bae519120f62bb290 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 4 Jan 2017 13:57:50 -0600
Subject: [PATCH 081/225] MAGETWO-62803: Signifyd webhook controller
- Refactoring webhook data structure
---
.../Signifyd/Controller/Webhooks/Handler.php | 101 +++++++++++++++
.../Signifyd/Controller/Webhooks/Index.php | 91 --------------
.../Response/RawRequestBody.php | 22 ----
.../SignifydGateway/Response/Webhook.php | 74 -----------
.../Response/WebhookFactory.php | 79 ------------
.../Response/WebhookMessage.php | 117 ++++++++++++++++++
...idator.php => WebhookMessageValidator.php} | 29 ++---
.../Response/WebhookRequest.php | 49 ++++++++
.../Response/WebhookRequestReader.php | 85 +++++++++++++
9 files changed, 364 insertions(+), 283 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
delete mode 100644 app/code/Magento/Signifyd/Controller/Webhooks/Index.php
delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php
delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookFactory.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php
rename app/code/Magento/Signifyd/Model/SignifydGateway/Response/{ResponseValidator.php => WebhookMessageValidator.php} (65%)
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
new file mode 100644
index 0000000000000..c02fc3127d5c0
--- /dev/null
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
@@ -0,0 +1,101 @@
+webhookRequest = $webhookRequest;
+ $this->config = $config;
+ $this->logger = $logger;
+ $this->webhookRequestReader = $webhookRequestReader;
+ $this->caseUpdatingServiceFactory = $caseUpdatingServiceFactory;
+ }
+
+ /**
+ * Processes webhook message data and updates case entity
+ *
+ * @return void
+ */
+ public function execute()
+ {
+ if ($this->config->isActive() === false) {
+ return;
+ }
+
+ try {
+ $webhookMessage = $this->webhookRequestReader->read($this->webhookRequest);
+ $caseUpdatingService = $this->caseUpdatingServiceFactory->create($webhookMessage->getEventTopic());
+ $caseUpdatingService->update($webhookMessage->getData());
+ } catch (WebhookException $e) {
+ $this->getResponse()->setHttpResponseCode(400);
+ $this->logger->error($e->getMessage());
+ } catch (\InvalidArgumentException $e) {
+ $this->getResponse()->setHttpResponseCode(400);
+ $this->logger->error($e->getMessage());
+ } catch (LocalizedException $e) {
+ $this->getResponse()->setHttpResponseCode(400);
+ $this->logger->error($e->getMessage());
+ }
+ }
+}
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Index.php b/app/code/Magento/Signifyd/Controller/Webhooks/Index.php
deleted file mode 100644
index 2385e221038c8..0000000000000
--- a/app/code/Magento/Signifyd/Controller/Webhooks/Index.php
+++ /dev/null
@@ -1,91 +0,0 @@
-rawRequestBody = $rawRequestBody;
- $this->config = $config;
- $this->logger = $logger;
- $this->webhookFactory = $webhookFactory;
- }
-
- /**
- * Processes webhook message data and updates case entity
- *
- * @return void
- */
- public function execute()
- {
- if ($this->config->isActive() === false) {
- return;
- }
-
- /** @var \Magento\Framework\App\Request\Http $request */
- $request = $this->getRequest();
- $hash = $request->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256');
- $topic = $request->getHeader('X-SIGNIFYD-TOPIC');
- $rawResponseBody = $this->rawRequestBody->get();
-
- try {
- $webhook = $this->webhookFactory->create($rawResponseBody, $hash, $topic);
- if ($webhook->isTest()) {
- return;
- }
- } catch (WebhookException $e) {
- $this->getResponse()->setHttpResponseCode(400);
- $this->logger->error($e->getMessage());
- }
- }
-}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php
deleted file mode 100644
index ec77193ba3e5f..0000000000000
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php
+++ /dev/null
@@ -1,22 +0,0 @@
-body = $body;
- $this->topic = $topic;
- }
-
- /**
- * Returns webhook body
- *
- * @return array
- */
- public function getBody()
- {
- return $this->body;
- }
-
- /**
- * Returns event topic identifier
- *
- * @return string
- */
- public function getTopic()
- {
- return $this->topic;
- }
-
- /**
- * Checks if webhook is a test
- *
- * @return bool
- */
- public function isTest()
- {
- return $this->topic === 'cases/test';
- }
-}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookFactory.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookFactory.php
deleted file mode 100644
index daa88a0af0b06..0000000000000
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookFactory.php
+++ /dev/null
@@ -1,79 +0,0 @@
-objectManager = $objectManager;
- $this->responseValidator = $responseValidator;
- $this->dataDecoder = $decoder;
- }
-
- /**
- * Create webhook data object.
- *
- * @param string $rawResponseBody
- * @param string $hash Base64 encoded output of the HMAC SHA256 encoding of the JSON body of the message.
- * @param string $topic event topic identifier.
- * @return Webhook
- * @throws WebhookException if data validation fails
- */
- public function create($rawResponseBody, $hash, $topic)
- {
-
- if (!$this->responseValidator->validate($rawResponseBody, $hash, $topic)) {
- throw new WebhookException(
- $this->responseValidator->getErrorMessage()
- );
- }
-
- try {
- $decodedResponseBody = $this->dataDecoder->decode($rawResponseBody);
- } catch (\Exception $e) {
- throw new WebhookException(
- 'Webhook message body is not valid JSON: ' . $e->getMessage(),
- $e->getCode(),
- $e
- );
- }
-
- return $this->objectManager->create(
- Webhook::class,
- ['topic' => $topic, 'body' => $decodedResponseBody]
- );
- }
-}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php
new file mode 100644
index 0000000000000..6ac5d9a0501bd
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php
@@ -0,0 +1,117 @@
+rawData = $rawData;
+ $this->data = $data;
+ $this->eventTopic = $eventTopic;
+ $this->expectedHash = $expectedHash;
+ }
+
+ /**
+ * Returns decoded webhook request body.
+ *
+ * @return DataObject
+ */
+ public function getData()
+ {
+ return new DataObject($this->data);
+ }
+
+ /**
+ * Returns event topic identifier.
+ *
+ * @return string
+ */
+ public function getEventTopic()
+ {
+ return $this->eventTopic;
+ }
+
+ /**
+ * Returns expected hash.
+ *
+ * @return string
+ */
+ public function getExpectedHash()
+ {
+ return $this->expectedHash;
+ }
+
+ /**
+ * Returns actual hash based on raw request body and api key
+ *
+ * @param string $apiKey
+ * @return string
+ */
+ public function getActualHash($apiKey)
+ {
+ return base64_encode(hash_hmac('sha256', $this->rawData, $apiKey, true));
+ }
+
+ /**
+ * Checks if webhook is a test.
+ *
+ * @return bool
+ */
+ public function isTest()
+ {
+ return $this->eventTopic === 'cases/test';
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/ResponseValidator.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php
similarity index 65%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/Response/ResponseValidator.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php
index 0ca443132c0e9..ff383d90b182c 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/ResponseValidator.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php
@@ -8,10 +8,10 @@
use Magento\Signifyd\Model\Config;
/**
- * Validates webhook response.
+ * Validates webhook message.
*
*/
-class ResponseValidator
+class WebhookMessageValidator
{
/**
@@ -47,24 +47,22 @@ public function __construct(
}
/**
- * Validates webhook response.
+ * Validates webhook message.
*
- * @param string $rawResponseBody
- * @param string $hash Base64 encoded output of the HMAC SHA256 encoding of the JSON body of the message.
- * @param string $topic event topic identifier.
+ * @param WebhookMessage $webhookMessage
* @return bool
*/
- public function validate($rawResponseBody, $hash, $topic)
+ public function validate(WebhookMessage $webhookMessage)
{
- if ($this->isValidTopic($topic) === false) {
+ if ($this->isValidTopic($webhookMessage->getEventTopic()) === false) {
$this->errorMessages[] = 'Value of X-SIGNIFYD-TOPIC header is not allowed';
}
- if (empty($rawResponseBody)) {
+ if (empty($webhookMessage->getData())) {
$this->errorMessages[] = 'Webhook message is empty';
}
- if ($this->isValidHmacSha256($rawResponseBody, $hash, $topic) === false) {
+ if ($this->isValidHash($webhookMessage) === false) {
$this->errorMessages[] = 'X-SIGNIFYD-SEC-HMAC-SHA256 header verification fails';
}
@@ -96,17 +94,14 @@ private function isValidTopic($topic)
/**
* Verifies a webhook message has in fact come from SIGNIFYD.
*
- * @param string $rawResponseBody
- * @param string $hash X-SIGNIFYD-SEC-HMAC-SHA256 header is included in each webhook POST message.
- * @param string $topic topic identifier.
+ * @param WebhookMessage $webhookMessage
* @return bool
*/
- private function isValidHmacSha256($rawResponseBody, $hash, $topic)
+ private function isValidHash(WebhookMessage $webhookMessage)
{
// In the case that this is a webhook test, the encoding ABCDE is allowed
- $apiKey = $topic == 'cases/test' ? 'ABCDE' : $this->config->getApiKey();
- $check = base64_encode(hash_hmac('sha256', $rawResponseBody, $apiKey, true));
+ $apiKey = $webhookMessage->isTest() ? 'ABCDE' : $this->config->getApiKey();
- return $check === $hash;
+ return $webhookMessage->getActualHash($apiKey) === $webhookMessage->getExpectedHash();
}
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
new file mode 100644
index 0000000000000..04367f6caf4b3
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
@@ -0,0 +1,49 @@
+request = $request;
+ }
+
+ /**
+ * Retrieve header value.
+ *
+ * @param string $name header name to retrieve.
+ * @return string
+ */
+ public function getHeader($name)
+ {
+ return $this->request->getHeader($name) ?: '';
+ }
+
+ /**
+ * Returns raw data from the request body.
+ *
+ * @return string
+ */
+ public function getBody()
+ {
+ return file_get_contents("php://input") ?: '';
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php
new file mode 100644
index 0000000000000..97bfaf2dc6213
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php
@@ -0,0 +1,85 @@
+webhookMessageValidator = $webhookMessageValidator;
+ $this->dataDecoder = $decoder;
+ $this->webhookMessageFactory = $webhookMessageFactory;
+ }
+
+ /**
+ * Returns webhook message data object.
+ *
+ * @param WebhookRequest $request
+ * @return WebhookMessage
+ * @throws WebhookException if data validation fails
+ */
+ public function read(WebhookRequest $request)
+ {
+ $hash = $request->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256');
+ $eventTopic = $request->getHeader('X-SIGNIFYD-TOPIC');
+ $rawData = $request->getBody();
+
+ try {
+ $decodedData = $this->dataDecoder->decode($rawData);
+ } catch (\Exception $e) {
+ throw new WebhookException(
+ 'Webhook request body is not valid JSON: ' . $e->getMessage(),
+ $e->getCode(),
+ $e
+ );
+ }
+
+ $webhookMessage = $this->webhookMessageFactory->create(
+ [
+ 'rawData' => $rawData,
+ 'data' => $decodedData,
+ 'eventTopic' => $eventTopic,
+ 'expectedHash' => $hash
+ ]
+ );
+
+ if (!$this->webhookMessageValidator->validate($webhookMessage)) {
+ throw new WebhookException(
+ $this->webhookMessageValidator->getErrorMessage()
+ );
+ }
+
+ return $webhookMessage;
+ }
+}
From 5cc6fae42ac4be541b2fc4415386de259d84fdaf Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 5 Jan 2017 05:25:26 -0600
Subject: [PATCH 082/225] MAGETWO-62806: Update case entity
- Moved message generator initialization to own factory
- Added internal service to update order comments history
- Refactored service and factory for case updating
---
.../Signifyd/Api/CaseManagementInterface.php | 8 --
.../Signifyd/Api/CaseRepositoryInterface.php | 8 ++
.../Magento/Signifyd/Model/CaseManagement.php | 16 ----
.../Magento/Signifyd/Model/CaseRepository.php | 14 +++-
.../Signifyd/Model/CaseUpdatingService.php | 75 ++++++++----------
.../Model/CaseUpdatingServiceFactory.php | 64 +++++----------
.../Model/CaseUpdatingServiceInterface.php | 22 ++++++
.../Signifyd/Model/CommentsHistoryUpdater.php | 49 ++++++++++++
.../Model/MessageGenerators/CaseRescore.php | 14 ++--
.../MessageGenerators/GeneratorFactory.php | 79 +++++++++++++++++++
.../Model/StubCaseUpdatingService.php | 24 ++++++
.../Model/Validators/CaseDataValidator.php | 3 +-
.../Model/CaseUpdatingServiceTest.php | 22 ++----
13 files changed, 262 insertions(+), 136 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
create mode 100644 app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
create mode 100644 app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index 1e72b30e30110..bb13cc552c74e 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -31,12 +31,4 @@ public function create($orderId);
* @return CaseInterface|null
*/
public function getByOrderId($orderId);
-
- /**
- * Gets Case entity by received case (investigation) id.
- *
- * @param int $caseId
- * @return CaseInterface|null
- */
- public function getByCaseId($caseId);
}
diff --git a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
index 0e63e9283ad28..d84bd4a3bf7d8 100644
--- a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
@@ -32,6 +32,14 @@ public function save(CaseInterface $case);
*/
public function getById($id);
+ /**
+ * Gets entity by Signifyd case id.
+ *
+ * @param int $caseId
+ * @return CaseInterface|null
+ */
+ public function getByCaseId($caseId);
+
/**
* Deletes case entity.
*
diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php
index 0af87b9b89d3f..8705f9a812ae3 100644
--- a/app/code/Magento/Signifyd/Model/CaseManagement.php
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -88,20 +88,4 @@ public function getByOrderId($orderId)
$items = $this->caseRepository->getList($searchCriteria)->getItems();
return !empty($items) ? array_pop($items) : null;
}
-
- /**
- * @inheritdoc
- */
- public function getByCaseId($caseId)
- {
- $filters = [
- $this->filterBuilder->setField('case_id')
- ->setValue($caseId)
- ->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
index f18ffc47356d9..9c68302074400 100644
--- a/app/code/Magento/Signifyd/Model/CaseRepository.php
+++ b/app/code/Magento/Signifyd/Model/CaseRepository.php
@@ -1,6 +1,6 @@
caseFactory->create();
+ $this->resourceModel->load($case, $caseId, 'case_id');
+
+ return $case->getEntityId() ? $case : null;
+ }
+
/**
* @inheritdoc
*/
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index 474ade3ce8797..cbdb2c77714e9 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -8,77 +8,60 @@
use Magento\Framework\DataObject;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NotFoundException;
-use Magento\Sales\Model\Order\Status\HistoryFactory;
-use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
+use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\Validators\CaseDataValidator;
-use Psr\Log\LoggerInterface;
/**
* Performs Signifyd case entity updating operations.
*/
-class CaseUpdatingService
+class CaseUpdatingService implements CaseUpdatingServiceInterface
{
/**
* @var MessageGeneratorInterface
*/
private $messageGenerator;
- /**
- * @var CaseManagementInterface
- */
- private $caseManagement;
-
/**
* @var CaseRepositoryInterface
*/
private $caseRepository;
/**
- * @var HistoryFactory
- */
- private $historyFactory;
-
- /**
- * @var LoggerInterface
+ * @var CaseDataValidator
*/
- private $logger;
+ private $caseDataValidator;
/**
- * @var CaseDataValidator
+ * @var CommentsHistoryUpdater
*/
- private $caseDataValidator;
+ private $commentsHistoryUpdater;
/**
* CaseUpdatingService constructor.
*
* @param MessageGeneratorInterface $messageGenerator
- * @param CaseManagementInterface $caseManagement
* @param CaseRepositoryInterface $caseRepository
- * @param LoggerInterface $logger
* @param CaseDataValidator $caseDataValidator
- * @param HistoryFactory $historyFactory
+ * @param CommentsHistoryUpdater $commentsHistoryUpdater
*/
public function __construct(
MessageGeneratorInterface $messageGenerator,
- CaseManagementInterface $caseManagement,
CaseRepositoryInterface $caseRepository,
- LoggerInterface $logger,
CaseDataValidator $caseDataValidator,
- HistoryFactory $historyFactory
+ CommentsHistoryUpdater $commentsHistoryUpdater
) {
$this->messageGenerator = $messageGenerator;
- $this->caseManagement = $caseManagement;
$this->caseRepository = $caseRepository;
- $this->historyFactory = $historyFactory;
- $this->logger = $logger;
$this->caseDataValidator = $caseDataValidator;
+ $this->commentsHistoryUpdater = $commentsHistoryUpdater;
}
/**
* Updates Signifyd Case entity by received data.
*
* @param DataObject $data
+ * @return void
* @throws LocalizedException
* @throws NotFoundException
*/
@@ -88,33 +71,39 @@ public function update(DataObject $data)
throw new LocalizedException(__('The "%1" should not be empty.', 'caseId'));
}
- $case = $this->caseManagement->getByCaseId($data->getData('caseId'));
+ $case = $this->caseRepository->getByCaseId($data->getData('caseId'));
if ($case === null) {
throw new NotFoundException(__('Case entity not found.'));
}
try {
- $case->setGuaranteeEligible($data->getData('guaranteeEligible'))
- ->setStatus($data->getData('status'))
- ->setReviewDisposition($data->getData('reviewDisposition'))
- ->setAssociatedTeam($data->getData('associatedTeam'))
- ->setCreatedAt($data->getData('createdAt'))
- ->setUpdatedAt($data->getData('updatedAt'))
- ->setScore($data->getData('score'))
- ->setGuaranteeDisposition($data->getData('guaranteeDisposition'));
+ $this->prepareCaseData($case, $data);
$this->caseRepository->save($case);
// add comment to order history
$message = $this->messageGenerator->generate($data);
- /** @var \Magento\Sales\Api\Data\OrderStatusHistoryInterface $history */
- $history = $this->historyFactory->create();
- $history->setParentId($case->getOrderId())
- ->setComment($message)
- ->save();
-
+ $this->commentsHistoryUpdater->addComment($case, $message);
} catch (\Exception $e) {
- $this->logger->error($e->getMessage());
throw new LocalizedException(__('Cannot update Case entity.'), $e);
}
}
+
+ /**
+ * Sets data to case entity.
+ *
+ * @param CaseInterface $case
+ * @param DataObject $data
+ * @return void
+ */
+ private function prepareCaseData(CaseInterface $case, DataObject $data)
+ {
+ $case->setGuaranteeEligible($data->getData('guaranteeEligible') ?: $case->isGuaranteeEligible())
+ ->setStatus($data->getData('status') ?: $case->getStatus())
+ ->setReviewDisposition($data->getData('reviewDisposition') ?: $case->getReviewDisposition())
+ ->setAssociatedTeam($data->getData('associatedTeam') ?: $case->getAssociatedTeam())
+ ->setCreatedAt($data->getData('createdAt') ?: $case->getCreatedAt())
+ ->setUpdatedAt($data->getData('updatedAt') ?: $case->getUpdatedAt())
+ ->setScore($data->getData('score') ?: $case->getScore())
+ ->setGuaranteeDisposition($data->getData('guaranteeDisposition') ?: $case->getGuaranteeDisposition());
+ }
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
index c2bb54a4dc95d..e626e8347d239 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
@@ -6,10 +6,7 @@
namespace Magento\Signifyd\Model;
use Magento\Framework\ObjectManagerInterface;
-use Magento\Signifyd\Model\MessageGenerators\CaseCreation;
-use Magento\Signifyd\Model\MessageGenerators\CaseRescore;
-use Magento\Signifyd\Model\MessageGenerators\CaseReview;
-use Magento\Signifyd\Model\MessageGenerators\GuaranteeCompletion;
+use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
/**
* Creates instance of case updating service configured with specific message generator.
@@ -19,42 +16,31 @@
class CaseUpdatingServiceFactory
{
/**
- * Type of message for Signifyd case creation.
+ * Type of testing Signifyd case
* @var string
*/
- private static $caseCreation = 'CASE_CREATION';
+ private static $caseTest = 'cases/test';
/**
- * Type of message for Signifyd case re-scoring.
- * @var string
- */
- private static $caseRescore = 'CASE_RESCORE';
-
- /**
- * Type of message for Signifyd case reviewing
- * @var string
- */
- private static $caseReview = 'CASE_REVIEW';
-
- /**
- * Type of message of Signifyd guarantee completion
- * @var string
+ * @var ObjectManagerInterface
*/
- private static $guaranteeCompletion = 'GUARANTEE_COMPLETION';
+ private $objectManager;
/**
- * @var ObjectManagerInterface
+ * @var GeneratorFactory
*/
- private $objectManager;
+ private $generatorFactory;
/**
* CaseUpdatingServiceFactory constructor.
*
* @param ObjectManagerInterface $objectManager
+ * @param GeneratorFactory $generatorFactory
*/
- public function __construct(ObjectManagerInterface $objectManager)
+ public function __construct(ObjectManagerInterface $objectManager, GeneratorFactory $generatorFactory)
{
$this->objectManager = $objectManager;
+ $this->generatorFactory = $generatorFactory;
}
/**
@@ -62,32 +48,20 @@ public function __construct(ObjectManagerInterface $objectManager)
* As param retrieves type of message generator.
*
* @param string $type
- * @return CaseUpdatingService
+ * @return CaseUpdatingServiceInterface
+ * @throws \InvalidArgumentException
*/
public function create($type)
{
- switch ($type) {
- case self::$caseCreation:
- $className = CaseCreation::class;
- break;
- case self::$caseRescore:
- $className = CaseRescore::class;
- break;
- case self::$caseReview:
- $className = CaseReview::class;
- break;
- case self::$guaranteeCompletion:
- $className = GuaranteeCompletion::class;
- break;
- default:
- throw new \InvalidArgumentException('Specified message type does not supported.');
+ if ($type === self::$caseTest) {
+ $service = $this->objectManager->create(StubCaseUpdatingService::class);
+ } else {
+ $messageGenerator = $this->generatorFactory->create($type);
+ $service = $this->objectManager->create(CaseUpdatingService::class, [
+ 'messageGenerator' => $messageGenerator
+ ]);
}
- $messageGenerator = $this->objectManager->get($className);
- $service = $this->objectManager->create(CaseUpdatingService::class, [
- 'messageGenerator' => $messageGenerator
- ]);
-
return $service;
}
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
new file mode 100644
index 0000000000000..1fa97ce3b2ad4
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
@@ -0,0 +1,22 @@
+historyFactory = $historyFactory;
+ }
+
+ /**
+ * Adds comment to case related order.
+ *
+ * @param CaseInterface $case
+ * @param Phrase $message
+ * @return void
+ */
+ public function addComment(CaseInterface $case, Phrase $message)
+ {
+ /** @var \Magento\Sales\Api\Data\OrderStatusHistoryInterface $history */
+ $history = $this->historyFactory->create();
+ $history->setParentId($case->getOrderId())
+ ->setComment($message)
+ ->setEntityName('order')
+ ->save();
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
index 81765a66e278b..5df98975d51e2 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Model\MessageGenerators;
use Magento\Framework\DataObject;
-use Magento\Signifyd\Api\CaseManagementInterface;
+use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
use Magento\Signifyd\Model\Validators\CaseDataValidator;
@@ -17,9 +17,9 @@
class CaseRescore implements MessageGeneratorInterface
{
/**
- * @var CaseManagementInterface
+ * @var CaseRepositoryInterface
*/
- private $caseManagement;
+ private $caseRepository;
/**
* @var CaseDataValidator
@@ -29,12 +29,12 @@ class CaseRescore implements MessageGeneratorInterface
/**
* CaseRescore constructor.
*
- * @param CaseManagementInterface $caseManagement
+ * @param CaseRepositoryInterface $caseRepository
* @param CaseDataValidator $caseDataValidator
*/
- public function __construct(CaseManagementInterface $caseManagement, CaseDataValidator $caseDataValidator)
+ public function __construct(CaseRepositoryInterface $caseRepository, CaseDataValidator $caseDataValidator)
{
- $this->caseManagement = $caseManagement;
+ $this->caseRepository = $caseRepository;
$this->caseDataValidator = $caseDataValidator;
}
@@ -47,7 +47,7 @@ public function generate(DataObject $data)
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
- $caseEntity = $this->caseManagement->getByCaseId($data->getData('caseId'));
+ $caseEntity = $this->caseRepository->getByCaseId($data->getData('caseId'));
if ($caseEntity === null) {
throw new MessageGeneratorException(__('Case entity not found.'));
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
new file mode 100644
index 0000000000000..2b1b4a01b0ed3
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
@@ -0,0 +1,79 @@
+objectManager = $objectManager;
+ }
+
+ /**
+ * Creates instance of message generator.
+ * Throws exception if type of message generator does not have implementations.
+ *
+ * @param string $type
+ * @return MessageGeneratorInterface
+ * @throws \InvalidArgumentException
+ */
+ public function create($type)
+ {
+ switch ($type) {
+ case self::$caseCreation:
+ $className = CaseCreation::class;
+ break;
+ case self::$caseRescore:
+ $className = CaseRescore::class;
+ break;
+ case self::$caseReview:
+ $className = CaseReview::class;
+ break;
+ case self::$guaranteeCompletion:
+ $className = GuaranteeCompletion::class;
+ break;
+ default:
+ throw new \InvalidArgumentException('Specified message type does not supported.');
+ }
+
+ return $this->objectManager->create($className);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php b/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
new file mode 100644
index 0000000000000..3d8ff6478f06c
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
@@ -0,0 +1,24 @@
+objectManager->create(CaseCreation::class);
- $logger = $this->getMockBuilder(LoggerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
$this->service = $this->objectManager->create(CaseUpdatingService::class, [
- 'messageGenerator' => $messageGenerator,
- 'logger' => $logger
+ 'messageGenerator' => $messageGenerator
]);
}
@@ -59,8 +53,6 @@ public function testUpdate()
$data = new DataObject(
[
'caseId' => $caseId,
- 'guaranteeEligible' => true,
- 'status' => CaseInterface::STATUS_DISMISSED,
'score' => 750,
'reviewDisposition' => CaseInterface::DISPOSITION_FRAUDULENT,
'associatedTeam' => [
@@ -77,14 +69,16 @@ public function testUpdate()
$this->service->update($data);
- /** @var CaseManagementInterface $caseManagement */
- $caseManagement = $this->objectManager->get(CaseManagementInterface::class);
- $caseEntity = $caseManagement->getByCaseId($caseId);
+ /** @var CaseRepositoryInterface $caseManagement */
+ $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
+ $caseEntity = $caseRepository->getByCaseId($caseId);
static::assertNotEmpty($caseEntity);
static::assertEquals('2017-01-05 22:23:26', $caseEntity->getCreatedAt());
static::assertEquals(CaseInterface::GUARANTEE_APPROVED, $caseEntity->getGuaranteeDisposition());
static::assertEquals('AnyTeam', $caseEntity->getAssociatedTeam()['teamName']);
+ static::assertEquals(true, $caseEntity->isGuaranteeEligible());
+ static::assertEquals(CaseInterface::STATUS_PROCESSING, $caseEntity->getStatus());
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
From 1d6e6e27dd4470a1b44150acb7ea18243bd9edd5 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 5 Jan 2017 05:40:55 -0600
Subject: [PATCH 083/225] MAGETWO-62806: Update case entity
- Refactored code according to failed static tests
---
.../Signifyd/Api/CaseManagementInterface.php | 2 +-
.../Signifyd/Model/CaseUpdatingService.php | 32 ++++++++++++++-----
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index bb13cc552c74e..7c0445a4211c7 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -1,6 +1,6 @@
setGuaranteeEligible($data->getData('guaranteeEligible') ?: $case->isGuaranteeEligible())
- ->setStatus($data->getData('status') ?: $case->getStatus())
- ->setReviewDisposition($data->getData('reviewDisposition') ?: $case->getReviewDisposition())
- ->setAssociatedTeam($data->getData('associatedTeam') ?: $case->getAssociatedTeam())
- ->setCreatedAt($data->getData('createdAt') ?: $case->getCreatedAt())
- ->setUpdatedAt($data->getData('updatedAt') ?: $case->getUpdatedAt())
- ->setScore($data->getData('score') ?: $case->getScore())
- ->setGuaranteeDisposition($data->getData('guaranteeDisposition') ?: $case->getGuaranteeDisposition());
+ if ($data->getData('guaranteeEligible') !== null) {
+ $case->setGuaranteeEligible($data->getData('guaranteeEligible'));
+ }
+ if ($data->getData('status') !== null) {
+ $case->setStatus($data->getData('status'));
+ }
+ if ($data->getData('reviewDisposition') !== null) {
+ $case->setReviewDisposition($data->getData('reviewDisposition'));
+ }
+ if ($data->getData('associatedTeam') !== null) {
+ $case->setAssociatedTeam($data->getData('associatedTeam'));
+ }
+ if ($data->getData('createdAt') !== null) {
+ $case->setCreatedAt($data->getData('createdAt'));
+ }
+ if ($data->getData('updatedAt') !== null) {
+ $case->setUpdatedAt($data->getData('updatedAt'));
+ }
+ if ($data->getData('score') !== null) {
+ $case->setScore($data->getData('score'));
+ }
+ if ($data->getData('guaranteeDisposition') !== null) {
+ $case->setGuaranteeDisposition($data->getData('guaranteeDisposition'));
+ }
}
}
From 1509b3400d8a98c711b8c3067edd2f9d140a0aa3 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 5 Jan 2017 06:24:37 -0600
Subject: [PATCH 084/225] MAGETWO-62803: Signifyd webhook controller
- Move webhook request validation to controller
---
.../Signifyd/Controller/Webhooks/Handler.php | 50 ++++----
.../Response/WebhookException.php | 14 ---
.../Response/WebhookMessage.php | 53 +-------
...estReader.php => WebhookMessageReader.php} | 35 +-----
.../Response/WebhookMessageValidator.php | 107 -----------------
.../Response/WebhookRequest.php | 21 +++-
.../Response/WebhookRequestValidator.php | 113 ++++++++++++++++++
7 files changed, 157 insertions(+), 236 deletions(-)
delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php
rename app/code/Magento/Signifyd/Model/SignifydGateway/Response/{WebhookRequestReader.php => WebhookMessageReader.php} (51%)
delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestValidator.php
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
index c02fc3127d5c0..d773149a373d5 100644
--- a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
@@ -8,12 +8,10 @@
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Exception\LocalizedException;
-use Magento\Signifyd\Model\CaseUpdatingService;
use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
-use Magento\Signifyd\Model\Config;
+use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequestValidator;
use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequest;
-use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequestReader;
-use Magento\Signifyd\Model\SignifydGateway\Response\WebhookException;
+use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessageReader;
use Psr\Log\LoggerInterface;
/**
@@ -28,71 +26,67 @@ class Handler extends Action
*/
private $webhookRequest;
- /**
- * @var Config
- */
- private $config;
-
/**
* @var LoggerInterface
*/
private $logger;
/**
- * @var WebhookRequestReader
+ * @var WebhookMessageReader
*/
- private $webhookRequestReader;
+ private $webhookMessageReader;
/**
* @var CaseUpdatingServiceFactory
*/
private $caseUpdatingServiceFactory;
+ /**
+ * @var WebhookRequestValidator
+ */
+ private $webhookRequestValidator;
+
/**
* @param Context $context
* @param WebhookRequest $webhookRequest
- * @param Config $config
* @param LoggerInterface $logger
- * @param WebhookRequestReader $webhookRequestReader
+ * @param WebhookMessageReader $webhookMessageReader
* @param CaseUpdatingServiceFactory $caseUpdatingServiceFactory
+ * @param WebhookRequestValidator $webhookRequestValidator
*/
public function __construct(
Context $context,
WebhookRequest $webhookRequest,
- Config $config,
LoggerInterface $logger,
- WebhookRequestReader $webhookRequestReader,
- CaseUpdatingServiceFactory $caseUpdatingServiceFactory
+ WebhookMessageReader $webhookMessageReader,
+ CaseUpdatingServiceFactory $caseUpdatingServiceFactory,
+ WebhookRequestValidator $webhookRequestValidator
) {
parent::__construct($context);
$this->webhookRequest = $webhookRequest;
- $this->config = $config;
$this->logger = $logger;
- $this->webhookRequestReader = $webhookRequestReader;
+ $this->webhookMessageReader = $webhookMessageReader;
$this->caseUpdatingServiceFactory = $caseUpdatingServiceFactory;
+ $this->webhookRequestValidator = $webhookRequestValidator;
}
/**
- * Processes webhook message data and updates case entity
+ * Processes webhook request data and updates case entity
*
* @return void
*/
public function execute()
{
- if ($this->config->isActive() === false) {
+ if (!$this->webhookRequestValidator->validate($this->webhookRequest)) {
+ $this->getResponse()->setHttpResponseCode(400);
return;
}
+ $webhookMessage = $this->webhookMessageReader->read($this->webhookRequest);
+ $caseUpdatingService = $this->caseUpdatingServiceFactory->create($webhookMessage->getEventTopic());
+
try {
- $webhookMessage = $this->webhookRequestReader->read($this->webhookRequest);
- $caseUpdatingService = $this->caseUpdatingServiceFactory->create($webhookMessage->getEventTopic());
$caseUpdatingService->update($webhookMessage->getData());
- } catch (WebhookException $e) {
- $this->getResponse()->setHttpResponseCode(400);
- $this->logger->error($e->getMessage());
- } catch (\InvalidArgumentException $e) {
- $this->getResponse()->setHttpResponseCode(400);
- $this->logger->error($e->getMessage());
} catch (LocalizedException $e) {
$this->getResponse()->setHttpResponseCode(400);
$this->logger->error($e->getMessage());
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php
deleted file mode 100644
index 5b5f34320456d..0000000000000
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php
+++ /dev/null
@@ -1,14 +0,0 @@
-rawData = $rawData;
$this->data = $data;
$this->eventTopic = $eventTopic;
- $this->expectedHash = $expectedHash;
}
/**
@@ -83,35 +63,4 @@ public function getEventTopic()
{
return $this->eventTopic;
}
-
- /**
- * Returns expected hash.
- *
- * @return string
- */
- public function getExpectedHash()
- {
- return $this->expectedHash;
- }
-
- /**
- * Returns actual hash based on raw request body and api key
- *
- * @param string $apiKey
- * @return string
- */
- public function getActualHash($apiKey)
- {
- return base64_encode(hash_hmac('sha256', $this->rawData, $apiKey, true));
- }
-
- /**
- * Checks if webhook is a test.
- *
- * @return bool
- */
- public function isTest()
- {
- return $this->eventTopic === 'cases/test';
- }
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php
similarity index 51%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php
index 97bfaf2dc6213..3511101680f05 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php
@@ -8,15 +8,10 @@
use Magento\Framework\Json\DecoderInterface;
/**
- * Reads request and produces webhook data object based on request params.
+ * Reads request and produces webhook message data object based on request params.
*/
-class WebhookRequestReader
+class WebhookMessageReader
{
- /**
- * @var WebhookMessageValidator
- */
- private $webhookMessageValidator;
-
/**
* @var DecoderInterface
*/
@@ -28,16 +23,13 @@ class WebhookRequestReader
private $webhookMessageFactory;
/**
- * @param WebhookMessageValidator $webhookMessageValidator
* @param DecoderInterface $decoder
* @param WebhookMessageFactory $webhookMessageFactory
*/
public function __construct(
- WebhookMessageValidator $webhookMessageValidator,
DecoderInterface $decoder,
WebhookMessageFactory $webhookMessageFactory
) {
- $this->webhookMessageValidator = $webhookMessageValidator;
$this->dataDecoder = $decoder;
$this->webhookMessageFactory = $webhookMessageFactory;
}
@@ -47,39 +39,24 @@ public function __construct(
*
* @param WebhookRequest $request
* @return WebhookMessage
- * @throws WebhookException if data validation fails
*/
public function read(WebhookRequest $request)
{
- $hash = $request->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256');
- $eventTopic = $request->getHeader('X-SIGNIFYD-TOPIC');
- $rawData = $request->getBody();
-
try {
- $decodedData = $this->dataDecoder->decode($rawData);
+ $decodedData = $this->dataDecoder->decode($request->getBody());
} catch (\Exception $e) {
- throw new WebhookException(
+ throw new \InvalidArgumentException(
'Webhook request body is not valid JSON: ' . $e->getMessage(),
$e->getCode(),
$e
);
}
- $webhookMessage = $this->webhookMessageFactory->create(
+ return $this->webhookMessageFactory->create(
[
- 'rawData' => $rawData,
'data' => $decodedData,
- 'eventTopic' => $eventTopic,
- 'expectedHash' => $hash
+ 'eventTopic' => $request->getEventTopic()
]
);
-
- if (!$this->webhookMessageValidator->validate($webhookMessage)) {
- throw new WebhookException(
- $this->webhookMessageValidator->getErrorMessage()
- );
- }
-
- return $webhookMessage;
}
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php
deleted file mode 100644
index ff383d90b182c..0000000000000
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php
+++ /dev/null
@@ -1,107 +0,0 @@
-config = $config;
- }
-
- /**
- * Validates webhook message.
- *
- * @param WebhookMessage $webhookMessage
- * @return bool
- */
- public function validate(WebhookMessage $webhookMessage)
- {
- if ($this->isValidTopic($webhookMessage->getEventTopic()) === false) {
- $this->errorMessages[] = 'Value of X-SIGNIFYD-TOPIC header is not allowed';
- }
-
- if (empty($webhookMessage->getData())) {
- $this->errorMessages[] = 'Webhook message is empty';
- }
-
- if ($this->isValidHash($webhookMessage) === false) {
- $this->errorMessages[] = 'X-SIGNIFYD-SEC-HMAC-SHA256 header verification fails';
- }
-
- return empty($this->errorMessages);
-
- }
-
- /**
- * Returns error message if validation fails
- *
- * @return string
- */
- public function getErrorMessage()
- {
- return !empty($this->errorMessages) ? implode('; ', $this->errorMessages) : '';
- }
-
- /**
- * 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 message has in fact come from SIGNIFYD.
- *
- * @param WebhookMessage $webhookMessage
- * @return bool
- */
- private function isValidHash(WebhookMessage $webhookMessage)
- {
- // In the case that this is a webhook test, the encoding ABCDE is allowed
- $apiKey = $webhookMessage->isTest() ? 'ABCDE' : $this->config->getApiKey();
-
- return $webhookMessage->getActualHash($apiKey) === $webhookMessage->getExpectedHash();
- }
-}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
index 04367f6caf4b3..fb5e7781a15d9 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
@@ -8,7 +8,7 @@
use Magento\Framework\App\Request\Http;
/**
- * Reads raw data from the request body.
+ * Reads Signifyd webhook request data.
*/
class WebhookRequest
{
@@ -27,14 +27,23 @@ public function __construct(
}
/**
- * Retrieve header value.
+ * Returns Base64 encoded output of the HMAC SHA256 encoding of the JSON body of the message.
*
- * @param string $name header name to retrieve.
* @return string
*/
- public function getHeader($name)
+ public function getHash()
{
- return $this->request->getHeader($name) ?: '';
+ 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');
}
/**
@@ -44,6 +53,6 @@ public function getHeader($name)
*/
public function getBody()
{
- return file_get_contents("php://input") ?: '';
+ return (string)file_get_contents("php://input");
}
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestValidator.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestValidator.php
new file mode 100644
index 0000000000000..f9bf59a0fdb8c
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestValidator.php
@@ -0,0 +1,113 @@
+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;
+ }
+}
From df3b3e1e67733716849552eda62b36f512dc635b Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 5 Jan 2017 07:20:15 -0600
Subject: [PATCH 085/225] MAGETWO-62803: Signifyd webhook controller
- Add redirect to 404 page if webhook request validation fails
---
app/code/Magento/Signifyd/Controller/Webhooks/Handler.php | 2 +-
.../Model/SignifydGateway/Response/WebhookMessageReader.php | 5 ++++-
.../Model/SignifydGateway/Response/WebhookRequest.php | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
index d773149a373d5..346e41c8fb12f 100644
--- a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
@@ -78,7 +78,7 @@ public function __construct(
public function execute()
{
if (!$this->webhookRequestValidator->validate($this->webhookRequest)) {
- $this->getResponse()->setHttpResponseCode(400);
+ $this->_redirect('noroute');
return;
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php
index 3511101680f05..26764eaef0cd3 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php
@@ -39,6 +39,7 @@ public function __construct(
*
* @param WebhookRequest $request
* @return WebhookMessage
+ * @throws \InvalidArgumentException
*/
public function read(WebhookRequest $request)
{
@@ -52,11 +53,13 @@ public function read(WebhookRequest $request)
);
}
- return $this->webhookMessageFactory->create(
+ $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
index fb5e7781a15d9..0a892dd02733d 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
@@ -53,6 +53,6 @@ public function getEventTopic()
*/
public function getBody()
{
- return (string)file_get_contents("php://input");
+ return (string)@file_get_contents("php://input");
}
}
From 18f661ce45975175e71f8c96d59937046934b8d9 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 5 Jan 2017 07:37:23 -0600
Subject: [PATCH 086/225] MAGETWO-62806: Update case entity
- Refactored code according to code review comments
---
.../Signifyd/Api/CaseRepositoryInterface.php | 2 +-
.../Magento/Signifyd/Model/CaseEntity.php | 24 ++++++++---
.../Signifyd/Model/CaseUpdatingService.php | 43 ++++++-------------
.../Model/CaseUpdatingServiceFactory.php | 29 +++++++++----
.../Model/CaseUpdatingServiceInterface.php | 6 +--
.../Model/MessageGeneratorInterface.php | 6 +--
.../Model/MessageGenerators/CaseCreation.php | 5 +--
.../Model/MessageGenerators/CaseRescore.php | 7 ++-
.../Model/MessageGenerators/CaseReview.php | 7 ++-
.../MessageGenerators/GuaranteeCompletion.php | 7 ++-
.../Response/WebhookMessage.php | 6 +--
.../Model/StubCaseUpdatingService.php | 4 +-
.../Model/Validators/CaseDataValidator.php | 8 ++--
.../Model/CaseUpdatingServiceTest.php | 37 ++++++++--------
14 files changed, 95 insertions(+), 96 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
index d84bd4a3bf7d8..e985effe84b59 100644
--- a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
@@ -1,6 +1,6 @@
serializer = $serializer;
+ parent::__construct($context, $registry, $resource, $resourceCollection, $data);
+ }
+
/**
* @inheritdoc
*/
protected function _construct()
{
- $this->serializer = ObjectManager::getInstance()->get(SerializerInterface::class);
$this->_init(ResourceModel\CaseEntity::class);
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index 897b36b2635b9..90364ea541582 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\DataObject;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NotFoundException;
use Magento\Signifyd\Api\CaseRepositoryInterface;
@@ -60,18 +59,18 @@ public function __construct(
/**
* Updates Signifyd Case entity by received data.
*
- * @param DataObject $data
+ * @param array $data
* @return void
* @throws LocalizedException
* @throws NotFoundException
*/
- public function update(DataObject $data)
+ public function update(array $data)
{
if (!$this->caseDataValidator->validate($data)) {
throw new LocalizedException(__('The "%1" should not be empty.', 'caseId'));
}
- $case = $this->caseRepository->getByCaseId($data->getData('caseId'));
+ $case = $this->caseRepository->getByCaseId($data['caseId']);
if ($case === null) {
throw new NotFoundException(__('Case entity not found.'));
}
@@ -92,34 +91,20 @@ public function update(DataObject $data)
* Sets data to case entity.
*
* @param CaseInterface $case
- * @param DataObject $data
+ * @param array $data
* @return void
*/
- private function prepareCaseData(CaseInterface $case, DataObject $data)
+ private function prepareCaseData(CaseInterface $case, array $data)
{
- if ($data->getData('guaranteeEligible') !== null) {
- $case->setGuaranteeEligible($data->getData('guaranteeEligible'));
- }
- if ($data->getData('status') !== null) {
- $case->setStatus($data->getData('status'));
- }
- if ($data->getData('reviewDisposition') !== null) {
- $case->setReviewDisposition($data->getData('reviewDisposition'));
- }
- if ($data->getData('associatedTeam') !== null) {
- $case->setAssociatedTeam($data->getData('associatedTeam'));
- }
- if ($data->getData('createdAt') !== null) {
- $case->setCreatedAt($data->getData('createdAt'));
- }
- if ($data->getData('updatedAt') !== null) {
- $case->setUpdatedAt($data->getData('updatedAt'));
- }
- if ($data->getData('score') !== null) {
- $case->setScore($data->getData('score'));
- }
- if ($data->getData('guaranteeDisposition') !== null) {
- $case->setGuaranteeDisposition($data->getData('guaranteeDisposition'));
+ // list of keys which should not be replaced, like order id
+ $notResolvedKeys = [
+ 'orderId'
+ ];
+ foreach ($data as $key => $value) {
+ $methodName = 'set' . ucfirst($key);
+ if (!in_array($key, $notResolvedKeys) && method_exists($case, $methodName)) {
+ call_user_func([$case, $methodName], $value);
+ }
}
}
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
index e626e8347d239..e4cb86d724137 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
@@ -7,6 +7,7 @@
use Magento\Framework\ObjectManagerInterface;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
+use Magento\Signifyd\Model\Config;
/**
* Creates instance of case updating service configured with specific message generator.
@@ -31,16 +32,26 @@ class CaseUpdatingServiceFactory
*/
private $generatorFactory;
+ /**
+ * @var Config
+ */
+ private $config;
+
/**
* CaseUpdatingServiceFactory constructor.
*
* @param ObjectManagerInterface $objectManager
* @param GeneratorFactory $generatorFactory
+ * @param Config $config
*/
- public function __construct(ObjectManagerInterface $objectManager, GeneratorFactory $generatorFactory)
- {
+ public function __construct(
+ ObjectManagerInterface $objectManager,
+ GeneratorFactory $generatorFactory,
+ Config $config
+ ) {
$this->objectManager = $objectManager;
$this->generatorFactory = $generatorFactory;
+ $this->config = $config;
}
/**
@@ -53,15 +64,15 @@ public function __construct(ObjectManagerInterface $objectManager, GeneratorFact
*/
public function create($type)
{
- if ($type === self::$caseTest) {
- $service = $this->objectManager->create(StubCaseUpdatingService::class);
- } else {
- $messageGenerator = $this->generatorFactory->create($type);
- $service = $this->objectManager->create(CaseUpdatingService::class, [
- 'messageGenerator' => $messageGenerator
- ]);
+ if (!$this->config->isActive() || $type === self::$caseTest) {
+ return $this->objectManager->create(StubCaseUpdatingService::class);
}
+ $messageGenerator = $this->generatorFactory->create($type);
+ $service = $this->objectManager->create(CaseUpdatingService::class, [
+ 'messageGenerator' => $messageGenerator
+ ]);
+
return $service;
}
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
index 1fa97ce3b2ad4..3e221f24682e1 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\DataObject;
-
/**
* Common abstraction to perform updating operations with Signifyd case entity.
*/
@@ -15,8 +13,8 @@ interface CaseUpdatingServiceInterface
/**
* Updates Signifyd Case entity by received data.
*
- * @param DataObject $data
+ * @param array $data
* @return void
*/
- public function update(DataObject $data);
+ public function update(array $data);
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php b/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
index 949c957748274..1126973e1abf2 100644
--- a/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
+++ b/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\DataObject;
-
/**
* Represents common abstraction for Signifyd Case/Guarantee messages.
* Each interface implementation might use Case/Guarantee data to generate specific message.
@@ -15,9 +13,9 @@ interface MessageGeneratorInterface
{
/**
* Creates new localized message based on Signifyd Case/Guarantee data.
- * @param DataObject $data
+ * @param $data
* @return \Magento\Framework\Phrase
* @throws MessageGeneratorException
*/
- public function generate(DataObject $data);
+ public function generate(array $data);
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
index 7c65f923ff13f..72165538956b4 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Model\MessageGenerators;
-use Magento\Framework\DataObject;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
use Magento\Signifyd\Model\Validators\CaseDataValidator;
@@ -33,12 +32,12 @@ public function __construct(CaseDataValidator $caseDataValidator)
/**
* @inheritdoc
*/
- public function generate(DataObject $data)
+ public function generate(array $data)
{
if (!$this->caseDataValidator->validate($data)) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
- return __('Signifyd Case %1 has been created for order.', $data->getData('caseId'));
+ return __('Signifyd Case %1 has been created for order.', $data['caseId']);
}
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
index 5df98975d51e2..adbd604ed9376 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Model\MessageGenerators;
-use Magento\Framework\DataObject;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
@@ -41,13 +40,13 @@ public function __construct(CaseRepositoryInterface $caseRepository, CaseDataVal
/**
* @inheritdoc
*/
- public function generate(DataObject $data)
+ public function generate(array $data)
{
if (!$this->caseDataValidator->validate($data)) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
- $caseEntity = $this->caseRepository->getByCaseId($data->getData('caseId'));
+ $caseEntity = $this->caseRepository->getByCaseId($data['caseId']));
if ($caseEntity === null) {
throw new MessageGeneratorException(__('Case entity not found.'));
@@ -55,7 +54,7 @@ public function generate(DataObject $data)
return __(
'Case Update: New score for the order is %1. Previous score was %2.',
- $data->getData('score'),
+ !empty($data['score']) ? $data['score'] : 0,
$caseEntity->getScore()
);
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
index 06cedd4ad42fb..c34c6592b751d 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Model\MessageGenerators;
-use Magento\Framework\DataObject;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
@@ -17,15 +16,15 @@ class CaseReview implements MessageGeneratorInterface
/**
* @inheritdoc
*/
- public function generate(DataObject $data)
+ public function generate(array $data)
{
- if (empty($data->getData('reviewDisposition'))) {
+ if (empty($data['reviewDisposition'])) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'reviewDisposition'));
}
return __(
'Case Update: Case Review was completed. Review Deposition is %1.',
- __($data->getData('reviewDisposition'))
+ __($data['reviewDisposition'])
);
}
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
index 051a48f68c7bb..cfc73922c5d9a 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Model\MessageGenerators;
-use Magento\Framework\DataObject;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
@@ -17,12 +16,12 @@ class GuaranteeCompletion implements MessageGeneratorInterface
/**
* @inheritdoc
*/
- public function generate(DataObject $data)
+ public function generate(array $data)
{
- if (empty($data->getData('guaranteeDisposition'))) {
+ if (empty($data['guaranteeDisposition'])) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'guaranteeDisposition'));
}
- return __('Case Update: Guarantee Disposition is %1.', __($data->getData('guaranteeDisposition')));
+ return __('Case Update: Guarantee Disposition is %1.', __($data['guaranteeDisposition']));
}
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php
index 8ce2d78657725..f48c5c3a39a6f 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway\Response;
-use Magento\Framework\DataObject;
-
/**
* Webhooks are messages sent by SIGNIFYD via HTTP POST to a url you configure on your
* Notifications page in the SIGNIFYD settings.
@@ -47,11 +45,11 @@ public function __construct(
/**
* Returns decoded webhook request body.
*
- * @return DataObject
+ * @return array
*/
public function getData()
{
- return new DataObject($this->data);
+ return $this->data;
}
/**
diff --git a/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php b/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
index 3d8ff6478f06c..9d7cffdd7ca1a 100644
--- a/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\DataObject;
-
/**
* Stub implementation for case updating service interface and might be used
* for test Signifyd webhooks
@@ -17,7 +15,7 @@ class StubCaseUpdatingService implements CaseUpdatingServiceInterface
/**
* @inheritdoc
*/
- public function update(DataObject $data)
+ public function update(array $data)
{
// just stub method and doesn't contain any logic
}
diff --git a/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php b/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
index 07b109b82745f..9827984956f54 100644
--- a/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
+++ b/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Model\Validators;
-use Magento\Framework\DataObject;
-
/**
* Validates Signifyd Case id field.
*/
@@ -14,12 +12,12 @@ class CaseDataValidator
{
/**
* Checks if data object contains Signifyd Case id.
- * @param DataObject $data
+ * @param array $data
* @return bool
*/
- public function validate(DataObject $data)
+ public function validate(array $data)
{
- if (empty($data->getData('caseId'))) {
+ if (empty($data['caseId'])) {
return false;
}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
index ecc16820e934b..2fb3d0481a2e3 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
@@ -6,7 +6,6 @@
namespace Magento\Signifyd\Model;
use Magento\Framework\App\ObjectManager;
-use Magento\Framework\DataObject;
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
@@ -44,34 +43,37 @@ protected function setUp()
}
/**
+ * Checks case updating flow and messages in order comments history.
+ *
* @covers \Magento\Signifyd\Model\CaseUpdatingService::update
* @magentoDataFixture Magento/Signifyd/_files/case.php
*/
public function testUpdate()
{
$caseId = 123;
- $data = new DataObject(
- [
- 'caseId' => $caseId,
- 'score' => 750,
- '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
- ]
- );
+ $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
+ ];
$this->service->update($data);
/** @var CaseRepositoryInterface $caseManagement */
$caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
+ /** @var CaseInterface $caseEntity */
$caseEntity = $caseRepository->getByCaseId($caseId);
+ $orderEntityId = $caseEntity->getOrderId();
static::assertNotEmpty($caseEntity);
static::assertEquals('2017-01-05 22:23:26', $caseEntity->getCreatedAt());
@@ -79,6 +81,7 @@ public function testUpdate()
static::assertEquals('AnyTeam', $caseEntity->getAssociatedTeam()['teamName']);
static::assertEquals(true, $caseEntity->isGuaranteeEligible());
static::assertEquals(CaseInterface::STATUS_PROCESSING, $caseEntity->getStatus());
+ static::assertEquals($orderEntityId, $caseEntity->getOrderId());
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
From 2f4c7bb4698b45df8430b714d066bc522392a883 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 5 Jan 2017 11:31:36 -0600
Subject: [PATCH 087/225] MAGETWO-62803: Signifyd webhook controller
- Add WebhookRequestValidatorTest
- Add HandlerTest
---
.../Unit/Controller/Webhooks/HandlerTest.php | 228 +++++++++++++++++
.../Response/WebhookRequestValidatorTest.php | 231 ++++++++++++++++++
2 files changed, 459 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
diff --git a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
new file mode 100644
index 0000000000000..8fcec8433f87a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
@@ -0,0 +1,228 @@
+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(CaseUpdatingServiceFactory::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->controller = new Handler(
+ $this->context,
+ $this->webhookRequest,
+ $this->logger,
+ $this->webhookMessageReader,
+ $this->caseUpdatingServiceFactory,
+ $this->webhookRequestValidator
+ );
+ }
+
+ /**
+ * Successfull case
+ */
+ public function testExecuteSuccessfully()
+ {
+ $eventTopic = 'cases\test';
+ $data = ['score' => 200, 'caseId' => 1];
+
+ $this->webhookRequestValidator->expects($this->once())
+ ->method('validate')
+ ->willReturn(true);
+
+ $webhookMessage = $this->getMockBuilder(WebhookMessage::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $webhookMessage->expects($this->once())
+ ->method('getEventTopic')
+ ->willReturn($eventTopic);
+ $webhookMessage->expects($this->once())
+ ->method('getData')
+ ->willReturn($data);
+ $this->webhookMessageReader->expects($this->once())
+ ->method('read')
+ ->with($this->webhookRequest)
+ ->willReturn($webhookMessage);
+
+ $caseUpdatingService = $this->getMockBuilder(CaseUpdatingService::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $caseUpdatingService->expects($this->once())
+ ->method('update')
+ ->with($data)
+ ->willReturn($caseUpdatingService);
+
+ $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\test';
+ $data = ['score' => 200, 'caseId' => 1];
+
+ $this->webhookRequestValidator->expects($this->once())
+ ->method('validate')
+ ->willReturn(true);
+
+ $webhookMessage = $this->getMockBuilder(WebhookMessage::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $webhookMessage->expects($this->once())
+ ->method('getEventTopic')
+ ->willReturn($eventTopic);
+ $webhookMessage->expects($this->once())
+ ->method('getData')
+ ->willReturn($data);
+ $this->webhookMessageReader->expects($this->once())
+ ->method('read')
+ ->with($this->webhookRequest)
+ ->willReturn($webhookMessage);
+
+ $caseUpdatingService = $this->getMockBuilder(CaseUpdatingService::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $caseUpdatingService->expects($this->once())
+ ->method('update')
+ ->with($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('error')
+ ->with(__('Error'));
+
+ $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();
+ }
+}
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
new file mode 100644
index 0000000000000..0209a64d5c94b
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
@@ -0,0 +1,231 @@
+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;
+ }
+}
From b785f2bae0f5a598c82924ed9b919609b9d5acb2 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 6 Jan 2017 02:50:30 -0600
Subject: [PATCH 088/225] MAGETWO-62806: Update case entity
- Added unit tests
---
.../Magento/Signifyd/Model/CaseEntity.php | 16 +-
.../Model/CaseUpdatingServiceFactory.php | 1 -
.../Signifyd/Model/CommentsHistoryUpdater.php | 2 +
.../Model/MessageGeneratorInterface.php | 2 +-
.../Model/MessageGenerators/CaseRescore.php | 2 +-
.../Model/CaseUpdatingServiceFactoryTest.php | 167 +++++++++
.../Unit/Model/CaseUpdatingServiceTest.php | 336 ++++++++++++++++++
.../Unit/Model/CommentsHistoryUpdaterTest.php | 140 ++++++++
.../GeneratorFactoryTest.php | 99 ++++++
.../Unit/Model/SignifydOrderSessionIdTest.php | 4 +-
10 files changed, 761 insertions(+), 8 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index 647b8e2410301..d75285d228e4e 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -28,13 +28,23 @@ class CaseEntity extends AbstractModel implements CaseInterface
*/
private $serializer;
+ /**
+ * CaseEntity constructor.
+ *
+ * @param Context $context
+ * @param Registry $registry
+ * @param SerializerInterface $serializer
+ * @param array $data
+ * @param AbstractResource|null $resource
+ * @param AbstractDb|null $resourceCollection
+ */
public function __construct(
- SerializerInterface $serializer,
Context $context,
Registry $registry,
+ SerializerInterface $serializer,
+ array $data = [],
AbstractResource $resource = null,
- AbstractDb $resourceCollection = null,
- array $data = []
+ AbstractDb $resourceCollection = null
) {
$this->serializer = $serializer;
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
index e4cb86d724137..f9236a5fa9395 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
@@ -7,7 +7,6 @@
use Magento\Framework\ObjectManagerInterface;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
-use Magento\Signifyd\Model\Config;
/**
* Creates instance of case updating service configured with specific message generator.
diff --git a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
index 914efd0cd7e6a..ff600b91d0a6b 100644
--- a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
+++ b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
@@ -32,10 +32,12 @@ public function __construct(HistoryFactory $historyFactory)
/**
* Adds comment to case related order.
+ * Throws an exception if cannot save history comment.
*
* @param CaseInterface $case
* @param Phrase $message
* @return void
+ * @throws \Exception
*/
public function addComment(CaseInterface $case, Phrase $message)
{
diff --git a/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php b/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
index 1126973e1abf2..265b6ae1e5f5a 100644
--- a/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
+++ b/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
@@ -13,7 +13,7 @@ interface MessageGeneratorInterface
{
/**
* Creates new localized message based on Signifyd Case/Guarantee data.
- * @param $data
+ * @param array $data
* @return \Magento\Framework\Phrase
* @throws MessageGeneratorException
*/
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
index adbd604ed9376..0f184590d4946 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -46,7 +46,7 @@ public function generate(array $data)
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
- $caseEntity = $this->caseRepository->getByCaseId($data['caseId']));
+ $caseEntity = $this->caseRepository->getByCaseId($data['caseId']);
if ($caseEntity === null) {
throw new MessageGeneratorException(__('Case entity not found.'));
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
new file mode 100644
index 0000000000000..4c73756e39ac8
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
@@ -0,0 +1,167 @@
+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(CaseUpdatingServiceFactory::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\CaseUpdatingServiceFactory::create
+ */
+ public function testCreateWithInactiveConfig()
+ {
+ $type = 'cases/creation';
+ $this->config->expects(self::once())
+ ->method('isActive')
+ ->willReturn(false);
+
+ $this->fakeObjectManager->expects(self::once())
+ ->method('create')
+ ->with(StubCaseUpdatingService::class)
+ ->willReturn(new StubCaseUpdatingService());
+
+ $instance = $this->factory->create($type);
+ static::assertInstanceOf(StubCaseUpdatingService::class, $instance);
+ }
+
+ /**
+ * Checks type of instance for updating service if test type is received.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::create
+ */
+ public function testCreateWithTestType()
+ {
+ $type = 'cases/test';
+ $this->config->expects(self::once())
+ ->method('isActive')
+ ->willReturn(true);
+
+ $this->fakeObjectManager->expects(self::once())
+ ->method('create')
+ ->with(StubCaseUpdatingService::class)
+ ->willReturn(new StubCaseUpdatingService());
+
+ $instance = $this->factory->create($type);
+ static::assertInstanceOf(StubCaseUpdatingService::class, $instance);
+ }
+
+ /**
+ * Checks exception type and message for unknown case type.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::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\CaseUpdatingServiceFactory::create
+ */
+ public function testCreate()
+ {
+ $type = 'case/creation';
+ $this->config->expects(self::once())
+ ->method('isActive')
+ ->willReturn(true);
+
+ $messageGenerator = $this->getMockBuilder(MessageGeneratorInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->generatorFactory->expects(self::once())
+ ->method('create')
+ ->with($type)
+ ->willReturn($messageGenerator);
+
+ $service = $this->getMockBuilder(CaseUpdatingService::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->fakeObjectManager->expects(self::once())
+ ->method('create')
+ ->with(CaseUpdatingService::class, ['messageGenerator' => $messageGenerator])
+ ->willReturn($service);
+
+ $result = $this->factory->create($type);
+ static::assertInstanceOf(CaseUpdatingService::class, $result);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
new file mode 100644
index 0000000000000..6c72190b0f16c
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
@@ -0,0 +1,336 @@
+objectManager = new ObjectManager($this);
+
+ $this->messageGenerator = $this->getMockBuilder(MessageGeneratorInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['generate'])
+ ->getMock();
+
+ $this->caseRepository = $this->getMockBuilder(CaseRepositoryInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getByCaseId'])
+ ->getMockForAbstractClass();
+
+ $this->caseDataValidator = $this->getMockBuilder(CaseDataValidator::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['validate'])
+ ->getMock();
+
+ $this->commentsHistoryUpdater = $this->getMockBuilder(CommentsHistoryUpdater::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['addComment'])
+ ->getMock();
+
+ $this->service = $this->objectManager->getObject(CaseUpdatingService::class, [
+ 'messageGenerator' => $this->messageGenerator,
+ 'caseRepository' => $this->caseRepository,
+ 'caseDataValidator' => $this->caseDataValidator,
+ 'commentsHistoryUpdater' => $this->commentsHistoryUpdater
+ ]);
+ }
+
+ /**
+ * Checks a test case when Signifyd case id is missed in input data.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessage The "caseId" should not be empty.
+ */
+ public function testUpdateWithFailedValidation()
+ {
+ $data = [];
+ $this->caseDataValidator->expects(self::once())
+ ->method('validate')
+ ->with($data)
+ ->willReturn(false);
+
+ $this->service->update($data);
+ }
+
+ /**
+ * Checks a test case when Signifyd case entity not found in repository.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @expectedException \Magento\Framework\Exception\NotFoundException
+ * @expectedExceptionMessage Case entity not found.
+ */
+ public function testUpdateWithNotExistingCase()
+ {
+ $caseId = 123;
+ $data = [
+ 'caseId' => $caseId
+ ];
+
+ $this->caseDataValidator->expects(self::once())
+ ->method('validate')
+ ->with($data)
+ ->willReturn(true);
+
+ $this->caseRepository->expects(self::once())
+ ->method('getByCaseId')
+ ->with($caseId)
+ ->willReturn(null);
+
+ $this->service->update($data);
+ }
+
+ /**
+ * Checks as test case when service cannot save Signifyd case entity
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::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
+ ];
+
+ $this->caseDataValidator->expects(self::once())
+ ->method('validate')
+ ->with($data)
+ ->willReturn(true);
+
+ $caseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['setCaseId', 'setStatus', 'setOrderId', 'setScore'])
+ ->getMockForAbstractClass();
+
+ $this->caseRepository->expects(self::once())
+ ->method('getByCaseId')
+ ->with($caseId)
+ ->willReturn($caseEntity);
+
+ $caseEntity->expects(self::never())
+ ->method('setOrderId');
+ $caseEntity->expects(self::once())
+ ->method('setCaseId')
+ ->with($caseId)
+ ->willReturnSelf();
+ $caseEntity->expects(self::once())
+ ->method('setStatus')
+ ->with(CaseInterface::STATUS_OPEN)
+ ->willReturnSelf();
+ $caseEntity->expects(self::once())
+ ->method('setScore')
+ ->with(500)
+ ->willReturnSelf();
+
+ $this->caseRepository->expects(self::once())
+ ->method('save')
+ ->willThrowException(new \Exception('Something wrong.'));
+
+ $this->service->update($data);
+ }
+
+ /**
+ * Checks as test case when message generator throws an exception
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessage Cannot update Case entity.
+ */
+ public function testUpdateWithExceptionFromMessageGenerator()
+ {
+ $caseId = 123;
+ $data = [
+ 'caseId' => $caseId
+ ];
+
+ $this->caseDataValidator->expects(self::once())
+ ->method('validate')
+ ->with($data)
+ ->willReturn(true);
+
+ $caseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['setCaseId'])
+ ->getMockForAbstractClass();
+
+ $this->caseRepository->expects(self::once())
+ ->method('getByCaseId')
+ ->with($caseId)
+ ->willReturn($caseEntity);
+
+ $caseEntity->expects(self::once())
+ ->method('setCaseId')
+ ->with($caseId)
+ ->willReturnSelf();
+
+ $this->caseRepository->expects(self::once())
+ ->method('save')
+ ->with($caseEntity)
+ ->willReturn($caseEntity);
+
+ $this->messageGenerator->expects(self::once())
+ ->method('generate')
+ ->with($data)
+ ->willThrowException(new MessageGeneratorException(__('Cannot generate message.')));
+
+ $this->service->update($data);
+ }
+
+ /**
+ * Checks a test case when comments history updater throws an exception.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessage Cannot update Case entity.
+ */
+ public function testUpdateWithFailedCommentSaving()
+ {
+ $caseId = 123;
+ $data = [
+ 'caseId' => $caseId
+ ];
+
+ $this->caseDataValidator->expects(self::once())
+ ->method('validate')
+ ->with($data)
+ ->willReturn(true);
+
+ $caseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['setCaseId'])
+ ->getMockForAbstractClass();
+
+ $this->caseRepository->expects(self::once())
+ ->method('getByCaseId')
+ ->with($caseId)
+ ->willReturn($caseEntity);
+
+ $caseEntity->expects(self::once())
+ ->method('setCaseId')
+ ->with($caseId)
+ ->willReturnSelf();
+
+ $this->caseRepository->expects(self::once())
+ ->method('save')
+ ->with($caseEntity)
+ ->willReturn($caseEntity);
+
+ $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($data);
+ }
+
+ /**
+ * Checks a test case when Signifyd case entity is successfully updated and message stored in comments history.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ */
+ public function testUpdate()
+ {
+ $caseId = 123;
+ $data = [
+ 'caseId' => $caseId
+ ];
+
+ $this->caseDataValidator->expects(self::once())
+ ->method('validate')
+ ->with($data)
+ ->willReturn(true);
+
+ $caseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['setCaseId'])
+ ->getMockForAbstractClass();
+
+ $this->caseRepository->expects(self::once())
+ ->method('getByCaseId')
+ ->with($caseId)
+ ->willReturn($caseEntity);
+
+ $caseEntity->expects(self::once())
+ ->method('setCaseId')
+ ->with($caseId)
+ ->willReturnSelf();
+
+ $this->caseRepository->expects(self::once())
+ ->method('save')
+ ->with($caseEntity)
+ ->willReturn($caseEntity);
+
+ $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);
+
+ $this->service->update($data);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
new file mode 100644
index 0000000000000..e154fc32afa9a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
@@ -0,0 +1,140 @@
+historyFactory = $this->getMockBuilder(HistoryFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+
+ $this->caseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getOrderId'])
+ ->getMockForAbstractClass();
+
+ $this->initCommentMock();
+
+ $this->updater = $objectManager->getObject(CommentsHistoryUpdater::class, [
+ 'historyFactory' => $this->historyFactory
+ ]);
+ }
+
+ /**
+ * 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->expects(self::once())
+ ->method('save')
+ ->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->expects(self::once())
+ ->method('save')
+ ->willReturnSelf();
+
+ $this->updater->addComment($this->caseEntity, __(self::$message));
+ }
+
+ /**
+ * 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->expects(self::once())
+ ->method('create')
+ ->willReturn($this->historyEntity);
+
+ $this->historyEntity->expects(self::once())
+ ->method('setParentId')
+ ->with(self::$orderId)
+ ->willReturnSelf();
+ $this->historyEntity->expects(self::once())
+ ->method('setComment')
+ ->with(self::$message)
+ ->willReturnSelf();
+ $this->historyEntity->expects(self::once())
+ ->method('setEntityName')
+ ->with('order')
+ ->willReturnSelf();
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
new file mode 100644
index 0000000000000..c154b22fcab2a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
@@ -0,0 +1,99 @@
+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);
+ static::assertInstanceOf($className, $instance);
+ }
+
+ /**
+ * Get list of available messages generators types and equal class names.
+ *
+ * @return array
+ */
+ public function typeDataProvider()
+ {
+ return [
+ ['cases/creation', CaseCreation::class],
+ ['cases/rescore', CaseRescore::class],
+ ['cases/review', CaseReview::class],
+ ['guarantees/completion', GuaranteeCompletion::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/SignifydOrderSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
index f8a36ef172dc5..2c1788ad288c2 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
@@ -1,6 +1,6 @@
identityGenerator->expects(static::once())
+ $this->identityGenerator->expects(self::once())
->method('generateIdForData')
->with($quoteId)
->willReturn($signifydOrderSessionId);
From 3c01a61fba4f8f27523fa6c3b077a4089f234b68 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 6 Jan 2017 03:15:57 -0600
Subject: [PATCH 089/225] MAGETWO-62803: Signifyd webhook controller
- Add WebhookMessageReaderTest
---
.../Response/WebhookMessageReaderTest.php | 114 ++++++++++++++++++
1 file changed, 114 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
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
new file mode 100644
index 0000000000000..03d13566e28c7
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
@@ -0,0 +1,114 @@
+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);
+ }
+}
From 1befdc3033973f6562d5bfb0ca48af75cb7a8e17 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 6 Jan 2017 05:45:32 -0600
Subject: [PATCH 090/225] MAGETWO-62806: Update case entity
- Added possibility to store Signifyd case id on case entity creation
---
.../Signifyd/Model/CaseCreationService.php | 19 +++++++++++++++----
.../Model/CaseCreationServiceTest.php | 10 +++++++++-
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseCreationService.php
index c544ab30d6b35..39414d8f84fc1 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseCreationService.php
@@ -1,12 +1,13 @@
caseManagement = $caseManagement;
$this->signifydGateway = $signifydGateway;
$this->logger = $logger;
+ $this->caseRepository = $caseRepository;
}
/**
@@ -56,10 +65,12 @@ public function __construct(
*/
public function createForOrder($orderId)
{
- $this->caseManagement->create($orderId);
+ $case = $this->caseManagement->create($orderId);
try {
- $this->signifydGateway->createCase($orderId);
+ $caseId = $this->signifydGateway->createCase($orderId);
+ $case->setCaseId($caseId);
+ $this->caseRepository->save($case);
} catch (ApiCallException $e) {
$this->logger->error($e->getMessage());
} catch (GatewayException $e) {
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
index effee790eaa2a..fc4841c5388f8 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
@@ -1,6 +1,6 @@
service->createForOrder($order->getEntityId());
static::assertTrue($result);
+
+ /** @var CaseRepositoryInterface $caseRepository */
+ $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
+ $caseEntity = $caseRepository->getByCaseId(123123);
+
+ static::assertNotEmpty($caseEntity);
+ static::assertEquals($order->getEntityId(), $caseEntity->getOrderId());
}
/**
From 04588c9fe1bd001f26539453121d8e6385511b31 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Fri, 6 Jan 2017 05:49:37 -0600
Subject: [PATCH 091/225] MAGETWO-62806: Update case entity
- Added tests for MessageGenerators
---
.../MessageGenerators/CaseCreationTest.php | 75 +++++++++
.../MessageGenerators/CaseRescoreTest.php | 151 ++++++++++++++++++
.../MessageGenerators/CaseReviewTest.php | 67 ++++++++
.../GuaranteeCompletionTest.php | 64 ++++++++
4 files changed, 357 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
new file mode 100644
index 0000000000000..91b542fc5dff5
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
@@ -0,0 +1,75 @@
+ 100];
+
+ /**
+ * @var ObjectManager
+ */
+ private $objectManager;
+
+ /**
+ * @var CaseCreation
+ */
+ private $caseCreation;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ $this->objectManager = new ObjectManager($this);
+
+ $this->caseCreation = $this->objectManager->getObject(CaseCreation::class, [
+ 'caseDataValidator' => new CaseDataValidator()
+ ]);
+ }
+
+ /**
+ * Parameter without required attribute caseId.
+ *
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedExceptionMessage The "caseId" should not be empty
+ */
+ public function testGenerateException()
+ {
+ $this->caseCreation->generate([]);
+ }
+
+ /**
+ * Checks interface generated message.
+ */
+ public function testGenerateMessageInterface()
+ {
+ $message = $this->caseCreation->generate(self::$data);
+
+ $this->assertInstanceOf(\Magento\Framework\Phrase::class, $message);
+ }
+
+ /**
+ * Generates case creation message for created Signifyd properly.
+ */
+ public function testGenerate()
+ {
+ $message = $this->caseCreation->generate(self::$data);
+
+ $phrase = __('Signifyd Case %1 has been created for order.', self::$data['caseId']);
+
+ $this->assertEquals($phrase, $message);
+ }
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
new file mode 100644
index 0000000000000..0d230544ee190
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -0,0 +1,151 @@
+ 100,
+ 'score' => 200
+ ];
+
+ /**
+ * @var ObjectManager
+ */
+ private $objectManager;
+
+ /**
+ * @var CaseRepository|MockObject
+ */
+ private $caseRepository;
+
+ /**
+ * @var CaseRescore|MocObject
+ */
+ private $CaseRescore;
+
+ /**
+ * @var Case|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, [
+ 'caseDataValidator' => new CaseDataValidator(),
+ 'caseRepository' => $this->caseRepository
+ ]);
+
+ }
+
+ /**
+ * Data array without required attribute caseId.
+ *
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedExceptionMessage The "caseId" should not be empty
+ */
+ public function testGenerateEmptyCaseIdException()
+ {
+ $this->CaseRescore->generate([]);
+ }
+
+ /**
+ * Case entity was not found in DB.
+ *
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @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, [
+ 'caseDataValidator' => new CaseDataValidator(),
+ '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, [
+ 'caseDataValidator' => new CaseDataValidator(),
+ '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, [
+ 'caseDataValidator' => new CaseDataValidator(),
+ '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);
+ }
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
new file mode 100644
index 0000000000000..f27676be8d534
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
@@ -0,0 +1,67 @@
+ 100];
+
+ /**
+ * @var CaseReview
+ */
+ private $caseReview;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ $this->caseReview = new CaseReview();
+ }
+
+ /**
+ * Parameter without required attribute reviewDisposition.
+ *
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedExceptionMessage The "reviewDisposition" should not be empty
+ */
+ public function testGenerateException()
+ {
+ $this->caseReview->generate([]);
+ }
+
+ /**
+ * Checks interface generated message.
+ */
+ public function testGenerateMessageInterface()
+ {
+ $message = $this->caseReview->generate(self::$data);
+
+ $this->assertInstanceOf(\Magento\Framework\Phrase::class, $message);
+ }
+
+ /**
+ * Generates Case Review message for created Signifyd properly.
+ */
+ public function testGenerate()
+ {
+ $message = $this->caseReview->generate(self::$data);
+
+ $phrase = __(
+ 'Case Update: Case Review was completed. Review Deposition is %1.',
+ __(self::$data['reviewDisposition'])
+ );
+
+ $this->assertEquals($phrase, $message);
+ }
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
new file mode 100644
index 0000000000000..7e95d10bc3c6a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
@@ -0,0 +1,64 @@
+ 100];
+
+ /**
+ * @var GuaranteeCompletion
+ */
+ private $guaranteeCompletion;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ $this->guaranteeCompletion = new GuaranteeCompletion();
+ }
+
+ /**
+ * Parameter without required attribute guaranteeDisposition.
+ *
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedExceptionMessage The "guaranteeDisposition" should not be empty
+ */
+ public function testGenerateException()
+ {
+ $this->guaranteeCompletion->generate([]);
+ }
+
+ /**
+ * Checks interface generated Guarantee Completion message.
+ */
+ public function testGenerateMessageInterface()
+ {
+ $message = $this->guaranteeCompletion->generate(self::$data);
+
+ $this->assertInstanceOf(\Magento\Framework\Phrase::class, $message);
+ }
+
+ /**
+ * Generates Guarantee Completion message for created Signifyd properly.
+ */
+ public function testGenerate()
+ {
+ $message = $this->guaranteeCompletion->generate(self::$data);
+
+ $phrase = __('Case Update: Guarantee Disposition is %1.', __(self::$data['guaranteeDisposition']));
+
+ $this->assertEquals($phrase, $message);
+ }
+}
\ No newline at end of file
From 68a8ff2fff19a54ddd5512505ebe7f564aeb70ac Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Fri, 6 Jan 2017 06:24:10 -0600
Subject: [PATCH 092/225] MAGETWO-62806: Update case entity
- Fixed code styling
---
.../MessageGenerators/CaseCreationTest.php | 2 +-
.../MessageGenerators/CaseRescoreTest.php | 26 ++++++++++---------
.../MessageGenerators/CaseReviewTest.php | 2 +-
.../GuaranteeCompletionTest.php | 2 +-
4 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
index 91b542fc5dff5..639ffdf8c458c 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
@@ -72,4 +72,4 @@ public function testGenerate()
$this->assertEquals($phrase, $message);
}
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 0d230544ee190..1662d830289d3 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -36,7 +36,7 @@ class CaseRescoreTest extends \PHPUnit_Framework_TestCase
/**
* @var CaseRescore|MocObject
*/
- private $CaseRescore;
+ private $caseRescore;
/**
* @var Case|MockObject
@@ -56,7 +56,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $this->CaseRescore = $this->objectManager->getObject(CaseRescore::class, [
+ $this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
'caseRepository' => $this->caseRepository
]);
@@ -71,7 +71,7 @@ protected function setUp()
*/
public function testGenerateEmptyCaseIdException()
{
- $this->CaseRescore->generate([]);
+ $this->caseRescore->generate([]);
}
/**
@@ -87,12 +87,12 @@ public function testGenerateNotFoundException()
->with(self::$data['caseId'])
->willReturn(null);
- $this->CaseRescore = $this->objectManager->getObject(CaseRescore::class, [
+ $this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
'caseRepository' => $this->caseRepository
]);
- $this->CaseRescore->generate(self::$data);
+ $this->caseRescore->generate(self::$data);
}
/**
@@ -109,7 +109,7 @@ public function testGenerateWithPreviousScore()
->with(self::$data['caseId'])
->willReturn($this->case);
- $this->CaseRescore = $this->objectManager->getObject(CaseRescore::class, [
+ $this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
'caseRepository' => $this->caseRepository
]);
@@ -117,9 +117,10 @@ public function testGenerateWithPreviousScore()
$phrase = __(
'Case Update: New score for the order is %1. Previous score was %2.',
self::$data['score'],
- self::$data['score']);
+ self::$data['score']
+ );
- $message = $this->CaseRescore->generate(self::$data);
+ $message = $this->caseRescore->generate(self::$data);
$this->assertEquals($phrase, $message);
}
@@ -134,7 +135,7 @@ public function testGenerateWithoutPreviousScore()
->with(self::$data['caseId'])
->willReturn($this->case);
- $this->CaseRescore = $this->objectManager->getObject(CaseRescore::class, [
+ $this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
'caseRepository' => $this->caseRepository
]);
@@ -142,10 +143,11 @@ public function testGenerateWithoutPreviousScore()
$phrase = __(
'Case Update: New score for the order is %1. Previous score was %2.',
self::$data['score'],
- null);
+ null
+ );
- $message = $this->CaseRescore->generate(self::$data);
+ $message = $this->caseRescore->generate(self::$data);
$this->assertEquals($phrase, $message);
}
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
index f27676be8d534..700a5de134bac 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
@@ -64,4 +64,4 @@ public function testGenerate()
$this->assertEquals($phrase, $message);
}
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
index 7e95d10bc3c6a..250ce1a7553a4 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
@@ -61,4 +61,4 @@ public function testGenerate()
$this->assertEquals($phrase, $message);
}
-}
\ No newline at end of file
+}
From dce616bc4757d02cea4d8bdd92447df73cf63bca Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Fri, 6 Jan 2017 07:40:24 -0600
Subject: [PATCH 093/225] MAGETWO-62806: Update case entity
- Code refactoring
- Fixed PHPDoc blocks
---
.../MessageGenerators/CaseCreationTest.php | 14 +++++--
.../MessageGenerators/CaseRescoreTest.php | 37 ++++++++++---------
.../MessageGenerators/CaseReviewTest.php | 14 +++++--
.../GuaranteeCompletionTest.php | 14 +++++--
4 files changed, 49 insertions(+), 30 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
index 639ffdf8c458c..a268dacd57dd2 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
@@ -8,6 +8,7 @@
use Magento\Signifyd\Model\MessageGenerators\CaseCreation;
use Magento\Signifyd\Model\Validators\CaseDataValidator;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\Phrase;
/**
* Tests for Signifyd CaseCreation message generator.
@@ -53,21 +54,26 @@ public function testGenerateException()
/**
* Checks interface generated message.
+ *
+ * @return Phrase
*/
public function testGenerateMessageInterface()
{
$message = $this->caseCreation->generate(self::$data);
- $this->assertInstanceOf(\Magento\Framework\Phrase::class, $message);
+ $this->assertInstanceOf(Phrase::class, $message);
+
+ return $message;
}
/**
* Generates case creation message for created Signifyd properly.
+ *
+ * @depends testGenerateMessageInterface
+ * @param Phrase $message
*/
- public function testGenerate()
+ public function testGenerate(Phrase $message)
{
- $message = $this->caseCreation->generate(self::$data);
-
$phrase = __('Signifyd Case %1 has been created for order.', self::$data['caseId']);
$this->assertEquals($phrase, $message);
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 1662d830289d3..a18927b811f3c 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -10,6 +10,7 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Tests for Signifyd CaseRescore message generator.
@@ -29,17 +30,17 @@ class CaseRescoreTest extends \PHPUnit_Framework_TestCase
private $objectManager;
/**
- * @var CaseRepository|MockObject
+ * @var CaseRepositoryInterface|MockObject
*/
private $caseRepository;
/**
- * @var CaseRescore|MocObject
+ * @var CaseRescore|MockObject
*/
private $caseRescore;
/**
- * @var Case|MockObject
+ * @var CaseInterface|MockObject
*/
private $case;
@@ -49,12 +50,12 @@ class CaseRescoreTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->case = $this->getMockBuilder(CaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ ->disableOriginalConstructor()
+ ->getMock();
$this->objectManager = new ObjectManager($this);
$this->caseRepository = $this->getMockBuilder(CaseRepositoryInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ ->disableOriginalConstructor()
+ ->getMock();
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
@@ -83,9 +84,9 @@ public function testGenerateEmptyCaseIdException()
public function testGenerateNotFoundException()
{
$this->caseRepository->expects($this->once())
- ->method('getByCaseId')
- ->with(self::$data['caseId'])
- ->willReturn(null);
+ ->method('getByCaseId')
+ ->with(self::$data['caseId'])
+ ->willReturn(null);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
@@ -101,13 +102,13 @@ public function testGenerateNotFoundException()
public function testGenerateWithPreviousScore()
{
$this->case->expects($this->once())
- ->method('getScore')
- ->willReturn(self::$data['score']);
+ ->method('getScore')
+ ->willReturn(self::$data['score']);
$this->caseRepository->expects($this->once())
- ->method('getByCaseId')
- ->with(self::$data['caseId'])
- ->willReturn($this->case);
+ ->method('getByCaseId')
+ ->with(self::$data['caseId'])
+ ->willReturn($this->case);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
@@ -131,9 +132,9 @@ public function testGenerateWithPreviousScore()
public function testGenerateWithoutPreviousScore()
{
$this->caseRepository->expects($this->once())
- ->method('getByCaseId')
- ->with(self::$data['caseId'])
- ->willReturn($this->case);
+ ->method('getByCaseId')
+ ->with(self::$data['caseId'])
+ ->willReturn($this->case);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
index 700a5de134bac..4bbf45aa77d5f 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
@@ -6,6 +6,7 @@
namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators;
use Magento\Signifyd\Model\MessageGenerators\CaseReview;
+use \Magento\Framework\Phrase;
/**
* Tests for Signifyd CaseReview message generator.
@@ -42,21 +43,26 @@ public function testGenerateException()
/**
* Checks interface generated message.
+ *
+ * @return \Magento\Framework\Phrase
*/
public function testGenerateMessageInterface()
{
$message = $this->caseReview->generate(self::$data);
- $this->assertInstanceOf(\Magento\Framework\Phrase::class, $message);
+ $this->assertInstanceOf(Phrase::class, $message);
+
+ return $message;
}
/**
* Generates Case Review message for created Signifyd properly.
+ *
+ * @depends testGenerateMessageInterface
+ * @param Phrase $message
*/
- public function testGenerate()
+ public function testGenerate(Phrase $message)
{
- $message = $this->caseReview->generate(self::$data);
-
$phrase = __(
'Case Update: Case Review was completed. Review Deposition is %1.',
__(self::$data['reviewDisposition'])
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
index 250ce1a7553a4..801d455b4f076 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
@@ -6,6 +6,7 @@
namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators;
use Magento\Signifyd\Model\MessageGenerators\GuaranteeCompletion;
+use \Magento\Framework\Phrase;
/**
* Tests for Signifyd GuaranteeCompletion message generator.
@@ -42,21 +43,26 @@ public function testGenerateException()
/**
* Checks interface generated Guarantee Completion message.
+ *
+ * @return Phrase
*/
public function testGenerateMessageInterface()
{
$message = $this->guaranteeCompletion->generate(self::$data);
- $this->assertInstanceOf(\Magento\Framework\Phrase::class, $message);
+ $this->assertInstanceOf(Phrase::class, $message);
+
+ return $message;
}
/**
* Generates Guarantee Completion message for created Signifyd properly.
+ *
+ * @depends testGenerateMessageInterface
+ * @param Phrase $message
*/
- public function testGenerate()
+ public function testGenerate(Phrase $message)
{
- $message = $this->guaranteeCompletion->generate(self::$data);
-
$phrase = __('Case Update: Guarantee Disposition is %1.', __(self::$data['guaranteeDisposition']));
$this->assertEquals($phrase, $message);
From 07de30ae4416703134ba2fcc4b5058115a0e56ec Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 6 Jan 2017 08:33:13 -0600
Subject: [PATCH 094/225] MAGETWO-62807: Case information block on order
details page in admin panel
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 157 ++++++++++++++++++
.../adminhtml/layout/sales_order_view.xml | 14 ++
.../view/adminhtml/templates/case_info.phtml | 54 ++++++
3 files changed, 225 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
create mode 100644 app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml
create mode 100644 app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
new file mode 100644
index 0000000000000..f2d29cd70170f
--- /dev/null
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -0,0 +1,157 @@
+config = $config;
+ $this->caseManagement = $caseManagement;
+
+ parent::__construct($context, $registry, $adminHelper, $data);
+ }
+
+ /**
+ * Retrieve required options from parent
+ *
+ * @throws \Magento\Framework\Exception\LocalizedException
+ * @return void
+ */
+ protected function _beforeToHtml()
+ {
+ if (!$this->getParentBlock()) {
+ throw new \Magento\Framework\Exception\LocalizedException(
+ __('Please correct the parent block for this block.')
+ );
+ }
+ $this->setOrder($this->getParentBlock()->getOrder());
+
+ foreach ($this->getParentBlock()->getOrderInfoData() as $key => $value) {
+ $this->setDataUsingMethod($key, $value);
+ }
+
+ parent::_beforeToHtml();
+ }
+
+ /**
+ * Checks if module is enabled.
+ *
+ * @return boolean
+ */
+ public function isModuleActive()
+ {
+ return $this->config->isActive();
+ }
+
+ /**
+ * Gets Case entity associated with order id.
+ *
+ * @return CaseInterface|null
+ */
+ public function getCaseEntity()
+ {
+ return $this->caseManagement->getByOrderId(
+ $this->getOrder()->getEntityId()
+ );
+ }
+
+ /**
+ * Gets state of case guarantee eligible.
+ *
+ * @param CaseInterface $caseEntity
+ * @return \Magento\Framework\Phrase
+ */
+ public function getGuaranteeEligible(CaseInterface $caseEntity) {
+ return $caseEntity->isGuaranteeEligible() ? __('Yes') : __('No');
+ }
+
+ /**
+ * Gets state of case guarantee eligible.
+ *
+ * @param CaseInterface $caseEntity
+ * @return string
+ */
+ public function getAssociatedTeam(CaseInterface $caseEntity) {
+
+ $result = 'unknown';
+ $team = $caseEntity->getAssociatedTeam();
+ if (isset($team['teamName'])) {
+ $result = $team['teamName'];
+ }
+
+ return $result;
+ }
+
+ /**
+ * Returns cell class name according to case score value.
+ * It could be used by merchant to customize order view skin.
+ *
+ * @param CaseInterface $caseEntity
+ * @return string
+ */
+ public function getScoreClass(CaseInterface $caseEntity)
+ {
+ $score = $caseEntity->getScore();
+
+ if (self::$scoreAccept <= $score) {
+ $result = 'green';
+ } elseif ($score <= self::$scoreDecline) {
+ $result = 'red';
+ } else {
+ $result = 'yellow';
+ }
+
+ return $result;
+ }
+}
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
new file mode 100644
index 0000000000000..2e1b692b009f4
--- /dev/null
+++ b/app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
new file mode 100644
index 0000000000000..90327fcfeb64f
--- /dev/null
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -0,0 +1,54 @@
+
+
+isModuleActive()) {
+ return '';
+ }
+
+ $case = $block->getCaseEntity();
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ escapeHtml($case->getStatus()); ?>
+ escapeHtml($case->getScore()); ?>
+ escapeHtml($block->getGuaranteeEligible($case)); ?>
+ escapeHtml($case->getGuaranteeDisposition()); ?>
+ escapeHtml($block->getAssociatedTeam($case)); ?>
+ escapeHtml($case->getReviewDisposition()); ?>
+ escapeHtml($case->getCreatedAt()); ?>
+ escapeHtml($case->getUpdatedAt()); ?>
+
+
+
+
+
+
+
+
+
From 53668bee934008b67835ca506588bd0e5c37e04d Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 6 Jan 2017 10:15:02 -0600
Subject: [PATCH 095/225] MAGETWO-62809: Controller integration tests
- Added integration test for webhook controller
- Generation message for order comment history moved before saving case entity
---
.../Signifyd/Controller/Webhooks/Handler.php | 2 +-
.../Signifyd/Model/CaseUpdatingService.php | 6 +-
.../Unit/Controller/Webhooks/HandlerTest.php | 3 +-
.../Unit/Model/CaseUpdatingServiceTest.php | 2 +-
.../Controller/Webhooks/HandlerTest.php | 95 +++++++++++++++++++
.../Magento/Signifyd/_files/webhook_body.json | 1 +
6 files changed, 101 insertions(+), 8 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/webhook_body.json
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
index 346e41c8fb12f..b513bb328db65 100644
--- a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
@@ -89,7 +89,7 @@ public function execute()
$caseUpdatingService->update($webhookMessage->getData());
} catch (LocalizedException $e) {
$this->getResponse()->setHttpResponseCode(400);
- $this->logger->error($e->getMessage());
+ $this->logger->critical($e);
}
}
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index 90364ea541582..996b8e144c122 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -77,11 +77,9 @@ public function update(array $data)
try {
$this->prepareCaseData($case, $data);
+ $orderHistoryComment = $this->messageGenerator->generate($data);
$this->caseRepository->save($case);
-
- // add comment to order history
- $message = $this->messageGenerator->generate($data);
- $this->commentsHistoryUpdater->addComment($case, $message);
+ $this->commentsHistoryUpdater->addComment($case, $orderHistoryComment);
} catch (\Exception $e) {
throw new LocalizedException(__('Cannot update Case entity.'), $e);
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
index 8fcec8433f87a..b9b29ae0766fa 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
@@ -201,8 +201,7 @@ public function testExecuteCaseUpdatingServiceException()
->method('setHttpResponseCode')
->with(400);
$this->logger->expects($this->once())
- ->method('error')
- ->with(__('Error'));
+ ->method('critical');
$this->controller->execute();
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
index 6c72190b0f16c..49d5fb676a71b 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
@@ -218,7 +218,7 @@ public function testUpdateWithExceptionFromMessageGenerator()
->with($caseId)
->willReturnSelf();
- $this->caseRepository->expects(self::once())
+ $this->caseRepository->expects(self::never())
->method('save')
->with($caseEntity)
->willReturn($caseEntity);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
new file mode 100644
index 0000000000000..49e9ee0296f79
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
@@ -0,0 +1,95 @@
+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();
+
+ static::assertNotEmpty($caseEntity);
+ static::assertEquals('2017-01-06 12:47:03', $caseEntity->getCreatedAt());
+ static::assertEquals('2017-01-06 12:47:03', $caseEntity->getUpdatedAt());
+ static::assertEquals(CaseInterface::GUARANTEE_PENDING, $caseEntity->getGuaranteeDisposition());
+ static::assertEquals('Magento', $caseEntity->getAssociatedTeam()['teamName']);
+ static::assertEquals(true, $caseEntity->isGuaranteeEligible());
+ static::assertEquals(CaseInterface::STATUS_OPEN, $caseEntity->getStatus());
+ static::assertEquals($orderEntityId, $caseEntity->getOrderId());
+
+ /** @var OrderRepositoryInterface $orderRepository */
+ $orderRepository = $this->_objectManager->get(OrderRepositoryInterface::class);
+ $order = $orderRepository->get($caseEntity->getOrderId());
+ $histories = $order->getStatusHistories();
+ static::assertNotEmpty($histories);
+
+ /** @var OrderStatusHistoryInterface $caseCreationComment */
+ $caseComment = array_pop($histories);
+ static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseComment);
+
+ static::assertEquals(
+ "Case Update: New score for the order is 384. Previous score was 553.",
+ $caseComment->getComment()
+ );
+ }
+
+ /**
+ * 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;
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/webhook_body.json b/dev/tests/integration/testsuite/Magento/Signifyd/_files/webhook_body.json
new file mode 100644
index 0000000000000..4308c8bf833ef
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/webhook_body.json
@@ -0,0 +1 @@
+{"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
From fe5f9c440920490fd06683f5922c5ffa62f96785 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 10 Jan 2017 04:45:21 -0600
Subject: [PATCH 096/225] MAGETWO-62807: Case information block on order
details page in admin panel
- static tests fix
---
app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php | 6 ++++--
.../Signifyd/view/adminhtml/templates/case_info.phtml | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index f2d29cd70170f..2a61f66144ed2 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -112,7 +112,8 @@ public function getCaseEntity()
* @param CaseInterface $caseEntity
* @return \Magento\Framework\Phrase
*/
- public function getGuaranteeEligible(CaseInterface $caseEntity) {
+ public function getGuaranteeEligible(CaseInterface $caseEntity)
+ {
return $caseEntity->isGuaranteeEligible() ? __('Yes') : __('No');
}
@@ -122,7 +123,8 @@ public function getGuaranteeEligible(CaseInterface $caseEntity) {
* @param CaseInterface $caseEntity
* @return string
*/
- public function getAssociatedTeam(CaseInterface $caseEntity) {
+ public function getAssociatedTeam(CaseInterface $caseEntity)
+ {
$result = 'unknown';
$team = $caseEntity->getAssociatedTeam();
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 90327fcfeb64f..eff571558f2b6 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -36,7 +36,7 @@
escapeHtml($case->getStatus()); ?>
- escapeHtml($case->getScore()); ?>
+ escapeHtml($case->getScore()); ?>
escapeHtml($block->getGuaranteeEligible($case)); ?>
escapeHtml($case->getGuaranteeDisposition()); ?>
escapeHtml($block->getAssociatedTeam($case)); ?>
From 32a891b502dc2e8e05b668be10b3666872039216 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 10 Jan 2017 05:03:01 -0600
Subject: [PATCH 097/225] MAGETWO-62809: Controller integration tests
- Remove webhook request object from object manager instances after test execution
---
.../Magento/Signifyd/Controller/Webhooks/HandlerTest.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
index 49e9ee0296f79..952f961298218 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
@@ -68,6 +68,8 @@ public function testExecuteSuccess()
"Case Update: New score for the order is 384. Previous score was 553.",
$caseComment->getComment()
);
+
+ $this->_objectManager->removeSharedInstance(WebhookRequest::class);
}
/**
From 881cf1426fc3fa0eaf188b467290325b37412be2 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 4 Jan 2017 09:25:47 -0600
Subject: [PATCH 098/225] MAGETWO-62822: Create Guarantee creation service
- existing gateway functionality covered with unit tests
---
.../Model/SignifydGateway/GatewayTest.php | 169 ++++++++++++++++++
1 file changed, 169 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
new file mode 100644
index 0000000000000..ea2d5986edd44
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -0,0 +1,169 @@
+createCaseBuilder = $this->getMockBuilder(CreateCaseBuilderInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->apiClient = $this->getMockBuilder(ApiClient::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $om = new ObjectManager($this);
+ $this->gateway = $om->getObject(Gateway::class, [
+ 'createCaseBuilder' => $this->createCaseBuilder,
+ 'apiClient' => $this->apiClient,
+ ]);
+ }
+
+ public function testCreateCaseForSpecifiedOrder()
+ {
+ $dummyOrderId = 1;
+ $dummySignifydInvestigationId = 42;
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willReturn([
+ 'investigationId' => $dummySignifydInvestigationId
+ ]);
+
+ $this->createCaseBuilder
+ ->expects($this->atLeastOnce())
+ ->method('build')
+ ->with($this->equalTo($dummyOrderId))
+ ->willReturn([]);
+
+ $this->gateway->createCase($dummyOrderId);
+ }
+
+ public function testCreateCaseCallsValidApiMethod()
+ {
+ $dummyOrderId = 1;
+ $dummySignifydInvestigationId = 42;
+ $this->createCaseBuilder
+ ->method('build')
+ ->willReturn([]);
+
+ $this->apiClient
+ ->expects($this->atLeastOnce())
+ ->method('makeApiCall')
+ ->with(
+ $this->equalTo('/cases'),
+ $this->equalTo('POST'),
+ $this->isType('array')
+ )
+ ->willReturn([
+ 'investigationId' => $dummySignifydInvestigationId
+ ]);
+
+ $this->gateway->createCase($dummyOrderId);
+
+ }
+
+ public function testCreateCaseNormalFlow()
+ {
+ $dummyOrderId = 1;
+ $dummySignifydInvestigationId = 42;
+ $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;
+ $apiCallFailureMessage = 'Api call failed';
+ $this->createCaseBuilder
+ ->method('build')
+ ->willReturn([]);
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willThrowException(new ApiCallException($apiCallFailureMessage));
+
+ $this->setExpectedException(
+ GatewayException::class,
+ $apiCallFailureMessage
+ );
+ $this->gateway->createCase($dummyOrderId);
+ }
+
+ public function testCreateCaseWithMissedResponseRequiredData()
+ {
+ $dummyOrderId = 1;
+ $this->createCaseBuilder
+ ->method('build')
+ ->willReturn([]);
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willReturn([
+ 'someOtherParameter' => 'foo',
+ ]);
+
+ $this->setExpectedException(GatewayException::class);
+ $this->gateway->createCase($dummyOrderId);
+ }
+
+ public function testCreateCaseWithAdditionalResponseData()
+ {
+ $dummyOrderId = 1;
+ $dummySignifydInvestigationId = 42;
+ $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'
+ );
+ }
+}
From d87f9d96e1dc3d0d7e517041817f91156bb2d33f Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 4 Jan 2017 09:41:02 -0600
Subject: [PATCH 099/225] MAGETWO-62822: Create Guarantee creation service
- added initial implementation of submitting case for guarantee to gateway
---
.../Model/SignifydGateway/Gateway.php | 18 ++++++++++++++++++
.../Model/SignifydGateway/GatewayTest.php | 19 +++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
index 2ffefb65937ee..218e917f15fa3 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
@@ -60,4 +60,22 @@ public function createCase($orderId)
return (int)$caseCreationResult['investigationId'];
}
+
+ /**
+ * @param int $signifydCaseId
+ * @return array
+ * @throws GatewayException
+ */
+ public function submitCaseForGuarantee($signifydCaseId)
+ {
+ $guaranteeCreationResult = $this->apiClient->makeApiCall(
+ '/guarantees',
+ 'POST',
+ [
+ 'caseId' => $signifydCaseId,
+ ]
+ );
+
+ return $guaranteeCreationResult;
+ }
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
index ea2d5986edd44..8d5fc9767ba7f 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -166,4 +166,23 @@ public function testCreateCaseWithAdditionalResponseData()
'Method must return value specified in "investigationId" response parameter and ignore any other parameters'
);
}
+
+ public function testCreateGuaranteeCallsValidApiMethod()
+ {
+ $dummySygnifydCaseId = 42;
+
+ $this->apiClient
+ ->expects($this->atLeastOnce())
+ ->method('makeApiCall')
+ ->with(
+ $this->equalTo('/guarantees'),
+ $this->equalTo('POST'),
+ $this->equalTo([
+ 'caseId' => $dummySygnifydCaseId
+ ])
+ );
+
+ $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+
+ }
}
From 371cde76c25e1f24e2421a65421d7a8b571a448d Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 04:31:40 -0600
Subject: [PATCH 100/225] MAGETWO-62822: Create Guarantee creation service
- implemented submitting case for the guarantee and covered with unit tests
- refactoring (constants described in Signifyd API added to Gateway)
---
.../Signifyd/Api/Data/CaseInterface.php | 27 +++--
.../Model/SignifydGateway/Gateway.php | 49 +++++++-
.../Model/SignifydGateway/GatewayTest.php | 111 +++++++++++++++++-
3 files changed, 172 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index 6a58effa19e4f..f534cd04da4c3 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Signifyd\Api\Data;
+use Magento\Signifyd\Model\SignifydGateway\Gateway;
+
/**
* Signifyd Case entity interface
*
@@ -16,29 +18,30 @@ interface CaseInterface
/**#@+
* Constants for case available statuses
*/
- const STATUS_OPEN = 'OPEN';
+ const STATUS_OPEN = Gateway::STATUS_OPEN;
const STATUS_PENDING = 'PENDING';
- const STATUS_PROCESSING = 'PROCESSING';
- const STATUS_FLAGGED = 'FLAGGED';
- const STATUS_DISMISSED = 'DISMISSED';
+ const STATUS_PROCESSING = Gateway::STATUS_PROCESSING;
+ const STATUS_FLAGGED = Gateway::STATUS_FLAGGED;
+ const STATUS_DISMISSED = Gateway::STATUS_DISMISSED;
/**#@-*/
/**#@+
* Constants for guarantee available statuses
*/
- const GUARANTEE_APPROVED = 'APPROVED';
- const GUARANTEE_DECLINED = 'DECLINED';
- const GUARANTEE_PENDING = 'PENDING';
- const GUARANTEE_CANCELED = 'CANCELED';
- const GUARANTEE_IN_REVIEW = 'IN_REVIEW';
+ const GUARANTEE_APPROVED = Gateway::GUARANTEE_APPROVED;
+ const GUARANTEE_DECLINED = Gateway::GUARANTEE_DECLINED;
+ const GUARANTEE_PENDING = Gateway::GUARANTEE_PENDING;
+ const GUARANTEE_CANCELED = Gateway::GUARANTEE_CANCELED;
+ const GUARANTEE_IN_REVIEW = Gateway::GUARANTEE_IN_REVIEW;
+ const GUARANTEE_UNREQUESTED = Gateway::GUARANTEE_UNREQUESTED;
/**#@-*/
/**#@+
* Constants for case available review dispositions
*/
- const DISPOSITION_GOOD = 'GOOD';
- const DISPOSITION_FRAUDULENT = 'FRAUDULENT';
- const DISPOSITION_UNSET = 'UNSET';
+ const DISPOSITION_GOOD = Gateway::DISPOSITION_GOOD;
+ const DISPOSITION_FRAUDULENT = Gateway::DISPOSITION_FRAUDULENT;
+ const DISPOSITION_UNSET = Gateway::DISPOSITION_UNSET;
/**#@-*/
/**
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
index 218e917f15fa3..930d5ef472a00 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
@@ -15,6 +15,34 @@
*/
class Gateway
{
+ /**#@+
+ * Constants for case available statuses
+ */
+ const STATUS_OPEN = 'OPEN';
+ const STATUS_PROCESSING = 'PROCESSING';
+ const STATUS_FLAGGED = 'FLAGGED';
+ const STATUS_DISMISSED = 'DISMISSED';
+ /**#@-*/
+
+ /**#@+
+ * Constants for guarantee available statuses
+ * @see https://www.signifyd.com/resources/manual/signifyd-guarantee/signifyd-guarantee/
+ */
+ const GUARANTEE_APPROVED = 'APPROVED';
+ const GUARANTEE_DECLINED = 'DECLINED';
+ const GUARANTEE_PENDING = 'PENDING';
+ const GUARANTEE_CANCELED = 'CANCELED';
+ const GUARANTEE_IN_REVIEW = 'IN_REVIEW';
+ const GUARANTEE_UNREQUESTED = 'UNREQUESTED';
+ /**#@-*/
+
+ /**#@+
+ * Constants for case available review dispositions
+ */
+ const DISPOSITION_GOOD = 'GOOD';
+ const DISPOSITION_FRAUDULENT = 'FRAUDULENT';
+ const DISPOSITION_UNSET = 'UNSET';
+
/**
* @var CreateCaseBuilderInterface
*/
@@ -76,6 +104,25 @@ public function submitCaseForGuarantee($signifydCaseId)
]
);
- return $guaranteeCreationResult;
+ if (!isset($guaranteeCreationResult['disposition'])) {
+ throw new GatewayException('Expected field "disposition" missed.');
+ }
+
+ $disposition = strtoupper($guaranteeCreationResult['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;
}
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
index 8d5fc9767ba7f..94f4aef036981 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -167,9 +167,10 @@ public function testCreateCaseWithAdditionalResponseData()
);
}
- public function testCreateGuaranteeCallsValidApiMethod()
+ public function testSubmitCaseForGuaranteeCallsValidApiMethod()
{
$dummySygnifydCaseId = 42;
+ $dummyDisposition = 'APPROVED';
$this->apiClient
->expects($this->atLeastOnce())
@@ -180,9 +181,115 @@ public function testCreateGuaranteeCallsValidApiMethod()
$this->equalTo([
'caseId' => $dummySygnifydCaseId
])
- );
+ )->willReturn([
+ 'disposition' => $dummyDisposition
+ ]);
+
+ $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+
+ }
+
+ public function testSubmitCaseForGuaranteeWithFailedApiCall()
+ {
+ $dummySygnifydCaseId = 42;
+ $apiCallFailureMessage = 'Api call failed';
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willThrowException(new ApiCallException($apiCallFailureMessage));
+
+ $this->setExpectedException(
+ GatewayException::class,
+ $apiCallFailureMessage
+ );
$this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ }
+ public function testSubmitCaseForGuaranteeReturnsDisposition()
+ {
+ $dummySygnifydCaseId = 42;
+ $dummyDisposition = 'APPROVED';
+ $dummyGuaranteeId = 123;
+ $dummyRereviewCount = 0;
+
+ $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;
+ $dummyGuaranteeId = 123;
+ $dummyRereviewCount = 0;
+
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willReturn([
+ 'guaranteeId' => $dummyGuaranteeId,
+ 'rereviewCount' => $dummyRereviewCount,
+ ]);
+
+ $this->setExpectedException(GatewayException::class);
+ $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ }
+
+ public function testSubmitCaseForGuaranteeWithUnexpectedDisposition()
+ {
+ $dummySygnifydCaseId = 42;
+ $dummyUnexpectedDisposition = 'UNEXPECTED';
+
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willReturn([
+ 'disposition' => $dummyUnexpectedDisposition,
+ ]);
+
+ $this->setExpectedException(GatewayException::class);
+ $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ }
+
+ /**
+ * @dataProvider supportedGuaranteeDispositionsProvider
+ */
+ public function testSubmitCaseForGuaranteeWithExpectedDisposition($dummyExpectedDisposition)
+ {
+ $dummySygnifydCaseId = 42;
+
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willReturn([
+ 'disposition' => $dummyExpectedDisposition,
+ ]);
+
+ $actualDisposition = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $this->assertEquals(
+ $dummyExpectedDisposition,
+ $actualDisposition,
+ 'Expected disposition should be return from method'
+ );
+ }
+
+ public function supportedGuaranteeDispositionsProvider()
+ {
+ return [
+ ['APPROVED'],
+ ['DECLINED'],
+ ['PENDING'],
+ ['CANCELED'],
+ ['IN_REVIEW'],
+ ['UNREQUESTED'],
+ ];
}
}
From 8a34b8230f8d297be1ddcd96fd9c7cabc93388b4 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 04:35:38 -0600
Subject: [PATCH 101/225] MAGETWO-62822: Create Guarantee creation service
- changed to named data sets in gateway unit test
---
.../Test/Unit/Model/SignifydGateway/GatewayTest.php | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
index 94f4aef036981..3a58a5db1ec43 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -284,12 +284,12 @@ public function testSubmitCaseForGuaranteeWithExpectedDisposition($dummyExpected
public function supportedGuaranteeDispositionsProvider()
{
return [
- ['APPROVED'],
- ['DECLINED'],
- ['PENDING'],
- ['CANCELED'],
- ['IN_REVIEW'],
- ['UNREQUESTED'],
+ 'APPROVED' => ['APPROVED'],
+ 'DECLINED' => ['DECLINED'],
+ 'PENDING' => ['PENDING'],
+ 'CANCELED' => ['CANCELED'],
+ 'IN_REVIEW' => ['IN_REVIEW'],
+ 'UNREQUESTED' => ['UNREQUESTED'],
];
}
}
From 4d570889886262318ea4f77f9238030fbd1a41c4 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 04:45:05 -0600
Subject: [PATCH 102/225] MAGETWO-62822: Create Guarantee creation service
- reimplementing gateway unit test without object manager
---
.../Test/Unit/Model/SignifydGateway/GatewayTest.php | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
index 3a58a5db1ec43..74be30f8544dd 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -7,7 +7,6 @@
use PHPUnit_Framework_TestCase as TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilderInterface;
@@ -40,11 +39,10 @@ public function setUp()
->disableOriginalConstructor()
->getMock();
- $om = new ObjectManager($this);
- $this->gateway = $om->getObject(Gateway::class, [
- 'createCaseBuilder' => $this->createCaseBuilder,
- 'apiClient' => $this->apiClient,
- ]);
+ $this->gateway = new Gateway(
+ $this->createCaseBuilder,
+ $this->apiClient
+ );
}
public function testCreateCaseForSpecifiedOrder()
From 88e8c8fd03a3354b96669e7d6ab32839d333ea42 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 04:54:09 -0600
Subject: [PATCH 103/225] MAGETWO-62822: Create Guarantee creation service
- changed copyright year
---
app/code/Magento/Signifyd/Api/Data/CaseInterface.php | 2 +-
app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php | 2 +-
.../Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index f534cd04da4c3..13b6564ad3323 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -1,6 +1,6 @@
Date: Tue, 10 Jan 2017 05:39:14 -0600
Subject: [PATCH 104/225] MAGETWO-62822: Create Guarantee creation service
- added links to Signifyd API docs
---
app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
index 2f732bef758c9..dfd21776e98ad 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
@@ -68,6 +68,8 @@ public function __construct(
}
/**
+ * @see https://www.signifyd.com/docs/api/#/reference/cases/create-a-case
+ *
* @param int $orderId
* @return int Signifyd case (investigation) identifier
* @throws GatewayException
@@ -90,6 +92,8 @@ public function createCase($orderId)
}
/**
+ * @see https://www.signifyd.com/docs/api/#/reference/guarantees/submit-a-case-for-guarantee
+ *
* @param int $signifydCaseId
* @return array
* @throws GatewayException
From 3499bde06272d249497a8e1bb59aac83c2c0294e Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 07:15:05 -0600
Subject: [PATCH 105/225] MAGETWO-63047: Add possibility to fetch raw HTTP
request data from Magento app request
---
.../Signifyd/Model/SignifydGateway/Response/WebhookRequest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
index 0a892dd02733d..4a77fa5245fe5 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
@@ -53,6 +53,6 @@ public function getEventTopic()
*/
public function getBody()
{
- return (string)@file_get_contents("php://input");
+ return (string)$this->request->getContent();
}
}
From cfcb2eab3a8d930a2f09e5addc4e13990b6437e1 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 10 Jan 2017 08:16:43 -0600
Subject: [PATCH 106/225] MAGETWO-62823: Update case entity on Guarantee
creation
- Added service to update case entity after guarantee submitting
- Added index for a case id
- Covered guarantee creation service by integration test
---
.../Model/Guarantee/CreationService.php | 92 +++++++++
.../MessageGenerators/GeneratorFactory.php | 9 +
.../MessageGenerators/GuaranteeCreation.php | 22 +++
.../Magento/Signifyd/Setup/InstallSchema.php | 17 +-
.../GeneratorFactoryTest.php | 2 +
.../GuaranteeCreationTest.php | 46 +++++
.../Model/Guarantee/CreationServiceTest.php | 175 ++++++++++++++++++
7 files changed, 360 insertions(+), 3 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCreation.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
new file mode 100644
index 0000000000000..574972289188c
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
@@ -0,0 +1,92 @@
+caseUpdatingServiceFactory = $caseUpdatingServiceFactory;
+ $this->gateway = $gateway;
+ $this->logger = $logger;
+ $this->caseManagement = $caseManagement;
+ }
+
+ /**
+ * Sends request to Signifyd to create guarantee for a case and updates case entity by retrieved data.
+ *
+ * @param int $orderId
+ * @return bool
+ */
+ public function create($orderId)
+ {
+ $caseEntity = $this->caseManagement->getByOrderId($orderId);
+ if ($caseEntity === null) {
+ $this->logger->error("Cannot find case entity for order entity id: {$orderId}");
+ return false;
+ }
+ $updatingService = $this->caseUpdatingServiceFactory->create('guarantees/creation');
+
+ try {
+ $data = $this->gateway->submitCaseForGuarantee($caseEntity->getCaseId());
+ $updatingService->update($data);
+ } catch (ApiCallException $e) {
+ $this->logger->error($e->getMessage());
+ return false;
+ } catch (GatewayException $e) {
+ $this->logger->error($e->getMessage());
+ return false;
+ } catch (LocalizedException $e) {
+ $this->logger->error($e->getMessage());
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
index 2b1b4a01b0ed3..4d0d12b03ebe8 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
@@ -37,6 +37,12 @@ class GeneratorFactory
*/
private static $guaranteeCompletion = 'guarantees/completion';
+ /**
+ * Type of message of Signifyd guarantee creation
+ * @var string
+ */
+ private static $guaranteeCreation = 'guarantees/creation';
+
/**
* CaseUpdatingServiceFactory constructor.
*
@@ -70,6 +76,9 @@ public function create($type)
case self::$guaranteeCompletion:
$className = GuaranteeCompletion::class;
break;
+ case self::$guaranteeCreation:
+ $className = GuaranteeCreation::class;
+ break;
default:
throw new \InvalidArgumentException('Specified message type does not supported.');
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCreation.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCreation.php
new file mode 100644
index 0000000000000..4c87b6cd5009b
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCreation.php
@@ -0,0 +1,22 @@
+getIdxName(
$setup->getTable(static::$table),
'order_id',
- \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
+ AdapterInterface::INDEX_TYPE_UNIQUE
),
'order_id',
- ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
+ ['type' => AdapterInterface::INDEX_TYPE_UNIQUE]
+ );
+
+ $table->addIndex(
+ $setup->getIdxName(
+ $setup->getTable(static::$table),
+ 'case_id',
+ AdapterInterface::INDEX_TYPE_UNIQUE
+ ),
+ 'case_id',
+ ['type' => AdapterInterface::INDEX_TYPE_UNIQUE]
);
$table->addForeignKey(
@@ -70,6 +80,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
Table::ACTION_SET_NULL
);
+
$connection->createTable($table);
}
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
index c154b22fcab2a..ddc71b60b3816 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
@@ -12,6 +12,7 @@
use Magento\Signifyd\Model\MessageGenerators\CaseReview;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
use Magento\Signifyd\Model\MessageGenerators\GuaranteeCompletion;
+use Magento\Signifyd\Model\MessageGenerators\GuaranteeCreation;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
@@ -81,6 +82,7 @@ public function typeDataProvider()
['cases/rescore', CaseRescore::class],
['cases/review', CaseReview::class],
['guarantees/completion', GuaranteeCompletion::class],
+ ['guarantees/creation', GuaranteeCreation::class],
];
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
new file mode 100644
index 0000000000000..dd90e4c57da1d
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
@@ -0,0 +1,46 @@
+generate($data);
+
+ static::assertEquals($message, $message);
+ static::assertInstanceOf(Phrase::class, $message);
+ }
+
+ /**
+ * Gets list of variations for input data.
+ *
+ * @return array
+ */
+ public function dataProvider()
+ {
+ $message = 'Case Update: Case is submitted for guarantee.';
+ return [
+ [[], $message],
+ [['caseId' => 123], $message],
+ ];
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
new file mode 100644
index 0000000000000..3547c6a8c8f29
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -0,0 +1,175 @@
+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::create
+ */
+ public function testCreateWithoutCaseEntity()
+ {
+ $orderId = 123;
+ $this->logger->expects(self::once())
+ ->method('error')
+ ->with('Cannot find case entity for order entity id: 123');
+
+ $this->gateway->expects(self::never())
+ ->method('submitCaseForGuarantee');
+
+ $result = $this->service->create($orderId);
+ self::assertFalse($result);
+ }
+
+ /**
+ * Checks a test case, when request is failing.
+ *
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ */
+ public function testCreateWithFailedRequest()
+ {
+ $caseEntity = $this->getCaseEntity();
+
+ $this->gateway->expects(self::once())
+ ->method('submitCaseForGuarantee')
+ ->willThrowException(new ApiCallException('Something wrong'));
+
+ $this->logger->expects(self::once())
+ ->method('error')
+ ->with('Something wrong');
+
+ $result = $this->service->create($caseEntity->getOrderId());
+ self::assertFalse($result);
+ }
+
+ /**
+ * Checks a test case, when case entity updating is failed.
+ *
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ */
+ public function testCreateWithFailedCaseUpdating()
+ {
+ $caseEntity = $this->getCaseEntity();
+
+ $this->gateway->expects(self::once())
+ ->method('submitCaseForGuarantee')
+ ->with($caseEntity->getCaseId())
+ ->willReturn([]);
+
+ $this->logger->expects(self::once())
+ ->method('error')
+ ->with('The "caseId" should not be empty.');
+
+ $result = $this->service->create($caseEntity->getOrderId());
+ self::assertFalse($result);
+ }
+
+ /**
+ * Checks a test case, when case entity is updated successfully.
+ *
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ */
+ public function testCreate()
+ {
+ $caseEntity = $this->getCaseEntity();
+ $data = [
+ 'caseId' => $caseEntity->getCaseId(),
+ 'guaranteeEligible' => true,
+ 'guaranteeDisposition' => CaseInterface::GUARANTEE_IN_REVIEW
+ ];
+
+ $this->gateway->expects(self::once())
+ ->method('submitCaseForGuarantee')
+ ->with($caseEntity->getCaseId())
+ ->willReturn($data);
+
+ $this->logger->expects(self::never())
+ ->method('error');
+
+ $result = $this->service->create($caseEntity->getOrderId());
+ self::assertTrue($result);
+
+ $updatedCase = $this->getCaseEntity();
+ self::assertEquals(CaseInterface::GUARANTEE_IN_REVIEW, $updatedCase->getGuaranteeDisposition());
+ self::assertTrue((bool) $updatedCase->isGuaranteeEligible());
+ self::assertEquals(CaseInterface::STATUS_PROCESSING, $updatedCase->getStatus());
+ }
+
+ /**
+ * 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);
+ }
+}
From bf8e06d495d34aa9874fea368da8022943777484 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 10 Jan 2017 09:26:51 -0600
Subject: [PATCH 107/225] MAGETWO-62821: Controller to submit for Guarantee
- Add controller to submit order for Guarantee
---
.../Controller/Adminhtml/Guarantee/Create.php | 60 ++++++++
.../Magento/Signifyd/etc/adminhtml/routes.xml | 14 ++
app/code/Magento/Signifyd/i18n/en_US.csv | 5 +-
.../Adminhtml/Guarantee/CreateTest.php | 134 ++++++++++++++++++
.../Model/CaseUpdatingServiceTest.php | 2 +-
5 files changed, 213 insertions(+), 2 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
create mode 100644 app/code/Magento/Signifyd/etc/adminhtml/routes.xml
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
diff --git a/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php b/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
new file mode 100644
index 0000000000000..7550a6d2c7ee3
--- /dev/null
+++ b/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
@@ -0,0 +1,60 @@
+creationService = $creationService;
+ }
+
+ public function execute()
+ {
+ $orderId = $this->getRequest()->getParam('orderId');
+ $resultRedirect = $this->resultRedirectFactory->create();
+
+ if (empty($orderId)) {
+ $this->messageManager->addErrorMessage(__('Order id is required.'));
+ $resultRedirect->setPath('sales/order/index');
+ return $resultRedirect;
+ }
+
+ $resultRedirect->setPath('sales/order/view', ['order_id' => $orderId]);
+ if ($this->creationService->create($orderId)) {
+ $this->messageManager->addSuccessMessage(
+ __('Order has been submitted for Guarantee.')
+ );
+ } else {
+ $this->messageManager->addErrorMessage(
+ __('Sorry, we can\'t submit order for Guarantee.')
+ );
+ }
+
+ return $resultRedirect;
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/routes.xml b/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
new file mode 100644
index 0000000000000..1f94759c1b7b6
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index a10f12073987f..fe940d75ef691 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -17,4 +17,7 @@
"Signifyd Case %1 has been created for order.","Signifyd Case %1 has been created for order."
"The "%1" should not be empty.","The "%1" should not be empty."
"Case entity not found.","Case entity not found."
-"Cannot update Case entity.","Cannot update Case entity."
\ No newline at end of file
+"Cannot update Case entity.","Cannot update Case entity."
+"Order has been submitted for Guarantee.","Order has been submitted for Guarantee."
+"Sorry, we can't submit order for Guarantee.","Sorry, we can't submit order for Guarantee."
+"Order id is required.","Order id is required."
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
new file mode 100644
index 0000000000000..46c7464105ff6
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
@@ -0,0 +1,134 @@
+creationService = $this->getMockBuilder(CreationService::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->_objectManager->addSharedInstance($this->creationService, CreationService::class);
+ }
+
+ /**
+ * Tests successful Guarantee creation for an order.
+ *
+ * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Create::execute
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoAppArea adminhtml
+ */
+ public function testExecuteSuccess()
+ {
+ $orderId = $this->getOrderId();
+ $this->getRequest()->setPostValue('orderId', $orderId);
+
+ $this->creationService->expects($this->once())
+ ->method('create')
+ ->with($orderId)
+ ->willReturn(true);
+
+ $this->dispatch(self::$entryPoint);
+
+ $this->assertRedirect($this->stringContains('backend/sales/order/view'));
+ $this->assertSessionMessages(
+ $this->equalTo(['Order has been submitted for Guarantee.']),
+ MessageInterface::TYPE_SUCCESS
+ );
+ }
+
+ /**
+ * Tests failure Guarantee creation due to empty order id.
+ *
+ * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Create::execute
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoAppArea adminhtml
+ */
+ public function testExecuteWithEmptyOrderId()
+ {
+ $orderId = '';
+ $this->getRequest()->setPostValue('orderId', $orderId);
+
+ $this->creationService->expects($this->never())
+ ->method('create');
+
+ $this->dispatch(self::$entryPoint);
+
+ $this->assertRedirect($this->stringContains('backend/sales/order/index'));
+ $this->assertSessionMessages(
+ $this->equalTo(['Order id is required.']),
+ MessageInterface::TYPE_ERROR
+ );
+ }
+
+ /**
+ * Tests failure Guarantee creation due to unsuccessful CreationService call.
+ *
+ * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Create::execute
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoAppArea adminhtml
+ */
+ public function testExecuteWithCreationServiceFail()
+ {
+ $orderId = $this->getOrderId();
+ $this->getRequest()->setPostValue('orderId', $orderId);
+
+ $this->creationService->expects($this->once())
+ ->method('create')
+ ->with($orderId)
+ ->willReturn(false);
+
+ $this->dispatch(self::$entryPoint);
+
+ $this->assertRedirect($this->stringContains('backend/sales/order/view'));
+ $this->assertSessionMessages(
+ $this->equalTo(['Sorry, we can't submit order for Guarantee.']),
+ MessageInterface::TYPE_ERROR
+ );
+ }
+
+ /**
+ * Returns orderId from case in fixture
+ *
+ * @return int
+ */
+ private function getOrderId()
+ {
+ $caseId = 123;
+ /** @var CaseRepositoryInterface $caseRepository */
+ $caseRepository = $this->_objectManager->get(CaseRepositoryInterface::class);
+ /** @var CaseInterface $caseEntity */
+ $caseEntity = $caseRepository->getByCaseId($caseId);
+
+ return $caseEntity->getOrderId();
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
index 2fb3d0481a2e3..25af28570737c 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
@@ -69,7 +69,7 @@ public function testUpdate()
$this->service->update($data);
- /** @var CaseRepositoryInterface $caseManagement */
+ /** @var CaseRepositoryInterface $caseRepository */
$caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
/** @var CaseInterface $caseEntity */
$caseEntity = $caseRepository->getByCaseId($caseId);
From cf33015f1a7bc579d6fa873c0ca5280ad7567793 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 10 Jan 2017 09:31:42 -0600
Subject: [PATCH 108/225] MAGETWO-62821: Controller to submit for Guarantee
- Add correct annotation
---
.../Signifyd/Controller/Adminhtml/Guarantee/Create.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php b/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
index 7550a6d2c7ee3..ea0ac3654e32b 100644
--- a/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
+++ b/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
@@ -10,7 +10,7 @@
use Magento\Signifyd\Model\Guarantee\CreationService;
/**
- * Responsible for submitting case for Guarantee.
+ * Responsible for submitting order for Guarantee.
*
* @see https://www.signifyd.com/docs/api/#/reference/guarantees/create-guarantee
*/
@@ -33,6 +33,11 @@ public function __construct(
$this->creationService = $creationService;
}
+ /**
+ * Submits order for Guarantee and redirects user to order page with result message
+ *
+ * @return \Magento\Framework\Controller\Result\Redirect
+ */
public function execute()
{
$orderId = $this->getRequest()->getParam('orderId');
From 3992cd8189a2772296972b9a91ea3a9a592f59eb Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 10 Jan 2017 11:06:06 -0600
Subject: [PATCH 109/225] MAGETWO-62823: Update case entity on Guarantee
creation
- Updated integration test
---
.../Model/Guarantee/CreationServiceTest.php | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
index 3547c6a8c8f29..c9ee755912e2f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -6,6 +6,8 @@
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\ApiCallException;
@@ -159,6 +161,18 @@ public function testCreate()
self::assertEquals(CaseInterface::GUARANTEE_IN_REVIEW, $updatedCase->getGuaranteeDisposition());
self::assertTrue((bool) $updatedCase->isGuaranteeEligible());
self::assertEquals(CaseInterface::STATUS_PROCESSING, $updatedCase->getStatus());
+
+ /** @var OrderRepositoryInterface $orderRepository */
+ $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
+ $order = $orderRepository->get($updatedCase->getOrderId());
+ $histories = $order->getStatusHistories();
+ static::assertNotEmpty($histories);
+
+
+ /** @var OrderStatusHistoryInterface $caseCreationComment */
+ $caseCreationComment = array_pop($histories);
+ static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
+ static::assertEquals('Case Update: Case is submitted for guarantee.', $caseCreationComment->getComment());
}
/**
From 4223f6f33ef34810279abe5654e23a7a1b7c50cb Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 10 Jan 2017 11:41:35 -0600
Subject: [PATCH 110/225] MAGETWO-62806: Update case entity
- Renamed validator
---
.../Signifyd/Model/CaseUpdatingService.php | 14 ++++++------
.../Model/MessageGenerators/CaseCreation.php | 14 ++++++------
.../Model/MessageGenerators/CaseRescore.php | 14 ++++++------
...eDataValidator.php => CaseIdValidator.php} | 2 +-
.../Unit/Model/CaseUpdatingServiceTest.php | 22 +++++++++----------
.../MessageGenerators/CaseCreationTest.php | 4 ++--
.../MessageGenerators/CaseRescoreTest.php | 14 ++++++------
7 files changed, 42 insertions(+), 42 deletions(-)
rename app/code/Magento/Signifyd/Model/Validators/{CaseDataValidator.php => CaseIdValidator.php} (95%)
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index 996b8e144c122..a4ca6b8b716a7 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -9,7 +9,7 @@
use Magento\Framework\Exception\NotFoundException;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Model\Validators\CaseDataValidator;
+use Magento\Signifyd\Model\Validators\CaseIdValidator;
/**
* Performs Signifyd case entity updating operations.
@@ -27,9 +27,9 @@ class CaseUpdatingService implements CaseUpdatingServiceInterface
private $caseRepository;
/**
- * @var CaseDataValidator
+ * @var CaseIdValidator
*/
- private $caseDataValidator;
+ private $caseIdValidator;
/**
* @var CommentsHistoryUpdater
@@ -41,18 +41,18 @@ class CaseUpdatingService implements CaseUpdatingServiceInterface
*
* @param MessageGeneratorInterface $messageGenerator
* @param CaseRepositoryInterface $caseRepository
- * @param CaseDataValidator $caseDataValidator
+ * @param CaseIdValidator $caseIdValidator
* @param CommentsHistoryUpdater $commentsHistoryUpdater
*/
public function __construct(
MessageGeneratorInterface $messageGenerator,
CaseRepositoryInterface $caseRepository,
- CaseDataValidator $caseDataValidator,
+ CaseIdValidator $caseIdValidator,
CommentsHistoryUpdater $commentsHistoryUpdater
) {
$this->messageGenerator = $messageGenerator;
$this->caseRepository = $caseRepository;
- $this->caseDataValidator = $caseDataValidator;
+ $this->caseIdValidator = $caseIdValidator;
$this->commentsHistoryUpdater = $commentsHistoryUpdater;
}
@@ -66,7 +66,7 @@ public function __construct(
*/
public function update(array $data)
{
- if (!$this->caseDataValidator->validate($data)) {
+ if (!$this->caseIdValidator->validate($data)) {
throw new LocalizedException(__('The "%1" should not be empty.', 'caseId'));
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
index 72165538956b4..a9affc97bbe4a 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
@@ -7,7 +7,7 @@
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
-use Magento\Signifyd\Model\Validators\CaseDataValidator;
+use Magento\Signifyd\Model\Validators\CaseIdValidator;
/**
* Generates message for created Signifyd case.
@@ -15,18 +15,18 @@
class CaseCreation implements MessageGeneratorInterface
{
/**
- * @var CaseDataValidator
+ * @var CaseIdValidator
*/
- private $caseDataValidator;
+ private $caseIdValidator;
/**
* CaseCreation constructor.
*
- * @param CaseDataValidator $caseDataValidator
+ * @param CaseIdValidator $caseIdValidator
*/
- public function __construct(CaseDataValidator $caseDataValidator)
+ public function __construct(CaseIdValidator $caseIdValidator)
{
- $this->caseDataValidator = $caseDataValidator;
+ $this->caseIdValidator = $caseIdValidator;
}
/**
@@ -34,7 +34,7 @@ public function __construct(CaseDataValidator $caseDataValidator)
*/
public function generate(array $data)
{
- if (!$this->caseDataValidator->validate($data)) {
+ if (!$this->caseIdValidator->validate($data)) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
index 0f184590d4946..b2ff54c5c1c3b 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -8,7 +8,7 @@
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
-use Magento\Signifyd\Model\Validators\CaseDataValidator;
+use Magento\Signifyd\Model\Validators\CaseIdValidator;
/**
* Generates message based on previous and current Case scores.
@@ -21,20 +21,20 @@ class CaseRescore implements MessageGeneratorInterface
private $caseRepository;
/**
- * @var CaseDataValidator
+ * @var CaseIdValidator
*/
- private $caseDataValidator;
+ private $caseIdValidator;
/**
* CaseRescore constructor.
*
* @param CaseRepositoryInterface $caseRepository
- * @param CaseDataValidator $caseDataValidator
+ * @param CaseIdValidator $caseIdValidator
*/
- public function __construct(CaseRepositoryInterface $caseRepository, CaseDataValidator $caseDataValidator)
+ public function __construct(CaseRepositoryInterface $caseRepository, CaseIdValidator $caseIdValidator)
{
$this->caseRepository = $caseRepository;
- $this->caseDataValidator = $caseDataValidator;
+ $this->caseIdValidator = $caseIdValidator;
}
/**
@@ -42,7 +42,7 @@ public function __construct(CaseRepositoryInterface $caseRepository, CaseDataVal
*/
public function generate(array $data)
{
- if (!$this->caseDataValidator->validate($data)) {
+ if (!$this->caseIdValidator->validate($data)) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
diff --git a/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php b/app/code/Magento/Signifyd/Model/Validators/CaseIdValidator.php
similarity index 95%
rename from app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
rename to app/code/Magento/Signifyd/Model/Validators/CaseIdValidator.php
index 9827984956f54..2dea2b30235c3 100644
--- a/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
+++ b/app/code/Magento/Signifyd/Model/Validators/CaseIdValidator.php
@@ -8,7 +8,7 @@
/**
* Validates Signifyd Case id field.
*/
-class CaseDataValidator
+class CaseIdValidator
{
/**
* Checks if data object contains Signifyd Case id.
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
index 49d5fb676a71b..2d09cbc8a540b 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
@@ -12,7 +12,7 @@
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
-use Magento\Signifyd\Model\Validators\CaseDataValidator;
+use Magento\Signifyd\Model\Validators\CaseIdValidator;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
@@ -41,9 +41,9 @@ class CaseUpdatingServiceTest extends \PHPUnit_Framework_TestCase
private $caseRepository;
/**
- * @var CaseDataValidator|MockObject
+ * @var CaseIdValidator|MockObject
*/
- private $caseDataValidator;
+ private $caseIdValidator;
/**
* @var CommentsHistoryUpdater|MockObject
@@ -67,7 +67,7 @@ protected function setUp()
->setMethods(['getByCaseId'])
->getMockForAbstractClass();
- $this->caseDataValidator = $this->getMockBuilder(CaseDataValidator::class)
+ $this->caseIdValidator = $this->getMockBuilder(CaseIdValidator::class)
->disableOriginalConstructor()
->setMethods(['validate'])
->getMock();
@@ -80,7 +80,7 @@ protected function setUp()
$this->service = $this->objectManager->getObject(CaseUpdatingService::class, [
'messageGenerator' => $this->messageGenerator,
'caseRepository' => $this->caseRepository,
- 'caseDataValidator' => $this->caseDataValidator,
+ 'caseIdValidator' => $this->caseIdValidator,
'commentsHistoryUpdater' => $this->commentsHistoryUpdater
]);
}
@@ -95,7 +95,7 @@ protected function setUp()
public function testUpdateWithFailedValidation()
{
$data = [];
- $this->caseDataValidator->expects(self::once())
+ $this->caseIdValidator->expects(self::once())
->method('validate')
->with($data)
->willReturn(false);
@@ -117,7 +117,7 @@ public function testUpdateWithNotExistingCase()
'caseId' => $caseId
];
- $this->caseDataValidator->expects(self::once())
+ $this->caseIdValidator->expects(self::once())
->method('validate')
->with($data)
->willReturn(true);
@@ -147,7 +147,7 @@ public function testUpdateWithFailedCaseSaving()
'score' => 500
];
- $this->caseDataValidator->expects(self::once())
+ $this->caseIdValidator->expects(self::once())
->method('validate')
->with($data)
->willReturn(true);
@@ -198,7 +198,7 @@ public function testUpdateWithExceptionFromMessageGenerator()
'caseId' => $caseId
];
- $this->caseDataValidator->expects(self::once())
+ $this->caseIdValidator->expects(self::once())
->method('validate')
->with($data)
->willReturn(true);
@@ -245,7 +245,7 @@ public function testUpdateWithFailedCommentSaving()
'caseId' => $caseId
];
- $this->caseDataValidator->expects(self::once())
+ $this->caseIdValidator->expects(self::once())
->method('validate')
->with($data)
->willReturn(true);
@@ -296,7 +296,7 @@ public function testUpdate()
'caseId' => $caseId
];
- $this->caseDataValidator->expects(self::once())
+ $this->caseIdValidator->expects(self::once())
->method('validate')
->with($data)
->willReturn(true);
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
index a268dacd57dd2..1daa58f6917d9 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators;
use Magento\Signifyd\Model\MessageGenerators\CaseCreation;
-use Magento\Signifyd\Model\Validators\CaseDataValidator;
+use Magento\Signifyd\Model\Validators\CaseIdValidator;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\Phrase;
@@ -37,7 +37,7 @@ protected function setUp()
$this->objectManager = new ObjectManager($this);
$this->caseCreation = $this->objectManager->getObject(CaseCreation::class, [
- 'caseDataValidator' => new CaseDataValidator()
+ 'caseIdValidator' => new CaseIdValidator()
]);
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index a18927b811f3c..21d08fa5afb1f 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators;
use Magento\Signifyd\Model\MessageGenerators\CaseRescore;
-use Magento\Signifyd\Model\Validators\CaseDataValidator;
+use Magento\Signifyd\Model\Validators\CaseIdValidator;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
@@ -58,7 +58,7 @@ protected function setUp()
->getMock();
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseDataValidator' => new CaseDataValidator(),
+ 'caseIdValidator' => new CaseIdValidator(),
'caseRepository' => $this->caseRepository
]);
@@ -89,7 +89,7 @@ public function testGenerateNotFoundException()
->willReturn(null);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseDataValidator' => new CaseDataValidator(),
+ 'caseIdValidator' => new CaseIdValidator(),
'caseRepository' => $this->caseRepository
]);
@@ -111,8 +111,8 @@ public function testGenerateWithPreviousScore()
->willReturn($this->case);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseDataValidator' => new CaseDataValidator(),
- 'caseRepository' => $this->caseRepository
+ 'caseIdValidator' => new CaseIdValidator(),
+ 'caseRepository' => $this->caseRepository
]);
$phrase = __(
@@ -137,8 +137,8 @@ public function testGenerateWithoutPreviousScore()
->willReturn($this->case);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseDataValidator' => new CaseDataValidator(),
- 'caseRepository' => $this->caseRepository
+ 'caseIdValidator' => new CaseIdValidator(),
+ 'caseRepository' => $this->caseRepository
]);
$phrase = __(
From 3c578aa8c9d82360fa453683e5186939ac27a98a Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 11 Jan 2017 03:52:18 -0600
Subject: [PATCH 111/225] MAGETWO-62822: Create Guarantee creation service
- fixed doc blocks
---
app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
index dfd21776e98ad..9e437ecff1be6 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
@@ -68,6 +68,7 @@ public function __construct(
}
/**
+ * Returns id of created case (investigation) on Signifyd service
* @see https://www.signifyd.com/docs/api/#/reference/cases/create-a-case
*
* @param int $orderId
@@ -92,10 +93,11 @@ public function createCase($orderId)
}
/**
+ * Returns guaranty decision result
* @see https://www.signifyd.com/docs/api/#/reference/guarantees/submit-a-case-for-guarantee
*
* @param int $signifydCaseId
- * @return array
+ * @return string
* @throws GatewayException
*/
public function submitCaseForGuarantee($signifydCaseId)
From a27c6fe5c4a7be533491ab0a882401a6fa728478 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 11 Jan 2017 04:26:48 -0600
Subject: [PATCH 112/225] MAGETWO-62807: Case information block on order
details page in admin panel
- Covered with integration test
---
.../view/adminhtml/templates/case_info.phtml | 9 +-
.../Signifyd/Block/Adminhtml/CaseInfoTest.php | 112 ++++++++++++++++++
.../Signifyd/Block/FingerprintTest.php | 1 -
3 files changed, 113 insertions(+), 9 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index eff571558f2b6..adcbb6f924609 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -8,11 +8,9 @@
?>
isModuleActive()) {
+ if (!$block->isModuleActive() || !($case = $block->getCaseEntity())) {
return '';
}
-
- $case = $block->getCaseEntity();
?>
-
escapeHtml($case->getStatus()); ?>
@@ -45,10 +42,6 @@
escapeHtml($case->getUpdatedAt()); ?>
-
-
-
-
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
new file mode 100644
index 0000000000000..52cb4865eff96
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -0,0 +1,112 @@
+loadArea(Area::AREA_ADMINHTML);
+
+ $objectManager = Bootstrap::getObjectManager();
+ $this->order = $objectManager->create(Order::class);
+ $this->registry = $objectManager->get(Registry::class);
+ $this->layout = $objectManager->get(LayoutInterface::class);
+ }
+
+ /**
+ * Checks that block does not give contents
+ * if Signifyd module is inactive.
+ *
+ * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::isModuleActive
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 0
+ */
+ public function testModuleIsInactive()
+ {
+ static::assertEmpty($this->getBlockContents());
+ }
+
+ /**
+ * 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
+ */
+ public function testCaseEntityNotExists()
+ {
+ $this->registry->register('current_order', $this->order->loadByIncrementId('100000001'));
+
+ static::assertEmpty($this->getBlockContents());
+ }
+
+ /**
+ * Checks that:
+ * - block give contents
+ * - associated team displays correct
+ * - score class displays correct
+ *
+ * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getAssociatedTeam
+ * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getScoreClass
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ */
+ public function testCaseEntityExists()
+ {
+ $this->registry->register('current_order', $this->order->loadByIncrementId('100000001'));
+
+ $html = $this->getBlockContents();
+ static::assertNotEmpty($html);
+ static::assertContains('Some Team', $html);
+ static::assertContains('col-case-score-green', $html);
+ }
+
+ /**
+ * Renders block contents.
+ *
+ * @return string
+ */
+ private function getBlockContents()
+ {
+ /** @var CaseInfo $block */
+ $block = $this->layout->createBlock(CaseInfo::class, 'order_case_info');
+ $block->setTemplate('Magento_Signifyd::case_info.phtml');
+
+ /** @var OrderTabInfo $parent */
+ $parent = $this->layout->createBlock(OrderTabInfo::class, 'order_tab_info');
+ $parent->setChild('order_case_info', $block);
+
+ return $block->toHtml();
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
index 6708af55dddf9..a9780a560381f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
@@ -8,7 +8,6 @@
use Magento\Framework\App\Area;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\View\LayoutInterface;
-use Magento\Signifyd\Block\Fingerprint;
use Magento\TestFramework\Helper\Bootstrap;
class FingerprintTest extends \PHPUnit_Framework_TestCase
From 34dcb55f526269138bc86888f3fee1cc20c8abd8 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 11 Jan 2017 04:42:33 -0600
Subject: [PATCH 113/225] MAGETWO-62822: Create Guarantee creation service
- refactored unit test for more explicit failure reason
---
.../Unit/Model/SignifydGateway/GatewayTest.php | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
index f84300af354bd..b8bc60ebf77e9 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -271,12 +271,15 @@ public function testSubmitCaseForGuaranteeWithExpectedDisposition($dummyExpected
'disposition' => $dummyExpectedDisposition,
]);
- $actualDisposition = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
- $this->assertEquals(
- $dummyExpectedDisposition,
- $actualDisposition,
- 'Expected disposition should be return from method'
- );
+ try {
+ $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ } catch (GatewayException $e) {
+ $this->fail(sprintf(
+ 'Expected disposition "%s" was not accepted with message "%s"',
+ $dummyExpectedDisposition,
+ $e->getMessage()
+ ));
+ }
}
public function supportedGuaranteeDispositionsProvider()
From 1ba93c37ea8e4e728fb5e0a52837aaf07726790c Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 11 Jan 2017 05:12:32 -0600
Subject: [PATCH 114/225] MAGETWO-62823: Update case entity on Guarantee
creation
- Updated service according to gateway changes
---
.../Signifyd/Model/Guarantee/CreationService.php | 12 ++++++++++--
.../Model/Guarantee/CreationServiceTest.php | 13 +++----------
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
index 574972289188c..18e500446b105 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
@@ -6,12 +6,12 @@
namespace Magento\Signifyd\Model\Guarantee;
use Magento\Framework\Exception\LocalizedException;
+use Magento\Signifyd\Model\CaseManagement;
use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Psr\Log\LoggerInterface;
-use Magento\Signifyd\Model\CaseManagement;
/**
* Register guarantee at Signifyd and updates case entity
@@ -74,7 +74,15 @@ public function create($orderId)
$updatingService = $this->caseUpdatingServiceFactory->create('guarantees/creation');
try {
- $data = $this->gateway->submitCaseForGuarantee($caseEntity->getCaseId());
+ $disposition = $this->gateway->submitCaseForGuarantee($caseEntity->getCaseId());
+ if (!$disposition) {
+ $this->logger->error("Cannot retrieve guarantee disposition for case: {$caseEntity->getEntityId()}.");
+ return false;
+ }
+ $data = [
+ 'caseId' => $caseEntity->getCaseId(),
+ 'guaranteeDisposition' => $disposition
+ ];
$updatingService->update($data);
} catch (ApiCallException $e) {
$this->logger->error($e->getMessage());
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
index c9ee755912e2f..be529923f2fae 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -120,11 +120,11 @@ public function testCreateWithFailedCaseUpdating()
$this->gateway->expects(self::once())
->method('submitCaseForGuarantee')
->with($caseEntity->getCaseId())
- ->willReturn([]);
+ ->willReturn('');
$this->logger->expects(self::once())
->method('error')
- ->with('The "caseId" should not be empty.');
+ ->with('Cannot retrieve guarantee disposition for case: ' . $caseEntity->getEntityId() . '.');
$result = $this->service->create($caseEntity->getOrderId());
self::assertFalse($result);
@@ -140,16 +140,11 @@ public function testCreateWithFailedCaseUpdating()
public function testCreate()
{
$caseEntity = $this->getCaseEntity();
- $data = [
- 'caseId' => $caseEntity->getCaseId(),
- 'guaranteeEligible' => true,
- 'guaranteeDisposition' => CaseInterface::GUARANTEE_IN_REVIEW
- ];
$this->gateway->expects(self::once())
->method('submitCaseForGuarantee')
->with($caseEntity->getCaseId())
- ->willReturn($data);
+ ->willReturn(CaseInterface::GUARANTEE_IN_REVIEW);
$this->logger->expects(self::never())
->method('error');
@@ -159,7 +154,6 @@ public function testCreate()
$updatedCase = $this->getCaseEntity();
self::assertEquals(CaseInterface::GUARANTEE_IN_REVIEW, $updatedCase->getGuaranteeDisposition());
- self::assertTrue((bool) $updatedCase->isGuaranteeEligible());
self::assertEquals(CaseInterface::STATUS_PROCESSING, $updatedCase->getStatus());
/** @var OrderRepositoryInterface $orderRepository */
@@ -168,7 +162,6 @@ public function testCreate()
$histories = $order->getStatusHistories();
static::assertNotEmpty($histories);
-
/** @var OrderStatusHistoryInterface $caseCreationComment */
$caseCreationComment = array_pop($histories);
static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
From 1ffffac9a7a6264bec1eada0aab4db532afd1187 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 11 Jan 2017 05:52:28 -0600
Subject: [PATCH 115/225] MAGETWO-62807: Case information block on order
details page in admin panel
- copyrights
---
app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php | 2 +-
.../Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml | 2 +-
.../Magento/Signifyd/view/adminhtml/templates/case_info.phtml | 2 +-
.../testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php | 2 +-
.../testsuite/Magento/Signifyd/Block/FingerprintTest.php | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 2a61f66144ed2..febea5219a2a4 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -1,6 +1,6 @@
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index adcbb6f924609..be4a8d993d0ff 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -1,6 +1,6 @@
Date: Wed, 11 Jan 2017 07:18:40 -0600
Subject: [PATCH 116/225] MAGETWO-62806: Update case entity
- Renamed method
---
app/code/Magento/Signifyd/Model/CaseUpdatingService.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index a4ca6b8b716a7..69263c9fef970 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -76,7 +76,7 @@ public function update(array $data)
}
try {
- $this->prepareCaseData($case, $data);
+ $this->setCaseData($case, $data);
$orderHistoryComment = $this->messageGenerator->generate($data);
$this->caseRepository->save($case);
$this->commentsHistoryUpdater->addComment($case, $orderHistoryComment);
@@ -92,7 +92,7 @@ public function update(array $data)
* @param array $data
* @return void
*/
- private function prepareCaseData(CaseInterface $case, array $data)
+ private function setCaseData(CaseInterface $case, array $data)
{
// list of keys which should not be replaced, like order id
$notResolvedKeys = [
From 8b47d09e57e0b5fa9467fa9e889b08018f89890f Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 11 Jan 2017 09:19:20 -0600
Subject: [PATCH 117/225] MAGETWO-62821: Controller to submit for Guarantee
- Fix static
---
.../Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
index 46c7464105ff6..7375ff8c6d983 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
@@ -1,7 +1,6 @@
Date: Wed, 11 Jan 2017 10:28:54 -0600
Subject: [PATCH 118/225] MAGETWO-62806: Update case entity
- Simplified messages generators
- Removed case id validator
---
.../Signifyd/Model/CaseUpdatingService.php | 11 +--
.../Model/MessageGenerators/BaseGenerator.php | 58 +++++++++++++
.../Model/MessageGenerators/CaseCreation.php | 43 ----------
.../Model/MessageGenerators/CaseRescore.php | 12 +--
.../Model/MessageGenerators/CaseReview.php | 30 -------
.../MessageGenerators/GeneratorFactory.php | 23 +++--
.../MessageGenerators/GuaranteeCompletion.php | 27 ------
.../MessageGenerators/GuaranteeCreation.php | 22 -----
.../Model/Validators/CaseIdValidator.php | 26 ------
.../Unit/Model/CaseUpdatingServiceTest.php | 41 ---------
.../MessageGenerators/BaseGeneratorTest.php | 83 +++++++++++++++++++
.../MessageGenerators/CaseCreationTest.php | 81 ------------------
.../MessageGenerators/CaseRescoreTest.php | 15 ++--
.../MessageGenerators/CaseReviewTest.php | 73 ----------------
.../GeneratorFactoryTest.php | 15 ++--
.../GuaranteeCompletionTest.php | 70 ----------------
.../GuaranteeCreationTest.php | 46 ----------
.../Model/CaseUpdatingServiceTest.php | 5 +-
18 files changed, 177 insertions(+), 504 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php
delete mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
delete mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
delete mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
delete mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCreation.php
delete mode 100644 app/code/Magento/Signifyd/Model/Validators/CaseIdValidator.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index 69263c9fef970..bf39d2356a28d 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -9,7 +9,6 @@
use Magento\Framework\Exception\NotFoundException;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Model\Validators\CaseIdValidator;
/**
* Performs Signifyd case entity updating operations.
@@ -26,11 +25,6 @@ class CaseUpdatingService implements CaseUpdatingServiceInterface
*/
private $caseRepository;
- /**
- * @var CaseIdValidator
- */
- private $caseIdValidator;
-
/**
* @var CommentsHistoryUpdater
*/
@@ -41,18 +35,15 @@ class CaseUpdatingService implements CaseUpdatingServiceInterface
*
* @param MessageGeneratorInterface $messageGenerator
* @param CaseRepositoryInterface $caseRepository
- * @param CaseIdValidator $caseIdValidator
* @param CommentsHistoryUpdater $commentsHistoryUpdater
*/
public function __construct(
MessageGeneratorInterface $messageGenerator,
CaseRepositoryInterface $caseRepository,
- CaseIdValidator $caseIdValidator,
CommentsHistoryUpdater $commentsHistoryUpdater
) {
$this->messageGenerator = $messageGenerator;
$this->caseRepository = $caseRepository;
- $this->caseIdValidator = $caseIdValidator;
$this->commentsHistoryUpdater = $commentsHistoryUpdater;
}
@@ -66,7 +57,7 @@ public function __construct(
*/
public function update(array $data)
{
- if (!$this->caseIdValidator->validate($data)) {
+ if (empty($data['caseId'])) {
throw new LocalizedException(__('The "%1" should not be empty.', 'caseId'));
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php b/app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php
new file mode 100644
index 0000000000000..b76a0885a3611
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php
@@ -0,0 +1,58 @@
+template = $template;
+ $this->requiredParams = $requiredParams;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function generate(array $data)
+ {
+ $placeholders = [];
+ foreach ($this->requiredParams as $param) {
+ if (empty($data[$param])) {
+ throw new MessageGeneratorException(__('The "%1" should not be empty.', $param));
+ }
+ $placeholders[] = $data[$param];
+ }
+ return __($this->template, ...$placeholders);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
deleted file mode 100644
index a9affc97bbe4a..0000000000000
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
+++ /dev/null
@@ -1,43 +0,0 @@
-caseIdValidator = $caseIdValidator;
- }
-
- /**
- * @inheritdoc
- */
- public function generate(array $data)
- {
- if (!$this->caseIdValidator->validate($data)) {
- throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
- }
-
- return __('Signifyd Case %1 has been created for order.', $data['caseId']);
- }
-}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
index b2ff54c5c1c3b..c62d4334755ed 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -8,7 +8,6 @@
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
-use Magento\Signifyd\Model\Validators\CaseIdValidator;
/**
* Generates message based on previous and current Case scores.
@@ -20,21 +19,14 @@ class CaseRescore implements MessageGeneratorInterface
*/
private $caseRepository;
- /**
- * @var CaseIdValidator
- */
- private $caseIdValidator;
-
/**
* CaseRescore constructor.
*
* @param CaseRepositoryInterface $caseRepository
- * @param CaseIdValidator $caseIdValidator
*/
- public function __construct(CaseRepositoryInterface $caseRepository, CaseIdValidator $caseIdValidator)
+ public function __construct(CaseRepositoryInterface $caseRepository)
{
$this->caseRepository = $caseRepository;
- $this->caseIdValidator = $caseIdValidator;
}
/**
@@ -42,7 +34,7 @@ public function __construct(CaseRepositoryInterface $caseRepository, CaseIdValid
*/
public function generate(array $data)
{
- if (!$this->caseIdValidator->validate($data)) {
+ if (empty($data['caseId'])) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
deleted file mode 100644
index c34c6592b751d..0000000000000
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
+++ /dev/null
@@ -1,30 +0,0 @@
- 'Signifyd Case %1 has been created for order.',
+ 'requiredParams' => ['caseId']
+ ];
break;
case self::$caseRescore:
+ $classConfig = [];
$className = CaseRescore::class;
break;
case self::$caseReview:
- $className = CaseReview::class;
+ $classConfig = [
+ 'template' => 'Case Update: Case Review was completed. Review Deposition is %1.',
+ 'requiredParams' => ['reviewDisposition']
+ ];
break;
case self::$guaranteeCompletion:
- $className = GuaranteeCompletion::class;
+ $classConfig = [
+ 'template' => 'Case Update: Guarantee Disposition is %1.',
+ 'requiredParams' => ['guaranteeDisposition']
+ ];
break;
case self::$guaranteeCreation:
- $className = GuaranteeCreation::class;
+ $classConfig = [
+ 'template' => 'Case Update: Case is submitted for guarantee.'
+ ];
break;
default:
throw new \InvalidArgumentException('Specified message type does not supported.');
}
- return $this->objectManager->create($className);
+ return $this->objectManager->create($className, $classConfig);
}
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
deleted file mode 100644
index cfc73922c5d9a..0000000000000
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
+++ /dev/null
@@ -1,27 +0,0 @@
-setMethods(['getByCaseId'])
->getMockForAbstractClass();
- $this->caseIdValidator = $this->getMockBuilder(CaseIdValidator::class)
- ->disableOriginalConstructor()
- ->setMethods(['validate'])
- ->getMock();
-
$this->commentsHistoryUpdater = $this->getMockBuilder(CommentsHistoryUpdater::class)
->disableOriginalConstructor()
->setMethods(['addComment'])
@@ -80,7 +69,6 @@ protected function setUp()
$this->service = $this->objectManager->getObject(CaseUpdatingService::class, [
'messageGenerator' => $this->messageGenerator,
'caseRepository' => $this->caseRepository,
- 'caseIdValidator' => $this->caseIdValidator,
'commentsHistoryUpdater' => $this->commentsHistoryUpdater
]);
}
@@ -95,10 +83,6 @@ protected function setUp()
public function testUpdateWithFailedValidation()
{
$data = [];
- $this->caseIdValidator->expects(self::once())
- ->method('validate')
- ->with($data)
- ->willReturn(false);
$this->service->update($data);
}
@@ -117,11 +101,6 @@ public function testUpdateWithNotExistingCase()
'caseId' => $caseId
];
- $this->caseIdValidator->expects(self::once())
- ->method('validate')
- ->with($data)
- ->willReturn(true);
-
$this->caseRepository->expects(self::once())
->method('getByCaseId')
->with($caseId)
@@ -147,11 +126,6 @@ public function testUpdateWithFailedCaseSaving()
'score' => 500
];
- $this->caseIdValidator->expects(self::once())
- ->method('validate')
- ->with($data)
- ->willReturn(true);
-
$caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
->setMethods(['setCaseId', 'setStatus', 'setOrderId', 'setScore'])
@@ -198,11 +172,6 @@ public function testUpdateWithExceptionFromMessageGenerator()
'caseId' => $caseId
];
- $this->caseIdValidator->expects(self::once())
- ->method('validate')
- ->with($data)
- ->willReturn(true);
-
$caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
->setMethods(['setCaseId'])
@@ -245,11 +214,6 @@ public function testUpdateWithFailedCommentSaving()
'caseId' => $caseId
];
- $this->caseIdValidator->expects(self::once())
- ->method('validate')
- ->with($data)
- ->willReturn(true);
-
$caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
->setMethods(['setCaseId'])
@@ -296,11 +260,6 @@ public function testUpdate()
'caseId' => $caseId
];
- $this->caseIdValidator->expects(self::once())
- ->method('validate')
- ->with($data)
- ->willReturn(true);
-
$caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
->setMethods(['setCaseId'])
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
new file mode 100644
index 0000000000000..8005b316f24b8
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
@@ -0,0 +1,83 @@
+generate($data);
+ }
+
+ /**
+ * Checks cases with different template placeholders and input data.
+ *
+ * @covers \Magento\Signifyd\Model\MessageGenerators\BaseGenerator::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 BaseGenerator($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/MessageGenerators/CaseCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
deleted file mode 100644
index 1daa58f6917d9..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
+++ /dev/null
@@ -1,81 +0,0 @@
- 100];
-
- /**
- * @var ObjectManager
- */
- private $objectManager;
-
- /**
- * @var CaseCreation
- */
- private $caseCreation;
-
- /**
- * @inheritdoc
- */
- protected function setUp()
- {
- $this->objectManager = new ObjectManager($this);
-
- $this->caseCreation = $this->objectManager->getObject(CaseCreation::class, [
- 'caseIdValidator' => new CaseIdValidator()
- ]);
- }
-
- /**
- * Parameter without required attribute caseId.
- *
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
- * @expectedExceptionMessage The "caseId" should not be empty
- */
- public function testGenerateException()
- {
- $this->caseCreation->generate([]);
- }
-
- /**
- * Checks interface generated message.
- *
- * @return Phrase
- */
- public function testGenerateMessageInterface()
- {
- $message = $this->caseCreation->generate(self::$data);
-
- $this->assertInstanceOf(Phrase::class, $message);
-
- return $message;
- }
-
- /**
- * Generates case creation message for created Signifyd properly.
- *
- * @depends testGenerateMessageInterface
- * @param Phrase $message
- */
- public function testGenerate(Phrase $message)
- {
- $phrase = __('Signifyd Case %1 has been created for order.', self::$data['caseId']);
-
- $this->assertEquals($phrase, $message);
- }
-}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 21d08fa5afb1f..2dc7a4b14c492 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -5,11 +5,10 @@
*/
namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators;
-use Magento\Signifyd\Model\MessageGenerators\CaseRescore;
-use Magento\Signifyd\Model\Validators\CaseIdValidator;
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;
/**
@@ -58,8 +57,7 @@ protected function setUp()
->getMock();
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseIdValidator' => new CaseIdValidator(),
- 'caseRepository' => $this->caseRepository
+ 'caseRepository' => $this->caseRepository
]);
}
@@ -67,7 +65,7 @@ protected function setUp()
/**
* Data array without required attribute caseId.
*
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
* @expectedExceptionMessage The "caseId" should not be empty
*/
public function testGenerateEmptyCaseIdException()
@@ -78,7 +76,7 @@ public function testGenerateEmptyCaseIdException()
/**
* Case entity was not found in DB.
*
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
* @expectedExceptionMessage Case entity not found.
*/
public function testGenerateNotFoundException()
@@ -89,8 +87,7 @@ public function testGenerateNotFoundException()
->willReturn(null);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseIdValidator' => new CaseIdValidator(),
- 'caseRepository' => $this->caseRepository
+ 'caseRepository' => $this->caseRepository
]);
$this->caseRescore->generate(self::$data);
@@ -111,7 +108,6 @@ public function testGenerateWithPreviousScore()
->willReturn($this->case);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseIdValidator' => new CaseIdValidator(),
'caseRepository' => $this->caseRepository
]);
@@ -137,7 +133,6 @@ public function testGenerateWithoutPreviousScore()
->willReturn($this->case);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseIdValidator' => new CaseIdValidator(),
'caseRepository' => $this->caseRepository
]);
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
deleted file mode 100644
index 4bbf45aa77d5f..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
+++ /dev/null
@@ -1,73 +0,0 @@
- 100];
-
- /**
- * @var CaseReview
- */
- private $caseReview;
-
- /**
- * @inheritdoc
- */
- protected function setUp()
- {
- $this->caseReview = new CaseReview();
- }
-
- /**
- * Parameter without required attribute reviewDisposition.
- *
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
- * @expectedExceptionMessage The "reviewDisposition" should not be empty
- */
- public function testGenerateException()
- {
- $this->caseReview->generate([]);
- }
-
- /**
- * Checks interface generated message.
- *
- * @return \Magento\Framework\Phrase
- */
- public function testGenerateMessageInterface()
- {
- $message = $this->caseReview->generate(self::$data);
-
- $this->assertInstanceOf(Phrase::class, $message);
-
- return $message;
- }
-
- /**
- * Generates Case Review message for created Signifyd properly.
- *
- * @depends testGenerateMessageInterface
- * @param Phrase $message
- */
- public function testGenerate(Phrase $message)
- {
- $phrase = __(
- 'Case Update: Case Review was completed. Review Deposition is %1.',
- __(self::$data['reviewDisposition'])
- );
-
- $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
index ddc71b60b3816..f50b60ca436e2 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
@@ -7,12 +7,9 @@
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Signifyd\Model\MessageGenerators\CaseCreation;
+use Magento\Signifyd\Model\MessageGenerators\BaseGenerator;
use Magento\Signifyd\Model\MessageGenerators\CaseRescore;
-use Magento\Signifyd\Model\MessageGenerators\CaseReview;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
-use Magento\Signifyd\Model\MessageGenerators\GuaranteeCompletion;
-use Magento\Signifyd\Model\MessageGenerators\GuaranteeCreation;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
@@ -67,7 +64,7 @@ public function testCreate($type, $className)
->willReturn($generator);
$instance = $this->factory->create($type);
- static::assertInstanceOf($className, $instance);
+ self::assertInstanceOf($className, $instance);
}
/**
@@ -78,11 +75,11 @@ public function testCreate($type, $className)
public function typeDataProvider()
{
return [
- ['cases/creation', CaseCreation::class],
+ ['cases/creation', BaseGenerator::class],
+ ['cases/review', BaseGenerator::class],
['cases/rescore', CaseRescore::class],
- ['cases/review', CaseReview::class],
- ['guarantees/completion', GuaranteeCompletion::class],
- ['guarantees/creation', GuaranteeCreation::class],
+ ['guarantees/completion', BaseGenerator::class],
+ ['guarantees/creation', BaseGenerator::class],
];
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
deleted file mode 100644
index 801d455b4f076..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
+++ /dev/null
@@ -1,70 +0,0 @@
- 100];
-
- /**
- * @var GuaranteeCompletion
- */
- private $guaranteeCompletion;
-
- /**
- * @inheritdoc
- */
- protected function setUp()
- {
- $this->guaranteeCompletion = new GuaranteeCompletion();
- }
-
- /**
- * Parameter without required attribute guaranteeDisposition.
- *
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
- * @expectedExceptionMessage The "guaranteeDisposition" should not be empty
- */
- public function testGenerateException()
- {
- $this->guaranteeCompletion->generate([]);
- }
-
- /**
- * Checks interface generated Guarantee Completion message.
- *
- * @return Phrase
- */
- public function testGenerateMessageInterface()
- {
- $message = $this->guaranteeCompletion->generate(self::$data);
-
- $this->assertInstanceOf(Phrase::class, $message);
-
- return $message;
- }
-
- /**
- * Generates Guarantee Completion message for created Signifyd properly.
- *
- * @depends testGenerateMessageInterface
- * @param Phrase $message
- */
- public function testGenerate(Phrase $message)
- {
- $phrase = __('Case Update: Guarantee Disposition is %1.', __(self::$data['guaranteeDisposition']));
-
- $this->assertEquals($phrase, $message);
- }
-}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
deleted file mode 100644
index dd90e4c57da1d..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-generate($data);
-
- static::assertEquals($message, $message);
- static::assertInstanceOf(Phrase::class, $message);
- }
-
- /**
- * Gets list of variations for input data.
- *
- * @return array
- */
- public function dataProvider()
- {
- $message = 'Case Update: Case is submitted for guarantee.';
- return [
- [[], $message],
- [['caseId' => 123], $message],
- ];
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
index 25af28570737c..4862c160118d8 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
@@ -11,6 +11,7 @@
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\MessageGenerators\CaseCreation;
+use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
use Magento\TestFramework\Helper\Bootstrap;
/**
@@ -35,7 +36,9 @@ protected function setUp()
{
$this->objectManager = Bootstrap::getObjectManager();
- $messageGenerator = $this->objectManager->create(CaseCreation::class);
+ /** @var GeneratorFactory $messageFactory */
+ $messageFactory = $this->objectManager->get(GeneratorFactory::class);
+ $messageGenerator = $messageFactory->create('cases/creation');
$this->service = $this->objectManager->create(CaseUpdatingService::class, [
'messageGenerator' => $messageGenerator
From c51ec744df6857758e1c24305ccf5c424e20e098 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 11 Jan 2017 11:35:35 -0600
Subject: [PATCH 119/225] MAGETWO-62820: Create toolbar button to send
Guarantee request
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 59 +++++++++++++++++--
.../Model/Guarantee/SubmitEligible.php | 52 ++++++++++++++++
.../view/adminhtml/templates/case_info.phtml | 32 ++++++++++
.../view/adminhtml/web/js/request-send.js | 24 ++++++++
4 files changed, 161 insertions(+), 6 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
create mode 100644 app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index febea5219a2a4..4fc88a5d4b614 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -12,6 +12,7 @@
use Magento\Signifyd\Model\Config;
use Magento\Signifyd\Model\CaseManagement;
use Magento\Signifyd\Api\Data\CaseInterface;
+use Magento\Signifyd\Model\Guarantee\SubmitEligible;
/**
* Get Signifyd Case Info
@@ -28,6 +29,11 @@ class CaseInfo extends AbstractOrder
*/
private $caseManagement;
+ /**
+ * @var SubmitEligible
+ */
+ private $submitEligible;
+
/**
* @var int
*/
@@ -46,6 +52,7 @@ class CaseInfo extends AbstractOrder
* @param Admin $adminHelper
* @param Config $config
* @param CaseManagement $caseManagement
+ * @param SubmitEligible $submitEligible
* @param array $data
*/
public function __construct(
@@ -54,10 +61,12 @@ public function __construct(
Admin $adminHelper,
Config $config,
CaseManagement $caseManagement,
+ SubmitEligible $submitEligible,
array $data = []
) {
$this->config = $config;
$this->caseManagement = $caseManagement;
+ $this->submitEligible = $submitEligible;
parent::__construct($context, $registry, $adminHelper, $data);
}
@@ -95,15 +104,23 @@ public function isModuleActive()
}
/**
- * Gets Case entity associated with order id.
+ * Retrieves current order Id.
+ *
+ * @return integer
+ */
+ public function getOrderId()
+ {
+ return $this->getOrder()->getEntityId();
+ }
+
+ /**
+ * Gets case entity associated with order id.
*
* @return CaseInterface|null
*/
public function getCaseEntity()
{
- return $this->caseManagement->getByOrderId(
- $this->getOrder()->getEntityId()
- );
+ return $this->caseManagement->getByOrderId($this->getOrderId());
}
/**
@@ -118,7 +135,7 @@ public function getGuaranteeEligible(CaseInterface $caseEntity)
}
/**
- * Gets state of case guarantee eligible.
+ * Gets associated team name.
*
* @param CaseInterface $caseEntity
* @return string
@@ -137,7 +154,7 @@ public function getAssociatedTeam(CaseInterface $caseEntity)
/**
* Returns cell class name according to case score value.
- * It could be used by merchant to customize order view skin.
+ * It could be used by merchant to customize order view template.
*
* @param CaseInterface $caseEntity
* @return string
@@ -156,4 +173,34 @@ public function getScoreClass(CaseInterface $caseEntity)
return $result;
}
+
+ /**
+ * Gets configuration of allowed buttons.
+ *
+ * @return array
+ */
+ public function getButtons()
+ {
+ $buttons = [];
+
+ if ($this->submitEligible->check($this->getOrderId())) {
+ $buttons[] = $this->getSubmitButton();
+ }
+
+ return $buttons;
+ }
+
+ /**
+ * Returns configuration for submit Guarantee request button.
+ *
+ * @return array
+ */
+ private function getSubmitButton()
+ {
+ return [
+ 'title' => __('Submit Guarantee request'),
+ 'url' => $this->getUrl('signifyd/guarantee/create'),
+ 'componentName' => 'submit_guarantee_request'
+ ];
+ }
}
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php b/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
new file mode 100644
index 0000000000000..2571812fff03e
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
@@ -0,0 +1,52 @@
+caseManagement = $caseManagement;
+ }
+
+ /**
+ * Checks if Guarantee submit is applicable for order.
+ *
+ * @param integer $orderId
+ * @return bool
+ */
+ public function check($orderId)
+ {
+ $case = $this->getCaseEntity($orderId);
+
+ return true;
+ }
+
+ /**
+ * Retrieves case entity by order id.
+ *
+ * @param integer $orderId
+ * @return CaseInterface|null
+ */
+ private function getCaseEntity($orderId)
+ {
+ return $this->caseManagement->getByOrderId($orderId);
+ }
+}
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index be4a8d993d0ff..8a5a9605dc55a 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -43,5 +43,37 @@
+
+ getButtons() as $button):?>
+
+
+
+
+
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
new file mode 100644
index 0000000000000..e68ab939cd4b9
--- /dev/null
+++ b/app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js
@@ -0,0 +1,24 @@
+/**
+ * Copyright © 2013-2017 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
+ });
+ }
+ });
+});
From edfd6ccaf97aac5a36b7bdd2809d3b680772082f Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 11 Jan 2017 11:57:39 -0600
Subject: [PATCH 120/225] MAGETWO-62806: Update case entity
- Renamed message generator
---
.../Model/MessageGenerators/GeneratorFactory.php | 2 +-
.../{BaseGenerator.php => PatternGenerator.php} | 7 ++++---
.../Model/MessageGenerators/GeneratorFactoryTest.php | 10 +++++-----
...aseGeneratorTest.php => PatternGeneratorTest.php} | 12 ++++++------
4 files changed, 16 insertions(+), 15 deletions(-)
rename app/code/Magento/Signifyd/Model/MessageGenerators/{BaseGenerator.php => PatternGenerator.php} (91%)
rename app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/{BaseGeneratorTest.php => PatternGeneratorTest.php} (83%)
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
index 4271605ddd2cb..6f9f855350441 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
@@ -63,7 +63,7 @@ public function __construct(ObjectManagerInterface $objectManager)
*/
public function create($type)
{
- $className = BaseGenerator::class;
+ $className = PatternGenerator::class;
switch ($type) {
case self::$caseCreation:
$classConfig = [
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php b/app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php
similarity index 91%
rename from app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php
rename to app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php
index b76a0885a3611..e69bb565360b7 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php
@@ -18,7 +18,7 @@
* Message is 'Case Update: New score for the order is %1. Previous score was %2.', then the required params order
* should be ['new_score', 'prev_score'].
*/
-class BaseGenerator implements MessageGeneratorInterface
+class PatternGenerator implements MessageGeneratorInterface
{
/**
* @var string
@@ -31,8 +31,9 @@ class BaseGenerator implements MessageGeneratorInterface
private $requiredParams;
/**
- * BaseGenerator constructor.
- * @param $template
+ * PatternGenerator constructor.
+ *
+ * @param string $template
* @param array $requiredParams
*/
public function __construct($template, array $requiredParams = [])
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
index f50b60ca436e2..ff7a6d06f6074 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
@@ -7,7 +7,7 @@
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Signifyd\Model\MessageGenerators\BaseGenerator;
+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;
@@ -75,11 +75,11 @@ public function testCreate($type, $className)
public function typeDataProvider()
{
return [
- ['cases/creation', BaseGenerator::class],
- ['cases/review', BaseGenerator::class],
+ ['cases/creation', PatternGenerator::class],
+ ['cases/review', PatternGenerator::class],
['cases/rescore', CaseRescore::class],
- ['guarantees/completion', BaseGenerator::class],
- ['guarantees/creation', BaseGenerator::class],
+ ['guarantees/completion', PatternGenerator::class],
+ ['guarantees/creation', PatternGenerator::class],
];
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
similarity index 83%
rename from app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
rename to app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
index 8005b316f24b8..32d3aeec52d36 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
@@ -5,31 +5,31 @@
*/
namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators;
-use Magento\Signifyd\Model\MessageGenerators\BaseGenerator;
+use Magento\Signifyd\Model\MessageGenerators\PatternGenerator;
/**
* Contains tests for different variations like empty data, wrong required arguments, or bad placeholders.
*/
-class BaseGeneratorTest extends \PHPUnit_Framework_TestCase
+class PatternGeneratorTest extends \PHPUnit_Framework_TestCase
{
/**
* Checks an exception if generators does not receives required data.
*
- * @covers \Magento\Signifyd\Model\MessageGenerators\BaseGenerator::generate
+ * @covers \Magento\Signifyd\Model\MessageGenerators\PatternGenerator::generate
* @expectedException \Magento\Signifyd\Model\MessageGeneratorException
* @expectedExceptionMessage The "caseId" should not be empty.
*/
public function testGenerateThrowsException()
{
$data = [];
- $generator = new BaseGenerator('Signifyd Case %1 has been created for order.', ['caseId']);
+ $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\BaseGenerator::generate
+ * @covers \Magento\Signifyd\Model\MessageGenerators\PatternGenerator::generate
* @param string $template
* @param array $requiredFields
* @param string $expected
@@ -45,7 +45,7 @@ public function testGenerate($template, array $requiredFields, $expected)
'case_score' => 300
];
- $generator = new BaseGenerator($template, $requiredFields);
+ $generator = new PatternGenerator($template, $requiredFields);
$actual = $generator->generate($data);
self::assertEquals($expected, $actual);
}
From fa30953c0b7b776de15174e8636a6ddc56a518da Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 12 Jan 2017 05:04:29 -0600
Subject: [PATCH 121/225] MAGETWO-62822: Create Guarantee creation service
- added API interface for guarantee creation service
- guarantee creation service implementation covered with unit test
- refactoring
---
.../Api/CaseCreationServiceInterface.php | 1 +
.../Signifyd/Api/CaseManagementInterface.php | 7 +-
.../Signifyd/Api/CaseRepositoryInterface.php | 24 +-
.../Api/GuaranteeCreationServiceInterface.php | 27 ++
.../Controller/Adminhtml/Guarantee/Create.php | 2 +-
.../Signifyd/Model/CaseCreationService.php | 9 +-
.../Signifyd/Model/CaseUpdatingService.php | 2 +-
.../Model/Guarantee/CreationService.php | 70 ++---
.../Model/Guarantee/CreationServiceTest.php | 270 ++++++++++++++++++
app/code/Magento/Signifyd/etc/di.xml | 1 +
10 files changed, 353 insertions(+), 60 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
index 7141d76371c06..139e3690403e7 100644
--- a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -20,6 +20,7 @@ interface CaseCreationServiceInterface
*
* @param int $orderId
* @return bool
+ * @throws \Magento\Framework\Exception\NotFoundException If order does not exists
* @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
*/
public function createForOrder($orderId);
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index 7c0445a4211c7..d02f5b5831413 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Api;
-use Magento\Signifyd\Api\Data\CaseInterface;
-
/**
* Signifyd management interface
* Allows to performs operations with Signifyd cases.
@@ -19,7 +17,8 @@ interface CaseManagementInterface
* Creates new Case entity linked to order id.
*
* @param int $orderId
- * @return CaseInterface
+ * @return \Magento\Signifyd\Api\Data\CaseInterface
+ * @throws \Magento\Framework\Exception\NotFoundException If order does not exists
* @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
*/
public function create($orderId);
@@ -28,7 +27,7 @@ public function create($orderId);
* Gets Case entity associated with order id.
*
* @param int $orderId
- * @return CaseInterface|null
+ * @return \Magento\Signifyd\Api\Data\CaseInterface|null
*/
public function getByOrderId($orderId);
}
diff --git a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
index e985effe84b59..e265088ff673b 100644
--- a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
@@ -5,10 +5,6 @@
*/
namespace Magento\Signifyd\Api;
-use Magento\Framework\Api\SearchCriteria;
-use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Api\Data\CaseSearchResultsInterface;
-
/**
* Signifyd Case repository interface
*
@@ -19,16 +15,16 @@ interface CaseRepositoryInterface
/**
* Saves case entity.
*
- * @param CaseInterface $case
- * @return CaseInterface
+ * @param \Magento\Signifyd\Api\Data\CaseInterface $case
+ * @return \Magento\Signifyd\Api\Data\CaseInterface
*/
- public function save(CaseInterface $case);
+ public function save(\Magento\Signifyd\Api\Data\CaseInterface $case);
/**
* Gets case entity by order id.
*
* @param int $id
- * @return CaseInterface
+ * @return \Magento\Signifyd\Api\Data\CaseInterface
*/
public function getById($id);
@@ -36,23 +32,23 @@ public function getById($id);
* Gets entity by Signifyd case id.
*
* @param int $caseId
- * @return CaseInterface|null
+ * @return \Magento\Signifyd\Api\Data\CaseInterface|null
*/
public function getByCaseId($caseId);
/**
* Deletes case entity.
*
- * @param CaseInterface $case
+ * @param \Magento\Signifyd\Api\Data\CaseInterface $case
* @return bool
*/
- public function delete(CaseInterface $case);
+ public function delete(\Magento\Signifyd\Api\Data\CaseInterface $case);
/**
* Gets list of case entities.
*
- * @param SearchCriteria $searchCriteria
- * @return CaseSearchResultsInterface
+ * @param \Magento\Framework\Api\SearchCriteria $searchCriteria
+ * @return \Magento\Signifyd\Api\Data\CaseSearchResultsInterface
*/
- public function getList(SearchCriteria $searchCriteria);
+ public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria);
}
diff --git a/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
new file mode 100644
index 0000000000000..ad6d5e8098190
--- /dev/null
+++ b/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
@@ -0,0 +1,27 @@
+setPath('sales/order/view', ['order_id' => $orderId]);
- if ($this->creationService->create($orderId)) {
+ if ($this->creationService->createForOrder($orderId)) {
$this->messageManager->addSuccessMessage(
__('Order has been submitted for Guarantee.')
);
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseCreationService.php
index 39414d8f84fc1..b546c9c63fe4f 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseCreationService.php
@@ -8,7 +8,6 @@
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
-use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Psr\Log\LoggerInterface;
@@ -69,14 +68,14 @@ public function createForOrder($orderId)
try {
$caseId = $this->signifydGateway->createCase($orderId);
- $case->setCaseId($caseId);
- $this->caseRepository->save($case);
- } catch (ApiCallException $e) {
- $this->logger->error($e->getMessage());
} catch (GatewayException $e) {
$this->logger->error($e->getMessage());
+ return true;
}
+ $case->setCaseId($caseId);
+ $this->caseRepository->save($case);
+
return true;
}
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index bf39d2356a28d..22a287357c771 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -52,8 +52,8 @@ public function __construct(
*
* @param array $data
* @return void
- * @throws LocalizedException
* @throws NotFoundException
+ * @throws LocalizedException
*/
public function update(array $data)
{
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
index 18e500446b105..e3ca93842f29b 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Signifyd\Model\Guarantee;
-use Magento\Framework\Exception\LocalizedException;
-use Magento\Signifyd\Model\CaseManagement;
+use Magento\Framework\Exception\AlreadyExistsException;
+use Magento\Framework\Exception\NotFoundException;
+use Magento\Signifyd\Api\GuaranteeCreationServiceInterface;
+use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
-use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Psr\Log\LoggerInterface;
@@ -16,8 +17,13 @@
/**
* Register guarantee at Signifyd and updates case entity
*/
-class CreationService
+class CreationService implements GuaranteeCreationServiceInterface
{
+ /**
+ * @var CaseManagementInterface
+ */
+ private $caseManagement;
+
/**
* @var CaseUpdatingServiceFactory
*/
@@ -33,68 +39,62 @@ class CreationService
*/
private $logger;
- /**
- * @var CaseManagement
- */
- private $caseManagement;
-
/**
* CreationService constructor.
*
+ * @param CaseManagementInterface $caseManagement
* @param CaseUpdatingServiceFactory $caseUpdatingServiceFactory
* @param Gateway $gateway
- * @param CaseManagement $caseManagement
* @param LoggerInterface $logger
*/
public function __construct(
+ CaseManagementInterface $caseManagement,
CaseUpdatingServiceFactory $caseUpdatingServiceFactory,
Gateway $gateway,
- CaseManagement $caseManagement,
LoggerInterface $logger
) {
+ $this->caseManagement = $caseManagement;
$this->caseUpdatingServiceFactory = $caseUpdatingServiceFactory;
$this->gateway = $gateway;
$this->logger = $logger;
- $this->caseManagement = $caseManagement;
}
/**
- * Sends request to Signifyd to create guarantee for a case and updates case entity by retrieved data.
- *
- * @param int $orderId
- * @return bool
+ * @inheritdoc
*/
- public function create($orderId)
+ public function createForOrder($orderId)
{
$caseEntity = $this->caseManagement->getByOrderId($orderId);
if ($caseEntity === null) {
- $this->logger->error("Cannot find case entity for order entity id: {$orderId}");
- return false;
+ throw new NotFoundException(
+ __('Case for order with specified id "%1" is not created', $orderId)
+ );
+ }
+ if ($caseEntity->getCaseId() === null) {
+ throw new NotFoundException(
+ __('Case for order with specified id "%1" is not registered in Signifyd', $orderId)
+ );
+ }
+ if ($caseEntity->getGuaranteeDisposition() !== null) {
+ throw new AlreadyExistsException(
+ __('Guarantee for order "%1" has been created already', $orderId)
+ );
}
- $updatingService = $this->caseUpdatingServiceFactory->create('guarantees/creation');
try {
$disposition = $this->gateway->submitCaseForGuarantee($caseEntity->getCaseId());
- if (!$disposition) {
- $this->logger->error("Cannot retrieve guarantee disposition for case: {$caseEntity->getEntityId()}.");
- return false;
- }
- $data = [
- 'caseId' => $caseEntity->getCaseId(),
- 'guaranteeDisposition' => $disposition
- ];
- $updatingService->update($data);
- } catch (ApiCallException $e) {
- $this->logger->error($e->getMessage());
- return false;
} catch (GatewayException $e) {
$this->logger->error($e->getMessage());
return false;
- } catch (LocalizedException $e) {
- $this->logger->error($e->getMessage());
- return false;
}
+ $updatingService = $this->caseUpdatingServiceFactory->create('guarantees/creation');
+ $data = [
+ 'caseId' => $caseEntity->getCaseId(),
+ 'guaranteeDisposition' => $disposition
+ ];
+ $updatingService->update($data);
+
return true;
}
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
new file mode 100644
index 0000000000000..b8ee861c1e5dd
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
@@ -0,0 +1,270 @@
+caseManagement = $this->getMockBuilder(CaseManagementInterface::class)
+ ->getMockForAbstractClass();
+
+ $caseUpdatingServiceFactory = $this->getMockBuilder(CaseUpdatingServiceFactory::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->caseUpdatingService = $this->getMockBuilder(CaseUpdatingServiceInterface::class)
+ ->getMockForAbstractClass();
+ $caseUpdatingServiceFactory
+ ->method('create')
+ ->willReturn($this->caseUpdatingService);
+
+ $this->gateway = $this->getMockBuilder(Gateway::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->logger = $this->getMockBuilder(LoggerInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->service = new CreationService(
+ $this->caseManagement,
+ $caseUpdatingServiceFactory,
+ $this->gateway,
+ $this->logger
+ );
+ }
+
+ public function testCreateForOrderWithoutCase()
+ {
+ $dummyOrderId = 1;
+ $this->withCaseEntityNotExistsForOrderId($dummyOrderId);
+
+ $this->gateway
+ ->expects($this->never())
+ ->method('submitCaseForGuarantee');
+ $this->caseUpdatingService
+ ->expects($this->never())
+ ->method('update');
+ $this->setExpectedException(NotFoundException::class);
+
+ $this->service->createForOrder($dummyOrderId);
+ }
+
+ 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';
+ $this->withCaseEntityExistsForOrderId(
+ $dummyOrderId,
+ [
+ 'caseId' => $dummyCaseId,
+ ]
+ );
+ $this->withGatewaySuccess($dummyGuaranteeDisposition);
+
+ $this->caseUpdatingService
+ ->expects($this->once())
+ ->method('update')
+ ->with($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'
+ );
+ }
+
+ public function testCreateForOrderWithNotRegisteredCase()
+ {
+ $dummyOrderId = 1;
+ $dummyCaseId = null;
+ $this->withCaseEntityExistsForOrderId(
+ $dummyOrderId,
+ [
+ 'caseId' => $dummyCaseId,
+ ]
+ );
+
+ $this->gateway
+ ->expects($this->never())
+ ->method('submitCaseForGuarantee');
+ $this->caseUpdatingService
+ ->expects($this->never())
+ ->method('update');
+ $this->setExpectedException(NotFoundException::class);
+
+ $this->service->createForOrder($dummyOrderId);
+ }
+
+ public function testCreateForOrderWithExistedGuarantee()
+ {
+ $dummyOrderId = 1;
+ $dummyCaseId = 42;
+ $dummyGuarantyDisposition = 'APPROVED';
+ $this->withCaseEntityExistsForOrderId(
+ $dummyOrderId,
+ [
+ 'caseId' => $dummyCaseId,
+ 'guaranteeDisposition' => $dummyGuarantyDisposition
+ ]
+ );
+
+ $this->gateway
+ ->expects($this->never())
+ ->method('submitCaseForGuarantee');
+ $this->caseUpdatingService
+ ->expects($this->never())
+ ->method('update');
+ $this->setExpectedException(AlreadyExistsException::class);
+
+ $this->service->createForOrder($dummyOrderId);
+ }
+
+ private function withCaseEntityNotExistsForOrderId($orderId)
+ {
+ $this->caseManagement
+ ->method('getByOrderId')
+ ->with($this->equalTo($orderId))
+ ->willReturn(null);
+ }
+
+ private function withCaseEntityExistsForOrderId($orderId, array $caseData = [])
+ {
+ $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);
+ }
+
+ private function withGatewayFailure($failureMessage)
+ {
+ $this->gateway
+ ->method('submitCaseForGuarantee')
+ ->willThrowException(new GatewayException($failureMessage));
+ }
+
+ private function withGatewaySuccess($gatewayResult)
+ {
+ $this->gateway
+ ->method('submitCaseForGuarantee')
+ ->willReturn($gatewayResult);
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 81d157887f7e1..9a2eb0527d63f 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -11,5 +11,6 @@
+
\ No newline at end of file
From d1b3370c438e63fc380e38969ab1365e726ac80e Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 12 Jan 2017 05:05:17 -0600
Subject: [PATCH 122/225] MAGETWO-62822: Create Guarantee creation service
- refactoring
---
.../Model/Guarantee/CreationServiceTest.php | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
index be529923f2fae..0900a9f1a2162 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -36,11 +36,6 @@ class CreationServiceTest extends \PHPUnit_Framework_TestCase
*/
private $logger;
- /**
- * @var ObjectManager
- */
- private $objectManager;
-
/**
* @inheritdoc
*/
@@ -68,7 +63,7 @@ protected function setUp()
* Checks a test case, when Signifyd case entity cannot be found
* for a specified order.
*
- * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
*/
public function testCreateWithoutCaseEntity()
{
@@ -87,7 +82,7 @@ public function testCreateWithoutCaseEntity()
/**
* Checks a test case, when request is failing.
*
- * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/case.php
*/
public function testCreateWithFailedRequest()
@@ -102,14 +97,14 @@ public function testCreateWithFailedRequest()
->method('error')
->with('Something wrong');
- $result = $this->service->create($caseEntity->getOrderId());
+ $result = $this->service->createForOrder($caseEntity->getOrderId());
self::assertFalse($result);
}
/**
* Checks a test case, when case entity updating is failed.
*
- * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/case.php
* @magentoConfigFixture current_store fraud_protection/signifyd/active 1
*/
@@ -126,14 +121,14 @@ public function testCreateWithFailedCaseUpdating()
->method('error')
->with('Cannot retrieve guarantee disposition for case: ' . $caseEntity->getEntityId() . '.');
- $result = $this->service->create($caseEntity->getOrderId());
+ $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::create
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/case.php
* @magentoConfigFixture current_store fraud_protection/signifyd/active 1
*/
@@ -149,7 +144,7 @@ public function testCreate()
$this->logger->expects(self::never())
->method('error');
- $result = $this->service->create($caseEntity->getOrderId());
+ $result = $this->service->createForOrder($caseEntity->getOrderId());
self::assertTrue($result);
$updatedCase = $this->getCaseEntity();
From cd3f77b8460ecf6959e639233d1776f1941a1ba8 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Thu, 12 Jan 2017 05:30:37 -0600
Subject: [PATCH 123/225] MAGETWO-62820: Create toolbar button to send
Guarantee request
- Covered with integration test
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 24 +++++-----
.../view/adminhtml/templates/case_info.phtml | 2 +-
.../Signifyd/Block/Adminhtml/CaseInfoTest.php | 47 +++++++++++++++----
3 files changed, 52 insertions(+), 21 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 4fc88a5d4b614..e46ea352740ca 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -103,16 +103,6 @@ public function isModuleActive()
return $this->config->isActive();
}
- /**
- * Retrieves current order Id.
- *
- * @return integer
- */
- public function getOrderId()
- {
- return $this->getOrder()->getEntityId();
- }
-
/**
* Gets case entity associated with order id.
*
@@ -142,7 +132,6 @@ public function getGuaranteeEligible(CaseInterface $caseEntity)
*/
public function getAssociatedTeam(CaseInterface $caseEntity)
{
-
$result = 'unknown';
$team = $caseEntity->getAssociatedTeam();
if (isset($team['teamName'])) {
@@ -200,7 +189,18 @@ private function getSubmitButton()
return [
'title' => __('Submit Guarantee request'),
'url' => $this->getUrl('signifyd/guarantee/create'),
- 'componentName' => 'submit_guarantee_request'
+ 'componentName' => 'submit_guarantee_request',
+ 'orderId' => $this->getOrderId()
];
}
+
+ /**
+ * Retrieves current order Id.
+ *
+ * @return integer
+ */
+ private function getOrderId()
+ {
+ return $this->getOrder()->getEntityId();
+ }
}
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 8a5a9605dc55a..4ff6820b702dc 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -58,7 +58,7 @@
"title": "escapeHtml($button['title']); ?>",
"requestURL": "",
"data": {
- "orderId": "getOrderId(); ?>"
+ "orderId": ""
},
"actions": [
{
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index 95f4fd1f70db2..f05c630c76b21 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -6,7 +6,6 @@
namespace Magento\Signifyd\Block\Adminhtml;
-use Magento\Framework\App\Area;
use Magento\Framework\Registry;
use Magento\Framework\View\LayoutInterface;
use Magento\Sales\Block\Adminhtml\Order\View\Tab\Info as OrderTabInfo;
@@ -35,9 +34,6 @@ class CaseInfoTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{
- $bootstrap = Bootstrap::getInstance();
- $bootstrap->loadArea(Area::AREA_ADMINHTML);
-
$objectManager = Bootstrap::getObjectManager();
$this->order = $objectManager->create(Order::class);
$this->registry = $objectManager->get(Registry::class);
@@ -48,8 +44,9 @@ protected function setUp()
* Checks that block does not give contents
* if Signifyd module is inactive.
*
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::isModuleActive
+ * @covers CaseInfo::isModuleActive
* @magentoConfigFixture current_store fraud_protection/signifyd/active 0
+ * @magentoAppArea adminhtml
*/
public function testModuleIsInactive()
{
@@ -60,9 +57,10 @@ public function testModuleIsInactive()
* Checks that block does not give contents
* if there is no case entity created for order.
*
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseEntity
+ * @covers 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()
{
@@ -77,10 +75,11 @@ public function testCaseEntityNotExists()
* - associated team displays correct
* - score class displays correct
*
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getAssociatedTeam
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getScoreClass
+ * @covers CaseInfo::getAssociatedTeam
+ * @covers CaseInfo::getScoreClass
* @magentoConfigFixture current_store fraud_protection/signifyd/active 1
* @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoAppArea adminhtml
*/
public function testCaseEntityExists()
{
@@ -92,6 +91,38 @@ public function testCaseEntityExists()
static::assertContains('col-case-score-green', $html);
}
+ /**
+ * Checks that guarantee action buttons is available on order page.
+ *
+ * @covers CaseInfo::getButtons
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoAppArea adminhtml
+ */
+ public function testButtonsAvailable()
+ {
+ $this->registry->register('current_order', $this->order->loadByIncrementId('100000001'));
+
+ static::assertContains('Submit Guarantee request', $this->getBlockContents());
+ }
+
+ /**
+ * Checks that guarantee action buttons is unavailable on order page.
+ *
+ * @covers CaseInfo::getButtons
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoAppArea adminhtml
+ */
+ public function testButtonsUnavailable()
+ {
+ $this->registry->register('current_order', $this->order->loadByIncrementId('100000001'));
+
+ $this->order->setState(Order::STATE_CANCELED);
+
+ static::assertNotContains('Submit Guarantee request', $this->getBlockContents());
+ }
+
/**
* Renders block contents.
*
From 33f9d15ab29f14191d45af7337c9e8a7204e1059 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Thu, 12 Jan 2017 05:42:21 -0600
Subject: [PATCH 124/225] MAGETWO-62820: Create toolbar button to send
Guarantee request
- unit test and refactoring
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 4 +-
.../Unit/Block/Adminhtml/CaseInfoTest.php | 78 +++++++++++++++++++
.../view/adminhtml/templates/case_info.phtml | 2 +-
3 files changed, 81 insertions(+), 3 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index e46ea352740ca..fe0960282218c 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -94,11 +94,11 @@ protected function _beforeToHtml()
}
/**
- * Checks if module is enabled.
+ * Checks if service is enabled.
*
* @return boolean
*/
- public function isModuleActive()
+ public function isServiceActive()
{
return $this->config->isActive();
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
new file mode 100644
index 0000000000000..5384ce749a0bd
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
@@ -0,0 +1,78 @@
+caseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getScore'])
+ ->getMockForAbstractClass();
+
+ $this->caseInfo = $objectManager->getObject(CaseInfo::class);
+ }
+
+ /**
+ * Checks css class according to case entity score value.
+ *
+ * @param integer $score
+ * @param string $expectedClassName
+ * @covers \Magento\Signifyd\Block\CaseInfo::getScoreClass
+ * @dataProvider getScoreClassDataProvider
+ */
+ public function testGetScoreClass($score, $expectedClassName)
+ {
+ $this->caseEntity->expects($this->once())
+ ->method('getScore')
+ ->willReturn($score);
+
+ self::assertEquals(
+ $expectedClassName,
+ $this->caseInfo->getScoreClass($this->caseEntity)
+ );
+ }
+
+ /**
+ * Case scores and corresponding class name data provider
+
+ * @return array
+ */
+ public function getScoreClassDataProvider()
+ {
+ return [
+ [300, 'red'],
+ [400, 'yellow'],
+ [500, 'green'],
+ ];
+ }
+}
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 4ff6820b702dc..98b2b63224d4f 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -8,7 +8,7 @@
?>
isModuleActive() || !($case = $block->getCaseEntity())) {
+ if (!$block->isServiceActive() || !($case = $block->getCaseEntity())) {
return '';
}
?>
From 2e080f535fff447cf23e7ffb93762d77071f8afb Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 12 Jan 2017 06:28:25 -0600
Subject: [PATCH 125/225] MAGETWO-62825: Guarantee creation possibility
validator
-Add class for checking submit guarantee possibility
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 14 +--
.../Model/Guarantee/SubmitEligible.php | 88 ++++++++++++++++---
2 files changed, 84 insertions(+), 18 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index fe0960282218c..9684a8bd10789 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -12,7 +12,7 @@
use Magento\Signifyd\Model\Config;
use Magento\Signifyd\Model\CaseManagement;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Model\Guarantee\SubmitEligible;
+use Magento\Signifyd\Model\Guarantee\SubmitEligible as GuaranteeSubmitEligible;
/**
* Get Signifyd Case Info
@@ -30,9 +30,9 @@ class CaseInfo extends AbstractOrder
private $caseManagement;
/**
- * @var SubmitEligible
+ * @var GuaranteeSubmitEligible
*/
- private $submitEligible;
+ private $guaranteeSubmitEligible;
/**
* @var int
@@ -52,7 +52,7 @@ class CaseInfo extends AbstractOrder
* @param Admin $adminHelper
* @param Config $config
* @param CaseManagement $caseManagement
- * @param SubmitEligible $submitEligible
+ * @param GuaranteeSubmitEligible $guaranteeSubmitEligible
* @param array $data
*/
public function __construct(
@@ -61,12 +61,12 @@ public function __construct(
Admin $adminHelper,
Config $config,
CaseManagement $caseManagement,
- SubmitEligible $submitEligible,
+ GuaranteeSubmitEligible $guaranteeSubmitEligible,
array $data = []
) {
$this->config = $config;
$this->caseManagement = $caseManagement;
- $this->submitEligible = $submitEligible;
+ $this->guaranteeSubmitEligible = $guaranteeSubmitEligible;
parent::__construct($context, $registry, $adminHelper, $data);
}
@@ -172,7 +172,7 @@ public function getButtons()
{
$buttons = [];
- if ($this->submitEligible->check($this->getOrderId())) {
+ if ($this->guaranteeSubmitEligible->check($this->getOrderId())) {
$buttons[] = $this->getSubmitButton();
}
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php b/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
index 2571812fff03e..5e216a49c281d 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
@@ -5,9 +5,17 @@
*/
namespace Magento\Signifyd\Model\Guarantee;
+use Magento\Framework\Exception\InputException;
+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\Model\CaseManagement;
-use Magento\Signifyd\Api\Data\CaseInterface;
+/**
+ * Checks if is possible to submit guarantee request for order.
+ */
class SubmitEligible
{
/**
@@ -16,37 +24,95 @@ class SubmitEligible
private $caseManagement;
/**
- * SubmitEligible constructor.
+ * @var OrderRepositoryInterface
+ */
+ private $orderRepository;
+
+ /**
+ * @var DateTimeFactory
+ */
+ private $dateTimeFactory;
+
+ /**
+ * Eligible count of days from the order date to submit a case for Guarantee.
*
+ * @var int
+ */
+ private static $guarantyEligibleDays = 7;
+
+ /**
* @param CaseManagement $caseManagement
+ * @param OrderRepositoryInterface $orderRepository
+ * @param DateTimeFactory $dateTimeFactory
*/
public function __construct(
- CaseManagement $caseManagement
+ CaseManagement $caseManagement,
+ OrderRepositoryInterface $orderRepository,
+ DateTimeFactory $dateTimeFactory
) {
$this->caseManagement = $caseManagement;
+ $this->orderRepository = $orderRepository;
+ $this->dateTimeFactory = $dateTimeFactory;
}
/**
- * Checks if Guarantee submit is applicable for order.
+ * Checks if Guarantee submit is applicable for order and case.
*
- * @param integer $orderId
+ * @param int $orderId
* @return bool
*/
public function check($orderId)
{
- $case = $this->getCaseEntity($orderId);
+ $case = $this->caseManagement->getByOrderId($orderId);
+ if (null === $case || $case->isGuaranteeEligible() === false) {
+ return false;
+ }
+
+ $order = $this->getOrder($orderId);
+ if (null === $order || $this->checkOrder($order) === false) {
+ return false;
+ }
return true;
}
/**
- * Retrieves case entity by order id.
+ * Checks if Guarantee submit is applicable for order.
+ *
+ * @param OrderInterface $order
+ * @return bool
+ */
+ private function checkOrder(OrderInterface $order)
+ {
+ if (in_array($order->getState(), [Order::STATE_CANCELED, Order::STATE_CLOSED])) {
+ return false;
+ }
+
+ $orderCreateDate = $this->dateTimeFactory->create($order->getCreatedAt(), new \DateTimeZone('UTC'));
+ $currentDate = $this->dateTimeFactory->create('now', new \DateTimeZone('UTC'));
+ if ($orderCreateDate->diff($currentDate)->days >= static::$guarantyEligibleDays) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns order by id
*
- * @param integer $orderId
- * @return CaseInterface|null
+ * @param int $orderId
+ * @return OrderInterface|null
*/
- private function getCaseEntity($orderId)
+ private function getOrder($orderId)
{
- return $this->caseManagement->getByOrderId($orderId);
+ try {
+ $order = $this->orderRepository->get($orderId);
+ } catch (InputException $e) {
+ return null;
+ } catch (NoSuchEntityException $e) {
+ return null;
+ }
+
+ return $order;
}
}
From 19d19f5c7b9ca0559c14e962407192f5a146507e Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 12 Jan 2017 10:57:17 -0600
Subject: [PATCH 126/225] MAGETWO-54393: Updating Order Status using Webhooks
- Refactored code according to code review comments
---
.../Signifyd/Controller/Webhooks/Handler.php | 8 ++--
.../CreationService.php} | 6 +--
.../StubUpdatingService.php} | 4 +-
.../UpdatingService.php} | 14 +++---
.../UpdatingServiceFactory.php} | 13 +++---
.../UpdatingServiceInterface.php} | 4 +-
.../Signifyd/Model/CommentsHistoryUpdater.php | 4 ++
.../Model/Guarantee/CreationService.php | 12 ++---
.../Model/MessageGenerators/CaseRescore.php | 8 ++--
.../GeneratorException.php} | 4 +-
.../MessageGenerators/GeneratorFactory.php | 4 +-
.../GeneratorInterface.php} | 6 +--
.../MessageGenerators/PatternGenerator.php | 7 +--
.../Unit/Controller/Webhooks/HandlerTest.php | 24 +++++-----
.../UpdatingServiceFactoryTest.php} | 44 +++++++++----------
.../UpdatingServiceTest.php} | 32 +++++++-------
.../Unit/Model/CommentsHistoryUpdaterTest.php | 24 ++++++++--
.../Model/Guarantee/CreationServiceTest.php | 10 ++---
.../MessageGenerators/CaseRescoreTest.php | 4 +-
.../PatternGeneratorTest.php | 2 +-
app/code/Magento/Signifyd/etc/di.xml | 2 +-
.../Controller/Webhooks/HandlerTest.php | 1 -
.../Signifyd/Model/CaseManagementTest.php | 2 -
.../CreationServiceTest.php} | 16 +++----
.../UpdatingServiceTest.php} | 11 +++--
.../Model/Guarantee/CreationServiceTest.php | 36 ++++-----------
.../Magento/Signifyd/_files/case.php | 1 -
27 files changed, 148 insertions(+), 155 deletions(-)
rename app/code/Magento/Signifyd/Model/{CaseCreationService.php => CaseServices/CreationService.php} (92%)
rename app/code/Magento/Signifyd/Model/{StubCaseUpdatingService.php => CaseServices/StubUpdatingService.php} (77%)
rename app/code/Magento/Signifyd/Model/{CaseUpdatingService.php => CaseServices/UpdatingService.php} (87%)
rename app/code/Magento/Signifyd/Model/{CaseUpdatingServiceFactory.php => CaseServices/UpdatingServiceFactory.php} (83%)
rename app/code/Magento/Signifyd/Model/{CaseUpdatingServiceInterface.php => CaseServices/UpdatingServiceInterface.php} (81%)
rename app/code/Magento/Signifyd/Model/{MessageGeneratorException.php => MessageGenerators/GeneratorException.php} (68%)
rename app/code/Magento/Signifyd/Model/{MessageGeneratorInterface.php => MessageGenerators/GeneratorInterface.php} (80%)
rename app/code/Magento/Signifyd/Test/Unit/Model/{CaseUpdatingServiceFactoryTest.php => CaseServices/UpdatingServiceFactoryTest.php} (72%)
rename app/code/Magento/Signifyd/Test/Unit/Model/{CaseUpdatingServiceTest.php => CaseServices/UpdatingServiceTest.php} (88%)
rename dev/tests/integration/testsuite/Magento/Signifyd/Model/{CaseCreationServiceTest.php => CaseServices/CreationServiceTest.php} (93%)
rename dev/tests/integration/testsuite/Magento/Signifyd/Model/{CaseUpdatingServiceTest.php => CaseServices/UpdatingServiceTest.php} (90%)
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
index b513bb328db65..ce89bdf163dc3 100644
--- a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
@@ -8,7 +8,7 @@
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Exception\LocalizedException;
-use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
+use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory;
use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequestValidator;
use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequest;
use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessageReader;
@@ -37,7 +37,7 @@ class Handler extends Action
private $webhookMessageReader;
/**
- * @var CaseUpdatingServiceFactory
+ * @var UpdatingServiceFactory
*/
private $caseUpdatingServiceFactory;
@@ -51,7 +51,7 @@ class Handler extends Action
* @param WebhookRequest $webhookRequest
* @param LoggerInterface $logger
* @param WebhookMessageReader $webhookMessageReader
- * @param CaseUpdatingServiceFactory $caseUpdatingServiceFactory
+ * @param UpdatingServiceFactory $caseUpdatingServiceFactory
* @param WebhookRequestValidator $webhookRequestValidator
*/
public function __construct(
@@ -59,7 +59,7 @@ public function __construct(
WebhookRequest $webhookRequest,
LoggerInterface $logger,
WebhookMessageReader $webhookMessageReader,
- CaseUpdatingServiceFactory $caseUpdatingServiceFactory,
+ UpdatingServiceFactory $caseUpdatingServiceFactory,
WebhookRequestValidator $webhookRequestValidator
) {
parent::__construct($context);
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
similarity index 92%
rename from app/code/Magento/Signifyd/Model/CaseCreationService.php
rename to app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
index b546c9c63fe4f..d735aae67df41 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
@@ -3,7 +3,7 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
@@ -17,7 +17,7 @@
*
* Creates new Case entity and register it at Signifyd
*/
-class CaseCreationService implements CaseCreationServiceInterface
+class CreationService implements CaseCreationServiceInterface
{
/**
* @var CaseManagementInterface
@@ -40,7 +40,7 @@ class CaseCreationService implements CaseCreationServiceInterface
private $caseRepository;
/**
- * CaseCreationService constructor.
+ * CreationService constructor.
*
* @param CaseManagementInterface $caseManagement
* @param Gateway $signifydGateway
diff --git a/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseServices/StubUpdatingService.php
similarity index 77%
rename from app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
rename to app/code/Magento/Signifyd/Model/CaseServices/StubUpdatingService.php
index 9d7cffdd7ca1a..6c91235f22799 100644
--- a/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/StubUpdatingService.php
@@ -3,13 +3,13 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
/**
* Stub implementation for case updating service interface and might be used
* for test Signifyd webhooks
*/
-class StubCaseUpdatingService implements CaseUpdatingServiceInterface
+class StubUpdatingService implements UpdatingServiceInterface
{
/**
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
similarity index 87%
rename from app/code/Magento/Signifyd/Model/CaseUpdatingService.php
rename to app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
index 22a287357c771..8f002b82bac7b 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
@@ -3,20 +3,22 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NotFoundException;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
+use Magento\Signifyd\Model\CommentsHistoryUpdater;
+use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
/**
* Performs Signifyd case entity updating operations.
*/
-class CaseUpdatingService implements CaseUpdatingServiceInterface
+class UpdatingService implements UpdatingServiceInterface
{
/**
- * @var MessageGeneratorInterface
+ * @var GeneratorInterface
*/
private $messageGenerator;
@@ -31,14 +33,14 @@ class CaseUpdatingService implements CaseUpdatingServiceInterface
private $commentsHistoryUpdater;
/**
- * CaseUpdatingService constructor.
+ * UpdatingService constructor.
*
- * @param MessageGeneratorInterface $messageGenerator
+ * @param GeneratorInterface $messageGenerator
* @param CaseRepositoryInterface $caseRepository
* @param CommentsHistoryUpdater $commentsHistoryUpdater
*/
public function __construct(
- MessageGeneratorInterface $messageGenerator,
+ GeneratorInterface $messageGenerator,
CaseRepositoryInterface $caseRepository,
CommentsHistoryUpdater $commentsHistoryUpdater
) {
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceFactory.php
similarity index 83%
rename from app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
rename to app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceFactory.php
index f9236a5fa9395..8c6023fae1445 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceFactory.php
@@ -3,17 +3,18 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
use Magento\Framework\ObjectManagerInterface;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
+use Magento\Signifyd\Model\Config;
/**
* Creates instance of case updating service configured with specific message generator.
* The message generator initialization depends on specified type (like, case creation, re-scoring, review and
* guarantee completion).
*/
-class CaseUpdatingServiceFactory
+class UpdatingServiceFactory
{
/**
* Type of testing Signifyd case
@@ -37,7 +38,7 @@ class CaseUpdatingServiceFactory
private $config;
/**
- * CaseUpdatingServiceFactory constructor.
+ * UpdatingServiceFactory constructor.
*
* @param ObjectManagerInterface $objectManager
* @param GeneratorFactory $generatorFactory
@@ -58,17 +59,17 @@ public function __construct(
* As param retrieves type of message generator.
*
* @param string $type
- * @return CaseUpdatingServiceInterface
+ * @return UpdatingServiceInterface
* @throws \InvalidArgumentException
*/
public function create($type)
{
if (!$this->config->isActive() || $type === self::$caseTest) {
- return $this->objectManager->create(StubCaseUpdatingService::class);
+ return $this->objectManager->create(StubUpdatingService::class);
}
$messageGenerator = $this->generatorFactory->create($type);
- $service = $this->objectManager->create(CaseUpdatingService::class, [
+ $service = $this->objectManager->create(UpdatingService::class, [
'messageGenerator' => $messageGenerator
]);
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceInterface.php
similarity index 81%
rename from app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
rename to app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceInterface.php
index 3e221f24682e1..33d44e7c8cf3b 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceInterface.php
@@ -3,12 +3,12 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
/**
* Common abstraction to perform updating operations with Signifyd case entity.
*/
-interface CaseUpdatingServiceInterface
+interface UpdatingServiceInterface
{
/**
* Updates Signifyd Case entity by received data.
diff --git a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
index ff600b91d0a6b..976e5aa0a9dc6 100644
--- a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
+++ b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
@@ -41,6 +41,10 @@ public function __construct(HistoryFactory $historyFactory)
*/
public function addComment(CaseInterface $case, Phrase $message)
{
+ if (!$message->getText()) {
+ return;
+ }
+
/** @var \Magento\Sales\Api\Data\OrderStatusHistoryInterface $history */
$history = $this->historyFactory->create();
$history->setParentId($case->getOrderId())
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
index e3ca93842f29b..5801c4f490608 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
@@ -7,9 +7,9 @@
use Magento\Framework\Exception\AlreadyExistsException;
use Magento\Framework\Exception\NotFoundException;
-use Magento\Signifyd\Api\GuaranteeCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
-use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
+use Magento\Signifyd\Api\GuaranteeCreationServiceInterface;
+use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Psr\Log\LoggerInterface;
@@ -25,7 +25,7 @@ class CreationService implements GuaranteeCreationServiceInterface
private $caseManagement;
/**
- * @var CaseUpdatingServiceFactory
+ * @var UpdatingServiceFactory
*/
private $caseUpdatingServiceFactory;
@@ -43,13 +43,13 @@ class CreationService implements GuaranteeCreationServiceInterface
* CreationService constructor.
*
* @param CaseManagementInterface $caseManagement
- * @param CaseUpdatingServiceFactory $caseUpdatingServiceFactory
+ * @param UpdatingServiceFactory $caseUpdatingServiceFactory
* @param Gateway $gateway
* @param LoggerInterface $logger
*/
public function __construct(
CaseManagementInterface $caseManagement,
- CaseUpdatingServiceFactory $caseUpdatingServiceFactory,
+ UpdatingServiceFactory $caseUpdatingServiceFactory,
Gateway $gateway,
LoggerInterface $logger
) {
@@ -75,7 +75,7 @@ public function createForOrder($orderId)
__('Case for order with specified id "%1" is not registered in Signifyd', $orderId)
);
}
- if ($caseEntity->getGuaranteeDisposition() !== null) {
+ if ($caseEntity->getGuaranteeDisposition()) {
throw new AlreadyExistsException(
__('Guarantee for order "%1" has been created already', $orderId)
);
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
index c62d4334755ed..0c716b122501b 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -6,13 +6,11 @@
namespace Magento\Signifyd\Model\MessageGenerators;
use Magento\Signifyd\Api\CaseRepositoryInterface;
-use Magento\Signifyd\Model\MessageGeneratorException;
-use Magento\Signifyd\Model\MessageGeneratorInterface;
/**
* Generates message based on previous and current Case scores.
*/
-class CaseRescore implements MessageGeneratorInterface
+class CaseRescore implements GeneratorInterface
{
/**
* @var CaseRepositoryInterface
@@ -35,13 +33,13 @@ public function __construct(CaseRepositoryInterface $caseRepository)
public function generate(array $data)
{
if (empty($data['caseId'])) {
- throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
+ throw new GeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
$caseEntity = $this->caseRepository->getByCaseId($data['caseId']);
if ($caseEntity === null) {
- throw new MessageGeneratorException(__('Case entity not found.'));
+ throw new GeneratorException(__('Case entity not found.'));
}
return __(
diff --git a/app/code/Magento/Signifyd/Model/MessageGeneratorException.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php
similarity index 68%
rename from app/code/Magento/Signifyd/Model/MessageGeneratorException.php
rename to app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php
index 3958595bc1f45..ed967da231165 100644
--- a/app/code/Magento/Signifyd/Model/MessageGeneratorException.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php
@@ -3,14 +3,14 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\MessageGenerators;
use Magento\Framework\Exception\LocalizedException;
/**
* Common exception for Signifyd message generators.
*/
-class MessageGeneratorException extends LocalizedException
+class GeneratorException extends LocalizedException
{
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
index 6f9f855350441..cd40b6b9ab7ac 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
@@ -44,7 +44,7 @@ class GeneratorFactory
private static $guaranteeCreation = 'guarantees/creation';
/**
- * CaseUpdatingServiceFactory constructor.
+ * UpdatingServiceFactory constructor.
*
* @param ObjectManagerInterface $objectManager
*/
@@ -58,7 +58,7 @@ public function __construct(ObjectManagerInterface $objectManager)
* Throws exception if type of message generator does not have implementations.
*
* @param string $type
- * @return MessageGeneratorInterface
+ * @return GeneratorInterface
* @throws \InvalidArgumentException
*/
public function create($type)
diff --git a/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorInterface.php
similarity index 80%
rename from app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
rename to app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorInterface.php
index 265b6ae1e5f5a..11726bf74a924 100644
--- a/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorInterface.php
@@ -3,19 +3,19 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\MessageGenerators;
/**
* Represents common abstraction for Signifyd Case/Guarantee messages.
* Each interface implementation might use Case/Guarantee data to generate specific message.
*/
-interface MessageGeneratorInterface
+interface GeneratorInterface
{
/**
* Creates new localized message based on Signifyd Case/Guarantee data.
* @param array $data
* @return \Magento\Framework\Phrase
- * @throws MessageGeneratorException
+ * @throws GeneratorException
*/
public function generate(array $data);
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php b/app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php
index e69bb565360b7..a03b32b243dd5 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php
@@ -5,9 +5,6 @@
*/
namespace Magento\Signifyd\Model\MessageGenerators;
-use Magento\Signifyd\Model\MessageGeneratorException;
-use Magento\Signifyd\Model\MessageGeneratorInterface;
-
/**
* Common implementation of message generator.
* Takes a message template (placeholders for localization also can be used) and list
@@ -18,7 +15,7 @@
* Message is 'Case Update: New score for the order is %1. Previous score was %2.', then the required params order
* should be ['new_score', 'prev_score'].
*/
-class PatternGenerator implements MessageGeneratorInterface
+class PatternGenerator implements GeneratorInterface
{
/**
* @var string
@@ -50,7 +47,7 @@ public function generate(array $data)
$placeholders = [];
foreach ($this->requiredParams as $param) {
if (empty($data[$param])) {
- throw new MessageGeneratorException(__('The "%1" should not be empty.', $param));
+ throw new GeneratorException(__('The "%1" should not be empty.', $param));
}
$placeholders[] = $data[$param];
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
index b9b29ae0766fa..9ce3d0ad682fb 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
@@ -6,17 +6,17 @@
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\Model\CaseUpdatingServiceFactory;
-use Magento\Signifyd\Model\CaseUpdatingService;
-use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequestValidator;
-use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequest;
-use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessageReader;
+use Magento\Signifyd\Controller\Webhooks\Handler;
+use Magento\Signifyd\Model\CaseServices\UpdatingService;
+use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory;
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 Psr\Log\LoggerInterface;
-use Magento\Signifyd\Controller\Webhooks\Handler;
-use Magento\Framework\App\Response\RedirectInterface;
-use Magento\Framework\App\Response\Http as ResponseHttp;
/**
* Class IndexTest
@@ -66,7 +66,7 @@ class HandlerTest extends \PHPUnit_Framework_TestCase
private $webhookRequestValidator;
/**
- * @var CaseUpdatingServiceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var UpdatingServiceFactory|\PHPUnit_Framework_MockObject_MockObject
*/
private $caseUpdatingServiceFactory;
@@ -88,7 +88,7 @@ protected function setUp()
$this->webhookRequestValidator = $this->getMockBuilder(WebhookRequestValidator::class)
->disableOriginalConstructor()
->getMock();
- $this->caseUpdatingServiceFactory = $this->getMockBuilder(CaseUpdatingServiceFactory::class)
+ $this->caseUpdatingServiceFactory = $this->getMockBuilder(UpdatingServiceFactory::class)
->disableOriginalConstructor()
->getMock();
$this->logger = $this->getMockBuilder(LoggerInterface::class)
@@ -142,7 +142,7 @@ public function testExecuteSuccessfully()
->with($this->webhookRequest)
->willReturn($webhookMessage);
- $caseUpdatingService = $this->getMockBuilder(CaseUpdatingService::class)
+ $caseUpdatingService = $this->getMockBuilder(UpdatingService::class)
->disableOriginalConstructor()
->getMock();
$caseUpdatingService->expects($this->once())
@@ -184,7 +184,7 @@ public function testExecuteCaseUpdatingServiceException()
->with($this->webhookRequest)
->willReturn($webhookMessage);
- $caseUpdatingService = $this->getMockBuilder(CaseUpdatingService::class)
+ $caseUpdatingService = $this->getMockBuilder(UpdatingService::class)
->disableOriginalConstructor()
->getMock();
$caseUpdatingService->expects($this->once())
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
similarity index 72%
rename from app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
rename to app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
index 4c73756e39ac8..0639c420c9b9b 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
@@ -3,25 +3,25 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Unit\Model;
+namespace Magento\Signifyd\Test\Unit\Model\CaseServices;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Signifyd\Model\CaseUpdatingService;
-use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
+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\MessageGeneratorInterface;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
-use Magento\Signifyd\Model\StubCaseUpdatingService;
+use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Contains tests for case updating service factory.
*/
-class CaseUpdatingServiceFactoryTest extends \PHPUnit_Framework_TestCase
+class UpdatingServiceFactoryTest extends \PHPUnit_Framework_TestCase
{
/**
- * @var CaseUpdatingServiceFactory
+ * @var UpdatingServiceFactory
*/
private $factory;
@@ -61,7 +61,7 @@ protected function setUp()
->getMock();
$objectManager = new ObjectManager($this);
- $this->factory = $objectManager->getObject(CaseUpdatingServiceFactory::class, [
+ $this->factory = $objectManager->getObject(UpdatingServiceFactory::class, [
'objectManager' => $this->fakeObjectManager,
'generatorFactory' => $this->generatorFactory,
'config' => $this->config
@@ -71,7 +71,7 @@ protected function setUp()
/**
* Checks type of instance for updating service if Signifyd is not enabled.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::create
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory::create
*/
public function testCreateWithInactiveConfig()
{
@@ -82,17 +82,17 @@ public function testCreateWithInactiveConfig()
$this->fakeObjectManager->expects(self::once())
->method('create')
- ->with(StubCaseUpdatingService::class)
- ->willReturn(new StubCaseUpdatingService());
+ ->with(StubUpdatingService::class)
+ ->willReturn(new StubUpdatingService());
$instance = $this->factory->create($type);
- static::assertInstanceOf(StubCaseUpdatingService::class, $instance);
+ static::assertInstanceOf(StubUpdatingService::class, $instance);
}
/**
* Checks type of instance for updating service if test type is received.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::create
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory::create
*/
public function testCreateWithTestType()
{
@@ -103,17 +103,17 @@ public function testCreateWithTestType()
$this->fakeObjectManager->expects(self::once())
->method('create')
- ->with(StubCaseUpdatingService::class)
- ->willReturn(new StubCaseUpdatingService());
+ ->with(StubUpdatingService::class)
+ ->willReturn(new StubUpdatingService());
$instance = $this->factory->create($type);
- static::assertInstanceOf(StubCaseUpdatingService::class, $instance);
+ static::assertInstanceOf(StubUpdatingService::class, $instance);
}
/**
* Checks exception type and message for unknown case type.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::create
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory::create
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Specified message type does not supported.
*/
@@ -135,7 +135,7 @@ public function testCreateWithException()
/**
* Checks if factory creates correct instance of case updating service.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::create
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory::create
*/
public function testCreate()
{
@@ -144,7 +144,7 @@ public function testCreate()
->method('isActive')
->willReturn(true);
- $messageGenerator = $this->getMockBuilder(MessageGeneratorInterface::class)
+ $messageGenerator = $this->getMockBuilder(GeneratorInterface::class)
->disableOriginalConstructor()
->getMock();
$this->generatorFactory->expects(self::once())
@@ -152,16 +152,16 @@ public function testCreate()
->with($type)
->willReturn($messageGenerator);
- $service = $this->getMockBuilder(CaseUpdatingService::class)
+ $service = $this->getMockBuilder(UpdatingService::class)
->disableOriginalConstructor()
->getMock();
$this->fakeObjectManager->expects(self::once())
->method('create')
- ->with(CaseUpdatingService::class, ['messageGenerator' => $messageGenerator])
+ ->with(UpdatingService::class, ['messageGenerator' => $messageGenerator])
->willReturn($service);
$result = $this->factory->create($type);
- static::assertInstanceOf(CaseUpdatingService::class, $result);
+ static::assertInstanceOf(UpdatingService::class, $result);
}
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
similarity index 88%
rename from app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
rename to app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index 321953aef2120..581682c37b6a4 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
@@ -3,24 +3,24 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Unit\Model;
+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\CaseUpdatingService;
+use Magento\Signifyd\Model\CaseServices\UpdatingService;
use Magento\Signifyd\Model\CommentsHistoryUpdater;
-use Magento\Signifyd\Model\MessageGeneratorException;
-use Magento\Signifyd\Model\MessageGeneratorInterface;
+use Magento\Signifyd\Model\MessageGenerators\GeneratorException;
+use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Contains tests with different negative and positive scenarios for case updating service.
*/
-class CaseUpdatingServiceTest extends \PHPUnit_Framework_TestCase
+class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
{
/**
- * @var CaseUpdatingService
+ * @var UpdatingService
*/
private $service;
@@ -30,7 +30,7 @@ class CaseUpdatingServiceTest extends \PHPUnit_Framework_TestCase
private $objectManager;
/**
- * @var MessageGeneratorInterface|MockObject
+ * @var GeneratorInterface|MockObject
*/
private $messageGenerator;
@@ -51,7 +51,7 @@ protected function setUp()
{
$this->objectManager = new ObjectManager($this);
- $this->messageGenerator = $this->getMockBuilder(MessageGeneratorInterface::class)
+ $this->messageGenerator = $this->getMockBuilder(GeneratorInterface::class)
->disableOriginalConstructor()
->setMethods(['generate'])
->getMock();
@@ -66,7 +66,7 @@ protected function setUp()
->setMethods(['addComment'])
->getMock();
- $this->service = $this->objectManager->getObject(CaseUpdatingService::class, [
+ $this->service = $this->objectManager->getObject(UpdatingService::class, [
'messageGenerator' => $this->messageGenerator,
'caseRepository' => $this->caseRepository,
'commentsHistoryUpdater' => $this->commentsHistoryUpdater
@@ -76,7 +76,7 @@ protected function setUp()
/**
* Checks a test case when Signifyd case id is missed in input data.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage The "caseId" should not be empty.
*/
@@ -90,7 +90,7 @@ public function testUpdateWithFailedValidation()
/**
* Checks a test case when Signifyd case entity not found in repository.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
* @expectedException \Magento\Framework\Exception\NotFoundException
* @expectedExceptionMessage Case entity not found.
*/
@@ -112,7 +112,7 @@ public function testUpdateWithNotExistingCase()
/**
* Checks as test case when service cannot save Signifyd case entity
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage Cannot update Case entity.
*/
@@ -161,7 +161,7 @@ public function testUpdateWithFailedCaseSaving()
/**
* Checks as test case when message generator throws an exception
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage Cannot update Case entity.
*/
@@ -195,7 +195,7 @@ public function testUpdateWithExceptionFromMessageGenerator()
$this->messageGenerator->expects(self::once())
->method('generate')
->with($data)
- ->willThrowException(new MessageGeneratorException(__('Cannot generate message.')));
+ ->willThrowException(new GeneratorException(__('Cannot generate message.')));
$this->service->update($data);
}
@@ -203,7 +203,7 @@ public function testUpdateWithExceptionFromMessageGenerator()
/**
* Checks a test case when comments history updater throws an exception.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage Cannot update Case entity.
*/
@@ -251,7 +251,7 @@ public function testUpdateWithFailedCommentSaving()
/**
* Checks a test case when Signifyd case entity is successfully updated and message stored in comments history.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
*/
public function testUpdate()
{
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
index e154fc32afa9a..d85b0410ee27a 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
@@ -108,6 +108,22 @@ public function testAddComment()
$this->updater->addComment($this->caseEntity, __(self::$message));
}
+ /**
+ * 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');
+
+ $this->updater->addComment($this->caseEntity, __(''));
+ }
+
/**
* Creates mock object for history entity.
*
@@ -120,19 +136,19 @@ private function initCommentMock()
->setMethods(['setParentId', 'setComment', 'setEntityName', 'save'])
->getMockForAbstractClass();
- $this->historyFactory->expects(self::once())
+ $this->historyFactory->expects(self::any())
->method('create')
->willReturn($this->historyEntity);
- $this->historyEntity->expects(self::once())
+ $this->historyEntity->expects(self::any())
->method('setParentId')
->with(self::$orderId)
->willReturnSelf();
- $this->historyEntity->expects(self::once())
+ $this->historyEntity->expects(self::any())
->method('setComment')
->with(self::$message)
->willReturnSelf();
- $this->historyEntity->expects(self::once())
+ $this->historyEntity->expects(self::any())
->method('setEntityName')
->with('order')
->willReturnSelf();
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
index b8ee861c1e5dd..119165407e301 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
@@ -12,8 +12,8 @@
use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\Exception\AlreadyExistsException;
use Magento\Signifyd\Api\CaseManagementInterface;
-use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
-use Magento\Signifyd\Model\CaseUpdatingServiceInterface;
+use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory;
+use Magento\Signifyd\Model\CaseServices\UpdatingServiceInterface;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Psr\Log\LoggerInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
@@ -31,7 +31,7 @@ class CreationServiceTest extends TestCase
private $caseManagement;
/**
- * @var CaseUpdatingServiceInterface|MockObject
+ * @var UpdatingServiceInterface|MockObject
*/
private $caseUpdatingService;
@@ -50,10 +50,10 @@ public function setUp()
$this->caseManagement = $this->getMockBuilder(CaseManagementInterface::class)
->getMockForAbstractClass();
- $caseUpdatingServiceFactory = $this->getMockBuilder(CaseUpdatingServiceFactory::class)
+ $caseUpdatingServiceFactory = $this->getMockBuilder(UpdatingServiceFactory::class)
->disableOriginalConstructor()
->getMock();
- $this->caseUpdatingService = $this->getMockBuilder(CaseUpdatingServiceInterface::class)
+ $this->caseUpdatingService = $this->getMockBuilder(UpdatingServiceInterface::class)
->getMockForAbstractClass();
$caseUpdatingServiceFactory
->method('create')
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 2dc7a4b14c492..dc47f1458926c 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -65,7 +65,7 @@ protected function setUp()
/**
* Data array without required attribute caseId.
*
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedException \Magento\Signifyd\Model\MessageGenerators\GeneratorException
* @expectedExceptionMessage The "caseId" should not be empty
*/
public function testGenerateEmptyCaseIdException()
@@ -76,7 +76,7 @@ public function testGenerateEmptyCaseIdException()
/**
* Case entity was not found in DB.
*
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedException \Magento\Signifyd\Model\MessageGenerators\GeneratorException
* @expectedExceptionMessage Case entity not found.
*/
public function testGenerateNotFoundException()
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
index 32d3aeec52d36..e819a958cf6bf 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
@@ -16,7 +16,7 @@ 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\MessageGeneratorException
+ * @expectedException \Magento\Signifyd\Model\MessageGenerators\GeneratorException
* @expectedExceptionMessage The "caseId" should not be empty.
*/
public function testGenerateThrowsException()
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 9a2eb0527d63f..4b517ee389af9 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -10,7 +10,7 @@
-
+
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
index 952f961298218..c6d523a8cd50d 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
@@ -48,7 +48,6 @@ public function testExecuteSuccess()
static::assertNotEmpty($caseEntity);
static::assertEquals('2017-01-06 12:47:03', $caseEntity->getCreatedAt());
static::assertEquals('2017-01-06 12:47:03', $caseEntity->getUpdatedAt());
- static::assertEquals(CaseInterface::GUARANTEE_PENDING, $caseEntity->getGuaranteeDisposition());
static::assertEquals('Magento', $caseEntity->getAssociatedTeam()['teamName']);
static::assertEquals(true, $caseEntity->isGuaranteeEligible());
static::assertEquals(CaseInterface::STATUS_OPEN, $caseEntity->getStatus());
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
index 7271cdffcca21..9725956c6ceb6 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
@@ -11,7 +11,6 @@
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Model\CaseManagement;
use Magento\TestFramework\Helper\Bootstrap;
/**
@@ -57,7 +56,6 @@ public function testGetByOrderId()
$order = $this->getOrder();
$case = $this->caseManagement->getByOrderId($order->getEntityId());
- static::assertEquals(CaseInterface::GUARANTEE_PENDING, $case->getGuaranteeDisposition());
static::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus());
static::assertEquals(CaseInterface::DISPOSITION_GOOD, $case->getReviewDisposition());
static::assertEquals('2016-12-12 15:17:17', $case->getCreatedAt());
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
similarity index 93%
rename from dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
rename to dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
index fc4841c5388f8..4838bf794a513 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
@@ -3,7 +3,7 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -24,7 +24,7 @@
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CaseCreationServiceTest extends \PHPUnit_Framework_TestCase
+class CreationServiceTest extends \PHPUnit_Framework_TestCase
{
/**
* @var ObjectManager
@@ -47,7 +47,7 @@ class CaseCreationServiceTest extends \PHPUnit_Framework_TestCase
private $logger;
/**
- * @var CaseCreationService
+ * @var CreationService
*/
private $service;
@@ -87,7 +87,7 @@ protected function setUp()
->getMockForAbstractClass();
$this->service = $this->objectManager->create(
- CaseCreationService::class,
+ CreationService::class,
[
'signifydGateway' => $gateway,
'logger' => $this->logger
@@ -96,7 +96,7 @@ protected function setUp()
}
/**
- * @covers \Magento\Signifyd\Model\CaseCreationService::createForOrder
+ * @covers \Magento\Signifyd\Model\CaseServices\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
*/
public function testCreateForOrderWithEmptyResponse()
@@ -125,7 +125,7 @@ public function testCreateForOrderWithEmptyResponse()
}
/**
- * @covers \Magento\Signifyd\Model\CaseCreationService::createForOrder
+ * @covers \Magento\Signifyd\Model\CaseServices\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
*/
public function testCreateForOrderWithBadResponse()
@@ -162,7 +162,7 @@ public function testCreateForOrderWithBadResponse()
}
/**
- * @covers \Magento\Signifyd\Model\CaseCreationService::createForOrder
+ * @covers \Magento\Signifyd\Model\CaseServices\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
*/
public function testCreateOrderWithEmptyInvestigationId()
@@ -183,7 +183,7 @@ public function testCreateOrderWithEmptyInvestigationId()
}
/**
- * @covers \Magento\Signifyd\Model\CaseCreationService::createForOrder
+ * @covers \Magento\Signifyd\Model\CaseServices\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
*/
public function testCreateForOrder()
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
similarity index 90%
rename from dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
rename to dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
index 4862c160118d8..04813b3eb19f7 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
@@ -3,21 +3,20 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
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\MessageGenerators\CaseCreation;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
use Magento\TestFramework\Helper\Bootstrap;
/**
* Contains tests for case entity updating service.
*/
-class CaseUpdatingServiceTest extends \PHPUnit_Framework_TestCase
+class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
{
/**
* @var ObjectManager
@@ -25,7 +24,7 @@ class CaseUpdatingServiceTest extends \PHPUnit_Framework_TestCase
private $objectManager;
/**
- * @var CaseUpdatingService
+ * @var UpdatingService
*/
private $service;
@@ -40,7 +39,7 @@ protected function setUp()
$messageFactory = $this->objectManager->get(GeneratorFactory::class);
$messageGenerator = $messageFactory->create('cases/creation');
- $this->service = $this->objectManager->create(CaseUpdatingService::class, [
+ $this->service = $this->objectManager->create(UpdatingService::class, [
'messageGenerator' => $messageGenerator
]);
}
@@ -48,7 +47,7 @@ protected function setUp()
/**
* Checks case updating flow and messages in order comments history.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
* @magentoDataFixture Magento/Signifyd/_files/case.php
*/
public function testUpdate()
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
index 0900a9f1a2162..aa26311acf87a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -36,6 +36,11 @@ class CreationServiceTest extends \PHPUnit_Framework_TestCase
*/
private $logger;
+ /**
+ * @var ObjectManager
+ */
+ private $objectManager;
+
/**
* @inheritdoc
*/
@@ -64,18 +69,17 @@ protected function setUp()
* for a specified order.
*
* @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
+ * @expectedException \Magento\Framework\Exception\NotFoundException
+ * @expectedExceptionMessage Case for order with specified id "123" is not created
*/
public function testCreateWithoutCaseEntity()
{
$orderId = 123;
- $this->logger->expects(self::once())
- ->method('error')
- ->with('Cannot find case entity for order entity id: 123');
$this->gateway->expects(self::never())
->method('submitCaseForGuarantee');
- $result = $this->service->create($orderId);
+ $result = $this->service->createForOrder($orderId);
self::assertFalse($result);
}
@@ -101,30 +105,6 @@ public function testCreateWithFailedRequest()
self::assertFalse($result);
}
- /**
- * Checks a test case, when case entity updating is failed.
- *
- * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
- */
- public function testCreateWithFailedCaseUpdating()
- {
- $caseEntity = $this->getCaseEntity();
-
- $this->gateway->expects(self::once())
- ->method('submitCaseForGuarantee')
- ->with($caseEntity->getCaseId())
- ->willReturn('');
-
- $this->logger->expects(self::once())
- ->method('error')
- ->with('Cannot retrieve guarantee disposition for case: ' . $caseEntity->getEntityId() . '.');
-
- $result = $this->service->createForOrder($caseEntity->getOrderId());
- self::assertFalse($result);
- }
-
/**
* Checks a test case, when case entity is updated successfully.
*
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
index 0bd47cb790d9e..2c12403f93b63 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -23,7 +23,6 @@
$case = $caseFactory->create();
$case->setCaseId(123)
->setGuaranteeEligible(true)
- ->setGuaranteeDisposition(CaseInterface::GUARANTEE_PENDING)
->setStatus(CaseInterface::STATUS_PROCESSING)
->setScore(553)
->setOrderId($order->getEntityId())
From 73f4b291de9c9f2e80f334e30218a900e85068ee Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 12 Jan 2017 11:09:40 -0600
Subject: [PATCH 127/225] MAGETWO-62825: Guarantee creation possibility
validator
- Cover with unit test
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 14 +-
...ligible.php => CreateGuaranteeAbility.php} | 39 ++-
.../Guarantee/CreateGuaranteeAbilityTest.php | 257 ++++++++++++++++++
.../Adminhtml/Guarantee/CreateTest.php | 4 +-
4 files changed, 290 insertions(+), 24 deletions(-)
rename app/code/Magento/Signifyd/Model/Guarantee/{SubmitEligible.php => CreateGuaranteeAbility.php} (75%)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 9684a8bd10789..6fcdf24aafa3f 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -12,7 +12,7 @@
use Magento\Signifyd\Model\Config;
use Magento\Signifyd\Model\CaseManagement;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Model\Guarantee\SubmitEligible as GuaranteeSubmitEligible;
+use Magento\Signifyd\Model\Guarantee\CreateGuaranteeAbility;
/**
* Get Signifyd Case Info
@@ -30,9 +30,9 @@ class CaseInfo extends AbstractOrder
private $caseManagement;
/**
- * @var GuaranteeSubmitEligible
+ * @var CreateGuaranteeAbility
*/
- private $guaranteeSubmitEligible;
+ private $createGuaranteeAbility;
/**
* @var int
@@ -52,7 +52,7 @@ class CaseInfo extends AbstractOrder
* @param Admin $adminHelper
* @param Config $config
* @param CaseManagement $caseManagement
- * @param GuaranteeSubmitEligible $guaranteeSubmitEligible
+ * @param CreateGuaranteeAbility $createGuaranteeAbility
* @param array $data
*/
public function __construct(
@@ -61,12 +61,12 @@ public function __construct(
Admin $adminHelper,
Config $config,
CaseManagement $caseManagement,
- GuaranteeSubmitEligible $guaranteeSubmitEligible,
+ CreateGuaranteeAbility $createGuaranteeAbility,
array $data = []
) {
$this->config = $config;
$this->caseManagement = $caseManagement;
- $this->guaranteeSubmitEligible = $guaranteeSubmitEligible;
+ $this->createGuaranteeAbility = $createGuaranteeAbility;
parent::__construct($context, $registry, $adminHelper, $data);
}
@@ -172,7 +172,7 @@ public function getButtons()
{
$buttons = [];
- if ($this->guaranteeSubmitEligible->check($this->getOrderId())) {
+ if ($this->createGuaranteeAbility->isAvailable($this->getOrderId())) {
$buttons[] = $this->getSubmitButton();
}
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php b/app/code/Magento/Signifyd/Model/Guarantee/CreateGuaranteeAbility.php
similarity index 75%
rename from app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
rename to app/code/Magento/Signifyd/Model/Guarantee/CreateGuaranteeAbility.php
index 5e216a49c281d..57bd9f0f90830 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CreateGuaranteeAbility.php
@@ -14,9 +14,9 @@
use Magento\Signifyd\Model\CaseManagement;
/**
- * Checks if is possible to submit guarantee request for order.
+ * Checks if is possible to create Guarantee for order.
*/
-class SubmitEligible
+class CreateGuaranteeAbility
{
/**
* @var CaseManagement
@@ -34,7 +34,7 @@ class SubmitEligible
private $dateTimeFactory;
/**
- * Eligible count of days from the order date to submit a case for Guarantee.
+ * Eligible count of days from the order creation date to submit a case for Guarantee.
*
* @var int
*/
@@ -56,20 +56,32 @@ public function __construct(
}
/**
- * Checks if Guarantee submit is applicable for order and case.
+ * Checks if it is possible to create Guarantee for order and case.
*
* @param int $orderId
* @return bool
*/
- public function check($orderId)
+ public function isAvailable($orderId)
{
$case = $this->caseManagement->getByOrderId($orderId);
- if (null === $case || $case->isGuaranteeEligible() === false) {
+ if (null === $case) {
+ return false;
+ }
+
+ if ($case->isGuaranteeEligible() === false) {
return false;
}
$order = $this->getOrder($orderId);
- if (null === $order || $this->checkOrder($order) === false) {
+ 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;
}
@@ -80,21 +92,18 @@ public function check($orderId)
* 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 checkOrder(OrderInterface $order)
+ private function isOrderOlderThen($days, OrderInterface $order)
{
- if (in_array($order->getState(), [Order::STATE_CANCELED, Order::STATE_CLOSED])) {
- return false;
- }
-
$orderCreateDate = $this->dateTimeFactory->create($order->getCreatedAt(), new \DateTimeZone('UTC'));
$currentDate = $this->dateTimeFactory->create('now', new \DateTimeZone('UTC'));
- if ($orderCreateDate->diff($currentDate)->days >= static::$guarantyEligibleDays) {
- return false;
+ if ($orderCreateDate->diff($currentDate)->days >= $days) {
+ return true;
}
- return true;
+ return false;
}
/**
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
new file mode 100644
index 0000000000000..db279c724e263
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
@@ -0,0 +1,257 @@
+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));
+ }
+
+ 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/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
index 7375ff8c6d983..7add34e1a4586 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
@@ -52,7 +52,7 @@ public function testExecuteSuccess()
$this->getRequest()->setPostValue('orderId', $orderId);
$this->creationService->expects($this->once())
- ->method('create')
+ ->method('createForOrder')
->with($orderId)
->willReturn(true);
@@ -78,7 +78,7 @@ public function testExecuteWithEmptyOrderId()
$this->getRequest()->setPostValue('orderId', $orderId);
$this->creationService->expects($this->never())
- ->method('create');
+ ->method('createForOrder');
$this->dispatch(self::$entryPoint);
From 1c8213145a83fb6ff0da5278ed75257629623a08 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Thu, 12 Jan 2017 11:20:43 -0600
Subject: [PATCH 128/225] MAGETWO-62807: Case information block on order
details page in admin panel
- refactoring
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 162 +++++++++++++-----
.../view/adminhtml/templates/case_info.phtml | 19 +-
2 files changed, 130 insertions(+), 51 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 6fcdf24aafa3f..c2e424db42496 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -5,10 +5,8 @@
*/
namespace Magento\Signifyd\Block\Adminhtml;
-use Magento\Backend\Block\Template\Context;
-use Magento\Framework\Registry;
-use Magento\Sales\Block\Adminhtml\Order\AbstractOrder;
-use Magento\Sales\Helper\Admin;
+use Magento\Framework\View\Element\Template;
+use Magento\Framework\View\Element\Template\Context;
use Magento\Signifyd\Model\Config;
use Magento\Signifyd\Model\CaseManagement;
use Magento\Signifyd\Api\Data\CaseInterface;
@@ -17,13 +15,18 @@
/**
* Get Signifyd Case Info
*/
-class CaseInfo extends AbstractOrder
+class CaseInfo extends Template
{
/**
* @var Config
*/
private $config;
+ /**
+ * @var CaseInterface
+ */
+ private $caseEntity = null;
+
/**
* @var CaseManagement
*/
@@ -48,8 +51,6 @@ class CaseInfo extends AbstractOrder
* Constructor
*
* @param Context $context
- * @param Registry $registry
- * @param Admin $adminHelper
* @param Config $config
* @param CaseManagement $caseManagement
* @param CreateGuaranteeAbility $createGuaranteeAbility
@@ -57,8 +58,6 @@ class CaseInfo extends AbstractOrder
*/
public function __construct(
Context $context,
- Registry $registry,
- Admin $adminHelper,
Config $config,
CaseManagement $caseManagement,
CreateGuaranteeAbility $createGuaranteeAbility,
@@ -68,72 +67,148 @@ public function __construct(
$this->caseManagement = $caseManagement;
$this->createGuaranteeAbility = $createGuaranteeAbility;
- parent::__construct($context, $registry, $adminHelper, $data);
+ parent::__construct($context, $data);
+ }
+
+ /**
+ * Checks if service is enabled.
+ *
+ * @return boolean
+ */
+ public function isServiceActive()
+ {
+ return $this->config->isActive();
}
/**
- * Retrieve required options from parent
+ * Gets case entity associated with order id.
*
- * @throws \Magento\Framework\Exception\LocalizedException
- * @return void
+ * @return CaseInterface|null
*/
- protected function _beforeToHtml()
+ private function getCaseEntity()
{
- if (!$this->getParentBlock()) {
- throw new \Magento\Framework\Exception\LocalizedException(
- __('Please correct the parent block for this block.')
+ if (is_null($this->caseEntity)) {
+ $this->caseEntity = $this->caseManagement->getByOrderId(
+ $this->getOrderId()
);
}
- $this->setOrder($this->getParentBlock()->getOrder());
- foreach ($this->getParentBlock()->getOrderInfoData() as $key => $value) {
- $this->setDataUsingMethod($key, $value);
- }
+ return $this->caseEntity;
+ }
- parent::_beforeToHtml();
+ /**
+ * Checks if case is exists for order
+ *
+ * @return bool
+ */
+ public function isEmptyCase()
+ {
+ return is_null($this->getCaseEntity());
}
/**
- * Checks if service is enabled.
+ * Gets case status
*
- * @return boolean
+ * @return string
*/
- public function isServiceActive()
+ public function getCaseStatus()
{
- return $this->config->isActive();
+ return $this->isEmptyCase() ? '' : $this->getCaseEntity()->getStatus();
}
/**
- * Gets case entity associated with order id.
+ * Gets case score value
*
- * @return CaseInterface|null
+ * @return int
*/
- public function getCaseEntity()
+ public function getCaseScore()
{
- return $this->caseManagement->getByOrderId($this->getOrderId());
+ return $this->isEmptyCase() ? 0 : $this->getCaseEntity()->getScore();
}
/**
* Gets state of case guarantee eligible.
*
- * @param CaseInterface $caseEntity
- * @return \Magento\Framework\Phrase
+ * @return string|\Magento\Framework\Phrase
+ */
+ public function getCaseGuaranteeEligible()
+ {
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
+ return $this->getCaseEntity()->isGuaranteeEligible() ? __('Yes') : __('No');
+ }
+
+ /**
+ * Gets case guarantee disposition status.
+ *
+ * @return string
+ */
+ public function getCaseGuaranteeDisposition()
+ {
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
+ return $this->getCaseEntity()->getGuaranteeDisposition();
+ }
+
+ /**
+ * Gets case review disposition status.
+ *
+ * @return string
*/
- public function getGuaranteeEligible(CaseInterface $caseEntity)
+ public function getCaseReviewDisposition()
{
- return $caseEntity->isGuaranteeEligible() ? __('Yes') : __('No');
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
+ return $this->getCaseEntity()->getReviewDisposition();
}
/**
- * Gets associated team name.
+ * Gets case create date.
*
- * @param CaseInterface $caseEntity
* @return string
*/
- public function getAssociatedTeam(CaseInterface $caseEntity)
+ public function getCaseCreatedAt()
{
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
+ return $this->getCaseEntity()->getCreatedAt();
+ }
+
+ /**
+ * Gets case update date.
+ *
+ * @return string
+ */
+ public function getCaseUpdatedAt()
+ {
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
+ return $this->getCaseEntity()->getUpdatedAt();
+ }
+
+ /**
+ * Gets case associated team name.
+ *
+ * @return string
+ */
+ public function getCaseAssociatedTeam()
+ {
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
$result = 'unknown';
- $team = $caseEntity->getAssociatedTeam();
+ $team = $this->getCaseEntity()->getAssociatedTeam();
if (isset($team['teamName'])) {
$result = $team['teamName'];
}
@@ -145,12 +220,15 @@ public function getAssociatedTeam(CaseInterface $caseEntity)
* Returns cell class name according to case score value.
* It could be used by merchant to customize order view template.
*
- * @param CaseInterface $caseEntity
* @return string
*/
- public function getScoreClass(CaseInterface $caseEntity)
+ public function getScoreClass()
{
- $score = $caseEntity->getScore();
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
+ $score = $this->getCaseEntity()->getScore();
if (self::$scoreAccept <= $score) {
$result = 'green';
@@ -201,6 +279,6 @@ private function getSubmitButton()
*/
private function getOrderId()
{
- return $this->getOrder()->getEntityId();
+ return (int) $this->getRequest()->getParam('order_id');
}
}
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 98b2b63224d4f..b0160e263ef98 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -8,7 +8,8 @@
?>
isServiceActive() || !($case = $block->getCaseEntity())) {
+
+ if (!$block->isServiceActive() || $block->isEmptyCase()) {
return '';
}
?>
@@ -32,14 +33,14 @@
- escapeHtml($case->getStatus()); ?>
- escapeHtml($case->getScore()); ?>
- escapeHtml($block->getGuaranteeEligible($case)); ?>
- escapeHtml($case->getGuaranteeDisposition()); ?>
- escapeHtml($block->getAssociatedTeam($case)); ?>
- escapeHtml($case->getReviewDisposition()); ?>
- escapeHtml($case->getCreatedAt()); ?>
- escapeHtml($case->getUpdatedAt()); ?>
+ escapeHtml($block->getCaseStatus()); ?>
+ escapeHtml($block->getCaseScore()); ?>
+ escapeHtml($block->getCaseGuaranteeEligible()); ?>
+ escapeHtml($block->getCaseGuaranteeDisposition()); ?>
+ escapeHtml($block->getCaseAssociatedTeam()); ?>
+ escapeHtml($block->getCaseReviewDisposition()); ?>
+ escapeHtml($block->getCaseCreatedAt()); ?>
+ escapeHtml($block->getCaseUpdatedAt()); ?>
From 342f7836b6e8decf502796d75dcaae4b4f7112c5 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 13 Jan 2017 03:56:46 -0600
Subject: [PATCH 129/225] MAGETWO-54393: Updating Order Status using Webhooks
- Refactored code according to code review
---
.../Signifyd/Api/Data/CaseInterface.php | 3 +-
.../Api/GuaranteeCreationServiceInterface.php | 2 -
.../Signifyd/Model/CommentsHistoryUpdater.php | 1 -
.../Model/Guarantee/CreationService.php | 27 ++--
.../Model/Guarantee/CreationServiceTest.php | 118 +++++++-----------
.../Model/Guarantee/CreationServiceTest.php | 5 +-
.../Request/CreateCaseBuilderTest.php | 2 +-
..._with_customer_and_two_simple_products.php | 2 +-
8 files changed, 62 insertions(+), 98 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index 13b6564ad3323..6e05d2334656e 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -76,8 +76,9 @@ public function setCaseId($id);
/**
* Returns value, which indicates if a guarantee can be requested for a case.
+ * Returns null if state of guarantee eligible does not set yet.
*
- * @return boolean
+ * @return boolean|null
*/
public function isGuaranteeEligible();
diff --git a/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
index ad6d5e8098190..3f3b0e223c71c 100644
--- a/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
@@ -20,8 +20,6 @@ interface GuaranteeCreationServiceInterface
*
* @param int $orderId
* @return bool
- * @throws \Magento\Framework\Exception\NotFoundException If case for specified order is not created yet.
- * @throws \Magento\Framework\Exception\AlreadyExistsException If guarantee already created.
*/
public function createForOrder($orderId);
}
diff --git a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
index 976e5aa0a9dc6..2f794aedca67a 100644
--- a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
+++ b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
@@ -26,7 +26,6 @@ class CommentsHistoryUpdater
*/
public function __construct(HistoryFactory $historyFactory)
{
-
$this->historyFactory = $historyFactory;
}
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
index 5801c4f490608..0288476bd6fcd 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
@@ -34,6 +34,11 @@ class CreationService implements GuaranteeCreationServiceInterface
*/
private $gateway;
+ /**
+ * @var CreateGuaranteeAbility
+ */
+ private $createGuaranteeAbility;
+
/**
* @var LoggerInterface
*/
@@ -45,17 +50,20 @@ class CreationService implements GuaranteeCreationServiceInterface
* @param CaseManagementInterface $caseManagement
* @param UpdatingServiceFactory $caseUpdatingServiceFactory
* @param Gateway $gateway
+ * @param CreateGuaranteeAbility $createGuaranteeAbility
* @param LoggerInterface $logger
*/
public function __construct(
CaseManagementInterface $caseManagement,
UpdatingServiceFactory $caseUpdatingServiceFactory,
Gateway $gateway,
+ CreateGuaranteeAbility $createGuaranteeAbility,
LoggerInterface $logger
) {
$this->caseManagement = $caseManagement;
$this->caseUpdatingServiceFactory = $caseUpdatingServiceFactory;
$this->gateway = $gateway;
+ $this->createGuaranteeAbility = $createGuaranteeAbility;
$this->logger = $logger;
}
@@ -64,23 +72,12 @@ public function __construct(
*/
public function createForOrder($orderId)
{
- $caseEntity = $this->caseManagement->getByOrderId($orderId);
- if ($caseEntity === null) {
- throw new NotFoundException(
- __('Case for order with specified id "%1" is not created', $orderId)
- );
- }
- if ($caseEntity->getCaseId() === null) {
- throw new NotFoundException(
- __('Case for order with specified id "%1" is not registered in Signifyd', $orderId)
- );
- }
- if ($caseEntity->getGuaranteeDisposition()) {
- throw new AlreadyExistsException(
- __('Guarantee for order "%1" has been created already', $orderId)
- );
+ if (!$this->createGuaranteeAbility->isAvailable($orderId)) {
+ return false;
}
+ $caseEntity = $this->caseManagement->getByOrderId($orderId);
+
try {
$disposition = $this->gateway->submitCaseForGuarantee($caseEntity->getCaseId());
} catch (GatewayException $e) {
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
index 119165407e301..cd41ce4c34d3b 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
@@ -5,18 +5,17 @@
*/
namespace Magento\Signifyd\Test\Unit\Model\Guarantee;
-use Magento\Signifyd\Model\SignifydGateway\GatewayException;
-use PHPUnit_Framework_TestCase as TestCase;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
-use Magento\Signifyd\Model\Guarantee\CreationService;
-use Magento\Framework\Exception\NotFoundException;
-use Magento\Framework\Exception\AlreadyExistsException;
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;
-use Magento\Signifyd\Api\Data\CaseInterface;
class CreationServiceTest extends TestCase
{
@@ -45,7 +44,15 @@ class CreationServiceTest extends TestCase
*/
private $logger;
- public function setUp()
+ /**
+ * @var CreateGuaranteeAbility|MockObject
+ */
+ private $createGuaranteeAbility;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
{
$this->caseManagement = $this->getMockBuilder(CaseManagementInterface::class)
->getMockForAbstractClass();
@@ -63,6 +70,11 @@ public function setUp()
->disableOriginalConstructor()
->getMock();
+ $this->createGuaranteeAbility = $this->getMockBuilder(CreateGuaranteeAbility::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['isAvailable'])
+ ->getMock();
+
$this->logger = $this->getMockBuilder(LoggerInterface::class)
->getMockForAbstractClass();
@@ -70,24 +82,33 @@ public function setUp()
$this->caseManagement,
$caseUpdatingServiceFactory,
$this->gateway,
+ $this->createGuaranteeAbility,
$this->logger
);
}
- public function testCreateForOrderWithoutCase()
+ /**
+ * 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()
{
- $dummyOrderId = 1;
- $this->withCaseEntityNotExistsForOrderId($dummyOrderId);
+ $orderId = 1;
- $this->gateway
- ->expects($this->never())
+ $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');
- $this->caseUpdatingService
- ->expects($this->never())
- ->method('update');
- $this->setExpectedException(NotFoundException::class);
- $this->service->createForOrder($dummyOrderId);
+ $result = $this->service->createForOrder($orderId);
+ self::assertFalse($result);
}
public function testCreateForOrderWitCase()
@@ -174,8 +195,6 @@ public function testCreateForOrderWithCaseUpdate()
);
$this->withGatewaySuccess($dummyGuaranteeDisposition);
-
-
$result = $this->service->createForOrder($dummyOrderId);
$this->assertEquals(
true,
@@ -184,62 +203,13 @@ public function testCreateForOrderWithCaseUpdate()
);
}
- public function testCreateForOrderWithNotRegisteredCase()
- {
- $dummyOrderId = 1;
- $dummyCaseId = null;
- $this->withCaseEntityExistsForOrderId(
- $dummyOrderId,
- [
- 'caseId' => $dummyCaseId,
- ]
- );
-
- $this->gateway
- ->expects($this->never())
- ->method('submitCaseForGuarantee');
- $this->caseUpdatingService
- ->expects($this->never())
- ->method('update');
- $this->setExpectedException(NotFoundException::class);
-
- $this->service->createForOrder($dummyOrderId);
- }
-
- public function testCreateForOrderWithExistedGuarantee()
- {
- $dummyOrderId = 1;
- $dummyCaseId = 42;
- $dummyGuarantyDisposition = 'APPROVED';
- $this->withCaseEntityExistsForOrderId(
- $dummyOrderId,
- [
- 'caseId' => $dummyCaseId,
- 'guaranteeDisposition' => $dummyGuarantyDisposition
- ]
- );
-
- $this->gateway
- ->expects($this->never())
- ->method('submitCaseForGuarantee');
- $this->caseUpdatingService
- ->expects($this->never())
- ->method('update');
- $this->setExpectedException(AlreadyExistsException::class);
-
- $this->service->createForOrder($dummyOrderId);
- }
-
- private function withCaseEntityNotExistsForOrderId($orderId)
- {
- $this->caseManagement
- ->method('getByOrderId')
- ->with($this->equalTo($orderId))
- ->willReturn(null);
- }
-
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) {
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
index aa26311acf87a..f42945a6bacd7 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -12,6 +12,7 @@
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
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;
@@ -69,8 +70,6 @@ protected function setUp()
* for a specified order.
*
* @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
- * @expectedException \Magento\Framework\Exception\NotFoundException
- * @expectedExceptionMessage Case for order with specified id "123" is not created
*/
public function testCreateWithoutCaseEntity()
{
@@ -95,7 +94,7 @@ public function testCreateWithFailedRequest()
$this->gateway->expects(self::once())
->method('submitCaseForGuarantee')
- ->willThrowException(new ApiCallException('Something wrong'));
+ ->willThrowException(new GatewayException('Something wrong'));
$this->logger->expects(self::once())
->method('error')
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
index d37d6fd6f8a7f..d1a863290d13f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -83,7 +83,7 @@ public function testCreateCaseBuilderWithFullSetOfData()
'orderSessionId' => $signifydOrderSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getIncrementId(),
- 'createdAt' => '2016-12-12T12:00:55+00:00',
+ 'createdAt' => date('c', strtotime(date('Y-m-d 00:00:55'))),
'paymentGateway' => 'paypal_account',
'transactionId' => $payment->getLastTransId(),
'currency' => $order->getOrderCurrencyCode(),
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
index 8f69f7a281610..a38cd01873cfc 100644
--- 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
@@ -71,7 +71,7 @@
->setCustomerId($customer->getId())
->setCustomerIsGuest(false)
->setRemoteIp('127.0.0.1')
- ->setCreatedAt('2016-12-12T12:00:55+0000')
+ ->setCreatedAt(date('Y-m-d 00:00:55'))
->setOrderCurrencyCode('USD')
->setBaseCurrencyCode('USD')
->setSubtotal($orderAmount)
From 828acbe2b763b06f2a80a5a89e4491db60550936 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 13 Jan 2017 05:08:23 -0600
Subject: [PATCH 130/225] MAGETWO-62807: Case information block on order
details page in admin panel
- Extension point created for sales order view
---
.../Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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
index 998e5e82a686a..4764050633c85 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml
+++ b/app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml
@@ -7,7 +7,7 @@
-->
-
+
From 2c5077d285f75ded9db183634cc5da246280d503 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 13 Jan 2017 05:15:32 -0600
Subject: [PATCH 131/225] MAGETWO-62825: Guarantee creation possibility
validator
- Add CreateGuarantyAbility check to controller
---
.../Controller/Adminhtml/Guarantee/Create.php | 14 +++++++++++---
.../Controller/Adminhtml/Guarantee/CreateTest.php | 2 +-
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php b/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
index 837f22e976b9c..54d41fe8bfa7c 100644
--- a/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
+++ b/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
@@ -7,6 +7,7 @@
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
+use Magento\Signifyd\Model\Guarantee\CreateGuaranteeAbility;
use Magento\Signifyd\Model\Guarantee\CreationService;
/**
@@ -20,17 +21,24 @@ class Create extends Action
* @var CreationService
*/
private $creationService;
+ /**
+ * @var CreateGuaranteeAbility
+ */
+ private $createGuaranteeAbility;
/**
* @param Context $context
* @param CreationService $creationService
+ * @param CreateGuaranteeAbility $createGuaranteeAbility
*/
public function __construct(
Context $context,
- CreationService $creationService
+ CreationService $creationService,
+ CreateGuaranteeAbility $createGuaranteeAbility
) {
parent::__construct($context);
$this->creationService = $creationService;
+ $this->createGuaranteeAbility = $createGuaranteeAbility;
}
/**
@@ -40,7 +48,7 @@ public function __construct(
*/
public function execute()
{
- $orderId = $this->getRequest()->getParam('orderId');
+ $orderId = (int)$this->getRequest()->getParam('orderId');
$resultRedirect = $this->resultRedirectFactory->create();
if (empty($orderId)) {
@@ -50,7 +58,7 @@ public function execute()
}
$resultRedirect->setPath('sales/order/view', ['order_id' => $orderId]);
- if ($this->creationService->createForOrder($orderId)) {
+ if ($this->createGuaranteeAbility->isAvailable($orderId) && $this->creationService->createForOrder($orderId)) {
$this->messageManager->addSuccessMessage(
__('Order has been submitted for Guarantee.')
);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
index 7add34e1a4586..71afeb8ad6dc9 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
@@ -102,7 +102,7 @@ public function testExecuteWithCreationServiceFail()
$this->getRequest()->setPostValue('orderId', $orderId);
$this->creationService->expects($this->once())
- ->method('create')
+ ->method('createForOrder')
->with($orderId)
->willReturn(false);
From b35187174567bff5ee7664e56fa4869089f32209 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 13 Jan 2017 09:28:35 -0600
Subject: [PATCH 132/225] MAGETWO-62807: Case information block on order
details page in admin panel
- refactoring
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 112 +++++++++---------
.../Unit/Block/Adminhtml/CaseInfoTest.php | 108 ++++++++++++++++-
2 files changed, 162 insertions(+), 58 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index c2e424db42496..7ddd7b02e0a0d 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -25,7 +25,7 @@ class CaseInfo extends Template
/**
* @var CaseInterface
*/
- private $caseEntity = null;
+ private $caseEntity = false;
/**
* @var CaseManagement
@@ -87,7 +87,7 @@ public function isServiceActive()
*/
private function getCaseEntity()
{
- if (is_null($this->caseEntity)) {
+ if ($this->caseEntity === false) {
$this->caseEntity = $this->caseManagement->getByOrderId(
$this->getOrderId()
);
@@ -96,6 +96,18 @@ private function getCaseEntity()
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
*
@@ -113,7 +125,9 @@ public function isEmptyCase()
*/
public function getCaseStatus()
{
- return $this->isEmptyCase() ? '' : $this->getCaseEntity()->getStatus();
+ return $this->getCaseProperty('', function () {
+ return $this->getCaseEntity()->getStatus();
+ });
}
/**
@@ -123,7 +137,9 @@ public function getCaseStatus()
*/
public function getCaseScore()
{
- return $this->isEmptyCase() ? 0 : $this->getCaseEntity()->getScore();
+ return $this->getCaseProperty(0, function () {
+ return $this->getCaseEntity()->getScore();
+ });
}
/**
@@ -133,11 +149,9 @@ public function getCaseScore()
*/
public function getCaseGuaranteeEligible()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- return $this->getCaseEntity()->isGuaranteeEligible() ? __('Yes') : __('No');
+ return $this->getCaseProperty('', function () {
+ return $this->getCaseEntity()->isGuaranteeEligible() ? __('Yes') : __('No');
+ });
}
/**
@@ -147,11 +161,9 @@ public function getCaseGuaranteeEligible()
*/
public function getCaseGuaranteeDisposition()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- return $this->getCaseEntity()->getGuaranteeDisposition();
+ return $this->getCaseProperty('', function () {
+ return $this->getCaseEntity()->getGuaranteeDisposition();
+ });
}
/**
@@ -161,11 +173,9 @@ public function getCaseGuaranteeDisposition()
*/
public function getCaseReviewDisposition()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- return $this->getCaseEntity()->getReviewDisposition();
+ return $this->getCaseProperty('', function () {
+ return $this->getCaseEntity()->getReviewDisposition();
+ });
}
/**
@@ -175,11 +185,9 @@ public function getCaseReviewDisposition()
*/
public function getCaseCreatedAt()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- return $this->getCaseEntity()->getCreatedAt();
+ return $this->getCaseProperty('asd', function () {
+ return $this->getCaseEntity()->getCreatedAt();
+ });
}
/**
@@ -189,11 +197,9 @@ public function getCaseCreatedAt()
*/
public function getCaseUpdatedAt()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- return $this->getCaseEntity()->getUpdatedAt();
+ return $this->getCaseProperty('', function () {
+ return $this->getCaseEntity()->getUpdatedAt();
+ });
}
/**
@@ -203,17 +209,15 @@ public function getCaseUpdatedAt()
*/
public function getCaseAssociatedTeam()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- $result = 'unknown';
- $team = $this->getCaseEntity()->getAssociatedTeam();
- if (isset($team['teamName'])) {
- $result = $team['teamName'];
- }
-
- return $result;
+ return $this->getCaseProperty('', function () {
+ $teamName = 'unknown';
+ $team = $this->getCaseEntity()->getAssociatedTeam();
+ if (isset($team['teamName'])) {
+ $teamName = $team['teamName'];
+ }
+
+ return $teamName;
+ });
}
/**
@@ -224,21 +228,19 @@ public function getCaseAssociatedTeam()
*/
public function getScoreClass()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- $score = $this->getCaseEntity()->getScore();
-
- if (self::$scoreAccept <= $score) {
- $result = 'green';
- } elseif ($score <= self::$scoreDecline) {
- $result = 'red';
- } else {
- $result = 'yellow';
- }
-
- return $result;
+ return $this->getCaseProperty('', function () {
+ $score = $this->getCaseEntity()->getScore();
+
+ if (self::$scoreAccept <= $score) {
+ $result = 'green';
+ } elseif ($score <= self::$scoreDecline) {
+ $result = 'red';
+ } else {
+ $result = 'yellow';
+ }
+
+ return $result;
+ });
}
/**
diff --git a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
index 5384ce749a0bd..060a3a1e49421 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
@@ -5,10 +5,15 @@
*/
namespace Magento\Signifyd\Test\Unit\Block\Adminhtml;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+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\Model\Config;
+use Magento\Signifyd\Model\CaseManagement;
+use Magento\Signifyd\Model\Guarantee\CreateGuaranteeAbility;
use Magento\Signifyd\Block\Adminhtml\CaseInfo;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Tests for Signifyd block information.
@@ -27,6 +32,31 @@ class CaseInfoTest extends \PHPUnit_Framework_TestCase
*/
private $caseInfo;
+ /**
+ * @var Context
+ */
+ private $context;
+
+ /**
+ * @var Config
+ */
+ private $config;
+
+ /**
+ * @var CaseManagement
+ */
+ private $caseManagement;
+
+ /**
+ * @var CreateGuaranteeAbility
+ */
+ private $createGuaranteeAbility;
+
+ /**
+ * @var RequestInterface
+ */
+ private $request;
+
/**
* @inheritdoc
*/
@@ -34,12 +64,40 @@ 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->createGuaranteeAbility = $this->getMockBuilder(CreateGuaranteeAbility::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
$this->caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
->setMethods(['getScore'])
->getMockForAbstractClass();
- $this->caseInfo = $objectManager->getObject(CaseInfo::class);
+ $this->caseInfo = $objectManager->getObject(CaseInfo::class, [
+ 'context' => $this->context,
+ 'config' => $this->config,
+ 'caseManagement' => $this->caseManagement,
+ 'createGuaranteeAbility' => $this->createGuaranteeAbility
+ ]);
}
/**
@@ -56,9 +114,53 @@ public function testGetScoreClass($score, $expectedClassName)
->method('getScore')
->willReturn($score);
+ $this->caseManagement->expects(self::once())
+ ->method('getByOrderId')
+ ->willReturn($this->caseEntity);
+
self::assertEquals(
$expectedClassName,
- $this->caseInfo->getScoreClass($this->caseEntity)
+ $this->caseInfo->getScoreClass()
+ );
+ }
+
+ /**
+ * Checks case property getter with real case.
+ *
+ * @covers \Magento\Signifyd\Block\CaseInfo::getCaseProperty
+ */
+ public function testCasePropertyWithCaseExists()
+ {
+ $score = 575;
+
+ $this->caseEntity->expects($this->once())
+ ->method('getScore')
+ ->willReturn($score);
+
+ $this->caseManagement->expects(self::once())
+ ->method('getByOrderId')
+ ->willReturn($this->caseEntity);
+
+ self::assertEquals(
+ $score,
+ $this->caseInfo->getCaseScore()
+ );
+ }
+
+ /**
+ * Checks case property getter with empty case.
+ *
+ * @covers \Magento\Signifyd\Block\CaseInfo::getCaseProperty
+ */
+ public function testCasePropertyWithEmptyCase()
+ {
+ $this->caseManagement->expects(self::once())
+ ->method('getByOrderId')
+ ->willReturn(null);
+
+ self::assertEquals(
+ 0,
+ $this->caseInfo->getCaseScore()
);
}
From f910c71303c21018322066397b80fe5e29130f20 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 13 Jan 2017 10:28:35 -0600
Subject: [PATCH 133/225] MAGETWO-62807: Case information block on order
details page in admin panel
- refactoring
---
app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php | 4 ++--
.../Signifyd/view/adminhtml/templates/case_info.phtml | 10 +++++-----
.../Signifyd/view/adminhtml/web/js/request-send.js | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 7ddd7b02e0a0d..6d964c3c92e89 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -103,7 +103,7 @@ private function getCaseEntity()
* @param callable $callback
* @return mixed
*/
- private function getCaseProperty( $defaultValue, callable $callback)
+ private function getCaseProperty($defaultValue, callable $callback)
{
return $this->isEmptyCase() ? $defaultValue : call_user_func($callback);
}
@@ -115,7 +115,7 @@ private function getCaseProperty( $defaultValue, callable $callback)
*/
public function isEmptyCase()
{
- return is_null($this->getCaseEntity());
+ return $this->getCaseEntity() === null;
}
/**
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index b0160e263ef98..679a584fa2ad5 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -46,20 +46,20 @@
getButtons() as $button):?>
-
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index 2b5569dbf8c50..c59c64a5f60e1 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -5,13 +5,11 @@
*/
namespace Magento\Signifyd\Block\Adminhtml;
-use Magento\Backend\Block\Template;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\View\LayoutInterface;
use Magento\Sales\Model\Order;
-use Magento\Sales\Model\OrderRepository;
use Magento\TestFramework\Helper\Bootstrap;
class CaseInfoTest extends \PHPUnit_Framework_TestCase
@@ -31,16 +29,6 @@ class CaseInfoTest extends \PHPUnit_Framework_TestCase
*/
private $layout;
- /**
- * @var string
- */
- private static $submitButton = 'Submit Guarantee Request';
-
- /**
- * @var string
- */
- private static $cancelButton = 'Cancel Guarantee Request';
-
/**
* @inheritdoc
*/
@@ -100,69 +88,6 @@ public function testCaseEntityExists()
static::assertContains('col-case-score-green', $html);
}
- /**
- * Checks state of Guarantee action buttons on order page.
- *
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getButtons
- * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoAppArea adminhtml
- */
- public function testSubmitButtonAvailable()
- {
- $this->order->loadByIncrementId('100000001');
-
- $blockContents = $this->getBlockContents();
-
- static::assertContains(self::$submitButton, $blockContents);
- static::assertNotContains(self::$cancelButton, $blockContents);
- }
-
- /**
- * Checks that guarantee action buttons is unavailable on order page.
- *
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getButtons
- * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoAppArea adminhtml
- */
- public function testButtonsUnavailable()
- {
- $this->order->loadByIncrementId('100000001');
- $this->order->setState(Order::STATE_CANCELED);
-
- /** @var OrderRepository $orderRepository */
- $orderRepository = $this->objectManager->get(OrderRepository::class);
- $orderRepository->save($this->order);
-
- $blockContents = $this->getBlockContents();
-
- static::assertNotContains(self::$submitButton, $blockContents);
- static::assertNotContains(self::$cancelButton, $blockContents);
- }
-
- /**
- * Checks action buttons for case entity with Guarantee submitted.
- *
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getButtons
- * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
- * @magentoDataFixture Magento/Signifyd/_files/approved_case.php
- * @magentoAppArea adminhtml
- */
- public function testButtonsForApprovedCase()
- {
- $this->order->loadByIncrementId('100000001');
-
- /** @var OrderRepository $orderRepository */
- $orderRepository = $this->objectManager->get(OrderRepository::class);
- $orderRepository->save($this->order);
-
- $blockContents = $this->getBlockContents();
-
- static::assertNotContains(self::$submitButton, $blockContents);
- static::assertContains(self::$cancelButton, $blockContents);
- }
-
/**
* Renders block contents.
*
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CancelTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CancelTest.php
deleted file mode 100644
index 05089bde9ac56..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CancelTest.php
+++ /dev/null
@@ -1,157 +0,0 @@
-cancelingService = $this->getMockBuilder(GuaranteeCancelingServiceInterface::class)
- ->disableOriginalConstructor()
- ->setMethods(['cancelForOrder'])
- ->getMockForAbstractClass();
-
- $this->_objectManager->addSharedInstance($this->cancelingService, CancelingService::class);
- }
-
- /**
- * @inheritdoc
- */
- protected function tearDown()
- {
- $this->_objectManager->removeSharedInstance(CancelingService::class);
-
- parent::tearDown();
- }
-
- /**
- * Checks a test case, when order id is missed in request.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Cancel::execute
- * @magentoAppArea adminhtml
- */
- public function testExecuteWithEmptyOrderId()
- {
- $this->getRequest()->setPostValue('order_id', null);
-
- $this->cancelingService->expects(self::never())
- ->method('cancelForOrder');
-
- $this->dispatch(self::$entryPoint);
-
- self::assertRedirect(self::stringContains('backend/sales/order/index'));
- self::assertSessionMessages(
- self::equalTo(['Order id is required.']),
- MessageInterface::TYPE_ERROR
- );
- }
-
- /**
- * Checks a test case, when guarantee is not available for canceling.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Cancel::execute
- * @magentoAppArea adminhtml
- */
- public function testExecuteWithNotAvailableGuarantee()
- {
- $this->getRequest()->setPostValue('order_id', 123);
-
- $this->cancelingService->expects(self::never())
- ->method('cancelForOrder');
-
- $this->dispatch(self::$entryPoint);
-
- self::assertRedirect(self::stringContains('backend/sales/order/view'));
- self::assertSessionMessages(
- self::equalTo(['Sorry, we cannot cancel Guarantee for order.']),
- MessageInterface::TYPE_ERROR
- );
- }
-
- /**
- * Checks as test case, when canceling service cannot successfully cancel guarantee.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Cancel::execute
- * @magentoDataFixture Magento/Signifyd/_files/approved_case.php
- * @magentoAppArea adminhtml
- */
- public function testExecuteWithCancelingFailedRequest()
- {
- $caseId = 123;
-
- /** @var CaseRepositoryInterface $caseRepository */
- $caseRepository = $this->_objectManager->get(CaseRepositoryInterface::class);
- $caseEntity = $caseRepository->getByCaseId($caseId);
-
- $this->getRequest()->setPostValue('order_id', $caseEntity->getOrderId());
-
- $this->cancelingService->expects(self::once())
- ->method('cancelForOrder')
- ->with(self::equalTo($caseEntity->getOrderId()))
- ->willReturn(false);
-
- $this->dispatch(self::$entryPoint);
-
- self::assertRedirect(self::stringContains('backend/sales/order/view'));
- self::assertSessionMessages(
- self::equalTo(['Sorry, we cannot cancel Guarantee for order.']),
- MessageInterface::TYPE_ERROR
- );
- }
-
- /**
- * Checks a test case, when guarantee is successfully canceled for order.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Cancel::execute
- * @magentoDataFixture Magento/Signifyd/_files/approved_case.php
- * @magentoAppArea adminhtml
- */
- public function testExecute()
- {
- $caseId = 123;
-
- /** @var CaseRepositoryInterface $caseRepository */
- $caseRepository = $this->_objectManager->get(CaseRepositoryInterface::class);
- $caseEntity = $caseRepository->getByCaseId($caseId);
-
- $this->getRequest()->setPostValue('order_id', $caseEntity->getOrderId());
-
- $this->cancelingService->expects(self::once())
- ->method('cancelForOrder')
- ->with(self::equalTo($caseEntity->getOrderId()))
- ->willReturn(true);
-
- $this->dispatch(self::$entryPoint);
-
- self::assertRedirect(self::stringContains('backend/sales/order/view'));
- self::assertSessionMessages(
- self::equalTo(['Guarantee has been cancelled for order.']),
- MessageInterface::TYPE_SUCCESS
- );
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
deleted file mode 100644
index 4c1e4e61cba7c..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
+++ /dev/null
@@ -1,133 +0,0 @@
-creationService = $this->getMockBuilder(CreationService::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->_objectManager->addSharedInstance($this->creationService, CreationService::class);
- }
-
- /**
- * Tests successful Guarantee creation for an order.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Create::execute
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoAppArea adminhtml
- */
- public function testExecuteSuccess()
- {
- $orderId = $this->getOrderId();
- $this->getRequest()->setPostValue('order_id', $orderId);
-
- $this->creationService->expects($this->once())
- ->method('createForOrder')
- ->with($orderId)
- ->willReturn(true);
-
- $this->dispatch(self::$entryPoint);
-
- $this->assertRedirect($this->stringContains('backend/sales/order/view'));
- $this->assertSessionMessages(
- $this->equalTo(['Order has been submitted for Guarantee.']),
- MessageInterface::TYPE_SUCCESS
- );
- }
-
- /**
- * Tests failure Guarantee creation due to empty order id.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Create::execute
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoAppArea adminhtml
- */
- public function testExecuteWithEmptyOrderId()
- {
- $orderId = '';
- $this->getRequest()->setPostValue('order_id', $orderId);
-
- $this->creationService->expects($this->never())
- ->method('createForOrder');
-
- $this->dispatch(self::$entryPoint);
-
- $this->assertRedirect($this->stringContains('backend/sales/order/index'));
- $this->assertSessionMessages(
- $this->equalTo(['Order id is required.']),
- MessageInterface::TYPE_ERROR
- );
- }
-
- /**
- * Tests failure Guarantee creation due to unsuccessful CreationService call.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Create::execute
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoAppArea adminhtml
- */
- public function testExecuteWithCreationServiceFail()
- {
- $orderId = $this->getOrderId();
- $this->getRequest()->setPostValue('order_id', $orderId);
-
- $this->creationService->expects($this->once())
- ->method('createForOrder')
- ->with($orderId)
- ->willReturn(false);
-
- $this->dispatch(self::$entryPoint);
-
- $this->assertRedirect($this->stringContains('backend/sales/order/view'));
- $this->assertSessionMessages(
- $this->equalTo(['Sorry, we cannot submit order for Guarantee.']),
- MessageInterface::TYPE_ERROR
- );
- }
-
- /**
- * Returns orderId from case in fixture
- *
- * @return int
- */
- private function getOrderId()
- {
- $caseId = 123;
- /** @var CaseRepositoryInterface $caseRepository */
- $caseRepository = $this->_objectManager->get(CaseRepositoryInterface::class);
- /** @var CaseInterface $caseEntity */
- $caseEntity = $caseRepository->getByCaseId($caseId);
-
- return $caseEntity->getOrderId();
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
new file mode 100644
index 0000000000000..d00204191aa32
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
@@ -0,0 +1,119 @@
+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 triggers event to cancel Signifyd case guarantee
+ *
+ * @covers \Magento\Signifyd\Observer\CancelOrder::execute
+ * @magentoDataFixture Magento/Signifyd/_files/approved_case.php
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ */
+ public function testExecute()
+ {
+ $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 FilterBuilder $filterBuilder */
+ $filterBuilder = $this->objectManager->get(FilterBuilder::class);
+ $filters = [
+ $filterBuilder->setField(OrderInterface::INCREMENT_ID)
+ ->setValue('100000001')
+ ->create()
+ ];
+
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ ->create();
+
+ $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
+ $orders = $orderRepository->getList($searchCriteria)
+ ->getItems();
+
+ /** @var OrderInterface $order */
+ return array_pop($orders);
+ }
+}
From 067f39c00094f14c7d7560a8dd4cacb11da718af Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 3 Feb 2017 05:08:33 -0600
Subject: [PATCH 161/225] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Added missed namespace
---
.../testsuite/Magento/Signifyd/Observer/CancelOrderTest.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
index d00204191aa32..94f1779312f1f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
@@ -3,6 +3,8 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+namespace Magento\Signifyd\Observer;
+
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Sales\Api\Data\OrderInterface;
@@ -15,7 +17,7 @@
use Magento\TestFramework\ObjectManager;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
-class CancelOrderTest extends PHPUnit_Framework_TestCase
+class CancelOrderTest extends \PHPUnit_Framework_TestCase
{
/**
* @var int
From 5d527cd45f882cdba7fbd518d21c78fc1580e949 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 3 Feb 2017 05:11:14 -0600
Subject: [PATCH 162/225] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- static test fix
---
app/code/Magento/Signifyd/Setup/InstallData.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Setup/InstallData.php b/app/code/Magento/Signifyd/Setup/InstallData.php
index d82a16a5a0286..1436d52d4b823 100644
--- a/app/code/Magento/Signifyd/Setup/InstallData.php
+++ b/app/code/Magento/Signifyd/Setup/InstallData.php
@@ -33,7 +33,8 @@ public function __construct(
/**
* Installs data for sales module
*
- * Update of sales_order_grid* tables is provided here to be sure that these tables are already created. {@inheritdoc}
+ * Update of sales_order_grid* tables is provided here to be sure that these tables are already created.
+ * {@inheritdoc}
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
From 3fc99c3875fcafa739caa58704b5f4d5f9a8d6e8 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 3 Feb 2017 06:00:10 -0600
Subject: [PATCH 163/225] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- SalesArchive dependency added
(cherry picked from commit 4c897f1)
---
app/code/Magento/Signifyd/composer.json | 1 +
app/code/Magento/Signifyd/etc/module.xml | 1 +
2 files changed, 2 insertions(+)
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index cf9b2311bbba5..87ce791eae618 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -5,6 +5,7 @@
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"magento/framework": "100.2.*",
"magento/module-sales": "100.2.*",
+ "magento/module-sales-archive": "100.2.*",
"magento/module-store": "100.2.*",
"magento/module-customer": "100.2.*",
"magento/module-directory": "100.2.*",
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index e2469080bdac2..5d973cc95851e 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,6 +9,7 @@
+
From 856ff86e05013fa85c176c9d34b4488d56f6a064 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 6 Feb 2017 03:02:23 -0600
Subject: [PATCH 164/225] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- type attribute removed for VirtualType
(cherry picked from commit 44d6ceb)
---
app/code/Magento/Signifyd/etc/di.xml | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index fd2396f1b0aa2..2f0261ec8d131 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -14,8 +14,7 @@
-
-
+
-
@@ -29,8 +28,7 @@
-
-
+
-
From dd08983cc002b45ba9e8d10d9aaea0b2cfb144bd Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 6 Feb 2017 06:02:30 -0600
Subject: [PATCH 165/225] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Added api interfaces and default mapper implementation
- Added AVS, CVV codes mapper for Braintree payment method
(cherry picked from commit e928e23)
---
.../SignifydGateway/Request/PurchaseBuilder.php | 17 +++++++++++++++--
app/code/Magento/Signifyd/composer.json | 3 ++-
app/code/Magento/Signifyd/etc/module.xml | 1 +
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index dd464f73c1df2..524b4a2e6ab8f 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -6,8 +6,9 @@
namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\App\Area;
-use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Config\ScopeInterface;
+use Magento\Framework\Intl\DateTimeFactory;
+use Magento\Payment\Api\Data\CodeVerificationInterfaceFactory;
use Magento\Sales\Model\Order;
use Magento\Signifyd\Model\SignifydOrderSessionId;
@@ -31,19 +32,27 @@ class PurchaseBuilder
*/
private $signifydOrderSessionId;
+ /**
+ * @var CodeVerificationInterfaceFactory
+ */
+ private $codeVerificationFactory;
+
/**
* @param DateTimeFactory $dateTimeFactory
* @param ScopeInterface $scope
* @param SignifydOrderSessionId $signifydOrderSessionId
+ * @param CodeVerificationInterfaceFactory $codeVerificationFactory
*/
public function __construct(
DateTimeFactory $dateTimeFactory,
ScopeInterface $scope,
- SignifydOrderSessionId $signifydOrderSessionId
+ SignifydOrderSessionId $signifydOrderSessionId,
+ CodeVerificationInterfaceFactory $codeVerificationFactory
) {
$this->dateTimeFactory = $dateTimeFactory;
$this->scope = $scope;
$this->signifydOrderSessionId = $signifydOrderSessionId;
+ $this->codeVerificationFactory = $codeVerificationFactory;
}
/**
@@ -60,6 +69,8 @@ public function build(Order $order)
new \DateTimeZone('UTC')
);
+ $verificationService = $this->codeVerificationFactory->create($orderPayment);
+
$result = [
'purchase' => [
'orderSessionId' => $this->signifydOrderSessionId->get($order->getQuoteId()),
@@ -69,6 +80,8 @@ public function build(Order $order)
'paymentGateway' => $this->getPaymentGateway($orderPayment->getMethod()),
'transactionId' => $orderPayment->getLastTransId(),
'currency' => $order->getOrderCurrencyCode(),
+ 'avsResponseCode' => $verificationService->getAvsCode(),
+ 'cvvResponseCode' => $verificationService->getCvvCode(),
'orderChannel' => $this->getOrderChannel(),
'totalPrice' => $order->getGrandTotal(),
],
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 87ce791eae618..3c5d5bd592253 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -10,7 +10,8 @@
"magento/module-customer": "100.2.*",
"magento/module-directory": "100.2.*",
"magento/module-checkout": "100.2.*",
- "magento/module-backend": "100.2.*"
+ "magento/module-backend": "100.2.*",
+ "magento/module-payment": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 5d973cc95851e..602860b1be220 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -15,6 +15,7 @@
+
From 99ce874fc21bb0cc7d4f8c0e66f447a2755073af Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 6 Feb 2017 10:28:15 -0600
Subject: [PATCH 166/225] MAGETWO-64154: Rearrange Signifyd information table
in order view template
(cherry picked from commit e28585a)
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 142 +++++-------------
.../Unit/Block/Adminhtml/CaseInfoTest.php | 127 ++++++++++++----
.../view/adminhtml/templates/case_info.phtml | 48 +++---
.../Signifyd/Block/Adminhtml/CaseInfoTest.php | 4 +-
4 files changed, 153 insertions(+), 168 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 873f5c6df1da7..af3d30785efaf 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -31,16 +31,6 @@ class CaseInfo extends Template
*/
private $caseManagement;
- /**
- * @var int
- */
- private static $scoreAccept = 500;
-
- /**
- * @var int
- */
- private static $scoreDecline = 300;
-
/**
* Constructor
*
@@ -117,37 +107,19 @@ public function isEmptyCase()
public function getCaseStatus()
{
return $this->getCaseProperty('', function () {
- return $this->getCaseEntity()->getStatus();
- });
- }
-
- /**
- * Gets case score value
- *
- * @return int
- */
- public function getCaseScore()
- {
- return $this->getCaseProperty(0, function () {
- return $this->getCaseEntity()->getScore();
- });
- }
-
- /**
- * Gets state of case guarantee eligible.
- *
- * @return string|\Magento\Framework\Phrase
- */
- public function getCaseGuaranteeEligible()
- {
- return $this->getCaseProperty('', function () {
- $value = $this->getCaseEntity()->isGuaranteeEligible();
-
- if ($value === null) {
- return '';
- }
-
- return $value ? __('Yes') : __('No');
+ $caseStatusMap = [
+ CaseInterface::STATUS_OPEN => __('Open'),
+ CaseInterface::STATUS_PENDING => __('Pending'),
+ CaseInterface::STATUS_PROCESSING => __('Processing'),
+ CaseInterface::STATUS_FLAGGED => __('Flagged'),
+ CaseInterface::STATUS_DISMISSED => __('Dismissed')
+ ];
+
+ $status = isset($caseStatusMap[$this->getCaseEntity()->getStatus()]) ?
+ $caseStatusMap[$this->getCaseEntity()->getStatus()] :
+ '';
+
+ return $status;
});
}
@@ -159,7 +131,20 @@ public function getCaseGuaranteeEligible()
public function getCaseGuaranteeDisposition()
{
return $this->getCaseProperty('', function () {
- return $this->getCaseEntity()->getGuaranteeDisposition();
+ $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;
});
}
@@ -171,72 +156,17 @@ public function getCaseGuaranteeDisposition()
public function getCaseReviewDisposition()
{
return $this->getCaseProperty('', function () {
- return $this->getCaseEntity()->getReviewDisposition();
- });
- }
-
- /**
- * Gets case create date.
- *
- * @return string
- */
- public function getCaseCreatedAt()
- {
- return $this->getCaseProperty('asd', function () {
- return $this->getCaseEntity()->getCreatedAt();
- });
- }
-
- /**
- * Gets case update date.
- *
- * @return string
- */
- public function getCaseUpdatedAt()
- {
- return $this->getCaseProperty('', function () {
- return $this->getCaseEntity()->getUpdatedAt();
- });
- }
-
- /**
- * Gets case associated team name.
- *
- * @return string
- */
- public function getCaseAssociatedTeam()
- {
- return $this->getCaseProperty('', function () {
- $teamName = 'unknown';
- $team = $this->getCaseEntity()->getAssociatedTeam();
- if (isset($team['teamName'])) {
- $teamName = $team['teamName'];
- }
-
- return $teamName;
- });
- }
-
- /**
- * Returns cell class name according to case score value.
- * It could be used by merchant to customize order view template.
- *
- * @return string
- */
- public function getScoreClass()
- {
- return $this->getCaseProperty('', function () {
- $score = $this->getCaseEntity()->getScore();
+ $reviewStatusMap = [
+ CaseInterface::DISPOSITION_GOOD => __('Good'),
+ CaseInterface::DISPOSITION_FRAUDULENT => __('Fraudulent'),
+ CaseInterface::DISPOSITION_UNSET => __('Unset')
+ ];
- if (self::$scoreAccept <= $score) {
- $result = 'green';
- } elseif ($score <= self::$scoreDecline) {
- $result = 'red';
- } else {
- $result = 'yellow';
- }
+ $status = isset($reviewStatusMap[$this->getCaseEntity()->getReviewDisposition()]) ?
+ $reviewStatusMap[$this->getCaseEntity()->getReviewDisposition()] :
+ '';
- return $result;
+ return $status;
});
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
index f44639bfce96b..0d046800d9523 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
@@ -90,80 +90,141 @@ protected function setUp()
}
/**
- * Checks css class according to case entity score value.
+ * Checks label according to Signifyd status.
*
- * @param integer $score
- * @param string $expectedClassName
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getScoreClass
- * @dataProvider getScoreClassDataProvider
+ * @param string $status
+ * @param string $expectedLabel
+ * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseStatus()
+ * @dataProvider getStatusLabelDataProvider
*/
- public function testGetScoreClass($score, $expectedClassName)
+ public function testGetCaseStatus($status, $expectedLabel)
{
- $this->caseEntity->expects($this->once())
- ->method('getScore')
- ->willReturn($score);
-
$this->caseManagement->expects(self::once())
->method('getByOrderId')
->willReturn($this->caseEntity);
+ $this->caseEntity->expects(self::atLeastOnce())
+ ->method('getStatus')
+ ->willReturn($status);
+
self::assertEquals(
- $expectedClassName,
- $this->caseInfo->getScoreClass()
+ $expectedLabel,
+ $this->caseInfo->getCaseStatus()
);
}
/**
- * Checks case property getter with real case.
+ * Case status and corresponding label data provider.
*
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseProperty
+ * @return array
*/
- public function testCasePropertyWithCaseExists()
+ public function getStatusLabelDataProvider()
{
- $score = 575;
-
- $this->caseEntity->expects($this->once())
- ->method('getScore')
- ->willReturn($score);
+ return [
+ [CaseInterface::STATUS_OPEN, __('Open')],
+ [CaseInterface::STATUS_PENDING, __('Pending')],
+ [CaseInterface::STATUS_PROCESSING, __('Processing')],
+ [CaseInterface::STATUS_FLAGGED, __('Flagged')],
+ [CaseInterface::STATUS_DISMISSED, __('Dismissed')],
+ ['Unregistered', '']
+ ];
+ }
+ /**
+ * 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(
- $score,
- $this->caseInfo->getCaseScore()
+ $expectedLabel,
+ $this->caseInfo->getCaseGuaranteeDisposition()
);
}
/**
- * Checks case property getter with empty case.
+ * Case Guarantee Disposition and corresponding label data provider.
*
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseProperty
+ * @return array
*/
- public function testCasePropertyWithEmptyCase()
+ 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 label according to Signifyd Review Disposition.
+ *
+ * @param string $reviewDisposition
+ * @param string $expectedLabel
+ * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseReviewDisposition()
+ * @dataProvider getReviewLabelDataProvider
+ */
+ public function testGetReviewDisposition($reviewDisposition, $expectedLabel)
{
$this->caseManagement->expects(self::once())
->method('getByOrderId')
- ->willReturn(null);
+ ->willReturn($this->caseEntity);
+
+ $this->caseEntity->expects(self::atLeastOnce())
+ ->method('getReviewDisposition')
+ ->willReturn($reviewDisposition);
self::assertEquals(
- 0,
- $this->caseInfo->getCaseScore()
+ $expectedLabel,
+ $this->caseInfo->getCaseReviewDisposition()
);
}
/**
- * Case scores and corresponding class name data provider
+ * Case Review Disposition and corresponding label data provider.
*
* @return array
*/
- public function getScoreClassDataProvider()
+ public function getReviewLabelDataProvider()
{
return [
- [300, 'red'],
- [400, 'yellow'],
- [500, 'green'],
+ [CaseInterface::DISPOSITION_GOOD, __('Good')],
+ [CaseInterface::DISPOSITION_FRAUDULENT, __('Fraudulent')],
+ [CaseInterface::DISPOSITION_UNSET, __('Unset')],
+ ['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/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 08ebd64400ca0..6649ca8fcd2fe 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -17,32 +17,26 @@
escapeHtml(__('Fraud Protection Information')); ?>
-
-
-
-
- escapeHtml(__('Case Status')); ?>
- escapeHtml(__('Case Score')); ?>
- escapeHtml(__('Guarantee Eligible')); ?>
- escapeHtml(__('Guarantee Disposition')); ?>
- escapeHtml(__('Associated Team')); ?>
- escapeHtml(__('Review Disposition')); ?>
- escapeHtml(__('Case Created')); ?>
- escapeHtml(__('Case Updated')); ?>
-
-
-
-
- escapeHtml($block->getCaseStatus()); ?>
- escapeHtml($block->getCaseScore()); ?>
- escapeHtml($block->getCaseGuaranteeEligible()); ?>
- escapeHtml($block->getCaseGuaranteeDisposition()); ?>
- escapeHtml($block->getCaseAssociatedTeam()); ?>
- escapeHtml($block->getCaseReviewDisposition()); ?>
- escapeHtml($block->getCaseCreatedAt()); ?>
- escapeHtml($block->getCaseUpdatedAt()); ?>
-
-
-
+
+
+
+
+
+
+ escapeHtml(__('Case Status')); ?>
+ escapeHtml($block->getCaseStatus()); ?>
+
+
+ escapeHtml(__('Guarantee Disposition')); ?>
+ escapeHtml($block->getCaseGuaranteeDisposition()); ?>
+
+
+ escapeHtml(__('Review Disposition')); ?>
+ escapeHtml($block->getCaseReviewDisposition()); ?>
+
+
+
+
+
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index c59c64a5f60e1..95a24791e6911 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -84,8 +84,8 @@ public function testCaseEntityExists()
$html = $this->getBlockContents();
static::assertNotEmpty($html);
- static::assertContains('Some Team', $html);
- static::assertContains('col-case-score-green', $html);
+ static::assertContains('Processing', $html);
+ static::assertContains('Good', $html);
}
/**
From 1fb4b41570e88ede878151c75f4d7180ec9e132f Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 6 Feb 2017 10:57:54 -0600
Subject: [PATCH 167/225] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Reimplemented API interfaces
- Updated purchase builder
(cherry picked from commit bc7c6b4)
---
.../Model/PaymentVerificationFactory.php | 66 +++++++++++++++++++
.../Request/PurchaseBuilder.php | 50 +++++++++++---
app/code/Magento/Signifyd/etc/di.xml | 8 ++-
3 files changed, 113 insertions(+), 11 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
diff --git a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
new file mode 100644
index 0000000000000..f6f3024fdeee1
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
@@ -0,0 +1,66 @@
+config = $config;
+ $this->objectManager = $objectManager;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function createPaymentCvv($paymentCode)
+ {
+ return $this->create($paymentCode, 'cvv_ems_adapter');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function createPaymentAvs($paymentCode)
+ {
+ return $this->create($paymentCode, 'avs_ems_adapter');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ private function create($paymentCode, $configKey)
+ {
+ $this->config->setMethodCode($paymentCode);
+ $verificationClass = $this->config->getValue($configKey);
+ if ($verificationClass === null) {
+ return $this->objectManager->get(PaymentVerificationInterface::class);
+ }
+ return $this->objectManager->create($verificationClass);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 524b4a2e6ab8f..48e2c3837fc71 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -8,8 +8,10 @@
use Magento\Framework\App\Area;
use Magento\Framework\Config\ScopeInterface;
use Magento\Framework\Intl\DateTimeFactory;
-use Magento\Payment\Api\Data\CodeVerificationInterfaceFactory;
+use Magento\Payment\Api\PaymentVerificationInterface;
+use Magento\Sales\Api\Data\OrderPaymentInterface;
use Magento\Sales\Model\Order;
+use Magento\Signifyd\Model\PaymentVerificationFactory;
use Magento\Signifyd\Model\SignifydOrderSessionId;
/**
@@ -33,26 +35,26 @@ class PurchaseBuilder
private $signifydOrderSessionId;
/**
- * @var CodeVerificationInterfaceFactory
+ * @var PaymentVerificationFactory
*/
- private $codeVerificationFactory;
+ private $paymentVerificationFactory;
/**
* @param DateTimeFactory $dateTimeFactory
* @param ScopeInterface $scope
* @param SignifydOrderSessionId $signifydOrderSessionId
- * @param CodeVerificationInterfaceFactory $codeVerificationFactory
+ * @param PaymentVerificationFactory $paymentVerificationFactory
*/
public function __construct(
DateTimeFactory $dateTimeFactory,
ScopeInterface $scope,
SignifydOrderSessionId $signifydOrderSessionId,
- CodeVerificationInterfaceFactory $codeVerificationFactory
+ PaymentVerificationFactory $paymentVerificationFactory
) {
$this->dateTimeFactory = $dateTimeFactory;
$this->scope = $scope;
$this->signifydOrderSessionId = $signifydOrderSessionId;
- $this->codeVerificationFactory = $codeVerificationFactory;
+ $this->paymentVerificationFactory = $paymentVerificationFactory;
}
/**
@@ -69,8 +71,6 @@ public function build(Order $order)
new \DateTimeZone('UTC')
);
- $verificationService = $this->codeVerificationFactory->create($orderPayment);
-
$result = [
'purchase' => [
'orderSessionId' => $this->signifydOrderSessionId->get($order->getQuoteId()),
@@ -80,8 +80,8 @@ public function build(Order $order)
'paymentGateway' => $this->getPaymentGateway($orderPayment->getMethod()),
'transactionId' => $orderPayment->getLastTransId(),
'currency' => $order->getOrderCurrencyCode(),
- 'avsResponseCode' => $verificationService->getAvsCode(),
- 'cvvResponseCode' => $verificationService->getCvvCode(),
+ 'avsResponseCode' => $this->getAvsCode($orderPayment),
+ 'cvvResponseCode' => $this->getCvvCode($orderPayment),
'orderChannel' => $this->getOrderChannel(),
'totalPrice' => $order->getGrandTotal(),
],
@@ -175,4 +175,34 @@ private function getOrderChannel()
{
return $this->scope->getCurrentScope() === Area::AREA_ADMINHTML ? 'PHONE' : 'WEB';
}
+
+ /**
+ * Gets AVS code for order payment method.
+ *
+ * @param OrderPaymentInterface $orderPayment
+ * @return string
+ */
+ private function getAvsCode(OrderPaymentInterface $orderPayment)
+ {
+ /** @var PaymentVerificationInterface $avsAdapter */
+ $avsAdapter = $this->paymentVerificationFactory->createPaymentAvs($orderPayment->getMethod());
+ $code = $avsAdapter->getCode($orderPayment);
+
+ return $code !== null ? $code : 'U';
+ }
+
+ /**
+ * Gets CVV code for order payment method.
+ *
+ * @param OrderPaymentInterface $orderPayment
+ * @return string
+ */
+ private function getCvvCode(OrderPaymentInterface $orderPayment)
+ {
+ /** @var PaymentVerificationInterface $cvvAdapter */
+ $cvvAdapter = $this->paymentVerificationFactory->createPaymentCvv($orderPayment->getMethod());
+ $code = $cvvAdapter->getCode($orderPayment);
+
+ return $code !== null ? $code : '';
+ }
}
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 2f0261ec8d131..b60bc6b1dfb3d 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -42,4 +42,10 @@
-
\ No newline at end of file
+
+
+
+ Magento\Payment\Gateway\Config\Config
+
+
+
From e06d7ab2a815d2d0ad62a7e14244b517a6e18bfe Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 6 Feb 2017 11:24:16 -0600
Subject: [PATCH 168/225] MAGETWO-63945: Add extension point to sales grid
indexer
(cherry picked from commit 3d6ed7a)
---
.../Magento/Signifyd/Model/CaseManagement.php | 4 +-
.../Model/CaseServices/UpdatingService.php | 13 +++-
.../Signifyd/Model/OrderGridUpdater.php | 53 +++++++++++++
.../Signifyd/Model/OrderIdListProvider.php | 53 +++++++++++++
.../Magento/Signifyd/Setup/InstallSchema.php | 7 +-
.../CaseServices/UpdatingServiceTest.php | 37 ++++++++-
.../Test/Unit/Model/OrderGridUpdaterTest.php | 75 +++++++++++++++++++
app/code/Magento/Signifyd/etc/di.xml | 13 ++++
.../Signifyd/Model/CaseManagementTest.php | 1 +
.../CaseServices/UpdatingServiceTest.php | 28 +++++++
10 files changed, 277 insertions(+), 7 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/OrderGridUpdater.php
create mode 100644 app/code/Magento/Signifyd/Model/OrderIdListProvider.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/OrderGridUpdaterTest.php
diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php
index 79b90333209f1..4f62dbb563ce6 100644
--- a/app/code/Magento/Signifyd/Model/CaseManagement.php
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -64,9 +64,11 @@ public function __construct(
*/
public function create($orderId)
{
+ /** @var \Magento\Signifyd\Api\Data\CaseInterface $case */
$case = $this->caseFactory->create();
$case->setOrderId($orderId)
- ->setStatus(CaseInterface::STATUS_PENDING);
+ ->setStatus(CaseInterface::STATUS_PENDING)
+ ->setGuaranteeDisposition(CaseInterface::GUARANTEE_PENDING);
try {
return $this->caseRepository->save($case);
} catch (DuplicateException $e) {
diff --git a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
index f0336938d2515..70a214fe19a31 100644
--- a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
@@ -11,6 +11,7 @@
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
+use Magento\Signifyd\Model\OrderGridUpdater;
/**
* Performs Signifyd case entity updating operations.
@@ -32,21 +33,30 @@ class UpdatingService implements UpdatingServiceInterface
*/
private $commentsHistoryUpdater;
+ /**
+ * @var OrderGridUpdater
+ */
+ private $orderGridUpdater;
+
/**
* UpdatingService constructor.
*
* @param GeneratorInterface $messageGenerator
* @param CaseRepositoryInterface $caseRepository
* @param CommentsHistoryUpdater $commentsHistoryUpdater
+ * @param OrderGridUpdater $orderGridUpdater
*/
public function __construct(
GeneratorInterface $messageGenerator,
CaseRepositoryInterface $caseRepository,
- CommentsHistoryUpdater $commentsHistoryUpdater
+ CommentsHistoryUpdater $commentsHistoryUpdater,
+ OrderGridUpdater $orderGridUpdater
+
) {
$this->messageGenerator = $messageGenerator;
$this->caseRepository = $caseRepository;
$this->commentsHistoryUpdater = $commentsHistoryUpdater;
+ $this->orderGridUpdater = $orderGridUpdater;
}
/**
@@ -68,6 +78,7 @@ public function update(CaseInterface $case, array $data)
$this->setCaseData($case, $data);
$orderHistoryComment = $this->messageGenerator->generate($data);
$this->caseRepository->save($case);
+ $this->orderGridUpdater->update($case->getOrderId());
$this->commentsHistoryUpdater->addComment($case, $orderHistoryComment);
} catch (\Exception $e) {
throw new LocalizedException(__('Cannot update Case entity.'), $e);
diff --git a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php b/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
new file mode 100644
index 0000000000000..eeb67a90b6475
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
@@ -0,0 +1,53 @@
+globalConfig = $globalConfig;
+ $this->entityGrid = $entityGrid;
+ }
+
+ /**
+ * Handles synchronous updating order entity in grid after.
+ *
+ * Works only if asynchronous grid indexing is disabled
+ * in global settings.
+ *
+ * @param $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/OrderIdListProvider.php b/app/code/Magento/Signifyd/Model/OrderIdListProvider.php
new file mode 100644
index 0000000000000..8093ce23f55d8
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/OrderIdListProvider.php
@@ -0,0 +1,53 @@
+caseEntity = $caseEntity;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get($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/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index e6436a3f1b7e3..8107d06285bff 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -40,7 +40,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
$table->addColumn('order_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('case_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('guarantee_eligible', Table::TYPE_BOOLEAN, null);
- $table->addColumn('guarantee_disposition', Table::TYPE_TEXT, 32);
+ $table->addColumn(
+ 'guarantee_disposition',
+ Table::TYPE_TEXT,
+ 32,
+ ['default' => CaseInterface::GUARANTEE_PENDING]
+ );
$table->addColumn('status', Table::TYPE_TEXT, 32, ['default' => CaseInterface::STATUS_PENDING]);
$table->addColumn('score', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('associated_team', Table::TYPE_TEXT, '64k');
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index 76ed91c887538..1dff0981e5d5b 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
@@ -12,6 +12,7 @@
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use Magento\Signifyd\Model\MessageGenerators\GeneratorException;
use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
+use Magento\Signifyd\Model\OrderGridUpdater;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
@@ -44,6 +45,11 @@ class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
*/
private $commentsHistoryUpdater;
+ /**
+ * @var OrderGridUpdater|MockObject
+ */
+ private $orderGridUpdater;
+
/**
* @inheritdoc
*/
@@ -66,10 +72,15 @@ protected function setUp()
->setMethods(['addComment'])
->getMock();
+ $this->orderGridUpdater = $this->getMockBuilder(OrderGridUpdater::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
$this->service = $this->objectManager->getObject(UpdatingService::class, [
'messageGenerator' => $this->messageGenerator,
'caseRepository' => $this->caseRepository,
- 'commentsHistoryUpdater' => $this->commentsHistoryUpdater
+ 'commentsHistoryUpdater' => $this->commentsHistoryUpdater,
+ 'orderGridUpdater' => $this->orderGridUpdater
]);
}
@@ -171,7 +182,8 @@ public function testUpdateWithFailedCommentSaving()
{
$caseId = 123;
$data = [
- 'caseId' => $caseId
+ 'caseId' => $caseId,
+ 'orderId' => 1
];
$caseEntity = $this->withCaseEntity(1, $caseId, $data);
@@ -181,6 +193,10 @@ public function testUpdateWithFailedCommentSaving()
->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')
@@ -204,7 +220,8 @@ public function testUpdate()
{
$caseId = 123;
$data = [
- 'caseId' => $caseId
+ 'caseId' => $caseId,
+ 'orderId' => 1
];
$caseEntity = $this->withCaseEntity(21, $caseId, $data);
@@ -220,6 +237,10 @@ public function testUpdate()
->with($data)
->willReturn($message);
+ $this->orderGridUpdater->expects(self::once())
+ ->method('update')
+ ->with($data['orderId']);
+
$this->commentsHistoryUpdater->expects(self::once())
->method('addComment')
->with($caseEntity, $message);
@@ -240,7 +261,10 @@ private function withCaseEntity($caseEntityId, $caseId, array $data = [])
/** @var CaseInterface|MockObject $caseEntity */
$caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
- ->setMethods(['getEntityId', 'getCaseId', 'setCaseId', 'setStatus', 'setOrderId', 'setScore'])
+ ->setMethods([
+ 'getEntityId', 'getCaseId', 'getOrderId',
+ 'setCaseId', 'setStatus', 'setOrderId', 'setScore'
+ ])
->getMockForAbstractClass();
$caseEntity->expects(self::any())
@@ -260,6 +284,11 @@ private function withCaseEntity($caseEntityId, $caseId, array $data = [])
->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/OrderGridUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/OrderGridUpdaterTest.php
new file mode 100644
index 0000000000000..90f672cc956ce
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/OrderGridUpdaterTest.php
@@ -0,0 +1,75 @@
+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/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index b60bc6b1dfb3d..02bb8d34adce7 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -14,8 +14,21 @@
+
+
+ Magento\Sales\Model\ResourceModel\Order\Grid
+
+
+
+
+
+ - Magento\Signifyd\Model\OrderIdListProvider
+
+
+
+ SignifydIdListProvider
-
- signifyd_case
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
index fee9bb9f06b01..fd772594f48ef 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
@@ -45,6 +45,7 @@ public function testCreate()
static::assertNotEmpty($case->getEntityId());
static::assertEquals(CaseInterface::STATUS_PENDING, $case->getStatus());
+ static::assertEquals(CaseInterface::GUARANTEE_PENDING, $case->getGuaranteeDisposition());
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
index 01ac31dd249d1..f04108d2b3c8a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
@@ -6,6 +6,7 @@
namespace Magento\Signifyd\Model\CaseServices;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\App\ResourceConnection;
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
@@ -78,6 +79,8 @@ public function testUpdate()
$caseEntity = $caseRepository->getByCaseId($caseId);
$orderEntityId = $caseEntity->getOrderId();
+ $gridGuarantyStatus = $this->getOrderGridGuarantyStatus($orderEntityId);
+
static::assertNotEmpty($caseEntity);
static::assertEquals('2017-01-05 22:23:26', $caseEntity->getCreatedAt());
static::assertEquals(CaseInterface::GUARANTEE_APPROVED, $caseEntity->getGuaranteeDisposition());
@@ -85,6 +88,11 @@ public function testUpdate()
static::assertEquals(true, $caseEntity->isGuaranteeEligible());
static::assertEquals(CaseInterface::STATUS_PROCESSING, $caseEntity->getStatus());
static::assertEquals($orderEntityId, $caseEntity->getOrderId());
+ static::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);
@@ -97,4 +105,24 @@ public function testUpdate()
static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
static::assertEquals("Signifyd Case $caseId has been created for order.", $caseCreationComment->getComment());
}
+
+ /**
+ * Returns value of signifyd_guarantee_status column from sales order grid
+ *
+ * @param int $orderEntityId
+ * @return string|null
+ */
+ private function getOrderGridGuarantyStatus($orderEntityId)
+ {
+ /** @var \Magento\Sales\Model\ResourceModel\Order\Grid\Collection $orderGridCollection */
+ $orderGridCollection = $this->objectManager->get(
+ \Magento\Sales\Model\ResourceModel\Order\Grid\Collection::class
+ );
+
+ $items = $orderGridCollection->addFilter($orderGridCollection->getIdFieldName(), $orderEntityId)
+ ->getItems();
+ $result = array_pop($items);
+
+ return isset($result['signifyd_guarantee_status']) ? $result['signifyd_guarantee_status'] : null;
+ }
}
From d5c92d1687c09b5dd24008a1e26d364f12141cfa Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 6 Feb 2017 11:28:44 -0600
Subject: [PATCH 169/225] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- update connection name
(cherry picked from commit aa9fb31)
---
app/code/Magento/Signifyd/Setup/InstallData.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Setup/InstallData.php b/app/code/Magento/Signifyd/Setup/InstallData.php
index 1436d52d4b823..6e37ac63c493e 100644
--- a/app/code/Magento/Signifyd/Setup/InstallData.php
+++ b/app/code/Magento/Signifyd/Setup/InstallData.php
@@ -38,7 +38,7 @@ public function __construct(
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
- $this->resource->getConnection('sales_order')->addColumn(
+ $this->resource->getConnection('sales')->addColumn(
$setup->getTable('sales_order_grid'),
'signifyd_guarantee_status',
[
@@ -48,7 +48,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
]
);
- $this->resource->getConnection('sales_order')->addColumn(
+ $this->resource->getConnection('sales')->addColumn(
$setup->getTable('magento_sales_order_grid_archive'),
'signifyd_guarantee_status',
[
From d7a5b86f2ec961525066c3b0cd137d9b38961ae7 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 7 Feb 2017 01:57:49 -0600
Subject: [PATCH 170/225] MAGETWO-63945: Add extension point to sales grid
indexer
- Rename IdListProviderComposite to IdListProvider
- Fix static
(cherry picked from commit 14b0ba9)
---
.../Magento/Signifyd/Model/CaseServices/UpdatingService.php | 1 -
app/code/Magento/Signifyd/Model/OrderGridUpdater.php | 2 +-
app/code/Magento/Signifyd/etc/di.xml | 2 +-
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
index 70a214fe19a31..f93bb08eb0761 100644
--- a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
@@ -51,7 +51,6 @@ public function __construct(
CaseRepositoryInterface $caseRepository,
CommentsHistoryUpdater $commentsHistoryUpdater,
OrderGridUpdater $orderGridUpdater
-
) {
$this->messageGenerator = $messageGenerator;
$this->caseRepository = $caseRepository;
diff --git a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php b/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
index eeb67a90b6475..0e6cbefedb483 100644
--- a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
+++ b/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
@@ -36,7 +36,7 @@ public function __construct(
}
/**
- * Handles synchronous updating order entity in grid after.
+ * Handles synchronous updating order entity in grid.
*
* Works only if asynchronous grid indexing is disabled
* in global settings.
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 02bb8d34adce7..764d8f7eddb77 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -19,7 +19,7 @@
Magento\Sales\Model\ResourceModel\Order\Grid
-
+
- Magento\Signifyd\Model\OrderIdListProvider
From 17122c86a092ab38e1fb6e82f9b8f813942b70d9 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 7 Feb 2017 03:04:38 -0600
Subject: [PATCH 171/225] MAGETWO-63945: Add extension point to sales grid
indexer
- Add constraints for sales_order_grid
(cherry picked from commit f9a639b)
---
app/code/Magento/Signifyd/Model/OrderGridUpdater.php | 2 +-
app/code/Magento/Signifyd/etc/constraints.xml | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php b/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
index 0e6cbefedb483..5cefddaf21022 100644
--- a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
+++ b/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
@@ -41,7 +41,7 @@ public function __construct(
* Works only if asynchronous grid indexing is disabled
* in global settings.
*
- * @param $orderId
+ * @param int $orderId
* @return void
*/
public function update($orderId)
diff --git a/app/code/Magento/Signifyd/etc/constraints.xml b/app/code/Magento/Signifyd/etc/constraints.xml
index 6c4224e28f7e8..65e3f45035dc2 100644
--- a/app/code/Magento/Signifyd/etc/constraints.xml
+++ b/app/code/Magento/Signifyd/etc/constraints.xml
@@ -10,5 +10,8 @@
+
+
+
\ No newline at end of file
From b8fe05a0b9c4c94a7d701b8d9d19b1d3b0282479 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 7 Feb 2017 04:41:21 -0600
Subject: [PATCH 172/225] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- update Oms and set default connection name
(cherry picked from commit e8fc565)
---
app/code/Magento/Signifyd/etc/di.xml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 764d8f7eddb77..453e5d61179a2 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -61,4 +61,9 @@
Magento\Payment\Gateway\Config\Config
+
+
+ sales
+
+
From 90be2c0ce1479d73e9fb2e6757c3ec34acc43bb6 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 7 Feb 2017 05:26:53 -0600
Subject: [PATCH 173/225] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Refactored code according to code review.
(cherry picked from commit 99af3fc)
---
.../Model/PaymentVerificationFactory.php | 31 ++++++++++++++++---
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
index f6f3024fdeee1..e228df47b040c 100644
--- a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
+++ b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
@@ -10,7 +10,7 @@
use Magento\Payment\Gateway\ConfigInterface;
/**
- * Creates verification service for provided payment method, or \Magento\Payment\Api\PaymentVerificationInterface::class
+ * Creates verification service for provided payment method, or PaymentVerificationInterface::class
* if payment method does not support AVS, CVV verifications.
*/
class PaymentVerificationFactory
@@ -36,7 +36,12 @@ public function __construct(ObjectManagerInterface $objectManager, ConfigInterfa
}
/**
- * @inheritdoc
+ * Creates instance of CVV code verification.
+ * Exception will be thrown if CVV mapper does not implement PaymentVerificationInterface.
+ *
+ * @param string $paymentCode
+ * @return PaymentVerificationInterface
+ * @throws \Exception
*/
public function createPaymentCvv($paymentCode)
{
@@ -44,7 +49,12 @@ public function createPaymentCvv($paymentCode)
}
/**
- * @inheritdoc
+ * Creates instance of AVS code verification.
+ * Exception will be thrown if AVS mapper does not implement PaymentVerificationInterface.
+ *
+ * @param string $paymentCode
+ * @return PaymentVerificationInterface
+ * @throws \Exception
*/
public function createPaymentAvs($paymentCode)
{
@@ -52,7 +62,14 @@ public function createPaymentAvs($paymentCode)
}
/**
- * @inheritdoc
+ * Creates instance of PaymentVerificationInterface.
+ * Default implementation will be returned if payment method does not implement PaymentVerificationInterface.
+ * Exception will be thrown if payment verification instance does not implement PaymentVerificationInterface.
+ *
+ * @param string $paymentCode
+ * @param string $configKey
+ * @return PaymentVerificationInterface
+ * @throws \Exception
*/
private function create($paymentCode, $configKey)
{
@@ -61,6 +78,10 @@ private function create($paymentCode, $configKey)
if ($verificationClass === null) {
return $this->objectManager->get(PaymentVerificationInterface::class);
}
- return $this->objectManager->create($verificationClass);
+ $mapper = $this->objectManager->create($verificationClass);
+ if (!$mapper instanceof PaymentVerificationInterface) {
+ throw new \Exception($verificationClass . ' must implement ' . PaymentVerificationInterface::class);
+ }
+ return $mapper;
}
}
From cfd313ea932d5897ea6954f3c2e4525d39bc4e85 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 7 Feb 2017 05:33:41 -0600
Subject: [PATCH 174/225] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Updated doc blocks
(cherry picked from commit a19956d)
---
app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php | 2 --
app/code/Magento/Signifyd/Observer/PlaceOrder.php | 4 ----
2 files changed, 6 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index af3d30785efaf..9aaf15ca4a688 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -32,8 +32,6 @@ class CaseInfo extends Template
private $caseManagement;
/**
- * Constructor
- *
* @param Context $context
* @param Config $config
* @param CaseManagement $caseManagement
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index 764caaf97adea..d260de96c5a9e 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -15,8 +15,6 @@
use Psr\Log\LoggerInterface;
/**
- * Place Order observer.
- *
* Observer should be triggered when new order is created and placed.
* If Signifyd integration enabled in configuration then new case will be created.
*/
@@ -38,8 +36,6 @@ class PlaceOrder implements ObserverInterface
private $logger;
/**
- * PlaceOrder constructor.
- *
* @param Config $signifydIntegrationConfig
* @param CaseCreationServiceInterface $caseCreationService
* @param LoggerInterface $logger
From 781e984ed0b5f86da4b9f9ec24ccdb4ad4bc57a1 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 7 Feb 2017 07:00:08 -0600
Subject: [PATCH 175/225] MAGETWO-63945: Add extension point to sales grid
indexer
- Refactoring according CR
---
.../Signifyd/Model/CaseServices/UpdatingService.php | 6 +++---
.../NotSyncedOrderIdListProvider.php} | 9 +++++----
.../Model/{ => SalesOrderGrid}/OrderGridUpdater.php | 2 +-
.../Test/Unit/Model/CaseServices/UpdatingServiceTest.php | 4 ++--
.../Model/{ => SalesOrderGrid}/OrderGridUpdaterTest.php | 9 +++------
app/code/Magento/Signifyd/etc/di.xml | 6 +++---
6 files changed, 17 insertions(+), 19 deletions(-)
rename app/code/Magento/Signifyd/Model/{OrderIdListProvider.php => SalesOrderGrid/NotSyncedOrderIdListProvider.php} (80%)
rename app/code/Magento/Signifyd/Model/{ => SalesOrderGrid}/OrderGridUpdater.php (95%)
rename app/code/Magento/Signifyd/Test/Unit/Model/{ => SalesOrderGrid}/OrderGridUpdaterTest.php (87%)
diff --git a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
index f93bb08eb0761..40f28b32ec0eb 100644
--- a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
@@ -11,7 +11,7 @@
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
-use Magento\Signifyd\Model\OrderGridUpdater;
+use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
/**
* Performs Signifyd case entity updating operations.
@@ -34,7 +34,7 @@ class UpdatingService implements UpdatingServiceInterface
private $commentsHistoryUpdater;
/**
- * @var OrderGridUpdater
+ * @var \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater
*/
private $orderGridUpdater;
@@ -44,7 +44,7 @@ class UpdatingService implements UpdatingServiceInterface
* @param GeneratorInterface $messageGenerator
* @param CaseRepositoryInterface $caseRepository
* @param CommentsHistoryUpdater $commentsHistoryUpdater
- * @param OrderGridUpdater $orderGridUpdater
+ * @param \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater $orderGridUpdater
*/
public function __construct(
GeneratorInterface $messageGenerator,
diff --git a/app/code/Magento/Signifyd/Model/OrderIdListProvider.php b/app/code/Magento/Signifyd/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
similarity index 80%
rename from app/code/Magento/Signifyd/Model/OrderIdListProvider.php
rename to app/code/Magento/Signifyd/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
index 8093ce23f55d8..cbcd376d35b2e 100644
--- a/app/code/Magento/Signifyd/Model/OrderIdListProvider.php
+++ b/app/code/Magento/Signifyd/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
@@ -3,15 +3,16 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\SalesOrderGrid;
-use Magento\Sales\Model\ResourceModel\Provider\IdListProviderInterface;
+use Magento\Sales\Model\ResourceModel\Provider\NotSyncedDataProviderInterface;
+use Magento\Signifyd\Model\ResourceModel;
use Magento\Signifyd\Model\ResourceModel\CaseEntity;
/**
* Provides order ids list which Signifyd Case guaranty status were changed
*/
-class OrderIdListProvider implements IdListProviderInterface
+class NotSyncedOrderIdListProvider implements NotSyncedDataProviderInterface
{
/**
* @var ResourceModel\CaseEntity
@@ -30,7 +31,7 @@ public function __construct(
/**
* @inheritdoc
*/
- public function get($mainTableName, $gridTableName)
+ public function getIds($mainTableName, $gridTableName)
{
$connection = $this->caseEntity->getConnection();
$select = $connection->select()
diff --git a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php b/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php
similarity index 95%
rename from app/code/Magento/Signifyd/Model/OrderGridUpdater.php
rename to app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php
index 5cefddaf21022..5cb87d3316645 100644
--- a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
+++ b/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php
@@ -3,7 +3,7 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\SalesOrderGrid;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Sales\Model\ResourceModel\GridInterface;
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index 1dff0981e5d5b..a2894939042dd 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
@@ -12,7 +12,7 @@
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use Magento\Signifyd\Model\MessageGenerators\GeneratorException;
use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
-use Magento\Signifyd\Model\OrderGridUpdater;
+use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
@@ -46,7 +46,7 @@ class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
private $commentsHistoryUpdater;
/**
- * @var OrderGridUpdater|MockObject
+ * @var \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater|MockObject
*/
private $orderGridUpdater;
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/OrderGridUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
similarity index 87%
rename from app/code/Magento/Signifyd/Test/Unit/Model/OrderGridUpdaterTest.php
rename to app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
index 90f672cc956ce..eda647c214db7 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/OrderGridUpdaterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
@@ -3,16 +3,13 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Unit\Model;
+namespace Magento\Signifyd\Test\Unit\Model\SalesOrderGrid;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Sales\Model\ResourceModel\GridInterface;
-use Magento\Signifyd\Model\OrderGridUpdater;
+use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
-/**
- * Class OrderGridUpdaterTest
- */
class OrderGridUpdaterTest extends \PHPUnit_Framework_TestCase
{
/**
@@ -40,7 +37,7 @@ protected function setUp()
$this->globalConfig = $this->getMockBuilder(ScopeConfigInterface::class)
->getMockForAbstractClass();
- $this->model = new OrderGridUpdater($this->orderGrid, $this->globalConfig);
+ $this->model = new \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater($this->orderGrid, $this->globalConfig);
}
public function testUpdateInSyncMode()
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 453e5d61179a2..35d9c54e8149b 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -14,15 +14,15 @@
-
+
Magento\Sales\Model\ResourceModel\Order\Grid
-
+
- - Magento\Signifyd\Model\OrderIdListProvider
+ - Magento\Signifyd\Model\SalesOrderGrid\NotSyncedOrderIdListProvider
From e3037df2d7e89ba22f7525258db8dd87b9d1c826 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 7 Feb 2017 07:58:48 -0600
Subject: [PATCH 176/225] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Updated payment verification interface
- Updated Braintree avs/cvv mappers behaviour
- Refactored payment verification default implementation
(cherry picked from commit 32323c2)
---
.../Model/DefaultPaymentVerification.php | 37 +++++++++++++++++++
.../Model/PaymentVerificationFactory.php | 33 +++++++++++++----
.../Request/PurchaseBuilder.php | 8 +---
app/code/Magento/Signifyd/etc/di.xml | 6 +++
4 files changed, 71 insertions(+), 13 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php
diff --git a/app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php b/app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php
new file mode 100644
index 0000000000000..fdea5b7cac138
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php
@@ -0,0 +1,37 @@
+default = $default;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getCode(OrderPaymentInterface $orderPayment)
+ {
+ return $this->default;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
index e228df47b040c..ecd6867073d98 100644
--- a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
+++ b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
@@ -25,14 +25,32 @@ class PaymentVerificationFactory
*/
private $objectManager;
+ /**
+ * @var DefaultPaymentVerification
+ */
+ private $avsAdapter;
+
+ /**
+ * @var DefaultPaymentVerification
+ */
+ private $cvvAdapter;
+
/**
* @param ObjectManagerInterface $objectManager
- * @param Config $config
+ * @param ConfigInterface|Config $config
+ * @param DefaultPaymentVerification $avsAdapter
+ * @param DefaultPaymentVerification $cvvAdapter
*/
- public function __construct(ObjectManagerInterface $objectManager, ConfigInterface $config)
- {
+ public function __construct(
+ ObjectManagerInterface $objectManager,
+ ConfigInterface $config,
+ DefaultPaymentVerification $avsAdapter,
+ DefaultPaymentVerification $cvvAdapter
+ ) {
$this->config = $config;
$this->objectManager = $objectManager;
+ $this->avsAdapter = $avsAdapter;
+ $this->cvvAdapter = $cvvAdapter;
}
/**
@@ -45,7 +63,7 @@ public function __construct(ObjectManagerInterface $objectManager, ConfigInterfa
*/
public function createPaymentCvv($paymentCode)
{
- return $this->create($paymentCode, 'cvv_ems_adapter');
+ return $this->create($this->cvvAdapter, $paymentCode, 'cvv_ems_adapter');
}
/**
@@ -58,7 +76,7 @@ public function createPaymentCvv($paymentCode)
*/
public function createPaymentAvs($paymentCode)
{
- return $this->create($paymentCode, 'avs_ems_adapter');
+ return $this->create($this->avsAdapter, $paymentCode, 'avs_ems_adapter');
}
/**
@@ -66,17 +84,18 @@ public function createPaymentAvs($paymentCode)
* Default implementation will be returned if payment method does not implement PaymentVerificationInterface.
* Exception will be thrown if payment verification instance does not implement PaymentVerificationInterface.
*
+ * @param DefaultPaymentVerification $defaultAdapter
* @param string $paymentCode
* @param string $configKey
* @return PaymentVerificationInterface
* @throws \Exception
*/
- private function create($paymentCode, $configKey)
+ private function create(DefaultPaymentVerification $defaultAdapter, $paymentCode, $configKey)
{
$this->config->setMethodCode($paymentCode);
$verificationClass = $this->config->getValue($configKey);
if ($verificationClass === null) {
- return $this->objectManager->get(PaymentVerificationInterface::class);
+ return $defaultAdapter;
}
$mapper = $this->objectManager->create($verificationClass);
if (!$mapper instanceof PaymentVerificationInterface) {
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 48e2c3837fc71..86f9520a13309 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -186,9 +186,7 @@ private function getAvsCode(OrderPaymentInterface $orderPayment)
{
/** @var PaymentVerificationInterface $avsAdapter */
$avsAdapter = $this->paymentVerificationFactory->createPaymentAvs($orderPayment->getMethod());
- $code = $avsAdapter->getCode($orderPayment);
-
- return $code !== null ? $code : 'U';
+ return $avsAdapter->getCode($orderPayment);
}
/**
@@ -201,8 +199,6 @@ private function getCvvCode(OrderPaymentInterface $orderPayment)
{
/** @var PaymentVerificationInterface $cvvAdapter */
$cvvAdapter = $this->paymentVerificationFactory->createPaymentCvv($orderPayment->getMethod());
- $code = $cvvAdapter->getCode($orderPayment);
-
- return $code !== null ? $code : '';
+ return $cvvAdapter->getCode($orderPayment);
}
}
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 35d9c54e8149b..b43d708fc852a 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -56,9 +56,15 @@
+
+
+ U
+
+
Magento\Payment\Gateway\Config\Config
+ SignifydAvsDefaultMapper
From 751c24e0db28b20b0ad05dccd87271d6287d719b Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 7 Feb 2017 08:21:56 -0600
Subject: [PATCH 177/225] MAGETWO-63945: Add extension point to sales grid
indexer
- Fix static
(cherry picked from commit 6f7df62)
---
.../Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
index eda647c214db7..1390a036955c2 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
@@ -37,7 +37,7 @@ protected function setUp()
$this->globalConfig = $this->getMockBuilder(ScopeConfigInterface::class)
->getMockForAbstractClass();
- $this->model = new \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater($this->orderGrid, $this->globalConfig);
+ $this->model = new OrderGridUpdater($this->orderGrid, $this->globalConfig);
}
public function testUpdateInSyncMode()
From 1d67a0e374e99d27ec48505abae3aa75d752cad1 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 7 Feb 2017 10:51:44 -0600
Subject: [PATCH 178/225] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- refactoring
---
app/code/Magento/Signifyd/Setup/InstallData.php | 9 +++++++--
app/code/Magento/Signifyd/Setup/InstallSchema.php | 7 ++++++-
app/code/Magento/Signifyd/composer.json | 3 +++
app/code/Magento/Signifyd/etc/di.xml | 7 +++++++
4 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Setup/InstallData.php b/app/code/Magento/Signifyd/Setup/InstallData.php
index 6e37ac63c493e..a7490064a895a 100644
--- a/app/code/Magento/Signifyd/Setup/InstallData.php
+++ b/app/code/Magento/Signifyd/Setup/InstallData.php
@@ -21,6 +21,11 @@ class InstallData implements InstallDataInterface
*/
private $resource;
+ /**
+ * @var string
+ */
+ private static $connectionName = 'sales';
+
/**
* @param ResourceConnection $resource
*/
@@ -38,7 +43,7 @@ public function __construct(
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
- $this->resource->getConnection('sales')->addColumn(
+ $this->resource->getConnection(self::$connectionName)->addColumn(
$setup->getTable('sales_order_grid'),
'signifyd_guarantee_status',
[
@@ -48,7 +53,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
]
);
- $this->resource->getConnection('sales')->addColumn(
+ $this->resource->getConnection(self::$connectionName)->addColumn(
$setup->getTable('magento_sales_order_grid_archive'),
'signifyd_guarantee_status',
[
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index 8107d06285bff..b66bd5314b6bb 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -22,13 +22,18 @@ class InstallSchema implements InstallSchemaInterface
*/
private static $table = 'signifyd_case';
+ /**
+ * @var string
+ */
+ private static $connectionName = 'sales';
+
/**
* @inheritdoc
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
/** @var AdapterInterface $connection */
- $connection = $setup->startSetup()->getConnection();
+ $connection = $setup->startSetup()->getConnection(self::$connectionName);
$table = $connection->newTable($setup->getTable(static::$table));
$table->addColumn(
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 3c5d5bd592253..315ed2db7495d 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -13,6 +13,9 @@
"magento/module-backend": "100.2.*",
"magento/module-payment": "100.2.*"
},
+ "suggest": {
+ "magento/module-scalable-oms": "100.2.*"
+ },
"type": "magento2-module",
"version": "100.2.0-dev",
"license": [
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index b43d708fc852a..b17b5f3e8a8f4 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -72,4 +72,11 @@
sales
+
+
+
+ - signifyd_case
+
+
+
From 829e3edf3a89c2282e3d74cce8149d154bc18ee5 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 8 Feb 2017 03:51:07 -0600
Subject: [PATCH 179/225] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Added payment method code validation to Braintree mappers
- Updated default payment verification mapper and factory for creating mappers
(cherry picked from commit 8464db0)
---
.../Model/PaymentVerificationFactory.php | 28 +++++++++----------
...p => PredefinedVerificationCodeMapper.php} | 12 ++++----
.../Request/CreateCaseBuilder.php | 14 ++++++++++
.../Request/PurchaseBuilder.php | 3 --
app/code/Magento/Signifyd/etc/di.xml | 9 ++++--
.../Request/CreateCaseBuilderTest.php | 8 ++++--
.../order_with_guest_and_virtual_product.php | 7 ++++-
7 files changed, 52 insertions(+), 29 deletions(-)
rename app/code/Magento/Signifyd/Model/{DefaultPaymentVerification.php => PredefinedVerificationCodeMapper.php} (70%)
diff --git a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
index ecd6867073d98..b84fa43628c0f 100644
--- a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
+++ b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
@@ -26,31 +26,31 @@ class PaymentVerificationFactory
private $objectManager;
/**
- * @var DefaultPaymentVerification
+ * @var PaymentVerificationInterface
*/
- private $avsAdapter;
+ private $avsDefaultAdapter;
/**
- * @var DefaultPaymentVerification
+ * @var PaymentVerificationInterface
*/
- private $cvvAdapter;
+ private $cvvDefaultAdapter;
/**
* @param ObjectManagerInterface $objectManager
* @param ConfigInterface|Config $config
- * @param DefaultPaymentVerification $avsAdapter
- * @param DefaultPaymentVerification $cvvAdapter
+ * @param PaymentVerificationInterface $avsDefaultAdapter
+ * @param PaymentVerificationInterface $cvvDefaultAdapter
*/
public function __construct(
ObjectManagerInterface $objectManager,
ConfigInterface $config,
- DefaultPaymentVerification $avsAdapter,
- DefaultPaymentVerification $cvvAdapter
+ PaymentVerificationInterface $avsDefaultAdapter,
+ PaymentVerificationInterface $cvvDefaultAdapter
) {
$this->config = $config;
$this->objectManager = $objectManager;
- $this->avsAdapter = $avsAdapter;
- $this->cvvAdapter = $cvvAdapter;
+ $this->avsDefaultAdapter = $avsDefaultAdapter;
+ $this->cvvDefaultAdapter = $cvvDefaultAdapter;
}
/**
@@ -63,7 +63,7 @@ public function __construct(
*/
public function createPaymentCvv($paymentCode)
{
- return $this->create($this->cvvAdapter, $paymentCode, 'cvv_ems_adapter');
+ return $this->create($this->cvvDefaultAdapter, $paymentCode, 'cvv_ems_adapter');
}
/**
@@ -76,7 +76,7 @@ public function createPaymentCvv($paymentCode)
*/
public function createPaymentAvs($paymentCode)
{
- return $this->create($this->avsAdapter, $paymentCode, 'avs_ems_adapter');
+ return $this->create($this->avsDefaultAdapter, $paymentCode, 'avs_ems_adapter');
}
/**
@@ -84,13 +84,13 @@ public function createPaymentAvs($paymentCode)
* Default implementation will be returned if payment method does not implement PaymentVerificationInterface.
* Exception will be thrown if payment verification instance does not implement PaymentVerificationInterface.
*
- * @param DefaultPaymentVerification $defaultAdapter
+ * @param PaymentVerificationInterface $defaultAdapter
* @param string $paymentCode
* @param string $configKey
* @return PaymentVerificationInterface
* @throws \Exception
*/
- private function create(DefaultPaymentVerification $defaultAdapter, $paymentCode, $configKey)
+ private function create(PaymentVerificationInterface $defaultAdapter, $paymentCode, $configKey)
{
$this->config->setMethodCode($paymentCode);
$verificationClass = $this->config->getValue($configKey);
diff --git a/app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php b/app/code/Magento/Signifyd/Model/PredefinedVerificationCodeMapper.php
similarity index 70%
rename from app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php
rename to app/code/Magento/Signifyd/Model/PredefinedVerificationCodeMapper.php
index fdea5b7cac138..149743192ba9c 100644
--- a/app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php
+++ b/app/code/Magento/Signifyd/Model/PredefinedVerificationCodeMapper.php
@@ -12,19 +12,19 @@
* Default implementation of payment verification interface.
* The default code value can be configured via DI.
*/
-class DefaultPaymentVerification implements PaymentVerificationInterface
+class PredefinedVerificationCodeMapper implements PaymentVerificationInterface
{
/**
* @var string
*/
- private $default;
+ private $code;
/**
- * @param string $default
+ * @param string $code
*/
- public function __construct($default = '')
+ public function __construct($code = '')
{
- $this->default = $default;
+ $this->code = $code;
}
/**
@@ -32,6 +32,6 @@ public function __construct($default = '')
*/
public function getCode(OrderPaymentInterface $orderPayment)
{
- return $this->default;
+ return $this->code;
}
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
index ec0d4dcb55889..16823447d32ee 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
@@ -15,6 +15,15 @@
*/
class CreateCaseBuilder implements CreateCaseBuilderInterface
{
+ /**
+ * List of params, which can be empty, but required by Signifyd API.
+ *
+ * @var array
+ */
+ private static $allowed = [
+ 'cvvResponseCode'
+ ];
+
/**
* @var OrderFactory
*/
@@ -106,6 +115,11 @@ public function build($orderId)
private function removeEmptyValues($data)
{
foreach ($data as $key => $value) {
+ // skip allowed empty values
+ if (in_array($key, self::$allowed, true)) {
+ continue;
+ }
+
if (is_array($value)) {
$data[$key] = $this->removeEmptyValues($data[$key]);
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 86f9520a13309..287ecdb84ca77 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -8,7 +8,6 @@
use Magento\Framework\App\Area;
use Magento\Framework\Config\ScopeInterface;
use Magento\Framework\Intl\DateTimeFactory;
-use Magento\Payment\Api\PaymentVerificationInterface;
use Magento\Sales\Api\Data\OrderPaymentInterface;
use Magento\Sales\Model\Order;
use Magento\Signifyd\Model\PaymentVerificationFactory;
@@ -184,7 +183,6 @@ private function getOrderChannel()
*/
private function getAvsCode(OrderPaymentInterface $orderPayment)
{
- /** @var PaymentVerificationInterface $avsAdapter */
$avsAdapter = $this->paymentVerificationFactory->createPaymentAvs($orderPayment->getMethod());
return $avsAdapter->getCode($orderPayment);
}
@@ -197,7 +195,6 @@ private function getAvsCode(OrderPaymentInterface $orderPayment)
*/
private function getCvvCode(OrderPaymentInterface $orderPayment)
{
- /** @var PaymentVerificationInterface $cvvAdapter */
$cvvAdapter = $this->paymentVerificationFactory->createPaymentCvv($orderPayment->getMethod());
return $cvvAdapter->getCode($orderPayment);
}
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index b17b5f3e8a8f4..08c2a343262a7 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -56,15 +56,18 @@
-
+
- U
+ U
+
+
Magento\Payment\Gateway\Config\Config
- SignifydAvsDefaultMapper
+ SignifydAvsDefaultMapper
+ SignifydCvvDefaultMapper
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
index b6844a4da447d..1f93dc9b87d8a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -87,6 +87,8 @@ public function testCreateCaseBuilderWithFullSetOfData()
'paymentGateway' => 'paypal_account',
'transactionId' => $payment->getLastTransId(),
'currency' => $order->getOrderCurrencyCode(),
+ 'avsResponseCode' => 'U',
+ 'cvvResponseCode' => '',
'orderChannel' => 'WEB',
'totalPrice' => $order->getGrandTotal(),
'shipments' => [
@@ -160,7 +162,7 @@ public function testCreateCaseBuilderWithFullSetOfData()
]
];
- static::assertEquals(
+ self::assertEquals(
$expected,
$this->caseBuilder->build($order->getEntityId())
);
@@ -200,6 +202,8 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
'paymentGateway' => $payment->getMethod(),
'transactionId' => $payment->getLastTransId(),
'currency' => $order->getOrderCurrencyCode(),
+ 'avsResponseCode' => 'Y',
+ 'cvvResponseCode' => 'M',
'orderChannel' => 'PHONE',
'totalPrice' => $order->getGrandTotal(),
'products' => [
@@ -231,7 +235,7 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
]
];
- static::assertEquals(
+ self::assertEquals(
$expected,
$this->caseBuilder->build($order->getEntityId())
);
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
index a5a55b431df37..3d60f1c6f7e8c 100644
--- 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
@@ -9,6 +9,7 @@
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';
@@ -19,9 +20,13 @@
$billingAddress = $objectManager->create(Address::class, ['data' => $addressData]);
$billingAddress->setAddressType('billing');
+/** @var OrderPaymentInterface $payment */
$payment = $objectManager->create(Payment::class);
$payment->setMethod('braintree')
- ->setLastTransId('00001');
+ ->setLastTransId('00001')
+ ->setAdditionalInformation('avsPostalCodeResponseCode', 'M')
+ ->setAdditionalInformation('avsStreetAddressResponseCode', 'M')
+ ->setAdditionalInformation('cvvResponseCode', 'M');
/** @var Item $orderItem */
$orderItem1 = $objectManager->create(Item::class);
From f253ba513694adf6db666f42ac1a13ffca9a83b0 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 8 Feb 2017 07:50:12 -0600
Subject: [PATCH 180/225] MAGETWO-63945: Add extension point to sales grid
indexer
- Add docblock to OrderGridUpdater
(cherry picked from commit f077436)
---
.../Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php b/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php
index 5cb87d3316645..1d5e67b0c1065 100644
--- a/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php
+++ b/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php
@@ -9,7 +9,9 @@
use Magento\Sales\Model\ResourceModel\GridInterface;
/**
- * Perfoms sales order grid updating operations
+ * Perfoms sales order grid updating operations.
+ *
+ * Serves order grid updates in both synchronous and asynchronous modes.
*/
class OrderGridUpdater
{
From ad11d9aa0462265b56d7090cec46633f845d284d Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 8 Feb 2017 07:59:05 -0600
Subject: [PATCH 181/225] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Refactored code
- Added unit tests
(cherry picked from commit 9d9f254)
---
...per.php => PredefinedVerificationCode.php} | 2 +-
.../Request/CreateCaseBuilder.php | 2 +-
.../Model/PaymentVerificationFactoryTest.php | 222 ++++++++++++++++++
app/code/Magento/Signifyd/etc/di.xml | 4 +-
4 files changed, 226 insertions(+), 4 deletions(-)
rename app/code/Magento/Signifyd/Model/{PredefinedVerificationCodeMapper.php => PredefinedVerificationCode.php} (89%)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
diff --git a/app/code/Magento/Signifyd/Model/PredefinedVerificationCodeMapper.php b/app/code/Magento/Signifyd/Model/PredefinedVerificationCode.php
similarity index 89%
rename from app/code/Magento/Signifyd/Model/PredefinedVerificationCodeMapper.php
rename to app/code/Magento/Signifyd/Model/PredefinedVerificationCode.php
index 149743192ba9c..c6f12d01364a0 100644
--- a/app/code/Magento/Signifyd/Model/PredefinedVerificationCodeMapper.php
+++ b/app/code/Magento/Signifyd/Model/PredefinedVerificationCode.php
@@ -12,7 +12,7 @@
* Default implementation of payment verification interface.
* The default code value can be configured via DI.
*/
-class PredefinedVerificationCodeMapper implements PaymentVerificationInterface
+class PredefinedVerificationCode implements PaymentVerificationInterface
{
/**
* @var string
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
index 16823447d32ee..4f46cf69b70aa 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
@@ -116,7 +116,7 @@ private function removeEmptyValues($data)
{
foreach ($data as $key => $value) {
// skip allowed empty values
- if (in_array($key, self::$allowed, true)) {
+ if (in_array($key, self::$allowed, true) && $value === '') {
continue;
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
new file mode 100644
index 0000000000000..4e335d5a35c95
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
@@ -0,0 +1,222 @@
+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 \Exception
+ * @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/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 08c2a343262a7..6bf80d12402fc 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -56,12 +56,12 @@
-
+
U
-
+
From fbc36e1db6c0a8a44377c23c108dda0393547355 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 8 Feb 2017 10:24:16 -0600
Subject: [PATCH 182/225] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Updated data fields filtration
(cherry picked from commit c06d779)
---
.../Request/CreateCaseBuilder.php | 16 +---------------
.../Request/CreateCaseBuilderTest.php | 6 ++++--
2 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
index 4f46cf69b70aa..317337d70b58a 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
@@ -15,15 +15,6 @@
*/
class CreateCaseBuilder implements CreateCaseBuilderInterface
{
- /**
- * List of params, which can be empty, but required by Signifyd API.
- *
- * @var array
- */
- private static $allowed = [
- 'cvvResponseCode'
- ];
-
/**
* @var OrderFactory
*/
@@ -115,11 +106,6 @@ public function build($orderId)
private function removeEmptyValues($data)
{
foreach ($data as $key => $value) {
- // skip allowed empty values
- if (in_array($key, self::$allowed, true) && $value === '') {
- continue;
- }
-
if (is_array($value)) {
$data[$key] = $this->removeEmptyValues($data[$key]);
}
@@ -140,6 +126,6 @@ private function removeEmptyValues($data)
*/
private function isEmpty($value)
{
- return $value === null || $value === '' || (is_array($value) && empty($value));
+ return $value === null || (is_array($value) && empty($value));
}
}
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
index 1f93dc9b87d8a..066e493dc0f01 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -127,7 +127,8 @@ public function testCreateCaseBuilderWithFullSetOfData()
'city' => $billingAddress->getCity(),
'provinceCode' => $billingAddress->getRegionCode(),
'postalCode' => $billingAddress->getPostcode(),
- 'countryCode' => $billingAddress->getCountryId()
+ 'countryCode' => $billingAddress->getCountryId(),
+ 'unit' => ''
]
],
'recipient' => [
@@ -223,7 +224,8 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
'city' => $billingAddress->getCity(),
'provinceCode' => $billingAddress->getRegionCode(),
'postalCode' => $billingAddress->getPostcode(),
- 'countryCode' => $billingAddress->getCountryId()
+ 'countryCode' => $billingAddress->getCountryId(),
+ 'unit' => ''
]
],
'seller' => $this->getSellerData(),
From c205be8ae94ee2bd1a0c9a421756700bcad9d9bd Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 9 Feb 2017 03:10:30 -0600
Subject: [PATCH 183/225] MAGETWO-64345: Fix test request processing in webhook
controller
---
.../Signifyd/Controller/Webhooks/Handler.php | 18 ++++++--
.../Unit/Controller/Webhooks/HandlerTest.php | 43 ++++++++++++++++---
.../Controller/Webhooks/HandlerTest.php | 39 +++++++++++++++++
3 files changed, 91 insertions(+), 9 deletions(-)
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
index 9a522b073900a..ac13ff028afcf 100644
--- a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
@@ -23,6 +23,13 @@
*/
class Handler extends Action
{
+ /**
+ * Event topic of test webhook request.
+ *
+ * @var string
+ */
+ private static $eventTopicTest = 'cases/test';
+
/**
* @var WebhookRequest
*/
@@ -95,18 +102,21 @@ public function __construct(
*/
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);
-
- $data = $webhookMessage->getData();
- if ($this->config->isDebugModeEnabled()) {
- $this->logger->debug(json_encode($data));
+ if ($webhookMessage->getEventTopic() === self::$eventTopicTest) {
+ return;
}
+ $data = $webhookMessage->getData();
if (empty($data['caseId'])) {
$this->_redirect('noroute');
return;
diff --git a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
index 598fb9f20a41a..9230419ace200 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
@@ -144,7 +144,7 @@ protected function setUp()
*/
public function testExecuteSuccessfully()
{
- $eventTopic = 'cases\test';
+ $eventTopic = 'cases/creation';
$caseId = 1;
$data = ['score' => 200, 'caseId' => $caseId];
@@ -155,7 +155,7 @@ public function testExecuteSuccessfully()
$webhookMessage = $this->getMockBuilder(WebhookMessage::class)
->disableOriginalConstructor()
->getMock();
- $webhookMessage->expects($this->once())
+ $webhookMessage->expects($this->exactly(2))
->method('getEventTopic')
->willReturn($eventTopic);
$webhookMessage->expects($this->once())
@@ -194,7 +194,7 @@ public function testExecuteSuccessfully()
*/
public function testExecuteCaseUpdatingServiceException()
{
- $eventTopic = 'cases\test';
+ $eventTopic = 'cases/creation';
$caseId = 1;
$data = ['score' => 200, 'caseId' => $caseId];
@@ -205,7 +205,7 @@ public function testExecuteCaseUpdatingServiceException()
$webhookMessage = $this->getMockBuilder(WebhookMessage::class)
->disableOriginalConstructor()
->getMock();
- $webhookMessage->expects($this->once())
+ $webhookMessage->expects($this->exactly(2))
->method('getEventTopic')
->willReturn($eventTopic);
$webhookMessage->expects($this->once())
@@ -265,6 +265,37 @@ public function testExecuteRequestValidationFails()
$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.
*
@@ -278,8 +309,10 @@ public function testExecuteWithMissedCaseId()
$webhookMessage = $this->getMockBuilder(WebhookMessage::class)
->disableOriginalConstructor()
- ->setMethods(['getData'])
->getMock();
+ $webhookMessage->expects($this->once())
+ ->method('getEventTopic')
+ ->willReturn('cases/creation');
$webhookMessage->expects(self::once())
->method('getData')
->willReturn([
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
index 26818a0a0c41a..e483328a680d7 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
@@ -71,6 +71,22 @@ public function testExecuteSuccess()
$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
*
@@ -93,4 +109,27 @@ private function getWebhookRequest()
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;
+ }
}
From edea198792590f5255eeade43200e7054a6dc35b Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 10 Feb 2017 05:54:15 -0600
Subject: [PATCH 184/225] MAGETWO-64154: Rearrange Signifyd information table
in order view template
- always display fraud block when case entity for order is exists
(cherry picked from commit e785e77)
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 19 -------------------
.../view/adminhtml/templates/case_info.phtml | 2 +-
.../Signifyd/Block/Adminhtml/CaseInfoTest.php | 9 ++++++---
3 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 9aaf15ca4a688..43c138bb5150f 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -9,18 +9,12 @@
use Magento\Framework\View\Element\Template\Context;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\CaseManagement;
-use Magento\Signifyd\Model\Config;
/**
* Get Signifyd Case Info
*/
class CaseInfo extends Template
{
- /**
- * @var Config
- */
- private $config;
-
/**
* @var CaseInterface
*/
@@ -33,32 +27,19 @@ class CaseInfo extends Template
/**
* @param Context $context
- * @param Config $config
* @param CaseManagement $caseManagement
* @param array $data
*/
public function __construct(
Context $context,
- Config $config,
CaseManagement $caseManagement,
array $data = []
) {
- $this->config = $config;
$this->caseManagement = $caseManagement;
parent::__construct($context, $data);
}
- /**
- * Checks if service is enabled.
- *
- * @return boolean
- */
- public function isServiceActive()
- {
- return $this->config->isActive();
- }
-
/**
* Gets case entity associated with order id.
*
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 6649ca8fcd2fe..fef28b05ebb8c 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -9,7 +9,7 @@
isServiceActive() || $block->isEmptyCase()) {
+ if ($block->isEmptyCase()) {
return '';
}
?>
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index 95a24791e6911..1f55beea98a37 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -40,15 +40,18 @@ protected function setUp()
}
/**
- * Checks that block does not give contents
- * if Signifyd module is inactive.
+ * 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()
{
- static::assertEmpty($this->getBlockContents());
+ $this->order->loadByIncrementId('100000001');
+
+ static::assertNotEmpty($this->getBlockContents());
}
/**
From b6b06aadda13add9c0b4aed1af4b96ec65ebc3b2 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 14 Feb 2017 07:26:13 -0600
Subject: [PATCH 185/225] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Refactored code according to code review changes.
(cherry picked from commit 301b9c1)
---
.../Model/PaymentVerificationFactory.php | 9 ++--
app/code/Magento/Signifyd/README.md | 51 ++++++++++++++++++-
.../Model/PaymentVerificationFactoryTest.php | 2 +-
3 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
index b84fa43628c0f..3aa3c20669af2 100644
--- a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
+++ b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
@@ -8,6 +8,7 @@
use Magento\Framework\ObjectManagerInterface;
use Magento\Payment\Api\PaymentVerificationInterface;
use Magento\Payment\Gateway\ConfigInterface;
+use Magento\Framework\Exception\ConfigurationMismatchException;
/**
* Creates verification service for provided payment method, or PaymentVerificationInterface::class
@@ -82,13 +83,13 @@ public function createPaymentAvs($paymentCode)
/**
* Creates instance of PaymentVerificationInterface.
* Default implementation will be returned if payment method does not implement PaymentVerificationInterface.
- * Exception will be thrown if payment verification instance does not implement PaymentVerificationInterface.
*
* @param PaymentVerificationInterface $defaultAdapter
* @param string $paymentCode
* @param string $configKey
* @return PaymentVerificationInterface
- * @throws \Exception
+ * @throws ConfigurationMismatchException If payment verification instance
+ * does not implement PaymentVerificationInterface.
*/
private function create(PaymentVerificationInterface $defaultAdapter, $paymentCode, $configKey)
{
@@ -99,7 +100,9 @@ private function create(PaymentVerificationInterface $defaultAdapter, $paymentCo
}
$mapper = $this->objectManager->create($verificationClass);
if (!$mapper instanceof PaymentVerificationInterface) {
- throw new \Exception($verificationClass . ' must implement ' . PaymentVerificationInterface::class);
+ throw new ConfigurationMismatchException(
+ __('%1 must implement %2', $verificationClass, PaymentVerificationInterface::class)
+ );
}
return $mapper;
}
diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md
index 5159d4c6951c4..fc869bfe106d8 100644
--- a/app/code/Magento/Signifyd/README.md
+++ b/app/code/Magento/Signifyd/README.md
@@ -1 +1,50 @@
-The Magento_Signifyd module implements the integration with the [Signifyd](https://www.signifyd.com/docs/api/) fraud prevention service.
+The Magento_Signifyd module provides integration with [Signifyd](https://www.signifyd.com/) fraud protection tool.
+
+#### Introduction
+
+Current implementation allows to create a [case](https://www.signifyd.com/docs/api/#/reference/cases) for the placed order,
+automatically retrieves [guarantee](https://www.signifyd.com/docs/api/#/reference/guarantees) for a created case and
+can cancel Signifyd guarantee on the order canceling.
+
+Magento integration uses Signifyd API and all needed technical details can be found in the [Signifyd API docs](https://www.signifyd.com/docs/api/#/introduction/).
+
+Magento_Signifyd module has extension points for 3d-party developers marked with `@api` annotation:
+
+ - `CaseInterface` - common absraction for a Signifyd case entity, provides methods to set or retrieve all case data fields.
+ - `CaseManagementInterface` - contains methods to create new case entity or retrieve existing for a specified order.
+ - `CaseCreationServiceInterface` - provides an ability to create case entity for a specified order and send request thru Signifyd API to create a new case.
+ - `CaseRepositoryInterface` - describes methods to work with case entity.
+ - `GuaranteeCreationServiceInterface` - allows to send request thru Signifyd API to create new case guarantee.
+ - `GuaranteeCancelingServiceInterface` - allows to send request thru Signifyd API to cancel Signifyd case guarantee.
+ - `CaseSearchResultsInterface` - might be used by `CaseRepositoryInterface` to retrieve list of case entities by specific
+conditions.
+
+To update case(guarantee) entity data Magento implementation uses [Signifyd Webhooks](https://www.signifyd.com/docs/api/#/reference/webhooks) mechanism.
+New created case entity will have `PENDING` status for a case and guarantee. After receiving Webhook, both statuses will be changed to appropriate Signifyd statuses.
+
+#### Customization
+
+Signifyd service collects a lof of different information related for order (all fields described in [API](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case)),
+most of these fields are optional but some of them are required (like `avsResponseCode`, `cvvResponseCode`),
+so, for more accurate calculations,3d party integrations, like payment methods, might provide some additional details, like CVV/AVS response codes.
+
+The 3d party payment methods can implement `\Magento\Payment\Api\PaymentVerificationInterface` to provide AVS/CVV mapping
+from specific codes to [EMS standard](http://www.emsecommerce.net/avs_cvv2_response_codes.htm) and register these mappers in custom payment module `condig.xml` file.
+For example, the mappers registration might look similar to the next:
+
+```xml
+
+
+
+ CustomPaymentFacade
+ Custom Payment
+ ...
+ Magento\CustomPayment\Model\AvsEmsCodeMapper
+ Magento\CustomPayment\Model\CvvEmsCodeMapper
+
+
+
+```
+
+Described steps are enough to provide custom AVS/CVV mapping for custom payment integrations, everything else, like mapper initialization,
+will be provided by Magento Signifyd infrastructure.
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
index 4e335d5a35c95..6c4ffaf7c142e 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
@@ -138,7 +138,7 @@ public function testCreateDefaultCvvMapper()
* Checks a test case, when mapper implementation does not corresponding to PaymentVerificationInterface.
*
* @covers \Magento\Signifyd\Model\PaymentVerificationFactory::createPaymentCvv
- * @expectedException \Exception
+ * @expectedException \Magento\Framework\Exception\ConfigurationMismatchException
* @expectedExceptionMessage stdClass must implement Magento\Payment\Api\PaymentVerificationInterface
*/
public function testCreateWithUnsupportedImplementation()
From 8a75ae549e06ab92b0a037f707564b55400300e6 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Wed, 8 Feb 2017 07:56:17 -0600
Subject: [PATCH 186/225] MAGETWO-63912: Implement payment method code mapping
in Signifyd
- Added payments mapping config files
- Added config file handler
- Changed the PurchaseBuilder class
- Added an unit test
(cherry picked from commit 0d96778)
---
.../PaymentMethodMapper.php | 40 ++++++++
.../XmlToArrayConfigConverter.php | 81 ++++++++++++++++
.../Request/PurchaseBuilder.php | 21 ++++-
.../XmlToArrayConfigConverterTest.php | 76 +++++++++++++++
.../_files/expected_array.php | 13 +++
.../_files/signifyd_payment_mapping.xml | 32 +++++++
app/code/Magento/Signifyd/etc/di.xml | 24 +++++
.../Signifyd/etc/signifyd_payment_mapping.xml | 94 +++++++++++++++++++
.../Signifyd/etc/signifyd_payment_mapping.xsd | 27 ++++++
app/code/Magento/Signifyd/i18n/en_US.csv | 6 +-
10 files changed, 408 insertions(+), 6 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php
create mode 100644 app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/signifyd_payment_mapping.xml
create mode 100644 app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
create mode 100644 app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd
diff --git a/app/code/Magento/Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php b/app/code/Magento/Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php
new file mode 100644
index 0000000000000..48ba85c5da671
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php
@@ -0,0 +1,40 @@
+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
new file mode 100644
index 0000000000000..6438c38ec58ab
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
@@ -0,0 +1,81 @@
+getElementsByTagName('payment_method');
+ $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::$paymentMethodNodeType);
+ $signifyPaymentMethodCode = $this->readSubnodeValue($payment, self::$signifydPaymentMethodNodeType);
+
+ 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 = $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/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 287ecdb84ca77..7fc729fab5b80 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -12,6 +12,7 @@
use Magento\Sales\Model\Order;
use Magento\Signifyd\Model\PaymentVerificationFactory;
use Magento\Signifyd\Model\SignifydOrderSessionId;
+use Magento\Signifyd\Model\PaymentMethodMapper\PaymentMethodMapper;
/**
* Prepare data related to purchase event represented in case creation request.
@@ -39,21 +40,31 @@ class PurchaseBuilder
private $paymentVerificationFactory;
/**
- * @param DateTimeFactory $dateTimeFactory
- * @param ScopeInterface $scope
- * @param SignifydOrderSessionId $signifydOrderSessionId
+ * @var PaymentMethodMapper
+ */
+ private $paymentMethodMapper;
+
+ /**
+ * PurchaseBuilder constructor.
+ *
+ * @param DateTimeFactory $dateTimeFactory
+ * @param ScopeInterface $scope
+ * @param SignifydOrderSessionId $signifydOrderSessionId
* @param PaymentVerificationFactory $paymentVerificationFactory
+ * @param PaymentMethodMapper $paymentMethodMapper
*/
public function __construct(
DateTimeFactory $dateTimeFactory,
ScopeInterface $scope,
SignifydOrderSessionId $signifydOrderSessionId,
- PaymentVerificationFactory $paymentVerificationFactory
+ PaymentVerificationFactory $paymentVerificationFactory,
+ PaymentMethodMapper $paymentMethodMapper
) {
$this->dateTimeFactory = $dateTimeFactory;
$this->scope = $scope;
$this->signifydOrderSessionId = $signifydOrderSessionId;
$this->paymentVerificationFactory = $paymentVerificationFactory;
+ $this->paymentMethodMapper = $paymentMethodMapper;
}
/**
@@ -83,6 +94,8 @@ public function build(Order $order)
'cvvResponseCode' => $this->getCvvCode($orderPayment),
'orderChannel' => $this->getOrderChannel(),
'totalPrice' => $order->getGrandTotal(),
+ 'paymentMethod' => $this->paymentMethodMapper
+ ->getSignifydPaymentMethodCode($orderPayment->getMethod())
],
];
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
new file mode 100644
index 0000000000000..ec7a7986e2ee0
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
@@ -0,0 +1,76 @@
+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
new file mode 100644
index 0000000000000..0578513ab228e
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php
@@ -0,0 +1,13 @@
+ 'PAYMENT_CARD',
+ 'payment_method_2' => 'PAYPAL_ACCOUNT',
+ '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
new file mode 100644
index 0000000000000..d18eefbae718d
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/signifyd_payment_mapping.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+ 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/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 6bf80d12402fc..9e042ef797529 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -82,4 +82,28 @@
+
+
+ Magento_Signifyd
+ signifyd_payment_mapping.xsd
+
+
+
+
+ Magento\Signifyd\Model\PaymentMethodMapper\XmlToArrayConfigConverter
+ paymentMapperSchemaLocator
+ signifyd_payment_mapping.xml
+
+
+
+
+ PaymentMapperConfigReader
+ signifyd_payment_list_cache
+
+
+
+
+ PaymentMethodConfigData
+
+
diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
new file mode 100644
index 0000000000000..c23ed024a7fa5
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
@@ -0,0 +1,94 @@
+
+
+
+
+
+ braintree
+ PAYMENT_CARD
+
+
+ braintree_paypal
+ PAYPAL_ACCOUNT
+
+
+ paypal_express
+ PAYPAL_ACCOUNT
+
+
+ paypal_express_bml
+ PAYPAL_ACCOUNT
+
+
+ payflow_express
+ PAYPAL_ACCOUNT
+
+
+ payflow_express_bml
+ PAYPAL_ACCOUNT
+
+
+ payflowpro
+ PAYMENT_CARD
+
+
+ payflow_link
+ PAYMENT_CARD
+
+
+ payflow_advanced
+ PAYMENT_CARD
+
+
+ hosted_pro
+ PAYMENT_CARD
+
+
+ authorizenet_directpost
+ PAYMENT_CARD
+
+
+ worldpay
+ PAYMENT_CARD
+
+
+ eway
+ PAYMENT_CARD
+
+
+ cybersource
+ PAYMENT_CARD
+
+
+ checkmo
+ CHECK
+
+
+ banktransfer
+ CHECK
+
+
+ cashondelivery
+ CASH
+
+
+ free
+ FREE
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd
new file mode 100644
index 0000000000000..cd8aa93b7aa2a
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index 97d9475048932..e595bcbc89bdb 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -22,5 +22,7 @@
"Sorry, we cannot submit order for Guarantee.","Sorry, we cannot submit order for Guarantee."
"Order id is required.","Order id is required."
"The case entity should not be empty.","The case entity should not be empty."
-"Guarantee has been cancelled for order.","Guarantee has been cancelled for order."
-"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
\ No newline at end of file
+"Guarantee has been cancelled for your order.","Guarantee has been cancelled for your order."
+"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
+"Not empty value for "%1" node is required."
+"Only single entrance of "%1" node is required."
\ No newline at end of file
From 97ca9d696d148e59056e3c838893b22267b6623b Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Tue, 14 Feb 2017 10:22:57 -0600
Subject: [PATCH 187/225] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed xsd schema
---
app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml | 2 +-
app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
index c23ed024a7fa5..c6016ce7fddaf 100644
--- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
@@ -16,7 +16,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Signifyd:etc/signifyd_payment_mapping.xsd">
braintree
diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd
index cd8aa93b7aa2a..abbf5879b7bc8 100644
--- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd
@@ -9,7 +9,7 @@
-
+
From d935d549213d9c6951e58e22f9ba9855df75d80b Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 14 Feb 2017 11:27:57 -0600
Subject: [PATCH 188/225] MAGETWO-63923: Create documentation for Signifyd
extension points
- Added info about Signifyd payment methods mapping customization
(cherry picked from commit 131301d)
---
app/code/Magento/Signifyd/README.md | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md
index fc869bfe106d8..5d1c0510ba671 100644
--- a/app/code/Magento/Signifyd/README.md
+++ b/app/code/Magento/Signifyd/README.md
@@ -47,4 +47,25 @@ For example, the mappers registration might look similar to the next:
```
Described steps are enough to provide custom AVS/CVV mapping for custom payment integrations, everything else, like mapper initialization,
-will be provided by Magento Signifyd infrastructure.
\ No newline at end of file
+will be provided by Magento Signifyd infrastructure.
+
+Also, Signifyd can retrieve payment method for a placed order (Magento Signifyd module implementation contains
+predefined list of mapped Magento payment method codes to Signifyd payment codes, this mapping located in `Magento\Signifyd\etc\signifyd_payment_mapping.xml` file).
+The 3d party payment integrations can add own mapping for [Signifyd payment codes](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case),
+it's enough to add `signifyd_payment_mapping.xml` to custom payment method implementation and specify needed mapping.
+For example, it might look like this:
+
+```xml
+
+
+
+ custom_payment_code
+ PAYMENT_CARD
+
+
+
+```
+
+ - `magento_code` attribute value should be code for a custom payment method (the same as in the payment `config.xml`).
+ - `signifyd_code` attribute value should be one of available Signifyd payment method codes.
\ No newline at end of file
From 581288bc9f894ebd17b216869d61869d016d20ae Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Wed, 15 Feb 2017 02:28:00 -0600
Subject: [PATCH 189/225] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed the integration test
- Code refactoring
(cherry picked from commit b13ef44)
---
app/code/Magento/Signifyd/etc/di.xml | 4 ++--
app/code/Magento/Signifyd/i18n/en_US.csv | 4 ++--
.../Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 6 ++++--
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 9e042ef797529..e873548ed26ba 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -82,7 +82,7 @@
-
+
Magento_Signifyd
signifyd_payment_mapping.xsd
@@ -91,7 +91,7 @@
Magento\Signifyd\Model\PaymentMethodMapper\XmlToArrayConfigConverter
- paymentMapperSchemaLocator
+ PaymentMapperSchemaLocator
signifyd_payment_mapping.xml
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index e595bcbc89bdb..188419e33ac76 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -24,5 +24,5 @@
"The case entity should not be empty.","The case entity should not be empty."
"Guarantee has been cancelled for your order.","Guarantee has been cancelled for your order."
"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
-"Not empty value for "%1" node is required."
-"Only single entrance of "%1" node is required."
\ No newline at end of file
+"Not empty value for "%1" node is required.","Not empty value for "%1" node is required."
+"Only single entrance of "%1" node is required.","Only single entrance of "%1" node is required."
\ No newline at end of file
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
index 066e493dc0f01..2c9bd2c456c64 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -115,7 +115,8 @@ public function testCreateCaseBuilderWithFullSetOfData()
'itemUrl' => $product->getProductUrl(),
'itemWeight' => $product->getWeight()
]
- ]
+ ],
+ 'paymentMethod' => 'PAYPAL_ACCOUNT'
],
'card' => [
'cardHolderName' => 'firstname lastname',
@@ -215,7 +216,8 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
'itemQuantity' => $orderItems[0]->getQtyOrdered(),
'itemUrl' => $product->getProductUrl()
],
- ]
+ ],
+ 'paymentMethod' => 'PAYPAL_ACCOUNT'
],
'card' => [
'cardHolderName' => 'firstname lastname',
From 449b5867aa8d846278a05250762d194313c3f31d Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Wed, 15 Feb 2017 04:15:04 -0600
Subject: [PATCH 190/225] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed integration test
(cherry picked from commit b742954)
---
.../Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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
index 2c9bd2c456c64..0147792ba1f0b 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -217,7 +217,7 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
'itemUrl' => $product->getProductUrl()
],
],
- 'paymentMethod' => 'PAYPAL_ACCOUNT'
+ 'paymentMethod' => 'PAYMENT_CARD'
],
'card' => [
'cardHolderName' => 'firstname lastname',
From eb1a69c1ff928118fead3e05d4d7788fd08fd468 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Wed, 15 Feb 2017 09:16:30 -0600
Subject: [PATCH 191/225] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Code refactoring
(cherry picked from commit fee1b9c)
---
.../XmlToArrayConfigConverter.php | 23 ++++++++++++-------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php b/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
index 6438c38ec58ab..31ebbe6835e37 100644
--- a/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
+++ b/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
@@ -13,25 +13,32 @@
class XmlToArrayConfigConverter implements \Magento\Framework\Config\ConverterInterface
{
/**
- * Node type for payment methods
+ * Node type wrapper for magento and signifyd payment codes
*
* @var string
*/
- private static $paymentMethodNodeType = 'magento_code';
+ private static $paymentMethodNodeType = 'payment_method';
/**
- * Node type for Sygnifyd payment methods
+ * Node type for payment methods code
*
* @var string
*/
- private static $signifydPaymentMethodNodeType = 'signifyd_code';
+ private static $magentoCodeNodeType = 'magento_code';
+
+ /**
+ * Node type for Sygnifyd payment methods code
+ *
+ * @var string
+ */
+ private static $signifydCodeNodeType = 'signifyd_code';
/**
* @inheritdoc
*/
public function convert($source)
{
- $paymentMethods = $source->getElementsByTagName('payment_method');
+ $paymentMethods = $source->getElementsByTagName(self::$paymentMethodNodeType);
$paymentsList = [];
foreach ($paymentMethods as $paymentMethod) {
$paymentsList += $this->getPaymentMethodMapping($paymentMethod);
@@ -50,8 +57,8 @@ public function convert($source)
*/
private function getPaymentMethodMapping(\DOMElement $payment)
{
- $paymentMethodCode = $this->readSubnodeValue($payment, self::$paymentMethodNodeType);
- $signifyPaymentMethodCode = $this->readSubnodeValue($payment, self::$signifydPaymentMethodNodeType);
+ $paymentMethodCode = $this->readSubnodeValue($payment, self::$magentoCodeNodeType);
+ $signifyPaymentMethodCode = $this->readSubnodeValue($payment, self::$signifydCodeNodeType);
return [$paymentMethodCode => $signifyPaymentMethodCode];
}
@@ -71,7 +78,7 @@ private function readSubnodeValue(\DOMElement $element, $subNodeType)
throw new ValidationSchemaException(__('Only single entrance of "%1" node is required.', $subNodeType));
}
- $subNodeValue = $domList[0]->nodeValue;
+ $subNodeValue = trim($domList[0]->nodeValue);
if (!$subNodeValue) {
throw new ValidationSchemaException(__('Not empty value for "%1" node is required.', $subNodeType));
}
From 8ffa123a5547f7f79ddda420c66b24e6413e808d Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 15 Feb 2017 09:36:50 -0600
Subject: [PATCH 192/225] MAGETWO-63923: Create documentation for Signifyd
extension points
- Updated Readme file
(cherry picked from commit 0740544)
---
app/code/Magento/Signifyd/README.md | 67 ++++++++++++++++-------------
1 file changed, 36 insertions(+), 31 deletions(-)
diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md
index 5d1c0510ba671..6ade95e78c2a5 100644
--- a/app/code/Magento/Signifyd/README.md
+++ b/app/code/Magento/Signifyd/README.md
@@ -1,36 +1,41 @@
-The Magento_Signifyd module provides integration with [Signifyd](https://www.signifyd.com/) fraud protection tool.
+# The Magento Signifyd module overview
-#### Introduction
+The Magento_Signifyd module provides integration with the [Signifyd](https://www.signifyd.com/) fraud protection tool.
-Current implementation allows to create a [case](https://www.signifyd.com/docs/api/#/reference/cases) for the placed order,
-automatically retrieves [guarantee](https://www.signifyd.com/docs/api/#/reference/guarantees) for a created case and
-can cancel Signifyd guarantee on the order canceling.
+## Introduction
-Magento integration uses Signifyd API and all needed technical details can be found in the [Signifyd API docs](https://www.signifyd.com/docs/api/#/introduction/).
+The module implementation allows to:
-Magento_Signifyd module has extension points for 3d-party developers marked with `@api` annotation:
+ - create the Signifyd [case](https://www.signifyd.com/docs/api/#/reference/cases) for a placed order
+ - automatically receive the Signifyd [guarantee](https://www.signifyd.com/docs/api/#/reference/guarantees) for a created case
+ - automatically cancel a guarantee when the order is canceled.
- - `CaseInterface` - common absraction for a Signifyd case entity, provides methods to set or retrieve all case data fields.
- - `CaseManagementInterface` - contains methods to create new case entity or retrieve existing for a specified order.
- - `CaseCreationServiceInterface` - provides an ability to create case entity for a specified order and send request thru Signifyd API to create a new case.
- - `CaseRepositoryInterface` - describes methods to work with case entity.
- - `GuaranteeCreationServiceInterface` - allows to send request thru Signifyd API to create new case guarantee.
- - `GuaranteeCancelingServiceInterface` - allows to send request thru Signifyd API to cancel Signifyd case guarantee.
- - `CaseSearchResultsInterface` - might be used by `CaseRepositoryInterface` to retrieve list of case entities by specific
+Magento integration uses the Signifyd API; see the [Signifyd API docs](https://www.signifyd.com/docs/api/#/introduction/) for technical details.
+
+For external developers, the module contains these extension points (marked with `@api` annotation):
+
+ - `CaseInterface` - common absraction for the Signifyd case entity, provides methods to set or retrieve all case data fields.
+ - `CaseManagementInterface` - contains methods to create a new case entity or retrieve existing for a specified order.
+ - `CaseCreationServiceInterface` - provides an ability to create case entity for a specified order and send request through the Signifyd API to create a new case.
+ - `CaseRepositoryInterface` - describes methods to work with a case entity.
+ - `GuaranteeCreationServiceInterface` - allows to send request through the Signifyd API to create a new case guarantee.
+ - `GuaranteeCancelingServiceInterface` - allows to send request through the Signifyd API to cancel the Signifyd case guarantee.
+ - `CaseSearchResultsInterface` - might be used by `CaseRepositoryInterface` to retrieve a list of case entities by specific
conditions.
-To update case(guarantee) entity data Magento implementation uses [Signifyd Webhooks](https://www.signifyd.com/docs/api/#/reference/webhooks) mechanism.
-New created case entity will have `PENDING` status for a case and guarantee. After receiving Webhook, both statuses will be changed to appropriate Signifyd statuses.
+To update entity data for a case or guarantee this module uses the [Signifyd Webhooks](https://www.signifyd.com/docs/api/#/reference/webhooks) mechanism.
+Newly created case entity will have `PENDING` status for a case and guarantee. After receiving Webhook, both statuses will be changed to appropriate Signifyd statuses.
-#### Customization
+## Customization
-Signifyd service collects a lof of different information related for order (all fields described in [API](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case)),
-most of these fields are optional but some of them are required (like `avsResponseCode`, `cvvResponseCode`),
-so, for more accurate calculations,3d party integrations, like payment methods, might provide some additional details, like CVV/AVS response codes.
+The Signifyd service collects a lot of information about an order (all fields described in [API](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case)),
+most of these fields are optional but some of them are required (like `avsResponseCode`, `cvvResponseCode`).
+So, for more accurate calculations, external integrations, like payment methods, might provide some additional details, like CVV/AVS response codes.
-The 3d party payment methods can implement `\Magento\Payment\Api\PaymentVerificationInterface` to provide AVS/CVV mapping
-from specific codes to [EMS standard](http://www.emsecommerce.net/avs_cvv2_response_codes.htm) and register these mappers in custom payment module `condig.xml` file.
-For example, the mappers registration might look similar to the next:
+The custom payment methods can implement `\Magento\Payment\Api\PaymentVerificationInterface` to provide AVS/CVV mapping
+from specific codes to [EMS standard](http://www.emsecommerce.net/avs_cvv2_response_codes.htm) and register these mappers in the `condig.xml` file
+of a custom payment module.
+For example, the mappers registration might look like this:
```xml
@@ -46,14 +51,14 @@ For example, the mappers registration might look similar to the next:
```
-Described steps are enough to provide custom AVS/CVV mapping for custom payment integrations, everything else, like mapper initialization,
-will be provided by Magento Signifyd infrastructure.
+These steps are enough to provide custom AVS/CVV mapping for payment integrations, everything else, like mapper initialization,
+will be provided by the Magento Signifyd infrastructure.
-Also, Signifyd can retrieve payment method for a placed order (Magento Signifyd module implementation contains
-predefined list of mapped Magento payment method codes to Signifyd payment codes, this mapping located in `Magento\Signifyd\etc\signifyd_payment_mapping.xml` file).
-The 3d party payment integrations can add own mapping for [Signifyd payment codes](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case),
+Also, Signifyd can retrieve payment method for a placed order (the Magento Signifyd module can map Magento and Signifyd
+payment codes using the predefined XML list, located in `Magento\Signifyd\etc\signifyd_payment_mapping.xml` file).
+The 3rd-party payment integrations can apply own mappings for the [Signifyd payment codes](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case),
it's enough to add `signifyd_payment_mapping.xml` to custom payment method implementation and specify needed mapping.
-For example, it might look like this:
+For example:
```xml
```
- - `magento_code` attribute value should be code for a custom payment method (the same as in the payment `config.xml`).
- - `signifyd_code` attribute value should be one of available Signifyd payment method codes.
\ No newline at end of file
+ - `magento_code` attribute value should be the code for a custom payment method (the same as in the payment's `config.xml`).
+ - `signifyd_code` attribute value should be one of available the Signifyd payment method codes.
\ No newline at end of file
From 7f277da56e908f398d35866e2623a7873003efde Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 15 Feb 2017 10:09:41 -0600
Subject: [PATCH 193/225] MAGETWO-63640: View Signifyd Guarantee Status in
Order Grid
- Order grid sync after case creation
---
.../Model/CaseServices/CreationService.php | 12 ++++++++-
.../CaseServices/CreationServiceTest.php | 26 +++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php b/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
index 19a8f17bf5bb5..510cf8ff9e7e7 100644
--- a/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
@@ -8,6 +8,7 @@
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
+use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Psr\Log\LoggerInterface;
@@ -39,6 +40,11 @@ class CreationService implements CaseCreationServiceInterface
*/
private $caseRepository;
+ /**
+ * @var OrderGridUpdater
+ */
+ private $orderGridUpdater;
+
/**
* CreationService constructor.
*
@@ -46,17 +52,20 @@ class CreationService implements CaseCreationServiceInterface
* @param Gateway $signifydGateway
* @param LoggerInterface $logger
* @param CaseRepositoryInterface $caseRepository
+ * @param OrderGridUpdater $orderGridUpdater
*/
public function __construct(
CaseManagementInterface $caseManagement,
Gateway $signifydGateway,
LoggerInterface $logger,
- CaseRepositoryInterface $caseRepository
+ CaseRepositoryInterface $caseRepository,
+ OrderGridUpdater $orderGridUpdater
) {
$this->caseManagement = $caseManagement;
$this->signifydGateway = $signifydGateway;
$this->logger = $logger;
$this->caseRepository = $caseRepository;
+ $this->orderGridUpdater = $orderGridUpdater;
}
/**
@@ -65,6 +74,7 @@ public function __construct(
public function createForOrder($orderId)
{
$case = $this->caseManagement->create($orderId);
+ $this->orderGridUpdater->update($orderId);
try {
$caseId = $this->signifydGateway->createCase($orderId);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
index 8f4cc6d188245..d779e98ebd034 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
@@ -175,9 +175,15 @@ public function testCreateForOrder()
/** @var CaseRepositoryInterface $caseRepository */
$caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
$caseEntity = $caseRepository->getByCaseId(123123);
+ $gridGuarantyStatus = $this->getOrderGridGuarantyStatus($caseEntity->getOrderId());
static::assertNotEmpty($caseEntity);
static::assertEquals($order->getEntityId(), $caseEntity->getOrderId());
+ static::assertEquals(
+ $gridGuarantyStatus,
+ $caseEntity->getGuaranteeDisposition(),
+ 'Signifyd guaranty status in sales_order_grid table does not match case entity guaranty status'
+ );
}
/**
@@ -210,4 +216,24 @@ private function getOrder()
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 \Magento\Sales\Model\ResourceModel\Order\Grid\Collection $orderGridCollection */
+ $orderGridCollection = $this->objectManager->get(
+ \Magento\Sales\Model\ResourceModel\Order\Grid\Collection::class
+ );
+
+ $items = $orderGridCollection->addFilter($orderGridCollection->getIdFieldName(), $orderEntityId)
+ ->getItems();
+ $result = array_pop($items);
+
+ return isset($result['signifyd_guarantee_status']) ? $result['signifyd_guarantee_status'] : null;
+ }
}
From a876cd3fd60b2d2d7059a2c86ef8b6602d26068a Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Fri, 17 Feb 2017 07:35:56 -0600
Subject: [PATCH 194/225] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed a comment
(cherry picked from commit 03d0671)
---
.../Signifyd/etc/signifyd_payment_mapping.xml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
index c6016ce7fddaf..cafea60dd2d79 100644
--- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
@@ -5,12 +5,12 @@
* See COPYING.txt for license details.
*/
/**
- * Custom payment method might adds a block in payment_list e.g.
- *
- * custom_payment_method
- * PAYMENT_CARD
- *
- * Appropriate value for the tag from Signifyd documentation:
+ * Custom payment method might adds a block in payment_method_list e.g.
+ *
+ * custom_payment_method
+ * PAYMENT_CARD
+ *
+ * Appropriate value for the 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
*/
From a0c0abd87807e51960b79a531f4649bce0c7a80e Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 1 Mar 2017 07:02:54 -0600
Subject: [PATCH 195/225] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Removed some guarantee cancel checks
(cherry picked from commit 4592a64)
---
.../Guarantee/CancelGuaranteeAbility.php | 6 +--
.../Guarantee/CancelGuaranteeAbilityTest.php | 48 +------------------
.../Model/Guarantee/CancelingServiceTest.php | 25 ----------
3 files changed, 2 insertions(+), 77 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php b/app/code/Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php
index c5e0561735218..2908914ef3bf7 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php
@@ -51,11 +51,7 @@ public function isAvailable($orderId)
return false;
}
- if ($case->isGuaranteeEligible() !== false) {
- return false;
- }
-
- if (in_array($case->getGuaranteeDisposition(), [null, $case::GUARANTEE_DECLINED, $case::GUARANTEE_CANCELED])) {
+ if (in_array($case->getGuaranteeDisposition(), [null, $case::GUARANTEE_CANCELED])) {
return false;
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
index 00b6910a71a70..280f54e7aa5d3 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
@@ -63,10 +63,6 @@ public function testIsAvailableSuccess()
->disableOriginalConstructor()
->getMock();
- $case->expects($this->once())
- ->method('isGuaranteeEligible')
- ->willReturn(false);
-
$case->expects($this->once())
->method('getGuaranteeDisposition')
->willReturn(CaseEntity::GUARANTEE_APPROVED);
@@ -103,40 +99,6 @@ public function testIsAvailableWithNullCase()
$this->assertFalse($this->cancelGuaranteeAbility->isAvailable($orderId));
}
- /**
- * Tests case when GuaranteeEligible for Case is true or null
- *
- * @param mixed $guaranteeEligible
- * @dataProvider isAvailableWithGuarantyIsEligibleDataProvider
- */
- public function testIsAvailableWithGuarantyIsEligible($guaranteeEligible)
- {
- $orderId = 123;
-
- /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */
- $case = $this->getMockBuilder(CaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $case->expects($this->once())
- ->method('isGuaranteeEligible')
- ->willReturn($guaranteeEligible);
-
- $this->caseManagement->expects($this->once())
- ->method('getByOrderId')
- ->with($orderId)
- ->willReturn($case);
-
- $this->assertFalse($this->cancelGuaranteeAbility->isAvailable($orderId));
- }
-
- public function isAvailableWithGuarantyIsEligibleDataProvider()
- {
- return [
- [null], [true]
- ];
- }
-
/**
* Tests case when Guarantee Disposition has Declined or Canceled states.
*
@@ -152,10 +114,6 @@ public function testIsAvailableWithCanceledGuarantee($guaranteeDisposition)
->disableOriginalConstructor()
->getMock();
- $case->expects($this->once())
- ->method('isGuaranteeEligible')
- ->willReturn(false);
-
$case->expects($this->once())
->method('getGuaranteeDisposition')
->willReturn($guaranteeDisposition);
@@ -171,7 +129,7 @@ public function testIsAvailableWithCanceledGuarantee($guaranteeDisposition)
public function isAvailableWithCanceledGuaranteeDataProvider()
{
return [
- [CaseEntity::GUARANTEE_DECLINED], [CaseEntity::GUARANTEE_CANCELED]
+ [CaseEntity::GUARANTEE_CANCELED]
];
}
@@ -187,10 +145,6 @@ public function testIsAvailableWithNullOrder()
->disableOriginalConstructor()
->getMock();
- $case->expects($this->once())
- ->method('isGuaranteeEligible')
- ->willReturn(false);
-
$case->expects($this->once())
->method('getGuaranteeDisposition')
->willReturn(CaseEntity::GUARANTEE_APPROVED);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
index 1ccf347f6f33f..054c8c50598ba 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
@@ -65,31 +65,6 @@ protected function setUp()
]);
}
- /**
- * Checks a test case, when Signifyd guarantee was declined.
- *
- * @covers \Magento\Signifyd\Model\Guarantee\CancelingService::cancelForOrder
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
- */
- public function testCancelForOrderWithDeclinedGuarantee()
- {
- /** @var CaseRepositoryInterface $caseRepository */
- $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
- $caseEntity = $caseRepository->getByCaseId(self::$caseId);
- $caseEntity->setGuaranteeDisposition(CaseInterface::GUARANTEE_DECLINED);
- $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.
*
From 14d60c11244c76345d16d3dbc07bd8a8ff1448ed Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 28 Feb 2017 10:16:39 -0600
Subject: [PATCH 196/225] MAGETWO-65105: Unhold on "Approved" guarantee status
(cherry picked from commit bbf8925)
---
.../Model/CaseServices/UpdatingService.php | 17 +++++-
.../CaseServices/UpdatingServiceTest.php | 28 +++++++--
.../CaseServices/UpdatingServiceTest.php | 60 +++++++++++++++++++
.../Magento/Signifyd/_files/case.php | 6 ++
.../Magento/Signifyd/_files/declined_case.php | 38 ++++++++++++
5 files changed, 143 insertions(+), 6 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/declined_case.php
diff --git a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
index 40f28b32ec0eb..d94af78c42430 100644
--- a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
@@ -11,6 +11,7 @@
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
+use Magento\Signifyd\Model\OrderStateService;
use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
/**
@@ -38,6 +39,11 @@ class UpdatingService implements UpdatingServiceInterface
*/
private $orderGridUpdater;
+ /**
+ * @var OrderStateService
+ */
+ private $orderStateService;
+
/**
* UpdatingService constructor.
*
@@ -45,17 +51,20 @@ class UpdatingService implements UpdatingServiceInterface
* @param CaseRepositoryInterface $caseRepository
* @param CommentsHistoryUpdater $commentsHistoryUpdater
* @param \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater $orderGridUpdater
+ * @param OrderStateService $orderStateService
*/
public function __construct(
GeneratorInterface $messageGenerator,
CaseRepositoryInterface $caseRepository,
CommentsHistoryUpdater $commentsHistoryUpdater,
- OrderGridUpdater $orderGridUpdater
+ OrderGridUpdater $orderGridUpdater,
+ OrderStateService $orderStateService
) {
$this->messageGenerator = $messageGenerator;
$this->caseRepository = $caseRepository;
$this->commentsHistoryUpdater = $commentsHistoryUpdater;
$this->orderGridUpdater = $orderGridUpdater;
+ $this->orderStateService = $orderStateService;
}
/**
@@ -74,11 +83,15 @@ public function update(CaseInterface $case, array $data)
}
try {
+ $previousDisposition = $case->getGuaranteeDisposition();
$this->setCaseData($case, $data);
$orderHistoryComment = $this->messageGenerator->generate($data);
- $this->caseRepository->save($case);
+ $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);
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index a2894939042dd..0717fea7c1644 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
@@ -12,6 +12,7 @@
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;
@@ -46,10 +47,15 @@ class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
private $commentsHistoryUpdater;
/**
- * @var \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater|MockObject
+ * @var OrderGridUpdater|MockObject
*/
private $orderGridUpdater;
+ /**
+ * @var OrderStateService|MockObject
+ */
+ private $orderStateService;
+
/**
* @inheritdoc
*/
@@ -76,11 +82,16 @@ protected function setUp()
->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
+ 'orderGridUpdater' => $this->orderGridUpdater,
+ 'orderStateService' => $this->orderStateService
]);
}
@@ -226,10 +237,15 @@ public function testUpdate()
$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($caseEntity);
+ ->willReturn($caseEntitySaved);
$message = __('Message is generated.');
$this->messageGenerator->expects(self::once())
@@ -243,7 +259,11 @@ public function testUpdate()
$this->commentsHistoryUpdater->expects(self::once())
->method('addComment')
- ->with($caseEntity, $message);
+ ->with($caseEntitySaved, $message);
+
+ $this->orderStateService->expects(self::once())
+ ->method('updateByCase')
+ ->with($caseEntitySaved);
$this->service->update($caseEntity, $data);
}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
index f04108d2b3c8a..85730778dc21c 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
@@ -9,6 +9,7 @@
use Magento\Framework\App\ResourceConnection;
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
+use Magento\Sales\Model\Order;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
@@ -47,6 +48,7 @@ protected function setUp()
/**
* 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
@@ -97,6 +99,7 @@ public function testUpdate()
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($caseEntity->getOrderId());
+ static::assertEquals(Order::STATE_PROCESSING, $order->getState());
$histories = $order->getStatusHistories();
static::assertNotEmpty($histories);
@@ -106,6 +109,63 @@ public function testUpdate()
static::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());
+
+ static::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());
+
+ static::assertEquals(Order::STATE_PROCESSING, $order->getState());
+ }
+
/**
* Returns value of signifyd_guarantee_status column from sales order grid
*
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
index a7df26f033074..fec40dec4f17f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -3,12 +3,17 @@
* Copyright © 2013-2017 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);
@@ -28,6 +33,7 @@
->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');
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/declined_case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/declined_case.php
new file mode 100644
index 0000000000000..16cf1b1b8df14
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/declined_case.php
@@ -0,0 +1,38 @@
+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);
From 811e58cebfece376fde0c667c1a9df02533784da Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 27 Feb 2017 07:47:11 -0600
Subject: [PATCH 197/225] MAGETWO-65103: Setup HOLD status by default after
placing order in case Signifyd was used
(cherry picked from commit 7143d21)
---
.../Model/CaseServices/CreationService.php | 12 +-
.../Signifyd/Model/CommentsHistoryUpdater.php | 5 +-
.../Signifyd/Model/OrderStateService.php | 120 +++++++++++
.../Unit/Model/CommentsHistoryUpdaterTest.php | 16 +-
.../Test/Unit/Model/OrderStateServiceTest.php | 204 ++++++++++++++++++
app/code/Magento/Signifyd/i18n/en_US.csv | 3 +-
.../CaseServices/CreationServiceTest.php | 15 ++
.../CaseServices/UpdatingServiceTest.php | 1 -
8 files changed, 369 insertions(+), 7 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/OrderStateService.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php
diff --git a/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php b/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
index 510cf8ff9e7e7..5503b26958e7f 100644
--- a/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
@@ -8,6 +8,7 @@
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
+use Magento\Signifyd\Model\OrderStateService;
use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
@@ -45,6 +46,11 @@ class CreationService implements CaseCreationServiceInterface
*/
private $orderGridUpdater;
+ /**
+ * @var OrderStateService
+ */
+ private $orderStateService;
+
/**
* CreationService constructor.
*
@@ -53,19 +59,22 @@ class CreationService implements CaseCreationServiceInterface
* @param LoggerInterface $logger
* @param CaseRepositoryInterface $caseRepository
* @param OrderGridUpdater $orderGridUpdater
+ * @param OrderStateService $orderStateService
*/
public function __construct(
CaseManagementInterface $caseManagement,
Gateway $signifydGateway,
LoggerInterface $logger,
CaseRepositoryInterface $caseRepository,
- OrderGridUpdater $orderGridUpdater
+ OrderGridUpdater $orderGridUpdater,
+ OrderStateService $orderStateService
) {
$this->caseManagement = $caseManagement;
$this->signifydGateway = $signifydGateway;
$this->logger = $logger;
$this->caseRepository = $caseRepository;
$this->orderGridUpdater = $orderGridUpdater;
+ $this->orderStateService = $orderStateService;
}
/**
@@ -85,6 +94,7 @@ public function createForOrder($orderId)
$case->setCaseId($caseId);
$this->caseRepository->save($case);
+ $this->orderStateService->updateByCase($case);
return true;
}
diff --git a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
index f36a6205fe3fd..4682f71c3cd7a 100644
--- a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
+++ b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
@@ -35,10 +35,10 @@ public function __construct(HistoryFactory $historyFactory)
*
* @param CaseInterface $case
* @param Phrase $message
+ * @param string $status
* @return void
- * @throws \Exception
*/
- public function addComment(CaseInterface $case, Phrase $message)
+ public function addComment(CaseInterface $case, Phrase $message, $status = '')
{
if (!$message->getText()) {
return;
@@ -49,6 +49,7 @@ public function addComment(CaseInterface $case, Phrase $message)
$history->setParentId($case->getOrderId())
->setComment($message)
->setEntityName('order')
+ ->setStatus($status)
->save();
}
}
diff --git a/app/code/Magento/Signifyd/Model/OrderStateService.php b/app/code/Magento/Signifyd/Model/OrderStateService.php
new file mode 100644
index 0000000000000..8acb9e28a52eb
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/OrderStateService.php
@@ -0,0 +1,120 @@
+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/Test/Unit/Model/CommentsHistoryUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
index fa0a752451917..fe4ccf1c02ea2 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Test\Unit\Model;
-use Magento\Framework\Phrase;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Model\Order\Status\HistoryFactory;
@@ -28,6 +27,11 @@ class CommentsHistoryUpdaterTest extends \PHPUnit_Framework_TestCase
*/
private static $message = 'Case is created.';
+ /**
+ * @var string
+ */
+ private static $status = 'On Hold';
+
/**
* @var CommentsHistoryUpdater
*/
@@ -84,6 +88,10 @@ public function testAddCommentWithException()
->method('getOrderId')
->willReturn(self::$orderId);
+ $this->historyEntity->expects(self::any())
+ ->method('setStatus')
+ ->with('')
+ ->willReturnSelf();
$this->historyEntity->expects(self::once())
->method('save')
->willThrowException(new \Exception('Cannot save comment message.'));
@@ -102,11 +110,15 @@ public function testAddComment()
->method('getOrderId')
->willReturn(self::$orderId);
+ $this->historyEntity->expects(self::any())
+ ->method('setStatus')
+ ->with(self::$status)
+ ->willReturnSelf();
$this->historyEntity->expects(self::once())
->method('save')
->willReturnSelf();
- $this->updater->addComment($this->caseEntity, __(self::$message));
+ $this->updater->addComment($this->caseEntity, __(self::$message), self::$status);
}
/**
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php
new file mode 100644
index 0000000000000..93f4d40dba84a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php
@@ -0,0 +1,204 @@
+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/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index 188419e33ac76..47feacc8c4a2f 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -25,4 +25,5 @@
"Guarantee has been cancelled for your order.","Guarantee has been cancelled for your order."
"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
"Not empty value for "%1" node is required.","Not empty value for "%1" node is required."
-"Only single entrance of "%1" node is required.","Only single entrance of "%1" node is required."
\ No newline at end of file
+"Only single entrance of "%1" node is required.","Only single entrance of "%1" node is required."
+"Awaiting the Signifyd guarantee disposition.","Awaiting the Signifyd guarantee disposition."
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
index d779e98ebd034..a8d31240fb5b0 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
@@ -9,7 +9,9 @@
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\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
use Magento\Signifyd\Model\SignifydGateway\ApiClient;
@@ -184,6 +186,19 @@ public function testCreateForOrder()
$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());
+ static::assertEquals(Order::STATE_HOLDED, $order->getState());
+
+ $histories = $order->getStatusHistories();
+ static::assertNotEmpty($histories);
+
+ /** @var OrderStatusHistoryInterface $orderHoldComment */
+ $orderHoldComment = array_pop($histories);
+ static::assertInstanceOf(OrderStatusHistoryInterface::class, $orderHoldComment);
+ static::assertEquals("Awaiting the Signifyd guarantee disposition.", $orderHoldComment->getComment());
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
index 85730778dc21c..879405a757eaf 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
@@ -6,7 +6,6 @@
namespace Magento\Signifyd\Model\CaseServices;
use Magento\Framework\App\ObjectManager;
-use Magento\Framework\App\ResourceConnection;
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Model\Order;
From 45947325b601f926881348bbc9fbd1c79e3e4c46 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 1 Mar 2017 11:07:08 -0600
Subject: [PATCH 198/225] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Code review fixes
(cherry picked from commit 973286b)
---
.../Guarantee/CancelGuaranteeAbilityTest.php | 16 +++---------
.../Model/Guarantee/CancelingServiceTest.php | 25 +++++++++++++++++++
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
index 280f54e7aa5d3..f51b4980ee857 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
@@ -100,12 +100,9 @@ public function testIsAvailableWithNullCase()
}
/**
- * Tests case when Guarantee Disposition has Declined or Canceled states.
- *
- * @param string $guaranteeDisposition
- * @dataProvider isAvailableWithCanceledGuaranteeDataProvider
+ * Tests case when Guarantee Disposition has Canceled states.
*/
- public function testIsAvailableWithCanceledGuarantee($guaranteeDisposition)
+ public function testIsAvailableWithCanceledGuarantee()
{
$orderId = 123;
@@ -116,7 +113,7 @@ public function testIsAvailableWithCanceledGuarantee($guaranteeDisposition)
$case->expects($this->once())
->method('getGuaranteeDisposition')
- ->willReturn($guaranteeDisposition);
+ ->willReturn(CaseEntity::GUARANTEE_CANCELED);
$this->caseManagement->expects($this->once())
->method('getByOrderId')
@@ -126,13 +123,6 @@ public function testIsAvailableWithCanceledGuarantee($guaranteeDisposition)
$this->assertFalse($this->cancelGuaranteeAbility->isAvailable($orderId));
}
- public function isAvailableWithCanceledGuaranteeDataProvider()
- {
- return [
- [CaseEntity::GUARANTEE_CANCELED]
- ];
- }
-
/**
* Tests case when order does not exist.
*/
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
index 054c8c50598ba..682b3338bef02 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
@@ -65,6 +65,31 @@ protected function setUp()
]);
}
+ /**
+ * 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.
*
From d037632ae66d8a26cdb5a218c37d0643f1063ca0 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Tue, 7 Mar 2017 10:53:15 -0600
Subject: [PATCH 199/225] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- Changes in install schema
(cherry picked from commit 9fb40e4)
---
.../Magento/Signifyd/Setup/InstallData.php | 66 -------------------
.../Magento/Signifyd/Setup/InstallSchema.php | 10 +++
app/code/Magento/Signifyd/composer.json | 1 -
app/code/Magento/Signifyd/etc/module.xml | 1 -
4 files changed, 10 insertions(+), 68 deletions(-)
delete mode 100644 app/code/Magento/Signifyd/Setup/InstallData.php
diff --git a/app/code/Magento/Signifyd/Setup/InstallData.php b/app/code/Magento/Signifyd/Setup/InstallData.php
deleted file mode 100644
index a7490064a895a..0000000000000
--- a/app/code/Magento/Signifyd/Setup/InstallData.php
+++ /dev/null
@@ -1,66 +0,0 @@
-resource = $resource;
- }
-
- /**
- * Installs data for sales module
- *
- * Update of sales_order_grid* tables is provided here to be sure that these tables are already created.
- * {@inheritdoc}
- */
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
- {
- $this->resource->getConnection(self::$connectionName)->addColumn(
- $setup->getTable('sales_order_grid'),
- 'signifyd_guarantee_status',
- [
- 'type' => Table::TYPE_TEXT,
- 'length' => 32,
- 'comment' => 'Signifyd Guarantee Disposition Status'
- ]
- );
-
- $this->resource->getConnection(self::$connectionName)->addColumn(
- $setup->getTable('magento_sales_order_grid_archive'),
- 'signifyd_guarantee_status',
- [
- 'type' => Table::TYPE_TEXT,
- 'length' => 32,
- 'comment' => 'Signifyd Guarantee Disposition Status'
- ]
- );
- }
-}
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index b66bd5314b6bb..35a373097e736 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -92,5 +92,15 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
);
$connection->createTable($table);
+
+ $connection->addColumn(
+ $setup->getTable('sales_order_grid'),
+ 'signifyd_guarantee_status',
+ [
+ 'type' => Table::TYPE_TEXT,
+ 'length' => 32,
+ 'comment' => 'Signifyd Guarantee Disposition Status'
+ ]
+ );
}
}
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 315ed2db7495d..0ec646ed17908 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -5,7 +5,6 @@
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"magento/framework": "100.2.*",
"magento/module-sales": "100.2.*",
- "magento/module-sales-archive": "100.2.*",
"magento/module-store": "100.2.*",
"magento/module-customer": "100.2.*",
"magento/module-directory": "100.2.*",
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 602860b1be220..81d97d6fdc0d4 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,7 +9,6 @@
-
From 1617f5d4a6032598c3edd07011ef7dbb70194992 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 1 Mar 2017 09:48:40 -0600
Subject: [PATCH 200/225] MAGETWO-63641: Signifyd Marketing Materials on
Configuration Page
(cherry picked from commit 9dc2d9c)
---
.../System/Config/Field/WebhookUrl.php | 60 +++++++++++++++
.../Adminhtml/System/Config/Fieldset/Info.php | 31 ++++++++
app/code/Magento/Signifyd/composer.json | 1 +
.../Magento/Signifyd/etc/adminhtml/system.xml | 69 ++++++++++++------
app/code/Magento/Signifyd/i18n/en_US.csv | 16 +++-
.../view/adminhtml/web/images/logo.png | Bin 0 -> 5218 bytes
6 files changed, 154 insertions(+), 23 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Field/WebhookUrl.php
create mode 100644 app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Fieldset/Info.php
create mode 100644 app/code/Magento/Signifyd/view/adminhtml/web/images/logo.png
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
new file mode 100644
index 0000000000000..1fbb15953dbc7
--- /dev/null
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Field/WebhookUrl.php
@@ -0,0 +1,60 @@
+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
new file mode 100644
index 0000000000000..a2501be28395e
--- /dev/null
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Fieldset/Info.php
@@ -0,0 +1,31 @@
+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/composer.json b/app/code/Magento/Signifyd/composer.json
index 0ec646ed17908..e298e61dfc6a3 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -3,6 +3,7 @@
"description": "Submitting Case Entry to Signifyd on Order Creation",
"require": {
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
+ "magento/module-config": "100.2.*",
"magento/framework": "100.2.*",
"magento/module-sales": "100.2.*",
"magento/module-store": "100.2.*",
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/system.xml b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
index 20445a953edce..1da4c75cea0c3 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/system.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
@@ -12,28 +12,53 @@
sales
Magento_Sales::fraud_protection
- Signifyd
-
- Enable this Solution
- Magento\Config\Model\Config\Source\Yesno
- fraud_protection/signifyd/active
-
-
- API Key
- http://signifyd.com/settings/teams after you create a Signifyd account]]>
- fraud_protection/signifyd/api_key
- Magento\Config\Model\Config\Backend\Encrypted
-
-
- API URL
- fraud_protection/signifyd/api_url
- Don’t change unless asked to do so.
-
-
- Debug
- Magento\Config\Model\Config\Source\Yesno
- fraud_protection/signifyd/debug
-
+ signifyd-logo-header
+
+ Magento\Signifyd\Block\Adminhtml\System\Config\Fieldset\Info
+ signifyd-about-header
+
+ Benefits:
+ Grow your business without fear of fraud
+ Accept more orders and maximize your revenue
+ Automate order review and shift fraud off your plate ]]>
+
+ https://www.signifyd.com/magento-ecommerce-fraud-protection-partner
+
+
+ signifyd-about-header
+ Configuration
+ View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com .]]>
+
+
+ Enable this Solution
+ Magento\Config\Model\Config\Source\Yesno
+ fraud_protection/signifyd/active
+
+
+ API Key
+ settings page in the Signifyd console]]>
+ fraud_protection/signifyd/api_key
+ Magento\Config\Model\Config\Backend\Encrypted
+
+
+ API URL
+ fraud_protection/signifyd/api_url
+ Don’t change unless asked to do so.
+
+
+ Debug
+ Magento\Config\Model\Config\Source\Yesno
+ fraud_protection/signifyd/debug
+
+
+ Webhook URL
+ configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento.]]>
+ signifyd/webhooks/handler
+ Magento\Signifyd\Block\Adminhtml\System\Config\Field\WebhookUrl
+
+
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index 47feacc8c4a2f..dca6bcade0eb8 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -26,4 +26,18 @@
"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
"Not empty value for "%1" node is required.","Not empty value for "%1" node is required."
"Only single entrance of "%1" node is required.","Only single entrance of "%1" node is required."
-"Awaiting the Signifyd guarantee disposition.","Awaiting the Signifyd guarantee disposition."
\ No newline at end of file
+"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.
+ Benefits:
+ Grow your business without fear of fraud
+ Accept more orders and maximize your revenue
+ Automate order review and shift fraud off your plate ","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.
+ Benefits:
+ Grow your business without fear of fraud
+ Accept more orders and maximize your revenue
+ Automate order review and shift fraud off your plate "
+"View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com ","View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com "
+"Your API key can be found on the settings page in the Signifyd console","Your API key can be found on the settings page in the Signifyd console"
+"Don’t change unless asked to do so.","Don’t change unless asked to do so."
+"Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento.","Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento."
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/view/adminhtml/web/images/logo.png b/app/code/Magento/Signifyd/view/adminhtml/web/images/logo.png
new file mode 100644
index 0000000000000000000000000000000000000000..7c6645e7c6c93e6ee1a2a5d14ad1b7e95c07ff2b
GIT binary patch
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?jAO2sjD`7)Zc-lTm>hpkH=TwE5ApA_({kLh;f7
z{YTVAGfSWzk%R-PfRz=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*W5*_43Xx<(B;x;+iZLGVN2ZXDmVtWKaG;DC#>K;%
zLL|G(9_{6CwK$T8KMrd^A`*bVHUs7HFAcu}$3m2$F0NQ*1%xX`Ndbd{K@|`uKdWbD7P_9u7<6hW&~RTxB72?9qzp$H`<9RpPr2ogaXAUdibMVcC{
z3yR`F!Q+0HsScjI^H*XKuAgsFLQ4!)jXz*XN
z|1cH*W$)MWzpC~RlGX}G(|>x9_V7;^RD$qLU>wkB1n91R3&eYZ>p4UFK)?hR
zP*-U#Gd)PiSeJHu#>2DB{OdQ?pGi7OJ?G=X2^~sx>u?{1P9
zd-PA;9+BwPXd@j7UQ(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?*{x77m8IX3M$
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$unqsl0hXL6T=zU{6ZSf~KuNXaR7l3uy}OK^
z$|6`#NfX9-zgzec$yUJ(sp)|y(pD&^B1u-EPpDycbzy(xsbw%Yo3A2%;bgrWBO0hoE9+hX0H*8_uIkOd3sxQK(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;@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&!XWI;Wtmf8v-soE4HepS}_jslM8D8-0y;yo|&zT`}Z|
zW8gn&rV&j5^4?i=jf{) 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}I_caSJR##ear$a2f6t@3=a
zR*=x3ZI^b6Yy$U&MYAbY#SYB)GVj>umOuM_;PtB{$^TFVr3~Z+-;I
zP*-mc9@krVm^}UWCo8sq-Ts(_K7`xGJyBgrqZ-_{n2(uu-F3^6wzi+&qin_2iEDCb95n5dq>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#IA7>*T>gCyH|h(Gg6t-DpB;x`=ZA*3?sf?m3Eq*`{>kPb9nmM
zfW-{w*kJGlXY3M{vFS57`~{n{yUDG}h>hCd_S7(Or-^ip+%iJo
zB{;Z&S3zzF-A4Va)uy~#ap`(|cdhrPWHRp+K-ucIv;u`e;8cW(Wp_Ii+`+ir6Uwq3
z7tV6}*4J1=e^W$w9q2Id?%P*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!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#^
zW;)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
zw1gLXRknh`4-&U~Al#8K2Ew%P*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!OuJY
b#4);)59=<+A+s!w{`wi~o1-groud8^wIwiR
literal 0
HcmV?d00001
From 5b949624f2f1de778bf9e41224b76fb3f82f418b Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 1 Mar 2017 04:58:33 -0600
Subject: [PATCH 201/225] MAGETWO-64937: Skip the orders with offline payment
method on case creation
- Removed an ability to submit Signifyd case for order placed with offline payment method
(cherry picked from commit 039ee4d)
---
.../Magento/Signifyd/Observer/PlaceOrder.php | 4 +-
.../_files/expected_array.php | 1 -
.../Test/Unit/Observer/PlaceOrderTest.php | 254 ++++++++++++++++++
.../Signifyd/etc/signifyd_payment_mapping.xml | 12 -
.../Signifyd/Observer/PlaceOrderTest.php | 181 +++++++++++++
5 files changed, 437 insertions(+), 15 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index d260de96c5a9e..cf5b03026bfb3 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -73,7 +73,7 @@ public function execute(Observer $observer)
}
/**
- * Creates signifyd case for single order
+ * Creates Signifyd case for single order with online payment method.
*
* @param OrderInterface $order
* @return void
@@ -81,7 +81,7 @@ public function execute(Observer $observer)
private function createCaseForOrder($order)
{
$orderId = $order->getEntityId();
- if (null === $orderId) {
+ if (null === $orderId || $order->getPayment()->getMethodInstance()->isOffline()) {
return;
}
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
index 0578513ab228e..f4f60058be295 100644
--- 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
@@ -6,7 +6,6 @@
return [
'payment_method_1' => 'PAYMENT_CARD',
'payment_method_2' => 'PAYPAL_ACCOUNT',
- '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/Observer/PlaceOrderTest.php b/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php
new file mode 100644
index 0000000000000..2c64b4a90101a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php
@@ -0,0 +1,254 @@
+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()
+ {
+ $this->withActiveSignifydIntegration(false);
+
+ $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);
+
+ $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;
+ $this->withActiveSignifydIntegration(true);
+ $this->withOrderEntity($orderId);
+ $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;
+ $exceptionMessage = __('Case with the same order id already exists.');
+
+ $this->withActiveSignifydIntegration(true);
+ $this->withOrderEntity($orderId);
+ $this->withAvailablePaymentMethod(true);
+
+ $this->creationService->method('createForOrder')
+ ->with(self::equalTo($orderId))
+ ->willThrowException(new AlreadyExistsException($exceptionMessage));
+
+ $this->logger->method('error')
+ ->with(self::equalTo($exceptionMessage));
+
+ $this->placeOrder->execute($this->observer);
+ }
+
+ /**
+ * Checks a test case when observer successfully calls case creation service.
+ *
+ * @covers \Magento\Signifyd\Observer\PlaceOrder::execute
+ */
+ public function testExecute()
+ {
+ $orderId = 1;
+
+ $this->withActiveSignifydIntegration(true);
+ $this->withOrderEntity($orderId);
+ $this->withAvailablePaymentMethod(true);
+
+ $this->creationService
+ ->method('createForOrder')
+ ->with(self::equalTo($orderId));
+
+ $this->logger->expects(self::never())
+ ->method('error');
+
+ $this->placeOrder->execute($this->observer);
+ }
+
+ /**
+ * Specifies order entity mock execution.
+ *
+ * @param int $orderId
+ * @return void
+ */
+ private function withOrderEntity($orderId)
+ {
+ $this->orderEntity = $this->getMockBuilder(OrderInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->orderEntity->method('getEntityId')
+ ->willReturn($orderId);
+
+ $this->observer->method('getEvent')
+ ->willReturn($this->event);
+
+ $this->event->method('getData')
+ ->with('order')
+ ->willReturn($this->orderEntity);
+ }
+
+ /**
+ * Specifies config mock execution.
+ *
+ * @param bool $isActive
+ * @return void
+ */
+ private function withActiveSignifydIntegration($isActive)
+ {
+ $this->config->method('isActive')
+ ->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/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
index cafea60dd2d79..24f722d9e7246 100644
--- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
@@ -74,18 +74,6 @@
cybersource
PAYMENT_CARD
-
- checkmo
- CHECK
-
-
- banktransfer
- CHECK
-
-
- cashondelivery
- CASH
-
free
FREE
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php
new file mode 100644
index 0000000000000..f0136aadd0cce
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php
@@ -0,0 +1,181 @@
+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);
+ }
+
+ /**
+ * 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 FilterBuilder $filterBuilder */
+ $filterBuilder = $this->objectManager->get(FilterBuilder::class);
+ $filters = [
+ $filterBuilder->setField(OrderInterface::INCREMENT_ID)
+ ->setValue($incrementId)
+ ->create()
+ ];
+
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ ->create();
+
+ $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
+ $orders = $orderRepository->getList($searchCriteria)
+ ->getItems();
+
+ $order = array_pop($orders);
+
+ return $order;
+ }
+}
From 41e68ca2915beae63c427da4d7a45b6a52993088 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 17 Mar 2017 11:08:59 -0500
Subject: [PATCH 202/225] MAGETWO-66178: Update marketing information, order
page and order list with new labels
(cherry picked from commit 9d60d44)
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 46 -----------
.../Unit/Block/Adminhtml/CaseInfoTest.php | 80 -------------------
.../Magento/Signifyd/etc/adminhtml/system.xml | 4 +-
app/code/Magento/Signifyd/i18n/en_US.csv | 3 +-
.../view/adminhtml/templates/case_info.phtml | 10 +--
.../ui_component/sales_order_grid.xml | 2 +-
.../Signifyd/Block/Adminhtml/CaseInfoTest.php | 22 +++--
7 files changed, 16 insertions(+), 151 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 43c138bb5150f..a17f9f58f2976 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -78,30 +78,6 @@ public function isEmptyCase()
return $this->getCaseEntity() === null;
}
- /**
- * Gets case status
- *
- * @return string
- */
- public function getCaseStatus()
- {
- return $this->getCaseProperty('', function () {
- $caseStatusMap = [
- CaseInterface::STATUS_OPEN => __('Open'),
- CaseInterface::STATUS_PENDING => __('Pending'),
- CaseInterface::STATUS_PROCESSING => __('Processing'),
- CaseInterface::STATUS_FLAGGED => __('Flagged'),
- CaseInterface::STATUS_DISMISSED => __('Dismissed')
- ];
-
- $status = isset($caseStatusMap[$this->getCaseEntity()->getStatus()]) ?
- $caseStatusMap[$this->getCaseEntity()->getStatus()] :
- '';
-
- return $status;
- });
- }
-
/**
* Gets case guarantee disposition status.
*
@@ -127,28 +103,6 @@ public function getCaseGuaranteeDisposition()
});
}
- /**
- * Gets case review disposition status.
- *
- * @return string
- */
- public function getCaseReviewDisposition()
- {
- return $this->getCaseProperty('', function () {
- $reviewStatusMap = [
- CaseInterface::DISPOSITION_GOOD => __('Good'),
- CaseInterface::DISPOSITION_FRAUDULENT => __('Fraudulent'),
- CaseInterface::DISPOSITION_UNSET => __('Unset')
- ];
-
- $status = isset($reviewStatusMap[$this->getCaseEntity()->getReviewDisposition()]) ?
- $reviewStatusMap[$this->getCaseEntity()->getReviewDisposition()] :
- '';
-
- return $status;
- });
- }
-
/**
* Retrieves current order Id.
*
diff --git a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
index 0d046800d9523..b1c2aa023aa82 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
@@ -89,47 +89,6 @@ protected function setUp()
]);
}
- /**
- * Checks label according to Signifyd status.
- *
- * @param string $status
- * @param string $expectedLabel
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseStatus()
- * @dataProvider getStatusLabelDataProvider
- */
- public function testGetCaseStatus($status, $expectedLabel)
- {
- $this->caseManagement->expects(self::once())
- ->method('getByOrderId')
- ->willReturn($this->caseEntity);
-
- $this->caseEntity->expects(self::atLeastOnce())
- ->method('getStatus')
- ->willReturn($status);
-
- self::assertEquals(
- $expectedLabel,
- $this->caseInfo->getCaseStatus()
- );
- }
-
- /**
- * Case status and corresponding label data provider.
- *
- * @return array
- */
- public function getStatusLabelDataProvider()
- {
- return [
- [CaseInterface::STATUS_OPEN, __('Open')],
- [CaseInterface::STATUS_PENDING, __('Pending')],
- [CaseInterface::STATUS_PROCESSING, __('Processing')],
- [CaseInterface::STATUS_FLAGGED, __('Flagged')],
- [CaseInterface::STATUS_DISMISSED, __('Dismissed')],
- ['Unregistered', '']
- ];
- }
-
/**
* Checks label according to Signifyd Guarantee Disposition.
*
@@ -172,45 +131,6 @@ public function getGuaranteeLabelDataProvider()
];
}
- /**
- * Checks label according to Signifyd Review Disposition.
- *
- * @param string $reviewDisposition
- * @param string $expectedLabel
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseReviewDisposition()
- * @dataProvider getReviewLabelDataProvider
- */
- public function testGetReviewDisposition($reviewDisposition, $expectedLabel)
- {
- $this->caseManagement->expects(self::once())
- ->method('getByOrderId')
- ->willReturn($this->caseEntity);
-
- $this->caseEntity->expects(self::atLeastOnce())
- ->method('getReviewDisposition')
- ->willReturn($reviewDisposition);
-
- self::assertEquals(
- $expectedLabel,
- $this->caseInfo->getCaseReviewDisposition()
- );
- }
-
- /**
- * Case Review Disposition and corresponding label data provider.
- *
- * @return array
- */
- public function getReviewLabelDataProvider()
- {
- return [
- [CaseInterface::DISPOSITION_GOOD, __('Good')],
- [CaseInterface::DISPOSITION_FRAUDULENT, __('Fraudulent')],
- [CaseInterface::DISPOSITION_UNSET, __('Unset')],
- ['Unregistered', '']
- ];
- }
-
/**
* Checks case property getter with empty case.
*
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/system.xml b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
index 1da4c75cea0c3..e0a5fad5bf334 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/system.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
@@ -16,7 +16,7 @@
Magento\Signifyd\Block\Adminhtml\System\Config\Fieldset\Info
signifyd-about-header
-
+
Benefits:
@@ -24,7 +24,7 @@
Accept more orders and maximize your revenue
Automate order review and shift fraud off your plate ]]>
- https://www.signifyd.com/magento-ecommerce-fraud-protection-partner
+ https://www.signifyd.com/magento-guaranteed-fraud-protection
signifyd-about-header
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index dca6bcade0eb8..474efd51d03fe 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -40,4 +40,5 @@
"View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com ","View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com "
"Your API key can be found on the settings page in the Signifyd console","Your API key can be found on the settings page in the Signifyd console"
"Don’t change unless asked to do so.","Don’t change unless asked to do so."
-"Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento.","Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento."
\ No newline at end of file
+"Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento.","Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento."
+"Signifyd Guarantee Decision","Signifyd Guarantee Decision"
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index fef28b05ebb8c..07d4bb4f656d7 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -23,17 +23,9 @@
- escapeHtml(__('Case Status')); ?>
- escapeHtml($block->getCaseStatus()); ?>
-
-
- escapeHtml(__('Guarantee Disposition')); ?>
+ escapeHtml(__('Signifyd Guarantee Decision')); ?>
escapeHtml($block->getCaseGuaranteeDisposition()); ?>
-
- escapeHtml(__('Review Disposition')); ?>
- escapeHtml($block->getCaseReviewDisposition()); ?>
-
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
index 324dc089d3dfb..1a6515e69c3d6 100644
--- 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
@@ -15,7 +15,7 @@
- select
- Magento_Ui/js/grid/columns/select
- select
- - Signifyd Guarantee Status
+ - Signifyd Guarantee Decision
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index 1f55beea98a37..48b2b33513a6a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -51,7 +51,7 @@ public function testModuleIsInactive()
{
$this->order->loadByIncrementId('100000001');
- static::assertNotEmpty($this->getBlockContents());
+ static::assertNotEmpty($this->getBlock()->toHtml());
}
/**
@@ -67,14 +67,13 @@ public function testCaseEntityNotExists()
{
$this->order->loadByIncrementId('100000001');
- static::assertEmpty($this->getBlockContents());
+ static::assertEmpty($this->getBlock()->toHtml());
}
/**
* Checks that:
* - block give contents
- * - associated team displays correct
- * - score class displays correct
+ * - block contents guarantee decision field
*
* @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getScoreClass
* @magentoConfigFixture current_store fraud_protection/signifyd/active 1
@@ -85,18 +84,17 @@ public function testCaseEntityExists()
{
$this->order->loadByIncrementId('100000001');
- $html = $this->getBlockContents();
- static::assertNotEmpty($html);
- static::assertContains('Processing', $html);
- static::assertContains('Good', $html);
+ $block = $this->getBlock();
+ static::assertNotEmpty($block->toHtml());
+ static::assertContains((string) $block->getCaseGuaranteeDisposition(), $block->toHtml());
}
/**
- * Renders block contents.
+ * Gets block.
*
- * @return string
+ * @return CaseInfo
*/
- private function getBlockContents()
+ private function getBlock()
{
$this->layout->addContainer('order_additional_info', 'Container');
@@ -105,7 +103,7 @@ private function getBlockContents()
$block->setAttribute('context', $this->getContext());
$block->setTemplate('Magento_Signifyd::case_info.phtml');
- return $block->toHtml();
+ return $block;
}
/**
From cceba9543dda14bd2ab2d637153d66c7c2338e36 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 20 Mar 2017 08:35:41 -0500
Subject: [PATCH 203/225] MAGETWO-65119: Create/update automated functional
tests
- Guarantee cancel flow using plugins now
- Webhook wait functions deleted
(cherry picked from commit 8a8759d)
---
.../Magento/Signifyd/Observer/CancelOrder.php | 73 ------------------
.../Magento/Signifyd/Plugin/OrderPlugin.php | 51 ++++++++++++
.../Magento/Signifyd/Plugin/PaymentPlugin.php | 77 +++++++++++++++++++
.../Magento/Signifyd/etc/adminhtml/di.xml | 6 ++
app/code/Magento/Signifyd/etc/events.xml | 3 -
5 files changed, 134 insertions(+), 76 deletions(-)
delete mode 100644 app/code/Magento/Signifyd/Observer/CancelOrder.php
create mode 100644 app/code/Magento/Signifyd/Plugin/OrderPlugin.php
create mode 100644 app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
diff --git a/app/code/Magento/Signifyd/Observer/CancelOrder.php b/app/code/Magento/Signifyd/Observer/CancelOrder.php
deleted file mode 100644
index 2710f89be3d24..0000000000000
--- a/app/code/Magento/Signifyd/Observer/CancelOrder.php
+++ /dev/null
@@ -1,73 +0,0 @@
-config = $config;
- $this->guaranteeAbility = $guaranteeAbility;
- $this->cancelingService = $cancelingService;
- }
-
- /**
- * @inheritdoc
- */
- public function execute(Observer $observer)
- {
- if (!$this->config->isActive()) {
- return;
- }
-
- /** @var OrderInterface $order */
- $order = $observer->getEvent()
- ->getDataByKey('order');
-
- if ($order === null) {
- return;
- }
-
- if ($this->guaranteeAbility->isAvailable($order->getEntityId())) {
- $this->cancelingService->cancelForOrder($order->getEntityId());
- }
- }
-}
diff --git a/app/code/Magento/Signifyd/Plugin/OrderPlugin.php b/app/code/Magento/Signifyd/Plugin/OrderPlugin.php
new file mode 100644
index 0000000000000..584f2d3e3ac2f
--- /dev/null
+++ b/app/code/Magento/Signifyd/Plugin/OrderPlugin.php
@@ -0,0 +1,51 @@
+guaranteeCancelingService = $guaranteeCancelingService;
+ }
+
+ /**
+ * Performs Signifyd guarantee cancel operation after order canceling
+ * if cancel order operation was successful.
+ *
+ * @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
new file mode 100644
index 0000000000000..2949cd01fbfda
--- /dev/null
+++ b/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
@@ -0,0 +1,77 @@
+guaranteeCancelingService = $guaranteeCancelingService;
+ $this->registry = $registry;
+ }
+
+ /**
+ * Performs Signifyd guarantee cancel operation after payment denying.
+ *
+ * @param MethodInterface $subject
+ * @param MethodInterface|bool $result
+ * @return MethodInterface|bool
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function afterDenyPayment(MethodInterface $subject, $result)
+ {
+ /** @var \Magento\Sales\Api\Data\OrderInterface $order */
+ $order = $this->registry->registry('current_order');
+
+ if ($this->isPaymentDenied($order->getPayment(), $result)) {
+ $this->guaranteeCancelingService->cancelForOrder(
+ $order->getEntityId()
+ );
+ }
+
+ 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 \Magento\Sales\Api\Data\OrderPaymentInterface $payment
+ * @param MethodInterface $result
+ * @return bool
+ */
+ private function isPaymentDenied($payment, $result)
+ {
+ return $result !== false || $payment->getIsTransactionClosed();
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/di.xml b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
index 1c827afa99dbc..0a64a591ccd3b 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/di.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
@@ -7,4 +7,10 @@
-->
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/events.xml b/app/code/Magento/Signifyd/etc/events.xml
index 17cbe99ec96a1..c5e69449793a5 100644
--- a/app/code/Magento/Signifyd/etc/events.xml
+++ b/app/code/Magento/Signifyd/etc/events.xml
@@ -9,7 +9,4 @@
-
-
-
From bc676a7ab0ef4ee471715e0df17a92cd88929575 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 20 Mar 2017 09:01:39 -0500
Subject: [PATCH 204/225] MAGETWO-65119: Create/update automated functional
tests
- Added constraint into deny payment testcase
- Covered cancel and deny flow with integration tests
- Added delete customer step to functional test
(cherry picked from commit 8d21c24)
---
.../Magento/Signifyd/Plugin/OrderPlugin.php | 5 +-
.../Magento/Signifyd/Plugin/PaymentPlugin.php | 5 +-
.../Test/Unit/Observer/CancelOrderTest.php | 209 -----------------
.../Magento/Signifyd/etc/adminhtml/di.xml | 6 -
app/code/Magento/Signifyd/etc/di.xml | 6 +
.../{Observer => Plugin}/CancelOrderTest.php | 12 +-
.../Signifyd/Plugin/DenyPaymentTest.php | 218 ++++++++++++++++++
7 files changed, 237 insertions(+), 224 deletions(-)
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Observer/CancelOrderTest.php
rename dev/tests/integration/testsuite/Magento/Signifyd/{Observer => Plugin}/CancelOrderTest.php (92%)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php
diff --git a/app/code/Magento/Signifyd/Plugin/OrderPlugin.php b/app/code/Magento/Signifyd/Plugin/OrderPlugin.php
index 584f2d3e3ac2f..0d8ea10529c9e 100644
--- a/app/code/Magento/Signifyd/Plugin/OrderPlugin.php
+++ b/app/code/Magento/Signifyd/Plugin/OrderPlugin.php
@@ -10,9 +10,9 @@
use Magento\Signifyd\Api\GuaranteeCancelingServiceInterface;
/**
- * Plugin complements Order::cancel method logic with canceling Signifyd guarantee.
+ * Plugin for Magento\Sales\Model\Order.
*
- * @see Order::cancel
+ * @see Order
*/
class OrderPlugin
{
@@ -34,6 +34,7 @@ public function __construct(
* 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
diff --git a/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php b/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
index 2949cd01fbfda..3cec11bee82ce 100644
--- a/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
+++ b/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
@@ -10,9 +10,9 @@
use Magento\Signifyd\Api\GuaranteeCancelingServiceInterface;
/**
- * Plugin complements MethodInterface::denyPayment method logic with canceling Signifyd guarantee.
+ * Plugin for Magento\Payment\Model\MethodInterface.
*
- * @see MethodInterface::denyPayment
+ * @see MethodInterface
*/
class PaymentPlugin
{
@@ -41,6 +41,7 @@ public function __construct(
/**
* Performs Signifyd guarantee cancel operation after payment denying.
*
+ * @see MethodInterface::denyPayment
* @param MethodInterface $subject
* @param MethodInterface|bool $result
* @return MethodInterface|bool
diff --git a/app/code/Magento/Signifyd/Test/Unit/Observer/CancelOrderTest.php b/app/code/Magento/Signifyd/Test/Unit/Observer/CancelOrderTest.php
deleted file mode 100644
index f3d52e31776ef..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/Observer/CancelOrderTest.php
+++ /dev/null
@@ -1,209 +0,0 @@
-config = $this->getMockBuilder(Config::class)
- ->disableOriginalConstructor()
- ->setMethods(['isActive'])
- ->getMock();
-
- $this->guaranteeAbility = $this->getMockBuilder(CancelGuaranteeAbility::class)
- ->disableOriginalConstructor()
- ->setMethods(['isAvailable'])
- ->getMock();
-
- $this->cancelingService = $this->getMockBuilder(GuaranteeCancelingServiceInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->observer = $objectManager->getObject(CancelOrder::class, [
- 'config' => $this->config,
- 'guaranteeAbility' => $this->guaranteeAbility,
- 'cancelingService' => $this->cancelingService
- ]);
- }
-
- /**
- * Checks a test case, when Signifyd does not enabled.
- *
- * @covers \Magento\Signifyd\Observer\CancelOrder::execute
- */
- public function testExecuteWithDisabledConfiguration()
- {
- $order = null;
- $this->config->expects(self::once())
- ->method('isActive')
- ->willReturn(false);
-
- $this->guaranteeAbility->expects(self::never())
- ->method('isAvailable');
-
- $this->cancelingService->expects(self::never())
- ->method('cancelForOrder');
-
- /** @var Observer|MockObject $observer */
- $observer = $this->getObserverMock($order);
- $this->observer->execute($observer);
- }
-
- /**
- * Checks a test case, when not order entity in observer event.
- *
- * @covers \Magento\Signifyd\Observer\CancelOrder::execute
- */
- public function testExecuteWithNonExistsOrder()
- {
- $order = null;
- $this->config->expects(self::once())
- ->method('isActive')
- ->willReturn(true);
-
- $this->guaranteeAbility->expects(self::never())
- ->method('isAvailable');
-
- $this->cancelingService->expects(self::never())
- ->method('cancelForOrder');
-
- /** @var Observer|MockObject $observer */
- $observer = $this->getObserverMock($order);
- $this->observer->execute($observer);
- }
-
- /**
- * Checks a case, when case guarantee is not available for cancelling.
- *
- * @covers \Magento\Signifyd\Observer\CancelOrder::execute
- */
- public function testExecuteWithNonEligibleGuarantee()
- {
- $entityId = 1;
- /** @var OrderInterface|MockObject $order */
- $order = $this->getMockBuilder(OrderInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $order->expects(self::once())
- ->method('getEntityId')
- ->willReturn($entityId);
-
- $this->config->expects(self::once())
- ->method('isActive')
- ->willReturn(true);
-
- $this->guaranteeAbility->expects(self::once())
- ->method('isAvailable')
- ->with(self::equalTo($entityId))
- ->willReturn(false);
-
- $this->cancelingService->expects(self::never())
- ->method('cancelForOrder');
-
- /** @var Observer|MockObject $observer */
- $observer = $this->getObserverMock($order);
- $this->observer->execute($observer);
- }
-
- /**
- * Checks a case, when case guarantee submitted for cancelling.
- *
- * @covers \Magento\Signifyd\Observer\CancelOrder::execute
- */
- public function testExecute()
- {
- $entityId = 1;
- /** @var OrderInterface|MockObject $order */
- $order = $this->getMockBuilder(OrderInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $order->expects(self::exactly(2))
- ->method('getEntityId')
- ->willReturn($entityId);
-
- $this->config->expects(self::once())
- ->method('isActive')
- ->willReturn(true);
-
- $this->guaranteeAbility->expects(self::once())
- ->method('isAvailable')
- ->with(self::equalTo($entityId))
- ->willReturn(true);
-
- $this->cancelingService->expects(self::once())
- ->method('cancelForOrder')
- ->with(self::equalTo($entityId));
-
- /** @var Observer|MockObject $observer */
- $observer = $this->getObserverMock($order);
- $this->observer->execute($observer);
- }
-
- /**
- * Gets mock object for observer.
- *
- * @param OrderInterface|null $order
- * @return Observer|MockObject
- */
- private function getObserverMock($order)
- {
- $observer = $this->getMockBuilder(Observer::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $event = $this->getMockBuilder(Event::class)
- ->disableOriginalConstructor()
- ->setMethods(['getDataByKey'])
- ->getMock();
-
- $observer->expects(self::any())
- ->method('getEvent')
- ->willReturn($event);
-
- $event->expects(self::any())
- ->method('getDataByKey')
- ->with('order')
- ->willReturn($order);
-
- return $observer;
- }
-}
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/di.xml b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
index 0a64a591ccd3b..1c827afa99dbc 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/di.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
@@ -7,10 +7,4 @@
-->
-
-
-
-
-
-
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index e873548ed26ba..551da4f023a56 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -106,4 +106,10 @@
PaymentMethodConfigData
+
+
+
+
+
+
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php
similarity index 92%
rename from dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
rename to dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php
index 94f1779312f1f..4a7be25913a81 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php
@@ -3,7 +3,7 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Observer;
+namespace Magento\Signifyd\Plugin;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -58,13 +58,14 @@ protected function tearDown()
}
/**
- * Checks a test case, when order has been cancelled and triggers event to cancel Signifyd case guarantee
+ * Checks a test case, when order has been cancelled
+ * and calls plugin to cancel Signifyd case guarantee.
*
- * @covers \Magento\Signifyd\Observer\CancelOrder::execute
+ * @covers \Magento\Signifyd\Plugin\OrderPlugin::afterCancel
* @magentoDataFixture Magento/Signifyd/_files/approved_case.php
* @magentoConfigFixture current_store fraud_protection/signifyd/active 1
*/
- public function testExecute()
+ public function testAfterCancel()
{
$order = $this->getOrder();
@@ -93,7 +94,8 @@ public function testExecute()
}
/**
- * Get stored order
+ * Get stored order.
+ *
* @return OrderInterface
*/
private function getOrder()
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php
new file mode 100644
index 0000000000000..e6b249221a36f
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php
@@ -0,0 +1,218 @@
+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 FilterBuilder $filterBuilder */
+ $filterBuilder = $this->objectManager->get(FilterBuilder::class);
+ $filters = [
+ $filterBuilder->setField(OrderInterface::INCREMENT_ID)
+ ->setValue('100000001')
+ ->create()
+ ];
+
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ ->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;
+ }
+}
From 370f13da3983d2c4153e28ccda720fbc3883f1bd Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Thu, 23 Mar 2017 04:51:33 -0500
Subject: [PATCH 205/225] MAGETWO-65119: Create/update automated functional
tests
- Reimplemented customer cleanup logic
(cherry picked from commit deb655f)
---
.../TestStep/SignifydCreateCustomerStep.php | 76 +++++++++++++++++++
1 file changed, 76 insertions(+)
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php
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
new file mode 100644
index 0000000000000..ca57d7c3b97b6
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php
@@ -0,0 +1,76 @@
+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(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]
+ );
+ }
+}
From acd54ab58f613b81455eae5cefb8a992556c9a67 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 27 Mar 2017 05:35:17 -0500
Subject: [PATCH 206/225] MAGETWO-65119: Create/update automated functional
tests
- Added cleanup for customer
(cherry picked from commit 5f03007)
---
.../Signifyd/Test/TestStep/SignifydCreateCustomerStep.php | 1 +
1 file changed, 1 insertion(+)
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
index ca57d7c3b97b6..039c8c50da3f9 100644
--- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php
@@ -57,6 +57,7 @@ public function run()
*/
public function cleanup()
{
+ $this->getStepInstance(CreateCustomerStep::class)->cleanup();
$this->getStepInstance(DeleteCustomerStep::class)->run();
}
From 89f3f7568afc5164f5a0fbbc1a9ac3076ca54b3b Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 29 Mar 2017 10:06:36 -0500
Subject: [PATCH 207/225] MAGETWO-65119: Create/update automated functional
tests
- Fixed usage of registry in plugin
(cherry picked from commit 5bab362)
---
.../Magento/Signifyd/Plugin/PaymentPlugin.php | 31 ++++++-------------
1 file changed, 10 insertions(+), 21 deletions(-)
diff --git a/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php b/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
index 3cec11bee82ce..031cdac6738b2 100644
--- a/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
+++ b/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Signifyd\Plugin;
-use Magento\Framework\Registry;
+use Magento\Payment\Model\InfoInterface;
use Magento\Payment\Model\MethodInterface;
use Magento\Signifyd\Api\GuaranteeCancelingServiceInterface;
@@ -21,41 +21,30 @@ class PaymentPlugin
*/
private $guaranteeCancelingService;
- /**
- * @var Registry
- */
- private $registry;
-
/**
* @param GuaranteeCancelingServiceInterface $guaranteeCancelingService
- * @param Registry $registry
*/
public function __construct(
- GuaranteeCancelingServiceInterface $guaranteeCancelingService,
- Registry $registry
+ GuaranteeCancelingServiceInterface $guaranteeCancelingService
) {
$this->guaranteeCancelingService = $guaranteeCancelingService;
- $this->registry = $registry;
}
/**
* Performs Signifyd guarantee cancel operation after payment denying.
*
* @see MethodInterface::denyPayment
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ *
* @param MethodInterface $subject
* @param MethodInterface|bool $result
- * @return MethodInterface|bool
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ * @param InfoInterface $payment
+ * @return bool|MethodInterface
*/
- public function afterDenyPayment(MethodInterface $subject, $result)
+ public function afterDenyPayment(MethodInterface $subject, $result, InfoInterface $payment)
{
- /** @var \Magento\Sales\Api\Data\OrderInterface $order */
- $order = $this->registry->registry('current_order');
-
- if ($this->isPaymentDenied($order->getPayment(), $result)) {
- $this->guaranteeCancelingService->cancelForOrder(
- $order->getEntityId()
- );
+ if ($this->isPaymentDenied($payment, $result)) {
+ $this->guaranteeCancelingService->cancelForOrder($payment->getParentId());
}
return $result;
@@ -67,7 +56,7 @@ public function afterDenyPayment(MethodInterface $subject, $result)
* Result not false check for payment methods using AbstractMethod.
* Transaction is closed check for payment methods using Gateway.
*
- * @param \Magento\Sales\Api\Data\OrderPaymentInterface $payment
+ * @param InfoInterface $payment
* @param MethodInterface $result
* @return bool
*/
From 3dee91d1d26ed55c6aafcef95fd062c67ea57e0e Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 31 Mar 2017 06:09:39 -0500
Subject: [PATCH 208/225] MAGETWO-63642: Update Order Status Based on Signifyd
Guarantee Status
- Fixed copyrights
(cherry picked from commit aff5cd9)
---
app/code/Magento/Signifyd/Model/OrderStateService.php | 2 +-
app/code/Magento/Signifyd/Plugin/OrderPlugin.php | 2 +-
app/code/Magento/Signifyd/Plugin/PaymentPlugin.php | 2 +-
.../Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php | 2 +-
.../Signifyd/Test/TestStep/SignifydCreateCustomerStep.php | 2 +-
.../testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php | 2 +-
.../testsuite/Magento/Signifyd/_files/declined_case.php | 2 +-
7 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/OrderStateService.php b/app/code/Magento/Signifyd/Model/OrderStateService.php
index 8acb9e28a52eb..47e3c7a4d1f14 100644
--- a/app/code/Magento/Signifyd/Model/OrderStateService.php
+++ b/app/code/Magento/Signifyd/Model/OrderStateService.php
@@ -1,6 +1,6 @@
Date: Tue, 11 Apr 2017 03:57:35 -0500
Subject: [PATCH 209/225] MAGETWO-67298: Push the file (Signifyd readme) to the
repo
(cherry picked from commit 726cf75)
---
app/code/Magento/Signifyd/README.md | 144 ++++++++++++++--------------
1 file changed, 73 insertions(+), 71 deletions(-)
diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md
index 6ade95e78c2a5..149bd9d6401a0 100644
--- a/app/code/Magento/Signifyd/README.md
+++ b/app/code/Magento/Signifyd/README.md
@@ -1,76 +1,78 @@
-# The Magento Signifyd module overview
+# Magento_Signifyd module
-The Magento_Signifyd module provides integration with the [Signifyd](https://www.signifyd.com/) fraud protection tool.
+## Overview
-## Introduction
+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 the Signifyd [case](https://www.signifyd.com/docs/api/#/reference/cases) for a placed order
- - automatically receive the Signifyd [guarantee](https://www.signifyd.com/docs/api/#/reference/guarantees) for a created case
- - automatically cancel a guarantee when the order is canceled.
-
-Magento integration uses the Signifyd API; see the [Signifyd API docs](https://www.signifyd.com/docs/api/#/introduction/) for technical details.
-
-For external developers, the module contains these extension points (marked with `@api` annotation):
-
- - `CaseInterface` - common absraction for the Signifyd case entity, provides methods to set or retrieve all case data fields.
- - `CaseManagementInterface` - contains methods to create a new case entity or retrieve existing for a specified order.
- - `CaseCreationServiceInterface` - provides an ability to create case entity for a specified order and send request through the Signifyd API to create a new case.
- - `CaseRepositoryInterface` - describes methods to work with a case entity.
- - `GuaranteeCreationServiceInterface` - allows to send request through the Signifyd API to create a new case guarantee.
- - `GuaranteeCancelingServiceInterface` - allows to send request through the Signifyd API to cancel the Signifyd case guarantee.
- - `CaseSearchResultsInterface` - might be used by `CaseRepositoryInterface` to retrieve a list of case entities by specific
-conditions.
-
-To update entity data for a case or guarantee this module uses the [Signifyd Webhooks](https://www.signifyd.com/docs/api/#/reference/webhooks) mechanism.
-Newly created case entity will have `PENDING` status for a case and guarantee. After receiving Webhook, both statuses will be changed to appropriate Signifyd statuses.
-
-## Customization
-
-The Signifyd service collects a lot of information about an order (all fields described in [API](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case)),
-most of these fields are optional but some of them are required (like `avsResponseCode`, `cvvResponseCode`).
-So, for more accurate calculations, external integrations, like payment methods, might provide some additional details, like CVV/AVS response codes.
-
-The custom payment methods can implement `\Magento\Payment\Api\PaymentVerificationInterface` to provide AVS/CVV mapping
-from specific codes to [EMS standard](http://www.emsecommerce.net/avs_cvv2_response_codes.htm) and register these mappers in the `condig.xml` file
-of a custom payment module.
-For example, the mappers registration might look like this:
-
-```xml
-
-
-
- CustomPaymentFacade
- Custom Payment
- ...
- Magento\CustomPayment\Model\AvsEmsCodeMapper
- Magento\CustomPayment\Model\CvvEmsCodeMapper
-
-
-
-```
-
-These steps are enough to provide custom AVS/CVV mapping for payment integrations, everything else, like mapper initialization,
-will be provided by the Magento Signifyd infrastructure.
-
-Also, Signifyd can retrieve payment method for a placed order (the Magento Signifyd module can map Magento and Signifyd
-payment codes using the predefined XML list, located in `Magento\Signifyd\etc\signifyd_payment_mapping.xml` file).
-The 3rd-party payment integrations can apply own mappings for the [Signifyd payment codes](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case),
-it's enough to add `signifyd_payment_mapping.xml` to custom payment method implementation and specify needed mapping.
-For example:
-
-```xml
-
-
-
- custom_payment_code
- PAYMENT_CARD
-
-
-
-```
-
- - `magento_code` attribute value should be the code for a custom payment method (the same as in the payment's `config.xml`).
- - `signifyd_code` attribute value should be one of available the Signifyd payment method codes.
\ No newline at end of file
+ - 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:
+
+`CaseInterface` (common abstraction for the Signifyd case entity):
+
+- set or retrieve all case data fields
+
+`CaseManagementInterface`:
+
+- create a new case entity
+- retrieve the existing case entity for a specified order
+
+`CaseCreationServiceInterface`:
+
+- create a case entity for a specified order
+- send a request through the Signifyd API to create a new case
+
+`CaseRepositoryInterface`:
+
+- describe methods to work with a case entity
+
+`GuaranteeCreationServiceInterface`:
+
+- send a request through the Signifyd API to create a new case guarantee
+
+`GuaranteeCancelingServiceInterface`:
+- send a request through the Signifyd API to cancel the Signifyd case guarantee
+
+`CaseSearchResultsInterface`:
+
+- might be used by `CaseRepositoryInterface` to retrieve a list of case entities by specific conditions
+
+For information about a public API in Magento 2, see [Public interfaces & APIs](http://devdocs.magento.com/guides/v2.1/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](http://devdocs.magento.com/guides/v2.0/release-notes/changes/ee_changes.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](http://devdocs.magento.com/guides/v2.2/payments-integrations/signifyd/signifyd.html#provide-avscvv-response-codes)
+
+- [Retrieve payment method for a placed order](http://devdocs.magento.com/guides/v2.2/payments-integrations/signifyd/signifyd.html#retrieve-payment-method-for-a-placed-order)
From cf7fd3ada64f54d50553a1dc8cd6d2c3763c96da Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 19 Apr 2017 03:56:16 -0500
Subject: [PATCH 210/225] MAGETWO-67298: Push the file (Signifyd readme) to the
repo
- Replace class names with FQCN
(cherry picked from commit 9ed3881)
---
app/code/Magento/Signifyd/README.md | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md
index 149bd9d6401a0..9479972cb21b6 100644
--- a/app/code/Magento/Signifyd/README.md
+++ b/app/code/Magento/Signifyd/README.md
@@ -18,34 +18,34 @@ The Magento_Signifyd module does not add own Events, Layouts, and UI Components
The following interfaces (marked with the `@api` annotation) provide methods that allow to:
-`CaseInterface` (common abstraction for the Signifyd case entity):
+`Magento\Signifyd\Api\Data\CaseInterface` (common abstraction for the Signifyd case entity):
- set or retrieve all case data fields
-`CaseManagementInterface`:
+`Magento\Signifyd\Api\CaseManagementInterface`:
- create a new case entity
- retrieve the existing case entity for a specified order
-`CaseCreationServiceInterface`:
+`Magento\Signifyd\Api\CaseCreationServiceInterface`:
- create a case entity for a specified order
- send a request through the Signifyd API to create a new case
-`CaseRepositoryInterface`:
+`Magento\Signifyd\Api\CaseRepositoryInterface`:
- describe methods to work with a case entity
-`GuaranteeCreationServiceInterface`:
+`Magento\Signifyd\Api\GuaranteeCreationServiceInterface`:
- send a request through the Signifyd API to create a new case guarantee
-`GuaranteeCancelingServiceInterface`:
+`Magento\Signifyd\Api\GuaranteeCancelingServiceInterface`:
- send a request through the Signifyd API to cancel the Signifyd case guarantee
-`CaseSearchResultsInterface`:
+`Magento\Signifyd\Api\Data\CaseSearchResultsInterface`:
-- might be used by `CaseRepositoryInterface` to retrieve a list of case entities by specific conditions
+- 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](http://devdocs.magento.com/guides/v2.1/extension-dev-guide/api-concepts.html).
From 8f07e1d9e8c51f00eccfa6d4270d4a190c1c3c4c Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 30 Aug 2017 07:43:52 -0500
Subject: [PATCH 211/225] MAGETWO-71763: Signifyd does not work for PayPal
Payments Standard
- Added listener for place order event with PayPal Express Checkout
(cherry picked from commit 9c27160)
---
app/code/Magento/Signifyd/etc/events.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/code/Magento/Signifyd/etc/events.xml b/app/code/Magento/Signifyd/etc/events.xml
index c5e69449793a5..9717f3947a9c4 100644
--- a/app/code/Magento/Signifyd/etc/events.xml
+++ b/app/code/Magento/Signifyd/etc/events.xml
@@ -9,4 +9,7 @@
+
+
+
From e5649e5ef8462f0a1f710db617949d27351ee517 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Fri, 17 Nov 2017 15:55:47 -0600
Subject: [PATCH 212/225] MAGETWO-72487: Move code to CE
- move the function tests
---
dev/tests/functional/credentials.xml.dist | 1 +
.../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 | 67 +++++
.../Block/SignifydConsole/SignifydLogin.php | 31 +++
.../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 | 34 +++
...ymentWithSignifydGuaranteeDeclinedTest.php | 63 +++++
...ymentWithSignifydGuaranteeDeclinedTest.xml | 38 +++
...ateSignifydGuaranteeAndCancelOrderTest.php | 62 +++++
...ateSignifydGuaranteeAndCancelOrderTest.xml | 68 +++++
...ymentWithSignifydGuaranteeDeclinedTest.php | 63 +++++
...ymentWithSignifydGuaranteeDeclinedTest.xml | 39 +++
.../Test/TestStep/OpenOrderGridStep.php | 173 +++++++++++++
.../Test/TestStep/SignifydCancelOrderStep.php | 105 ++++++++
.../SignifydFillShippingAddressStep.php | 70 +++++
.../Test/TestStep/SignifydLoginStep.php | 68 +++++
.../Test/TestStep/SignifydObserveCaseStep.php | 152 +++++++++++
.../SignifydSetWebhookHandlersStep.php | 64 +++++
.../TestStep/UnholdAndCancelOrderStep.php | 84 ++++++
.../app/Magento/Signifyd/Test/etc/di.xml | 34 +++
.../Magento/Signifyd/Test/etc/testcase.xml | 58 +++++
43 files changed, 2608 insertions(+)
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/Grid.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/View/FraudProtection.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseInfo.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseSearch.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/SignifydLogin.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/Webhooks.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnAdmin.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInCommentsHistory.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAccount.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress/Firstname.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydData.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/OrdersGrid.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/SalesOrderView.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydCases.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydLogin.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydNotifications.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Address.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/ConfigData.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Customer.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydAccount.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydData.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/OpenOrderGridStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCancelOrderStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydFillShippingAddressStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydLoginStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydObserveCaseStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydSetWebhookHandlersStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/UnholdAndCancelOrderStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/di.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/testcase.xml
diff --git a/dev/tests/functional/credentials.xml.dist b/dev/tests/functional/credentials.xml.dist
index 57e24cd59aa08..01e3a35be9a2d 100644
--- a/dev/tests/functional/credentials.xml.dist
+++ b/dev/tests/functional/credentials.xml.dist
@@ -80,4 +80,5 @@
+
diff --git a/dev/tests/functional/etc/repository_replacer_payments.xml b/dev/tests/functional/etc/repository_replacer_payments.xml
index 2b20e7220f537..a0ecca61eb372 100644
--- a/dev/tests/functional/etc/repository_replacer_payments.xml
+++ b/dev/tests/functional/etc/repository_replacer_payments.xml
@@ -21,4 +21,11 @@
AUTHORIZENET_PASSWORD
+
+
+
+ SIGNIFYD_EMAIL
+ SIGNIFYD_PASSWORD
+
+
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
new file mode 100644
index 0000000000000..54f580f48dcf4
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/Grid.php
@@ -0,0 +1,33 @@
+ [
+ '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
new file mode 100644
index 0000000000000..e2b4e6f748977
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/View/FraudProtection.php
@@ -0,0 +1,31 @@
+_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
new file mode 100644
index 0000000000000..5fe6096035803
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseInfo.php
@@ -0,0 +1,245 @@
+_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
new file mode 100644
index 0000000000000..ef292de3a9e5f
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseSearch.php
@@ -0,0 +1,67 @@
+_rootElement->find($this->searchBar)->setValue($customerName);
+ $this->_rootElement->find($this->submitButton)->click();
+ }
+
+ /**
+ * 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
new file mode 100644
index 0000000000000..7f530afe4df63
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/SignifydLogin.php
@@ -0,0 +1,31 @@
+_rootElement->find($this->loginButton)->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
new file mode 100644
index 0000000000000..424d5681c07c6
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/Webhooks.php
@@ -0,0 +1,216 @@
+ '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
new file mode 100644
index 0000000000000..55134b8d94548
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php
@@ -0,0 +1,73 @@
+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
new file mode 100644
index 0000000000000..9fe29f022470f
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnAdmin.php
@@ -0,0 +1,85 @@
+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
new file mode 100644
index 0000000000000..995f5092b6121
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
@@ -0,0 +1,214 @@
+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
new file mode 100644
index 0000000000000..aef5c0e9abd26
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInCommentsHistory.php
@@ -0,0 +1,56 @@
+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
new file mode 100644
index 0000000000000..2f08ac8f40a3e
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
@@ -0,0 +1,50 @@
+ $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
new file mode 100644
index 0000000000000..4b86f66730f90
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
@@ -0,0 +1,57 @@
+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
new file mode 100644
index 0000000000000..8b1455811d003
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAccount.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
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
new file mode 100644
index 0000000000000..02b5cc8211d89
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
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
new file mode 100644
index 0000000000000..9e4930484eef0
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress/Firstname.php
@@ -0,0 +1,46 @@
+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
new file mode 100644
index 0000000000000..23ee2cddf434a
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydData.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
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
new file mode 100644
index 0000000000000..749d91c3ed395
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/OrdersGrid.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
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
new file mode 100644
index 0000000000000..36d77723dfcee
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/SalesOrderView.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
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
new file mode 100644
index 0000000000000..cfe889bb8de44
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydCases.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
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
new file mode 100644
index 0000000000000..5fe5da6d28013
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydLogin.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
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
new file mode 100644
index 0000000000000..dd12f14c28800
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydNotifications.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
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
new file mode 100644
index 0000000000000..a534cbc6107fe
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Address.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+ John%signifyd_isolation%
+ Doe
+ Magento
+ Culver City
+ 6161 West Centinela Avenue
+ 555-55-555-55
+ United States
+ California
+ 90230
+
+
+
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
new file mode 100644
index 0000000000000..2af46f077b304
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/ConfigData.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+ - fraud_protection
+ - 1
+ - Yes
+ - 1
+
+
+ - fraud_protection
+ - 1
+
+ - SIGNIFYD_CONFIG_API_KEY
+
+
+ - fraud_protection
+ - 1
+
+ - https://api.signifyd.com/v2/
+
+
+ - fraud_protection
+ - 1
+ - Yes
+ - 1
+
+
+
+
+ - fraud_protection
+ - 1
+ - Yes
+ - 0
+
+
+
+
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
new file mode 100644
index 0000000000000..b45e3d01b8ec8
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Customer.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ John
+ Doe
+ testapprove@magento.com
+ 123123^q
+ 123123^q
+
+
+ John
+ Doe
+ testdecline@magento.com
+ 123123^q
+ 123123^q
+
+
+
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
new file mode 100644
index 0000000000000..4d3dd5229eae3
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydAccount.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+ SIGNIFYD_EMAIL
+ SIGNIFYD_PASSWORD
+
+
+
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
new file mode 100644
index 0000000000000..5b3be4b9d570a
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydData.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+ autotest
+ Good
+ Approved
+ CVV2 Match (M)
+ Full match (Y)
+ USD 5.00
+
+
+ autotest
+ Bad
+ Declined
+ CVV2 Match (M)
+ Full match (Y)
+ USD 5.00
+
+
+ autotest
+ Bad
+ Declined
+ Unavailable (U)
+ GBP 10.00
+
+
+
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
new file mode 100644
index 0000000000000..1dd742c9f7096
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
@@ -0,0 +1,63 @@
+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
new file mode 100644
index 0000000000000..6391081e5e161
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+ catalogProductSimple::product_100_dollar
+ signifyd_decline_us_customer
+ login
+ Flat Rate
+ Fixed
+ hosted_pro
+
+ - 210.00
+ - GBP
+
+ credit_card_hostedpro
+ visa_hosted_pro
+ false
+ merchant_country_gb, hosted_pro, config_base_currency_gb, signifyd
+ Suspected Fraud
+ signifyd_us_shipping_address
+ sandbox_default
+ signifyd_guarantee_fraudulent
+ Processing
+ test_type:3rd_party_test_single_flow, severity:S2
+
+
+
+
+
+
+
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
new file mode 100644
index 0000000000000..5ca76ff70479f
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
@@ -0,0 +1,62 @@
+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
new file mode 100644
index 0000000000000..404229c2451cd
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+ catalogProductSimple::product_10_dollar
+ login
+ signifyd_approve_us_customer
+ Flat Rate
+ Fixed
+ braintree
+ braintree
+ 15.00
+ USD
+ visa_default
+ braintree
+ braintree,signifyd
+ Processing
+ signifyd_us_shipping_address
+ sandbox_default
+ signifyd_guarantee_approve
+ test_type:3rd_party_test_single_flow, severity:S1
+
+
+
+
+
+
+
+
+
+ catalogProductSimple::product_10_dollar
+ login
+ signifyd_decline_us_customer
+ Flat Rate
+ Fixed
+ braintree
+ braintree
+ 15.00
+ USD
+ visa_default
+ braintree
+ braintree,signifyd
+ On Hold
+ signifyd_us_shipping_address
+ sandbox_default
+ signifyd_guarantee_decline
+ test_type:3rd_party_test_single_flow, severity:S1
+
+
+
+
+
+
+
+
+
+
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
new file mode 100644
index 0000000000000..698861da26018
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
@@ -0,0 +1,63 @@
+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
new file mode 100644
index 0000000000000..5496619fe1bf9
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+ catalogProductSimple::product_100_dollar
+ signifyd_decline_us_customer
+ login
+ Flat Rate
+ Fixed
+ hosted_pro
+
+ - 210.00
+ - GBP
+
+ credit_card_hostedpro
+ visa_hosted_pro
+ false
+ merchant_country_gb, hosted_pro, config_base_currency_gb, signifyd
+ Suspected Fraud
+ Canceled
+ signifyd_us_shipping_address
+ sandbox_default
+ signifyd_guarantee_fraudulent
+ test_type:3rd_party_test_single_flow, severity:S2
+
+
+
+
+
+
+
+
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
new file mode 100644
index 0000000000000..409dffc8340b7
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/OpenOrderGridStep.php
@@ -0,0 +1,173 @@
+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
new file mode 100644
index 0000000000000..54f4dd75223e0
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCancelOrderStep.php
@@ -0,0 +1,105 @@
+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/SignifydFillShippingAddressStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydFillShippingAddressStep.php
new file mode 100644
index 0000000000000..0b1dda1d0a46a
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydFillShippingAddressStep.php
@@ -0,0 +1,70 @@
+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
new file mode 100644
index 0000000000000..3dd1b94d6b505
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydLoginStep.php
@@ -0,0 +1,68 @@
+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
new file mode 100644
index 0000000000000..126e32489e6c9
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydObserveCaseStep.php
@@ -0,0 +1,152 @@
+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();
+ $this->signifydCases->getCaseSearchBlock()
+ ->searchCaseByCustomerName($this->signifydAddress->getFirstname());
+ $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
new file mode 100644
index 0000000000000..2b630b8c1dac8
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydSetWebhookHandlersStep.php
@@ -0,0 +1,64 @@
+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
new file mode 100644
index 0000000000000..0c90b1b76937b
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/UnholdAndCancelOrderStep.php
@@ -0,0 +1,84 @@
+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
new file mode 100644
index 0000000000000..2ba4b6c97d33f
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/di.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+ S1
+
+
+
+
+ S1
+
+
+
+
+ S1
+
+
+
+
+ S1
+
+
+
+
+ S2
+
+
+
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
new file mode 100644
index 0000000000000..cfbd2e6ace2b4
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/testcase.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From c60476efc287c60261d728bf42c4e28ed30e76a9 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Fri, 17 Nov 2017 17:13:23 -0600
Subject: [PATCH 213/225] MAGETWO-72487: Move code to CE
- fix copyright
---
app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php | 2 +-
app/code/Magento/Signifyd/Api/CaseManagementInterface.php | 2 +-
app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php | 2 +-
app/code/Magento/Signifyd/Api/Data/CaseInterface.php | 2 +-
.../Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php | 2 +-
.../Magento/Signifyd/Api/GuaranteeCancelingServiceInterface.php | 2 +-
.../Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php | 2 +-
app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php | 2 +-
.../Signifyd/Block/Adminhtml/System/Config/Field/WebhookUrl.php | 2 +-
.../Signifyd/Block/Adminhtml/System/Config/Fieldset/Info.php | 2 +-
app/code/Magento/Signifyd/Block/Fingerprint.php | 2 +-
app/code/Magento/Signifyd/Controller/Webhooks/Handler.php | 2 +-
app/code/Magento/Signifyd/Model/CaseEntity.php | 2 +-
app/code/Magento/Signifyd/Model/CaseManagement.php | 2 +-
app/code/Magento/Signifyd/Model/CaseRepository.php | 2 +-
.../Magento/Signifyd/Model/CaseServices/CreationService.php | 2 +-
.../Magento/Signifyd/Model/CaseServices/StubUpdatingService.php | 2 +-
.../Magento/Signifyd/Model/CaseServices/UpdatingService.php | 2 +-
.../Signifyd/Model/CaseServices/UpdatingServiceFactory.php | 2 +-
.../Signifyd/Model/CaseServices/UpdatingServiceInterface.php | 2 +-
app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php | 2 +-
app/code/Magento/Signifyd/Model/Config.php | 2 +-
app/code/Magento/Signifyd/Model/CustomerOrders.php | 2 +-
.../Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php | 2 +-
app/code/Magento/Signifyd/Model/Guarantee/CancelingService.php | 2 +-
.../Magento/Signifyd/Model/Guarantee/CreateGuaranteeAbility.php | 2 +-
app/code/Magento/Signifyd/Model/Guarantee/CreationService.php | 2 +-
.../Magento/Signifyd/Model/MessageGenerators/CaseRescore.php | 2 +-
.../Signifyd/Model/MessageGenerators/GeneratorException.php | 2 +-
.../Signifyd/Model/MessageGenerators/GeneratorFactory.php | 2 +-
.../Signifyd/Model/MessageGenerators/GeneratorInterface.php | 2 +-
.../Signifyd/Model/MessageGenerators/PatternGenerator.php | 2 +-
.../Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php | 2 +-
.../Model/PaymentMethodMapper/XmlToArrayConfigConverter.php | 2 +-
app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php | 2 +-
app/code/Magento/Signifyd/Model/PredefinedVerificationCode.php | 2 +-
.../Signifyd/Model/QuoteSession/Adminhtml/BackendSession.php | 2 +-
.../Magento/Signifyd/Model/QuoteSession/FrontendSession.php | 2 +-
.../Signifyd/Model/QuoteSession/QuoteSessionInterface.php | 2 +-
app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity.php | 2 +-
.../Signifyd/Model/ResourceModel/CaseEntity/Collection.php | 2 +-
.../Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php | 2 +-
.../Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php | 2 +-
.../Magento/Signifyd/Model/SignifydGateway/ApiCallException.php | 2 +-
app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php | 2 +-
.../Signifyd/Model/SignifydGateway/Client/HttpClientFactory.php | 2 +-
.../Signifyd/Model/SignifydGateway/Client/RequestBuilder.php | 2 +-
.../Signifyd/Model/SignifydGateway/Client/RequestSender.php | 2 +-
.../Signifyd/Model/SignifydGateway/Client/ResponseHandler.php | 2 +-
.../Signifyd/Model/SignifydGateway/Debugger/BlackHole.php | 2 +-
.../Signifyd/Model/SignifydGateway/Debugger/DebuggerFactory.php | 2 +-
.../Model/SignifydGateway/Debugger/DebuggerInterface.php | 2 +-
.../Magento/Signifyd/Model/SignifydGateway/Debugger/Log.php | 2 +-
app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php | 2 +-
.../Magento/Signifyd/Model/SignifydGateway/GatewayException.php | 2 +-
.../Signifyd/Model/SignifydGateway/Request/AddressBuilder.php | 2 +-
.../Signifyd/Model/SignifydGateway/Request/CardBuilder.php | 2 +-
.../Model/SignifydGateway/Request/ClientVersionBuilder.php | 2 +-
.../Model/SignifydGateway/Request/CreateCaseBuilder.php | 2 +-
.../SignifydGateway/Request/CreateCaseBuilderInterface.php | 2 +-
.../Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php | 2 +-
.../Signifyd/Model/SignifydGateway/Request/RecipientBuilder.php | 2 +-
.../Signifyd/Model/SignifydGateway/Request/SellerBuilder.php | 2 +-
.../Model/SignifydGateway/Request/UserAccountBuilder.php | 2 +-
.../Signifyd/Model/SignifydGateway/Response/WebhookMessage.php | 2 +-
.../Model/SignifydGateway/Response/WebhookMessageReader.php | 2 +-
.../Signifyd/Model/SignifydGateway/Response/WebhookRequest.php | 2 +-
.../Model/SignifydGateway/Response/WebhookRequestValidator.php | 2 +-
app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php | 2 +-
app/code/Magento/Signifyd/Observer/PlaceOrder.php | 2 +-
app/code/Magento/Signifyd/Setup/InstallSchema.php | 2 +-
.../Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php | 2 +-
.../Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php | 2 +-
.../Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php | 2 +-
.../Test/Unit/Model/CaseServices/UpdatingServiceTest.php | 2 +-
.../Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php | 2 +-
.../Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php | 2 +-
.../Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php | 2 +-
.../Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php | 2 +-
.../Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php | 2 +-
.../Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php | 2 +-
.../Test/Unit/Model/MessageGenerators/CaseRescoreTest.php | 2 +-
.../Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php | 2 +-
.../Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php | 2 +-
.../Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php | 2 +-
.../Unit/Model/PaymentMethodMapper/_files/expected_array.php | 2 +-
.../PaymentMethodMapper/_files/signifyd_payment_mapping.xml | 2 +-
.../Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php | 2 +-
.../Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php | 2 +-
.../Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php | 2 +-
.../Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php | 2 +-
.../Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php | 2 +-
.../Model/SignifydGateway/Response/WebhookMessageReaderTest.php | 2 +-
.../SignifydGateway/Response/WebhookRequestValidatorTest.php | 2 +-
.../Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php | 2 +-
app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php | 2 +-
.../Signifyd/Ui/Component/Listing/Column/Guarantee/Options.php | 2 +-
app/code/Magento/Signifyd/etc/acl.xml | 2 +-
app/code/Magento/Signifyd/etc/adminhtml/di.xml | 2 +-
app/code/Magento/Signifyd/etc/adminhtml/routes.xml | 2 +-
app/code/Magento/Signifyd/etc/adminhtml/system.xml | 2 +-
app/code/Magento/Signifyd/etc/config.xml | 2 +-
app/code/Magento/Signifyd/etc/constraints.xml | 2 +-
app/code/Magento/Signifyd/etc/di.xml | 2 +-
app/code/Magento/Signifyd/etc/events.xml | 2 +-
app/code/Magento/Signifyd/etc/frontend/di.xml | 2 +-
app/code/Magento/Signifyd/etc/frontend/routes.xml | 2 +-
app/code/Magento/Signifyd/etc/module.xml | 2 +-
app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml | 2 +-
app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd | 2 +-
app/code/Magento/Signifyd/registration.php | 2 +-
.../Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml | 2 +-
.../Magento/Signifyd/view/adminhtml/templates/case_info.phtml | 2 +-
.../Signifyd/view/adminhtml/ui_component/sales_order_grid.xml | 2 +-
app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js | 2 +-
.../Signifyd/view/frontend/layout/checkout_cart_index.xml | 2 +-
.../Signifyd/view/frontend/layout/checkout_index_index.xml | 2 +-
.../Magento/Signifyd/view/frontend/templates/fingerprint.phtml | 2 +-
118 files changed, 118 insertions(+), 118 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
index 3cf727ee696eb..4664431ead85f 100644
--- a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -1,6 +1,6 @@
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
index 6c4ffaf7c142e..377c83a340a01 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
@@ -1,6 +1,6 @@
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/di.xml b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
index 1c827afa99dbc..c771d67216d43 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/di.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/routes.xml b/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
index 1f94759c1b7b6..0f5ec8f6ef3c4 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/system.xml b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
index e0a5fad5bf334..d9ba2f7ffdff2 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/system.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/config.xml b/app/code/Magento/Signifyd/etc/config.xml
index a02a363358533..804342a14bb08 100644
--- a/app/code/Magento/Signifyd/etc/config.xml
+++ b/app/code/Magento/Signifyd/etc/config.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/constraints.xml b/app/code/Magento/Signifyd/etc/constraints.xml
index 65e3f45035dc2..1c02b42bf11c9 100644
--- a/app/code/Magento/Signifyd/etc/constraints.xml
+++ b/app/code/Magento/Signifyd/etc/constraints.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 551da4f023a56..bd05c8717b7d2 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/events.xml b/app/code/Magento/Signifyd/etc/events.xml
index 9717f3947a9c4..a89b56ddf13c6 100644
--- a/app/code/Magento/Signifyd/etc/events.xml
+++ b/app/code/Magento/Signifyd/etc/events.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/frontend/di.xml b/app/code/Magento/Signifyd/etc/frontend/di.xml
index ceaa02a71e605..6aa887c67578d 100644
--- a/app/code/Magento/Signifyd/etc/frontend/di.xml
+++ b/app/code/Magento/Signifyd/etc/frontend/di.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/frontend/routes.xml b/app/code/Magento/Signifyd/etc/frontend/routes.xml
index a21f612e54bba..5803f59d8624b 100644
--- a/app/code/Magento/Signifyd/etc/frontend/routes.xml
+++ b/app/code/Magento/Signifyd/etc/frontend/routes.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 81d97d6fdc0d4..d5adcba88ad9a 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
index 24f722d9e7246..096a968167173 100644
--- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/registration.php b/app/code/Magento/Signifyd/registration.php
index f3a11ab0a1183..9f35e0bb2f41b 100644
--- a/app/code/Magento/Signifyd/registration.php
+++ b/app/code/Magento/Signifyd/registration.php
@@ -1,6 +1,6 @@
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 07d4bb4f656d7..b706406331f1a 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -1,6 +1,6 @@
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
index 881bb27477800..f55170336ca03 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js
+++ b/app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js
@@ -1,5 +1,5 @@
/**
- * Copyright © 2013-2017 Magento, Inc. All rights reserved.
+ * Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
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
index a9ea616735d56..30472ae5e9ae9 100644
--- a/app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml
+++ b/app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml
@@ -1,7 +1,7 @@
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
index a9ea616735d56..30472ae5e9ae9 100644
--- a/app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml
+++ b/app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
index 425d8c608cfc6..9ceccffa8dc19 100644
--- a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
+++ b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
@@ -1,6 +1,6 @@
Date: Fri, 17 Nov 2017 17:16:46 -0600
Subject: [PATCH 214/225] MAGETWO-72487: Move code to CE
- upgrading Magento2 Project PHPUnit version to latest
- add since annotation in doc block
- resolve some conflicts
---
.../Api/CaseCreationServiceInterface.php | 2 +
.../Signifyd/Api/CaseManagementInterface.php | 3 +
.../Signifyd/Api/CaseRepositoryInterface.php | 10 ++-
.../Signifyd/Api/Data/CaseInterface.php | 23 +++++
.../Api/Data/CaseSearchResultsInterface.php | 3 +
.../GuaranteeCancelingServiceInterface.php | 2 +
.../Api/GuaranteeCreationServiceInterface.php | 2 +
.../Signifyd/Block/Adminhtml/CaseInfo.php | 5 ++
.../Magento/Signifyd/Block/Fingerprint.php | 5 ++
.../Magento/Signifyd/Model/CaseRepository.php | 4 +-
.../Signifyd/Model/CommentsHistoryUpdater.php | 18 +++-
.../Magento/Signifyd/Model/CustomerOrders.php | 4 +-
.../MessageGenerators/GeneratorException.php | 3 +
.../Signifyd/Model/OrderStateService.php | 3 +-
.../Request/PurchaseBuilder.php | 11 ++-
.../Unit/Block/Adminhtml/CaseInfoTest.php | 2 +-
.../Unit/Controller/Webhooks/HandlerTest.php | 4 +-
.../UpdatingServiceFactoryTest.php | 2 +-
.../CaseServices/UpdatingServiceTest.php | 2 +-
.../Unit/Model/CommentsHistoryUpdaterTest.php | 40 +++++----
.../Test/Unit/Model/CustomerOrdersTest.php | 2 +-
.../Guarantee/CancelGuaranteeAbilityTest.php | 2 +-
.../Model/Guarantee/CancelingServiceTest.php | 2 +-
.../Guarantee/CreateGuaranteeAbilityTest.php | 2 +-
.../Model/Guarantee/CreationServiceTest.php | 2 +-
.../MessageGenerators/CaseRescoreTest.php | 3 +-
.../GeneratorFactoryTest.php | 2 +-
.../PatternGeneratorTest.php | 2 +-
.../Test/Unit/Model/OrderStateServiceTest.php | 2 +-
.../XmlToArrayConfigConverterTest.php | 2 +-
.../Model/PaymentVerificationFactoryTest.php | 2 +-
.../SalesOrderGrid/OrderGridUpdaterTest.php | 2 +-
.../Client/HttpClientFactoryTest.php | 2 +-
.../Client/ResponseHandlerTest.php | 3 +-
.../Model/SignifydGateway/GatewayTest.php | 35 +++++---
.../Response/WebhookMessageReaderTest.php | 2 +-
.../Response/WebhookRequestValidatorTest.php | 2 +-
.../Unit/Model/SignifydOrderSessionIdTest.php | 2 +-
.../Test/Unit/Observer/PlaceOrderTest.php | 5 +-
app/code/Magento/Signifyd/composer.json | 28 +++---
.../Magento/Signifyd/etc/adminhtml/routes.xml | 2 +-
app/code/Magento/Signifyd/etc/di.xml | 42 +++++----
app/code/Magento/Signifyd/etc/frontend/di.xml | 7 --
app/code/Magento/Signifyd/i18n/en_US.csv | 88 ++++++++++---------
app/code/Magento/Signifyd/registration.php | 8 +-
.../view/adminhtml/templates/case_info.phtml | 6 +-
.../ui_component/sales_order_grid.xml | 29 +++---
.../view/frontend/templates/fingerprint.phtml | 4 +-
48 files changed, 264 insertions(+), 174 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
index 4664431ead85f..f7611660b93a1 100644
--- a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -12,6 +12,7 @@
* Implementation should send request to Signifyd API and create new entity in Magento.
*
* @api
+ * @since 100.2.0
*/
interface CaseCreationServiceInterface
{
@@ -22,6 +23,7 @@ interface CaseCreationServiceInterface
* @return bool
* @throws \Magento\Framework\Exception\NotFoundException If order does not exists
* @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
+ * @since 100.2.0
*/
public function createForOrder($orderId);
}
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index d12abebe8b98a..69075a308cb96 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -10,6 +10,7 @@
* Allows to performs operations with Signifyd cases.
*
* @api
+ * @since 100.2.0
*/
interface CaseManagementInterface
{
@@ -20,6 +21,7 @@ interface CaseManagementInterface
* @return \Magento\Signifyd\Api\Data\CaseInterface
* @throws \Magento\Framework\Exception\NotFoundException If order does not exists
* @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
+ * @since 100.2.0
*/
public function create($orderId);
@@ -28,6 +30,7 @@ public function create($orderId);
*
* @param int $orderId
* @return \Magento\Signifyd\Api\Data\CaseInterface|null
+ * @since 100.2.0
*/
public function getByOrderId($orderId);
}
diff --git a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
index 2be176ba41111..4f148a082b300 100644
--- a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
@@ -9,6 +9,7 @@
* Signifyd Case repository interface
*
* @api
+ * @since 100.2.0
*/
interface CaseRepositoryInterface
{
@@ -17,6 +18,7 @@ interface CaseRepositoryInterface
*
* @param \Magento\Signifyd\Api\Data\CaseInterface $case
* @return \Magento\Signifyd\Api\Data\CaseInterface
+ * @since 100.2.0
*/
public function save(\Magento\Signifyd\Api\Data\CaseInterface $case);
@@ -25,6 +27,7 @@ public function save(\Magento\Signifyd\Api\Data\CaseInterface $case);
*
* @param int $id
* @return \Magento\Signifyd\Api\Data\CaseInterface
+ * @since 100.2.0
*/
public function getById($id);
@@ -33,6 +36,7 @@ public function getById($id);
*
* @param int $caseId
* @return \Magento\Signifyd\Api\Data\CaseInterface|null
+ * @since 100.2.0
*/
public function getByCaseId($caseId);
@@ -41,14 +45,16 @@ public function getByCaseId($caseId);
*
* @param \Magento\Signifyd\Api\Data\CaseInterface $case
* @return bool
+ * @since 100.2.0
*/
public function delete(\Magento\Signifyd\Api\Data\CaseInterface $case);
/**
* Gets list of case entities.
*
- * @param \Magento\Framework\Api\SearchCriteria $searchCriteria
+ * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
* @return \Magento\Signifyd\Api\Data\CaseSearchResultsInterface
+ * @since 100.2.0
*/
- public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria);
+ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
}
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index a14d81eb18465..eff46b972fc02 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -12,6 +12,7 @@
*
* @api
* @see https://www.signifyd.com/docs/api/#/reference/cases/retrieve-a-case/get-a-case
+ * @since 100.2.0
*/
interface CaseInterface
{
@@ -48,6 +49,7 @@ interface CaseInterface
* Returns local case entity identifier.
*
* @return int
+ * @since 100.2.0
*/
public function getEntityId();
@@ -56,6 +58,7 @@ public function getEntityId();
*
* @param int $id
* @return $this
+ * @since 100.2.0
*/
public function setEntityId($id);
@@ -63,6 +66,7 @@ public function setEntityId($id);
* Returns Signifyd case identifier.
*
* @return int
+ * @since 100.2.0
*/
public function getCaseId();
@@ -71,6 +75,7 @@ public function getCaseId();
*
* @param int $id
* @return $this
+ * @since 100.2.0
*/
public function setCaseId($id);
@@ -79,6 +84,7 @@ public function setCaseId($id);
* Returns null if state of guarantee eligible does not set yet.
*
* @return boolean|null
+ * @since 100.2.0
*/
public function isGuaranteeEligible();
@@ -87,6 +93,7 @@ public function isGuaranteeEligible();
*
* @param bool $guaranteeEligible
* @return $this
+ * @since 100.2.0
*/
public function setGuaranteeEligible($guaranteeEligible);
@@ -94,6 +101,7 @@ public function setGuaranteeEligible($guaranteeEligible);
* Returns decision state of the guarantee.
*
* @return string
+ * @since 100.2.0
*/
public function getGuaranteeDisposition();
@@ -102,6 +110,7 @@ public function getGuaranteeDisposition();
*
* @param string $disposition
* @return $this
+ * @since 100.2.0
*/
public function setGuaranteeDisposition($disposition);
@@ -109,6 +118,7 @@ public function setGuaranteeDisposition($disposition);
* Returns case status.
*
* @return string
+ * @since 100.2.0
*/
public function getStatus();
@@ -117,6 +127,7 @@ public function getStatus();
*
* @param string $status
* @return $this
+ * @since 100.2.0
*/
public function setStatus($status);
@@ -124,6 +135,7 @@ public function setStatus($status);
* Returns value, which indicates the likelihood that the order is fraud.
*
* @return int
+ * @since 100.2.0
*/
public function getScore();
@@ -132,6 +144,7 @@ public function getScore();
*
* @param int $score
* @return $this
+ * @since 100.2.0
*/
public function setScore($score);
@@ -139,6 +152,7 @@ public function setScore($score);
* Get order id for a case.
*
* @return int
+ * @since 100.2.0
*/
public function getOrderId();
@@ -147,6 +161,7 @@ public function getOrderId();
*
* @param int $orderId
* @return $this
+ * @since 100.2.0
*/
public function setOrderId($orderId);
@@ -154,6 +169,7 @@ public function setOrderId($orderId);
* Returns data about a team associated with a case.
*
* @return array
+ * @since 100.2.0
*/
public function getAssociatedTeam();
@@ -162,6 +178,7 @@ public function getAssociatedTeam();
*
* @param array $team
* @return $this
+ * @since 100.2.0
*/
public function setAssociatedTeam(array $team);
@@ -169,6 +186,7 @@ public function setAssociatedTeam(array $team);
* Returns disposition of an agent's opinion after reviewing the case.
*
* @return string
+ * @since 100.2.0
*/
public function getReviewDisposition();
@@ -177,6 +195,7 @@ public function getReviewDisposition();
*
* @param string $disposition
* @return $this
+ * @since 100.2.0
*/
public function setReviewDisposition($disposition);
@@ -184,6 +203,7 @@ public function setReviewDisposition($disposition);
* Returns creation datetime for a case.
*
* @return string
+ * @since 100.2.0
*/
public function getCreatedAt();
@@ -192,6 +212,7 @@ public function getCreatedAt();
*
* @param string $datetime in DATE_ATOM format
* @return $this
+ * @since 100.2.0
*/
public function setCreatedAt($datetime);
@@ -199,6 +220,7 @@ public function setCreatedAt($datetime);
* Returns updating datetime for a case.
*
* @return string
+ * @since 100.2.0
*/
public function getUpdatedAt();
@@ -207,6 +229,7 @@ public function getUpdatedAt();
*
* @param string $datetime in DATE_ATOM format
* @return $this
+ * @since 100.2.0
*/
public function setUpdatedAt($datetime);
}
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
index a0a571613d3b1..78d37841cff69 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
@@ -11,6 +11,7 @@
* Retrieve and set list of case entities.
*
* @api
+ * @since 100.2.0
*/
interface CaseSearchResultsInterface extends SearchResultsInterface
{
@@ -18,6 +19,7 @@ interface CaseSearchResultsInterface extends SearchResultsInterface
* Gets collection of case entities.
*
* @return \Magento\Signifyd\Api\Data\CaseInterface[]
+ * @since 100.2.0
*/
public function getItems();
@@ -26,6 +28,7 @@ public function getItems();
*
* @param \Magento\Signifyd\Api\Data\CaseInterface[] $items
* @return $this
+ * @since 100.2.0
*/
public function setItems(array $items);
}
diff --git a/app/code/Magento/Signifyd/Api/GuaranteeCancelingServiceInterface.php b/app/code/Magento/Signifyd/Api/GuaranteeCancelingServiceInterface.php
index 9c000cecb37ee..41f4753d036a7 100644
--- a/app/code/Magento/Signifyd/Api/GuaranteeCancelingServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/GuaranteeCancelingServiceInterface.php
@@ -12,6 +12,7 @@
* Implementation should send request to Signifyd API and update existing case entity with guarantee information.
*
* @api
+ * @since 100.2.0
*/
interface GuaranteeCancelingServiceInterface
{
@@ -20,6 +21,7 @@ interface GuaranteeCancelingServiceInterface
*
* @param int $orderId
* @return bool
+ * @since 100.2.0
*/
public function cancelForOrder($orderId);
}
diff --git a/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
index 609f3166df0a2..b4502ea861acd 100644
--- a/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
@@ -12,6 +12,7 @@
* Implementation should send request to Signifyd API and update existing case entity with guarantee infromation.
*
* @api
+ * @since 100.2.0
*/
interface GuaranteeCreationServiceInterface
{
@@ -20,6 +21,7 @@ interface GuaranteeCreationServiceInterface
*
* @param int $orderId
* @return bool
+ * @since 100.2.0
*/
public function createForOrder($orderId);
}
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index fe7f810981389..87d09e392e091 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -12,6 +12,9 @@
/**
* Get Signifyd Case Info
+ *
+ * @api
+ * @since 100.2.0
*/
class CaseInfo extends Template
{
@@ -72,6 +75,7 @@ private function getCaseProperty($defaultValue, callable $callback)
* Checks if case is exists for order
*
* @return bool
+ * @since 100.2.0
*/
public function isEmptyCase()
{
@@ -82,6 +86,7 @@ public function isEmptyCase()
* Gets case guarantee disposition status.
*
* @return string
+ * @since 100.2.0
*/
public function getCaseGuaranteeDisposition()
{
diff --git a/app/code/Magento/Signifyd/Block/Fingerprint.php b/app/code/Magento/Signifyd/Block/Fingerprint.php
index dbafd8be2554d..7afa092b3d0da 100644
--- a/app/code/Magento/Signifyd/Block/Fingerprint.php
+++ b/app/code/Magento/Signifyd/Block/Fingerprint.php
@@ -17,7 +17,9 @@
* Signifyd’s device fingerprinting solution uniquely tracks and identifies devices
* used to transact on your site, increasing your protection from fraud.
*
+ * @api
* @see https://www.signifyd.com/docs/api/#/reference/device-fingerprint/create-a-case
+ * @since 100.2.0
*/
class Fingerprint extends Template
{
@@ -38,6 +40,7 @@ class Fingerprint extends Template
/**
* @var string
+ * @since 100.2.0
*/
protected $_template = 'fingerprint.phtml';
@@ -65,6 +68,7 @@ public function __construct(
* Returns a unique Signifyd order session id.
*
* @return string
+ * @since 100.2.0
*/
public function getSignifydOrderSessionId()
{
@@ -77,6 +81,7 @@ public function getSignifydOrderSessionId()
* Checks if module is enabled.
*
* @return boolean
+ * @since 100.2.0
*/
public function isModuleActive()
{
diff --git a/app/code/Magento/Signifyd/Model/CaseRepository.php b/app/code/Magento/Signifyd/Model/CaseRepository.php
index aefed3b52199b..ea3ea3e67aafd 100644
--- a/app/code/Magento/Signifyd/Model/CaseRepository.php
+++ b/app/code/Magento/Signifyd/Model/CaseRepository.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\Api\SearchCriteria;
+use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
@@ -118,7 +118,7 @@ public function delete(CaseInterface $case)
/**
* @inheritdoc
*/
- public function getList(SearchCriteria $searchCriteria)
+ public function getList(SearchCriteriaInterface $searchCriteria)
{
/** @var Collection $collection */
$collection = $this->collectionFactory->create();
diff --git a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
index 0a24c972c4c6b..f473d157efa4a 100644
--- a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
+++ b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
@@ -6,6 +6,7 @@
namespace Magento\Signifyd\Model;
use Magento\Framework\Phrase;
+use Magento\Sales\Api\OrderStatusHistoryRepositoryInterface;
use Magento\Sales\Model\Order\Status\HistoryFactory;
use Magento\Signifyd\Api\Data\CaseInterface;
@@ -19,14 +20,23 @@ class CommentsHistoryUpdater
*/
private $historyFactory;
+ /**
+ * @var OrderStatusHistoryRepositoryInterface
+ */
+ private $historyRepository;
+
/**
* CommentsHistoryUpdater constructor.
*
* @param HistoryFactory $historyFactory
+ * @param OrderStatusHistoryRepositoryInterface $historyRepository
*/
- public function __construct(HistoryFactory $historyFactory)
- {
+ public function __construct(
+ HistoryFactory $historyFactory,
+ OrderStatusHistoryRepositoryInterface $historyRepository
+ ) {
$this->historyFactory = $historyFactory;
+ $this->historyRepository = $historyRepository;
}
/**
@@ -49,7 +59,7 @@ public function addComment(CaseInterface $case, Phrase $message, $status = '')
$history->setParentId($case->getOrderId())
->setComment($message)
->setEntityName('order')
- ->setStatus($status)
- ->save();
+ ->setStatus($status);
+ $this->historyRepository->save($history);
}
}
diff --git a/app/code/Magento/Signifyd/Model/CustomerOrders.php b/app/code/Magento/Signifyd/Model/CustomerOrders.php
index 4cd725d642e97..c326cf06424c0 100644
--- a/app/code/Magento/Signifyd/Model/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/CustomerOrders.php
@@ -81,8 +81,8 @@ public function __construct(
* 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
+ * 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
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php
index 1298a85934350..103cb9fc1e2d3 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php
@@ -9,6 +9,9 @@
/**
* Common exception for Signifyd message generators.
+ *
+ * @api
+ * @since 100.2.0
*/
class GeneratorException extends LocalizedException
{
diff --git a/app/code/Magento/Signifyd/Model/OrderStateService.php b/app/code/Magento/Signifyd/Model/OrderStateService.php
index 47e3c7a4d1f14..2b3f0e155981e 100644
--- a/app/code/Magento/Signifyd/Model/OrderStateService.php
+++ b/app/code/Magento/Signifyd/Model/OrderStateService.php
@@ -55,8 +55,7 @@ public function updateByCase(CaseInterface $case)
{
$orderId = $case->getOrderId();
- switch ($case->getGuaranteeDisposition())
- {
+ switch ($case->getGuaranteeDisposition()) {
case CaseInterface::GUARANTEE_APPROVED:
$this->unHold($orderId);
break;
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 7f1311c90ba42..858ce0f0f3287 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -175,7 +175,16 @@ private function getShippingMethod($shippingDescription)
*/
private function getPaymentGateway($gatewayCode)
{
- return strstr($gatewayCode, 'paypal') === false ? $gatewayCode : 'paypal_account';
+ $payPalCodeList = [
+ 'paypal_express',
+ 'braintree_paypal',
+ 'payflowpro',
+ 'payflow_express',
+ 'payflow_link',
+ 'payflow_advanced',
+ 'hosted_pro',
+ ];
+ return in_array($gatewayCode, $payPalCodeList) ? 'paypal_account' : $gatewayCode;
}
/**
diff --git a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
index 4e23d32b6de67..164cd8018fb69 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
@@ -19,7 +19,7 @@
*
* Class CaseInfoTest
*/
-class CaseInfoTest extends \PHPUnit_Framework_TestCase
+class CaseInfoTest extends \PHPUnit\Framework\TestCase
{
/**
* @var CaseInterface|MockObject
diff --git a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
index 6e17432fa0e4f..1a8cfdc703247 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
@@ -27,7 +27,7 @@
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class HandlerTest extends \PHPUnit_Framework_TestCase
+class HandlerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Handler
@@ -121,7 +121,7 @@ protected function setUp()
$config = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
- ->setMethods(['isDebugModeEnabled'])
+ ->setMethods(['isDebugModeEnabled', 'getByCaseId'])
->getMock();
$config->expects(self::any())
->method('getByCaseId')
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
index f903c1ad0efad..f0184c032b550 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
@@ -18,7 +18,7 @@
/**
* Contains tests for case updating service factory.
*/
-class UpdatingServiceFactoryTest extends \PHPUnit_Framework_TestCase
+class UpdatingServiceFactoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var UpdatingServiceFactory
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index 2dfcc5c7ea862..6eb7e5c37d5fc 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
@@ -19,7 +19,7 @@
/**
* Contains tests with different negative and positive scenarios for case updating service.
*/
-class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
+class UpdatingServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var UpdatingService
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
index 2dc9ad4d2d457..5cbb3d8d93cdd 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
@@ -11,11 +11,12 @@
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
+class CommentsHistoryUpdaterTest extends \PHPUnit\Framework\TestCase
{
/**
* @var int
@@ -52,6 +53,11 @@ class CommentsHistoryUpdaterTest extends \PHPUnit_Framework_TestCase
*/
private $historyEntity;
+ /**
+ * @var OrderStatusHistoryRepositoryInterface|MockObject
+ */
+ private $historyRepository;
+
/**
* @inheritdoc
*/
@@ -61,9 +67,12 @@ protected function setUp()
$this->historyFactory = $this->getMockBuilder(HistoryFactory::class)
->disableOriginalConstructor()
- ->setMethods(['create'])
+ ->setMethods(['create', 'save'])
->getMock();
+ $this->historyRepository = $this->getMockBuilder(OrderStatusHistoryRepositoryInterface::class)
+ ->getMockForAbstractClass();
+
$this->caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
->setMethods(['getOrderId'])
@@ -72,7 +81,8 @@ protected function setUp()
$this->initCommentMock();
$this->updater = $objectManager->getObject(CommentsHistoryUpdater::class, [
- 'historyFactory' => $this->historyFactory
+ 'historyFactory' => $this->historyFactory,
+ 'historyRepository' => $this->historyRepository
]);
}
@@ -88,12 +98,12 @@ public function testAddCommentWithException()
->method('getOrderId')
->willReturn(self::$orderId);
- $this->historyEntity->expects(self::any())
- ->method('setStatus')
+ $this->historyEntity->method('setStatus')
->with('')
->willReturnSelf();
- $this->historyEntity->expects(self::once())
+ $this->historyRepository->expects(self::once())
->method('save')
+ ->with($this->historyEntity)
->willThrowException(new \Exception('Cannot save comment message.'));
$this->updater->addComment($this->caseEntity, __(self::$message));
@@ -110,12 +120,12 @@ public function testAddComment()
->method('getOrderId')
->willReturn(self::$orderId);
- $this->historyEntity->expects(self::any())
- ->method('setStatus')
+ $this->historyEntity->method('setStatus')
->with(self::$status)
->willReturnSelf();
- $this->historyEntity->expects(self::once())
+ $this->historyRepository->expects(self::once())
->method('save')
+ ->with($this->historyEntity)
->willReturnSelf();
$this->updater->addComment($this->caseEntity, __(self::$message), self::$status);
@@ -150,20 +160,16 @@ private function initCommentMock()
->setMethods(['setParentId', 'setComment', 'setEntityName', 'save'])
->getMockForAbstractClass();
- $this->historyFactory->expects(self::any())
- ->method('create')
+ $this->historyFactory->method('create')
->willReturn($this->historyEntity);
- $this->historyEntity->expects(self::any())
- ->method('setParentId')
+ $this->historyEntity->method('setParentId')
->with(self::$orderId)
->willReturnSelf();
- $this->historyEntity->expects(self::any())
- ->method('setComment')
+ $this->historyEntity->method('setComment')
->with(self::$message)
->willReturnSelf();
- $this->historyEntity->expects(self::any())
- ->method('setEntityName')
+ $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
index 67a508be20c0d..02d3b4b9ad7a7 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
@@ -19,7 +19,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CustomerOrdersTest extends \PHPUnit_Framework_TestCase
+class CustomerOrdersTest extends \PHPUnit\Framework\TestCase
{
/**
* @var int
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
index 572bb48f87a46..f7b4e473a0ec8 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
@@ -16,7 +16,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CancelGuaranteeAbilityTest extends \PHPUnit_Framework_TestCase
+class CancelGuaranteeAbilityTest extends \PHPUnit\Framework\TestCase
{
/**
* @var OrderRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php
index 90365d1ec788a..f8f1d4a4522c9 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php
@@ -19,7 +19,7 @@
/**
* Contains test cases for Signifyd guarantee canceling service.
*/
-class CancelingServiceTest extends \PHPUnit_Framework_TestCase
+class CancelingServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var int
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
index cae198d54c618..7ba3ab3eef4f6 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
@@ -17,7 +17,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CreateGuaranteeAbilityTest extends \PHPUnit_Framework_TestCase
+class CreateGuaranteeAbilityTest extends \PHPUnit\Framework\TestCase
{
/**
* @var DateTimeFactory
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
index 0d488949b20d5..a22bfe12222a6 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
@@ -14,7 +14,7 @@
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 \PHPUnit\Framework\TestCase as TestCase;
use Psr\Log\LoggerInterface;
class CreationServiceTest extends TestCase
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 03dc16f3a8251..ba14036cd68d0 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -16,7 +16,7 @@
*
* Class CaseRescoreTest
*/
-class CaseRescoreTest extends \PHPUnit_Framework_TestCase
+class CaseRescoreTest extends \PHPUnit\Framework\TestCase
{
private static $data = [
'caseId' => 100,
@@ -59,7 +59,6 @@ protected function setUp()
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseRepository' => $this->caseRepository
]);
-
}
/**
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
index 8ada5eb71bdb1..50f87df3b694f 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
@@ -15,7 +15,7 @@
/**
* Contains tests for messages generators factory.
*/
-class GeneratorFactoryTest extends \PHPUnit_Framework_TestCase
+class GeneratorFactoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var GeneratorFactory
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
index 1fb060471319f..9d5f71f657a1e 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
@@ -10,7 +10,7 @@
/**
* Contains tests for different variations like empty data, wrong required arguments, or bad placeholders.
*/
-class PatternGeneratorTest extends \PHPUnit_Framework_TestCase
+class PatternGeneratorTest extends \PHPUnit\Framework\TestCase
{
/**
* Checks an exception if generators does not receives required data.
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php
index 1555685b78d32..3a567a79891f8 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php
@@ -13,7 +13,7 @@
use Magento\Signifyd\Model\OrderStateService;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
-class OrderStateServiceTest extends \PHPUnit_Framework_TestCase
+class OrderStateServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var int
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
index bff9401217355..319229e326c4b 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
@@ -9,7 +9,7 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\Config\Dom\ValidationSchemaException;
-class XmlToArrayConfigConverterTest extends \PHPUnit_Framework_TestCase
+class XmlToArrayConfigConverterTest extends \PHPUnit\Framework\TestCase
{
/**
* @var XmlToArrayConfigConverter
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
index 377c83a340a01..b0f9239d43bfa 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
@@ -12,7 +12,7 @@
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Magento\Payment\Gateway\ConfigInterface;
-class PaymentVerificationFactoryTest extends \PHPUnit_Framework_TestCase
+class PaymentVerificationFactoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var PaymentVerificationFactory
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
index 1dedb56f27d44..885c9f018a488 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
@@ -10,7 +10,7 @@
use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
-class OrderGridUpdaterTest extends \PHPUnit_Framework_TestCase
+class OrderGridUpdaterTest extends \PHPUnit\Framework\TestCase
{
/**
* @var GridInterface|MockObject
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
index 89bd0c64efe67..776e8a75b9646 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php
@@ -13,7 +13,7 @@
use Magento\Framework\Json\EncoderInterface;
use \PHPUnit_Framework_MockObject_MockObject as MockObject;
-class HttpClientFactoryTest extends \PHPUnit_Framework_TestCase
+class HttpClientFactoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var string
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
index 10a4ee23bec8a..bf0c6ee238d5f 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php
@@ -12,7 +12,7 @@
use \Zend_Http_Response as Response;
use \PHPUnit_Framework_MockObject_MockObject as MockObject;
-class ResponseHandlerTest extends \PHPUnit_Framework_TestCase
+class ResponseHandlerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var string
@@ -70,7 +70,6 @@ public function setUp()
$this->responseHandler = $this->objectManager->getObject(ResponseHandler::class, [
'dataDecoder' => $this->dataDecoder
]);
-
}
/**
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
index ee59617aad926..f7aa65f842b91 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Signifyd\Test\Unit\Model\SignifydGateway;
-use PHPUnit_Framework_TestCase as TestCase;
+use \PHPUnit\Framework\TestCase as TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
@@ -13,7 +13,7 @@
use Magento\Signifyd\Model\SignifydGateway\ApiClient;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
-class GatewayTest extends TestCase
+class GatewayTest extends \PHPUnit\Framework\TestCase
{
/**
* @var CreateCaseBuilderInterface|MockObject
@@ -61,7 +61,8 @@ public function testCreateCaseForSpecifiedOrder()
->with($this->equalTo($dummyOrderId))
->willReturn([]);
- $this->gateway->createCase($dummyOrderId);
+ $result = $this->gateway->createCase($dummyOrderId);
+ $this->assertEquals(42, $result);
}
public function testCreateCaseCallsValidApiMethod()
@@ -84,7 +85,8 @@ public function testCreateCaseCallsValidApiMethod()
'investigationId' => $dummySignifydInvestigationId
]);
- $this->gateway->createCase($dummyOrderId);
+ $result = $this->gateway->createCase($dummyOrderId);
+ $this->assertEquals(42, $result);
}
public function testCreateCaseNormalFlow()
@@ -119,7 +121,7 @@ public function testCreateCaseWithFailedApiCall()
->method('makeApiCall')
->willThrowException(new ApiCallException($apiCallFailureMessage));
- $this->setExpectedException(
+ $this->expectException(
GatewayException::class,
$apiCallFailureMessage
);
@@ -138,7 +140,7 @@ public function testCreateCaseWithMissedResponseRequiredData()
'someOtherParameter' => 'foo',
]);
- $this->setExpectedException(GatewayException::class);
+ $this->expectException(GatewayException::class);
$this->gateway->createCase($dummyOrderId);
}
@@ -182,7 +184,8 @@ public function testSubmitCaseForGuaranteeCallsValidApiMethod()
'disposition' => $dummyDisposition
]);
- $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $result = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $this->assertEquals('APPROVED', $result);
}
public function testSubmitCaseForGuaranteeWithFailedApiCall()
@@ -194,11 +197,12 @@ public function testSubmitCaseForGuaranteeWithFailedApiCall()
->method('makeApiCall')
->willThrowException(new ApiCallException($apiCallFailureMessage));
- $this->setExpectedException(
+ $this->expectException(
GatewayException::class,
$apiCallFailureMessage
);
- $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $result = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $this->assertEquals('Api call failed', $result);
}
public function testSubmitCaseForGuaranteeReturnsDisposition()
@@ -237,7 +241,7 @@ public function testSubmitCaseForGuaranteeWithMissedDisposition()
'rereviewCount' => $dummyRereviewCount,
]);
- $this->setExpectedException(GatewayException::class);
+ $this->expectException(GatewayException::class);
$this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
}
@@ -252,8 +256,9 @@ public function testSubmitCaseForGuaranteeWithUnexpectedDisposition()
'disposition' => $dummyUnexpectedDisposition,
]);
- $this->setExpectedException(GatewayException::class);
- $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $this->expectException(GatewayException::class);
+ $result = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $this->assertEquals('UNEXPECTED', $result);
}
/**
@@ -270,7 +275,8 @@ public function testSubmitCaseForGuaranteeWithExpectedDisposition($dummyExpected
]);
try {
- $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $result = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $this->assertEquals($dummyExpectedDisposition, $result);
} catch (GatewayException $e) {
$this->fail(sprintf(
'Expected disposition "%s" was not accepted with message "%s"',
@@ -314,7 +320,8 @@ public function testCancelGuaranteeWithUnexpectedDisposition()
->with('/cases/' . $caseId . '/guarantee', 'PUT', ['guaranteeDisposition' => Gateway::GUARANTEE_CANCELED])
->willReturn(['disposition' => Gateway::GUARANTEE_DECLINED]);
- $this->gateway->cancelGuarantee($caseId);
+ $result = $this->gateway->cancelGuarantee($caseId);
+ $this->assertEquals(Gateway::GUARANTEE_CANCELED, $result);
}
public function supportedGuaranteeDispositionsProvider()
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
index 604c9c63c935f..0dfdf4980fb58 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
@@ -14,7 +14,7 @@
/**
* Class WebhookMessageReaderTest
*/
-class WebhookMessageReaderTest extends \PHPUnit_Framework_TestCase
+class WebhookMessageReaderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var WebhookMessageReader
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
index 5a4ab570f655c..5ae6b95a77548 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
@@ -13,7 +13,7 @@
/**
* Class WebhookRequestValidatorTest
*/
-class WebhookRequestValidatorTest extends \PHPUnit_Framework_TestCase
+class WebhookRequestValidatorTest extends \PHPUnit\Framework\TestCase
{
/**
* @var WebhookRequestValidator
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
index 1f8875fa9cbdb..9d3061f240c21 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
@@ -14,7 +14,7 @@
* Class SignifydOrderSessionIdTest tests that SignifydOrderSessionId class dependencies
* follow the contracts.
*/
-class SignifydOrderSessionIdTest extends \PHPUnit_Framework_TestCase
+class SignifydOrderSessionIdTest extends \PHPUnit\Framework\TestCase
{
/**
* @var SignifydOrderSessionId
diff --git a/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php b/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php
index 100fe1052e035..e2870953ec280 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php
@@ -17,7 +17,7 @@
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Log\LoggerInterface;
-class PlaceOrderTest extends \PHPUnit_Framework_TestCase
+class PlaceOrderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Config|MockObject
@@ -160,7 +160,8 @@ public function testExecuteWithFailedCaseCreation()
$this->logger->method('error')
->with(self::equalTo($exceptionMessage));
- $this->placeOrder->execute($this->observer);
+ $result = $this->placeOrder->execute($this->observer);
+ $this->assertNull($result);
}
/**
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index e298e61dfc6a3..94731b78cbdbf 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -1,23 +1,27 @@
{
"name": "magento/module-signifyd",
"description": "Submitting Case Entry to Signifyd on Order Creation",
+ "config": {
+ "sort-packages": true
+ },
"require": {
- "php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
- "magento/module-config": "100.2.*",
- "magento/framework": "100.2.*",
- "magento/module-sales": "100.2.*",
- "magento/module-store": "100.2.*",
- "magento/module-customer": "100.2.*",
- "magento/module-directory": "100.2.*",
- "magento/module-checkout": "100.2.*",
- "magento/module-backend": "100.2.*",
- "magento/module-payment": "100.2.*"
+ "magento/framework": "100.3.*",
+ "magento/module-backend": "100.3.*",
+ "magento/module-checkout": "100.3.*",
+ "magento/module-config": "100.3.*",
+ "magento/module-customer": "100.3.*",
+ "magento/module-directory": "100.3.*",
+ "magento/module-payment": "100.3.*",
+ "magento/module-sales": "100.3.*",
+ "magento/module-store": "100.3.*",
+ "php": "7.0.2|7.0.4|~7.0.6|~7.1.0"
},
"suggest": {
- "magento/module-scalable-oms": "100.2.*"
+ "magento/module-config": "100.3.*",
+ "magento/module-scalable-oms": "100.3.*"
},
"type": "magento2-module",
- "version": "100.2.0-dev",
+ "version": "100.3.0-dev",
"license": [
"proprietary"
],
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/routes.xml b/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
index 0f5ec8f6ef3c4..c078ab3c8c4c1 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index bd05c8717b7d2..c32fd4352bb10 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -14,6 +14,21 @@
+
+
+
+ U
+
+
+
+
+
+
+ Magento\Payment\Gateway\Config\Config
+ SignifydAvsDefaultMapper
+ SignifydCvvDefaultMapper
+
+
Magento\Sales\Model\ResourceModel\Order\Grid
@@ -55,21 +70,6 @@
-
-
-
- U
-
-
-
-
-
-
- Magento\Payment\Gateway\Config\Config
- SignifydAvsDefaultMapper
- SignifydCvvDefaultMapper
-
-
sales
@@ -106,6 +106,18 @@
PaymentMethodConfigData
+
+
+
+ - 1
+ - 1
+
+
+ - 1
+ - 1
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/frontend/di.xml b/app/code/Magento/Signifyd/etc/frontend/di.xml
index 6aa887c67578d..08a690d1a9930 100644
--- a/app/code/Magento/Signifyd/etc/frontend/di.xml
+++ b/app/code/Magento/Signifyd/etc/frontend/di.xml
@@ -6,12 +6,5 @@
*/
-->
-
-
-
- - Magento\Signifyd\Model\Ui\ConfigProvider
-
-
-
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index 474efd51d03fe..40772188dac9e 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -1,44 +1,46 @@
-"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"
-"Case Update: Case Review was completed. Review Deposition is %1.","Case Update: Case Review was completed. Review Deposition is %1."
-"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."
-"Signifyd Case %1 has been created for order.","Signifyd Case %1 has been created for order."
-"The "%1" should not be empty.","The "%1" should not be empty."
-"Case entity not found.","Case entity not found."
-"Cannot update Case entity.","Cannot update Case entity."
-"Order has been submitted for Guarantee.","Order has been submitted for Guarantee."
-"Sorry, we cannot submit order for Guarantee.","Sorry, we cannot submit order for Guarantee."
-"Order id is required.","Order id is required."
+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."
-"Guarantee has been cancelled for your order.","Guarantee has been cancelled for your order."
-"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
-"Not empty value for "%1" node is required.","Not empty value for "%1" node is required."
-"Only single entrance of "%1" node is required.","Only single entrance of "%1" node is required."
-"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.
- Benefits:
- Grow your business without fear of fraud
- Accept more orders and maximize your revenue
- Automate order review and shift fraud off your plate
","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.
- Benefits:
- Grow your business without fear of fraud
- Accept more orders and maximize your revenue
- Automate order review and shift fraud off your plate "
-"View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com ","View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com "
-"Your API key can be found on the settings page in the Signifyd console","Your API key can be found on the settings page in the Signifyd console"
-"Don’t change unless asked to do so.","Don’t change unless asked to do so."
-"Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento.","Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento."
-"Signifyd Guarantee Decision","Signifyd Guarantee Decision"
\ No newline at end of file
+"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
index 9f35e0bb2f41b..72b11f7eac214 100644
--- a/app/code/Magento/Signifyd/registration.php
+++ b/app/code/Magento/Signifyd/registration.php
@@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/
-\Magento\Framework\Component\ComponentRegistrar::register(
- \Magento\Framework\Component\ComponentRegistrar::MODULE,
- 'Magento_Signifyd',
- __DIR__
-);
+use \Magento\Framework\Component\ComponentRegistrar;
+
+ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_Signifyd', __DIR__);
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index b706406331f1a..a42b7f93b5b92 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -15,7 +15,7 @@
?>
- escapeHtml(__('Fraud Protection Information')); ?>
+ = $block->escapeHtml(__('Fraud Protection Information')) ?>
@@ -23,8 +23,8 @@
- escapeHtml(__('Signifyd Guarantee Decision')); ?>
- escapeHtml($block->getCaseGuaranteeDisposition()); ?>
+ = $block->escapeHtml(__('Signifyd Guarantee Decision')) ?>
+ = $block->escapeHtml($block->getCaseGuaranteeDisposition()) ?>
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
index 21195adcc8bcf..91053d617f31f 100644
--- 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
@@ -1,23 +1,20 @@
+ ~ /**
+ ~ * Copyright © Magento, Inc. All rights reserved.
+ ~ * See COPYING.txt for license details.
+ ~ */
+ -->
-
-
- - Magento\Signifyd\Ui\Component\Listing\Column\Guarantee\Options
- -
-
- true
- - select
- - Magento_Ui/js/grid/columns/select
- - select
- - Signifyd Guarantee Decision
-
-
+
+
+ select
+
+ true
+ select
+ Signifyd Guarantee Decision
+
diff --git a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
index 9ceccffa8dc19..356bab9c62ded 100644
--- a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
+++ b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
@@ -12,7 +12,7 @@
-
\ No newline at end of file
+
From efd1ce969bc5b7c9ea983db98342f746f050ef05 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Fri, 17 Nov 2017 17:21:12 -0600
Subject: [PATCH 215/225] MAGETWO-72487: Move code to CE
- fix copyright
---
.../testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php | 2 +-
.../testsuite/Magento/Signifyd/Block/FingerprintTest.php | 2 +-
.../Magento/Signifyd/Controller/Webhooks/HandlerTest.php | 2 +-
.../testsuite/Magento/Signifyd/Model/CaseManagementTest.php | 2 +-
.../testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php | 2 +-
.../Magento/Signifyd/Model/CaseServices/CreationServiceTest.php | 2 +-
.../Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php | 2 +-
.../Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php | 2 +-
.../Magento/Signifyd/Model/Guarantee/CreationServiceTest.php | 2 +-
.../Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 2 +-
.../testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php | 2 +-
.../testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php | 2 +-
.../testsuite/Magento/Signifyd/_files/approved_case.php | 2 +-
.../integration/testsuite/Magento/Signifyd/_files/case.php | 2 +-
.../integration/testsuite/Magento/Signifyd/_files/customer.php | 2 +-
.../testsuite/Magento/Signifyd/_files/multiple_cases.php | 2 +-
.../_files/order_with_customer_and_two_simple_products.php | 2 +-
.../Signifyd/_files/order_with_guest_and_virtual_product.php | 2 +-
.../integration/testsuite/Magento/Signifyd/_files/store.php | 2 +-
19 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index 48b2b33513a6a..60fa3e7c65e44 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -1,6 +1,6 @@
Date: Fri, 17 Nov 2017 17:22:25 -0600
Subject: [PATCH 216/225] MAGETWO-72487: Move code to CE
- upgrading Magento2 Project PHPUnit version to latest
- resolve some conflicts
---
.../Signifyd/Block/Adminhtml/CaseInfoTest.php | 10 ++--
.../Signifyd/Block/FingerprintTest.php | 6 +-
.../Controller/Webhooks/HandlerTest.php | 24 ++++----
.../Signifyd/Model/CaseManagementTest.php | 27 +++------
.../Signifyd/Model/CaseRepositoryTest.php | 18 +++---
.../CaseServices/CreationServiceTest.php | 59 ++++++++-----------
.../CaseServices/UpdatingServiceTest.php | 37 ++++++------
.../Model/Guarantee/CancelingServiceTest.php | 10 ++--
.../Model/Guarantee/CreationServiceTest.php | 10 ++--
.../Request/CreateCaseBuilderTest.php | 4 +-
.../Signifyd/Observer/PlaceOrderTest.php | 15 +----
.../Signifyd/Plugin/CancelOrderTest.php | 15 +----
.../Signifyd/Plugin/DenyPaymentTest.php | 15 +----
..._with_customer_and_two_simple_products.php | 1 -
14 files changed, 102 insertions(+), 149 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index 60fa3e7c65e44..71a0d5715d1aa 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -12,7 +12,7 @@
use Magento\Sales\Model\Order;
use Magento\TestFramework\Helper\Bootstrap;
-class CaseInfoTest extends \PHPUnit_Framework_TestCase
+class CaseInfoTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManagerInterface
@@ -51,7 +51,7 @@ public function testModuleIsInactive()
{
$this->order->loadByIncrementId('100000001');
- static::assertNotEmpty($this->getBlock()->toHtml());
+ self::assertNotEmpty($this->getBlock()->toHtml());
}
/**
@@ -67,7 +67,7 @@ public function testCaseEntityNotExists()
{
$this->order->loadByIncrementId('100000001');
- static::assertEmpty($this->getBlock()->toHtml());
+ self::assertEmpty($this->getBlock()->toHtml());
}
/**
@@ -85,8 +85,8 @@ public function testCaseEntityExists()
$this->order->loadByIncrementId('100000001');
$block = $this->getBlock();
- static::assertNotEmpty($block->toHtml());
- static::assertContains((string) $block->getCaseGuaranteeDisposition(), $block->toHtml());
+ self::assertNotEmpty($block->toHtml());
+ self::assertContains((string) $block->getCaseGuaranteeDisposition(), $block->toHtml());
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
index aa31e1f65d34d..1efbb8b6d33e4 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
@@ -10,7 +10,7 @@
use Magento\Framework\View\LayoutInterface;
use Magento\TestFramework\Helper\Bootstrap;
-class FingerprintTest extends \PHPUnit_Framework_TestCase
+class FingerprintTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
@@ -35,7 +35,7 @@ protected function setUp()
*/
public function testSessionIdPresent()
{
- static::assertContains('data-order-session-id', $this->getBlockContents());
+ self::assertContains('data-order-session-id', $this->getBlockContents());
}
/**
@@ -45,7 +45,7 @@ public function testSessionIdPresent()
*/
public function testBlockEmpty()
{
- static::assertEmpty($this->getBlockContents());
+ self::assertEmpty($this->getBlockContents());
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
index a0802e3fdcb5d..667cb079f9096 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
@@ -45,25 +45,25 @@ public function testExecuteSuccess()
$caseEntity = $caseRepository->getByCaseId($caseId);
$orderEntityId = $caseEntity->getOrderId();
- static::assertNotEmpty($caseEntity);
- static::assertEquals('2017-01-06 12:47:03', $caseEntity->getCreatedAt());
- static::assertEquals('2017-01-06 12:47:03', $caseEntity->getUpdatedAt());
- static::assertEquals('Magento', $caseEntity->getAssociatedTeam()['teamName']);
- static::assertEquals(true, $caseEntity->isGuaranteeEligible());
- static::assertEquals(CaseInterface::STATUS_OPEN, $caseEntity->getStatus());
- static::assertEquals($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();
- static::assertNotEmpty($histories);
+ self::assertNotEmpty($histories);
/** @var OrderStatusHistoryInterface $caseCreationComment */
$caseComment = array_pop($histories);
- static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseComment);
+ self::assertInstanceOf(OrderStatusHistoryInterface::class, $caseComment);
- static::assertEquals(
+ self::assertEquals(
"Case Update: New score for the order is 384. Previous score was 553.",
$caseComment->getComment()
);
@@ -90,7 +90,7 @@ public function testExecuteTestSuccess()
/**
* Returns mocked WebhookRequest
*
- * @return WebhookRequest|\PHPUnit_Framework_MockObject_MockObject
+ * @return WebhookRequest|\PHPUnit\Framework\MockObject_MockObject
*/
private function getWebhookRequest()
{
@@ -113,7 +113,7 @@ private function getWebhookRequest()
/**
* Returns mocked test WebhookRequest
*
- * @return WebhookRequest|\PHPUnit_Framework_MockObject_MockObject
+ * @return WebhookRequest|\PHPUnit\Framework\MockObject_MockObject
*/
private function getTestWebhookRequest()
{
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
index 217b54621f26d..30603baf867ff 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\ObjectManager;
use Magento\Sales\Api\Data\OrderInterface;
@@ -16,7 +15,7 @@
/**
* Contains test methods for case management service
*/
-class CaseManagementTest extends \PHPUnit_Framework_TestCase
+class CaseManagementTest extends \PHPUnit\Framework\TestCase
{
/**
* @var CaseManagement
@@ -43,9 +42,9 @@ public function testCreate()
$order = $this->getOrder();
$case = $this->caseManagement->create($order->getEntityId());
- static::assertNotEmpty($case->getEntityId());
- static::assertEquals(CaseInterface::STATUS_PENDING, $case->getStatus());
- static::assertEquals(CaseInterface::GUARANTEE_PENDING, $case->getGuaranteeDisposition());
+ self::assertNotEmpty($case->getEntityId());
+ self::assertEquals(CaseInterface::STATUS_PENDING, $case->getStatus());
+ self::assertEquals(CaseInterface::GUARANTEE_PENDING, $case->getGuaranteeDisposition());
}
/**
@@ -57,10 +56,10 @@ public function testGetByOrderId()
$order = $this->getOrder();
$case = $this->caseManagement->getByOrderId($order->getEntityId());
- static::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus());
- static::assertEquals(CaseInterface::DISPOSITION_GOOD, $case->getReviewDisposition());
- static::assertEquals('2016-12-12 15:17:17', $case->getCreatedAt());
- static::assertEquals('2016-12-12 19:23:16', $case->getUpdatedAt());
+ 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());
}
/**
@@ -69,17 +68,9 @@ public function testGetByOrderId()
*/
private function getOrder()
{
- /** @var FilterBuilder $filterBuilder */
- $filterBuilder = $this->objectManager->get(FilterBuilder::class);
- $filters = [
- $filterBuilder->setField(OrderInterface::INCREMENT_ID)
- ->setValue('100000001')
- ->create()
- ];
-
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
- $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001')
->create();
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php
index 44972b6094ef0..ca98a20b15bec 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php
@@ -14,7 +14,7 @@
/**
* Testing case repository
*/
-class CaseRepositoryTest extends \PHPUnit_Framework_TestCase
+class CaseRepositoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
@@ -65,7 +65,7 @@ public function testDelete()
$case = array_pop($cases);
$this->repository->delete($case);
- static::assertEmpty($this->repository->getList($searchCriteria)->getItems());
+ self::assertEmpty($this->repository->getList($searchCriteria)->getItems());
}
/**
@@ -87,9 +87,9 @@ public function testGetById()
$found = $this->repository->getById($case->getEntityId());
- static::assertNotEmpty($found->getEntityId());
- static::assertEquals($case->getEntityId(), $found->getEntityId());
- static::assertEquals($case->getOrderId(), $found->getOrderId());
+ self::assertNotEmpty($found->getEntityId());
+ self::assertEquals($case->getEntityId(), $found->getEntityId());
+ self::assertEquals($case->getOrderId(), $found->getOrderId());
}
/**
@@ -116,11 +116,11 @@ public function testGetListDateInterval()
$items = $this->repository->getList($searchCriteria)
->getItems();
- static::assertCount(3, $items);
+ self::assertCount(3, $items);
for ($i = 1; $i < 4; $i ++) {
$current = array_shift($items);
- static::assertEquals($i, $current->getCaseId());
+ self::assertEquals($i, $current->getCaseId());
}
}
@@ -140,9 +140,9 @@ public function testGetListStatusProcessing()
$items = $this->repository->getList($searchCriteria)
->getItems();
- static::assertCount(1, $items);
+ self::assertCount(1, $items);
$case = array_pop($items);
- static::assertEquals(123, $case->getCaseId());
+ 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
index 0fd303b644141..6cf1e0bfddc9a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
@@ -5,20 +5,20 @@
*/
namespace Magento\Signifyd\Model\CaseServices;
-use Magento\Framework\Api\FilterBuilder;
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 PHPUnit\Framework\MockObject_MockObject as MockObject;
use Psr\Log\LoggerInterface;
/**
@@ -26,7 +26,7 @@
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CreationServiceTest extends \PHPUnit_Framework_TestCase
+class CreationServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
@@ -98,16 +98,16 @@ public function testCreateForOrderWithEmptyResponse()
$order = $this->getOrder();
$exceptionMessage = 'Response is not valid JSON: Decoding failed: Syntax error';
- $this->requestBuilder->expects(static::once())
+ $this->requestBuilder->expects(self::once())
->method('doRequest')
->willThrowException(new ApiCallException($exceptionMessage));
- $this->logger->expects(static::once())
+ $this->logger->expects(self::once())
->method('error')
->with($exceptionMessage);
$result = $this->service->createForOrder($order->getEntityId());
- static::assertTrue($result);
+ self::assertTrue($result);
}
/**
@@ -124,16 +124,16 @@ public function testCreateForOrderWithBadResponse()
];
$exceptionMessage = 'Bad Request - The request could not be parsed. Response: ' . json_encode($responseData);
- $this->requestBuilder->expects(static::once())
+ $this->requestBuilder->expects(self::once())
->method('doRequest')
->willThrowException(new ApiCallException($exceptionMessage));
- $this->logger->expects(static::once())
+ $this->logger->expects(self::once())
->method('error')
->with($exceptionMessage);
$result = $this->service->createForOrder($order->getEntityId());
- static::assertTrue($result);
+ self::assertTrue($result);
}
/**
@@ -144,16 +144,16 @@ public function testCreateOrderWithEmptyInvestigationId()
{
$order = $this->getOrder();
- $this->requestBuilder->expects(static::once())
+ $this->requestBuilder->expects(self::once())
->method('doRequest')
->willReturn([]);
- $this->logger->expects(static::once())
+ $this->logger->expects(self::once())
->method('error')
->with('Expected field "investigationId" missed.');
$result = $this->service->createForOrder($order->getEntityId());
- static::assertTrue($result);
+ self::assertTrue($result);
}
/**
@@ -164,24 +164,24 @@ public function testCreateForOrder()
{
$order = $this->getOrder();
- $this->requestBuilder->expects(static::once())
+ $this->requestBuilder->expects(self::once())
->method('doRequest')
->willReturn(['investigationId' => 123123]);
- $this->logger->expects(static::never())
+ $this->logger->expects(self::never())
->method('error');
$result = $this->service->createForOrder($order->getEntityId());
- static::assertTrue($result);
+ self::assertTrue($result);
/** @var CaseRepositoryInterface $caseRepository */
$caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
$caseEntity = $caseRepository->getByCaseId(123123);
$gridGuarantyStatus = $this->getOrderGridGuarantyStatus($caseEntity->getOrderId());
- static::assertNotEmpty($caseEntity);
- static::assertEquals($order->getEntityId(), $caseEntity->getOrderId());
- static::assertEquals(
+ 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'
@@ -190,15 +190,15 @@ public function testCreateForOrder()
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($caseEntity->getOrderId());
- static::assertEquals(Order::STATE_HOLDED, $order->getState());
+ self::assertEquals(Order::STATE_HOLDED, $order->getState());
$histories = $order->getStatusHistories();
- static::assertNotEmpty($histories);
+ self::assertNotEmpty($histories);
/** @var OrderStatusHistoryInterface $orderHoldComment */
$orderHoldComment = array_pop($histories);
- static::assertInstanceOf(OrderStatusHistoryInterface::class, $orderHoldComment);
- static::assertEquals("Awaiting the Signifyd guarantee disposition.", $orderHoldComment->getComment());
+ self::assertInstanceOf(OrderStatusHistoryInterface::class, $orderHoldComment);
+ self::assertEquals("Awaiting the Signifyd guarantee disposition.", $orderHoldComment->getComment());
}
/**
@@ -209,17 +209,10 @@ public function testCreateForOrder()
private function getOrder()
{
if ($this->order === null) {
- /** @var FilterBuilder $filterBuilder */
- $filterBuilder = $this->objectManager->get(FilterBuilder::class);
- $filters = [
- $filterBuilder->setField(OrderInterface::INCREMENT_ID)
- ->setValue('100000001')
- ->create()
- ];
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
- $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001')
->create();
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
@@ -240,10 +233,8 @@ private function getOrder()
*/
private function getOrderGridGuarantyStatus($orderEntityId)
{
- /** @var \Magento\Sales\Model\ResourceModel\Order\Grid\Collection $orderGridCollection */
- $orderGridCollection = $this->objectManager->get(
- \Magento\Sales\Model\ResourceModel\Order\Grid\Collection::class
- );
+ /** @var Collection $orderGridCollection */
+ $orderGridCollection = $this->objectManager->get(Collection::class);
$items = $orderGridCollection->addFilter($orderGridCollection->getIdFieldName(), $orderEntityId)
->getItems();
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
index cffcc4a456578..50e510ca072be 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
@@ -9,6 +9,7 @@
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;
@@ -17,7 +18,7 @@
/**
* Contains tests for case entity updating service.
*/
-class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
+class UpdatingServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
@@ -82,14 +83,14 @@ public function testUpdate()
$orderEntityId = $caseEntity->getOrderId();
$gridGuarantyStatus = $this->getOrderGridGuarantyStatus($orderEntityId);
- static::assertNotEmpty($caseEntity);
- static::assertEquals('2017-01-05 22:23:26', $caseEntity->getCreatedAt());
- static::assertEquals(CaseInterface::GUARANTEE_APPROVED, $caseEntity->getGuaranteeDisposition());
- static::assertEquals('AnyTeam', $caseEntity->getAssociatedTeam()['teamName']);
- static::assertEquals(true, $caseEntity->isGuaranteeEligible());
- static::assertEquals(CaseInterface::STATUS_PROCESSING, $caseEntity->getStatus());
- static::assertEquals($orderEntityId, $caseEntity->getOrderId());
- static::assertEquals(
+ 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'
@@ -98,14 +99,14 @@ public function testUpdate()
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($caseEntity->getOrderId());
- static::assertEquals(Order::STATE_PROCESSING, $order->getState());
+ self::assertEquals(Order::STATE_PROCESSING, $order->getState());
$histories = $order->getStatusHistories();
- static::assertNotEmpty($histories);
+ self::assertNotEmpty($histories);
/** @var OrderStatusHistoryInterface $caseCreationComment */
$caseCreationComment = array_pop($histories);
- static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
- static::assertEquals("Signifyd Case $caseId has been created for order.", $caseCreationComment->getComment());
+ self::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
+ self::assertEquals("Signifyd Case $caseId has been created for order.", $caseCreationComment->getComment());
}
/**
@@ -133,7 +134,7 @@ public function testOrderStateAfterDeclinedGuaranteeDisposition()
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($caseEntity->getOrderId());
- static::assertEquals(Order::STATE_HOLDED, $order->getState());
+ self::assertEquals(Order::STATE_HOLDED, $order->getState());
}
/**
@@ -162,7 +163,7 @@ public function testOrderStateAfterWebhookWithoutGuaranteeDisposition()
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($caseEntity->getOrderId());
- static::assertEquals(Order::STATE_PROCESSING, $order->getState());
+ self::assertEquals(Order::STATE_PROCESSING, $order->getState());
}
/**
@@ -173,10 +174,8 @@ public function testOrderStateAfterWebhookWithoutGuaranteeDisposition()
*/
private function getOrderGridGuarantyStatus($orderEntityId)
{
- /** @var \Magento\Sales\Model\ResourceModel\Order\Grid\Collection $orderGridCollection */
- $orderGridCollection = $this->objectManager->get(
- \Magento\Sales\Model\ResourceModel\Order\Grid\Collection::class
- );
+ /** @var Collection $orderGridCollection */
+ $orderGridCollection = $this->objectManager->get(Collection::class);
$items = $orderGridCollection->addFilter($orderGridCollection->getIdFieldName(), $orderEntityId)
->getItems();
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
index dcd39e02d0f06..2cc7a9a1f240a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
@@ -13,13 +13,13 @@
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 PHPUnit\Framework\MockObject_MockObject as MockObject;
use Psr\Log\LoggerInterface;
/**
* Contains test cases for canceling Signifyd guarantee flow.
*/
-class CancelingServiceTest extends \PHPUnit_Framework_TestCase
+class CancelingServiceTest extends \PHPUnit\Framework\TestCase
{
private static $caseId = 123;
@@ -148,11 +148,11 @@ public function testCancelForOrder()
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($updatedCase->getOrderId());
$histories = $order->getStatusHistories();
- static::assertNotEmpty($histories);
+ self::assertNotEmpty($histories);
/** @var OrderStatusHistoryInterface $caseCreationComment */
$caseCreationComment = array_pop($histories);
- static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
- static::assertEquals('Case Update: Case guarantee has been cancelled.', $caseCreationComment->getComment());
+ 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
index 66008cdee39e5..157e3270648b3 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -13,13 +13,13 @@
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 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
+class CreationServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var CreationService
@@ -133,12 +133,12 @@ public function testCreate()
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($updatedCase->getOrderId());
$histories = $order->getStatusHistories();
- static::assertNotEmpty($histories);
+ self::assertNotEmpty($histories);
/** @var OrderStatusHistoryInterface $caseCreationComment */
$caseCreationComment = array_pop($histories);
- static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
- static::assertEquals('Case Update: Case is submitted for guarantee.', $caseCreationComment->getComment());
+ self::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
+ self::assertEquals('Case Update: Case is submitted for guarantee.', $caseCreationComment->getComment());
}
/**
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
index aa9cde598445e..7e7e20c873948 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -20,7 +20,7 @@
* @magentoAppIsolation enabled
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CreateCaseBuilderTest extends \PHPUnit_Framework_TestCase
+class CreateCaseBuilderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManagerInterface
@@ -62,7 +62,7 @@ public function testCreateCaseBuilderWithFullSetOfData()
/** @var Order $order */
$order = $this->objectManager->create(Order::class);
$order->loadByIncrementId('100000001');
-
+
$orderItems = $order->getAllItems();
$product = $orderItems[0]->getProduct();
$payment = $order->getPayment();
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php
index 5e80d4f4138c2..d4204314453e5 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Observer;
-use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Event;
@@ -14,10 +13,10 @@
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\TestFramework\Helper\Bootstrap;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject_MockObject as MockObject;
use Psr\Log\LoggerInterface;
-class PlaceOrderTest extends \PHPUnit_Framework_TestCase
+class PlaceOrderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var CaseCreationServiceInterface|MockObject
@@ -157,17 +156,9 @@ public function testExecuteWithMultipleOrders()
*/
private function getOrder($incrementId)
{
- /** @var FilterBuilder $filterBuilder */
- $filterBuilder = $this->objectManager->get(FilterBuilder::class);
- $filters = [
- $filterBuilder->setField(OrderInterface::INCREMENT_ID)
- ->setValue($incrementId)
- ->create()
- ];
-
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
- $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, $incrementId)
->create();
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php
index f58ae5d52b1ba..7c1af95bdb89c 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Plugin;
-use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderManagementInterface;
@@ -15,9 +14,9 @@
use Magento\Signifyd\Model\SignifydGateway\ApiClient;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\ObjectManager;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject_MockObject as MockObject;
-class CancelOrderTest extends \PHPUnit_Framework_TestCase
+class CancelOrderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var int
@@ -100,17 +99,9 @@ public function testAfterCancel()
*/
private function getOrder()
{
- /** @var FilterBuilder $filterBuilder */
- $filterBuilder = $this->objectManager->get(FilterBuilder::class);
- $filters = [
- $filterBuilder->setField(OrderInterface::INCREMENT_ID)
- ->setValue('100000001')
- ->create()
- ];
-
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
- $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001')
->create();
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php
index ff7e30046c338..72da71a630dff 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Plugin;
-use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Registry;
use Magento\Payment\Model\Info as PaymentInfo;
@@ -22,12 +21,12 @@
use Magento\Signifyd\Model\SignifydGateway\ApiClient;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\ObjectManager;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject_MockObject as MockObject;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class DenyPaymentTest extends \PHPUnit_Framework_TestCase
+class DenyPaymentTest extends \PHPUnit\Framework\TestCase
{
/**
* @var int
@@ -119,17 +118,9 @@ public function testAfterDenyPayment()
*/
private function getOrder()
{
- /** @var FilterBuilder $filterBuilder */
- $filterBuilder = $this->objectManager->get(FilterBuilder::class);
- $filters = [
- $filterBuilder->setField(OrderInterface::INCREMENT_ID)
- ->setValue('100000001')
- ->create()
- ];
-
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
- $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001')
->create();
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
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
index f8532faf27886..49a0a2d33e236 100644
--- 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
@@ -16,7 +16,6 @@
$addressData = include __DIR__ . '/../../../Magento/Sales/_files/address_data.php';
-
$objectManager = Bootstrap::getObjectManager();
$billingAddress = $objectManager->create(Address::class, ['data' => $addressData]);
From 0f26719ec9816ff0fbf62475629982b23e2750bf Mon Sep 17 00:00:00 2001
From: Joan He
Date: Mon, 20 Nov 2017 11:01:25 -0600
Subject: [PATCH 217/225] MAGETWO-72487: Move code to CE
- update composer.lock
---
composer.lock | 341 +++++++++++++++++++++++++-------------------------
1 file changed, 171 insertions(+), 170 deletions(-)
diff --git a/composer.lock b/composer.lock
index 4a58df269a08e..c185c3759263b 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "content-hash": "9ee72dee95c04c48bc83a7334d8ccdf6",
+ "hash": "ae10df09bffedb7e1a02a974635a41d1",
+ "content-hash": "c80ea1a19bce9435f2acc7f9fc526e04",
"packages": [
{
"name": "braintree/braintree_php",
@@ -51,7 +52,7 @@
}
],
"description": "Braintree PHP Client Library",
- "time": "2017-02-16T19:59:04+00:00"
+ "time": "2017-02-16 19:59:04"
},
{
"name": "colinmollenhour/cache-backend-file",
@@ -87,7 +88,7 @@
],
"description": "The stock Zend_Cache_Backend_File backend has extremely poor performance for cleaning by tags making it become unusable as the number of cached items increases. This backend makes many changes resulting in a huge performance boost, especially for tag cleaning.",
"homepage": "https://github.com/colinmollenhour/Cm_Cache_Backend_File",
- "time": "2016-05-02T16:24:47+00:00"
+ "time": "2016-05-02 16:24:47"
},
{
"name": "colinmollenhour/cache-backend-redis",
@@ -123,7 +124,7 @@
],
"description": "Zend_Cache backend using Redis with full support for tags.",
"homepage": "https://github.com/colinmollenhour/Cm_Cache_Backend_Redis",
- "time": "2017-03-25T04:54:24+00:00"
+ "time": "2017-03-25 04:54:24"
},
{
"name": "colinmollenhour/credis",
@@ -162,7 +163,7 @@
],
"description": "Credis is a lightweight interface to the Redis key-value store which wraps the phpredis library when available for better performance.",
"homepage": "https://github.com/colinmollenhour/credis",
- "time": "2015-11-28T01:20:04+00:00"
+ "time": "2015-11-28 01:20:04"
},
{
"name": "colinmollenhour/php-redis-session-abstract",
@@ -199,20 +200,20 @@
],
"description": "A Redis-based session handler with optimistic locking",
"homepage": "https://github.com/colinmollenhour/php-redis-session-abstract",
- "time": "2017-04-19T14:21:43+00:00"
+ "time": "2017-04-19 14:21:43"
},
{
"name": "composer/ca-bundle",
- "version": "1.0.8",
+ "version": "1.0.9",
"source": {
"type": "git",
"url": "https://github.com/composer/ca-bundle.git",
- "reference": "9dd73a03951357922d8aee6cc084500de93e2343"
+ "reference": "36344aeffdc37711335563e6108cda86566432a6"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/composer/ca-bundle/zipball/9dd73a03951357922d8aee6cc084500de93e2343",
- "reference": "9dd73a03951357922d8aee6cc084500de93e2343",
+ "url": "https://api.github.com/repos/composer/ca-bundle/zipball/36344aeffdc37711335563e6108cda86566432a6",
+ "reference": "36344aeffdc37711335563e6108cda86566432a6",
"shasum": ""
},
"require": {
@@ -258,7 +259,7 @@
"ssl",
"tls"
],
- "time": "2017-09-11T07:24:36+00:00"
+ "time": "2017-11-13 15:51:25"
},
{
"name": "composer/composer",
@@ -335,7 +336,7 @@
"dependency",
"package"
],
- "time": "2017-03-10T08:29:45+00:00"
+ "time": "2017-03-10 08:29:45"
},
{
"name": "composer/semver",
@@ -397,7 +398,7 @@
"validation",
"versioning"
],
- "time": "2016-08-30T16:08:34+00:00"
+ "time": "2016-08-30 16:08:34"
},
{
"name": "composer/spdx-licenses",
@@ -458,7 +459,7 @@
"spdx",
"validator"
],
- "time": "2017-04-03T19:08:52+00:00"
+ "time": "2017-04-03 19:08:52"
},
{
"name": "container-interop/container-interop",
@@ -489,7 +490,7 @@
],
"description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
"homepage": "https://github.com/container-interop/container-interop",
- "time": "2017-02-14T19:40:03+00:00"
+ "time": "2017-02-14 19:40:03"
},
{
"name": "justinrainbow/json-schema",
@@ -555,7 +556,7 @@
"json",
"schema"
],
- "time": "2017-10-21T13:15:38+00:00"
+ "time": "2017-10-21 13:15:38"
},
{
"name": "league/climate",
@@ -604,7 +605,7 @@
"php",
"terminal"
],
- "time": "2015-01-18T14:31:58+00:00"
+ "time": "2015-01-18 14:31:58"
},
{
"name": "magento/composer",
@@ -640,7 +641,7 @@
"AFL-3.0"
],
"description": "Magento composer library helps to instantiate Composer application and run composer commands.",
- "time": "2017-04-24T09:57:02+00:00"
+ "time": "2017-04-24 09:57:02"
},
{
"name": "magento/magento-composer-installer",
@@ -719,7 +720,7 @@
"composer-installer",
"magento"
],
- "time": "2016-10-06T16:05:07+00:00"
+ "time": "2016-10-06 16:05:07"
},
{
"name": "magento/zendframework1",
@@ -766,7 +767,7 @@
"ZF1",
"framework"
],
- "time": "2017-06-21T14:56:23+00:00"
+ "time": "2017-06-21 14:56:23"
},
{
"name": "monolog/monolog",
@@ -844,7 +845,7 @@
"logging",
"psr-3"
],
- "time": "2017-06-19T01:22:40+00:00"
+ "time": "2017-06-19 01:22:40"
},
{
"name": "oyejorge/less.php",
@@ -906,7 +907,7 @@
"php",
"stylesheet"
],
- "time": "2017-03-28T22:19:25+00:00"
+ "time": "2017-03-28 22:19:25"
},
{
"name": "paragonie/random_compat",
@@ -954,7 +955,7 @@
"pseudorandom",
"random"
],
- "time": "2017-09-27T21:40:39+00:00"
+ "time": "2017-09-27 21:40:39"
},
{
"name": "pelago/emogrifier",
@@ -1014,7 +1015,7 @@
],
"description": "Converts CSS styles into inline style attributes in your HTML code",
"homepage": "http://www.pelagodesign.com/sidecar/emogrifier/",
- "time": "2017-03-02T12:51:48+00:00"
+ "time": "2017-03-02 12:51:48"
},
{
"name": "phpseclib/phpseclib",
@@ -1106,7 +1107,7 @@
"x.509",
"x509"
],
- "time": "2017-10-23T05:04:54+00:00"
+ "time": "2017-10-23 05:04:54"
},
{
"name": "psr/container",
@@ -1155,7 +1156,7 @@
"container-interop",
"psr"
],
- "time": "2017-02-14T16:28:37+00:00"
+ "time": "2017-02-14 16:28:37"
},
{
"name": "psr/log",
@@ -1202,7 +1203,7 @@
"psr",
"psr-3"
],
- "time": "2016-10-10T12:19:37+00:00"
+ "time": "2016-10-10 12:19:37"
},
{
"name": "ramsey/uuid",
@@ -1284,7 +1285,7 @@
"identifier",
"uuid"
],
- "time": "2017-03-26T20:37:53+00:00"
+ "time": "2017-03-26 20:37:53"
},
{
"name": "seld/cli-prompt",
@@ -1332,7 +1333,7 @@
"input",
"prompt"
],
- "time": "2017-03-18T11:32:45+00:00"
+ "time": "2017-03-18 11:32:45"
},
{
"name": "seld/jsonlint",
@@ -1381,7 +1382,7 @@
"parser",
"validator"
],
- "time": "2017-06-18T15:11:04+00:00"
+ "time": "2017-06-18 15:11:04"
},
{
"name": "seld/phar-utils",
@@ -1425,7 +1426,7 @@
"keywords": [
"phra"
],
- "time": "2015-10-13T18:44:15+00:00"
+ "time": "2015-10-13 18:44:15"
},
{
"name": "sjparkinson/static-review",
@@ -1478,20 +1479,20 @@
}
],
"description": "An extendable framework for version control hooks.",
- "time": "2014-09-22T08:40:36+00:00"
+ "time": "2014-09-22 08:40:36"
},
{
"name": "symfony/console",
- "version": "v2.8.28",
+ "version": "v2.8.31",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "f81549d2c5fdee8d711c9ab3c7e7362353ea5853"
+ "reference": "7cad097cf081c0ab3d0322cc38d34ee80484d86f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/f81549d2c5fdee8d711c9ab3c7e7362353ea5853",
- "reference": "f81549d2c5fdee8d711c9ab3c7e7362353ea5853",
+ "url": "https://api.github.com/repos/symfony/console/zipball/7cad097cf081c0ab3d0322cc38d34ee80484d86f",
+ "reference": "7cad097cf081c0ab3d0322cc38d34ee80484d86f",
"shasum": ""
},
"require": {
@@ -1539,7 +1540,7 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
- "time": "2017-10-01T21:00:16+00:00"
+ "time": "2017-11-16 15:20:19"
},
{
"name": "symfony/debug",
@@ -1596,20 +1597,20 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
- "time": "2016-07-30T07:22:48+00:00"
+ "time": "2016-07-30 07:22:48"
},
{
"name": "symfony/event-dispatcher",
- "version": "v2.8.28",
+ "version": "v2.8.31",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
- "reference": "7fe089232554357efb8d4af65ce209fc6e5a2186"
+ "reference": "b59aacf238fadda50d612c9de73b74751872a903"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/7fe089232554357efb8d4af65ce209fc6e5a2186",
- "reference": "7fe089232554357efb8d4af65ce209fc6e5a2186",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b59aacf238fadda50d612c9de73b74751872a903",
+ "reference": "b59aacf238fadda50d612c9de73b74751872a903",
"shasum": ""
},
"require": {
@@ -1656,20 +1657,20 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
- "time": "2017-10-01T21:00:16+00:00"
+ "time": "2017-11-05 15:25:56"
},
{
"name": "symfony/filesystem",
- "version": "v3.3.10",
+ "version": "v3.3.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
- "reference": "90bc45abf02ae6b7deb43895c1052cb0038506f1"
+ "reference": "77db266766b54db3ee982fe51868328b887ce15c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/filesystem/zipball/90bc45abf02ae6b7deb43895c1052cb0038506f1",
- "reference": "90bc45abf02ae6b7deb43895c1052cb0038506f1",
+ "url": "https://api.github.com/repos/symfony/filesystem/zipball/77db266766b54db3ee982fe51868328b887ce15c",
+ "reference": "77db266766b54db3ee982fe51868328b887ce15c",
"shasum": ""
},
"require": {
@@ -1705,20 +1706,20 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
- "time": "2017-10-03T13:33:10+00:00"
+ "time": "2017-11-07 14:12:55"
},
{
"name": "symfony/finder",
- "version": "v3.3.10",
+ "version": "v3.3.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
- "reference": "773e19a491d97926f236942484cb541560ce862d"
+ "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/finder/zipball/773e19a491d97926f236942484cb541560ce862d",
- "reference": "773e19a491d97926f236942484cb541560ce862d",
+ "url": "https://api.github.com/repos/symfony/finder/zipball/138af5ec075d4b1d1bd19de08c38a34bb2d7d880",
+ "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880",
"shasum": ""
},
"require": {
@@ -1754,7 +1755,7 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
- "time": "2017-10-02T06:42:24+00:00"
+ "time": "2017-11-05 15:47:03"
},
{
"name": "symfony/polyfill-mbstring",
@@ -1813,20 +1814,20 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/process",
- "version": "v2.8.28",
+ "version": "v2.8.31",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
- "reference": "26c9fb02bf06bd6b90f661a5bd17e510810d0176"
+ "reference": "d25449e031f600807949aab7cadbf267712f4eee"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/process/zipball/26c9fb02bf06bd6b90f661a5bd17e510810d0176",
- "reference": "26c9fb02bf06bd6b90f661a5bd17e510810d0176",
+ "url": "https://api.github.com/repos/symfony/process/zipball/d25449e031f600807949aab7cadbf267712f4eee",
+ "reference": "d25449e031f600807949aab7cadbf267712f4eee",
"shasum": ""
},
"require": {
@@ -1862,7 +1863,7 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
- "time": "2017-10-01T21:00:16+00:00"
+ "time": "2017-11-05 15:25:56"
},
{
"name": "tedivm/jshrink",
@@ -1908,7 +1909,7 @@
"javascript",
"minifier"
],
- "time": "2015-07-04T07:35:09+00:00"
+ "time": "2015-07-04 07:35:09"
},
{
"name": "tubalmartin/cssmin",
@@ -1961,7 +1962,7 @@
"minify",
"yui"
],
- "time": "2017-05-16T13:45:26+00:00"
+ "time": "2017-05-16 13:45:26"
},
{
"name": "webonyx/graphql-php",
@@ -2008,7 +2009,7 @@
"api",
"graphql"
],
- "time": "2017-10-13T17:45:55+00:00"
+ "time": "2017-10-13 17:45:55"
},
{
"name": "zendframework/zend-captcha",
@@ -2065,7 +2066,7 @@
"captcha",
"zf2"
],
- "time": "2017-02-23T08:09:44+00:00"
+ "time": "2017-02-23 08:09:44"
},
{
"name": "zendframework/zend-code",
@@ -2118,7 +2119,7 @@
"code",
"zf2"
],
- "time": "2016-10-24T13:23:32+00:00"
+ "time": "2016-10-24 13:23:32"
},
{
"name": "zendframework/zend-config",
@@ -2174,7 +2175,7 @@
"config",
"zf2"
],
- "time": "2016-02-04T23:01:10+00:00"
+ "time": "2016-02-04 23:01:10"
},
{
"name": "zendframework/zend-console",
@@ -2226,7 +2227,7 @@
"console",
"zf2"
],
- "time": "2016-02-09T17:15:12+00:00"
+ "time": "2016-02-09 17:15:12"
},
{
"name": "zendframework/zend-crypt",
@@ -2276,7 +2277,7 @@
"crypt",
"zf2"
],
- "time": "2016-02-03T23:46:30+00:00"
+ "time": "2016-02-03 23:46:30"
},
{
"name": "zendframework/zend-db",
@@ -2333,7 +2334,7 @@
"db",
"zf2"
],
- "time": "2016-08-09T19:28:55+00:00"
+ "time": "2016-08-09 19:28:55"
},
{
"name": "zendframework/zend-di",
@@ -2380,7 +2381,7 @@
"di",
"zf2"
],
- "time": "2016-04-25T20:58:11+00:00"
+ "time": "2016-04-25 20:58:11"
},
{
"name": "zendframework/zend-escaper",
@@ -2424,7 +2425,7 @@
"escaper",
"zf2"
],
- "time": "2016-06-30T19:48:38+00:00"
+ "time": "2016-06-30 19:48:38"
},
{
"name": "zendframework/zend-eventmanager",
@@ -2471,7 +2472,7 @@
"eventmanager",
"zf2"
],
- "time": "2016-02-18T20:49:05+00:00"
+ "time": "2016-02-18 20:49:05"
},
{
"name": "zendframework/zend-filter",
@@ -2531,7 +2532,7 @@
"filter",
"zf2"
],
- "time": "2017-05-17T20:56:17+00:00"
+ "time": "2017-05-17 20:56:17"
},
{
"name": "zendframework/zend-form",
@@ -2608,7 +2609,7 @@
"form",
"zf2"
],
- "time": "2017-05-18T14:59:53+00:00"
+ "time": "2017-05-18 14:59:53"
},
{
"name": "zendframework/zend-http",
@@ -2661,7 +2662,7 @@
"zend",
"zf"
],
- "time": "2017-10-13T12:06:24+00:00"
+ "time": "2017-10-13 12:06:24"
},
{
"name": "zendframework/zend-hydrator",
@@ -2719,7 +2720,7 @@
"hydrator",
"zf2"
],
- "time": "2016-02-18T22:38:26+00:00"
+ "time": "2016-02-18 22:38:26"
},
{
"name": "zendframework/zend-i18n",
@@ -2786,20 +2787,20 @@
"i18n",
"zf2"
],
- "time": "2017-05-17T17:00:12+00:00"
+ "time": "2017-05-17 17:00:12"
},
{
"name": "zendframework/zend-inputfilter",
- "version": "2.7.4",
+ "version": "2.7.5",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-inputfilter.git",
- "reference": "699ab4916e0aa73104e1f9ff068ef6d33c5f5fe4"
+ "reference": "02bbc6b5fc54991e43e7471e54e2173077708d7b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/zendframework/zend-inputfilter/zipball/699ab4916e0aa73104e1f9ff068ef6d33c5f5fe4",
- "reference": "699ab4916e0aa73104e1f9ff068ef6d33c5f5fe4",
+ "url": "https://api.github.com/repos/zendframework/zend-inputfilter/zipball/02bbc6b5fc54991e43e7471e54e2173077708d7b",
+ "reference": "02bbc6b5fc54991e43e7471e54e2173077708d7b",
"shasum": ""
},
"require": {
@@ -2841,7 +2842,7 @@
"inputfilter",
"zf2"
],
- "time": "2017-05-18T14:20:56+00:00"
+ "time": "2017-11-07 17:08:00"
},
{
"name": "zendframework/zend-json",
@@ -2896,7 +2897,7 @@
"json",
"zf2"
],
- "time": "2016-02-04T21:20:26+00:00"
+ "time": "2016-02-04 21:20:26"
},
{
"name": "zendframework/zend-loader",
@@ -2940,7 +2941,7 @@
"loader",
"zf2"
],
- "time": "2015-06-03T14:05:47+00:00"
+ "time": "2015-06-03 14:05:47"
},
{
"name": "zendframework/zend-log",
@@ -3011,7 +3012,7 @@
"logging",
"zf2"
],
- "time": "2017-05-17T16:03:26+00:00"
+ "time": "2017-05-17 16:03:26"
},
{
"name": "zendframework/zend-mail",
@@ -3073,7 +3074,7 @@
"mail",
"zf2"
],
- "time": "2017-06-08T20:03:58+00:00"
+ "time": "2017-06-08 20:03:58"
},
{
"name": "zendframework/zend-math",
@@ -3123,7 +3124,7 @@
"math",
"zf2"
],
- "time": "2016-04-07T16:29:53+00:00"
+ "time": "2016-04-07 16:29:53"
},
{
"name": "zendframework/zend-mime",
@@ -3172,20 +3173,20 @@
"mime",
"zf2"
],
- "time": "2017-01-16T16:43:38+00:00"
+ "time": "2017-01-16 16:43:38"
},
{
"name": "zendframework/zend-modulemanager",
- "version": "2.8.0",
+ "version": "2.8.1",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-modulemanager.git",
- "reference": "c2c5b52ad9741e0b9a9c01a0ee72ab63e5b494b9"
+ "reference": "710c13353b1ff0975777dbeb39bbf1c85e3353a3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/zendframework/zend-modulemanager/zipball/c2c5b52ad9741e0b9a9c01a0ee72ab63e5b494b9",
- "reference": "c2c5b52ad9741e0b9a9c01a0ee72ab63e5b494b9",
+ "url": "https://api.github.com/repos/zendframework/zend-modulemanager/zipball/710c13353b1ff0975777dbeb39bbf1c85e3353a3",
+ "reference": "710c13353b1ff0975777dbeb39bbf1c85e3353a3",
"shasum": ""
},
"require": {
@@ -3230,7 +3231,7 @@
"modulemanager",
"zf2"
],
- "time": "2017-07-11T19:39:57+00:00"
+ "time": "2017-11-01 18:30:41"
},
{
"name": "zendframework/zend-mvc",
@@ -3317,7 +3318,7 @@
"mvc",
"zf2"
],
- "time": "2016-02-23T15:24:59+00:00"
+ "time": "2016-02-23 15:24:59"
},
{
"name": "zendframework/zend-serializer",
@@ -3374,7 +3375,7 @@
"serializer",
"zf2"
],
- "time": "2016-06-21T17:01:55+00:00"
+ "time": "2016-06-21 17:01:55"
},
{
"name": "zendframework/zend-server",
@@ -3420,7 +3421,7 @@
"server",
"zf2"
],
- "time": "2016-06-20T22:27:55+00:00"
+ "time": "2016-06-20 22:27:55"
},
{
"name": "zendframework/zend-servicemanager",
@@ -3472,7 +3473,7 @@
"servicemanager",
"zf2"
],
- "time": "2016-12-19T19:14:29+00:00"
+ "time": "2016-12-19 19:14:29"
},
{
"name": "zendframework/zend-session",
@@ -3538,7 +3539,7 @@
"session",
"zf2"
],
- "time": "2017-06-19T21:31:39+00:00"
+ "time": "2017-06-19 21:31:39"
},
{
"name": "zendframework/zend-soap",
@@ -3590,7 +3591,7 @@
"soap",
"zf2"
],
- "time": "2016-04-21T16:06:27+00:00"
+ "time": "2016-04-21 16:06:27"
},
{
"name": "zendframework/zend-stdlib",
@@ -3649,7 +3650,7 @@
"stdlib",
"zf2"
],
- "time": "2016-04-12T21:17:31+00:00"
+ "time": "2016-04-12 21:17:31"
},
{
"name": "zendframework/zend-text",
@@ -3696,7 +3697,7 @@
"text",
"zf2"
],
- "time": "2016-02-08T19:03:52+00:00"
+ "time": "2016-02-08 19:03:52"
},
{
"name": "zendframework/zend-uri",
@@ -3743,7 +3744,7 @@
"uri",
"zf2"
],
- "time": "2016-02-17T22:38:51+00:00"
+ "time": "2016-02-17 22:38:51"
},
{
"name": "zendframework/zend-validator",
@@ -3814,7 +3815,7 @@
"validator",
"zf2"
],
- "time": "2017-08-22T14:19:23+00:00"
+ "time": "2017-08-22 14:19:23"
},
{
"name": "zendframework/zend-view",
@@ -3901,7 +3902,7 @@
"view",
"zf2"
],
- "time": "2017-03-21T15:05:56+00:00"
+ "time": "2017-03-21 15:05:56"
}
],
"packages-dev": [
@@ -3957,7 +3958,7 @@
"constructor",
"instantiate"
],
- "time": "2015-06-14T21:17:01+00:00"
+ "time": "2015-06-14 21:17:01"
},
{
"name": "friendsofphp/php-cs-fixer",
@@ -4027,7 +4028,7 @@
}
],
"description": "A tool to automatically fix PHP code style",
- "time": "2017-03-31T12:59:38+00:00"
+ "time": "2017-03-31 12:59:38"
},
{
"name": "ircmaxell/password-compat",
@@ -4069,7 +4070,7 @@
"hashing",
"password"
],
- "time": "2014-11-20T16:49:30+00:00"
+ "time": "2014-11-20 16:49:30"
},
{
"name": "lusitanian/oauth",
@@ -4136,7 +4137,7 @@
"oauth",
"security"
],
- "time": "2016-07-12T22:15:40+00:00"
+ "time": "2016-07-12 22:15:40"
},
{
"name": "myclabs/deep-copy",
@@ -4181,7 +4182,7 @@
"object",
"object graph"
],
- "time": "2017-10-19T19:58:43+00:00"
+ "time": "2017-10-19 19:58:43"
},
{
"name": "pdepend/pdepend",
@@ -4221,7 +4222,7 @@
"BSD-3-Clause"
],
"description": "Official version of pdepend to be handled with Composer",
- "time": "2017-01-19T14:23:36+00:00"
+ "time": "2017-01-19 14:23:36"
},
{
"name": "phar-io/manifest",
@@ -4276,7 +4277,7 @@
}
],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
- "time": "2017-03-05T18:14:27+00:00"
+ "time": "2017-03-05 18:14:27"
},
{
"name": "phar-io/version",
@@ -4323,7 +4324,7 @@
}
],
"description": "Library for handling version information and constraints",
- "time": "2017-03-05T17:38:23+00:00"
+ "time": "2017-03-05 17:38:23"
},
{
"name": "phpdocumentor/reflection-common",
@@ -4377,7 +4378,7 @@
"reflection",
"static analysis"
],
- "time": "2017-09-11T18:02:19+00:00"
+ "time": "2017-09-11 18:02:19"
},
{
"name": "phpdocumentor/reflection-docblock",
@@ -4422,7 +4423,7 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
- "time": "2017-08-30T18:51:59+00:00"
+ "time": "2017-08-30 18:51:59"
},
{
"name": "phpdocumentor/type-resolver",
@@ -4469,7 +4470,7 @@
"email": "me@mikevanriel.com"
}
],
- "time": "2017-07-14T14:27:02+00:00"
+ "time": "2017-07-14 14:27:02"
},
{
"name": "phpmd/phpmd",
@@ -4535,7 +4536,7 @@
"phpmd",
"pmd"
],
- "time": "2017-01-20T14:41:10+00:00"
+ "time": "2017-01-20 14:41:10"
},
{
"name": "phpspec/prophecy",
@@ -4598,20 +4599,20 @@
"spy",
"stub"
],
- "time": "2017-09-04T11:05:03+00:00"
+ "time": "2017-09-04 11:05:03"
},
{
"name": "phpunit/php-code-coverage",
- "version": "5.2.2",
+ "version": "5.2.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "8ed1902a57849e117b5651fc1a5c48110946c06b"
+ "reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8ed1902a57849e117b5651fc1a5c48110946c06b",
- "reference": "8ed1902a57849e117b5651fc1a5c48110946c06b",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d",
+ "reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d",
"shasum": ""
},
"require": {
@@ -4620,7 +4621,7 @@
"php": "^7.0",
"phpunit/php-file-iterator": "^1.4.2",
"phpunit/php-text-template": "^1.2.1",
- "phpunit/php-token-stream": "^1.4.11 || ^2.0",
+ "phpunit/php-token-stream": "^2.0",
"sebastian/code-unit-reverse-lookup": "^1.0.1",
"sebastian/environment": "^3.0",
"sebastian/version": "^2.0.1",
@@ -4662,7 +4663,7 @@
"testing",
"xunit"
],
- "time": "2017-08-03T12:40:43+00:00"
+ "time": "2017-11-03 13:47:33"
},
{
"name": "phpunit/php-file-iterator",
@@ -4709,7 +4710,7 @@
"filesystem",
"iterator"
],
- "time": "2016-10-03T07:40:28+00:00"
+ "time": "2016-10-03 07:40:28"
},
{
"name": "phpunit/php-text-template",
@@ -4750,7 +4751,7 @@
"keywords": [
"template"
],
- "time": "2015-06-21T13:50:34+00:00"
+ "time": "2015-06-21 13:50:34"
},
{
"name": "phpunit/php-timer",
@@ -4799,7 +4800,7 @@
"keywords": [
"timer"
],
- "time": "2017-02-26T11:10:40+00:00"
+ "time": "2017-02-26 11:10:40"
},
{
"name": "phpunit/php-token-stream",
@@ -4848,7 +4849,7 @@
"keywords": [
"tokenizer"
],
- "time": "2017-08-20T05:47:52+00:00"
+ "time": "2017-08-20 05:47:52"
},
{
"name": "phpunit/phpunit",
@@ -4932,7 +4933,7 @@
"testing",
"xunit"
],
- "time": "2017-08-03T13:59:28+00:00"
+ "time": "2017-08-03 13:59:28"
},
{
"name": "phpunit/phpunit-mock-objects",
@@ -4991,7 +4992,7 @@
"mock",
"xunit"
],
- "time": "2017-08-03T14:08:16+00:00"
+ "time": "2017-08-03 14:08:16"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@@ -5036,7 +5037,7 @@
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
- "time": "2017-03-04T06:30:41+00:00"
+ "time": "2017-03-04 06:30:41"
},
{
"name": "sebastian/comparator",
@@ -5100,7 +5101,7 @@
"compare",
"equality"
],
- "time": "2017-03-03T06:26:08+00:00"
+ "time": "2017-03-03 06:26:08"
},
{
"name": "sebastian/diff",
@@ -5152,7 +5153,7 @@
"keywords": [
"diff"
],
- "time": "2017-05-22T07:24:03+00:00"
+ "time": "2017-05-22 07:24:03"
},
{
"name": "sebastian/environment",
@@ -5202,7 +5203,7 @@
"environment",
"hhvm"
],
- "time": "2017-07-01T08:51:00+00:00"
+ "time": "2017-07-01 08:51:00"
},
{
"name": "sebastian/exporter",
@@ -5269,24 +5270,24 @@
"export",
"exporter"
],
- "time": "2017-04-03T13:19:02+00:00"
+ "time": "2017-04-03 13:19:02"
},
{
"name": "sebastian/finder-facade",
- "version": "1.2.1",
+ "version": "1.2.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/finder-facade.git",
- "reference": "2a6f7f57efc0aa2d23297d9fd9e2a03111a8c0b9"
+ "reference": "4a3174709c2dc565fe5fb26fcf827f6a1fc7b09f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/finder-facade/zipball/2a6f7f57efc0aa2d23297d9fd9e2a03111a8c0b9",
- "reference": "2a6f7f57efc0aa2d23297d9fd9e2a03111a8c0b9",
+ "url": "https://api.github.com/repos/sebastianbergmann/finder-facade/zipball/4a3174709c2dc565fe5fb26fcf827f6a1fc7b09f",
+ "reference": "4a3174709c2dc565fe5fb26fcf827f6a1fc7b09f",
"shasum": ""
},
"require": {
- "symfony/finder": "~2.3|~3.0",
+ "symfony/finder": "~2.3|~3.0|~4.0",
"theseer/fdomdocument": "~1.3"
},
"type": "library",
@@ -5308,7 +5309,7 @@
],
"description": "FinderFacade is a convenience wrapper for Symfony's Finder component.",
"homepage": "https://github.com/sebastianbergmann/finder-facade",
- "time": "2016-02-17T07:02:23+00:00"
+ "time": "2017-11-18 17:31:49"
},
{
"name": "sebastian/global-state",
@@ -5359,7 +5360,7 @@
"keywords": [
"global state"
],
- "time": "2017-04-27T15:39:26+00:00"
+ "time": "2017-04-27 15:39:26"
},
{
"name": "sebastian/object-enumerator",
@@ -5406,7 +5407,7 @@
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
- "time": "2017-08-03T12:35:26+00:00"
+ "time": "2017-08-03 12:35:26"
},
{
"name": "sebastian/object-reflector",
@@ -5451,7 +5452,7 @@
],
"description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
- "time": "2017-03-29T09:07:27+00:00"
+ "time": "2017-03-29 09:07:27"
},
{
"name": "sebastian/phpcpd",
@@ -5502,7 +5503,7 @@
],
"description": "Copy/Paste Detector (CPD) for PHP code.",
"homepage": "https://github.com/sebastianbergmann/phpcpd",
- "time": "2016-04-17T19:32:49+00:00"
+ "time": "2016-04-17 19:32:49"
},
{
"name": "sebastian/recursion-context",
@@ -5555,7 +5556,7 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
- "time": "2017-03-03T06:23:57+00:00"
+ "time": "2017-03-03 06:23:57"
},
{
"name": "sebastian/resource-operations",
@@ -5597,7 +5598,7 @@
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
- "time": "2015-07-28T20:34:47+00:00"
+ "time": "2015-07-28 20:34:47"
},
{
"name": "sebastian/version",
@@ -5640,7 +5641,7 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
- "time": "2016-10-03T07:35:21+00:00"
+ "time": "2016-10-03 07:35:21"
},
{
"name": "squizlabs/php_codesniffer",
@@ -5691,20 +5692,20 @@
"phpcs",
"standards"
],
- "time": "2017-06-14T01:23:49+00:00"
+ "time": "2017-06-14 01:23:49"
},
{
"name": "symfony/config",
- "version": "v3.3.10",
+ "version": "v3.3.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
- "reference": "4ab62407bff9cd97c410a7feaef04c375aaa5cfd"
+ "reference": "8d2649077dc54dfbaf521d31f217383d82303c5f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/config/zipball/4ab62407bff9cd97c410a7feaef04c375aaa5cfd",
- "reference": "4ab62407bff9cd97c410a7feaef04c375aaa5cfd",
+ "url": "https://api.github.com/repos/symfony/config/zipball/8d2649077dc54dfbaf521d31f217383d82303c5f",
+ "reference": "8d2649077dc54dfbaf521d31f217383d82303c5f",
"shasum": ""
},
"require": {
@@ -5753,20 +5754,20 @@
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
- "time": "2017-10-04T18:56:58+00:00"
+ "time": "2017-11-07 14:16:22"
},
{
"name": "symfony/dependency-injection",
- "version": "v3.3.10",
+ "version": "v3.3.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/dependency-injection.git",
- "reference": "8ebad929aee3ca185b05f55d9cc5521670821ad1"
+ "reference": "4e84f5af2c2d51ee3dee72df40b7fc08f49b4ab8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/8ebad929aee3ca185b05f55d9cc5521670821ad1",
- "reference": "8ebad929aee3ca185b05f55d9cc5521670821ad1",
+ "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/4e84f5af2c2d51ee3dee72df40b7fc08f49b4ab8",
+ "reference": "4e84f5af2c2d51ee3dee72df40b7fc08f49b4ab8",
"shasum": ""
},
"require": {
@@ -5823,7 +5824,7 @@
],
"description": "Symfony DependencyInjection Component",
"homepage": "https://symfony.com",
- "time": "2017-10-04T17:15:30+00:00"
+ "time": "2017-11-13 18:10:32"
},
{
"name": "symfony/polyfill-php54",
@@ -5881,7 +5882,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/polyfill-php55",
@@ -5937,7 +5938,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/polyfill-php70",
@@ -5996,7 +5997,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/polyfill-php72",
@@ -6051,7 +6052,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/polyfill-xml",
@@ -6099,20 +6100,20 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/stopwatch",
- "version": "v3.3.10",
+ "version": "v3.3.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
- "reference": "170edf8b3247d7b6779eb6fa7428f342702ca184"
+ "reference": "1e93c3139ef6c799831fe03efd0fb1c7aecb3365"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/stopwatch/zipball/170edf8b3247d7b6779eb6fa7428f342702ca184",
- "reference": "170edf8b3247d7b6779eb6fa7428f342702ca184",
+ "url": "https://api.github.com/repos/symfony/stopwatch/zipball/1e93c3139ef6c799831fe03efd0fb1c7aecb3365",
+ "reference": "1e93c3139ef6c799831fe03efd0fb1c7aecb3365",
"shasum": ""
},
"require": {
@@ -6148,7 +6149,7 @@
],
"description": "Symfony Stopwatch Component",
"homepage": "https://symfony.com",
- "time": "2017-10-02T06:42:24+00:00"
+ "time": "2017-11-10 19:02:53"
},
{
"name": "theseer/fdomdocument",
@@ -6188,7 +6189,7 @@
],
"description": "The classes contained within this repository extend the standard DOM to use exceptions at all occasions of errors instead of PHP warnings or notices. They also add various custom methods and shortcuts for convenience and to simplify the usage of DOM.",
"homepage": "https://github.com/theseer/fDOMDocument",
- "time": "2017-06-30T11:53:12+00:00"
+ "time": "2017-06-30 11:53:12"
},
{
"name": "theseer/tokenizer",
@@ -6228,7 +6229,7 @@
}
],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
- "time": "2017-04-07T12:08:54+00:00"
+ "time": "2017-04-07 12:08:54"
},
{
"name": "webmozart/assert",
@@ -6278,7 +6279,7 @@
"check",
"validate"
],
- "time": "2016-11-23T20:04:58+00:00"
+ "time": "2016-11-23 20:04:58"
}
],
"aliases": [],
From ecdf63d3a2536439acb6bd387c0b9084e6d09591 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Mon, 20 Nov 2017 11:03:35 -0600
Subject: [PATCH 218/225] MAGETWO-72487: Move code to CE
- add exception hierarchy black list
---
.../Test/Integrity/_files/blacklist/exception_hierarchy.txt | 2 ++
1 file changed, 2 insertions(+)
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 eef18a25ad259..6897f43a02b34 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
@@ -9,3 +9,5 @@
\Magento\Framework\DB\Adapter\DuplicateException
\Magento\Framework\DB\DataConverter\DataConversionException
\Magento\Framework\DB\FieldDataConversionException
+\Magento\Signifyd\Model\SignifydGateway\GatewayException
+\Magento\Signifyd\Model\SignifydGateway\ApiCallException
From 4cb340c19ba918cfb776b89ea11f0beba86411ea Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 8 Feb 2017 02:58:48 -0600
Subject: [PATCH 219/225] MAGETWO-63945: Add extension point to sales grid
indexer
- Delete constraint.xml
---
app/code/Magento/Signifyd/etc/constraints.xml | 17 -----------------
1 file changed, 17 deletions(-)
delete mode 100644 app/code/Magento/Signifyd/etc/constraints.xml
diff --git a/app/code/Magento/Signifyd/etc/constraints.xml b/app/code/Magento/Signifyd/etc/constraints.xml
deleted file mode 100644
index 1c02b42bf11c9..0000000000000
--- a/app/code/Magento/Signifyd/etc/constraints.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
From 9abeb4a88452aed75b8c5532ea53186f9157a9e0 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Mon, 27 Nov 2017 15:39:42 -0600
Subject: [PATCH 220/225] MAGETWO-72487: Move code to CE
- (cherry picked from commit d71ad32)
---
app/code/Magento/Signifyd/etc/di.xml | 21 -------------------
.../Signifyd/frontend/js/Fingerprint.test.js | 2 +-
2 files changed, 1 insertion(+), 22 deletions(-)
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index c32fd4352bb10..92ad8a0bfd87a 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -56,32 +56,11 @@
-
-
-
- -
-
- signifyd_case
- - entity_id
- - order_id
-
-
-
- - signifyd_case.guarantee_disposition
-
-
-
sales
-
-
-
- - signifyd_case
-
-
-
Magento_Signifyd
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
index 1db9755eb074a..0be178c5a31f0 100644
--- 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
@@ -1,5 +1,5 @@
/**
- * Copyright © 2013-2017 Magento, Inc. All rights reserved.
+ * Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
From 2a48973be95a4d57a3765fa381f723f18fa35ce6 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Tue, 28 Nov 2017 08:55:47 -0600
Subject: [PATCH 221/225] MAGETWO-72487: Move code to CE
- remove suggest component magento/module-scalable-oms
---
app/code/Magento/Signifyd/composer.json | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 94731b78cbdbf..59326a48f3e85 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -17,8 +17,7 @@
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0"
},
"suggest": {
- "magento/module-config": "100.3.*",
- "magento/module-scalable-oms": "100.3.*"
+ "magento/module-config": "100.3.*"
},
"type": "magento2-module",
"version": "100.3.0-dev",
From d06e21db052856f6aa19fe4af6ad03ca6399bf99 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Fri, 19 Jan 2018 08:14:59 -0600
Subject: [PATCH 222/225] Merge remote-tracking branch 'upstream/2.3-develop'
into MAGETWO-72487-signifyd
# Conflicts:
# composer.lock
---
composer.lock | 233 +++++++++++++++++++++++++-------------------------
1 file changed, 117 insertions(+), 116 deletions(-)
diff --git a/composer.lock b/composer.lock
index f4cffe325b838..ae6e1fd10e961 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "content-hash": "5e50664c1b92a9eecb3f38d2a5b9b773",
+ "hash": "943d036414ed7ff506cc5e55e8b3c0d1",
+ "content-hash": "ea98e5feb4601c98687b0b876d7f1875",
"packages": [
{
"name": "braintree/braintree_php",
@@ -51,7 +52,7 @@
}
],
"description": "Braintree PHP Client Library",
- "time": "2017-02-16T19:59:04+00:00"
+ "time": "2017-02-16 19:59:04"
},
{
"name": "colinmollenhour/cache-backend-file",
@@ -87,7 +88,7 @@
],
"description": "The stock Zend_Cache_Backend_File backend has extremely poor performance for cleaning by tags making it become unusable as the number of cached items increases. This backend makes many changes resulting in a huge performance boost, especially for tag cleaning.",
"homepage": "https://github.com/colinmollenhour/Cm_Cache_Backend_File",
- "time": "2016-05-02T16:24:47+00:00"
+ "time": "2016-05-02 16:24:47"
},
{
"name": "colinmollenhour/cache-backend-redis",
@@ -123,7 +124,7 @@
],
"description": "Zend_Cache backend using Redis with full support for tags.",
"homepage": "https://github.com/colinmollenhour/Cm_Cache_Backend_Redis",
- "time": "2017-03-25T04:54:24+00:00"
+ "time": "2017-03-25 04:54:24"
},
{
"name": "colinmollenhour/credis",
@@ -162,7 +163,7 @@
],
"description": "Credis is a lightweight interface to the Redis key-value store which wraps the phpredis library when available for better performance.",
"homepage": "https://github.com/colinmollenhour/credis",
- "time": "2015-11-28T01:20:04+00:00"
+ "time": "2015-11-28 01:20:04"
},
{
"name": "colinmollenhour/php-redis-session-abstract",
@@ -199,7 +200,7 @@
],
"description": "A Redis-based session handler with optimistic locking",
"homepage": "https://github.com/colinmollenhour/php-redis-session-abstract",
- "time": "2017-04-19T14:21:43+00:00"
+ "time": "2017-04-19 14:21:43"
},
{
"name": "composer/ca-bundle",
@@ -255,7 +256,7 @@
"ssl",
"tls"
],
- "time": "2017-11-29T09:37:33+00:00"
+ "time": "2017-11-29 09:37:33"
},
{
"name": "composer/composer",
@@ -332,7 +333,7 @@
"dependency",
"package"
],
- "time": "2017-03-10T08:29:45+00:00"
+ "time": "2017-03-10 08:29:45"
},
{
"name": "composer/semver",
@@ -394,7 +395,7 @@
"validation",
"versioning"
],
- "time": "2016-08-30T16:08:34+00:00"
+ "time": "2016-08-30 16:08:34"
},
{
"name": "composer/spdx-licenses",
@@ -455,7 +456,7 @@
"spdx",
"validator"
],
- "time": "2018-01-03T16:37:06+00:00"
+ "time": "2018-01-03 16:37:06"
},
{
"name": "container-interop/container-interop",
@@ -486,7 +487,7 @@
],
"description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
"homepage": "https://github.com/container-interop/container-interop",
- "time": "2017-02-14T19:40:03+00:00"
+ "time": "2017-02-14 19:40:03"
},
{
"name": "justinrainbow/json-schema",
@@ -552,7 +553,7 @@
"json",
"schema"
],
- "time": "2017-10-21T13:15:38+00:00"
+ "time": "2017-10-21 13:15:38"
},
{
"name": "league/climate",
@@ -601,7 +602,7 @@
"php",
"terminal"
],
- "time": "2015-01-18T14:31:58+00:00"
+ "time": "2015-01-18 14:31:58"
},
{
"name": "magento/composer",
@@ -637,7 +638,7 @@
"AFL-3.0"
],
"description": "Magento composer library helps to instantiate Composer application and run composer commands.",
- "time": "2017-04-24T09:57:02+00:00"
+ "time": "2017-04-24 09:57:02"
},
{
"name": "magento/magento-composer-installer",
@@ -716,7 +717,7 @@
"composer-installer",
"magento"
],
- "time": "2017-12-29T16:45:24+00:00"
+ "time": "2017-12-29 16:45:24"
},
{
"name": "magento/zendframework1",
@@ -763,7 +764,7 @@
"ZF1",
"framework"
],
- "time": "2017-06-21T14:56:23+00:00"
+ "time": "2017-06-21 14:56:23"
},
{
"name": "monolog/monolog",
@@ -841,7 +842,7 @@
"logging",
"psr-3"
],
- "time": "2017-06-19T01:22:40+00:00"
+ "time": "2017-06-19 01:22:40"
},
{
"name": "oyejorge/less.php",
@@ -903,7 +904,7 @@
"php",
"stylesheet"
],
- "time": "2017-03-28T22:19:25+00:00"
+ "time": "2017-03-28 22:19:25"
},
{
"name": "paragonie/random_compat",
@@ -951,7 +952,7 @@
"pseudorandom",
"random"
],
- "time": "2017-09-27T21:40:39+00:00"
+ "time": "2017-09-27 21:40:39"
},
{
"name": "pelago/emogrifier",
@@ -1011,7 +1012,7 @@
],
"description": "Converts CSS styles into inline style attributes in your HTML code",
"homepage": "http://www.pelagodesign.com/sidecar/emogrifier/",
- "time": "2017-03-02T12:51:48+00:00"
+ "time": "2017-03-02 12:51:48"
},
{
"name": "phpseclib/phpseclib",
@@ -1103,7 +1104,7 @@
"x.509",
"x509"
],
- "time": "2017-11-29T06:38:08+00:00"
+ "time": "2017-11-29 06:38:08"
},
{
"name": "psr/container",
@@ -1152,7 +1153,7 @@
"container-interop",
"psr"
],
- "time": "2017-02-14T16:28:37+00:00"
+ "time": "2017-02-14 16:28:37"
},
{
"name": "psr/log",
@@ -1199,7 +1200,7 @@
"psr",
"psr-3"
],
- "time": "2016-10-10T12:19:37+00:00"
+ "time": "2016-10-10 12:19:37"
},
{
"name": "ramsey/uuid",
@@ -1281,7 +1282,7 @@
"identifier",
"uuid"
],
- "time": "2017-03-26T20:37:53+00:00"
+ "time": "2017-03-26 20:37:53"
},
{
"name": "seld/cli-prompt",
@@ -1329,7 +1330,7 @@
"input",
"prompt"
],
- "time": "2017-03-18T11:32:45+00:00"
+ "time": "2017-03-18 11:32:45"
},
{
"name": "seld/jsonlint",
@@ -1378,7 +1379,7 @@
"parser",
"validator"
],
- "time": "2018-01-03T12:13:57+00:00"
+ "time": "2018-01-03 12:13:57"
},
{
"name": "seld/phar-utils",
@@ -1422,7 +1423,7 @@
"keywords": [
"phra"
],
- "time": "2015-10-13T18:44:15+00:00"
+ "time": "2015-10-13 18:44:15"
},
{
"name": "sjparkinson/static-review",
@@ -1476,7 +1477,7 @@
],
"description": "An extendable framework for version control hooks.",
"abandoned": "phpro/grumphp",
- "time": "2014-09-22T08:40:36+00:00"
+ "time": "2014-09-22 08:40:36"
},
{
"name": "symfony/console",
@@ -1537,7 +1538,7 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
- "time": "2018-01-03T07:36:31+00:00"
+ "time": "2018-01-03 07:36:31"
},
{
"name": "symfony/debug",
@@ -1594,7 +1595,7 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
- "time": "2016-07-30T07:22:48+00:00"
+ "time": "2016-07-30 07:22:48"
},
{
"name": "symfony/event-dispatcher",
@@ -1654,7 +1655,7 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
- "time": "2018-01-03T07:36:31+00:00"
+ "time": "2018-01-03 07:36:31"
},
{
"name": "symfony/filesystem",
@@ -1703,7 +1704,7 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
- "time": "2018-01-03T07:37:34+00:00"
+ "time": "2018-01-03 07:37:34"
},
{
"name": "symfony/finder",
@@ -1752,7 +1753,7 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
- "time": "2018-01-03T07:37:34+00:00"
+ "time": "2018-01-03 07:37:34"
},
{
"name": "symfony/polyfill-mbstring",
@@ -1811,7 +1812,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/process",
@@ -1860,7 +1861,7 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
- "time": "2018-01-03T07:36:31+00:00"
+ "time": "2018-01-03 07:36:31"
},
{
"name": "tedivm/jshrink",
@@ -1906,7 +1907,7 @@
"javascript",
"minifier"
],
- "time": "2015-07-04T07:35:09+00:00"
+ "time": "2015-07-04 07:35:09"
},
{
"name": "tubalmartin/cssmin",
@@ -1959,7 +1960,7 @@
"minify",
"yui"
],
- "time": "2017-05-16T13:45:26+00:00"
+ "time": "2017-05-16 13:45:26"
},
{
"name": "webonyx/graphql-php",
@@ -2006,7 +2007,7 @@
"api",
"graphql"
],
- "time": "2017-12-12T09:03:21+00:00"
+ "time": "2017-12-12 09:03:21"
},
{
"name": "zendframework/zend-captcha",
@@ -2063,7 +2064,7 @@
"captcha",
"zf2"
],
- "time": "2017-02-23T08:09:44+00:00"
+ "time": "2017-02-23 08:09:44"
},
{
"name": "zendframework/zend-code",
@@ -2116,7 +2117,7 @@
"code",
"zf2"
],
- "time": "2016-10-24T13:23:32+00:00"
+ "time": "2016-10-24 13:23:32"
},
{
"name": "zendframework/zend-config",
@@ -2172,7 +2173,7 @@
"config",
"zf2"
],
- "time": "2016-02-04T23:01:10+00:00"
+ "time": "2016-02-04 23:01:10"
},
{
"name": "zendframework/zend-console",
@@ -2224,7 +2225,7 @@
"console",
"zf2"
],
- "time": "2016-02-09T17:15:12+00:00"
+ "time": "2016-02-09 17:15:12"
},
{
"name": "zendframework/zend-crypt",
@@ -2274,7 +2275,7 @@
"crypt",
"zf2"
],
- "time": "2016-02-03T23:46:30+00:00"
+ "time": "2016-02-03 23:46:30"
},
{
"name": "zendframework/zend-db",
@@ -2332,7 +2333,7 @@
"db",
"zf"
],
- "time": "2017-12-11T14:57:52+00:00"
+ "time": "2017-12-11 14:57:52"
},
{
"name": "zendframework/zend-di",
@@ -2379,7 +2380,7 @@
"di",
"zf2"
],
- "time": "2016-04-25T20:58:11+00:00"
+ "time": "2016-04-25 20:58:11"
},
{
"name": "zendframework/zend-escaper",
@@ -2423,7 +2424,7 @@
"escaper",
"zf2"
],
- "time": "2016-06-30T19:48:38+00:00"
+ "time": "2016-06-30 19:48:38"
},
{
"name": "zendframework/zend-eventmanager",
@@ -2470,7 +2471,7 @@
"eventmanager",
"zf2"
],
- "time": "2017-12-12T17:48:56+00:00"
+ "time": "2017-12-12 17:48:56"
},
{
"name": "zendframework/zend-filter",
@@ -2530,7 +2531,7 @@
"filter",
"zf2"
],
- "time": "2017-05-17T20:56:17+00:00"
+ "time": "2017-05-17 20:56:17"
},
{
"name": "zendframework/zend-form",
@@ -2608,7 +2609,7 @@
"form",
"zf"
],
- "time": "2017-12-06T21:09:08+00:00"
+ "time": "2017-12-06 21:09:08"
},
{
"name": "zendframework/zend-http",
@@ -2661,7 +2662,7 @@
"zend",
"zf"
],
- "time": "2017-10-13T12:06:24+00:00"
+ "time": "2017-10-13 12:06:24"
},
{
"name": "zendframework/zend-hydrator",
@@ -2719,7 +2720,7 @@
"hydrator",
"zf2"
],
- "time": "2016-02-18T22:38:26+00:00"
+ "time": "2016-02-18 22:38:26"
},
{
"name": "zendframework/zend-i18n",
@@ -2786,7 +2787,7 @@
"i18n",
"zf2"
],
- "time": "2017-05-17T17:00:12+00:00"
+ "time": "2017-05-17 17:00:12"
},
{
"name": "zendframework/zend-inputfilter",
@@ -2842,7 +2843,7 @@
"inputfilter",
"zf"
],
- "time": "2017-12-04T21:24:25+00:00"
+ "time": "2017-12-04 21:24:25"
},
{
"name": "zendframework/zend-json",
@@ -2897,7 +2898,7 @@
"json",
"zf2"
],
- "time": "2016-02-04T21:20:26+00:00"
+ "time": "2016-02-04 21:20:26"
},
{
"name": "zendframework/zend-loader",
@@ -2941,7 +2942,7 @@
"loader",
"zf2"
],
- "time": "2015-06-03T14:05:47+00:00"
+ "time": "2015-06-03 14:05:47"
},
{
"name": "zendframework/zend-log",
@@ -3012,7 +3013,7 @@
"logging",
"zf2"
],
- "time": "2017-05-17T16:03:26+00:00"
+ "time": "2017-05-17 16:03:26"
},
{
"name": "zendframework/zend-mail",
@@ -3074,7 +3075,7 @@
"mail",
"zf2"
],
- "time": "2017-06-08T20:03:58+00:00"
+ "time": "2017-06-08 20:03:58"
},
{
"name": "zendframework/zend-math",
@@ -3124,7 +3125,7 @@
"math",
"zf2"
],
- "time": "2016-04-07T16:29:53+00:00"
+ "time": "2016-04-07 16:29:53"
},
{
"name": "zendframework/zend-mime",
@@ -3175,7 +3176,7 @@
"mime",
"zf"
],
- "time": "2017-11-28T15:02:22+00:00"
+ "time": "2017-11-28 15:02:22"
},
{
"name": "zendframework/zend-modulemanager",
@@ -3235,7 +3236,7 @@
"modulemanager",
"zf"
],
- "time": "2017-12-02T06:11:18+00:00"
+ "time": "2017-12-02 06:11:18"
},
{
"name": "zendframework/zend-mvc",
@@ -3322,7 +3323,7 @@
"mvc",
"zf2"
],
- "time": "2016-02-23T15:24:59+00:00"
+ "time": "2016-02-23 15:24:59"
},
{
"name": "zendframework/zend-serializer",
@@ -3380,7 +3381,7 @@
"serializer",
"zf2"
],
- "time": "2017-11-20T22:21:04+00:00"
+ "time": "2017-11-20 22:21:04"
},
{
"name": "zendframework/zend-server",
@@ -3426,7 +3427,7 @@
"server",
"zf2"
],
- "time": "2016-06-20T22:27:55+00:00"
+ "time": "2016-06-20 22:27:55"
},
{
"name": "zendframework/zend-servicemanager",
@@ -3478,7 +3479,7 @@
"servicemanager",
"zf2"
],
- "time": "2017-12-05T16:27:36+00:00"
+ "time": "2017-12-05 16:27:36"
},
{
"name": "zendframework/zend-session",
@@ -3548,7 +3549,7 @@
"session",
"zf"
],
- "time": "2017-12-01T17:35:04+00:00"
+ "time": "2017-12-01 17:35:04"
},
{
"name": "zendframework/zend-soap",
@@ -3600,7 +3601,7 @@
"soap",
"zf2"
],
- "time": "2016-04-21T16:06:27+00:00"
+ "time": "2016-04-21 16:06:27"
},
{
"name": "zendframework/zend-stdlib",
@@ -3659,7 +3660,7 @@
"stdlib",
"zf2"
],
- "time": "2016-04-12T21:17:31+00:00"
+ "time": "2016-04-12 21:17:31"
},
{
"name": "zendframework/zend-text",
@@ -3706,7 +3707,7 @@
"text",
"zf2"
],
- "time": "2016-02-08T19:03:52+00:00"
+ "time": "2016-02-08 19:03:52"
},
{
"name": "zendframework/zend-uri",
@@ -3753,7 +3754,7 @@
"uri",
"zf2"
],
- "time": "2016-02-17T22:38:51+00:00"
+ "time": "2016-02-17 22:38:51"
},
{
"name": "zendframework/zend-validator",
@@ -3824,7 +3825,7 @@
"validator",
"zf2"
],
- "time": "2017-08-22T14:19:23+00:00"
+ "time": "2017-08-22 14:19:23"
},
{
"name": "zendframework/zend-view",
@@ -3911,7 +3912,7 @@
"view",
"zf2"
],
- "time": "2018-01-17T22:21:50+00:00"
+ "time": "2018-01-17 22:21:50"
}
],
"packages-dev": [
@@ -3967,7 +3968,7 @@
"constructor",
"instantiate"
],
- "time": "2015-06-14T21:17:01+00:00"
+ "time": "2015-06-14 21:17:01"
},
{
"name": "friendsofphp/php-cs-fixer",
@@ -4037,7 +4038,7 @@
}
],
"description": "A tool to automatically fix PHP code style",
- "time": "2017-03-31T12:59:38+00:00"
+ "time": "2017-03-31 12:59:38"
},
{
"name": "ircmaxell/password-compat",
@@ -4079,7 +4080,7 @@
"hashing",
"password"
],
- "time": "2014-11-20T16:49:30+00:00"
+ "time": "2014-11-20 16:49:30"
},
{
"name": "lusitanian/oauth",
@@ -4146,7 +4147,7 @@
"oauth",
"security"
],
- "time": "2016-07-12T22:15:40+00:00"
+ "time": "2016-07-12 22:15:40"
},
{
"name": "myclabs/deep-copy",
@@ -4191,7 +4192,7 @@
"object",
"object graph"
],
- "time": "2017-10-19T19:58:43+00:00"
+ "time": "2017-10-19 19:58:43"
},
{
"name": "pdepend/pdepend",
@@ -4231,7 +4232,7 @@
"BSD-3-Clause"
],
"description": "Official version of pdepend to be handled with Composer",
- "time": "2017-01-19T14:23:36+00:00"
+ "time": "2017-01-19 14:23:36"
},
{
"name": "phar-io/manifest",
@@ -4286,7 +4287,7 @@
}
],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
- "time": "2017-03-05T18:14:27+00:00"
+ "time": "2017-03-05 18:14:27"
},
{
"name": "phar-io/version",
@@ -4333,7 +4334,7 @@
}
],
"description": "Library for handling version information and constraints",
- "time": "2017-03-05T17:38:23+00:00"
+ "time": "2017-03-05 17:38:23"
},
{
"name": "phpdocumentor/reflection-common",
@@ -4387,7 +4388,7 @@
"reflection",
"static analysis"
],
- "time": "2017-09-11T18:02:19+00:00"
+ "time": "2017-09-11 18:02:19"
},
{
"name": "phpdocumentor/reflection-docblock",
@@ -4438,7 +4439,7 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
- "time": "2017-11-27T17:38:31+00:00"
+ "time": "2017-11-27 17:38:31"
},
{
"name": "phpdocumentor/type-resolver",
@@ -4485,7 +4486,7 @@
"email": "me@mikevanriel.com"
}
],
- "time": "2017-07-14T14:27:02+00:00"
+ "time": "2017-07-14 14:27:02"
},
{
"name": "phpmd/phpmd",
@@ -4551,7 +4552,7 @@
"phpmd",
"pmd"
],
- "time": "2017-01-20T14:41:10+00:00"
+ "time": "2017-01-20 14:41:10"
},
{
"name": "phpspec/prophecy",
@@ -4614,7 +4615,7 @@
"spy",
"stub"
],
- "time": "2017-11-24T13:59:53+00:00"
+ "time": "2017-11-24 13:59:53"
},
{
"name": "phpunit/php-code-coverage",
@@ -4677,7 +4678,7 @@
"testing",
"xunit"
],
- "time": "2017-12-06T09:29:45+00:00"
+ "time": "2017-12-06 09:29:45"
},
{
"name": "phpunit/php-file-iterator",
@@ -4724,7 +4725,7 @@
"filesystem",
"iterator"
],
- "time": "2017-11-27T13:52:08+00:00"
+ "time": "2017-11-27 13:52:08"
},
{
"name": "phpunit/php-text-template",
@@ -4765,7 +4766,7 @@
"keywords": [
"template"
],
- "time": "2015-06-21T13:50:34+00:00"
+ "time": "2015-06-21 13:50:34"
},
{
"name": "phpunit/php-timer",
@@ -4814,7 +4815,7 @@
"keywords": [
"timer"
],
- "time": "2017-02-26T11:10:40+00:00"
+ "time": "2017-02-26 11:10:40"
},
{
"name": "phpunit/php-token-stream",
@@ -4863,7 +4864,7 @@
"keywords": [
"tokenizer"
],
- "time": "2017-11-27T05:48:46+00:00"
+ "time": "2017-11-27 05:48:46"
},
{
"name": "phpunit/phpunit",
@@ -4947,7 +4948,7 @@
"testing",
"xunit"
],
- "time": "2017-08-03T13:59:28+00:00"
+ "time": "2017-08-03 13:59:28"
},
{
"name": "phpunit/phpunit-mock-objects",
@@ -5006,7 +5007,7 @@
"mock",
"xunit"
],
- "time": "2017-08-03T14:08:16+00:00"
+ "time": "2017-08-03 14:08:16"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@@ -5051,7 +5052,7 @@
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
- "time": "2017-03-04T06:30:41+00:00"
+ "time": "2017-03-04 06:30:41"
},
{
"name": "sebastian/comparator",
@@ -5115,7 +5116,7 @@
"compare",
"equality"
],
- "time": "2017-03-03T06:26:08+00:00"
+ "time": "2017-03-03 06:26:08"
},
{
"name": "sebastian/diff",
@@ -5167,7 +5168,7 @@
"keywords": [
"diff"
],
- "time": "2017-05-22T07:24:03+00:00"
+ "time": "2017-05-22 07:24:03"
},
{
"name": "sebastian/environment",
@@ -5217,7 +5218,7 @@
"environment",
"hhvm"
],
- "time": "2017-07-01T08:51:00+00:00"
+ "time": "2017-07-01 08:51:00"
},
{
"name": "sebastian/exporter",
@@ -5284,7 +5285,7 @@
"export",
"exporter"
],
- "time": "2017-04-03T13:19:02+00:00"
+ "time": "2017-04-03 13:19:02"
},
{
"name": "sebastian/finder-facade",
@@ -5323,7 +5324,7 @@
],
"description": "FinderFacade is a convenience wrapper for Symfony's Finder component.",
"homepage": "https://github.com/sebastianbergmann/finder-facade",
- "time": "2017-11-18T17:31:49+00:00"
+ "time": "2017-11-18 17:31:49"
},
{
"name": "sebastian/global-state",
@@ -5374,7 +5375,7 @@
"keywords": [
"global state"
],
- "time": "2017-04-27T15:39:26+00:00"
+ "time": "2017-04-27 15:39:26"
},
{
"name": "sebastian/object-enumerator",
@@ -5421,7 +5422,7 @@
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
- "time": "2017-08-03T12:35:26+00:00"
+ "time": "2017-08-03 12:35:26"
},
{
"name": "sebastian/object-reflector",
@@ -5466,7 +5467,7 @@
],
"description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
- "time": "2017-03-29T09:07:27+00:00"
+ "time": "2017-03-29 09:07:27"
},
{
"name": "sebastian/phpcpd",
@@ -5517,7 +5518,7 @@
],
"description": "Copy/Paste Detector (CPD) for PHP code.",
"homepage": "https://github.com/sebastianbergmann/phpcpd",
- "time": "2016-04-17T19:32:49+00:00"
+ "time": "2016-04-17 19:32:49"
},
{
"name": "sebastian/recursion-context",
@@ -5570,7 +5571,7 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
- "time": "2017-03-03T06:23:57+00:00"
+ "time": "2017-03-03 06:23:57"
},
{
"name": "sebastian/resource-operations",
@@ -5612,7 +5613,7 @@
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
- "time": "2015-07-28T20:34:47+00:00"
+ "time": "2015-07-28 20:34:47"
},
{
"name": "sebastian/version",
@@ -5655,7 +5656,7 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
- "time": "2016-10-03T07:35:21+00:00"
+ "time": "2016-10-03 07:35:21"
},
{
"name": "squizlabs/php_codesniffer",
@@ -5706,7 +5707,7 @@
"phpcs",
"standards"
],
- "time": "2017-06-14T01:23:49+00:00"
+ "time": "2017-06-14 01:23:49"
},
{
"name": "symfony/config",
@@ -5768,7 +5769,7 @@
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
- "time": "2018-01-03T07:37:34+00:00"
+ "time": "2018-01-03 07:37:34"
},
{
"name": "symfony/dependency-injection",
@@ -5839,7 +5840,7 @@
],
"description": "Symfony DependencyInjection Component",
"homepage": "https://symfony.com",
- "time": "2018-01-04T15:56:45+00:00"
+ "time": "2018-01-04 15:56:45"
},
{
"name": "symfony/polyfill-php54",
@@ -5897,7 +5898,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/polyfill-php55",
@@ -5953,7 +5954,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/polyfill-php70",
@@ -6012,7 +6013,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/polyfill-php72",
@@ -6067,7 +6068,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/polyfill-xml",
@@ -6115,7 +6116,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/stopwatch",
@@ -6164,7 +6165,7 @@
],
"description": "Symfony Stopwatch Component",
"homepage": "https://symfony.com",
- "time": "2018-01-03T07:37:34+00:00"
+ "time": "2018-01-03 07:37:34"
},
{
"name": "theseer/fdomdocument",
@@ -6204,7 +6205,7 @@
],
"description": "The classes contained within this repository extend the standard DOM to use exceptions at all occasions of errors instead of PHP warnings or notices. They also add various custom methods and shortcuts for convenience and to simplify the usage of DOM.",
"homepage": "https://github.com/theseer/fDOMDocument",
- "time": "2017-06-30T11:53:12+00:00"
+ "time": "2017-06-30 11:53:12"
},
{
"name": "theseer/tokenizer",
@@ -6244,7 +6245,7 @@
}
],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
- "time": "2017-04-07T12:08:54+00:00"
+ "time": "2017-04-07 12:08:54"
},
{
"name": "webmozart/assert",
@@ -6294,7 +6295,7 @@
"check",
"validate"
],
- "time": "2016-11-23T20:04:58+00:00"
+ "time": "2016-11-23 20:04:58"
}
],
"aliases": [],
From c333be1e6834139df454ada123fe5f1d7c3dc08f Mon Sep 17 00:00:00 2001
From: Joan He
Date: Mon, 22 Jan 2018 10:45:54 -0600
Subject: [PATCH 223/225] MAGETWO-72487: Move Signifyd to CE
-- These files are removed in MAGETWO-71615
---
.../view/adminhtml/web/js/packages.js | 39 -----------------
.../adminhtml/js/request-send.test.js | 43 -------------------
2 files changed, 82 deletions(-)
delete mode 100644 app/code/Magento/Shipping/view/adminhtml/web/js/packages.js
delete mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/adminhtml/js/request-send.test.js
diff --git a/app/code/Magento/Shipping/view/adminhtml/web/js/packages.js b/app/code/Magento/Shipping/view/adminhtml/web/js/packages.js
deleted file mode 100644
index f46ad4192d170..0000000000000
--- a/app/code/Magento/Shipping/view/adminhtml/web/js/packages.js
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
-
-define([
- 'jquery',
- 'Magento_Ui/js/modal/modal',
- 'mage/translate'
-], function ($, modal, $t) {
- 'use strict';
-
- return function (config, element) {
- config.buttons = [
- {
- text: $t('Print'),
- 'class': 'action action-primary',
-
- /**
- * Click handler
- */
- click: function () {
- window.location.href = this.options.url;
- }
- }, {
- text: $t('Cancel'),
- 'class': 'action action-secondary',
-
- /**
- * Click handler
- */
- click: function () {
- this.closeModal();
- }
- }
- ];
- modal(config, element);
- };
-});
diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/adminhtml/js/request-send.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/adminhtml/js/request-send.test.js
deleted file mode 100644
index b545314a2e7c8..0000000000000
--- a/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/adminhtml/js/request-send.test.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Copyright © 2013-2017 Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
-
-define([
- 'mageUtils',
- 'Magento_Signifyd/js/request-send'
-], function (utils, RequestButton) {
- 'use strict';
-
- describe('Check Signifyd UI component button', function () {
- var button,
- requestURL = '/url',
- requestData = {
- 'order_id': 1
- };
-
- beforeEach(function () {
- button = new RequestButton({
- requestURL: requestURL,
- data: requestData
- });
-
- spyOn(utils, 'submit');
- button.sendRequest();
- });
-
- it('checks if method sendRequest exists', function () {
- expect(button.sendRequest).toBeDefined();
- expect(typeof button.sendRequest).toBe('function');
- });
-
- it('checks if request submited', function () {
- expect(utils.submit).toHaveBeenCalledWith(
- {
- url: requestURL,
- data: requestData
- }
- );
- });
- });
-});
From 59ec4cf0910d83c20be1e81f5579ca6e7a602d91 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Tue, 6 Feb 2018 08:23:02 -0600
Subject: [PATCH 224/225] MAGETWO-72487: Move Signifyd to CE
-- Resolve merge conflict with declarative schema change
---
app/code/Magento/Signifyd/etc/db_schema.xml | 42 +++++++++++++++++++
.../Signifyd/etc/db_schema_whitelist.json | 28 +++++++++++++
2 files changed, 70 insertions(+)
create mode 100644 app/code/Magento/Signifyd/etc/db_schema.xml
create mode 100644 app/code/Magento/Signifyd/etc/db_schema_whitelist.json
diff --git a/app/code/Magento/Signifyd/etc/db_schema.xml b/app/code/Magento/Signifyd/etc/db_schema.xml
new file mode 100644
index 0000000000000..731ae1e94b2bb
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/db_schema.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/db_schema_whitelist.json b/app/code/Magento/Signifyd/etc/db_schema_whitelist.json
new file mode 100644
index 0000000000000..31f753dbb3b39
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/db_schema_whitelist.json
@@ -0,0 +1,28 @@
+{
+ "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
From 52abb74c38ec0b1ca5f21933cb955692ad5a820e Mon Sep 17 00:00:00 2001
From: Joan He
Date: Tue, 6 Feb 2018 11:35:49 -0600
Subject: [PATCH 225/225] MAGETWO-72487: Move Signifyd to CE
-- Resolve merge conflict with declarative schema change
---
.../Magento/Signifyd/Setup/InstallSchema.php | 106 ------------------
1 file changed, 106 deletions(-)
delete mode 100644 app/code/Magento/Signifyd/Setup/InstallSchema.php
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
deleted file mode 100644
index 101afd584484a..0000000000000
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ /dev/null
@@ -1,106 +0,0 @@
-startSetup()->getConnection(self::$connectionName);
-
- $table = $connection->newTable($setup->getTable(static::$table));
- $table->addColumn(
- 'entity_id',
- Table::TYPE_INTEGER,
- null,
- ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true]
- );
- $table->addColumn('order_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
- $table->addColumn('case_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
- $table->addColumn('guarantee_eligible', Table::TYPE_BOOLEAN, null);
- $table->addColumn(
- 'guarantee_disposition',
- Table::TYPE_TEXT,
- 32,
- ['default' => CaseInterface::GUARANTEE_PENDING]
- );
- $table->addColumn('status', Table::TYPE_TEXT, 32, ['default' => CaseInterface::STATUS_PENDING]);
- $table->addColumn('score', Table::TYPE_INTEGER, null, ['unsigned' => true]);
- $table->addColumn('associated_team', Table::TYPE_TEXT, '64k');
- $table->addColumn('review_disposition', Table::TYPE_TEXT, 32);
- $table->addColumn('created_at', Table::TYPE_TIMESTAMP);
- $table->addColumn('updated_at', Table::TYPE_TIMESTAMP);
-
- $table->addIndex(
- $setup->getIdxName(
- $setup->getTable(static::$table),
- 'order_id',
- AdapterInterface::INDEX_TYPE_UNIQUE
- ),
- 'order_id',
- ['type' => AdapterInterface::INDEX_TYPE_UNIQUE]
- );
-
- $table->addIndex(
- $setup->getIdxName(
- $setup->getTable(static::$table),
- 'case_id',
- AdapterInterface::INDEX_TYPE_UNIQUE
- ),
- 'case_id',
- ['type' => AdapterInterface::INDEX_TYPE_UNIQUE]
- );
-
- $table->addForeignKey(
- $setup->getFkName(
- $setup->getTable(static::$table),
- 'order_id',
- $setup->getTable('sales_order'),
- 'entity_id'
- ),
- 'order_id',
- $setup->getTable('sales_order'),
- 'entity_id',
- Table::ACTION_SET_NULL
- );
-
- $connection->createTable($table);
-
- $connection->addColumn(
- $setup->getTable('sales_order_grid'),
- 'signifyd_guarantee_status',
- [
- 'type' => Table::TYPE_TEXT,
- 'length' => 32,
- 'comment' => 'Signifyd Guarantee Disposition Status'
- ]
- );
- }
-}