From f7ff291e51c39d238cacb4540d2a554457be613c Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Thu, 8 Dec 2016 15:52:57 +0200
Subject: [PATCH 0001/2045] MAGETWO-61910: Create module and configuration
---
LICENSE.txt | 48 ++++++++++++++++++++++++++++++++++++++++
LICENSE_AFL.txt | 48 ++++++++++++++++++++++++++++++++++++++++
README.md | 1 +
composer.json | 22 ++++++++++++++++++
etc/acl.xml | 22 ++++++++++++++++++
etc/adminhtml/system.xml | 42 +++++++++++++++++++++++++++++++++++
etc/config.xml | 15 +++++++++++++
etc/frontend/routes.xml | 14 ++++++++++++
etc/module.xml | 14 ++++++++++++
registration.php | 11 +++++++++
10 files changed, 237 insertions(+)
create mode 100644 LICENSE.txt
create mode 100644 LICENSE_AFL.txt
create mode 100644 README.md
create mode 100644 composer.json
create mode 100644 etc/acl.xml
create mode 100644 etc/adminhtml/system.xml
create mode 100644 etc/config.xml
create mode 100644 etc/frontend/routes.xml
create mode 100644 etc/module.xml
create mode 100644 registration.php
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000000000..49525fd99da9c
--- /dev/null
+++ b/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/LICENSE_AFL.txt b/LICENSE_AFL.txt
new file mode 100644
index 0000000000000..f39d641b18a19
--- /dev/null
+++ b/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/README.md b/README.md
new file mode 100644
index 0000000000000..3cd2b4a30a858
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+The Magento_Signifyd module implements the integration with the Signifyd fraud prevention service.
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000000000..9f0c56a845f37
--- /dev/null
+++ b/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/etc/acl.xml b/etc/acl.xml
new file mode 100644
index 0000000000000..ab6db0dce88c2
--- /dev/null
+++ b/etc/acl.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
new file mode 100644
index 0000000000000..dd858612d132d
--- /dev/null
+++ b/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
+ siginifyd/active
+
+
+ API key
+ http://signifyd.com/settings/teams after you create a Signifyd account]]>
+ signifyd/api_key
+ Magento\Config\Model\Config\Backend\Encrypted
+
+
+ API URL
+ signifyd/api_url
+
+ Don’t change unless asked to do so.
+
+
+
+ Debug
+ Magento\Config\Model\Config\Source\Yesno
+ signifyd/debug
+
+
+
+
+
diff --git a/etc/config.xml b/etc/config.xml
new file mode 100644
index 0000000000000..b16f0903c2d1f
--- /dev/null
+++ b/etc/config.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+ 0
+ https://api.signifiyd.com/v2/
+
+
+
diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml
new file mode 100644
index 0000000000000..8a6c5b4e22c1d
--- /dev/null
+++ b/etc/frontend/routes.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/etc/module.xml b/etc/module.xml
new file mode 100644
index 0000000000000..f4d3bc9cac93c
--- /dev/null
+++ b/etc/module.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/registration.php b/registration.php
new file mode 100644
index 0000000000000..d7c40b5aa176a
--- /dev/null
+++ b/registration.php
@@ -0,0 +1,11 @@
+
Date: Thu, 8 Dec 2016 17:55:49 +0200
Subject: [PATCH 0002/2045] MAGETWO-61910: Create module and configuration
---
etc/module.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/etc/module.xml b/etc/module.xml
index f4d3bc9cac93c..1ee26044bbef4 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -8,7 +8,7 @@
-
+
From 4554d08a23e7e026e4e7f5998aa97b118acaf86d Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 9 Dec 2016 10:31:15 +0200
Subject: [PATCH 0003/2045] MAGETWO-61913: Create request builders
- Create builder interface
---
Model/Request/CreateCaseBuilder.php | 34 +++++++
Model/Request/CreateCaseBuilderInterface.php | 20 ++++
Model/Request/PurchaseBuilder.php | 102 +++++++++++++++++++
3 files changed, 156 insertions(+)
create mode 100644 Model/Request/CreateCaseBuilder.php
create mode 100644 Model/Request/CreateCaseBuilderInterface.php
create mode 100644 Model/Request/PurchaseBuilder.php
diff --git a/Model/Request/CreateCaseBuilder.php b/Model/Request/CreateCaseBuilder.php
new file mode 100644
index 0000000000000..055f78aa401b9
--- /dev/null
+++ b/Model/Request/CreateCaseBuilder.php
@@ -0,0 +1,34 @@
+purchaseBuilder = $purchaseBuilder;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function build($orderId)
+ {
+ return $this->purchaseBuilder;
+ }
+}
diff --git a/Model/Request/CreateCaseBuilderInterface.php b/Model/Request/CreateCaseBuilderInterface.php
new file mode 100644
index 0000000000000..63a302509cf76
--- /dev/null
+++ b/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 2bea0201cbea13881f40b90da7008fcc595911a3 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 9 Dec 2016 17:06:57 +0200
Subject: [PATCH 0004/2045] MAGETWO-61967: Generate orderSessionId on backend
---
Model/OrderSessionId.php | 56 ++++++++++++++++++++
Model/Ui/ConfigProvider.php | 46 ++++++++++++++++
Test/Unit/Model/OrderSessionIdTest.php | 62 ++++++++++++++++++++++
Test/Unit/Model/Ui/ConfigProviderTest.php | 64 +++++++++++++++++++++++
etc/frontend/di.xml | 16 ++++++
5 files changed, 244 insertions(+)
create mode 100644 Model/OrderSessionId.php
create mode 100644 Model/Ui/ConfigProvider.php
create mode 100644 Test/Unit/Model/OrderSessionIdTest.php
create mode 100644 Test/Unit/Model/Ui/ConfigProviderTest.php
create mode 100644 etc/frontend/di.xml
diff --git a/Model/OrderSessionId.php b/Model/OrderSessionId.php
new file mode 100644
index 0000000000000..22be3c6911493
--- /dev/null
+++ b/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/Model/Ui/ConfigProvider.php b/Model/Ui/ConfigProvider.php
new file mode 100644
index 0000000000000..4b690a0234e1d
--- /dev/null
+++ b/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/Test/Unit/Model/OrderSessionIdTest.php b/Test/Unit/Model/OrderSessionIdTest.php
new file mode 100644
index 0000000000000..7057956a8edaf
--- /dev/null
+++ b/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/Test/Unit/Model/Ui/ConfigProviderTest.php b/Test/Unit/Model/Ui/ConfigProviderTest.php
new file mode 100644
index 0000000000000..66e7f8be34b19
--- /dev/null
+++ b/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/etc/frontend/di.xml b/etc/frontend/di.xml
new file mode 100644
index 0000000000000..a81fde778a02a
--- /dev/null
+++ b/etc/frontend/di.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+ - Magento\Signifyd\Model\Ui\ConfigProvider
+
+
+
+
From 627f2be41c177b19268e44352e7fa0e14825ea45 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 12 Dec 2016 11:16:56 +0200
Subject: [PATCH 0005/2045] MAGETWO-61913: Create request builders
- Creates card, recipient and purchase builders
---
Model/Request/AddressBuilder.php | 44 ++++++++++
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 Model/Request/AddressBuilder.php
create mode 100644 Model/Request/CardBuilder.php
create mode 100644 Model/Request/RecipientBuilder.php
diff --git a/Model/Request/AddressBuilder.php b/Model/Request/AddressBuilder.php
new file mode 100644
index 0000000000000..621058e7f2c67
--- /dev/null
+++ b/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/Model/Request/CardBuilder.php b/Model/Request/CardBuilder.php
new file mode 100644
index 0000000000000..ec3e08f428b50
--- /dev/null
+++ b/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/Model/Request/CreateCaseBuilder.php b/Model/Request/CreateCaseBuilder.php
index 055f78aa401b9..346aa7a91465e 100644
--- a/Model/Request/CreateCaseBuilder.php
+++ b/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/Model/Request/PurchaseBuilder.php b/Model/Request/PurchaseBuilder.php
index ca1560d65c44a..46e691b8032f9 100644
--- a/Model/Request/PurchaseBuilder.php
+++ b/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/Model/Request/RecipientBuilder.php b/Model/Request/RecipientBuilder.php
new file mode 100644
index 0000000000000..38cb79d32de2b
--- /dev/null
+++ b/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 296e56e710d2f97ce6f35c923b959d4f2e61a63c Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 12:16:39 +0200
Subject: [PATCH 0006/2045] MAGETWO-61967: Generate orderSessionId on backend
- Added Checkout module dependency
---
composer.json | 3 ++-
etc/module.xml | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 9f0c56a845f37..cc8bd9d228508 100644
--- a/composer.json
+++ b/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/etc/module.xml b/etc/module.xml
index 1ee26044bbef4..82eb61e9ff0a8 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -9,6 +9,7 @@
+
From 6fc4fa2df393f1403343bda1581c28ccecca2dc7 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 12 Dec 2016 13:00:00 +0200
Subject: [PATCH 0007/2045] MAGETWO-61925: Create case entity infrastructure
- Added API interfaces for Sygnifyd integration
- Added implementation of API interfaces
- Covered Sygnifyd management by integration tests
---
Api/CaseManagementInterface.php | 31 +++++
Api/CaseRepositoryInterface.php | 32 +++++
Api/Data/CaseInterface.php | 227 ++++++++++++++++++++++++++++++++
Model/CaseEntity.php | 205 ++++++++++++++++++++++++++++
Model/CaseManagement.php | 57 ++++++++
Model/CaseRepository.php | 56 ++++++++
Setup/InstallSchema.php | 64 +++++++++
etc/constraints.xml | 14 ++
etc/di.xml | 39 ++++++
i18n/en_US.csv | 13 ++
10 files changed, 738 insertions(+)
create mode 100644 Api/CaseManagementInterface.php
create mode 100644 Api/CaseRepositoryInterface.php
create mode 100644 Api/Data/CaseInterface.php
create mode 100644 Model/CaseEntity.php
create mode 100644 Model/CaseManagement.php
create mode 100644 Model/CaseRepository.php
create mode 100644 Setup/InstallSchema.php
create mode 100644 etc/constraints.xml
create mode 100644 etc/di.xml
create mode 100644 i18n/en_US.csv
diff --git a/Api/CaseManagementInterface.php b/Api/CaseManagementInterface.php
new file mode 100644
index 0000000000000..c4d6005011b93
--- /dev/null
+++ b/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/Model/CaseManagement.php b/Model/CaseManagement.php
new file mode 100644
index 0000000000000..9269d8622dfab
--- /dev/null
+++ b/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/Model/CaseRepository.php b/Model/CaseRepository.php
new file mode 100644
index 0000000000000..916cbe6136817
--- /dev/null
+++ b/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/Setup/InstallSchema.php b/Setup/InstallSchema.php
new file mode 100644
index 0000000000000..c12399e669394
--- /dev/null
+++ b/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/etc/constraints.xml b/etc/constraints.xml
new file mode 100644
index 0000000000000..4947f84a5adc9
--- /dev/null
+++ b/etc/constraints.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/etc/di.xml b/etc/di.xml
new file mode 100644
index 0000000000000..3abcaad08a639
--- /dev/null
+++ b/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/i18n/en_US.csv b/i18n/en_US.csv
new file mode 100644
index 0000000000000..2785e217040ca
--- /dev/null
+++ b/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
From 90e49d96cace62ad35e99ca5d1d5cfcdb310074b Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 12 Dec 2016 13:00:00 +0200
Subject: [PATCH 0008/2045] MAGETWO-61925: Create case entity infrastructure
- Added API interfaces for Sygnifyd integration
- Added implementation of API interfaces
- Covered Sygnifyd management by integration tests
---
Model/CaseManagementTest.php | 93 ++++++++++++++++++++++++++++++++++++
_files/case.php | 31 ++++++++++++
2 files changed, 124 insertions(+)
create mode 100644 Model/CaseManagementTest.php
create mode 100644 _files/case.php
diff --git a/Model/CaseManagementTest.php b/Model/CaseManagementTest.php
new file mode 100644
index 0000000000000..c81a18a8afc99
--- /dev/null
+++ b/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/_files/case.php b/_files/case.php
new file mode 100644
index 0000000000000..2ec61edef8f39
--- /dev/null
+++ b/_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 c9e43610a1ab9e926e0ecc581dd0e26947d575cd Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 12 Dec 2016 13:15:19 +0200
Subject: [PATCH 0009/2045] MAGETWO-61925: Create case entity infrastructure
- Fixed failed static tests
---
Api/Data/CaseInterface.php | 4 +++-
Model/CaseEntity.php | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/Api/Data/CaseInterface.php b/Api/Data/CaseInterface.php
index 1a1358836003f..f1c4980d7fe2a 100644
--- a/Api/Data/CaseInterface.php
+++ b/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/Model/CaseEntity.php b/Model/CaseEntity.php
index 05f77fa752547..4dd028e5b74ab 100644
--- a/Model/CaseEntity.php
+++ b/Model/CaseEntity.php
@@ -50,7 +50,7 @@ public function setCaseId($id)
/**
* @inheritdoc
*/
- public function getGuaranteeEligible()
+ public function isGuaranteeEligible()
{
return $this->getData('guarantee_eligible');
}
From dde35f995170d5deefaa70ef628170ebd409c5c7 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 12 Dec 2016 13:15:19 +0200
Subject: [PATCH 0010/2045] MAGETWO-61925: Create case entity infrastructure
- Fixed failed static tests
---
_files/case.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/_files/case.php b/_files/case.php
index 2ec61edef8f39..148c831a9f2d7 100644
--- a/_files/case.php
+++ b/_files/case.php
@@ -28,4 +28,3 @@
/** @var CaseRepositoryInterface $caseRepository */
$caseRepository = $objectManager->get(CaseRepositoryInterface::class);
$caseRepository->save($case);
-
From 0fcabe6af50887ed3c85c89f2872edf77e9ec290 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 12 Dec 2016 13:26:08 +0200
Subject: [PATCH 0011/2045] MAGETWO-61925: Create case entity infrastructure
- Fixed failed static test
---
Api/Data/CaseInterface.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/Api/Data/CaseInterface.php b/Api/Data/CaseInterface.php
index f1c4980d7fe2a..9a85652f3d57c 100644
--- a/Api/Data/CaseInterface.php
+++ b/Api/Data/CaseInterface.php
@@ -40,6 +40,7 @@ interface CaseInterface
/**#@+
* Constants for guarantee available statuses
*/
+
/**
* Approved status
*/
From 51bc32fa3c9269616ee1a8035199788472c30218 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 13:48:33 +0200
Subject: [PATCH 0012/2045] MAGETWO-61967: Generate orderSessionId on backend
- Removed hard dependency on checkout session
- Used identity generator instead of sha1 hash
---
Model/OrderSessionId.php | 30 ++++++++++++++-------
Model/Ui/ConfigProvider.php | 2 +-
Test/Unit/Model/OrderSessionIdTest.php | 33 ++++++++++++++++-------
Test/Unit/Model/Ui/ConfigProviderTest.php | 4 +--
etc/adminhtml/di.xml | 14 ++++++++++
etc/frontend/di.xml | 5 ++++
6 files changed, 66 insertions(+), 22 deletions(-)
create mode 100644 etc/adminhtml/di.xml
diff --git a/Model/OrderSessionId.php b/Model/OrderSessionId.php
index 22be3c6911493..96356f81dd287 100644
--- a/Model/OrderSessionId.php
+++ b/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/Model/Ui/ConfigProvider.php b/Model/Ui/ConfigProvider.php
index 4b690a0234e1d..af6555a4329db 100644
--- a/Model/Ui/ConfigProvider.php
+++ b/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/Test/Unit/Model/OrderSessionIdTest.php b/Test/Unit/Model/OrderSessionIdTest.php
index 7057956a8edaf..32a8e3b6a7426 100644
--- a/Test/Unit/Model/OrderSessionIdTest.php
+++ b/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/Test/Unit/Model/Ui/ConfigProviderTest.php b/Test/Unit/Model/Ui/ConfigProviderTest.php
index 66e7f8be34b19..bfae3b8773cba 100644
--- a/Test/Unit/Model/Ui/ConfigProviderTest.php
+++ b/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/etc/adminhtml/di.xml b/etc/adminhtml/di.xml
new file mode 100644
index 0000000000000..2509a0be47376
--- /dev/null
+++ b/etc/adminhtml/di.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+ Magento\Backend\Model\Session\Quote
+
+
+
diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml
index a81fde778a02a..b5a97f00ac3a4 100644
--- a/etc/frontend/di.xml
+++ b/etc/frontend/di.xml
@@ -13,4 +13,9 @@
+
+
+ Magento\Checkout\Model\Session
+
+
From ca29d32198ec597cd1a122f5c6ac9863e808277a Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 13:55:44 +0200
Subject: [PATCH 0013/2045] MAGETWO-61967: Generate orderSessionId on backend
- Removed module.xml dependency
---
Test/Unit/Model/Ui/ConfigProviderTest.php | 2 +-
etc/module.xml | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/Test/Unit/Model/Ui/ConfigProviderTest.php b/Test/Unit/Model/Ui/ConfigProviderTest.php
index bfae3b8773cba..99f4c23e70cbd 100644
--- a/Test/Unit/Model/Ui/ConfigProviderTest.php
+++ b/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/etc/module.xml b/etc/module.xml
index 82eb61e9ff0a8..1ee26044bbef4 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -9,7 +9,6 @@
-
From 6d35e089a30d500f68f3ffdaee8e6a00c6e13119 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 12 Dec 2016 15:22:42 +0200
Subject: [PATCH 0014/2045] MAGETWO-61910: Create module and configuration
- fix for static tests
---
etc/adminhtml/system.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index dd858612d132d..0d0cc7e2cacea 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -16,17 +16,17 @@
Enable this Solution
Magento\Config\Model\Config\Source\Yesno
- siginifyd/active
+ fraud_protection/siginifyd/active
- API key
+ API Key
http://signifyd.com/settings/teams after you create a Signifyd account]]>
signifyd/api_key
Magento\Config\Model\Config\Backend\Encrypted
API URL
- signifyd/api_url
+ fraud_protection/signifyd/api_url
Don’t change unless asked to do so.
@@ -34,7 +34,7 @@
Debug
Magento\Config\Model\Config\Source\Yesno
- signifyd/debug
+ fraud_protection/signifyd/debug
From 0237a5bf1d6f9b99f21c4518c829fa45e77a94b8 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 12 Dec 2016 16:50:26 +0200
Subject: [PATCH 0015/2045] MAGETWO-61910: Create module and configuration
- fix for static tests
---
etc/adminhtml/system.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 0d0cc7e2cacea..14ae7d73e0e48 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -16,12 +16,12 @@
Enable this Solution
Magento\Config\Model\Config\Source\Yesno
- fraud_protection/siginifyd/active
+ fraud_protection/signifyd/active
API Key
http://signifyd.com/settings/teams after you create a Signifyd account]]>
- signifyd/api_key
+ fraud_protection/signifyd/api_key
Magento\Config\Model\Config\Backend\Encrypted
From 8fcbd35dfd8d84dec5e225ec3476d88b8bc103ff Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 12 Dec 2016 19:35:10 +0200
Subject: [PATCH 0016/2045] MAGETWO-61913: Create request builders
- Add seller, clientVersion and userAccount builders
---
Model/Request/AddressBuilder.php | 2 +-
Model/Request/ClientVersionBuilder.php | 43 +++++++
Model/Request/CreateCaseBuilder.php | 34 ++++-
Model/Request/CustomerOrders.php | 66 ++++++++++
Model/Request/PurchaseBuilder.php | 4 +-
Model/Request/SellerBuilder.php | 85 +++++++++++++
Model/Request/UserAccountBuilder.php | 168 +++++++++++++++++++++++++
7 files changed, 396 insertions(+), 6 deletions(-)
create mode 100644 Model/Request/ClientVersionBuilder.php
create mode 100644 Model/Request/CustomerOrders.php
create mode 100644 Model/Request/SellerBuilder.php
create mode 100644 Model/Request/UserAccountBuilder.php
diff --git a/Model/Request/AddressBuilder.php b/Model/Request/AddressBuilder.php
index 621058e7f2c67..2d2b4ac28f6f2 100644
--- a/Model/Request/AddressBuilder.php
+++ b/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/Model/Request/ClientVersionBuilder.php b/Model/Request/ClientVersionBuilder.php
new file mode 100644
index 0000000000000..4c8f4e843163a
--- /dev/null
+++ b/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/Model/Request/CreateCaseBuilder.php b/Model/Request/CreateCaseBuilder.php
index 346aa7a91465e..926c5354af57a 100644
--- a/Model/Request/CreateCaseBuilder.php
+++ b/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/Model/Request/CustomerOrders.php b/Model/Request/CustomerOrders.php
new file mode 100644
index 0000000000000..26322a745b8ee
--- /dev/null
+++ b/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/Model/Request/PurchaseBuilder.php b/Model/Request/PurchaseBuilder.php
index 46e691b8032f9..215c5f39a172d 100644
--- a/Model/Request/PurchaseBuilder.php
+++ b/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/Model/Request/SellerBuilder.php b/Model/Request/SellerBuilder.php
new file mode 100644
index 0000000000000..62977c6d81e51
--- /dev/null
+++ b/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/Model/Request/UserAccountBuilder.php b/Model/Request/UserAccountBuilder.php
new file mode 100644
index 0000000000000..198b57d3e238e
--- /dev/null
+++ b/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 064b2b398c72270a569e094a076d79b56661f319 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 9 Dec 2016 17:06:57 +0200
Subject: [PATCH 0017/2045] MAGETWO-61967: Generate orderSessionId on backend
---
Model/OrderSessionId.php | 56 ++++++++++++++++++++
Model/Ui/ConfigProvider.php | 46 ++++++++++++++++
Test/Unit/Model/OrderSessionIdTest.php | 62 ++++++++++++++++++++++
Test/Unit/Model/Ui/ConfigProviderTest.php | 64 +++++++++++++++++++++++
etc/frontend/di.xml | 16 ++++++
5 files changed, 244 insertions(+)
create mode 100644 Model/OrderSessionId.php
create mode 100644 Model/Ui/ConfigProvider.php
create mode 100644 Test/Unit/Model/OrderSessionIdTest.php
create mode 100644 Test/Unit/Model/Ui/ConfigProviderTest.php
create mode 100644 etc/frontend/di.xml
diff --git a/Model/OrderSessionId.php b/Model/OrderSessionId.php
new file mode 100644
index 0000000000000..22be3c6911493
--- /dev/null
+++ b/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/Model/Ui/ConfigProvider.php b/Model/Ui/ConfigProvider.php
new file mode 100644
index 0000000000000..4b690a0234e1d
--- /dev/null
+++ b/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/Test/Unit/Model/OrderSessionIdTest.php b/Test/Unit/Model/OrderSessionIdTest.php
new file mode 100644
index 0000000000000..7057956a8edaf
--- /dev/null
+++ b/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/Test/Unit/Model/Ui/ConfigProviderTest.php b/Test/Unit/Model/Ui/ConfigProviderTest.php
new file mode 100644
index 0000000000000..66e7f8be34b19
--- /dev/null
+++ b/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/etc/frontend/di.xml b/etc/frontend/di.xml
new file mode 100644
index 0000000000000..a81fde778a02a
--- /dev/null
+++ b/etc/frontend/di.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+ - Magento\Signifyd\Model\Ui\ConfigProvider
+
+
+
+
From 8a62983c1de8e84986416a464e5a22ce7c02b4ac Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 12:16:39 +0200
Subject: [PATCH 0018/2045] MAGETWO-61967: Generate orderSessionId on backend
- Added Checkout module dependency
---
composer.json | 3 ++-
etc/module.xml | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 9f0c56a845f37..cc8bd9d228508 100644
--- a/composer.json
+++ b/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/etc/module.xml b/etc/module.xml
index 1ee26044bbef4..82eb61e9ff0a8 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -9,6 +9,7 @@
+
From d07e9894bcf68d8732b7d9a15b3820efcb10738e Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 13:48:33 +0200
Subject: [PATCH 0019/2045] MAGETWO-61967: Generate orderSessionId on backend
- Removed hard dependency on checkout session
- Used identity generator instead of sha1 hash
---
Model/OrderSessionId.php | 30 ++++++++++++++-------
Model/Ui/ConfigProvider.php | 2 +-
Test/Unit/Model/OrderSessionIdTest.php | 33 ++++++++++++++++-------
Test/Unit/Model/Ui/ConfigProviderTest.php | 4 +--
etc/adminhtml/di.xml | 14 ++++++++++
etc/frontend/di.xml | 5 ++++
6 files changed, 66 insertions(+), 22 deletions(-)
create mode 100644 etc/adminhtml/di.xml
diff --git a/Model/OrderSessionId.php b/Model/OrderSessionId.php
index 22be3c6911493..96356f81dd287 100644
--- a/Model/OrderSessionId.php
+++ b/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/Model/Ui/ConfigProvider.php b/Model/Ui/ConfigProvider.php
index 4b690a0234e1d..af6555a4329db 100644
--- a/Model/Ui/ConfigProvider.php
+++ b/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/Test/Unit/Model/OrderSessionIdTest.php b/Test/Unit/Model/OrderSessionIdTest.php
index 7057956a8edaf..32a8e3b6a7426 100644
--- a/Test/Unit/Model/OrderSessionIdTest.php
+++ b/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/Test/Unit/Model/Ui/ConfigProviderTest.php b/Test/Unit/Model/Ui/ConfigProviderTest.php
index 66e7f8be34b19..bfae3b8773cba 100644
--- a/Test/Unit/Model/Ui/ConfigProviderTest.php
+++ b/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/etc/adminhtml/di.xml b/etc/adminhtml/di.xml
new file mode 100644
index 0000000000000..2509a0be47376
--- /dev/null
+++ b/etc/adminhtml/di.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+ Magento\Backend\Model\Session\Quote
+
+
+
diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml
index a81fde778a02a..b5a97f00ac3a4 100644
--- a/etc/frontend/di.xml
+++ b/etc/frontend/di.xml
@@ -13,4 +13,9 @@
+
+
+ Magento\Checkout\Model\Session
+
+
From c49a0fbc53fb88ead34308c6870d05a707be27f4 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 13:55:44 +0200
Subject: [PATCH 0020/2045] MAGETWO-61967: Generate orderSessionId on backend
- Removed module.xml dependency
---
Test/Unit/Model/Ui/ConfigProviderTest.php | 2 +-
etc/module.xml | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/Test/Unit/Model/Ui/ConfigProviderTest.php b/Test/Unit/Model/Ui/ConfigProviderTest.php
index bfae3b8773cba..99f4c23e70cbd 100644
--- a/Test/Unit/Model/Ui/ConfigProviderTest.php
+++ b/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/etc/module.xml b/etc/module.xml
index 82eb61e9ff0a8..1ee26044bbef4 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -9,7 +9,6 @@
-
From 5309092e44772d7a416653b2c1f1c5f473c97eb4 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 13 Dec 2016 14:22:45 +0200
Subject: [PATCH 0021/2045] MAGETWO-61925: Create case entity infrastructure
- Replaced entity manager by resource model
---
Api/CaseRepositoryInterface.php | 20 ++++-
Api/Data/CaseInterface.php | 5 ++
Api/Data/CaseSearchResultsInterface.php | 31 +++++++
Model/CaseEntity.php | 17 +++-
Model/CaseManagement.php | 39 +++++++--
Model/CaseRepository.php | 83 ++++++++++++++++---
Model/ResourceModel/CaseEntity.php | 22 +++++
Model/ResourceModel/CaseEntity/Collection.php | 24 ++++++
Setup/InstallSchema.php | 2 +-
etc/di.xml | 28 +------
10 files changed, 222 insertions(+), 49 deletions(-)
create mode 100644 Api/Data/CaseSearchResultsInterface.php
create mode 100644 Model/ResourceModel/CaseEntity.php
create mode 100644 Model/ResourceModel/CaseEntity/Collection.php
diff --git a/Api/CaseRepositoryInterface.php b/Api/CaseRepositoryInterface.php
index 5c869fc05392d..99ca62e99643e 100644
--- a/Api/CaseRepositoryInterface.php
+++ b/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/Api/Data/CaseInterface.php b/Api/Data/CaseInterface.php
index 9a85652f3d57c..ffcfd3f118eb9 100644
--- a/Api/Data/CaseInterface.php
+++ b/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/Api/Data/CaseSearchResultsInterface.php b/Api/Data/CaseSearchResultsInterface.php
new file mode 100644
index 0000000000000..6113411a73e01
--- /dev/null
+++ b/Api/Data/CaseSearchResultsInterface.php
@@ -0,0 +1,31 @@
+_init(ResourceModel\CaseEntity::class);
+ }
+
/**
* @inheritdoc
*/
diff --git a/Model/CaseManagement.php b/Model/CaseManagement.php
index 9269d8622dfab..3e31e0af1d883 100644
--- a/Model/CaseManagement.php
+++ b/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/Model/CaseRepository.php b/Model/CaseRepository.php
index 916cbe6136817..e9e326a459dd5 100644
--- a/Model/CaseRepository.php
+++ b/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/Model/ResourceModel/CaseEntity.php b/Model/ResourceModel/CaseEntity.php
new file mode 100644
index 0000000000000..c86f97812900d
--- /dev/null
+++ b/Model/ResourceModel/CaseEntity.php
@@ -0,0 +1,22 @@
+_init('signifyd_case', 'entity_id');
+ }
+}
diff --git a/Model/ResourceModel/CaseEntity/Collection.php b/Model/ResourceModel/CaseEntity/Collection.php
new file mode 100644
index 0000000000000..d8e999516a294
--- /dev/null
+++ b/Model/ResourceModel/CaseEntity/Collection.php
@@ -0,0 +1,24 @@
+_init(CaseEntity::class, CaseResourceModel::class);
+ }
+}
diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php
index c12399e669394..dfd9a7cfcab19 100644
--- a/Setup/InstallSchema.php
+++ b/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/etc/di.xml b/etc/di.xml
index 3abcaad08a639..6b49c74337868 100644
--- a/etc/di.xml
+++ b/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
From 7cc8809f335be5d2182ecda8e4d19be7ea425c87 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 13 Dec 2016 14:22:45 +0200
Subject: [PATCH 0022/2045] MAGETWO-61925: Create case entity infrastructure
- Replaced entity manager by resource model
---
Model/CaseManagementTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Model/CaseManagementTest.php b/Model/CaseManagementTest.php
index c81a18a8afc99..fe85408204dfd 100644
--- a/Model/CaseManagementTest.php
+++ b/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 4fe5c3122a3bc7451d51deaaf687e6958646b735 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 13 Dec 2016 14:28:08 +0200
Subject: [PATCH 0023/2045] MAGETWO-61913: Create request builders
- Update builders
---
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 ++++---
Model/Request/SellerBuilder.php | 39 ++++++++++++++++++--
Model/Request/UserAccountBuilder.php | 19 +++++-----
7 files changed, 107 insertions(+), 72 deletions(-)
diff --git a/Model/Request/CardBuilder.php b/Model/Request/CardBuilder.php
index ec3e08f428b50..2c931924d9c2a 100644
--- a/Model/Request/CardBuilder.php
+++ b/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/Model/Request/ClientVersionBuilder.php b/Model/Request/ClientVersionBuilder.php
index 4c8f4e843163a..25ee03da20dc1 100644
--- a/Model/Request/ClientVersionBuilder.php
+++ b/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/Model/Request/CreateCaseBuilder.php b/Model/Request/CreateCaseBuilder.php
index 926c5354af57a..5abaeffc01b01 100644
--- a/Model/Request/CreateCaseBuilder.php
+++ b/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/Model/Request/PurchaseBuilder.php b/Model/Request/PurchaseBuilder.php
index 215c5f39a172d..f64bf75c30e14 100644
--- a/Model/Request/PurchaseBuilder.php
+++ b/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/Model/Request/RecipientBuilder.php b/Model/Request/RecipientBuilder.php
index 38cb79d32de2b..510276d1cc75c 100644
--- a/Model/Request/RecipientBuilder.php
+++ b/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/Model/Request/SellerBuilder.php b/Model/Request/SellerBuilder.php
index 62977c6d81e51..21b319421d57c 100644
--- a/Model/Request/SellerBuilder.php
+++ b/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/Model/Request/UserAccountBuilder.php b/Model/Request/UserAccountBuilder.php
index 198b57d3e238e..c3296984be6b5 100644
--- a/Model/Request/UserAccountBuilder.php
+++ b/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 79ff8d9bc942d6e4d007f20f2734fde0f12c6d49 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 13 Dec 2016 14:34:30 +0200
Subject: [PATCH 0024/2045] MAGETWO-61925: Create case entity infrastructure
- Fixed failed static test
---
Model/CaseEntity.php | 7 ++-----
Model/CaseRepository.php | 2 ++
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/Model/CaseEntity.php b/Model/CaseEntity.php
index b3a7b05ac217a..85783da3308da 100644
--- a/Model/CaseEntity.php
+++ b/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/Model/CaseRepository.php b/Model/CaseRepository.php
index e9e326a459dd5..723dea8421167 100644
--- a/Model/CaseRepository.php
+++ b/Model/CaseRepository.php
@@ -18,6 +18,8 @@
/**
* Repository for Case interface
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CaseRepository implements CaseRepositoryInterface
{
From 1de46bcbfcc0743094552d1a6aa529dde01e7243 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 13 Dec 2016 15:51:03 +0200
Subject: [PATCH 0025/2045] MAGETWO-61913: Create request builders
- Replace ISO8601 with ATOM
---
Model/Request/PurchaseBuilder.php | 2 +-
Model/Request/UserAccountBuilder.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Model/Request/PurchaseBuilder.php b/Model/Request/PurchaseBuilder.php
index f64bf75c30e14..16de64b869cd1 100644
--- a/Model/Request/PurchaseBuilder.php
+++ b/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/Model/Request/UserAccountBuilder.php b/Model/Request/UserAccountBuilder.php
index c3296984be6b5..6cb33697488f6 100644
--- a/Model/Request/UserAccountBuilder.php
+++ b/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 664eda2547e5e55d23056697bb92594c0a00e8e4 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 13 Dec 2016 15:59:27 +0200
Subject: [PATCH 0026/2045] MAGETWO-61913: Create request builders
- integration tests
---
Model/Request/CreateCaseBuilderTest.php | 108 ++++++++++++++++++++++++
_files/order.php | 77 +++++++++++++++++
2 files changed, 185 insertions(+)
create mode 100644 Model/Request/CreateCaseBuilderTest.php
create mode 100644 _files/order.php
diff --git a/Model/Request/CreateCaseBuilderTest.php b/Model/Request/CreateCaseBuilderTest.php
new file mode 100644
index 0000000000000..bda6802572507
--- /dev/null
+++ b/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/_files/order.php b/_files/order.php
new file mode 100644
index 0000000000000..762c952b36743
--- /dev/null
+++ b/_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 1356d5ee71296c5fc94c6db8dfc919691f10fdc8 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 13 Dec 2016 16:17:07 +0200
Subject: [PATCH 0027/2045] MAGETWO-61913: Create request builders
- Declare Store dependency
---
composer.json | 3 ++-
etc/module.xml | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 9f0c56a845f37..69a42f2aa3336 100644
--- a/composer.json
+++ b/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-store": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
diff --git a/etc/module.xml b/etc/module.xml
index 1ee26044bbef4..aa2d26414b484 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -9,6 +9,7 @@
+
From 8370aeed4b8162e763802789fae5cf8813b05285 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 13 Dec 2016 17:44:34 +0200
Subject: [PATCH 0028/2045] MAGETWO-61925: Create case entity infrastructure
- Updated interface annotation
- Added integration test for case repository
---
Model/CaseRepositoryTest.php | 148 +++++++++++++++++++++++++++++++++++
_files/multiple_cases.php | 27 +++++++
2 files changed, 175 insertions(+)
create mode 100644 Model/CaseRepositoryTest.php
create mode 100644 _files/multiple_cases.php
diff --git a/Model/CaseRepositoryTest.php b/Model/CaseRepositoryTest.php
new file mode 100644
index 0000000000000..05a2eb443b248
--- /dev/null
+++ b/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/_files/multiple_cases.php b/_files/multiple_cases.php
new file mode 100644
index 0000000000000..e0c0f61310077
--- /dev/null
+++ b/_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 d2439f9992940cee08d3679b0ba990981f02968b Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 13 Dec 2016 17:44:34 +0200
Subject: [PATCH 0029/2045] MAGETWO-61925: Create case entity infrastructure
- Updated interface annotation
- Added integration test for case repository
---
Api/CaseManagementInterface.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Api/CaseManagementInterface.php b/Api/CaseManagementInterface.php
index c4d6005011b93..cced6d2e4afe3 100644
--- a/Api/CaseManagementInterface.php
+++ b/Api/CaseManagementInterface.php
@@ -18,7 +18,7 @@ interface CaseManagementInterface
/**
* Creates new Case entity
* @param string $orderId
- * @return void
+ * @return CaseInterface
*/
public function create($orderId);
From 0245f0d48acff13b320d8d31c20225a35f8391ed Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 13 Dec 2016 20:06:39 +0200
Subject: [PATCH 0030/2045] MAGETWO-61913: Create request builders
- integration test
---
Model/Request/CreateCaseBuilderTest.php | 108 ++++++++++++++++--------
_files/customer.php | 38 +++++++++
_files/order.php | 29 +++++--
3 files changed, 130 insertions(+), 45 deletions(-)
create mode 100644 _files/customer.php
diff --git a/Model/Request/CreateCaseBuilderTest.php b/Model/Request/CreateCaseBuilderTest.php
index bda6802572507..9186b6c6f0932 100644
--- a/Model/Request/CreateCaseBuilderTest.php
+++ b/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/_files/customer.php b/_files/customer.php
new file mode 100644
index 0000000000000..df9a814b2ec5b
--- /dev/null
+++ b/_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/_files/order.php b/_files/order.php
index 762c952b36743..285f2a28394bd 100644
--- a/_files/order.php
+++ b/_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 3cc6fb1c7781adb33022e5c11d97a9e2563ef14b Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 14 Dec 2016 12:55:01 +0200
Subject: [PATCH 0031/2045] MAGETWO-61913: Create request builders
- Make filtering empty values more obvious
---
Model/Request/CreateCaseBuilder.php | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/Model/Request/CreateCaseBuilder.php b/Model/Request/CreateCaseBuilder.php
index 5abaeffc01b01..b108bfa8cade6 100644
--- a/Model/Request/CreateCaseBuilder.php
+++ b/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 4fb997643111340b4665de009a5def5826bdb49b Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 14 Dec 2016 13:05:04 +0200
Subject: [PATCH 0032/2045] MAGETWO-61913: Create request builders
- integration test
---
Model/Request/CreateCaseBuilderTest.php | 69 ++++++++++++++++++++++---
_files/order.php | 38 ++++++++++----
_files/store.php | 31 +++++++++++
3 files changed, 120 insertions(+), 18 deletions(-)
create mode 100644 _files/store.php
diff --git a/Model/Request/CreateCaseBuilderTest.php b/Model/Request/CreateCaseBuilderTest.php
index 9186b6c6f0932..2ca933376d66c 100644
--- a/Model/Request/CreateCaseBuilderTest.php
+++ b/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/_files/order.php b/_files/order.php
index 285f2a28394bd..092b31553f3a7 100644
--- a/_files/order.php
+++ b/_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/_files/store.php b/_files/store.php
new file mode 100644
index 0000000000000..9a20bb1982069
--- /dev/null
+++ b/_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 1b7266df151248b6ed2c69d6d220ce9c9fde6224 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 16:27:07 +0200
Subject: [PATCH 0033/2045] 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 ++
Model/CaseCreationService.php | 68 ++++++
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 ++
Model/SignifydGateway/SignifydApiClient.php | 222 ++++++++++++++++++
.../SignifydApiResponseException.php | 14 ++
Model/SignifydGateway/SignifydGateway.php | 63 +++++
.../SignifydGatewayException.php | 14 ++
Observer/PlaceOrder.php | 83 +++++++
etc/config.xml | 10 +-
etc/di.xml | 2 +
etc/events.xml | 12 +
etc/module.xml | 1 +
23 files changed, 645 insertions(+), 16 deletions(-)
create mode 100644 Api/CaseCreationServiceInterface.php
create mode 100644 Model/CaseCreationService.php
create mode 100644 Model/Config.php
rename Model/{ => SignifydGateway}/Request/AddressBuilder.php (94%)
rename Model/{ => SignifydGateway}/Request/CardBuilder.php (95%)
rename Model/{ => SignifydGateway}/Request/ClientVersionBuilder.php (93%)
rename Model/{ => SignifydGateway}/Request/CreateCaseBuilder.php (98%)
rename Model/{ => SignifydGateway}/Request/CreateCaseBuilderInterface.php (85%)
rename Model/{ => SignifydGateway}/Request/CustomerOrders.php (96%)
rename Model/{ => SignifydGateway}/Request/PurchaseBuilder.php (97%)
rename Model/{ => SignifydGateway}/Request/RecipientBuilder.php (95%)
rename Model/{ => SignifydGateway}/Request/SellerBuilder.php (88%)
rename Model/{ => SignifydGateway}/Request/UserAccountBuilder.php (98%)
create mode 100644 Model/SignifydGateway/SignifydApiCallException.php
create mode 100644 Model/SignifydGateway/SignifydApiClient.php
create mode 100644 Model/SignifydGateway/SignifydApiResponseException.php
create mode 100644 Model/SignifydGateway/SignifydGateway.php
create mode 100644 Model/SignifydGateway/SignifydGatewayException.php
create mode 100644 Observer/PlaceOrder.php
create mode 100644 etc/events.xml
diff --git a/Api/CaseCreationServiceInterface.php b/Api/CaseCreationServiceInterface.php
new file mode 100644
index 0000000000000..d1bddc29d76f8
--- /dev/null
+++ b/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/Model/Config.php b/Model/Config.php
new file mode 100644
index 0000000000000..b6af0aaef3a59
--- /dev/null
+++ b/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/Model/Request/AddressBuilder.php b/Model/SignifydGateway/Request/AddressBuilder.php
similarity index 94%
rename from Model/Request/AddressBuilder.php
rename to Model/SignifydGateway/Request/AddressBuilder.php
index 2d2b4ac28f6f2..76ac256a1efa6 100644
--- a/Model/Request/AddressBuilder.php
+++ b/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/Model/Request/CardBuilder.php b/Model/SignifydGateway/Request/CardBuilder.php
similarity index 95%
rename from Model/Request/CardBuilder.php
rename to Model/SignifydGateway/Request/CardBuilder.php
index 2c931924d9c2a..5e50c637a2bff 100644
--- a/Model/Request/CardBuilder.php
+++ b/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/Model/Request/ClientVersionBuilder.php b/Model/SignifydGateway/Request/ClientVersionBuilder.php
similarity index 93%
rename from Model/Request/ClientVersionBuilder.php
rename to Model/SignifydGateway/Request/ClientVersionBuilder.php
index 25ee03da20dc1..b9c514a41f3d8 100644
--- a/Model/Request/ClientVersionBuilder.php
+++ b/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/Model/Request/CreateCaseBuilder.php b/Model/SignifydGateway/Request/CreateCaseBuilder.php
similarity index 98%
rename from Model/Request/CreateCaseBuilder.php
rename to Model/SignifydGateway/Request/CreateCaseBuilder.php
index b108bfa8cade6..2248e8089c5a2 100644
--- a/Model/Request/CreateCaseBuilder.php
+++ b/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/Model/Request/CreateCaseBuilderInterface.php b/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
similarity index 85%
rename from Model/Request/CreateCaseBuilderInterface.php
rename to Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
index 63a302509cf76..c18f7b0216a3d 100644
--- a/Model/Request/CreateCaseBuilderInterface.php
+++ b/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/Model/Request/CustomerOrders.php b/Model/SignifydGateway/Request/CustomerOrders.php
similarity index 96%
rename from Model/Request/CustomerOrders.php
rename to Model/SignifydGateway/Request/CustomerOrders.php
index 26322a745b8ee..fb80837c2c1ed 100644
--- a/Model/Request/CustomerOrders.php
+++ b/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/Model/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
similarity index 97%
rename from Model/Request/PurchaseBuilder.php
rename to Model/SignifydGateway/Request/PurchaseBuilder.php
index 16de64b869cd1..3d5cb1e3cc92d 100644
--- a/Model/Request/PurchaseBuilder.php
+++ b/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/Model/Request/RecipientBuilder.php b/Model/SignifydGateway/Request/RecipientBuilder.php
similarity index 95%
rename from Model/Request/RecipientBuilder.php
rename to Model/SignifydGateway/Request/RecipientBuilder.php
index 510276d1cc75c..81212c7b1c02a 100644
--- a/Model/Request/RecipientBuilder.php
+++ b/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/Model/Request/SellerBuilder.php b/Model/SignifydGateway/Request/SellerBuilder.php
similarity index 88%
rename from Model/Request/SellerBuilder.php
rename to Model/SignifydGateway/Request/SellerBuilder.php
index 21b319421d57c..f3129e441a5a9 100644
--- a/Model/Request/SellerBuilder.php
+++ b/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/Model/Request/UserAccountBuilder.php b/Model/SignifydGateway/Request/UserAccountBuilder.php
similarity index 98%
rename from Model/Request/UserAccountBuilder.php
rename to Model/SignifydGateway/Request/UserAccountBuilder.php
index 6cb33697488f6..a3f7cead80605 100644
--- a/Model/Request/UserAccountBuilder.php
+++ b/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/Model/SignifydGateway/SignifydApiCallException.php b/Model/SignifydGateway/SignifydApiCallException.php
new file mode 100644
index 0000000000000..e62ece8946926
--- /dev/null
+++ b/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/Model/SignifydGateway/SignifydApiResponseException.php b/Model/SignifydGateway/SignifydApiResponseException.php
new file mode 100644
index 0000000000000..cd6d9113e2119
--- /dev/null
+++ b/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/Model/SignifydGateway/SignifydGatewayException.php b/Model/SignifydGateway/SignifydGatewayException.php
new file mode 100644
index 0000000000000..d1d46a7d79445
--- /dev/null
+++ b/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/etc/config.xml b/etc/config.xml
index b16f0903c2d1f..7ff088dcb0321 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -7,9 +7,11 @@
-->
-
- 0
- https://api.signifiyd.com/v2/
-
+
+
+ 0
+ https://api.signifyd.com/v2/
+
+
diff --git a/etc/di.xml b/etc/di.xml
index 6b49c74337868..81d157887f7e1 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -10,4 +10,6 @@
+
+
\ No newline at end of file
diff --git a/etc/events.xml b/etc/events.xml
new file mode 100644
index 0000000000000..dd4fff95b8c4a
--- /dev/null
+++ b/etc/events.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/etc/module.xml b/etc/module.xml
index aa2d26414b484..40335d45f28a5 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -9,6 +9,7 @@
+
From 35fa6006e89056bcc1ae10f48c2656a57741289f Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 16:27:07 +0200
Subject: [PATCH 0034/2045] 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
---
Model/{ => SignifydGateway}/Request/CreateCaseBuilderTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
rename Model/{ => SignifydGateway}/Request/CreateCaseBuilderTest.php (98%)
diff --git a/Model/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
similarity index 98%
rename from Model/Request/CreateCaseBuilderTest.php
rename to Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 2ca933376d66c..516ecd329bf7e 100644
--- a/Model/Request/CreateCaseBuilderTest.php
+++ b/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 9e1cc392f41c0fe67a10247f5dc048026a1e275f Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 17:09:23 +0200
Subject: [PATCH 0035/2045] MAGETWO-61914: Create case request to Signifyd
- Removed debugging code
---
Model/SignifydGateway/SignifydApiClient.php | 4 ----
1 file changed, 4 deletions(-)
diff --git a/Model/SignifydGateway/SignifydApiClient.php b/Model/SignifydGateway/SignifydApiClient.php
index b485f54dc16d7..ba2e778b4ef93 100644
--- a/Model/SignifydGateway/SignifydApiClient.php
+++ b/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 8915dcf608640500e19c12dd1fcbe9e844c2f89f Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 17:23:52 +0200
Subject: [PATCH 0036/2045] MAGETWO-61914: Create case request to Signifyd
- fixed issue with not encrypted API key
---
Model/SignifydGateway/SignifydApiClient.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Model/SignifydGateway/SignifydApiClient.php b/Model/SignifydGateway/SignifydApiClient.php
index ba2e778b4ef93..b2a7be8b752f7 100644
--- a/Model/SignifydGateway/SignifydApiClient.php
+++ b/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 ff93fe2163e421a493ba8c9046d48c9392d04e91 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 17:46:43 +0200
Subject: [PATCH 0037/2045] MAGETWO-61914: Create case request to Signifyd
- fixed configuration reading
---
Model/Config.php | 34 ++++++++++++++++++----------------
etc/config.xml | 2 ++
2 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/Model/Config.php b/Model/Config.php
index b6af0aaef3a59..af3f26b80b5ca 100644
--- a/Model/Config.php
+++ b/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/etc/config.xml b/etc/config.xml
index 7ff088dcb0321..da606e2361c40 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -11,6 +11,8 @@
0
https://api.signifyd.com/v2/
+
+ 0
From 46d34bb8982f62ea4e3f8b43af3c1c040019bda0 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 14 Dec 2016 18:05:49 +0200
Subject: [PATCH 0038/2045] MAGETWO-61913: Create request builders
- Update CreateCaseBuilderTest
---
Model/SignifydGateway/Request/PurchaseBuilder.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Model/SignifydGateway/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
index 3d5cb1e3cc92d..fdb683e61631f 100644
--- a/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/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';
}
}
From 0973e60c4f74e7cdc4221001cddc02b58a433661 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 14 Dec 2016 18:05:49 +0200
Subject: [PATCH 0039/2045] MAGETWO-61913: Create request builders
- Update CreateCaseBuilderTest
---
.../Request/CreateCaseBuilderTest.php | 189 ++++++++++++------
_files/case.php | 2 +-
...with_customer_and_two_simple_products.php} | 42 ++--
.../order_with_guest_and_virtual_product.php | 62 ++++++
_files/store.php | 6 +-
5 files changed, 226 insertions(+), 75 deletions(-)
rename _files/{order.php => order_with_customer_and_two_simple_products.php} (73%)
create mode 100644 _files/order_with_guest_and_virtual_product.php
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 516ecd329bf7e..8d7a88c6c884c 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/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/_files/case.php b/_files/case.php
index 148c831a9f2d7..de635ba750399 100644
--- a/_files/case.php
+++ b/_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/_files/order.php b/_files/order_with_customer_and_two_simple_products.php
similarity index 73%
rename from _files/order.php
rename to _files/order_with_customer_and_two_simple_products.php
index 092b31553f3a7..53ab5fd724e45 100644
--- a/_files/order.php
+++ b/_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/_files/order_with_guest_and_virtual_product.php b/_files/order_with_guest_and_virtual_product.php
new file mode 100644
index 0000000000000..fa0d00be90497
--- /dev/null
+++ b/_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/_files/store.php b/_files/store.php
index 9a20bb1982069..e27f9a4e7370c 100644
--- a/_files/store.php
+++ b/_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 fde10f27cdfb5a841f512a74369f1c5496b31a6e Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 19:00:54 +0200
Subject: [PATCH 0040/2045] MAGETWO-61914: Create case request to Signifyd
- Refactoring: apply code standards
---
Api/CaseCreationServiceInterface.php | 5 +-
Model/CaseCreationService.php | 3 +-
Model/Config.php | 6 +-
.../SignifydGateway/Request/SellerBuilder.php | 1 -
.../SignifydApiCallException.php | 2 +-
Model/SignifydGateway/SignifydApiClient.php | 85 +++++++++++--------
.../SignifydApiResponseException.php | 2 +-
Model/SignifydGateway/SignifydGateway.php | 4 +-
.../SignifydGatewayException.php | 2 +-
Observer/PlaceOrder.php | 3 +-
10 files changed, 60 insertions(+), 53 deletions(-)
diff --git a/Api/CaseCreationServiceInterface.php b/Api/CaseCreationServiceInterface.php
index d1bddc29d76f8..939f64409a577 100644
--- a/Api/CaseCreationServiceInterface.php
+++ b/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/Model/CaseCreationService.php b/Model/CaseCreationService.php
index d876fe6585cc0..8c761a1c8fee0 100644
--- a/Model/CaseCreationService.php
+++ b/Model/CaseCreationService.php
@@ -64,5 +64,4 @@ public function createForOrder($orderId)
return true;
}
-
-}
\ No newline at end of file
+}
diff --git a/Model/Config.php b/Model/Config.php
index af3f26b80b5ca..f99480386293a 100644
--- a/Model/Config.php
+++ b/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/Model/SignifydGateway/Request/SellerBuilder.php b/Model/SignifydGateway/Request/SellerBuilder.php
index f3129e441a5a9..9b8af9535407c 100644
--- a/Model/SignifydGateway/Request/SellerBuilder.php
+++ b/Model/SignifydGateway/Request/SellerBuilder.php
@@ -131,5 +131,4 @@ private function getPublicDomain(StoreInterface $store)
return $domain;
}
-
}
diff --git a/Model/SignifydGateway/SignifydApiCallException.php b/Model/SignifydGateway/SignifydApiCallException.php
index e62ece8946926..ea1a1f73dfa1b 100644
--- a/Model/SignifydGateway/SignifydApiCallException.php
+++ b/Model/SignifydGateway/SignifydApiCallException.php
@@ -11,4 +11,4 @@
class SignifydApiCallException extends SignifydGatewayException
{
-}
\ No newline at end of file
+}
diff --git a/Model/SignifydGateway/SignifydApiClient.php b/Model/SignifydGateway/SignifydApiClient.php
index b2a7be8b752f7..7c70bf8770ab3 100644
--- a/Model/SignifydGateway/SignifydApiClient.php
+++ b/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/Model/SignifydGateway/SignifydApiResponseException.php b/Model/SignifydGateway/SignifydApiResponseException.php
index cd6d9113e2119..a353537074fea 100644
--- a/Model/SignifydGateway/SignifydApiResponseException.php
+++ b/Model/SignifydGateway/SignifydApiResponseException.php
@@ -11,4 +11,4 @@
class SignifydApiResponseException extends SignifydGatewayException
{
-}
\ No newline at end of file
+}
diff --git a/Model/SignifydGateway/SignifydGateway.php b/Model/SignifydGateway/SignifydGateway.php
index 0626f727168b0..0975b9359aab6 100644
--- a/Model/SignifydGateway/SignifydGateway.php
+++ b/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/Model/SignifydGateway/SignifydGatewayException.php b/Model/SignifydGateway/SignifydGatewayException.php
index d1d46a7d79445..7deb44fba132d 100644
--- a/Model/SignifydGateway/SignifydGatewayException.php
+++ b/Model/SignifydGateway/SignifydGatewayException.php
@@ -11,4 +11,4 @@
class SignifydGatewayException extends \Exception
{
-}
\ No newline at end of file
+}
diff --git a/Observer/PlaceOrder.php b/Observer/PlaceOrder.php
index 80309e7bbd497..aa9d0d39e5988 100644
--- a/Observer/PlaceOrder.php
+++ b/Observer/PlaceOrder.php
@@ -79,5 +79,4 @@ private function extractOrder(Event $event)
{
return $event->getData('order');
}
-
-}
\ No newline at end of file
+}
From f3a4e19942cb742e7c24f96f5f81be92e8d22be5 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 19:17:19 +0200
Subject: [PATCH 0041/2045] MAGETWO-61914: Create case request to Signifyd
- Refactoring: renamed gateway classes
---
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 Model/SignifydGateway/{SignifydGatewayException.php => ApiCallException.php} (81%)
rename Model/SignifydGateway/{SignifydApiClient.php => ApiClient.php} (93%)
rename Model/SignifydGateway/{SignifydApiCallException.php => ApiResponseException.php} (77%)
rename Model/SignifydGateway/{SignifydGateway.php => Gateway.php} (77%)
rename Model/SignifydGateway/{SignifydApiResponseException.php => GatewayException.php} (76%)
diff --git a/Model/CaseCreationService.php b/Model/CaseCreationService.php
index 8c761a1c8fee0..2dc76f4e74d4f 100644
--- a/Model/CaseCreationService.php
+++ b/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/Model/SignifydGateway/SignifydGatewayException.php b/Model/SignifydGateway/ApiCallException.php
similarity index 81%
rename from Model/SignifydGateway/SignifydGatewayException.php
rename to Model/SignifydGateway/ApiCallException.php
index 7deb44fba132d..5aaa44e2f0bb7 100644
--- a/Model/SignifydGateway/SignifydGatewayException.php
+++ b/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/Model/SignifydGateway/SignifydApiClient.php b/Model/SignifydGateway/ApiClient.php
similarity index 93%
rename from Model/SignifydGateway/SignifydApiClient.php
rename to Model/SignifydGateway/ApiClient.php
index 7c70bf8770ab3..a489c99f500a3 100644
--- a/Model/SignifydGateway/SignifydApiClient.php
+++ b/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/Model/SignifydGateway/SignifydApiCallException.php b/Model/SignifydGateway/ApiResponseException.php
similarity index 77%
rename from Model/SignifydGateway/SignifydApiCallException.php
rename to Model/SignifydGateway/ApiResponseException.php
index ea1a1f73dfa1b..80bbe02b17b34 100644
--- a/Model/SignifydGateway/SignifydApiCallException.php
+++ b/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/Model/SignifydGateway/SignifydGateway.php b/Model/SignifydGateway/Gateway.php
similarity index 77%
rename from Model/SignifydGateway/SignifydGateway.php
rename to Model/SignifydGateway/Gateway.php
index 0975b9359aab6..2ffefb65937ee 100644
--- a/Model/SignifydGateway/SignifydGateway.php
+++ b/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/Model/SignifydGateway/SignifydApiResponseException.php b/Model/SignifydGateway/GatewayException.php
similarity index 76%
rename from Model/SignifydGateway/SignifydApiResponseException.php
rename to Model/SignifydGateway/GatewayException.php
index a353537074fea..21066f8872d32 100644
--- a/Model/SignifydGateway/SignifydApiResponseException.php
+++ b/Model/SignifydGateway/GatewayException.php
@@ -8,7 +8,7 @@
/**
* Exception of interacation with Signifyd API
*/
-class SignifydApiResponseException extends SignifydGatewayException
+class GatewayException extends \Exception
{
}
From 3880cf7bfb5493fb1a3529a3a01773714e50083f Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 19:30:27 +0200
Subject: [PATCH 0042/2045] MAGETWO-61914: Create case request to Signifyd
- fixed refactoring issues
---
Api/CaseCreationServiceInterface.php | 2 +-
Model/SignifydGateway/ApiClient.php | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Api/CaseCreationServiceInterface.php b/Api/CaseCreationServiceInterface.php
index 939f64409a577..2118652f31a7d 100644
--- a/Api/CaseCreationServiceInterface.php
+++ b/Api/CaseCreationServiceInterface.php
@@ -22,4 +22,4 @@ interface CaseCreationServiceInterface
* @return bool
*/
public function createForOrder($orderId);
-}
\ No newline at end of file
+}
diff --git a/Model/SignifydGateway/ApiClient.php b/Model/SignifydGateway/ApiClient.php
index a489c99f500a3..5de361eec7975 100644
--- a/Model/SignifydGateway/ApiClient.php
+++ b/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:
From ce03c0c4e50575fe99a65e669f7dbe0824cce0a2 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 19:30:27 +0200
Subject: [PATCH 0043/2045] MAGETWO-61914: Create case request to Signifyd
- fixed refactoring issues
---
Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 8d7a88c6c884c..2665e9756e0f3 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -153,7 +153,6 @@ public function testCreateCaseBuilderWithFullSetOfData()
]
];
-
static::assertEquals(
$expected,
$this->caseBuilder->build($order->getEntityId())
From 737dda6f97cbd96bba068ce77b43646137694888 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 14 Dec 2016 19:34:44 +0200
Subject: [PATCH 0044/2045] 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 Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
diff --git a/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php b/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
new file mode 100644
index 0000000000000..a5d6ea624c1a6
--- /dev/null
+++ b/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 7355efd2b02f08e71317c987f5b1847e927c53b8 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 15 Dec 2016 12:13:21 +0200
Subject: [PATCH 0045/2045] MAGETWO-61914: Create case request to Signifyd
- improved observer implementation in case of disabled Signifyd integration
---
Observer/PlaceOrder.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Observer/PlaceOrder.php b/Observer/PlaceOrder.php
index aa9d0d39e5988..2eba75225ffcd 100644
--- a/Observer/PlaceOrder.php
+++ b/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 8bad7156c3cf1c9150a939d3f060c3aa50579211 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 15 Dec 2016 12:14:37 +0200
Subject: [PATCH 0046/2045] MAGETWO-61914: Create case request to Signifyd
- fixed typo in guard condition
---
Observer/PlaceOrder.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Observer/PlaceOrder.php b/Observer/PlaceOrder.php
index 2eba75225ffcd..f59dc7769e310 100644
--- a/Observer/PlaceOrder.php
+++ b/Observer/PlaceOrder.php
@@ -62,7 +62,7 @@ public function execute(Observer $observer)
}
$orderId = $order->getEntityId();
- if (null === $order) {
+ if (null === $orderId) {
return;
}
From 98939dc1af2d002b73fc35c922f63ea9863bcd5e Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 15 Dec 2016 12:18:55 +0200
Subject: [PATCH 0047/2045] MAGETWO-61914: Create case request to Signifyd
- declared used dependecies
---
composer.json | 5 ++++-
etc/module.xml | 2 ++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 69a42f2aa3336..5f18eff9001c2 100644
--- a/composer.json
+++ b/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/etc/module.xml b/etc/module.xml
index 40335d45f28a5..0a84948b522f7 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -11,6 +11,8 @@
+
+
From 1bc9ddd1ea1ecc2ee751cf0fe97550cb3605ea56 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 15 Dec 2016 12:32:23 +0200
Subject: [PATCH 0048/2045] MAGETWO-61914: Create case request to Signifyd
- removed edundant dependencies
---
composer.json | 1 -
etc/module.xml | 1 -
2 files changed, 2 deletions(-)
diff --git a/composer.json b/composer.json
index 5f18eff9001c2..920086ebd0106 100644
--- a/composer.json
+++ b/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/etc/module.xml b/etc/module.xml
index 0a84948b522f7..565ee18b92142 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -9,7 +9,6 @@
-
From 5cc8f4d68f723ba9968effb4cc43f8eca8a9d5fd Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 16 Dec 2016 12:28:06 +0200
Subject: [PATCH 0049/2045] MAGETWO-61968: Create component for frontend
---
Block/Fingerprint.php | 71 +++++++++++++++++++
view/frontend/layout/checkout_index_index.xml | 14 ++++
view/frontend/templates/fingerprint.phtml | 17 +++++
3 files changed, 102 insertions(+)
create mode 100644 Block/Fingerprint.php
create mode 100644 view/frontend/layout/checkout_index_index.xml
create mode 100644 view/frontend/templates/fingerprint.phtml
diff --git a/Block/Fingerprint.php b/Block/Fingerprint.php
new file mode 100644
index 0000000000000..07b6df02cf103
--- /dev/null
+++ b/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/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml
new file mode 100644
index 0000000000000..07b04cc41d1bf
--- /dev/null
+++ b/view/frontend/layout/checkout_index_index.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/view/frontend/templates/fingerprint.phtml b/view/frontend/templates/fingerprint.phtml
new file mode 100644
index 0000000000000..e15632ca9d4af
--- /dev/null
+++ b/view/frontend/templates/fingerprint.phtml
@@ -0,0 +1,17 @@
+
+isModuleEnabled()): ?>
+
+
\ No newline at end of file
From e4528a3f7ca5c34ca3b5f4f68803fcb8d794dc48 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 16 Dec 2016 12:28:06 +0200
Subject: [PATCH 0050/2045] MAGETWO-61968: Create component for frontend
---
Block/FingerprintTest.php | 61 +++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
create mode 100644 Block/FingerprintTest.php
diff --git a/Block/FingerprintTest.php b/Block/FingerprintTest.php
new file mode 100644
index 0000000000000..1f7c71ba7b2c4
--- /dev/null
+++ b/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());
+ }
+}
From 783a246101cdfb4ed84ca8f45aa4ab9fbe0fc2af Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 16 Dec 2016 13:00:04 +0200
Subject: [PATCH 0051/2045] MAGETWO-61968: Create component for frontend
- static tests fix
---
view/frontend/templates/fingerprint.phtml | 1 -
1 file changed, 1 deletion(-)
diff --git a/view/frontend/templates/fingerprint.phtml b/view/frontend/templates/fingerprint.phtml
index e15632ca9d4af..7d0e645afba01 100644
--- a/view/frontend/templates/fingerprint.phtml
+++ b/view/frontend/templates/fingerprint.phtml
@@ -9,7 +9,6 @@
isModuleEnabled()): ?>
\ No newline at end of file
From 7c981620bd21c953f9e36eca7ce5ed363000aa62 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 19 Dec 2016 12:06:43 +0200
Subject: [PATCH 0065/2045] MAGETWO-61969: Add fingerprint to case builder
- Refactoring of quote session id generation
---
.../Request/CreateCaseBuilderTest.php | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 9367a483fc2dc..9f1119954b311 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/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 74487b62f5f67f12d1bfa872baf2b6735d973e00 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 19 Dec 2016 12:06:43 +0200
Subject: [PATCH 0066/2045] MAGETWO-61969: Add fingerprint to case builder
- Refactoring of quote session id generation
---
Model/QuoteSessionId.php | 5 +++--
.../Request/PurchaseBuilder.php | 14 +++++++-------
Test/Unit/Model/QuoteSessionIdTest.php | 19 +++++++++++++++++--
3 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/Model/QuoteSessionId.php b/Model/QuoteSessionId.php
index 044836f6a54a6..e36e7f27b8efa 100644
--- a/Model/QuoteSessionId.php
+++ b/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/Model/SignifydGateway/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
index 5224a28830f96..de10249970cde 100644
--- a/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/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/Test/Unit/Model/QuoteSessionIdTest.php b/Test/Unit/Model/QuoteSessionIdTest.php
index cd6e1f82c9b98..4601939fe2057 100644
--- a/Test/Unit/Model/QuoteSessionIdTest.php
+++ b/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();
From f1ecff65f7000e96413b7d59263624a6a0f74746 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 23 Dec 2016 15:22:37 +0200
Subject: [PATCH 0067/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- static and acceptance tests fix
---
etc/di.xml | 1 +
etc/module.xml | 2 ++
2 files changed, 3 insertions(+)
diff --git a/etc/di.xml b/etc/di.xml
index 81d157887f7e1..df5214ba14c52 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -12,4 +12,5 @@
+
\ No newline at end of file
diff --git a/etc/module.xml b/etc/module.xml
index 565ee18b92142..2db123b053108 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -12,6 +12,8 @@
+
+
From 103aebc5c8c0e999be5765095e25c2c7ae90b1a8 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 19 Dec 2016 13:56:50 +0200
Subject: [PATCH 0068/2045] MAGETWO-61969: Add fingerprint to case builder
- Refactor name of quote session id getter method
---
Block/Fingerprint.php | 2 +-
Model/QuoteSession/QuoteSessionInterface.php | 4 +---
Model/QuoteSessionId.php | 6 +++---
.../SignifydGateway/Request/PurchaseBuilder.php | 2 +-
Test/Unit/Model/QuoteSessionIdTest.php | 12 ++++++------
composer.json | 3 ++-
view/frontend/templates/fingerprint.phtml | 16 +++++++++-------
7 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/Block/Fingerprint.php b/Block/Fingerprint.php
index 0e541f9036eba..ed14d75e7a16f 100644
--- a/Block/Fingerprint.php
+++ b/Block/Fingerprint.php
@@ -56,7 +56,7 @@ public function __construct(
*/
public function getQuoteSessionId()
{
- return $this->quoteSessionId->generate();
+ return $this->quoteSessionId->get();
}
/**
diff --git a/Model/QuoteSession/QuoteSessionInterface.php b/Model/QuoteSession/QuoteSessionInterface.php
index 9a68341596b65..dafaf680ee39d 100644
--- a/Model/QuoteSession/QuoteSessionInterface.php
+++ b/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/Model/QuoteSessionId.php b/Model/QuoteSessionId.php
index e36e7f27b8efa..004fff462b16d 100644
--- a/Model/QuoteSessionId.php
+++ b/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/Model/SignifydGateway/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
index de10249970cde..8a83cc64ad1de 100644
--- a/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/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/Test/Unit/Model/QuoteSessionIdTest.php b/Test/Unit/Model/QuoteSessionIdTest.php
index 4601939fe2057..e4cdad26ec204 100644
--- a/Test/Unit/Model/QuoteSessionIdTest.php
+++ b/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/composer.json b/composer.json
index 43f4f71a4a9e9..cf9b2311bbba5 100644
--- a/composer.json
+++ b/composer.json
@@ -8,7 +8,8 @@
"magento/module-store": "100.2.*",
"magento/module-customer": "100.2.*",
"magento/module-directory": "100.2.*",
- "magento/module-checkout": "100.2.*"
+ "magento/module-checkout": "100.2.*",
+ "magento/module-backend": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
diff --git a/view/frontend/templates/fingerprint.phtml b/view/frontend/templates/fingerprint.phtml
index e3388531c4670..a9f5a9dd476da 100644
--- a/view/frontend/templates/fingerprint.phtml
+++ b/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
From 6edd6177d90b03442daa967083b01e727d5062fd Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 19 Dec 2016 13:56:50 +0200
Subject: [PATCH 0069/2045] MAGETWO-61969: Add fingerprint to case builder
- Refactor name of quote session id getter method
---
Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 9f1119954b311..2201a4ed6a3aa 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/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 f599becfffa9f802f87f793d1b62094644bc4354 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Mon, 19 Dec 2016 12:35:59 +0200
Subject: [PATCH 0070/2045] 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/Model/SignifydGateway/ApiClient.php b/Model/SignifydGateway/ApiClient.php
index 0887c384e901d..86e424b45bc62 100644
--- a/Model/SignifydGateway/ApiClient.php
+++ b/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 7272783fe586bdd28bf65cc5dbbf4197cb7ea8a4 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 20 Dec 2016 11:36:58 +0200
Subject: [PATCH 0071/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Updates error messages in CaseCreationServiceTest
---
Model/CaseCreationServiceTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Model/CaseCreationServiceTest.php b/Model/CaseCreationServiceTest.php
index a200d93c6618b..effee790eaa2a 100644
--- a/Model/CaseCreationServiceTest.php
+++ b/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 eb6f68e638f5892e8bac5de8bad54be1295ad0f8 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 20 Dec 2016 18:55:10 +0200
Subject: [PATCH 0072/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Fix bug with multishipping place order
- Rename QuoteSessionId to SignifydOrderSessionId
- Update annotations
---
Block/Fingerprint.php | 42 ++++++---
Model/CaseManagement.php | 3 +-
Model/CaseRepository.php | 7 +-
Model/Config.php | 2 +-
Model/QuoteSessionId.php | 54 ------------
Model/SignifydGateway/ApiClient.php | 28 +++---
.../Request/CreateCaseBuilderInterface.php | 6 +-
.../Request/PurchaseBuilder.php | 14 +--
Model/SignifydOrderSessionId.php | 39 +++++++++
Observer/PlaceOrder.php | 34 +++++---
README.md | 2 +-
Test/Unit/Model/QuoteSessionIdTest.php | 86 -------------------
.../Unit/Model/SignifydOrderSessionIdTest.php | 60 +++++++++++++
etc/adminhtml/system.xml | 6 +-
etc/frontend/routes.xml | 14 ---
view/frontend/templates/fingerprint.phtml | 4 +-
16 files changed, 181 insertions(+), 220 deletions(-)
delete mode 100644 Model/QuoteSessionId.php
create mode 100644 Model/SignifydOrderSessionId.php
delete mode 100644 Test/Unit/Model/QuoteSessionIdTest.php
create mode 100644 Test/Unit/Model/SignifydOrderSessionIdTest.php
delete mode 100644 etc/frontend/routes.xml
diff --git a/Block/Fingerprint.php b/Block/Fingerprint.php
index ed14d75e7a16f..babceee2e1423 100644
--- a/Block/Fingerprint.php
+++ b/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/Model/CaseManagement.php b/Model/CaseManagement.php
index 3e31e0af1d883..504b52b85a74a 100644
--- a/Model/CaseManagement.php
+++ b/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/Model/CaseRepository.php b/Model/CaseRepository.php
index 723dea8421167..f18ffc47356d9 100644
--- a/Model/CaseRepository.php
+++ b/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/Model/Config.php b/Model/Config.php
index f99480386293a..b7c2afe4cb109 100644
--- a/Model/Config.php
+++ b/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/Model/QuoteSessionId.php b/Model/QuoteSessionId.php
deleted file mode 100644
index 004fff462b16d..0000000000000
--- a/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/Model/SignifydGateway/ApiClient.php b/Model/SignifydGateway/ApiClient.php
index 86e424b45bc62..3b14773b3fd25 100644
--- a/Model/SignifydGateway/ApiClient.php
+++ b/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/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php b/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
index e75a8aa9dbcfc..aa5e4ce48485b 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
+++ b/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/Model/SignifydGateway/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
index 8a83cc64ad1de..6f39369bc6752 100644
--- a/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/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/Model/SignifydOrderSessionId.php b/Model/SignifydOrderSessionId.php
new file mode 100644
index 0000000000000..b5f0fcee06ccd
--- /dev/null
+++ b/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/Observer/PlaceOrder.php b/Observer/PlaceOrder.php
index f59dc7769e310..1d0a51167dc34 100644
--- a/Observer/PlaceOrder.php
+++ b/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/README.md b/README.md
index 3cd2b4a30a858..5159d4c6951c4 100644
--- a/README.md
+++ b/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/Test/Unit/Model/QuoteSessionIdTest.php b/Test/Unit/Model/QuoteSessionIdTest.php
deleted file mode 100644
index e4cdad26ec204..0000000000000
--- a/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/Test/Unit/Model/SignifydOrderSessionIdTest.php b/Test/Unit/Model/SignifydOrderSessionIdTest.php
new file mode 100644
index 0000000000000..f8a36ef172dc5
--- /dev/null
+++ b/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/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 14ae7d73e0e48..a1ecbfcdff95c 100644
--- a/etc/adminhtml/system.xml
+++ b/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/etc/frontend/routes.xml b/etc/frontend/routes.xml
deleted file mode 100644
index 8a6c5b4e22c1d..0000000000000
--- a/etc/frontend/routes.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/view/frontend/templates/fingerprint.phtml b/view/frontend/templates/fingerprint.phtml
index a9f5a9dd476da..609391c2d695d 100644
--- a/view/frontend/templates/fingerprint.phtml
+++ b/view/frontend/templates/fingerprint.phtml
@@ -8,11 +8,11 @@
/** @var $block Magento\Signifyd\Block\Fingerprint */
?>
-isModuleEnabled()): ?>
+isModuleActive()): ?>
\ No newline at end of file
From 0b30fb14a83ca5a2e34907c03e7b58ee628adf9d Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 20 Dec 2016 18:55:10 +0200
Subject: [PATCH 0073/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Fix bug with multishipping place order
- Rename QuoteSessionId to SignifydOrderSessionId
- Update annotations
---
.../Request/CreateCaseBuilderTest.php | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 2201a4ed6a3aa..61dc67b7f7808 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/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 84bb63e0f96d1dee7522356487b80995ecc4a6d1 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 23 Dec 2016 15:23:59 +0200
Subject: [PATCH 0074/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Move CreateCaseBuilderInterface preference from global to frontend area
---
etc/di.xml | 1 -
1 file changed, 1 deletion(-)
diff --git a/etc/di.xml b/etc/di.xml
index df5214ba14c52..81d157887f7e1 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -12,5 +12,4 @@
-
\ No newline at end of file
From 55a9d0ada0eb313917fb88586837e3ea99e036bc Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 20 Dec 2016 19:36:44 +0200
Subject: [PATCH 0075/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- code review comments
---
Api/CaseCreationServiceInterface.php | 1 +
Api/CaseManagementInterface.php | 10 +-
Api/CaseRepositoryInterface.php | 12 ++-
Api/Data/CaseInterface.php | 129 ++++++++++--------------
Api/Data/CaseSearchResultsInterface.php | 6 +-
Model/CaseCreationService.php | 11 +-
Setup/InstallSchema.php | 11 ++
7 files changed, 90 insertions(+), 90 deletions(-)
diff --git a/Api/CaseCreationServiceInterface.php b/Api/CaseCreationServiceInterface.php
index 2118652f31a7d..7141d76371c06 100644
--- a/Api/CaseCreationServiceInterface.php
+++ b/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/Api/CaseManagementInterface.php b/Api/CaseManagementInterface.php
index cced6d2e4afe3..40f1dcc11b54f 100644
--- a/Api/CaseManagementInterface.php
+++ b/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/Api/CaseRepositoryInterface.php b/Api/CaseRepositoryInterface.php
index 99ca62e99643e..0e63e9283ad28 100644
--- a/Api/CaseRepositoryInterface.php
+++ b/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/Api/Data/CaseInterface.php b/Api/Data/CaseInterface.php
index ffcfd3f118eb9..6a58effa19e4f 100644
--- a/Api/Data/CaseInterface.php
+++ b/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/Api/Data/CaseSearchResultsInterface.php b/Api/Data/CaseSearchResultsInterface.php
index 6113411a73e01..451206f1b3d15 100644
--- a/Api/Data/CaseSearchResultsInterface.php
+++ b/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/Model/CaseCreationService.php b/Model/CaseCreationService.php
index 27fb33a80345c..dcbbbf11554be 100644
--- a/Model/CaseCreationService.php
+++ b/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/Setup/InstallSchema.php b/Setup/InstallSchema.php
index dfd9a7cfcab19..5b5f807e1f520 100644
--- a/Setup/InstallSchema.php
+++ b/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 40617ea246cc35edb18674d5974658ff4025e187 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 11:53:15 +0200
Subject: [PATCH 0076/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- refactor associated team to array
---
Model/CaseEntity.php | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/Model/CaseEntity.php b/Model/CaseEntity.php
index 85783da3308da..8502ac5a51b95 100644
--- a/Model/CaseEntity.php
+++ b/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 de2e8101710808a9d44246c97f20bb41a03d0c60 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 15:35:32 +0200
Subject: [PATCH 0077/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- refactor according to review
---
Api/CaseManagementInterface.php | 1 +
Model/CaseCreationService.php | 9 +--------
Model/CaseManagement.php | 8 +++++++-
Observer/PlaceOrder.php | 35 ++++++++++++++++++++++++++++-----
Setup/InstallSchema.php | 2 +-
5 files changed, 40 insertions(+), 15 deletions(-)
diff --git a/Api/CaseManagementInterface.php b/Api/CaseManagementInterface.php
index 40f1dcc11b54f..09c2e8c0e164c 100644
--- a/Api/CaseManagementInterface.php
+++ b/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/Model/CaseCreationService.php b/Model/CaseCreationService.php
index dcbbbf11554be..c544ab30d6b35 100644
--- a/Model/CaseCreationService.php
+++ b/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/Model/CaseManagement.php b/Model/CaseManagement.php
index 504b52b85a74a..8705f9a812ae3 100644
--- a/Model/CaseManagement.php
+++ b/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/Observer/PlaceOrder.php b/Observer/PlaceOrder.php
index 1d0a51167dc34..ef037ca7cd8e4 100644
--- a/Observer/PlaceOrder.php
+++ b/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/Setup/InstallSchema.php b/Setup/InstallSchema.php
index 5b5f807e1f520..deb313c66a828 100644
--- a/Setup/InstallSchema.php
+++ b/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);
From 7e7a2d7f02e8ac7df1fc36e9bef775fb13575718 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 15:35:32 +0200
Subject: [PATCH 0078/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- refactor according to review
---
Block/FingerprintTest.php | 2 +-
Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Block/FingerprintTest.php b/Block/FingerprintTest.php
index 2cdd3c1d67a3c..6708af55dddf9 100644
--- a/Block/FingerprintTest.php
+++ b/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/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 61dc67b7f7808..de0ddc7c1f03f 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/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 5c1ffb6e3f8657cc75c7e34d7b1fb2cd41df2b7c Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 16:49:26 +0200
Subject: [PATCH 0079/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- replace orderId with orderIncrementId
- fixes for integration tests
- db schema update
---
Api/Data/CaseInterface.php | 15 +++++++++++++++
Model/CaseEntity.php | 19 ++++++++++++++++++-
.../Request/PurchaseBuilder.php | 2 +-
Setup/InstallSchema.php | 1 +
4 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/Api/Data/CaseInterface.php b/Api/Data/CaseInterface.php
index 6a58effa19e4f..cd1122e276c87 100644
--- a/Api/Data/CaseInterface.php
+++ b/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/Model/CaseEntity.php b/Model/CaseEntity.php
index 8502ac5a51b95..efccab18da65b 100644
--- a/Model/CaseEntity.php
+++ b/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/Model/SignifydGateway/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
index 6f39369bc6752..81d601898373d 100644
--- a/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/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/Setup/InstallSchema.php b/Setup/InstallSchema.php
index deb313c66a828..61e26eb3bb46a 100644
--- a/Setup/InstallSchema.php
+++ b/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);
From c81abc12eb4cefd77a48b67cc02ccb6d8fea9805 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 16:49:26 +0200
Subject: [PATCH 0080/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- replace orderId with orderIncrementId
- fixes for integration tests
- db schema update
---
Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 4 ++--
_files/case.php | 9 ++++++++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index de0ddc7c1f03f..d37d6fd6f8a7f 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/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/_files/case.php b/_files/case.php
index de635ba750399..09f81b14725d1 100644
--- a/_files/case.php
+++ b/_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 6072c90049af9c25a42df5e48f7c60ae7ee66e3b Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 17:46:08 +0200
Subject: [PATCH 0081/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- fixes for static tests
---
Observer/PlaceOrder.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Observer/PlaceOrder.php b/Observer/PlaceOrder.php
index ef037ca7cd8e4..f5468d1aef667 100644
--- a/Observer/PlaceOrder.php
+++ b/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 022238a6ae585e29ca60756858f129b3af28b533 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 17:19:27 +0200
Subject: [PATCH 0082/2045] 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 Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
delete mode 100644 Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
diff --git a/Model/SignifydGateway/Request/CustomerOrders.php b/Model/SignifydGateway/Request/CustomerOrders.php
index 5fed6ebc99ab7..64d538e4c7cdb 100644
--- a/Model/SignifydGateway/Request/CustomerOrders.php
+++ b/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/Model/SignifydGateway/Request/UserAccountBuilder.php b/Model/SignifydGateway/Request/UserAccountBuilder.php
index 7133942741360..ac9bff2a14171 100644
--- a/Model/SignifydGateway/Request/UserAccountBuilder.php
+++ b/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/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php b/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
new file mode 100644
index 0000000000000..1e6d792d962f7
--- /dev/null
+++ b/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/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php b/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
deleted file mode 100644
index a5d6ea624c1a6..0000000000000
--- a/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 9cce1a27391484c64ec277f4c6fa24233dc296c4 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 17:22:56 +0200
Subject: [PATCH 0083/2045] 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/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php b/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
index 1e6d792d962f7..db89c9748bcc4 100644
--- a/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
+++ b/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
@@ -112,8 +112,6 @@ protected function setUp()
'logger' => $this->logger
]);
-
-
$this->initCurrencies();
$this->initOrderRepository();
From 17de3b6294ae662d9443c90ff6c37b92f93acebc Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 18:05:10 +0200
Subject: [PATCH 0084/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- fixes for static tests
---
Model/SignifydGateway/Request/CustomerOrders.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Model/SignifydGateway/Request/CustomerOrders.php b/Model/SignifydGateway/Request/CustomerOrders.php
index 64d538e4c7cdb..e757e16d4ae3f 100644
--- a/Model/SignifydGateway/Request/CustomerOrders.php
+++ b/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,
From 8030318024ba9a9ad4995a96fa889c81f3f27129 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 18:05:10 +0200
Subject: [PATCH 0085/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- fixes for static tests
---
_files/case.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/_files/case.php b/_files/case.php
index 09f81b14725d1..0bd47cb790d9e 100644
--- a/_files/case.php
+++ b/_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 52f084ae37f224a8a052f158b92c4500548e82e9 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 18:02:23 +0200
Subject: [PATCH 0086/2045] 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, 18 insertions(+), 13 deletions(-)
rename Model/{SignifydGateway/Request => }/CustomerOrders.php (93%)
rename Test/Unit/{SignifydGateway/Request => Model}/CustomerOrdersTest.php (94%)
diff --git a/Model/SignifydGateway/Request/CustomerOrders.php b/Model/CustomerOrders.php
similarity index 93%
rename from Model/SignifydGateway/Request/CustomerOrders.php
rename to Model/CustomerOrders.php
index 64d538e4c7cdb..bcfea4403c930 100644
--- a/Model/SignifydGateway/Request/CustomerOrders.php
+++ b/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;
@@ -55,20 +58,21 @@ class CustomerOrders
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param FilterBuilder $filterBuilder
* @param OrderRepositoryInterface $orderRepository
+ * @param CurrencyFactory $currencyFactory
+ * @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;
}
/**
@@ -81,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/Model/SignifydGateway/Request/UserAccountBuilder.php b/Model/SignifydGateway/Request/UserAccountBuilder.php
index ac9bff2a14171..5e02f108714c7 100644
--- a/Model/SignifydGateway/Request/UserAccountBuilder.php
+++ b/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/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php b/Test/Unit/Model/CustomerOrdersTest.php
similarity index 94%
rename from Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
rename to Test/Unit/Model/CustomerOrdersTest.php
index db89c9748bcc4..8798431f46873 100644
--- a/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
+++ b/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 c6379720294e6ce8bd7f2de7ea704fb423128a1d Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 18:19:58 +0200
Subject: [PATCH 0087/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Import all class names in CustomerOrders
---
Model/CustomerOrders.php | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/Model/CustomerOrders.php b/Model/CustomerOrders.php
index bcfea4403c930..2865e60ae3801 100644
--- a/Model/CustomerOrders.php
+++ b/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 072c004c005012e6bf85ec22a0fc16487a10363f Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 18:37:24 +0200
Subject: [PATCH 0088/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- flow fix
---
Observer/PlaceOrder.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Observer/PlaceOrder.php b/Observer/PlaceOrder.php
index f5468d1aef667..5f3d858e5cfec 100644
--- a/Observer/PlaceOrder.php
+++ b/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 56b062f1e37fedddf920a55f6f32d31faa890c2f Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 18:56:45 +0200
Subject: [PATCH 0089/2045] 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/Model/SignifydGateway/Request/UserAccountBuilder.php b/Model/SignifydGateway/Request/UserAccountBuilder.php
index 5e02f108714c7..60806e0ee05da 100644
--- a/Model/SignifydGateway/Request/UserAccountBuilder.php
+++ b/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 96da47241a9d82f16865eae7feb27bc76deb849b Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 18:51:27 +0200
Subject: [PATCH 0090/2045] 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/Model/SignifydGateway/Request/CreateCaseBuilder.php b/Model/SignifydGateway/Request/CreateCaseBuilder.php
index 1e2f35f7838bc..06f3a601889c9 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/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/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php b/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
index aa5e4ce48485b..13d119d7fe441 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
+++ b/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 446832df9e5642cb9227ea5417290ecdfb35805b Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 19:31:15 +0200
Subject: [PATCH 0091/2045] MAGETWO-62506: Stabilization
- Fix static tests
---
Test/Unit/Model/CustomerOrdersTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Test/Unit/Model/CustomerOrdersTest.php b/Test/Unit/Model/CustomerOrdersTest.php
index 8798431f46873..5e03d8806f5af 100644
--- a/Test/Unit/Model/CustomerOrdersTest.php
+++ b/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 7a6a42c86ab0e91a0881bac886404c743907814b Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 22 Dec 2016 10:22:52 +0200
Subject: [PATCH 0092/2045] MAGETWO-62506: Stabilization
- Fix static tests
---
Model/CustomerOrders.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Model/CustomerOrders.php b/Model/CustomerOrders.php
index 2865e60ae3801..58f563c56df7c 100644
--- a/Model/CustomerOrders.php
+++ b/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 e0c67702abce8e50b18c4473edd585c81b411035 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 19:34:43 +0200
Subject: [PATCH 0093/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- remove orderIncrementId
---
Api/Data/CaseInterface.php | 15 ---------------
Model/CaseEntity.php | 17 -----------------
Setup/InstallSchema.php | 1 -
3 files changed, 33 deletions(-)
diff --git a/Api/Data/CaseInterface.php b/Api/Data/CaseInterface.php
index cd1122e276c87..6a58effa19e4f 100644
--- a/Api/Data/CaseInterface.php
+++ b/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/Model/CaseEntity.php b/Model/CaseEntity.php
index efccab18da65b..a59763e091383 100644
--- a/Model/CaseEntity.php
+++ b/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/Setup/InstallSchema.php b/Setup/InstallSchema.php
index 61e26eb3bb46a..deb313c66a828 100644
--- a/Setup/InstallSchema.php
+++ b/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 3182538ba3477df1f5c7308347bf04193f73c689 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Thu, 22 Dec 2016 13:22:03 +0200
Subject: [PATCH 0094/2045] 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 view/frontend/layout/checkout_cart_index.xml
diff --git a/view/frontend/layout/checkout_cart_index.xml b/view/frontend/layout/checkout_cart_index.xml
new file mode 100644
index 0000000000000..07b04cc41d1bf
--- /dev/null
+++ b/view/frontend/layout/checkout_cart_index.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
From 83233c1cfe130ae9f791022c50e1d35298691504 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 23 Dec 2016 15:31:11 +0200
Subject: [PATCH 0095/2045] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- di refactoring
---
etc/adminhtml/di.xml | 6 +-----
etc/frontend/di.xml | 13 +------------
2 files changed, 2 insertions(+), 17 deletions(-)
diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml
index 2509a0be47376..4c7abb1d830bb 100644
--- a/etc/adminhtml/di.xml
+++ b/etc/adminhtml/di.xml
@@ -6,9 +6,5 @@
*/
-->
-
-
- Magento\Backend\Model\Session\Quote
-
-
+
diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml
index b5a97f00ac3a4..ceb009d24673a 100644
--- a/etc/frontend/di.xml
+++ b/etc/frontend/di.xml
@@ -6,16 +6,5 @@
*/
-->
-
-
-
- - Magento\Signifyd\Model\Ui\ConfigProvider
-
-
-
-
-
- Magento\Checkout\Model\Session
-
-
+
From b89084dcc8ce1b16b6ebad4eb248fc9b63da62b3 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 29 Dec 2016 14:31:11 +0200
Subject: [PATCH 0096/2045] MAGETWO-62738:
Magento\Signifyd\Model\CaseCreationServiceTest failed on mainline develop
- fixed issue with BiC in json_decode in PHP7.0
---
Model/SignifydGateway/ApiClient.php | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/Model/SignifydGateway/ApiClient.php b/Model/SignifydGateway/ApiClient.php
index 3b14773b3fd25..19b2b78a932b2 100644
--- a/Model/SignifydGateway/ApiClient.php
+++ b/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 a5825f873f61c608de37d5ee1b15854921b9c850 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 29 Dec 2016 15:17:44 +0200
Subject: [PATCH 0097/2045] MAGETWO-62738:
Magento\Signifyd\Model\CaseCreationServiceTest failed on mainline develop
- Fixed failed static test
---
Model/SignifydGateway/ApiClient.php | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/Model/SignifydGateway/ApiClient.php b/Model/SignifydGateway/ApiClient.php
index 19b2b78a932b2..8fc17cf1ac293 100644
--- a/Model/SignifydGateway/ApiClient.php
+++ b/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 6d13fe0f766213c1194d78d03c5360895cc218ed Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 29 Dec 2016 15:22:56 +0200
Subject: [PATCH 0098/2045] MAGETWO-62738:
Magento\Signifyd\Model\CaseCreationServiceTest failed on mainline develop
- Added suppress
---
Model/SignifydGateway/ApiClient.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Model/SignifydGateway/ApiClient.php b/Model/SignifydGateway/ApiClient.php
index 8fc17cf1ac293..566f08b498105 100644
--- a/Model/SignifydGateway/ApiClient.php
+++ b/Model/SignifydGateway/ApiClient.php
@@ -14,6 +14,8 @@
/**
* Encapsulates Signifyd API protocol.
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ApiClient
{
From 339738c412b2b77c19a6c6e244e014ed71a44156 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Tue, 3 Jan 2017 16:49:55 +0200
Subject: [PATCH 0099/2045] MAGETWO-62883: Update copyright year to 2017
- Changed copyright year
---
Model/SignifydGateway/ApiClient.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Model/SignifydGateway/ApiClient.php b/Model/SignifydGateway/ApiClient.php
index 566f08b498105..48d48ae4f81d4 100644
--- a/Model/SignifydGateway/ApiClient.php
+++ b/Model/SignifydGateway/ApiClient.php
@@ -1,6 +1,6 @@
Date: Wed, 4 Jan 2017 14:19:21 +0200
Subject: [PATCH 0100/2045] MAGETWO-62803: Signifyd webhook controller
- Added webhook controller
- Added webhook message validator
---
Controller/Webhooks/Index.php | 91 ++++++++++++++
.../Response/RawRequestBody.php | 22 ++++
.../Response/ResponseValidator.php | 112 ++++++++++++++++++
Model/SignifydGateway/Response/Webhook.php | 74 ++++++++++++
.../Response/WebhookException.php | 14 +++
.../Response/WebhookFactory.php | 80 +++++++++++++
etc/frontend/routes.xml | 14 +++
7 files changed, 407 insertions(+)
create mode 100644 Controller/Webhooks/Index.php
create mode 100644 Model/SignifydGateway/Response/RawRequestBody.php
create mode 100644 Model/SignifydGateway/Response/ResponseValidator.php
create mode 100644 Model/SignifydGateway/Response/Webhook.php
create mode 100644 Model/SignifydGateway/Response/WebhookException.php
create mode 100644 Model/SignifydGateway/Response/WebhookFactory.php
create mode 100644 etc/frontend/routes.xml
diff --git a/Controller/Webhooks/Index.php b/Controller/Webhooks/Index.php
new file mode 100644
index 0000000000000..2385e221038c8
--- /dev/null
+++ b/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/Model/SignifydGateway/Response/RawRequestBody.php b/Model/SignifydGateway/Response/RawRequestBody.php
new file mode 100644
index 0000000000000..ec77193ba3e5f
--- /dev/null
+++ b/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/Model/SignifydGateway/Response/Webhook.php b/Model/SignifydGateway/Response/Webhook.php
new file mode 100644
index 0000000000000..128daad8e08e4
--- /dev/null
+++ b/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/Model/SignifydGateway/Response/WebhookException.php b/Model/SignifydGateway/Response/WebhookException.php
new file mode 100644
index 0000000000000..8820e1be006dd
--- /dev/null
+++ b/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/etc/frontend/routes.xml b/etc/frontend/routes.xml
new file mode 100644
index 0000000000000..c7101ae29f069
--- /dev/null
+++ b/etc/frontend/routes.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
From 9d76e6702e437ddf359663781d60d0afc992b5f0 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 4 Jan 2017 14:46:38 +0200
Subject: [PATCH 0101/2045] MAGETWO-62803: Signifyd webhook controller
- Fix static
---
Model/SignifydGateway/Response/Webhook.php | 2 +-
Model/SignifydGateway/Response/WebhookException.php | 2 +-
Model/SignifydGateway/Response/WebhookFactory.php | 1 -
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/Model/SignifydGateway/Response/Webhook.php b/Model/SignifydGateway/Response/Webhook.php
index 128daad8e08e4..db251c83c407c 100644
--- a/Model/SignifydGateway/Response/Webhook.php
+++ b/Model/SignifydGateway/Response/Webhook.php
@@ -1,6 +1,6 @@
dataDecoder = $decoder;
}
-
/**
* Create webhook data object.
*
From 659a2d9c2a2d0e8fd24e3c82662a39f25383a77f Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 4 Jan 2017 18:44:01 +0200
Subject: [PATCH 0102/2045] MAGETWO-62806: Update case entity
- Added messages generators for comments history
- Added service for case updating
- Covered case updating by integration test
---
Api/CaseManagementInterface.php | 8 ++
Model/CaseEntity.php | 2 +-
Model/CaseManagement.php | 16 +++
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 +++++
i18n/en_US.csv | 9 +-
13 files changed, 479 insertions(+), 2 deletions(-)
create mode 100644 Model/CaseUpdatingService.php
create mode 100644 Model/CaseUpdatingServiceFactory.php
create mode 100644 Model/MessageGeneratorException.php
create mode 100644 Model/MessageGeneratorInterface.php
create mode 100644 Model/MessageGenerators/CaseCreation.php
create mode 100644 Model/MessageGenerators/CaseRescore.php
create mode 100644 Model/MessageGenerators/CaseReview.php
create mode 100644 Model/MessageGenerators/GuaranteeCompletion.php
create mode 100644 Model/Validators/CaseDataValidator.php
diff --git a/Api/CaseManagementInterface.php b/Api/CaseManagementInterface.php
index 09c2e8c0e164c..2cf5db226cbff 100644
--- a/Api/CaseManagementInterface.php
+++ b/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/Model/CaseEntity.php b/Model/CaseEntity.php
index a59763e091383..00951b6bb55f5 100644
--- a/Model/CaseEntity.php
+++ b/Model/CaseEntity.php
@@ -23,7 +23,7 @@ class CaseEntity extends AbstractModel implements CaseInterface
/**
* @var SerializerInterface
*/
- protected $serializer;
+ private $serializer;
/**
* @inheritdoc
diff --git a/Model/CaseManagement.php b/Model/CaseManagement.php
index 8705f9a812ae3..0af87b9b89d3f 100644
--- a/Model/CaseManagement.php
+++ b/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/Model/CaseUpdatingService.php b/Model/CaseUpdatingService.php
new file mode 100644
index 0000000000000..474ade3ce8797
--- /dev/null
+++ b/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/Model/CaseUpdatingServiceFactory.php b/Model/CaseUpdatingServiceFactory.php
new file mode 100644
index 0000000000000..c2bb54a4dc95d
--- /dev/null
+++ b/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/Model/MessageGeneratorException.php b/Model/MessageGeneratorException.php
new file mode 100644
index 0000000000000..3958595bc1f45
--- /dev/null
+++ b/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/Model/MessageGenerators/CaseRescore.php b/Model/MessageGenerators/CaseRescore.php
new file mode 100644
index 0000000000000..81765a66e278b
--- /dev/null
+++ b/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/Model/MessageGenerators/CaseReview.php b/Model/MessageGenerators/CaseReview.php
new file mode 100644
index 0000000000000..06cedd4ad42fb
--- /dev/null
+++ b/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/Model/MessageGenerators/GuaranteeCompletion.php b/Model/MessageGenerators/GuaranteeCompletion.php
new file mode 100644
index 0000000000000..051a48f68c7bb
--- /dev/null
+++ b/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/Model/Validators/CaseDataValidator.php b/Model/Validators/CaseDataValidator.php
new file mode 100644
index 0000000000000..1b44d26ec5f23
--- /dev/null
+++ b/Model/Validators/CaseDataValidator.php
@@ -0,0 +1,29 @@
+getData('caseId'))) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/i18n/en_US.csv b/i18n/en_US.csv
index 2785e217040ca..a10f12073987f 100644
--- a/i18n/en_US.csv
+++ b/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
From a65e6b0548fa342b933ed1b3997d67ad6fe6b8b3 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 4 Jan 2017 18:44:01 +0200
Subject: [PATCH 0103/2045] MAGETWO-62806: Update case entity
- Added messages generators for comments history
- Added service for case updating
- Covered case updating by integration test
---
Model/CaseUpdatingServiceTest.php | 100 ++++++++++++++++++++++++++++++
1 file changed, 100 insertions(+)
create mode 100644 Model/CaseUpdatingServiceTest.php
diff --git a/Model/CaseUpdatingServiceTest.php b/Model/CaseUpdatingServiceTest.php
new file mode 100644
index 0000000000000..750178e718e76
--- /dev/null
+++ b/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 13f06a5f6dba519b0d687b5f7914ce81cd88b81b Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 4 Jan 2017 18:52:08 +0200
Subject: [PATCH 0104/2045] MAGETWO-62806: Update case entity
- Updated method annotations
---
Api/CaseManagementInterface.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Api/CaseManagementInterface.php b/Api/CaseManagementInterface.php
index 2cf5db226cbff..1e72b30e30110 100644
--- a/Api/CaseManagementInterface.php
+++ b/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 ab5f9544548da393a189bd90be070df30428e978 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 4 Jan 2017 21:57:50 +0200
Subject: [PATCH 0105/2045] MAGETWO-62803: Signifyd webhook controller
- Refactoring webhook data structure
---
Controller/Webhooks/Handler.php | 101 +++++++++++++++
Controller/Webhooks/Index.php | 91 --------------
.../Response/RawRequestBody.php | 22 ----
Model/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 Controller/Webhooks/Handler.php
delete mode 100644 Controller/Webhooks/Index.php
delete mode 100644 Model/SignifydGateway/Response/RawRequestBody.php
delete mode 100644 Model/SignifydGateway/Response/Webhook.php
delete mode 100644 Model/SignifydGateway/Response/WebhookFactory.php
create mode 100644 Model/SignifydGateway/Response/WebhookMessage.php
rename Model/SignifydGateway/Response/{ResponseValidator.php => WebhookMessageValidator.php} (65%)
create mode 100644 Model/SignifydGateway/Response/WebhookRequest.php
create mode 100644 Model/SignifydGateway/Response/WebhookRequestReader.php
diff --git a/Controller/Webhooks/Handler.php b/Controller/Webhooks/Handler.php
new file mode 100644
index 0000000000000..c02fc3127d5c0
--- /dev/null
+++ b/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/Controller/Webhooks/Index.php b/Controller/Webhooks/Index.php
deleted file mode 100644
index 2385e221038c8..0000000000000
--- a/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/Model/SignifydGateway/Response/RawRequestBody.php b/Model/SignifydGateway/Response/RawRequestBody.php
deleted file mode 100644
index ec77193ba3e5f..0000000000000
--- a/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/Model/SignifydGateway/Response/WebhookFactory.php b/Model/SignifydGateway/Response/WebhookFactory.php
deleted file mode 100644
index daa88a0af0b06..0000000000000
--- a/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/Model/SignifydGateway/Response/WebhookMessage.php b/Model/SignifydGateway/Response/WebhookMessage.php
new file mode 100644
index 0000000000000..6ac5d9a0501bd
--- /dev/null
+++ b/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/Model/SignifydGateway/Response/ResponseValidator.php b/Model/SignifydGateway/Response/WebhookMessageValidator.php
similarity index 65%
rename from Model/SignifydGateway/Response/ResponseValidator.php
rename to Model/SignifydGateway/Response/WebhookMessageValidator.php
index 0ca443132c0e9..ff383d90b182c 100644
--- a/Model/SignifydGateway/Response/ResponseValidator.php
+++ b/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/Model/SignifydGateway/Response/WebhookRequest.php b/Model/SignifydGateway/Response/WebhookRequest.php
new file mode 100644
index 0000000000000..04367f6caf4b3
--- /dev/null
+++ b/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/Model/SignifydGateway/Response/WebhookRequestReader.php b/Model/SignifydGateway/Response/WebhookRequestReader.php
new file mode 100644
index 0000000000000..97bfaf2dc6213
--- /dev/null
+++ b/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 9df8190e6176a5a3cafbda6a9f39bf091f5d8d20 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 5 Jan 2017 13:25:26 +0200
Subject: [PATCH 0106/2045] 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
---
Api/CaseManagementInterface.php | 8 --
Api/CaseRepositoryInterface.php | 8 ++
Model/CaseManagement.php | 16 ----
Model/CaseRepository.php | 14 +++-
Model/CaseUpdatingService.php | 75 ++++++++-----------
Model/CaseUpdatingServiceFactory.php | 64 +++++-----------
Model/CaseUpdatingServiceInterface.php | 22 ++++++
Model/CommentsHistoryUpdater.php | 49 ++++++++++++
Model/MessageGenerators/CaseRescore.php | 14 ++--
Model/MessageGenerators/GeneratorFactory.php | 79 ++++++++++++++++++++
Model/StubCaseUpdatingService.php | 24 ++++++
Model/Validators/CaseDataValidator.php | 3 +-
12 files changed, 254 insertions(+), 122 deletions(-)
create mode 100644 Model/CaseUpdatingServiceInterface.php
create mode 100644 Model/CommentsHistoryUpdater.php
create mode 100644 Model/MessageGenerators/GeneratorFactory.php
create mode 100644 Model/StubCaseUpdatingService.php
diff --git a/Api/CaseManagementInterface.php b/Api/CaseManagementInterface.php
index 1e72b30e30110..bb13cc552c74e 100644
--- a/Api/CaseManagementInterface.php
+++ b/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/Api/CaseRepositoryInterface.php b/Api/CaseRepositoryInterface.php
index 0e63e9283ad28..d84bd4a3bf7d8 100644
--- a/Api/CaseRepositoryInterface.php
+++ b/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/Model/CaseManagement.php b/Model/CaseManagement.php
index 0af87b9b89d3f..8705f9a812ae3 100644
--- a/Model/CaseManagement.php
+++ b/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/Model/CaseRepository.php b/Model/CaseRepository.php
index f18ffc47356d9..9c68302074400 100644
--- a/Model/CaseRepository.php
+++ b/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/Model/CaseUpdatingService.php b/Model/CaseUpdatingService.php
index 474ade3ce8797..cbdb2c77714e9 100644
--- a/Model/CaseUpdatingService.php
+++ b/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/Model/CaseUpdatingServiceFactory.php b/Model/CaseUpdatingServiceFactory.php
index c2bb54a4dc95d..e626e8347d239 100644
--- a/Model/CaseUpdatingServiceFactory.php
+++ b/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/Model/CaseUpdatingServiceInterface.php b/Model/CaseUpdatingServiceInterface.php
new file mode 100644
index 0000000000000..1fa97ce3b2ad4
--- /dev/null
+++ b/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/Model/MessageGenerators/CaseRescore.php b/Model/MessageGenerators/CaseRescore.php
index 81765a66e278b..5df98975d51e2 100644
--- a/Model/MessageGenerators/CaseRescore.php
+++ b/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/Model/MessageGenerators/GeneratorFactory.php b/Model/MessageGenerators/GeneratorFactory.php
new file mode 100644
index 0000000000000..2b1b4a01b0ed3
--- /dev/null
+++ b/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/Model/StubCaseUpdatingService.php b/Model/StubCaseUpdatingService.php
new file mode 100644
index 0000000000000..3d8ff6478f06c
--- /dev/null
+++ b/Model/StubCaseUpdatingService.php
@@ -0,0 +1,24 @@
+
Date: Thu, 5 Jan 2017 13:25:26 +0200
Subject: [PATCH 0107/2045] 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
---
Model/CaseUpdatingServiceTest.php | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/Model/CaseUpdatingServiceTest.php b/Model/CaseUpdatingServiceTest.php
index 750178e718e76..ecc16820e934b 100644
--- a/Model/CaseUpdatingServiceTest.php
+++ b/Model/CaseUpdatingServiceTest.php
@@ -9,11 +9,10 @@
use Magento\Framework\DataObject;
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
-use Magento\Signifyd\Api\CaseManagementInterface;
+use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\TestFramework\Helper\Bootstrap;
use Magento\Signifyd\Model\MessageGenerators\CaseCreation;
-use Psr\Log\LoggerInterface;
+use Magento\TestFramework\Helper\Bootstrap;
/**
* Contains tests for case entity updating service.
@@ -39,13 +38,8 @@ protected function setUp()
$messageGenerator = $this->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 01cca135f9d00d551c0b947b7cb000df5040db7b Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Thu, 5 Jan 2017 13:27:32 +0200
Subject: [PATCH 0108/2045] MAGETWO-62855: Copyright Year Update 2017
---
Api/CaseCreationServiceInterface.php | 2 +-
Api/CaseManagementInterface.php | 2 +-
Api/CaseRepositoryInterface.php | 2 +-
Api/Data/CaseInterface.php | 2 +-
Api/Data/CaseSearchResultsInterface.php | 2 +-
Block/Fingerprint.php | 2 +-
Model/CaseCreationService.php | 2 +-
Model/CaseEntity.php | 2 +-
Model/CaseManagement.php | 2 +-
Model/CaseRepository.php | 2 +-
Model/Config.php | 2 +-
Model/CustomerOrders.php | 2 +-
Model/QuoteSession/Adminhtml/BackendSession.php | 2 +-
Model/QuoteSession/FrontendSession.php | 2 +-
Model/QuoteSession/QuoteSessionInterface.php | 2 +-
Model/ResourceModel/CaseEntity.php | 2 +-
Model/ResourceModel/CaseEntity/Collection.php | 2 +-
Model/SignifydGateway/ApiCallException.php | 2 +-
Model/SignifydGateway/ApiClient.php | 2 +-
Model/SignifydGateway/Debugger/BlackHole.php | 2 +-
Model/SignifydGateway/Debugger/DebuggerFactory.php | 2 +-
Model/SignifydGateway/Debugger/DebuggerInterface.php | 2 +-
Model/SignifydGateway/Debugger/Log.php | 2 +-
Model/SignifydGateway/Gateway.php | 2 +-
Model/SignifydGateway/GatewayException.php | 2 +-
Model/SignifydGateway/Request/AddressBuilder.php | 2 +-
Model/SignifydGateway/Request/CardBuilder.php | 2 +-
Model/SignifydGateway/Request/ClientVersionBuilder.php | 2 +-
Model/SignifydGateway/Request/CreateCaseBuilder.php | 2 +-
Model/SignifydGateway/Request/CreateCaseBuilderInterface.php | 2 +-
Model/SignifydGateway/Request/PurchaseBuilder.php | 2 +-
Model/SignifydGateway/Request/RecipientBuilder.php | 2 +-
Model/SignifydGateway/Request/SellerBuilder.php | 2 +-
Model/SignifydGateway/Request/UserAccountBuilder.php | 2 +-
Model/SignifydOrderSessionId.php | 2 +-
Observer/PlaceOrder.php | 2 +-
Setup/InstallSchema.php | 2 +-
Test/Unit/Model/CustomerOrdersTest.php | 2 +-
Test/Unit/Model/SignifydOrderSessionIdTest.php | 2 +-
etc/acl.xml | 2 +-
etc/adminhtml/di.xml | 2 +-
etc/adminhtml/system.xml | 2 +-
etc/config.xml | 2 +-
etc/constraints.xml | 4 ++--
etc/di.xml | 4 ++--
etc/events.xml | 4 ++--
etc/frontend/di.xml | 2 +-
etc/module.xml | 2 +-
registration.php | 2 +-
view/frontend/layout/checkout_cart_index.xml | 2 +-
view/frontend/layout/checkout_index_index.xml | 2 +-
view/frontend/templates/fingerprint.phtml | 4 ++--
52 files changed, 56 insertions(+), 56 deletions(-)
diff --git a/Api/CaseCreationServiceInterface.php b/Api/CaseCreationServiceInterface.php
index 7141d76371c06..1f66d2a9dc860 100644
--- a/Api/CaseCreationServiceInterface.php
+++ b/Api/CaseCreationServiceInterface.php
@@ -1,6 +1,6 @@
diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml
index 4c7abb1d830bb..1c827afa99dbc 100644
--- a/etc/adminhtml/di.xml
+++ b/etc/adminhtml/di.xml
@@ -1,7 +1,7 @@
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index a1ecbfcdff95c..20445a953edce 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -1,7 +1,7 @@
diff --git a/etc/config.xml b/etc/config.xml
index da606e2361c40..a02a363358533 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -1,7 +1,7 @@
diff --git a/etc/constraints.xml b/etc/constraints.xml
index 4947f84a5adc9..05836539b651e 100644
--- a/etc/constraints.xml
+++ b/etc/constraints.xml
@@ -1,7 +1,7 @@
@@ -11,4 +11,4 @@
-
\ No newline at end of file
+
diff --git a/etc/di.xml b/etc/di.xml
index 81d157887f7e1..159075019a512 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -1,7 +1,7 @@
@@ -12,4 +12,4 @@
-
\ No newline at end of file
+
diff --git a/etc/events.xml b/etc/events.xml
index dd4fff95b8c4a..c5e69449793a5 100644
--- a/etc/events.xml
+++ b/etc/events.xml
@@ -1,7 +1,7 @@
@@ -9,4 +9,4 @@
-
\ No newline at end of file
+
diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml
index ceb009d24673a..69a57a123344f 100644
--- a/etc/frontend/di.xml
+++ b/etc/frontend/di.xml
@@ -1,7 +1,7 @@
diff --git a/etc/module.xml b/etc/module.xml
index 2db123b053108..e2469080bdac2 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -1,7 +1,7 @@
diff --git a/registration.php b/registration.php
index d7c40b5aa176a..f3a11ab0a1183 100644
--- a/registration.php
+++ b/registration.php
@@ -1,6 +1,6 @@
diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml
index 07b04cc41d1bf..a9ea616735d56 100644
--- a/view/frontend/layout/checkout_index_index.xml
+++ b/view/frontend/layout/checkout_index_index.xml
@@ -1,7 +1,7 @@
diff --git a/view/frontend/templates/fingerprint.phtml b/view/frontend/templates/fingerprint.phtml
index 609391c2d695d..a68d46c7da2ef 100644
--- a/view/frontend/templates/fingerprint.phtml
+++ b/view/frontend/templates/fingerprint.phtml
@@ -1,6 +1,6 @@
escapeHtml($block->getSignifydOrderSessionId()); ?>"
src="https://cdn-scripts.signifyd.com/api/script-tag.js">
-
\ No newline at end of file
+
From aaa20d916ab1a93f12f47ceab8972bae8f1d11e6 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Thu, 5 Jan 2017 13:27:32 +0200
Subject: [PATCH 0109/2045] MAGETWO-62855: Copyright Year Update 2017
---
Block/FingerprintTest.php | 2 +-
Model/CaseCreationServiceTest.php | 2 +-
Model/CaseManagementTest.php | 2 +-
Model/CaseRepositoryTest.php | 2 +-
Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 2 +-
_files/case.php | 2 +-
_files/customer.php | 2 +-
_files/multiple_cases.php | 2 +-
_files/order_with_customer_and_two_simple_products.php | 2 +-
_files/order_with_guest_and_virtual_product.php | 2 +-
_files/store.php | 2 +-
11 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/Block/FingerprintTest.php b/Block/FingerprintTest.php
index 6708af55dddf9..4a3be835ca9b5 100644
--- a/Block/FingerprintTest.php
+++ b/Block/FingerprintTest.php
@@ -1,6 +1,6 @@
Date: Thu, 5 Jan 2017 13:40:55 +0200
Subject: [PATCH 0110/2045] MAGETWO-62806: Update case entity
- Refactored code according to failed static tests
---
Api/CaseManagementInterface.php | 2 +-
Model/CaseUpdatingService.php | 32 ++++++++++++++++++++++++--------
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/Api/CaseManagementInterface.php b/Api/CaseManagementInterface.php
index bb13cc552c74e..7c0445a4211c7 100644
--- a/Api/CaseManagementInterface.php
+++ b/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 1ca6e4b99cab4a768feca237138e1d89d1223a86 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 5 Jan 2017 14:24:37 +0200
Subject: [PATCH 0111/2045] MAGETWO-62803: Signifyd webhook controller
- Move webhook request validation to controller
---
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 Model/SignifydGateway/Response/WebhookException.php
rename Model/SignifydGateway/Response/{WebhookRequestReader.php => WebhookMessageReader.php} (51%)
delete mode 100644 Model/SignifydGateway/Response/WebhookMessageValidator.php
create mode 100644 Model/SignifydGateway/Response/WebhookRequestValidator.php
diff --git a/Controller/Webhooks/Handler.php b/Controller/Webhooks/Handler.php
index c02fc3127d5c0..d773149a373d5 100644
--- a/Controller/Webhooks/Handler.php
+++ b/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/Model/SignifydGateway/Response/WebhookException.php b/Model/SignifydGateway/Response/WebhookException.php
deleted file mode 100644
index 5b5f34320456d..0000000000000
--- a/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/Model/SignifydGateway/Response/WebhookRequestReader.php b/Model/SignifydGateway/Response/WebhookMessageReader.php
similarity index 51%
rename from Model/SignifydGateway/Response/WebhookRequestReader.php
rename to Model/SignifydGateway/Response/WebhookMessageReader.php
index 97bfaf2dc6213..3511101680f05 100644
--- a/Model/SignifydGateway/Response/WebhookRequestReader.php
+++ b/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/Model/SignifydGateway/Response/WebhookMessageValidator.php b/Model/SignifydGateway/Response/WebhookMessageValidator.php
deleted file mode 100644
index ff383d90b182c..0000000000000
--- a/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/Model/SignifydGateway/Response/WebhookRequest.php b/Model/SignifydGateway/Response/WebhookRequest.php
index 04367f6caf4b3..fb5e7781a15d9 100644
--- a/Model/SignifydGateway/Response/WebhookRequest.php
+++ b/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/Model/SignifydGateway/Response/WebhookRequestValidator.php b/Model/SignifydGateway/Response/WebhookRequestValidator.php
new file mode 100644
index 0000000000000..f9bf59a0fdb8c
--- /dev/null
+++ b/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 4012e5ef7102ceabcc115c83a78b233d610bd149 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 5 Jan 2017 15:20:15 +0200
Subject: [PATCH 0112/2045] MAGETWO-62803: Signifyd webhook controller
- Add redirect to 404 page if webhook request validation fails
---
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/Controller/Webhooks/Handler.php b/Controller/Webhooks/Handler.php
index d773149a373d5..346e41c8fb12f 100644
--- a/Controller/Webhooks/Handler.php
+++ b/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/Model/SignifydGateway/Response/WebhookMessageReader.php b/Model/SignifydGateway/Response/WebhookMessageReader.php
index 3511101680f05..26764eaef0cd3 100644
--- a/Model/SignifydGateway/Response/WebhookMessageReader.php
+++ b/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/Model/SignifydGateway/Response/WebhookRequest.php b/Model/SignifydGateway/Response/WebhookRequest.php
index fb5e7781a15d9..0a892dd02733d 100644
--- a/Model/SignifydGateway/Response/WebhookRequest.php
+++ b/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 f638f9741d3d3ccbe730cd3c7e944b56f2a1f08d Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 5 Jan 2017 15:37:23 +0200
Subject: [PATCH 0113/2045] MAGETWO-62806: Update case entity
- Refactored code according to code review comments
---
Model/CaseUpdatingServiceTest.php | 37 +++++++++++++++++--------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/Model/CaseUpdatingServiceTest.php b/Model/CaseUpdatingServiceTest.php
index ecc16820e934b..2fb3d0481a2e3 100644
--- a/Model/CaseUpdatingServiceTest.php
+++ b/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 abdda2ffe50fde0f1ef2954c2c9bc24fb2384aa6 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 5 Jan 2017 15:37:23 +0200
Subject: [PATCH 0114/2045] MAGETWO-62806: Update case entity
- Refactored code according to code review comments
---
Api/CaseRepositoryInterface.php | 2 +-
Model/CaseEntity.php | 24 ++++++++---
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 ++--
13 files changed, 75 insertions(+), 79 deletions(-)
diff --git a/Api/CaseRepositoryInterface.php b/Api/CaseRepositoryInterface.php
index d84bd4a3bf7d8..e985effe84b59 100644
--- a/Api/CaseRepositoryInterface.php
+++ b/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/Model/CaseUpdatingService.php b/Model/CaseUpdatingService.php
index 897b36b2635b9..90364ea541582 100644
--- a/Model/CaseUpdatingService.php
+++ b/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/Model/CaseUpdatingServiceFactory.php b/Model/CaseUpdatingServiceFactory.php
index e626e8347d239..e4cb86d724137 100644
--- a/Model/CaseUpdatingServiceFactory.php
+++ b/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/Model/CaseUpdatingServiceInterface.php b/Model/CaseUpdatingServiceInterface.php
index 1fa97ce3b2ad4..3e221f24682e1 100644
--- a/Model/CaseUpdatingServiceInterface.php
+++ b/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/Model/MessageGeneratorInterface.php b/Model/MessageGeneratorInterface.php
index 949c957748274..1126973e1abf2 100644
--- a/Model/MessageGeneratorInterface.php
+++ b/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/Model/MessageGenerators/CaseCreation.php b/Model/MessageGenerators/CaseCreation.php
index 7c65f923ff13f..72165538956b4 100644
--- a/Model/MessageGenerators/CaseCreation.php
+++ b/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/Model/MessageGenerators/CaseRescore.php b/Model/MessageGenerators/CaseRescore.php
index 5df98975d51e2..adbd604ed9376 100644
--- a/Model/MessageGenerators/CaseRescore.php
+++ b/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/Model/MessageGenerators/CaseReview.php b/Model/MessageGenerators/CaseReview.php
index 06cedd4ad42fb..c34c6592b751d 100644
--- a/Model/MessageGenerators/CaseReview.php
+++ b/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/Model/MessageGenerators/GuaranteeCompletion.php b/Model/MessageGenerators/GuaranteeCompletion.php
index 051a48f68c7bb..cfc73922c5d9a 100644
--- a/Model/MessageGenerators/GuaranteeCompletion.php
+++ b/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/Model/SignifydGateway/Response/WebhookMessage.php b/Model/SignifydGateway/Response/WebhookMessage.php
index 8ce2d78657725..f48c5c3a39a6f 100644
--- a/Model/SignifydGateway/Response/WebhookMessage.php
+++ b/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/Model/StubCaseUpdatingService.php b/Model/StubCaseUpdatingService.php
index 3d8ff6478f06c..9d7cffdd7ca1a 100644
--- a/Model/StubCaseUpdatingService.php
+++ b/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/Model/Validators/CaseDataValidator.php b/Model/Validators/CaseDataValidator.php
index 07b109b82745f..9827984956f54 100644
--- a/Model/Validators/CaseDataValidator.php
+++ b/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;
}
From 52f7f7fd9935b111f42bf1adf92ed3e539f4cf70 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 5 Jan 2017 19:31:36 +0200
Subject: [PATCH 0115/2045] MAGETWO-62803: Signifyd webhook controller
- Add WebhookRequestValidatorTest
- Add HandlerTest
---
Test/Unit/Controller/Webhooks/HandlerTest.php | 228 +++++++++++++++++
.../Response/WebhookRequestValidatorTest.php | 231 ++++++++++++++++++
2 files changed, 459 insertions(+)
create mode 100644 Test/Unit/Controller/Webhooks/HandlerTest.php
create mode 100644 Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
diff --git a/Test/Unit/Controller/Webhooks/HandlerTest.php b/Test/Unit/Controller/Webhooks/HandlerTest.php
new file mode 100644
index 0000000000000..8fcec8433f87a
--- /dev/null
+++ b/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/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php b/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
new file mode 100644
index 0000000000000..0209a64d5c94b
--- /dev/null
+++ b/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 8627d62c65739752003f77dad1f6bd4ef19e5dd6 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 6 Jan 2017 10:32:39 +0200
Subject: [PATCH 0116/2045] MAGETWO-62806: Update case entity
- Added unit tests
---
Model/CaseEntity.php | 10 +
Model/CaseUpdatingServiceFactory.php | 1 -
Model/CommentsHistoryUpdater.php | 2 +
Model/MessageGenerators/CaseRescore.php | 2 +-
.../Model/CaseUpdatingServiceFactoryTest.php | 169 +++++++++
Test/Unit/Model/CaseUpdatingServiceTest.php | 336 ++++++++++++++++++
.../Unit/Model/CommentsHistoryUpdaterTest.php | 140 ++++++++
.../GeneratorFactoryTest.php | 99 ++++++
.../Unit/Model/SignifydOrderSessionIdTest.php | 2 +-
9 files changed, 758 insertions(+), 3 deletions(-)
create mode 100644 Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
create mode 100644 Test/Unit/Model/CaseUpdatingServiceTest.php
create mode 100644 Test/Unit/Model/CommentsHistoryUpdaterTest.php
create mode 100644 Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
diff --git a/Model/CaseEntity.php b/Model/CaseEntity.php
index 647b8e2410301..6dd5c8fff0836 100644
--- a/Model/CaseEntity.php
+++ b/Model/CaseEntity.php
@@ -28,6 +28,16 @@ class CaseEntity extends AbstractModel implements CaseInterface
*/
private $serializer;
+ /**
+ * CaseEntity constructor.
+ *
+ * @param SerializerInterface $serializer
+ * @param Context $context
+ * @param Registry $registry
+ * @param AbstractResource|null $resource
+ * @param AbstractDb|null $resourceCollection
+ * @param array $data
+ */
public function __construct(
SerializerInterface $serializer,
Context $context,
diff --git a/Model/CaseUpdatingServiceFactory.php b/Model/CaseUpdatingServiceFactory.php
index e4cb86d724137..f9236a5fa9395 100644
--- a/Model/CaseUpdatingServiceFactory.php
+++ b/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/Model/CommentsHistoryUpdater.php b/Model/CommentsHistoryUpdater.php
index 914efd0cd7e6a..ff600b91d0a6b 100644
--- a/Model/CommentsHistoryUpdater.php
+++ b/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/Model/MessageGenerators/CaseRescore.php b/Model/MessageGenerators/CaseRescore.php
index adbd604ed9376..0f184590d4946 100644
--- a/Model/MessageGenerators/CaseRescore.php
+++ b/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/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php b/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
new file mode 100644
index 0000000000000..27e4f8b1e2f47
--- /dev/null
+++ b/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
@@ -0,0 +1,169 @@
+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/Test/Unit/Model/CaseUpdatingServiceTest.php b/Test/Unit/Model/CaseUpdatingServiceTest.php
new file mode 100644
index 0000000000000..6c72190b0f16c
--- /dev/null
+++ b/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/Test/Unit/Model/CommentsHistoryUpdaterTest.php b/Test/Unit/Model/CommentsHistoryUpdaterTest.php
new file mode 100644
index 0000000000000..e154fc32afa9a
--- /dev/null
+++ b/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/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
new file mode 100644
index 0000000000000..c154b22fcab2a
--- /dev/null
+++ b/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/Test/Unit/Model/SignifydOrderSessionIdTest.php b/Test/Unit/Model/SignifydOrderSessionIdTest.php
index f8a36ef172dc5..29ef7b88f4178 100644
--- a/Test/Unit/Model/SignifydOrderSessionIdTest.php
+++ b/Test/Unit/Model/SignifydOrderSessionIdTest.php
@@ -47,7 +47,7 @@ public function testGetByQuoteId()
$quoteId = 1;
$signifydOrderSessionId = 'asdfzxcv';
- $this->identityGenerator->expects(static::once())
+ $this->identityGenerator->expects(self::once())
->method('generateIdForData')
->with($quoteId)
->willReturn($signifydOrderSessionId);
From 24f5a8de83f63f9333900ecc0c749e783a4292b4 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 6 Jan 2017 10:50:30 +0200
Subject: [PATCH 0117/2045] MAGETWO-62806: Update case entity
- Fixed failed static tests
---
Model/CaseEntity.php | 10 +++++-----
Model/MessageGeneratorInterface.php | 2 +-
Test/Unit/Model/CaseUpdatingServiceFactoryTest.php | 4 +---
Test/Unit/Model/SignifydOrderSessionIdTest.php | 2 +-
4 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/Model/CaseEntity.php b/Model/CaseEntity.php
index 6dd5c8fff0836..d75285d228e4e 100644
--- a/Model/CaseEntity.php
+++ b/Model/CaseEntity.php
@@ -31,20 +31,20 @@ class CaseEntity extends AbstractModel implements CaseInterface
/**
* CaseEntity constructor.
*
- * @param SerializerInterface $serializer
* @param Context $context
* @param Registry $registry
+ * @param SerializerInterface $serializer
+ * @param array $data
* @param AbstractResource|null $resource
* @param AbstractDb|null $resourceCollection
- * @param array $data
*/
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/Model/MessageGeneratorInterface.php b/Model/MessageGeneratorInterface.php
index 1126973e1abf2..265b6ae1e5f5a 100644
--- a/Model/MessageGeneratorInterface.php
+++ b/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/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php b/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
index 27e4f8b1e2f47..4c73756e39ac8 100644
--- a/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
+++ b/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
@@ -158,9 +158,7 @@ public function testCreate()
$this->fakeObjectManager->expects(self::once())
->method('create')
- ->with(
- CaseUpdatingService::class, ['messageGenerator' => $messageGenerator]
- )
+ ->with(CaseUpdatingService::class, ['messageGenerator' => $messageGenerator])
->willReturn($service);
$result = $this->factory->create($type);
diff --git a/Test/Unit/Model/SignifydOrderSessionIdTest.php b/Test/Unit/Model/SignifydOrderSessionIdTest.php
index 29ef7b88f4178..2c1788ad288c2 100644
--- a/Test/Unit/Model/SignifydOrderSessionIdTest.php
+++ b/Test/Unit/Model/SignifydOrderSessionIdTest.php
@@ -1,6 +1,6 @@
Date: Fri, 6 Jan 2017 11:15:57 +0200
Subject: [PATCH 0118/2045] MAGETWO-62803: Signifyd webhook controller
- Add WebhookMessageReaderTest
---
.../Response/WebhookMessageReaderTest.php | 114 ++++++++++++++++++
1 file changed, 114 insertions(+)
create mode 100644 Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
diff --git a/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php b/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
new file mode 100644
index 0000000000000..03d13566e28c7
--- /dev/null
+++ b/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 f186ed63821ffaced8a70cceb507654a272b8b6f Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 6 Jan 2017 13:45:32 +0200
Subject: [PATCH 0119/2045] MAGETWO-62806: Update case entity
- Added possibility to store Signifyd case id on case entity creation
---
Model/CaseCreationService.php | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/Model/CaseCreationService.php b/Model/CaseCreationService.php
index c544ab30d6b35..39414d8f84fc1 100644
--- a/Model/CaseCreationService.php
+++ b/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) {
From e516cb92e4684dcf86f132194700e5a51c1ea3df Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 6 Jan 2017 13:45:32 +0200
Subject: [PATCH 0120/2045] MAGETWO-62806: Update case entity
- Added possibility to store Signifyd case id on case entity creation
---
Model/CaseCreationServiceTest.php | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/Model/CaseCreationServiceTest.php b/Model/CaseCreationServiceTest.php
index effee790eaa2a..fc4841c5388f8 100644
--- a/Model/CaseCreationServiceTest.php
+++ b/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 e7a9dcee11f800f9c9ed5ba7fd92fbbcab1e03d2 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Fri, 6 Jan 2017 13:49:37 +0200
Subject: [PATCH 0121/2045] 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 Test/Unit/Model/MessageGenerators/CaseCreationTest.php
create mode 100644 Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
create mode 100644 Test/Unit/Model/MessageGenerators/CaseReviewTest.php
create mode 100644 Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
diff --git a/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
new file mode 100644
index 0000000000000..91b542fc5dff5
--- /dev/null
+++ b/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/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
new file mode 100644
index 0000000000000..0d230544ee190
--- /dev/null
+++ b/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/Test/Unit/Model/MessageGenerators/CaseReviewTest.php b/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
new file mode 100644
index 0000000000000..f27676be8d534
--- /dev/null
+++ b/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/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php b/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
new file mode 100644
index 0000000000000..7e95d10bc3c6a
--- /dev/null
+++ b/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 637d7fd47b687a0094ff5e42b8e3151240fd4dd1 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Fri, 6 Jan 2017 14:13:33 +0200
Subject: [PATCH 0122/2045] MAGETWO-62806: Update case entity
- Fixed code styling
---
.../MessageGenerators/CaseCreationTest.php | 2 +-
.../MessageGenerators/CaseRescoreTest.php | 20 +++++++++----------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
index 91b542fc5dff5..639ffdf8c458c 100644
--- a/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 0d230544ee190..f32a6743664b6 100644
--- a/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/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
]);
@@ -119,7 +119,7 @@ public function testGenerateWithPreviousScore()
self::$data['score'],
self::$data['score']);
- $message = $this->CaseRescore->generate(self::$data);
+ $message = $this->caseRescore->generate(self::$data);
$this->assertEquals($phrase, $message);
}
@@ -134,7 +134,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
]);
@@ -144,8 +144,8 @@ public function testGenerateWithoutPreviousScore()
self::$data['score'],
null);
- $message = $this->CaseRescore->generate(self::$data);
+ $message = $this->caseRescore->generate(self::$data);
$this->assertEquals($phrase, $message);
}
-}
\ No newline at end of file
+}
From 818603462ed5e9d9f2750684ce14ea51ee0bc5f5 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Fri, 6 Jan 2017 14:24:10 +0200
Subject: [PATCH 0123/2045] MAGETWO-62806: Update case entity
- Fixed code styling
---
Test/Unit/Model/MessageGenerators/CaseRescoreTest.php | 6 ++++--
Test/Unit/Model/MessageGenerators/CaseReviewTest.php | 2 +-
.../Model/MessageGenerators/GuaranteeCompletionTest.php | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index f32a6743664b6..1662d830289d3 100644
--- a/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -117,7 +117,8 @@ 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);
@@ -142,7 +143,8 @@ 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);
diff --git a/Test/Unit/Model/MessageGenerators/CaseReviewTest.php b/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
index f27676be8d534..700a5de134bac 100644
--- a/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php b/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
index 7e95d10bc3c6a..250ce1a7553a4 100644
--- a/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
+++ b/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
@@ -61,4 +61,4 @@ public function testGenerate()
$this->assertEquals($phrase, $message);
}
-}
\ No newline at end of file
+}
From 9db52ccd024a953ccf303208c571d43b5be68f69 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Fri, 6 Jan 2017 15:40:24 +0200
Subject: [PATCH 0124/2045] 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/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
index 639ffdf8c458c..a268dacd57dd2 100644
--- a/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 1662d830289d3..a18927b811f3c 100644
--- a/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/CaseReviewTest.php b/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
index 700a5de134bac..4bbf45aa77d5f 100644
--- a/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php b/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
index 250ce1a7553a4..801d455b4f076 100644
--- a/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
+++ b/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 3aa15408bfbcefa88ba9b6743d69c4bb1d82b455 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 6 Jan 2017 16:33:13 +0200
Subject: [PATCH 0125/2045] MAGETWO-62807: Case information block on order
details page in admin panel
---
Block/Adminhtml/CaseInfo.php | 157 +++++++++++++++++++++
view/adminhtml/layout/sales_order_view.xml | 14 ++
view/adminhtml/templates/case_info.phtml | 54 +++++++
3 files changed, 225 insertions(+)
create mode 100644 Block/Adminhtml/CaseInfo.php
create mode 100644 view/adminhtml/layout/sales_order_view.xml
create mode 100644 view/adminhtml/templates/case_info.phtml
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
new file mode 100644
index 0000000000000..f2d29cd70170f
--- /dev/null
+++ b/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/view/adminhtml/layout/sales_order_view.xml b/view/adminhtml/layout/sales_order_view.xml
new file mode 100644
index 0000000000000..2e1b692b009f4
--- /dev/null
+++ b/view/adminhtml/layout/sales_order_view.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/view/adminhtml/templates/case_info.phtml b/view/adminhtml/templates/case_info.phtml
new file mode 100644
index 0000000000000..90327fcfeb64f
--- /dev/null
+++ b/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 2b910fdf953cd366bba0c29f8bf17eb0cf387c04 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 6 Jan 2017 18:15:02 +0200
Subject: [PATCH 0126/2045] MAGETWO-62809: Controller integration tests
- Added integration test for webhook controller
- Generation message for order comment history moved before saving case entity
---
Controller/Webhooks/Handler.php | 2 +-
Model/CaseUpdatingService.php | 6 ++----
Test/Unit/Controller/Webhooks/HandlerTest.php | 3 +--
Test/Unit/Model/CaseUpdatingServiceTest.php | 2 +-
4 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/Controller/Webhooks/Handler.php b/Controller/Webhooks/Handler.php
index 346e41c8fb12f..b513bb328db65 100644
--- a/Controller/Webhooks/Handler.php
+++ b/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/Model/CaseUpdatingService.php b/Model/CaseUpdatingService.php
index 90364ea541582..996b8e144c122 100644
--- a/Model/CaseUpdatingService.php
+++ b/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/Test/Unit/Controller/Webhooks/HandlerTest.php b/Test/Unit/Controller/Webhooks/HandlerTest.php
index 8fcec8433f87a..b9b29ae0766fa 100644
--- a/Test/Unit/Controller/Webhooks/HandlerTest.php
+++ b/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/Test/Unit/Model/CaseUpdatingServiceTest.php b/Test/Unit/Model/CaseUpdatingServiceTest.php
index 6c72190b0f16c..49d5fb676a71b 100644
--- a/Test/Unit/Model/CaseUpdatingServiceTest.php
+++ b/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);
From 7edb92b45d90c5fd84c62f6ec243f4f738bbece7 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 6 Jan 2017 18:15:02 +0200
Subject: [PATCH 0127/2045] MAGETWO-62809: Controller integration tests
- Added integration test for webhook controller
- Generation message for order comment history moved before saving case entity
---
Controller/Webhooks/HandlerTest.php | 95 +++++++++++++++++++++++++++++
_files/webhook_body.json | 1 +
2 files changed, 96 insertions(+)
create mode 100644 Controller/Webhooks/HandlerTest.php
create mode 100644 _files/webhook_body.json
diff --git a/Controller/Webhooks/HandlerTest.php b/Controller/Webhooks/HandlerTest.php
new file mode 100644
index 0000000000000..49e9ee0296f79
--- /dev/null
+++ b/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/_files/webhook_body.json b/_files/webhook_body.json
new file mode 100644
index 0000000000000..4308c8bf833ef
--- /dev/null
+++ b/_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 8eb599ca7b695c1eaf4df1b2f91c676f64a61b66 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 10 Jan 2017 12:45:21 +0200
Subject: [PATCH 0128/2045] MAGETWO-62807: Case information block on order
details page in admin panel
- static tests fix
---
Block/Adminhtml/CaseInfo.php | 6 ++++--
view/adminhtml/templates/case_info.phtml | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index f2d29cd70170f..2a61f66144ed2 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/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/view/adminhtml/templates/case_info.phtml b/view/adminhtml/templates/case_info.phtml
index 90327fcfeb64f..eff571558f2b6 100644
--- a/view/adminhtml/templates/case_info.phtml
+++ b/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 9444fe2752a5eda2530a6d35533c8d2e43090405 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 10 Jan 2017 13:03:01 +0200
Subject: [PATCH 0129/2045] MAGETWO-62809: Controller integration tests
- Remove webhook request object from object manager instances after test execution
---
Controller/Webhooks/HandlerTest.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Controller/Webhooks/HandlerTest.php b/Controller/Webhooks/HandlerTest.php
index 49e9ee0296f79..952f961298218 100644
--- a/Controller/Webhooks/HandlerTest.php
+++ b/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 3780fb6b8af5fbdb38246078682f356177c926b1 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 4 Jan 2017 17:25:47 +0200
Subject: [PATCH 0130/2045] 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 Test/Unit/Model/SignifydGateway/GatewayTest.php
diff --git a/Test/Unit/Model/SignifydGateway/GatewayTest.php b/Test/Unit/Model/SignifydGateway/GatewayTest.php
new file mode 100644
index 0000000000000..ea2d5986edd44
--- /dev/null
+++ b/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 b91451ce692317ddc5de1802116c22797528e83e Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 4 Jan 2017 17:41:02 +0200
Subject: [PATCH 0131/2045] 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/Model/SignifydGateway/Gateway.php b/Model/SignifydGateway/Gateway.php
index 2ffefb65937ee..218e917f15fa3 100644
--- a/Model/SignifydGateway/Gateway.php
+++ b/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/Test/Unit/Model/SignifydGateway/GatewayTest.php b/Test/Unit/Model/SignifydGateway/GatewayTest.php
index ea2d5986edd44..8d5fc9767ba7f 100644
--- a/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/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 2f52ed195b5e46916e04b11bc2aa26411dc423d4 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 12:31:40 +0200
Subject: [PATCH 0132/2045] 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)
---
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/Api/Data/CaseInterface.php b/Api/Data/CaseInterface.php
index 6a58effa19e4f..f534cd04da4c3 100644
--- a/Api/Data/CaseInterface.php
+++ b/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/Model/SignifydGateway/Gateway.php b/Model/SignifydGateway/Gateway.php
index 218e917f15fa3..930d5ef472a00 100644
--- a/Model/SignifydGateway/Gateway.php
+++ b/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/Test/Unit/Model/SignifydGateway/GatewayTest.php b/Test/Unit/Model/SignifydGateway/GatewayTest.php
index 8d5fc9767ba7f..94f4aef036981 100644
--- a/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/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 71d51e428a1731649cea0f00a81dcde930e49097 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 12:35:38 +0200
Subject: [PATCH 0133/2045] 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/Test/Unit/Model/SignifydGateway/GatewayTest.php b/Test/Unit/Model/SignifydGateway/GatewayTest.php
index 94f4aef036981..3a58a5db1ec43 100644
--- a/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/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 4d607dc752bb10ae2320701d7b701894e3e46a76 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 12:45:05 +0200
Subject: [PATCH 0134/2045] 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/Test/Unit/Model/SignifydGateway/GatewayTest.php b/Test/Unit/Model/SignifydGateway/GatewayTest.php
index 3a58a5db1ec43..74be30f8544dd 100644
--- a/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/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 e741178bbe0053c50cdee88875c4724165a2903e Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 12:54:09 +0200
Subject: [PATCH 0135/2045] MAGETWO-62822: Create Guarantee creation service
- changed copyright year
---
Api/Data/CaseInterface.php | 2 +-
Model/SignifydGateway/Gateway.php | 2 +-
Test/Unit/Model/SignifydGateway/GatewayTest.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Api/Data/CaseInterface.php b/Api/Data/CaseInterface.php
index f534cd04da4c3..13b6564ad3323 100644
--- a/Api/Data/CaseInterface.php
+++ b/Api/Data/CaseInterface.php
@@ -1,6 +1,6 @@
Date: Tue, 10 Jan 2017 13:39:14 +0200
Subject: [PATCH 0136/2045] MAGETWO-62822: Create Guarantee creation service
- added links to Signifyd API docs
---
Model/SignifydGateway/Gateway.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Model/SignifydGateway/Gateway.php b/Model/SignifydGateway/Gateway.php
index 2f732bef758c9..dfd21776e98ad 100644
--- a/Model/SignifydGateway/Gateway.php
+++ b/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 c7bc0ca2725464af9c3a83cd1bb0e7fc680e88eb Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 15:15:05 +0200
Subject: [PATCH 0137/2045] MAGETWO-63047: Add possibility to fetch raw HTTP
request data from Magento app request
---
Model/SignifydGateway/Response/WebhookRequest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Model/SignifydGateway/Response/WebhookRequest.php b/Model/SignifydGateway/Response/WebhookRequest.php
index 0a892dd02733d..4a77fa5245fe5 100644
--- a/Model/SignifydGateway/Response/WebhookRequest.php
+++ b/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 37d89583984f9801f4c72fd6884ec44477695823 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 10 Jan 2017 16:16:43 +0200
Subject: [PATCH 0138/2045] 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 +++++++++++++++++++
Model/MessageGenerators/GeneratorFactory.php | 9 ++
Model/MessageGenerators/GuaranteeCreation.php | 22 +++++
Setup/InstallSchema.php | 17 +++-
.../GeneratorFactoryTest.php | 2 +
.../GuaranteeCreationTest.php | 46 ++++++++++
6 files changed, 185 insertions(+), 3 deletions(-)
create mode 100644 Model/Guarantee/CreationService.php
create mode 100644 Model/MessageGenerators/GuaranteeCreation.php
create mode 100644 Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
diff --git a/Model/Guarantee/CreationService.php b/Model/Guarantee/CreationService.php
new file mode 100644
index 0000000000000..574972289188c
--- /dev/null
+++ b/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/Model/MessageGenerators/GeneratorFactory.php b/Model/MessageGenerators/GeneratorFactory.php
index 2b1b4a01b0ed3..4d0d12b03ebe8 100644
--- a/Model/MessageGenerators/GeneratorFactory.php
+++ b/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/Model/MessageGenerators/GuaranteeCreation.php b/Model/MessageGenerators/GuaranteeCreation.php
new file mode 100644
index 0000000000000..4c87b6cd5009b
--- /dev/null
+++ b/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/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
index c154b22fcab2a..ddc71b60b3816 100644
--- a/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php b/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
new file mode 100644
index 0000000000000..dd90e4c57da1d
--- /dev/null
+++ b/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],
+ ];
+ }
+}
From 3c9c7580c5f18e817246ad85c2eca998f86c304d Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 10 Jan 2017 16:16:43 +0200
Subject: [PATCH 0139/2045] 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/CreationServiceTest.php | 175 ++++++++++++++++++++++++
1 file changed, 175 insertions(+)
create mode 100644 Model/Guarantee/CreationServiceTest.php
diff --git a/Model/Guarantee/CreationServiceTest.php b/Model/Guarantee/CreationServiceTest.php
new file mode 100644
index 0000000000000..3547c6a8c8f29
--- /dev/null
+++ b/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 6063521a335a8e89d261d48d1a7325607aa70965 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 10 Jan 2017 17:26:51 +0200
Subject: [PATCH 0140/2045] MAGETWO-62821: Controller to submit for Guarantee
- Add controller to submit order for Guarantee
---
Controller/Adminhtml/Guarantee/Create.php | 60 +++++++++++++++++++++++
etc/adminhtml/routes.xml | 14 ++++++
i18n/en_US.csv | 5 +-
3 files changed, 78 insertions(+), 1 deletion(-)
create mode 100644 Controller/Adminhtml/Guarantee/Create.php
create mode 100644 etc/adminhtml/routes.xml
diff --git a/Controller/Adminhtml/Guarantee/Create.php b/Controller/Adminhtml/Guarantee/Create.php
new file mode 100644
index 0000000000000..7550a6d2c7ee3
--- /dev/null
+++ b/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/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml
new file mode 100644
index 0000000000000..1f94759c1b7b6
--- /dev/null
+++ b/etc/adminhtml/routes.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/i18n/en_US.csv b/i18n/en_US.csv
index a10f12073987f..fe940d75ef691 100644
--- a/i18n/en_US.csv
+++ b/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
From 731cd4955a9619152cd07b34220308ccd5f94b96 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 10 Jan 2017 17:26:51 +0200
Subject: [PATCH 0141/2045] MAGETWO-62821: Controller to submit for Guarantee
- Add controller to submit order for Guarantee
---
Controller/Adminhtml/Guarantee/CreateTest.php | 134 ++++++++++++++++++
Model/CaseUpdatingServiceTest.php | 2 +-
2 files changed, 135 insertions(+), 1 deletion(-)
create mode 100644 Controller/Adminhtml/Guarantee/CreateTest.php
diff --git a/Controller/Adminhtml/Guarantee/CreateTest.php b/Controller/Adminhtml/Guarantee/CreateTest.php
new file mode 100644
index 0000000000000..46c7464105ff6
--- /dev/null
+++ b/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/Model/CaseUpdatingServiceTest.php b/Model/CaseUpdatingServiceTest.php
index 2fb3d0481a2e3..25af28570737c 100644
--- a/Model/CaseUpdatingServiceTest.php
+++ b/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 a53a66b056c1835b83f7e45a6e983e8758730f98 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 10 Jan 2017 17:31:42 +0200
Subject: [PATCH 0142/2045] MAGETWO-62821: Controller to submit for Guarantee
- Add correct annotation
---
Controller/Adminhtml/Guarantee/Create.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Controller/Adminhtml/Guarantee/Create.php b/Controller/Adminhtml/Guarantee/Create.php
index 7550a6d2c7ee3..ea0ac3654e32b 100644
--- a/Controller/Adminhtml/Guarantee/Create.php
+++ b/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 453ca44a0def933b9ab68133577ed87e3bee39cb Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 10 Jan 2017 19:06:06 +0200
Subject: [PATCH 0143/2045] MAGETWO-62823: Update case entity on Guarantee
creation
- Updated integration test
---
Model/Guarantee/CreationServiceTest.php | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/Model/Guarantee/CreationServiceTest.php b/Model/Guarantee/CreationServiceTest.php
index 3547c6a8c8f29..c9ee755912e2f 100644
--- a/Model/Guarantee/CreationServiceTest.php
+++ b/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 397e3a74ac02214b93aca89b003ca1121401f52d Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 10 Jan 2017 19:41:35 +0200
Subject: [PATCH 0144/2045] MAGETWO-62806: Update case entity
- Renamed validator
---
Model/CaseUpdatingService.php | 14 ++++++------
Model/MessageGenerators/CaseCreation.php | 14 ++++++------
Model/MessageGenerators/CaseRescore.php | 14 ++++++------
...eDataValidator.php => CaseIdValidator.php} | 2 +-
Test/Unit/Model/CaseUpdatingServiceTest.php | 22 +++++++++----------
.../MessageGenerators/CaseCreationTest.php | 4 ++--
.../MessageGenerators/CaseRescoreTest.php | 14 ++++++------
7 files changed, 42 insertions(+), 42 deletions(-)
rename Model/Validators/{CaseDataValidator.php => CaseIdValidator.php} (95%)
diff --git a/Model/CaseUpdatingService.php b/Model/CaseUpdatingService.php
index 996b8e144c122..a4ca6b8b716a7 100644
--- a/Model/CaseUpdatingService.php
+++ b/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/Model/MessageGenerators/CaseCreation.php b/Model/MessageGenerators/CaseCreation.php
index 72165538956b4..a9affc97bbe4a 100644
--- a/Model/MessageGenerators/CaseCreation.php
+++ b/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/Model/MessageGenerators/CaseRescore.php b/Model/MessageGenerators/CaseRescore.php
index 0f184590d4946..b2ff54c5c1c3b 100644
--- a/Model/MessageGenerators/CaseRescore.php
+++ b/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/Model/Validators/CaseDataValidator.php b/Model/Validators/CaseIdValidator.php
similarity index 95%
rename from Model/Validators/CaseDataValidator.php
rename to Model/Validators/CaseIdValidator.php
index 9827984956f54..2dea2b30235c3 100644
--- a/Model/Validators/CaseDataValidator.php
+++ b/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/Test/Unit/Model/CaseUpdatingServiceTest.php b/Test/Unit/Model/CaseUpdatingServiceTest.php
index 49d5fb676a71b..2d09cbc8a540b 100644
--- a/Test/Unit/Model/CaseUpdatingServiceTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
index a268dacd57dd2..1daa58f6917d9 100644
--- a/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index a18927b811f3c..21d08fa5afb1f 100644
--- a/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/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 f87117635827b1f9ca7ba726a2d4c1e4b93e1838 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 11 Jan 2017 11:52:18 +0200
Subject: [PATCH 0145/2045] MAGETWO-62822: Create Guarantee creation service
- fixed doc blocks
---
Model/SignifydGateway/Gateway.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Model/SignifydGateway/Gateway.php b/Model/SignifydGateway/Gateway.php
index dfd21776e98ad..9e437ecff1be6 100644
--- a/Model/SignifydGateway/Gateway.php
+++ b/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 83af08589b9fbed12c9da5d28076900655fbc25c Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 11 Jan 2017 12:26:48 +0200
Subject: [PATCH 0146/2045] MAGETWO-62807: Case information block on order
details page in admin panel
- Covered with integration test
---
view/adminhtml/templates/case_info.phtml | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/view/adminhtml/templates/case_info.phtml b/view/adminhtml/templates/case_info.phtml
index eff571558f2b6..adcbb6f924609 100644
--- a/view/adminhtml/templates/case_info.phtml
+++ b/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()); ?>
-
-
-
-
From 1e7d7af9257f89f5ebe7a7a95f2d12e895517575 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 11 Jan 2017 12:26:48 +0200
Subject: [PATCH 0147/2045] MAGETWO-62807: Case information block on order
details page in admin panel
- Covered with integration test
---
Block/Adminhtml/CaseInfoTest.php | 112 +++++++++++++++++++++++++++++++
Block/FingerprintTest.php | 1 -
2 files changed, 112 insertions(+), 1 deletion(-)
create mode 100644 Block/Adminhtml/CaseInfoTest.php
diff --git a/Block/Adminhtml/CaseInfoTest.php b/Block/Adminhtml/CaseInfoTest.php
new file mode 100644
index 0000000000000..52cb4865eff96
--- /dev/null
+++ b/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/Block/FingerprintTest.php b/Block/FingerprintTest.php
index 6708af55dddf9..a9780a560381f 100644
--- a/Block/FingerprintTest.php
+++ b/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 668856cfa70cfed32a15315a5215ab56b5b7f951 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 11 Jan 2017 12:42:33 +0200
Subject: [PATCH 0148/2045] MAGETWO-62822: Create Guarantee creation service
- refactored unit test for more explicit failure reason
---
Test/Unit/Model/SignifydGateway/GatewayTest.php | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/Test/Unit/Model/SignifydGateway/GatewayTest.php b/Test/Unit/Model/SignifydGateway/GatewayTest.php
index f84300af354bd..b8bc60ebf77e9 100644
--- a/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/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 622523f07a5e9ffcbe5942e2eeee4b0bfb9a254b Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 11 Jan 2017 13:12:32 +0200
Subject: [PATCH 0149/2045] MAGETWO-62823: Update case entity on Guarantee
creation
- Updated service according to gateway changes
---
Model/Guarantee/CreationService.php | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/Model/Guarantee/CreationService.php b/Model/Guarantee/CreationService.php
index 574972289188c..18e500446b105 100644
--- a/Model/Guarantee/CreationService.php
+++ b/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());
From 2089c8c00117b0c7669c31bf5b562fd42abb2e35 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 11 Jan 2017 13:12:32 +0200
Subject: [PATCH 0150/2045] MAGETWO-62823: Update case entity on Guarantee
creation
- Updated service according to gateway changes
---
Model/Guarantee/CreationServiceTest.php | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/Model/Guarantee/CreationServiceTest.php b/Model/Guarantee/CreationServiceTest.php
index c9ee755912e2f..be529923f2fae 100644
--- a/Model/Guarantee/CreationServiceTest.php
+++ b/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 87069b02fe99b9d066702aca6b859cde358d2db5 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 11 Jan 2017 13:52:28 +0200
Subject: [PATCH 0151/2045] MAGETWO-62807: Case information block on order
details page in admin panel
- copyrights
---
Block/Adminhtml/CaseInfo.php | 2 +-
view/adminhtml/layout/sales_order_view.xml | 2 +-
view/adminhtml/templates/case_info.phtml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index 2a61f66144ed2..febea5219a2a4 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/Block/Adminhtml/CaseInfo.php
@@ -1,6 +1,6 @@
diff --git a/view/adminhtml/templates/case_info.phtml b/view/adminhtml/templates/case_info.phtml
index adcbb6f924609..be4a8d993d0ff 100644
--- a/view/adminhtml/templates/case_info.phtml
+++ b/view/adminhtml/templates/case_info.phtml
@@ -1,6 +1,6 @@
Date: Wed, 11 Jan 2017 13:52:28 +0200
Subject: [PATCH 0152/2045] MAGETWO-62807: Case information block on order
details page in admin panel
- copyrights
---
Block/Adminhtml/CaseInfoTest.php | 2 +-
Block/FingerprintTest.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Block/Adminhtml/CaseInfoTest.php b/Block/Adminhtml/CaseInfoTest.php
index 52cb4865eff96..95f4fd1f70db2 100644
--- a/Block/Adminhtml/CaseInfoTest.php
+++ b/Block/Adminhtml/CaseInfoTest.php
@@ -1,6 +1,6 @@
Date: Wed, 11 Jan 2017 15:18:40 +0200
Subject: [PATCH 0153/2045] MAGETWO-62806: Update case entity
- Renamed method
---
Model/CaseUpdatingService.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Model/CaseUpdatingService.php b/Model/CaseUpdatingService.php
index a4ca6b8b716a7..69263c9fef970 100644
--- a/Model/CaseUpdatingService.php
+++ b/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 41933b87798597a27049b246ea5ed4dca3e59ba7 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 11 Jan 2017 17:19:20 +0200
Subject: [PATCH 0154/2045] MAGETWO-62821: Controller to submit for Guarantee
- Fix static
---
Controller/Adminhtml/Guarantee/CreateTest.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Controller/Adminhtml/Guarantee/CreateTest.php b/Controller/Adminhtml/Guarantee/CreateTest.php
index 46c7464105ff6..7375ff8c6d983 100644
--- a/Controller/Adminhtml/Guarantee/CreateTest.php
+++ b/Controller/Adminhtml/Guarantee/CreateTest.php
@@ -1,7 +1,6 @@
Date: Wed, 11 Jan 2017 18:28:54 +0200
Subject: [PATCH 0155/2045] MAGETWO-62806: Update case entity
- Simplified messages generators
- Removed case id validator
---
Model/CaseUpdatingService.php | 11 +--
Model/MessageGenerators/BaseGenerator.php | 58 +++++++++++++
Model/MessageGenerators/CaseCreation.php | 43 ----------
Model/MessageGenerators/CaseRescore.php | 12 +--
Model/MessageGenerators/CaseReview.php | 30 -------
Model/MessageGenerators/GeneratorFactory.php | 23 +++--
.../MessageGenerators/GuaranteeCompletion.php | 27 ------
Model/MessageGenerators/GuaranteeCreation.php | 22 -----
Model/Validators/CaseIdValidator.php | 26 ------
Test/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 ----------
17 files changed, 173 insertions(+), 503 deletions(-)
create mode 100644 Model/MessageGenerators/BaseGenerator.php
delete mode 100644 Model/MessageGenerators/CaseCreation.php
delete mode 100644 Model/MessageGenerators/CaseReview.php
delete mode 100644 Model/MessageGenerators/GuaranteeCompletion.php
delete mode 100644 Model/MessageGenerators/GuaranteeCreation.php
delete mode 100644 Model/Validators/CaseIdValidator.php
create mode 100644 Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
delete mode 100644 Test/Unit/Model/MessageGenerators/CaseCreationTest.php
delete mode 100644 Test/Unit/Model/MessageGenerators/CaseReviewTest.php
delete mode 100644 Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
delete mode 100644 Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
diff --git a/Model/CaseUpdatingService.php b/Model/CaseUpdatingService.php
index 69263c9fef970..bf39d2356a28d 100644
--- a/Model/CaseUpdatingService.php
+++ b/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/Model/MessageGenerators/BaseGenerator.php b/Model/MessageGenerators/BaseGenerator.php
new file mode 100644
index 0000000000000..b76a0885a3611
--- /dev/null
+++ b/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/Model/MessageGenerators/CaseCreation.php b/Model/MessageGenerators/CaseCreation.php
deleted file mode 100644
index a9affc97bbe4a..0000000000000
--- a/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/Model/MessageGenerators/CaseRescore.php b/Model/MessageGenerators/CaseRescore.php
index b2ff54c5c1c3b..c62d4334755ed 100644
--- a/Model/MessageGenerators/CaseRescore.php
+++ b/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/Model/MessageGenerators/CaseReview.php b/Model/MessageGenerators/CaseReview.php
deleted file mode 100644
index c34c6592b751d..0000000000000
--- a/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/Model/MessageGenerators/GuaranteeCompletion.php b/Model/MessageGenerators/GuaranteeCompletion.php
deleted file mode 100644
index cfc73922c5d9a..0000000000000
--- a/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/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php b/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
new file mode 100644
index 0000000000000..8005b316f24b8
--- /dev/null
+++ b/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/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
deleted file mode 100644
index 1daa58f6917d9..0000000000000
--- a/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/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 21d08fa5afb1f..2dc7a4b14c492 100644
--- a/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/CaseReviewTest.php b/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
deleted file mode 100644
index 4bbf45aa77d5f..0000000000000
--- a/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/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
index ddc71b60b3816..f50b60ca436e2 100644
--- a/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php b/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
deleted file mode 100644
index 801d455b4f076..0000000000000
--- a/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/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php b/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
deleted file mode 100644
index dd90e4c57da1d..0000000000000
--- a/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],
- ];
- }
-}
From 46f570ae3471a55b712e5a00b51be60a78471e50 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 11 Jan 2017 18:28:54 +0200
Subject: [PATCH 0156/2045] MAGETWO-62806: Update case entity
- Simplified messages generators
- Removed case id validator
---
Model/CaseUpdatingServiceTest.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Model/CaseUpdatingServiceTest.php b/Model/CaseUpdatingServiceTest.php
index 25af28570737c..4862c160118d8 100644
--- a/Model/CaseUpdatingServiceTest.php
+++ b/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 392024762819a0510a257c5c62ba3d7516bd4c1a Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 11 Jan 2017 19:35:35 +0200
Subject: [PATCH 0157/2045] MAGETWO-62820: Create toolbar button to send
Guarantee request
---
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 Model/Guarantee/SubmitEligible.php
create mode 100644 view/adminhtml/web/js/request-send.js
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index febea5219a2a4..4fc88a5d4b614 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/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/Model/Guarantee/SubmitEligible.php b/Model/Guarantee/SubmitEligible.php
new file mode 100644
index 0000000000000..2571812fff03e
--- /dev/null
+++ b/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/view/adminhtml/templates/case_info.phtml b/view/adminhtml/templates/case_info.phtml
index be4a8d993d0ff..8a5a9605dc55a 100644
--- a/view/adminhtml/templates/case_info.phtml
+++ b/view/adminhtml/templates/case_info.phtml
@@ -43,5 +43,37 @@
+
+ getButtons() as $button):?>
+
+
+
+
+
diff --git a/view/adminhtml/web/js/request-send.js b/view/adminhtml/web/js/request-send.js
new file mode 100644
index 0000000000000..e68ab939cd4b9
--- /dev/null
+++ b/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 d172f268a287c1a0dca14cc8ef3c65074ef31145 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 11 Jan 2017 19:57:39 +0200
Subject: [PATCH 0158/2045] 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 Model/MessageGenerators/{BaseGenerator.php => PatternGenerator.php} (91%)
rename Test/Unit/Model/MessageGenerators/{BaseGeneratorTest.php => PatternGeneratorTest.php} (83%)
diff --git a/Model/MessageGenerators/GeneratorFactory.php b/Model/MessageGenerators/GeneratorFactory.php
index 4271605ddd2cb..6f9f855350441 100644
--- a/Model/MessageGenerators/GeneratorFactory.php
+++ b/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/Model/MessageGenerators/BaseGenerator.php b/Model/MessageGenerators/PatternGenerator.php
similarity index 91%
rename from Model/MessageGenerators/BaseGenerator.php
rename to Model/MessageGenerators/PatternGenerator.php
index b76a0885a3611..e69bb565360b7 100644
--- a/Model/MessageGenerators/BaseGenerator.php
+++ b/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/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
index f50b60ca436e2..ff7a6d06f6074 100644
--- a/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php b/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
similarity index 83%
rename from Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
rename to Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
index 8005b316f24b8..32d3aeec52d36 100644
--- a/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
+++ b/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 fb457e4cdde69e135a6c86b1f9f10bb262439a57 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 12 Jan 2017 13:04:29 +0200
Subject: [PATCH 0159/2045] 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 +
Api/CaseManagementInterface.php | 7 +-
Api/CaseRepositoryInterface.php | 24 +-
Api/GuaranteeCreationServiceInterface.php | 27 ++
Controller/Adminhtml/Guarantee/Create.php | 2 +-
Model/CaseCreationService.php | 9 +-
Model/CaseUpdatingService.php | 2 +-
Model/Guarantee/CreationService.php | 70 ++---
.../Model/Guarantee/CreationServiceTest.php | 270 ++++++++++++++++++
etc/di.xml | 1 +
10 files changed, 353 insertions(+), 60 deletions(-)
create mode 100644 Api/GuaranteeCreationServiceInterface.php
create mode 100644 Test/Unit/Model/Guarantee/CreationServiceTest.php
diff --git a/Api/CaseCreationServiceInterface.php b/Api/CaseCreationServiceInterface.php
index 7141d76371c06..139e3690403e7 100644
--- a/Api/CaseCreationServiceInterface.php
+++ b/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/Api/CaseManagementInterface.php b/Api/CaseManagementInterface.php
index 7c0445a4211c7..d02f5b5831413 100644
--- a/Api/CaseManagementInterface.php
+++ b/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/Api/CaseRepositoryInterface.php b/Api/CaseRepositoryInterface.php
index e985effe84b59..e265088ff673b 100644
--- a/Api/CaseRepositoryInterface.php
+++ b/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/Api/GuaranteeCreationServiceInterface.php b/Api/GuaranteeCreationServiceInterface.php
new file mode 100644
index 0000000000000..ad6d5e8098190
--- /dev/null
+++ b/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/Model/CaseCreationService.php b/Model/CaseCreationService.php
index 39414d8f84fc1..b546c9c63fe4f 100644
--- a/Model/CaseCreationService.php
+++ b/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/Model/CaseUpdatingService.php b/Model/CaseUpdatingService.php
index bf39d2356a28d..22a287357c771 100644
--- a/Model/CaseUpdatingService.php
+++ b/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/Model/Guarantee/CreationService.php b/Model/Guarantee/CreationService.php
index 18e500446b105..e3ca93842f29b 100644
--- a/Model/Guarantee/CreationService.php
+++ b/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/Test/Unit/Model/Guarantee/CreationServiceTest.php b/Test/Unit/Model/Guarantee/CreationServiceTest.php
new file mode 100644
index 0000000000000..b8ee861c1e5dd
--- /dev/null
+++ b/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/etc/di.xml b/etc/di.xml
index 81d157887f7e1..9a2eb0527d63f 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -11,5 +11,6 @@
+
\ No newline at end of file
From 0f254d012ec88da01da5f3d067c10fe112a9aff7 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 12 Jan 2017 13:05:17 +0200
Subject: [PATCH 0160/2045] MAGETWO-62822: Create Guarantee creation service
- refactoring
---
Model/Guarantee/CreationServiceTest.php | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/Model/Guarantee/CreationServiceTest.php b/Model/Guarantee/CreationServiceTest.php
index be529923f2fae..0900a9f1a2162 100644
--- a/Model/Guarantee/CreationServiceTest.php
+++ b/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 8ae2bfb8cbeead0dc92132ebea0669df4b07a91d Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Thu, 12 Jan 2017 13:30:37 +0200
Subject: [PATCH 0161/2045] MAGETWO-62820: Create toolbar button to send
Guarantee request
- Covered with integration test
---
Block/Adminhtml/CaseInfo.php | 24 ++++++++++++------------
view/adminhtml/templates/case_info.phtml | 2 +-
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index 4fc88a5d4b614..e46ea352740ca 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/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/view/adminhtml/templates/case_info.phtml b/view/adminhtml/templates/case_info.phtml
index 8a5a9605dc55a..4ff6820b702dc 100644
--- a/view/adminhtml/templates/case_info.phtml
+++ b/view/adminhtml/templates/case_info.phtml
@@ -58,7 +58,7 @@
"title": "escapeHtml($button['title']); ?>",
"requestURL": "",
"data": {
- "orderId": "getOrderId(); ?>"
+ "orderId": ""
},
"actions": [
{
From 8b29cfa46407d46cc8545b754db874cea6d9f755 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Thu, 12 Jan 2017 13:30:37 +0200
Subject: [PATCH 0162/2045] MAGETWO-62820: Create toolbar button to send
Guarantee request
- Covered with integration test
---
Block/Adminhtml/CaseInfoTest.php | 47 ++++++++++++++++++++++++++------
1 file changed, 39 insertions(+), 8 deletions(-)
diff --git a/Block/Adminhtml/CaseInfoTest.php b/Block/Adminhtml/CaseInfoTest.php
index 95f4fd1f70db2..f05c630c76b21 100644
--- a/Block/Adminhtml/CaseInfoTest.php
+++ b/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 dd44ea7abc9ee7de931d679170839a69db2760ab Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Thu, 12 Jan 2017 13:42:21 +0200
Subject: [PATCH 0163/2045] MAGETWO-62820: Create toolbar button to send
Guarantee request
- unit test and refactoring
---
Block/Adminhtml/CaseInfo.php | 4 +-
Test/Unit/Block/Adminhtml/CaseInfoTest.php | 78 ++++++++++++++++++++++
view/adminhtml/templates/case_info.phtml | 2 +-
3 files changed, 81 insertions(+), 3 deletions(-)
create mode 100644 Test/Unit/Block/Adminhtml/CaseInfoTest.php
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index e46ea352740ca..fe0960282218c 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/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/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/Test/Unit/Block/Adminhtml/CaseInfoTest.php
new file mode 100644
index 0000000000000..5384ce749a0bd
--- /dev/null
+++ b/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/view/adminhtml/templates/case_info.phtml b/view/adminhtml/templates/case_info.phtml
index 4ff6820b702dc..98b2b63224d4f 100644
--- a/view/adminhtml/templates/case_info.phtml
+++ b/view/adminhtml/templates/case_info.phtml
@@ -8,7 +8,7 @@
?>
isModuleActive() || !($case = $block->getCaseEntity())) {
+ if (!$block->isServiceActive() || !($case = $block->getCaseEntity())) {
return '';
}
?>
From d69a3cd1d87a044eb30843b84a2b3a8a95e1b98c Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 12 Jan 2017 14:28:25 +0200
Subject: [PATCH 0164/2045] MAGETWO-62825: Guarantee creation possibility
validator
-Add class for checking submit guarantee possibility
---
Block/Adminhtml/CaseInfo.php | 14 ++---
Model/Guarantee/SubmitEligible.php | 88 ++++++++++++++++++++++++++----
2 files changed, 84 insertions(+), 18 deletions(-)
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index fe0960282218c..9684a8bd10789 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/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/Model/Guarantee/SubmitEligible.php b/Model/Guarantee/SubmitEligible.php
index 2571812fff03e..5e216a49c281d 100644
--- a/Model/Guarantee/SubmitEligible.php
+++ b/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 6c7496f8954ef8c5f1854a6bcbefa9225a39b27a Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 12 Jan 2017 18:57:17 +0200
Subject: [PATCH 0165/2045] MAGETWO-54393: Updating Order Status using Webhooks
- Refactored code according to code review comments
---
Controller/Webhooks/Handler.php | 8 ++--
.../CreationService.php} | 6 +--
.../StubUpdatingService.php} | 4 +-
.../UpdatingService.php} | 14 +++---
.../UpdatingServiceFactory.php} | 13 +++---
.../UpdatingServiceInterface.php} | 4 +-
Model/CommentsHistoryUpdater.php | 4 ++
Model/Guarantee/CreationService.php | 12 ++---
Model/MessageGenerators/CaseRescore.php | 8 ++--
.../GeneratorException.php} | 4 +-
Model/MessageGenerators/GeneratorFactory.php | 4 +-
.../GeneratorInterface.php} | 6 +--
Model/MessageGenerators/PatternGenerator.php | 7 +--
Test/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 +-
etc/di.xml | 2 +-
21 files changed, 127 insertions(+), 109 deletions(-)
rename Model/{CaseCreationService.php => CaseServices/CreationService.php} (92%)
rename Model/{StubCaseUpdatingService.php => CaseServices/StubUpdatingService.php} (77%)
rename Model/{CaseUpdatingService.php => CaseServices/UpdatingService.php} (87%)
rename Model/{CaseUpdatingServiceFactory.php => CaseServices/UpdatingServiceFactory.php} (83%)
rename Model/{CaseUpdatingServiceInterface.php => CaseServices/UpdatingServiceInterface.php} (81%)
rename Model/{MessageGeneratorException.php => MessageGenerators/GeneratorException.php} (68%)
rename Model/{MessageGeneratorInterface.php => MessageGenerators/GeneratorInterface.php} (80%)
rename Test/Unit/Model/{CaseUpdatingServiceFactoryTest.php => CaseServices/UpdatingServiceFactoryTest.php} (72%)
rename Test/Unit/Model/{CaseUpdatingServiceTest.php => CaseServices/UpdatingServiceTest.php} (88%)
diff --git a/Controller/Webhooks/Handler.php b/Controller/Webhooks/Handler.php
index b513bb328db65..ce89bdf163dc3 100644
--- a/Controller/Webhooks/Handler.php
+++ b/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/Model/CaseCreationService.php b/Model/CaseServices/CreationService.php
similarity index 92%
rename from Model/CaseCreationService.php
rename to Model/CaseServices/CreationService.php
index b546c9c63fe4f..d735aae67df41 100644
--- a/Model/CaseCreationService.php
+++ b/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/Model/StubCaseUpdatingService.php b/Model/CaseServices/StubUpdatingService.php
similarity index 77%
rename from Model/StubCaseUpdatingService.php
rename to Model/CaseServices/StubUpdatingService.php
index 9d7cffdd7ca1a..6c91235f22799 100644
--- a/Model/StubCaseUpdatingService.php
+++ b/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/Model/CaseUpdatingService.php b/Model/CaseServices/UpdatingService.php
similarity index 87%
rename from Model/CaseUpdatingService.php
rename to Model/CaseServices/UpdatingService.php
index 22a287357c771..8f002b82bac7b 100644
--- a/Model/CaseUpdatingService.php
+++ b/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/Model/CaseUpdatingServiceFactory.php b/Model/CaseServices/UpdatingServiceFactory.php
similarity index 83%
rename from Model/CaseUpdatingServiceFactory.php
rename to Model/CaseServices/UpdatingServiceFactory.php
index f9236a5fa9395..8c6023fae1445 100644
--- a/Model/CaseUpdatingServiceFactory.php
+++ b/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/Model/CaseUpdatingServiceInterface.php b/Model/CaseServices/UpdatingServiceInterface.php
similarity index 81%
rename from Model/CaseUpdatingServiceInterface.php
rename to Model/CaseServices/UpdatingServiceInterface.php
index 3e221f24682e1..33d44e7c8cf3b 100644
--- a/Model/CaseUpdatingServiceInterface.php
+++ b/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/Model/CommentsHistoryUpdater.php b/Model/CommentsHistoryUpdater.php
index ff600b91d0a6b..976e5aa0a9dc6 100644
--- a/Model/CommentsHistoryUpdater.php
+++ b/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/Model/Guarantee/CreationService.php b/Model/Guarantee/CreationService.php
index e3ca93842f29b..5801c4f490608 100644
--- a/Model/Guarantee/CreationService.php
+++ b/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/Model/MessageGenerators/CaseRescore.php b/Model/MessageGenerators/CaseRescore.php
index c62d4334755ed..0c716b122501b 100644
--- a/Model/MessageGenerators/CaseRescore.php
+++ b/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/Model/MessageGeneratorException.php b/Model/MessageGenerators/GeneratorException.php
similarity index 68%
rename from Model/MessageGeneratorException.php
rename to Model/MessageGenerators/GeneratorException.php
index 3958595bc1f45..ed967da231165 100644
--- a/Model/MessageGeneratorException.php
+++ b/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/Model/MessageGenerators/GeneratorFactory.php b/Model/MessageGenerators/GeneratorFactory.php
index 6f9f855350441..cd40b6b9ab7ac 100644
--- a/Model/MessageGenerators/GeneratorFactory.php
+++ b/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/Model/MessageGeneratorInterface.php b/Model/MessageGenerators/GeneratorInterface.php
similarity index 80%
rename from Model/MessageGeneratorInterface.php
rename to Model/MessageGenerators/GeneratorInterface.php
index 265b6ae1e5f5a..11726bf74a924 100644
--- a/Model/MessageGeneratorInterface.php
+++ b/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/Model/MessageGenerators/PatternGenerator.php b/Model/MessageGenerators/PatternGenerator.php
index e69bb565360b7..a03b32b243dd5 100644
--- a/Model/MessageGenerators/PatternGenerator.php
+++ b/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/Test/Unit/Controller/Webhooks/HandlerTest.php b/Test/Unit/Controller/Webhooks/HandlerTest.php
index b9b29ae0766fa..9ce3d0ad682fb 100644
--- a/Test/Unit/Controller/Webhooks/HandlerTest.php
+++ b/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/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php b/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
similarity index 72%
rename from Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
rename to Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
index 4c73756e39ac8..0639c420c9b9b 100644
--- a/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
+++ b/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/Test/Unit/Model/CaseUpdatingServiceTest.php b/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
similarity index 88%
rename from Test/Unit/Model/CaseUpdatingServiceTest.php
rename to Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index 321953aef2120..581682c37b6a4 100644
--- a/Test/Unit/Model/CaseUpdatingServiceTest.php
+++ b/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/Test/Unit/Model/CommentsHistoryUpdaterTest.php b/Test/Unit/Model/CommentsHistoryUpdaterTest.php
index e154fc32afa9a..d85b0410ee27a 100644
--- a/Test/Unit/Model/CommentsHistoryUpdaterTest.php
+++ b/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/Test/Unit/Model/Guarantee/CreationServiceTest.php b/Test/Unit/Model/Guarantee/CreationServiceTest.php
index b8ee861c1e5dd..119165407e301 100644
--- a/Test/Unit/Model/Guarantee/CreationServiceTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 2dc7a4b14c492..dc47f1458926c 100644
--- a/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php b/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
index 32d3aeec52d36..e819a958cf6bf 100644
--- a/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
+++ b/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/etc/di.xml b/etc/di.xml
index 9a2eb0527d63f..4b517ee389af9 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -10,7 +10,7 @@
-
+
\ No newline at end of file
From a7e577751b532ee911c1ad4b7b7f57fc68986e11 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 12 Jan 2017 18:57:17 +0200
Subject: [PATCH 0166/2045] MAGETWO-54393: Updating Order Status using Webhooks
- Refactored code according to code review comments
---
Controller/Webhooks/HandlerTest.php | 1 -
Model/CaseManagementTest.php | 2 --
.../CreationServiceTest.php} | 16 ++++-----
.../UpdatingServiceTest.php} | 11 +++---
Model/Guarantee/CreationServiceTest.php | 36 +++++--------------
_files/case.php | 1 -
6 files changed, 21 insertions(+), 46 deletions(-)
rename Model/{CaseCreationServiceTest.php => CaseServices/CreationServiceTest.php} (93%)
rename Model/{CaseUpdatingServiceTest.php => CaseServices/UpdatingServiceTest.php} (90%)
diff --git a/Controller/Webhooks/HandlerTest.php b/Controller/Webhooks/HandlerTest.php
index 952f961298218..c6d523a8cd50d 100644
--- a/Controller/Webhooks/HandlerTest.php
+++ b/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/Model/CaseManagementTest.php b/Model/CaseManagementTest.php
index 7271cdffcca21..9725956c6ceb6 100644
--- a/Model/CaseManagementTest.php
+++ b/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/Model/CaseCreationServiceTest.php b/Model/CaseServices/CreationServiceTest.php
similarity index 93%
rename from Model/CaseCreationServiceTest.php
rename to Model/CaseServices/CreationServiceTest.php
index fc4841c5388f8..4838bf794a513 100644
--- a/Model/CaseCreationServiceTest.php
+++ b/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/Model/CaseUpdatingServiceTest.php b/Model/CaseServices/UpdatingServiceTest.php
similarity index 90%
rename from Model/CaseUpdatingServiceTest.php
rename to Model/CaseServices/UpdatingServiceTest.php
index 4862c160118d8..04813b3eb19f7 100644
--- a/Model/CaseUpdatingServiceTest.php
+++ b/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/Model/Guarantee/CreationServiceTest.php b/Model/Guarantee/CreationServiceTest.php
index 0900a9f1a2162..aa26311acf87a 100644
--- a/Model/Guarantee/CreationServiceTest.php
+++ b/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/_files/case.php b/_files/case.php
index 0bd47cb790d9e..2c12403f93b63 100644
--- a/_files/case.php
+++ b/_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 ecc50d9b35033990fe8625362cd2c62a4a28a43a Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 12 Jan 2017 19:09:40 +0200
Subject: [PATCH 0167/2045] MAGETWO-62825: Guarantee creation possibility
validator
- Cover with unit test
---
Block/Adminhtml/CaseInfo.php | 14 +-
...ligible.php => CreateGuaranteeAbility.php} | 39 ++-
.../Guarantee/CreateGuaranteeAbilityTest.php | 257 ++++++++++++++++++
3 files changed, 288 insertions(+), 22 deletions(-)
rename Model/Guarantee/{SubmitEligible.php => CreateGuaranteeAbility.php} (75%)
create mode 100644 Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index 9684a8bd10789..6fcdf24aafa3f 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/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/Model/Guarantee/SubmitEligible.php b/Model/Guarantee/CreateGuaranteeAbility.php
similarity index 75%
rename from Model/Guarantee/SubmitEligible.php
rename to Model/Guarantee/CreateGuaranteeAbility.php
index 5e216a49c281d..57bd9f0f90830 100644
--- a/Model/Guarantee/SubmitEligible.php
+++ b/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/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php b/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
new file mode 100644
index 0000000000000..db279c724e263
--- /dev/null
+++ b/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');
+ }
+}
From 6d8236f1cbd31fe3fc2325dfe9ece82f823269c9 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 12 Jan 2017 19:09:40 +0200
Subject: [PATCH 0168/2045] MAGETWO-62825: Guarantee creation possibility
validator
- Cover with unit test
---
Controller/Adminhtml/Guarantee/CreateTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Controller/Adminhtml/Guarantee/CreateTest.php b/Controller/Adminhtml/Guarantee/CreateTest.php
index 7375ff8c6d983..7add34e1a4586 100644
--- a/Controller/Adminhtml/Guarantee/CreateTest.php
+++ b/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 229c2963f3b95123fa76aa7e2227bf7cabfa7678 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Thu, 12 Jan 2017 19:20:43 +0200
Subject: [PATCH 0169/2045] MAGETWO-62807: Case information block on order
details page in admin panel
- refactoring
---
Block/Adminhtml/CaseInfo.php | 162 +++++++++++++++++------
view/adminhtml/templates/case_info.phtml | 19 +--
2 files changed, 130 insertions(+), 51 deletions(-)
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index 6fcdf24aafa3f..c2e424db42496 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/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/view/adminhtml/templates/case_info.phtml b/view/adminhtml/templates/case_info.phtml
index 98b2b63224d4f..b0160e263ef98 100644
--- a/view/adminhtml/templates/case_info.phtml
+++ b/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 09601db4cb3c6f7e4e33510db7e455307ad17e85 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 13 Jan 2017 11:56:46 +0200
Subject: [PATCH 0170/2045] MAGETWO-54393: Updating Order Status using Webhooks
- Refactored code according to code review
---
Api/Data/CaseInterface.php | 3 +-
Api/GuaranteeCreationServiceInterface.php | 2 -
Model/CommentsHistoryUpdater.php | 1 -
Model/Guarantee/CreationService.php | 27 ++--
.../Model/Guarantee/CreationServiceTest.php | 118 +++++++-----------
5 files changed, 58 insertions(+), 93 deletions(-)
diff --git a/Api/Data/CaseInterface.php b/Api/Data/CaseInterface.php
index 13b6564ad3323..6e05d2334656e 100644
--- a/Api/Data/CaseInterface.php
+++ b/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/Api/GuaranteeCreationServiceInterface.php b/Api/GuaranteeCreationServiceInterface.php
index ad6d5e8098190..3f3b0e223c71c 100644
--- a/Api/GuaranteeCreationServiceInterface.php
+++ b/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/Model/CommentsHistoryUpdater.php b/Model/CommentsHistoryUpdater.php
index 976e5aa0a9dc6..2f794aedca67a 100644
--- a/Model/CommentsHistoryUpdater.php
+++ b/Model/CommentsHistoryUpdater.php
@@ -26,7 +26,6 @@ class CommentsHistoryUpdater
*/
public function __construct(HistoryFactory $historyFactory)
{
-
$this->historyFactory = $historyFactory;
}
diff --git a/Model/Guarantee/CreationService.php b/Model/Guarantee/CreationService.php
index 5801c4f490608..0288476bd6fcd 100644
--- a/Model/Guarantee/CreationService.php
+++ b/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/Test/Unit/Model/Guarantee/CreationServiceTest.php b/Test/Unit/Model/Guarantee/CreationServiceTest.php
index 119165407e301..cd41ce4c34d3b 100644
--- a/Test/Unit/Model/Guarantee/CreationServiceTest.php
+++ b/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) {
From 889c6f65c2c66d46a7189c71cbf4f997848da075 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 13 Jan 2017 11:56:46 +0200
Subject: [PATCH 0171/2045] MAGETWO-54393: Updating Order Status using Webhooks
- Refactored code according to code review
---
Model/Guarantee/CreationServiceTest.php | 5 ++---
Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 2 +-
_files/order_with_customer_and_two_simple_products.php | 2 +-
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/Model/Guarantee/CreationServiceTest.php b/Model/Guarantee/CreationServiceTest.php
index aa26311acf87a..f42945a6bacd7 100644
--- a/Model/Guarantee/CreationServiceTest.php
+++ b/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/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index d37d6fd6f8a7f..d1a863290d13f 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/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/_files/order_with_customer_and_two_simple_products.php b/_files/order_with_customer_and_two_simple_products.php
index 8f69f7a281610..a38cd01873cfc 100644
--- a/_files/order_with_customer_and_two_simple_products.php
+++ b/_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 40608fb3cce2c980b037bd7349222c4a731c60c3 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 13 Jan 2017 13:08:23 +0200
Subject: [PATCH 0172/2045] MAGETWO-62807: Case information block on order
details page in admin panel
- Extension point created for sales order view
---
view/adminhtml/layout/sales_order_view.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/view/adminhtml/layout/sales_order_view.xml b/view/adminhtml/layout/sales_order_view.xml
index 998e5e82a686a..4764050633c85 100644
--- a/view/adminhtml/layout/sales_order_view.xml
+++ b/view/adminhtml/layout/sales_order_view.xml
@@ -7,7 +7,7 @@
-->
-
+
From 9278c2799a618686294b0e66b00b1780ef255c72 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 13 Jan 2017 13:15:32 +0200
Subject: [PATCH 0173/2045] MAGETWO-62825: Guarantee creation possibility
validator
- Add CreateGuarantyAbility check to controller
---
Controller/Adminhtml/Guarantee/Create.php | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/Controller/Adminhtml/Guarantee/Create.php b/Controller/Adminhtml/Guarantee/Create.php
index 837f22e976b9c..54d41fe8bfa7c 100644
--- a/Controller/Adminhtml/Guarantee/Create.php
+++ b/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.')
);
From c77e60b60b51a8bd9b73a51bf81165e4a6144977 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 13 Jan 2017 13:15:32 +0200
Subject: [PATCH 0174/2045] MAGETWO-62825: Guarantee creation possibility
validator
- Add CreateGuarantyAbility check to controller
---
Controller/Adminhtml/Guarantee/CreateTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Controller/Adminhtml/Guarantee/CreateTest.php b/Controller/Adminhtml/Guarantee/CreateTest.php
index 7add34e1a4586..71afeb8ad6dc9 100644
--- a/Controller/Adminhtml/Guarantee/CreateTest.php
+++ b/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 93b6a3d166775b53e30121dc1de5414a7fbc5948 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 13 Jan 2017 17:28:35 +0200
Subject: [PATCH 0175/2045] MAGETWO-62807: Case information block on order
details page in admin panel
- refactoring
---
Block/Adminhtml/CaseInfo.php | 112 +++++++++++----------
Test/Unit/Block/Adminhtml/CaseInfoTest.php | 108 +++++++++++++++++++-
2 files changed, 162 insertions(+), 58 deletions(-)
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index c2e424db42496..7ddd7b02e0a0d 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/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/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/Test/Unit/Block/Adminhtml/CaseInfoTest.php
index 5384ce749a0bd..060a3a1e49421 100644
--- a/Test/Unit/Block/Adminhtml/CaseInfoTest.php
+++ b/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 1c155abd6a30e14399d5adb012e2c38ad7236df4 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 13 Jan 2017 18:28:35 +0200
Subject: [PATCH 0176/2045] MAGETWO-62807: Case information block on order
details page in admin panel
- refactoring
---
Block/Adminhtml/CaseInfo.php | 4 ++--
view/adminhtml/templates/case_info.phtml | 10 +++++-----
view/adminhtml/web/js/request-send.js | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index 7ddd7b02e0a0d..6d964c3c92e89 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/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/view/adminhtml/templates/case_info.phtml b/view/adminhtml/templates/case_info.phtml
index b0160e263ef98..679a584fa2ad5 100644
--- a/view/adminhtml/templates/case_info.phtml
+++ b/view/adminhtml/templates/case_info.phtml
@@ -46,20 +46,20 @@
getButtons() as $button):?>
-
From 01de305ba9f4f1760e452cde768d19a2294ebf20 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 3 Feb 2017 13:06:38 +0200
Subject: [PATCH 0220/2045] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Added missed namespace
---
Observer/CancelOrderTest.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Observer/CancelOrderTest.php b/Observer/CancelOrderTest.php
index d00204191aa32..0f79f299a04a8 100644
--- a/Observer/CancelOrderTest.php
+++ b/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;
From e9ba3c8cdbfe2cd8d614e1de4115b0037dad2a4d Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 3 Feb 2017 13:08:33 +0200
Subject: [PATCH 0221/2045] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Fixed auto formatted namespace
---
Observer/CancelOrderTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Observer/CancelOrderTest.php b/Observer/CancelOrderTest.php
index 0f79f299a04a8..94f1779312f1f 100644
--- a/Observer/CancelOrderTest.php
+++ b/Observer/CancelOrderTest.php
@@ -17,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 86a56e80f3a21c9eeac1b1132cdfbc6c6accf374 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 3 Feb 2017 13:11:14 +0200
Subject: [PATCH 0222/2045] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- static test fix
---
Setup/InstallData.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Setup/InstallData.php b/Setup/InstallData.php
index d82a16a5a0286..1436d52d4b823 100644
--- a/Setup/InstallData.php
+++ b/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 e5bbdfe367ccc8fab11d244c566dba8e6cb47301 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 3 Feb 2017 14:00:10 +0200
Subject: [PATCH 0223/2045] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- SalesArchive dependency added
---
composer.json | 1 +
etc/module.xml | 1 +
2 files changed, 2 insertions(+)
diff --git a/composer.json b/composer.json
index cf9b2311bbba5..87ce791eae618 100644
--- a/composer.json
+++ b/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/etc/module.xml b/etc/module.xml
index e2469080bdac2..5d973cc95851e 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -9,6 +9,7 @@
+
From b0af63bd7abce53cdf773e77c5f13cd522537372 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 6 Feb 2017 11:02:23 +0200
Subject: [PATCH 0224/2045] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- type attribute removed for VirtualType
---
etc/di.xml | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/etc/di.xml b/etc/di.xml
index 5dadfb8d8928e..21faa4cb098af 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -14,8 +14,7 @@
-
-
+
-
@@ -29,8 +28,7 @@
-
-
+
-
From b05b3ca2b2957b65cc72872e71527536c1f60e78 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 6 Feb 2017 14:02:30 +0200
Subject: [PATCH 0225/2045] 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
---
.../SignifydGateway/Request/PurchaseBuilder.php | 17 +++++++++++++++--
composer.json | 3 ++-
etc/module.xml | 1 +
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/Model/SignifydGateway/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
index dd464f73c1df2..524b4a2e6ab8f 100644
--- a/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/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/composer.json b/composer.json
index cf9b2311bbba5..a2e936bb27511 100644
--- a/composer.json
+++ b/composer.json
@@ -9,7 +9,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/etc/module.xml b/etc/module.xml
index e2469080bdac2..81d97d6fdc0d4 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -14,6 +14,7 @@
+
From 8a2be19fc51a49b626efff7573a80f44a0579c65 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 6 Feb 2017 18:28:15 +0200
Subject: [PATCH 0226/2045] MAGETWO-64154: Rearrange Signifyd information table
in order view template
---
Block/Adminhtml/CaseInfo.php | 142 ++++++---------------
Test/Unit/Block/Adminhtml/CaseInfoTest.php | 127 +++++++++++++-----
view/adminhtml/templates/case_info.phtml | 48 +++----
3 files changed, 151 insertions(+), 166 deletions(-)
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index 873f5c6df1da7..af3d30785efaf 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/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/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/Test/Unit/Block/Adminhtml/CaseInfoTest.php
index f44639bfce96b..0d046800d9523 100644
--- a/Test/Unit/Block/Adminhtml/CaseInfoTest.php
+++ b/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/view/adminhtml/templates/case_info.phtml b/view/adminhtml/templates/case_info.phtml
index 08ebd64400ca0..6649ca8fcd2fe 100644
--- a/view/adminhtml/templates/case_info.phtml
+++ b/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()); ?>
+
+
+
+
+
From 3883e43bc2ccd0f6c9cbc1d771c0ba88a88388eb Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 6 Feb 2017 18:28:15 +0200
Subject: [PATCH 0227/2045] MAGETWO-64154: Rearrange Signifyd information table
in order view template
---
Block/Adminhtml/CaseInfoTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Block/Adminhtml/CaseInfoTest.php b/Block/Adminhtml/CaseInfoTest.php
index c59c64a5f60e1..95a24791e6911 100644
--- a/Block/Adminhtml/CaseInfoTest.php
+++ b/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 8b743a321a237de4b0f1a555892a228270a0818c Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 6 Feb 2017 18:57:54 +0200
Subject: [PATCH 0228/2045] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Reimplemented API interfaces
- Updated purchase builder
---
Model/PaymentVerificationFactory.php | 66 +++++++++++++++++++
.../Request/PurchaseBuilder.php | 50 +++++++++++---
etc/di.xml | 6 ++
3 files changed, 112 insertions(+), 10 deletions(-)
create mode 100644 Model/PaymentVerificationFactory.php
diff --git a/Model/PaymentVerificationFactory.php b/Model/PaymentVerificationFactory.php
new file mode 100644
index 0000000000000..f6f3024fdeee1
--- /dev/null
+++ b/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/Model/SignifydGateway/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
index 524b4a2e6ab8f..48e2c3837fc71 100644
--- a/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/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/etc/di.xml b/etc/di.xml
index 6ca2783da49c5..df5fdb79435ea 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -14,4 +14,10 @@
+
+
+
+ Magento\Payment\Gateway\Config\Config
+
+
From 45272be4cb8fa34c0353b9649f0be349aedc9d66 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 6 Feb 2017 19:24:16 +0200
Subject: [PATCH 0229/2045] MAGETWO-63945: Add extension point to sales grid
indexer
---
Model/CaseManagement.php | 4 +-
Model/CaseServices/UpdatingService.php | 13 +++-
Model/OrderGridUpdater.php | 53 +++++++++++++
Model/OrderIdListProvider.php | 53 +++++++++++++
Setup/InstallSchema.php | 7 +-
.../CaseServices/UpdatingServiceTest.php | 37 ++++++++-
Test/Unit/Model/OrderGridUpdaterTest.php | 75 +++++++++++++++++++
etc/di.xml | 13 ++++
8 files changed, 248 insertions(+), 7 deletions(-)
create mode 100644 Model/OrderGridUpdater.php
create mode 100644 Model/OrderIdListProvider.php
create mode 100644 Test/Unit/Model/OrderGridUpdaterTest.php
diff --git a/Model/CaseManagement.php b/Model/CaseManagement.php
index 79b90333209f1..4f62dbb563ce6 100644
--- a/Model/CaseManagement.php
+++ b/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/Model/CaseServices/UpdatingService.php b/Model/CaseServices/UpdatingService.php
index f0336938d2515..70a214fe19a31 100644
--- a/Model/CaseServices/UpdatingService.php
+++ b/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/Model/OrderGridUpdater.php b/Model/OrderGridUpdater.php
new file mode 100644
index 0000000000000..eeb67a90b6475
--- /dev/null
+++ b/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/Model/OrderIdListProvider.php b/Model/OrderIdListProvider.php
new file mode 100644
index 0000000000000..8093ce23f55d8
--- /dev/null
+++ b/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/Setup/InstallSchema.php b/Setup/InstallSchema.php
index e6436a3f1b7e3..8107d06285bff 100644
--- a/Setup/InstallSchema.php
+++ b/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/Test/Unit/Model/CaseServices/UpdatingServiceTest.php b/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index 76ed91c887538..1dff0981e5d5b 100644
--- a/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
+++ b/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/Test/Unit/Model/OrderGridUpdaterTest.php b/Test/Unit/Model/OrderGridUpdaterTest.php
new file mode 100644
index 0000000000000..90f672cc956ce
--- /dev/null
+++ b/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/etc/di.xml b/etc/di.xml
index 21faa4cb098af..c6956be08db64 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -14,8 +14,21 @@
+
+
+ Magento\Sales\Model\ResourceModel\Order\Grid
+
+
+
+
+
+ - Magento\Signifyd\Model\OrderIdListProvider
+
+
+
+ SignifydIdListProvider
-
- signifyd_case
From 7dbd5b4077c16a99397bcba0c8f2614aed3424e9 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 6 Feb 2017 19:24:16 +0200
Subject: [PATCH 0230/2045] MAGETWO-63945: Add extension point to sales grid
indexer
---
Model/CaseManagementTest.php | 1 +
Model/CaseServices/UpdatingServiceTest.php | 28 ++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/Model/CaseManagementTest.php b/Model/CaseManagementTest.php
index fee9bb9f06b01..fd772594f48ef 100644
--- a/Model/CaseManagementTest.php
+++ b/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/Model/CaseServices/UpdatingServiceTest.php b/Model/CaseServices/UpdatingServiceTest.php
index 01ac31dd249d1..f04108d2b3c8a 100644
--- a/Model/CaseServices/UpdatingServiceTest.php
+++ b/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 afa432daa4e0e6a8845bb49b2f3e704745ab495b Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 6 Feb 2017 19:28:44 +0200
Subject: [PATCH 0231/2045] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- update connection name
---
Setup/InstallData.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Setup/InstallData.php b/Setup/InstallData.php
index 1436d52d4b823..6e37ac63c493e 100644
--- a/Setup/InstallData.php
+++ b/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 6c0f82a6a8de4b97e94c20db80567e514df76053 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 7 Feb 2017 09:57:49 +0200
Subject: [PATCH 0232/2045] MAGETWO-63945: Add extension point to sales grid
indexer
- Rename IdListProviderComposite to IdListProvider
- Fix static
---
Model/CaseServices/UpdatingService.php | 1 -
Model/OrderGridUpdater.php | 2 +-
etc/di.xml | 2 +-
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/Model/CaseServices/UpdatingService.php b/Model/CaseServices/UpdatingService.php
index 70a214fe19a31..f93bb08eb0761 100644
--- a/Model/CaseServices/UpdatingService.php
+++ b/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/Model/OrderGridUpdater.php b/Model/OrderGridUpdater.php
index eeb67a90b6475..0e6cbefedb483 100644
--- a/Model/OrderGridUpdater.php
+++ b/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/etc/di.xml b/etc/di.xml
index c6956be08db64..795efd16e104e 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -19,7 +19,7 @@
Magento\Sales\Model\ResourceModel\Order\Grid
-
+
- Magento\Signifyd\Model\OrderIdListProvider
From 88ccf68fb45be9e22580505e0e195f8013b48429 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 7 Feb 2017 11:04:38 +0200
Subject: [PATCH 0233/2045] MAGETWO-63945: Add extension point to sales grid
indexer
- Add constraints for sales_order_grid
---
Model/OrderGridUpdater.php | 2 +-
etc/constraints.xml | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/Model/OrderGridUpdater.php b/Model/OrderGridUpdater.php
index 0e6cbefedb483..5cefddaf21022 100644
--- a/Model/OrderGridUpdater.php
+++ b/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/etc/constraints.xml b/etc/constraints.xml
index 05836539b651e..ee14127721f75 100644
--- a/etc/constraints.xml
+++ b/etc/constraints.xml
@@ -10,5 +10,8 @@
+
+
+
From 1c45c34c25e288b50e3db3f31905095ed45b8bd4 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 7 Feb 2017 12:41:21 +0200
Subject: [PATCH 0234/2045] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- update Oms and set default connection name
---
etc/di.xml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/etc/di.xml b/etc/di.xml
index 795efd16e104e..ef4fde4efd846 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -55,4 +55,9 @@
+
+
+ sales
+
+
From 177e7ae8953c55fd228d62426c62aaddc6e1085a Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 7 Feb 2017 13:26:53 +0200
Subject: [PATCH 0235/2045] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Refactored code according to code review.
---
Model/PaymentVerificationFactory.php | 31 +++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/Model/PaymentVerificationFactory.php b/Model/PaymentVerificationFactory.php
index f6f3024fdeee1..e228df47b040c 100644
--- a/Model/PaymentVerificationFactory.php
+++ b/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 14cdee76c17a20760069877b522fb39b80fcd55a Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 7 Feb 2017 13:33:41 +0200
Subject: [PATCH 0236/2045] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Updated doc blocks
---
Block/Adminhtml/CaseInfo.php | 2 --
Observer/PlaceOrder.php | 4 ----
2 files changed, 6 deletions(-)
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index af3d30785efaf..9aaf15ca4a688 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/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/Observer/PlaceOrder.php b/Observer/PlaceOrder.php
index 764caaf97adea..d260de96c5a9e 100644
--- a/Observer/PlaceOrder.php
+++ b/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 9dbb2b3616716c70ade6fe37bac8523ac17d920d Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 7 Feb 2017 14:52:15 +0200
Subject: [PATCH 0237/2045] MAGETWO-63945: Add extension point to sales grid
indexer
- Refactoring according CR
---
Model/CaseServices/UpdatingService.php | 6 +++---
.../NotSyncedOrderIdListProvider.php} | 9 +++++----
Model/{ => SalesOrderGrid}/OrderGridUpdater.php | 2 +-
Test/Unit/Model/CaseServices/UpdatingServiceTest.php | 4 ++--
Test/Unit/Model/OrderGridUpdaterTest.php | 4 ++--
etc/di.xml | 6 +++---
6 files changed, 16 insertions(+), 15 deletions(-)
rename Model/{OrderIdListProvider.php => SalesOrderGrid/NotSyncedOrderIdListProvider.php} (80%)
rename Model/{ => SalesOrderGrid}/OrderGridUpdater.php (95%)
diff --git a/Model/CaseServices/UpdatingService.php b/Model/CaseServices/UpdatingService.php
index f93bb08eb0761..40f28b32ec0eb 100644
--- a/Model/CaseServices/UpdatingService.php
+++ b/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/Model/OrderIdListProvider.php b/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
similarity index 80%
rename from Model/OrderIdListProvider.php
rename to Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
index 8093ce23f55d8..cbcd376d35b2e 100644
--- a/Model/OrderIdListProvider.php
+++ b/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/Model/OrderGridUpdater.php b/Model/SalesOrderGrid/OrderGridUpdater.php
similarity index 95%
rename from Model/OrderGridUpdater.php
rename to Model/SalesOrderGrid/OrderGridUpdater.php
index 5cefddaf21022..5cb87d3316645 100644
--- a/Model/OrderGridUpdater.php
+++ b/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/Test/Unit/Model/CaseServices/UpdatingServiceTest.php b/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index 1dff0981e5d5b..a2894939042dd 100644
--- a/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
+++ b/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/Test/Unit/Model/OrderGridUpdaterTest.php b/Test/Unit/Model/OrderGridUpdaterTest.php
index 90f672cc956ce..b210d35502bdb 100644
--- a/Test/Unit/Model/OrderGridUpdaterTest.php
+++ b/Test/Unit/Model/OrderGridUpdaterTest.php
@@ -7,7 +7,7 @@
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;
/**
@@ -40,7 +40,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/etc/di.xml b/etc/di.xml
index ef4fde4efd846..5a2a65e6efc9e 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -14,15 +14,15 @@
-
+
Magento\Sales\Model\ResourceModel\Order\Grid
-
+
- - Magento\Signifyd\Model\OrderIdListProvider
+ - Magento\Signifyd\Model\SalesOrderGrid\NotSyncedOrderIdListProvider
From be3abfb432414d961a1ae9b66fc4187ab07ceb95 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 7 Feb 2017 15:00:08 +0200
Subject: [PATCH 0238/2045] MAGETWO-63945: Add extension point to sales grid
indexer
- Refactoring according CR
---
.../Unit/Model/{ => SalesOrderGrid}/OrderGridUpdaterTest.php | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
rename Test/Unit/Model/{ => SalesOrderGrid}/OrderGridUpdaterTest.php (95%)
diff --git a/Test/Unit/Model/OrderGridUpdaterTest.php b/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
similarity index 95%
rename from Test/Unit/Model/OrderGridUpdaterTest.php
rename to Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
index b210d35502bdb..eda647c214db7 100644
--- a/Test/Unit/Model/OrderGridUpdaterTest.php
+++ b/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\SalesOrderGrid\OrderGridUpdater;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
-/**
- * Class OrderGridUpdaterTest
- */
class OrderGridUpdaterTest extends \PHPUnit_Framework_TestCase
{
/**
From 79862004968da8199a1fdc93078bbf5de9c5a3b5 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 7 Feb 2017 15:58:48 +0200
Subject: [PATCH 0239/2045] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Updated payment verification interface
- Updated Braintree avs/cvv mappers behaviour
- Refactored payment verification default implementation
---
Model/DefaultPaymentVerification.php | 37 +++++++++++++++++++
Model/PaymentVerificationFactory.php | 33 +++++++++++++----
.../Request/PurchaseBuilder.php | 8 +---
etc/di.xml | 6 +++
4 files changed, 71 insertions(+), 13 deletions(-)
create mode 100644 Model/DefaultPaymentVerification.php
diff --git a/Model/DefaultPaymentVerification.php b/Model/DefaultPaymentVerification.php
new file mode 100644
index 0000000000000..fdea5b7cac138
--- /dev/null
+++ b/Model/DefaultPaymentVerification.php
@@ -0,0 +1,37 @@
+default = $default;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getCode(OrderPaymentInterface $orderPayment)
+ {
+ return $this->default;
+ }
+}
diff --git a/Model/PaymentVerificationFactory.php b/Model/PaymentVerificationFactory.php
index e228df47b040c..ecd6867073d98 100644
--- a/Model/PaymentVerificationFactory.php
+++ b/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/Model/SignifydGateway/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
index 48e2c3837fc71..86f9520a13309 100644
--- a/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/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/etc/di.xml b/etc/di.xml
index df5fdb79435ea..36fba21f89eca 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -15,9 +15,15 @@
+
+
+ U
+
+
Magento\Payment\Gateway\Config\Config
+ SignifydAvsDefaultMapper
From c3b3df19ddc3151a15ccbc3cef085191eec02275 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 7 Feb 2017 16:21:56 +0200
Subject: [PATCH 0240/2045] MAGETWO-63945: Add extension point to sales grid
indexer
- Fix static
---
Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php b/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
index eda647c214db7..1390a036955c2 100644
--- a/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
+++ b/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 57232a1a53eb5affaba3dfbf2bcf342cefef13fb Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 7 Feb 2017 17:45:22 +0200
Subject: [PATCH 0241/2045] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- refactoring
---
Setup/InstallData.php | 9 +++++++--
Setup/InstallSchema.php | 7 ++++++-
composer.json | 3 +++
etc/di.xml | 7 +++++++
4 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/Setup/InstallData.php b/Setup/InstallData.php
index 6e37ac63c493e..a7490064a895a 100644
--- a/Setup/InstallData.php
+++ b/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/Setup/InstallSchema.php b/Setup/InstallSchema.php
index 8107d06285bff..b66bd5314b6bb 100644
--- a/Setup/InstallSchema.php
+++ b/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/composer.json b/composer.json
index 87ce791eae618..34d0030be5fc9 100644
--- a/composer.json
+++ b/composer.json
@@ -12,6 +12,9 @@
"magento/module-checkout": "100.2.*",
"magento/module-backend": "100.2.*"
},
+ "suggest": {
+ "magento/module-scalable-oms": "100.2.*",
+ },
"type": "magento2-module",
"version": "100.2.0-dev",
"license": [
diff --git a/etc/di.xml b/etc/di.xml
index 5a2a65e6efc9e..1b1460130eebb 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -60,4 +60,11 @@
sales
+
+
+
+ - signifyd_case
+
+
+
From 8bec33bc72ac9b5891154038dc362ba46d37311c Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 7 Feb 2017 18:51:44 +0200
Subject: [PATCH 0242/2045] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- refactoring
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 34d0030be5fc9..0f560d9c9a846 100644
--- a/composer.json
+++ b/composer.json
@@ -13,7 +13,7 @@
"magento/module-backend": "100.2.*"
},
"suggest": {
- "magento/module-scalable-oms": "100.2.*",
+ "magento/module-scalable-oms": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
From c9473c49eaef30f8582946f12b12fdad426c845a Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 8 Feb 2017 10:58:48 +0200
Subject: [PATCH 0243/2045] MAGETWO-63945: Add extension point to sales grid
indexer
- Delete constraint.xml
---
etc/constraints.xml | 17 -----------------
1 file changed, 17 deletions(-)
delete mode 100644 etc/constraints.xml
diff --git a/etc/constraints.xml b/etc/constraints.xml
deleted file mode 100644
index ee14127721f75..0000000000000
--- a/etc/constraints.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
From 8f4c49ef62be648d48a8360ee496ee3e6b6f029e Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 8 Feb 2017 11:51:07 +0200
Subject: [PATCH 0244/2045] 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
---
Model/PaymentVerificationFactory.php | 28 +++++++++----------
...p => PredefinedVerificationCodeMapper.php} | 12 ++++----
.../Request/CreateCaseBuilder.php | 14 ++++++++++
.../Request/PurchaseBuilder.php | 3 --
etc/di.xml | 9 ++++--
5 files changed, 40 insertions(+), 26 deletions(-)
rename Model/{DefaultPaymentVerification.php => PredefinedVerificationCodeMapper.php} (70%)
diff --git a/Model/PaymentVerificationFactory.php b/Model/PaymentVerificationFactory.php
index ecd6867073d98..b84fa43628c0f 100644
--- a/Model/PaymentVerificationFactory.php
+++ b/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/Model/DefaultPaymentVerification.php b/Model/PredefinedVerificationCodeMapper.php
similarity index 70%
rename from Model/DefaultPaymentVerification.php
rename to Model/PredefinedVerificationCodeMapper.php
index fdea5b7cac138..149743192ba9c 100644
--- a/Model/DefaultPaymentVerification.php
+++ b/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/Model/SignifydGateway/Request/CreateCaseBuilder.php b/Model/SignifydGateway/Request/CreateCaseBuilder.php
index ec0d4dcb55889..16823447d32ee 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/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/Model/SignifydGateway/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
index 86f9520a13309..287ecdb84ca77 100644
--- a/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/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/etc/di.xml b/etc/di.xml
index 36fba21f89eca..233f6a3db7bc0 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -15,15 +15,18 @@
-
+
- U
+ U
+
+
Magento\Payment\Gateway\Config\Config
- SignifydAvsDefaultMapper
+ SignifydAvsDefaultMapper
+ SignifydCvvDefaultMapper
From 7b856ef7eaba15e9ccdf63a4fd7ca605182571bd Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 8 Feb 2017 11:51:07 +0200
Subject: [PATCH 0245/2045] 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
---
Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 8 ++++++--
_files/order_with_guest_and_virtual_product.php | 7 ++++++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index b6844a4da447d..1f93dc9b87d8a 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/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/_files/order_with_guest_and_virtual_product.php b/_files/order_with_guest_and_virtual_product.php
index a5a55b431df37..3d60f1c6f7e8c 100644
--- a/_files/order_with_guest_and_virtual_product.php
+++ b/_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 fe54426152562c27a875faeed291a27d15ba535c Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 8 Feb 2017 15:50:12 +0200
Subject: [PATCH 0246/2045] MAGETWO-63945: Add extension point to sales grid
indexer
- Add docblock to OrderGridUpdater
---
Model/SalesOrderGrid/OrderGridUpdater.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Model/SalesOrderGrid/OrderGridUpdater.php b/Model/SalesOrderGrid/OrderGridUpdater.php
index 5cb87d3316645..1d5e67b0c1065 100644
--- a/Model/SalesOrderGrid/OrderGridUpdater.php
+++ b/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 8e4d135e754cbd7279ecf81fda421faea8846b8a Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 8 Feb 2017 15:59:05 +0200
Subject: [PATCH 0247/2045] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Refactored code
- Added unit tests
---
...per.php => PredefinedVerificationCode.php} | 2 +-
.../Request/CreateCaseBuilder.php | 2 +-
.../Model/PaymentVerificationFactoryTest.php | 222 ++++++++++++++++++
etc/di.xml | 4 +-
4 files changed, 226 insertions(+), 4 deletions(-)
rename Model/{PredefinedVerificationCodeMapper.php => PredefinedVerificationCode.php} (89%)
create mode 100644 Test/Unit/Model/PaymentVerificationFactoryTest.php
diff --git a/Model/PredefinedVerificationCodeMapper.php b/Model/PredefinedVerificationCode.php
similarity index 89%
rename from Model/PredefinedVerificationCodeMapper.php
rename to Model/PredefinedVerificationCode.php
index 149743192ba9c..c6f12d01364a0 100644
--- a/Model/PredefinedVerificationCodeMapper.php
+++ b/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/Model/SignifydGateway/Request/CreateCaseBuilder.php b/Model/SignifydGateway/Request/CreateCaseBuilder.php
index 16823447d32ee..4f46cf69b70aa 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/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/Test/Unit/Model/PaymentVerificationFactoryTest.php b/Test/Unit/Model/PaymentVerificationFactoryTest.php
new file mode 100644
index 0000000000000..4e335d5a35c95
--- /dev/null
+++ b/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/etc/di.xml b/etc/di.xml
index 233f6a3db7bc0..84e9013dfbdcc 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -15,12 +15,12 @@
-
+
U
-
+
From 0ed1cb34bb2900aba30c46accedd9398c36a85bb Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 8 Feb 2017 18:24:16 +0200
Subject: [PATCH 0248/2045] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Updated data fields filtration
---
.../Request/CreateCaseBuilder.php | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilder.php b/Model/SignifydGateway/Request/CreateCaseBuilder.php
index 4f46cf69b70aa..317337d70b58a 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/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));
}
}
From 79275fd994d9049bf7274eb6b7a491180508cefb Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 8 Feb 2017 18:24:16 +0200
Subject: [PATCH 0249/2045] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Updated data fields filtration
---
Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 1f93dc9b87d8a..066e493dc0f01 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/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 d2ebf9b1877d6b48733b2efb503438d05e9dfa36 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 8 Feb 2017 19:06:49 +0200
Subject: [PATCH 0250/2045] MAGETWO-64345: Fix test request processing in
webhook controller
---
Controller/Webhooks/HandlerTest.php | 41 +++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/Controller/Webhooks/HandlerTest.php b/Controller/Webhooks/HandlerTest.php
index 26818a0a0c41a..d57d9268af4e3 100644
--- a/Controller/Webhooks/HandlerTest.php
+++ b/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,29 @@ 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 2dfba716cbdd982fc51138322489a48dbf1dd3e9 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 8 Feb 2017 19:06:49 +0200
Subject: [PATCH 0251/2045] MAGETWO-64345: Fix test request processing in
webhook controller
---
Controller/Webhooks/Handler.php | 18 ++++++--
Test/Unit/Controller/Webhooks/HandlerTest.php | 43 ++++++++++++++++---
2 files changed, 52 insertions(+), 9 deletions(-)
diff --git a/Controller/Webhooks/Handler.php b/Controller/Webhooks/Handler.php
index 9a522b073900a..ac13ff028afcf 100644
--- a/Controller/Webhooks/Handler.php
+++ b/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/Test/Unit/Controller/Webhooks/HandlerTest.php b/Test/Unit/Controller/Webhooks/HandlerTest.php
index 598fb9f20a41a..9230419ace200 100644
--- a/Test/Unit/Controller/Webhooks/HandlerTest.php
+++ b/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([
From 3fac774446836837be2cd71c07abdc79c40311ed Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 9 Feb 2017 11:10:30 +0200
Subject: [PATCH 0252/2045] MAGETWO-64345: Fix test request processing in
webhook controller
- Fix static
---
Controller/Webhooks/HandlerTest.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/Controller/Webhooks/HandlerTest.php b/Controller/Webhooks/HandlerTest.php
index d57d9268af4e3..e483328a680d7 100644
--- a/Controller/Webhooks/HandlerTest.php
+++ b/Controller/Webhooks/HandlerTest.php
@@ -132,6 +132,4 @@ private function getTestWebhookRequest()
return $webhookRequest;
}
-
-
}
From 13ae2d960537268a9bdb31c4d2cfb37d9bea35ce Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 10 Feb 2017 13:54:15 +0200
Subject: [PATCH 0253/2045] MAGETWO-64154: Rearrange Signifyd information table
in order view template
- always display fraud block when case entity for order is exists
---
Block/Adminhtml/CaseInfo.php | 19 -------------------
view/adminhtml/templates/case_info.phtml | 2 +-
2 files changed, 1 insertion(+), 20 deletions(-)
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index 9aaf15ca4a688..43c138bb5150f 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/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/view/adminhtml/templates/case_info.phtml b/view/adminhtml/templates/case_info.phtml
index 6649ca8fcd2fe..fef28b05ebb8c 100644
--- a/view/adminhtml/templates/case_info.phtml
+++ b/view/adminhtml/templates/case_info.phtml
@@ -9,7 +9,7 @@
isServiceActive() || $block->isEmptyCase()) {
+ if ($block->isEmptyCase()) {
return '';
}
?>
From 6ef349d318547b4bbb23c970e3dbd2d25a8f0519 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 10 Feb 2017 13:54:15 +0200
Subject: [PATCH 0254/2045] MAGETWO-64154: Rearrange Signifyd information table
in order view template
- always display fraud block when case entity for order is exists
---
Block/Adminhtml/CaseInfoTest.php | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/Block/Adminhtml/CaseInfoTest.php b/Block/Adminhtml/CaseInfoTest.php
index 95a24791e6911..1f55beea98a37 100644
--- a/Block/Adminhtml/CaseInfoTest.php
+++ b/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 6a79a5fe253c284fc2523d888d3acfcf9de5bcec Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 14 Feb 2017 15:26:13 +0200
Subject: [PATCH 0255/2045] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Refactored code according to code review changes.
---
Model/PaymentVerificationFactory.php | 9 ++--
README.md | 51 ++++++++++++++++++-
.../Model/PaymentVerificationFactoryTest.php | 2 +-
3 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/Model/PaymentVerificationFactory.php b/Model/PaymentVerificationFactory.php
index b84fa43628c0f..3aa3c20669af2 100644
--- a/Model/PaymentVerificationFactory.php
+++ b/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/README.md b/README.md
index 5159d4c6951c4..fc869bfe106d8 100644
--- a/README.md
+++ b/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/Test/Unit/Model/PaymentVerificationFactoryTest.php b/Test/Unit/Model/PaymentVerificationFactoryTest.php
index 4e335d5a35c95..6c4ffaf7c142e 100644
--- a/Test/Unit/Model/PaymentVerificationFactoryTest.php
+++ b/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 7a27e5bfba0df7d0ffff44d547a3d929f05411a0 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Tue, 14 Feb 2017 15:42:59 +0200
Subject: [PATCH 0256/2045] MAGETWO-63855: Create functional automated for
complete Signifyd flow
---
Test/Block/Sanbox/CaseInfo.php | 18 +++++
Test/Block/Sanbox/CaseSearch.php | 41 ++++++++++
Test/Block/Sanbox/Login.php | 28 +++++++
Test/Fixture/SandboxMerchant.xml | 17 +++++
Test/Page/Sandbox/SignifydCases.xml | 13 ++++
Test/Page/Sandbox/SignifydLogin.xml | 12 +++
Test/Repository/Address.xml | 22 ++++++
Test/Repository/ConfigData.xml | 45 +++++++++++
Test/Repository/Customer.xml | 24 ++++++
Test/Repository/SandboxMerchant.xml | 15 ++++
.../OnePageCheckoutWithBraintreeTest.php | 30 ++++++++
.../OnePageCheckoutWithBraintreeTest.xml | 25 +++++++
Test/TestStep/ObserveSignifydCaseStep.php | 75 +++++++++++++++++++
Test/etc/testcase.xml | 27 +++++++
14 files changed, 392 insertions(+)
create mode 100644 Test/Block/Sanbox/CaseInfo.php
create mode 100644 Test/Block/Sanbox/CaseSearch.php
create mode 100644 Test/Block/Sanbox/Login.php
create mode 100644 Test/Fixture/SandboxMerchant.xml
create mode 100644 Test/Page/Sandbox/SignifydCases.xml
create mode 100644 Test/Page/Sandbox/SignifydLogin.xml
create mode 100644 Test/Repository/Address.xml
create mode 100644 Test/Repository/ConfigData.xml
create mode 100644 Test/Repository/Customer.xml
create mode 100644 Test/Repository/SandboxMerchant.xml
create mode 100644 Test/TestCase/OnePageCheckoutWithBraintreeTest.php
create mode 100644 Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
create mode 100644 Test/TestStep/ObserveSignifydCaseStep.php
create mode 100644 Test/etc/testcase.xml
diff --git a/Test/Block/Sanbox/CaseInfo.php b/Test/Block/Sanbox/CaseInfo.php
new file mode 100644
index 0000000000000..7f3a6c42e8211
--- /dev/null
+++ b/Test/Block/Sanbox/CaseInfo.php
@@ -0,0 +1,18 @@
+_rootElement->find($this->flagGoodButton)->click();
+ }
+}
diff --git a/Test/Block/Sanbox/CaseSearch.php b/Test/Block/Sanbox/CaseSearch.php
new file mode 100644
index 0000000000000..3ab40e47bbd15
--- /dev/null
+++ b/Test/Block/Sanbox/CaseSearch.php
@@ -0,0 +1,41 @@
+_rootElement->find($this->searchInput)->setValue($searchCriteria);
+ }
+
+ /**
+ * Search Signifyd case.
+ *
+ * @return void
+ */
+ public function searchCase()
+ {
+ $this->_rootElement->find($this->buttonSubmit)->click();
+ }
+
+ public function selectCase()
+ {
+ $this->_rootElement->find($this->buttonCase, Locator::SELECTOR_XPATH)->click();
+ }
+}
diff --git a/Test/Block/Sanbox/Login.php b/Test/Block/Sanbox/Login.php
new file mode 100644
index 0000000000000..2232052e2a25a
--- /dev/null
+++ b/Test/Block/Sanbox/Login.php
@@ -0,0 +1,28 @@
+_rootElement->find($this->loginButton)->click();
+ }
+}
diff --git a/Test/Fixture/SandboxMerchant.xml b/Test/Fixture/SandboxMerchant.xml
new file mode 100644
index 0000000000000..5db0871f0e49f
--- /dev/null
+++ b/Test/Fixture/SandboxMerchant.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
diff --git a/Test/Page/Sandbox/SignifydCases.xml b/Test/Page/Sandbox/SignifydCases.xml
new file mode 100644
index 0000000000000..53db0881a8ba9
--- /dev/null
+++ b/Test/Page/Sandbox/SignifydCases.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
diff --git a/Test/Page/Sandbox/SignifydLogin.xml b/Test/Page/Sandbox/SignifydLogin.xml
new file mode 100644
index 0000000000000..232b6f059e5b7
--- /dev/null
+++ b/Test/Page/Sandbox/SignifydLogin.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/Test/Repository/Address.xml b/Test/Repository/Address.xml
new file mode 100644
index 0000000000000..7863c3eec664a
--- /dev/null
+++ b/Test/Repository/Address.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+ John
+ Doe
+ Magento
+ Culver City
+ 6161 West Centinela Avenue
+ 555-55-555-55
+ United States
+ California
+ 90230
+
+
+
diff --git a/Test/Repository/ConfigData.xml b/Test/Repository/ConfigData.xml
new file mode 100644
index 0000000000000..c4d89ea5fd890
--- /dev/null
+++ b/Test/Repository/ConfigData.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+ - fraud_protection
+ - 1
+ - Yes
+ - 1
+
+
+ - fraud_protection
+ - 1
+
+ - SIGNIFYD_API_KEY
+
+
+ - fraud_protection
+ - 1
+
+ - https://api.signifyd.com/v2/
+
+
+ - fraud_protection
+ - 1
+ - Yes
+ - 1
+
+
+
+
+ - fraud_protection
+ - 1
+ - Yes
+ - 0
+
+
+
+
diff --git a/Test/Repository/Customer.xml b/Test/Repository/Customer.xml
new file mode 100644
index 0000000000000..0f2f15f29456b
--- /dev/null
+++ b/Test/Repository/Customer.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+ John
+ Doe
+
+ - General
+
+ testapprove@magento.com
+ 123123^q
+ 123123^q
+
+ - default
+
+
+
+
diff --git a/Test/Repository/SandboxMerchant.xml b/Test/Repository/SandboxMerchant.xml
new file mode 100644
index 0000000000000..62718bc6ce70c
--- /dev/null
+++ b/Test/Repository/SandboxMerchant.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+ SIGNIFYD_EMAIL
+ SIGNIFYD_EMAIL
+
+
+
diff --git a/Test/TestCase/OnePageCheckoutWithBraintreeTest.php b/Test/TestCase/OnePageCheckoutWithBraintreeTest.php
new file mode 100644
index 0000000000000..666582c111ca9
--- /dev/null
+++ b/Test/TestCase/OnePageCheckoutWithBraintreeTest.php
@@ -0,0 +1,30 @@
+executeScenario();
+ }
+}
diff --git a/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml b/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
new file mode 100644
index 0000000000000..c95ed85e93e3c
--- /dev/null
+++ b/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ catalogProductSimple::product_10_dollar
+ login
+ signifyd_approve_us_customer
+ signifyd_approve_us_shipping_address
+ Flat Rate
+ Fixed
+ braintree
+ visa_default
+ braintree
+ braintree,signifyd
+ sandbox_default
+ test_type:3rd_party_test, severity:S1
+
+
+
diff --git a/Test/TestStep/ObserveSignifydCaseStep.php b/Test/TestStep/ObserveSignifydCaseStep.php
new file mode 100644
index 0000000000000..8fb7269bfac36
--- /dev/null
+++ b/Test/TestStep/ObserveSignifydCaseStep.php
@@ -0,0 +1,75 @@
+sandboxMerchant = $sandboxMerchant;
+ $this->signifydLogin = $signifydLogin;
+ $this->signifydCases = $signifydCases;
+ $this->customer = $customer;
+ }
+
+ /**
+ * Run step flow
+ *
+ * @return void
+ */
+ public function run()
+ {
+ $this->signifydLogin->open();
+ $this->signifydLogin->getLoginBlock()->fill($this->sandboxMerchant);
+ $this->signifydLogin->getLoginBlock()->sandboxLogin();
+
+ $this->signifydCases->getCaseSearchBlock()->waitForElementVisible('#queueSearchBar');
+ $this->signifydCases->getCaseSearchBlock()
+ ->fillSearchCriteria($this->customer->getFirstname() . ' ' . $this->customer->getLastname());
+ $this->signifydCases->getCaseSearchBlock()->searchCase();
+
+ $this->signifydCases->getCaseSearchBlock()->selectCase();
+ $this->signifydCases->getCaseInfoBlock()->flagCaseGood();
+ }
+}
diff --git a/Test/etc/testcase.xml b/Test/etc/testcase.xml
new file mode 100644
index 0000000000000..f624ceced8e22
--- /dev/null
+++ b/Test/etc/testcase.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 32c0320b79b60382494a5e1b1c19f6b5f32b770f Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Wed, 8 Feb 2017 15:56:17 +0200
Subject: [PATCH 0257/2045] 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
---
.../PaymentMethodMapper.php | 40 ++++++++
.../XmlToArrayConfigConverter.php | 81 ++++++++++++++++
.../Request/PurchaseBuilder.php | 21 ++++-
.../XmlToArrayConfigConverterTest.php | 76 +++++++++++++++
.../_files/expected_array.php | 13 +++
.../_files/signifyd_payment_mapping.xml | 32 +++++++
etc/di.xml | 24 +++++
etc/signifyd_payment_mapping.xml | 94 +++++++++++++++++++
etc/signifyd_payment_mapping.xsd | 27 ++++++
i18n/en_US.csv | 4 +-
10 files changed, 407 insertions(+), 5 deletions(-)
create mode 100644 Model/PaymentMethodMapper/PaymentMethodMapper.php
create mode 100644 Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
create mode 100644 Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
create mode 100644 Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php
create mode 100644 Test/Unit/Model/PaymentMethodMapper/_files/signifyd_payment_mapping.xml
create mode 100644 etc/signifyd_payment_mapping.xml
create mode 100644 etc/signifyd_payment_mapping.xsd
diff --git a/Model/PaymentMethodMapper/PaymentMethodMapper.php b/Model/PaymentMethodMapper/PaymentMethodMapper.php
new file mode 100644
index 0000000000000..48ba85c5da671
--- /dev/null
+++ b/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/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php b/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
new file mode 100644
index 0000000000000..6438c38ec58ab
--- /dev/null
+++ b/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/Model/SignifydGateway/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
index 287ecdb84ca77..7fc729fab5b80 100644
--- a/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/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/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php b/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
new file mode 100644
index 0000000000000..ec7a7986e2ee0
--- /dev/null
+++ b/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/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php b/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php
new file mode 100644
index 0000000000000..0578513ab228e
--- /dev/null
+++ b/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/Test/Unit/Model/PaymentMethodMapper/_files/signifyd_payment_mapping.xml b/Test/Unit/Model/PaymentMethodMapper/_files/signifyd_payment_mapping.xml
new file mode 100644
index 0000000000000..d18eefbae718d
--- /dev/null
+++ b/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/etc/di.xml b/etc/di.xml
index 2af397ed0e129..e3ed752bcb9c5 100644
--- a/etc/di.xml
+++ b/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/etc/signifyd_payment_mapping.xml b/etc/signifyd_payment_mapping.xml
new file mode 100644
index 0000000000000..c23ed024a7fa5
--- /dev/null
+++ b/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/etc/signifyd_payment_mapping.xsd b/etc/signifyd_payment_mapping.xsd
new file mode 100644
index 0000000000000..cd8aa93b7aa2a
--- /dev/null
+++ b/etc/signifyd_payment_mapping.xsd
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/i18n/en_US.csv b/i18n/en_US.csv
index 516147e01cfd8..e595bcbc89bdb 100644
--- a/i18n/en_US.csv
+++ b/i18n/en_US.csv
@@ -23,4 +23,6 @@
"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 your order.","Guarantee has been cancelled for your order."
-"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
\ No newline at end of file
+"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 41cd85dbe55cf7802dfb0d58bfb29d32da29c9c5 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Tue, 14 Feb 2017 18:09:23 +0200
Subject: [PATCH 0258/2045] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed xsd schema location
---
etc/signifyd_payment_mapping.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/etc/signifyd_payment_mapping.xml b/etc/signifyd_payment_mapping.xml
index c23ed024a7fa5..c6016ce7fddaf 100644
--- a/etc/signifyd_payment_mapping.xml
+++ b/etc/signifyd_payment_mapping.xml
@@ -16,7 +16,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Signifyd:etc/signifyd_payment_mapping.xsd">
braintree
From 785d97e07d481e514b263e9ef2c02afdbec8a5e6 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Tue, 14 Feb 2017 18:22:57 +0200
Subject: [PATCH 0259/2045] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed xsd schema
---
etc/signifyd_payment_mapping.xsd | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/etc/signifyd_payment_mapping.xsd b/etc/signifyd_payment_mapping.xsd
index cd8aa93b7aa2a..abbf5879b7bc8 100644
--- a/etc/signifyd_payment_mapping.xsd
+++ b/etc/signifyd_payment_mapping.xsd
@@ -9,7 +9,7 @@
-
+
From 17473d78b624f4dc9efd5c643ec29edd41c761ac Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 14 Feb 2017 19:27:57 +0200
Subject: [PATCH 0260/2045] MAGETWO-63923: Create documentation for Signifyd
extension points
- Added info about Signifyd payment methods mapping customization
---
README.md | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index fc869bfe106d8..5d1c0510ba671 100644
--- a/README.md
+++ b/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 266f279bed8fdfcedebd8f16a13959ea129ff295 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Wed, 15 Feb 2017 10:28:00 +0200
Subject: [PATCH 0261/2045] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed the integration test
- Code refactoring
---
etc/di.xml | 4 ++--
i18n/en_US.csv | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/etc/di.xml b/etc/di.xml
index e3ed752bcb9c5..878272a9531a2 100644
--- a/etc/di.xml
+++ b/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/i18n/en_US.csv b/i18n/en_US.csv
index e595bcbc89bdb..188419e33ac76 100644
--- a/i18n/en_US.csv
+++ b/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
From 78eba96dda57b4382315dda1c1010a42094ee1b3 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Wed, 15 Feb 2017 10:28:00 +0200
Subject: [PATCH 0262/2045] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed the integration test
- Code refactoring
---
Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 066e493dc0f01..2c9bd2c456c64 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/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 abf6d519e673745ad5c644ca6daadd10704c9766 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Wed, 15 Feb 2017 12:15:04 +0200
Subject: [PATCH 0263/2045] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed integration test
---
Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 2c9bd2c456c64..0147792ba1f0b 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/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 3e346b42fd48b5ef9c2387dbf66038b6fb7ed97c Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 15 Feb 2017 15:19:43 +0200
Subject: [PATCH 0264/2045] MAGETWO-63912: Implement payment method code
mapping in Signifyd
- Added strict mapping for PayPal payment solutions (previous did not include PayflowPro, WPPHS, etc.)
---
Model/SignifydGateway/Request/PurchaseBuilder.php | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/Model/SignifydGateway/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
index 7fc729fab5b80..8f6a7f7316be7 100644
--- a/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/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;
}
/**
From f4cc47d4bb1d4f7f8e339c26da1ff22f2c7ec876 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 15 Feb 2017 15:41:41 +0200
Subject: [PATCH 0265/2045] MAGETWO-63855: Create functional automated for
complete Signifyd flow
---
.../AssertSignifydCaseInCommentsHistory.php | 61 +++++++++++++++++++
.../OnePageCheckoutWithBraintreeTest.xml | 7 +++
2 files changed, 68 insertions(+)
create mode 100644 Test/Constraint/AssertSignifydCaseInCommentsHistory.php
diff --git a/Test/Constraint/AssertSignifydCaseInCommentsHistory.php b/Test/Constraint/AssertSignifydCaseInCommentsHistory.php
new file mode 100644
index 0000000000000..62d5ac5ab161a
--- /dev/null
+++ b/Test/Constraint/AssertSignifydCaseInCommentsHistory.php
@@ -0,0 +1,61 @@
+open();
+ $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
+
+ /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
+ $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
+ $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment();
+
+ \PHPUnit_Framework_Assert::assertRegExp(
+ sprintf(self::CASE_CREATED_PATTERN, $prices['grandTotal']),
+ $latestComment['comment'],
+ 'Signifyd case is not created for the order #' . $orderId
+ );
+ }
+
+ /**
+ * Returns string representation of successful assertion.
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Message about Signifyd Case is available in Comments History section.";
+ }
+}
diff --git a/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml b/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
index c95ed85e93e3c..94cea25577740 100644
--- a/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
+++ b/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
@@ -15,11 +15,18 @@
Flat Rate
Fixed
braintree
+
+ - 15.00
+
visa_default
braintree
braintree,signifyd
sandbox_default
+ Processing
test_type:3rd_party_test, severity:S1
+
+
+
From 53ac028cd909a9231c32dd924465ae19dc14535f Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 15 Feb 2017 17:12:07 +0200
Subject: [PATCH 0266/2045] MAGETWO-63855: Create functional automated for
complete Signifyd flow
---
Test/Block/Sanbox/CaseInfo.php | 47 +++++++++++++
Test/Block/Sanbox/CaseSearch.php | 1 +
Test/Constraint/AssertCaseInfo.php | 66 +++++++++++++++++++
...AssertGuaranteeCancelInCommentsHistory.php | 60 +++++++++++++++++
Test/Repository/SandboxMerchant.xml | 2 +-
.../OnePageCheckoutWithBraintreeTest.php | 3 +-
.../OnePageCheckoutWithBraintreeTest.xml | 9 +++
Test/TestStep/ObserveSignifydCaseStep.php | 37 ++++++++++-
Test/etc/testcase.xml | 7 +-
9 files changed, 224 insertions(+), 8 deletions(-)
create mode 100644 Test/Constraint/AssertCaseInfo.php
create mode 100644 Test/Constraint/AssertGuaranteeCancelInCommentsHistory.php
diff --git a/Test/Block/Sanbox/CaseInfo.php b/Test/Block/Sanbox/CaseInfo.php
index 7f3a6c42e8211..5373b71f0f8d2 100644
--- a/Test/Block/Sanbox/CaseInfo.php
+++ b/Test/Block/Sanbox/CaseInfo.php
@@ -6,13 +6,60 @@
namespace Magento\Signifyd\Test\Block\Sanbox;
use Magento\Mtf\Block\Block;
+use Magento\Mtf\Client\Locator;
class CaseInfo extends Block
{
private $flagGoodButton = 'button.flag-case-good';
+ private $cvvResponseDescription = '//span[contains(@ng-bind, "caseOrderSummary.cvvResponseDescription")]';
+ private $cvvResponseCode = '//span[contains(@ng-bind, "caseOrderSummary.cvvResponseCode")]';
+ private $avsResponseDescription = '//span[contains(@ng-bind, "caseOrderSummary.avsResponseDescription")]';
+ private $avsResponseCode = '//span[contains(@ng-bind, "caseOrderSummary.avsResponseCode")]';
+ private $orderId = '//span[contains(@ng-bind, "currentCase.caseIdDisplay")]';
+ private $orderAmount = '//span[contains(@ng-bind, "currentCase.orderAmount")]';
+ private $cardHolder = '//a[contains(@data-dropdown, "peopleLinks0")]//span';
+ private $billingAddress = '//a[contains(@data-dropdown, "streetLinks0")]';
public function flagCaseGood()
{
$this->_rootElement->find($this->flagGoodButton)->click();
}
+
+ public function getCvvResponse()
+ {
+ return sprintf(
+ '%s (%s)',
+ $this->_rootElement->find($this->cvvResponseDescription, Locator::SELECTOR_XPATH)->getText(),
+ $this->_rootElement->find($this->cvvResponseCode, Locator::SELECTOR_XPATH)->getText()
+ );
+ }
+
+ public function getAvsResponse()
+ {
+ return sprintf(
+ '%s (%s)',
+ $this->_rootElement->find($this->avsResponseDescription, Locator::SELECTOR_XPATH)->getText(),
+ $this->_rootElement->find($this->avsResponseCode, Locator::SELECTOR_XPATH)->getText()
+ );
+ }
+
+ public function getOrderId()
+ {
+ return $this->_rootElement->find($this->orderId, Locator::SELECTOR_XPATH)->getText();
+ }
+
+ public function getOrderAmount()
+ {
+ return $this->_rootElement->find($this->orderAmount, Locator::SELECTOR_XPATH)->getText();
+ }
+
+ public function getCardHolder()
+ {
+ return $this->_rootElement->find($this->cardHolder, Locator::SELECTOR_XPATH)->getText();
+ }
+
+ public function getBillingAddress()
+ {
+ return $this->_rootElement->find($this->billingAddress, Locator::SELECTOR_XPATH)->getText();
+ }
}
diff --git a/Test/Block/Sanbox/CaseSearch.php b/Test/Block/Sanbox/CaseSearch.php
index 3ab40e47bbd15..adb1b8b48abe0 100644
--- a/Test/Block/Sanbox/CaseSearch.php
+++ b/Test/Block/Sanbox/CaseSearch.php
@@ -21,6 +21,7 @@ class CaseSearch extends Form
public function fillSearchCriteria($searchCriteria)
{
+ $this->waitForElementVisible($this->searchInput);
$this->_rootElement->find($this->searchInput)->setValue($searchCriteria);
}
diff --git a/Test/Constraint/AssertCaseInfo.php b/Test/Constraint/AssertCaseInfo.php
new file mode 100644
index 0000000000000..8d5084a0ab0b2
--- /dev/null
+++ b/Test/Constraint/AssertCaseInfo.php
@@ -0,0 +1,66 @@
+cvvResponse,
+ $signifydCases->getCaseInfoBlock()->getCvvResponse()
+ );
+
+ \PHPUnit_Framework_Assert::assertEquals(
+ $this->avsResponse,
+ $signifydCases->getCaseInfoBlock()->getAvsResponse()
+ );
+
+ \PHPUnit_Framework_Assert::assertEquals(
+ $order->getId(),
+ $signifydCases->getCaseInfoBlock()->getOrderId()
+ );
+
+ \PHPUnit_Framework_Assert::assertEquals(
+ number_format($cartPrice['grand_total'], 2),
+ $signifydCases->getCaseInfoBlock()->getOrderAmount()
+ );
+
+ \PHPUnit_Framework_Assert::assertEquals(
+ sprintf('%s %s', $customer->getFirstname(), $customer->getLastname()),
+ $signifydCases->getCaseInfoBlock()->getCardHolder()
+ );
+
+ \PHPUnit_Framework_Assert::assertContains(
+ $billingAddress->getStreet(),
+ $signifydCases->getCaseInfoBlock()->getBillingAddress()
+ );
+ }
+
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return 'Case information is correct.';
+ }
+}
diff --git a/Test/Constraint/AssertGuaranteeCancelInCommentsHistory.php b/Test/Constraint/AssertGuaranteeCancelInCommentsHistory.php
new file mode 100644
index 0000000000000..4fe8a439ec07c
--- /dev/null
+++ b/Test/Constraint/AssertGuaranteeCancelInCommentsHistory.php
@@ -0,0 +1,60 @@
+open();
+ $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
+
+ /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
+ $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
+ $comments = $infoTab->getCommentsHistoryBlock()->getComments();
+
+ foreach ($comments as $key => $comment) {
+ if (strstr($comment['comment'], 'Case Update') === false) {
+ unset($comments[$key]);
+ }
+ }
+ $comments = array_values($comments);
+
+ \PHPUnit_Framework_Assert::assertRegExp(
+ $this->guaranteeCancelPattern,
+ $comments[0]['comment'],
+ 'Incorrect guarantee cancel for the order #' . $orderId
+ );
+ }
+
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Message about guarantee cancel is available in Comments History section.";
+ }
+}
diff --git a/Test/Repository/SandboxMerchant.xml b/Test/Repository/SandboxMerchant.xml
index 62718bc6ce70c..34e39ed54c3e0 100644
--- a/Test/Repository/SandboxMerchant.xml
+++ b/Test/Repository/SandboxMerchant.xml
@@ -9,7 +9,7 @@
SIGNIFYD_EMAIL
- SIGNIFYD_EMAIL
+ SIGNIFYD_PASSWORD
diff --git a/Test/TestCase/OnePageCheckoutWithBraintreeTest.php b/Test/TestCase/OnePageCheckoutWithBraintreeTest.php
index 666582c111ca9..f652c3086216d 100644
--- a/Test/TestCase/OnePageCheckoutWithBraintreeTest.php
+++ b/Test/TestCase/OnePageCheckoutWithBraintreeTest.php
@@ -24,7 +24,8 @@ class OnePageCheckoutWithBraintreeTest extends Scenario
*
* @return void
*/
- public function test() {
+ public function test()
+ {
$this->executeScenario();
}
}
diff --git a/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml b/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
index 94cea25577740..f08262d20f17d 100644
--- a/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
+++ b/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
@@ -9,8 +9,13 @@
catalogProductSimple::product_10_dollar
+ 15.00
+ 15
+ 10
+ 5
login
signifyd_approve_us_customer
+ signifyd_approve_us_shipping_address
signifyd_approve_us_shipping_address
Flat Rate
Fixed
@@ -27,6 +32,10 @@
+
+
+
+
diff --git a/Test/TestStep/ObserveSignifydCaseStep.php b/Test/TestStep/ObserveSignifydCaseStep.php
index 8fb7269bfac36..c9f5107d34974 100644
--- a/Test/TestStep/ObserveSignifydCaseStep.php
+++ b/Test/TestStep/ObserveSignifydCaseStep.php
@@ -5,8 +5,11 @@
*/
namespace Magento\Signifyd\Test\TestStep;
+use Magento\Customer\Test\Fixture\Address;
use Magento\Customer\Test\Fixture\Customer;
use Magento\Mtf\TestStep\TestStepInterface;
+use Magento\Sales\Test\Fixture\OrderInjectable;
+use Magento\Signifyd\Test\Constraint\AssertCaseInfo;
use Magento\Signifyd\Test\Fixture\SandboxMerchant;
use Magento\Signifyd\Test\Page\Sandbox\SignifydCases;
use Magento\Signifyd\Test\Page\Sandbox\SignifydLogin;
@@ -35,22 +38,51 @@ class ObserveSignifydCaseStep implements TestStepInterface
*/
private $customer;
+ /**
+ * @var AssertCaseInfo
+ */
+ private $assertCaseInfo;
+
+ /**
+ * @var OrderInjectable
+ */
+ private $order;
+
+ /**
+ * @var array
+ */
+ private $cartPrice;
+ /**
+ * @var Address
+ */
+ private $billingAddress;
+
/**
* @param SandboxMerchant $sandboxMerchant
* @param SignifydLogin $signifydLogin
* @param SignifydCases $signifydCases
* @param Customer $customer
+ * @param AssertCaseInfo $assertCaseInfo
+ * @param OrderInjectable $order
*/
public function __construct(
SandboxMerchant $sandboxMerchant,
SignifydLogin $signifydLogin,
SignifydCases $signifydCases,
- Customer $customer
+ Customer $customer,
+ AssertCaseInfo $assertCaseInfo,
+ OrderInjectable $order,
+ Address $billingAddress,
+ array $cartPrice
) {
$this->sandboxMerchant = $sandboxMerchant;
$this->signifydLogin = $signifydLogin;
$this->signifydCases = $signifydCases;
$this->customer = $customer;
+ $this->assertCaseInfo = $assertCaseInfo;
+ $this->order = $order;
+ $this->cartPrice = $cartPrice;
+ $this->billingAddress = $billingAddress;
}
/**
@@ -64,12 +96,13 @@ public function run()
$this->signifydLogin->getLoginBlock()->fill($this->sandboxMerchant);
$this->signifydLogin->getLoginBlock()->sandboxLogin();
- $this->signifydCases->getCaseSearchBlock()->waitForElementVisible('#queueSearchBar');
$this->signifydCases->getCaseSearchBlock()
->fillSearchCriteria($this->customer->getFirstname() . ' ' . $this->customer->getLastname());
$this->signifydCases->getCaseSearchBlock()->searchCase();
$this->signifydCases->getCaseSearchBlock()->selectCase();
$this->signifydCases->getCaseInfoBlock()->flagCaseGood();
+
+ $this->assertCaseInfo->processAssert($this->signifydCases, $this->customer, $this->order, $this->billingAddress, $this->cartPrice);
}
}
diff --git a/Test/etc/testcase.xml b/Test/etc/testcase.xml
index f624ceced8e22..b2d91929d0ea9 100644
--- a/Test/etc/testcase.xml
+++ b/Test/etc/testcase.xml
@@ -19,9 +19,8 @@
-
-
-
-
+
+
+
From 66a54d232660b86f49ae120c2b0197bed31c3dfe Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Wed, 15 Feb 2017 17:16:30 +0200
Subject: [PATCH 0267/2045] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Code refactoring
---
.../XmlToArrayConfigConverter.php | 23 ++++++++++++-------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php b/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
index 6438c38ec58ab..31ebbe6835e37 100644
--- a/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
+++ b/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 75a9683125b33e00d62b68ec69ba00d7d0d0a410 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 15 Feb 2017 17:36:50 +0200
Subject: [PATCH 0268/2045] MAGETWO-63923: Create documentation for Signifyd
extension points
- Updated Readme file
---
README.md | 67 ++++++++++++++++++++++++++++++-------------------------
1 file changed, 36 insertions(+), 31 deletions(-)
diff --git a/README.md b/README.md
index 5d1c0510ba671..6ade95e78c2a5 100644
--- a/README.md
+++ b/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 0229e2359be64662b5fae372de8c77fc5a2c136f Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 15 Feb 2017 17:43:43 +0200
Subject: [PATCH 0269/2045] MAGETWO-63640: View Signifyd Guarantee Status in
Order Grid
- Order grid sync after case creation
---
Model/CaseServices/CreationService.php | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/Model/CaseServices/CreationService.php b/Model/CaseServices/CreationService.php
index 19a8f17bf5bb5..0847740e7b928 100644
--- a/Model/CaseServices/CreationService.php
+++ b/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($case->getOrderId());
try {
$caseId = $this->signifydGateway->createCase($orderId);
From 149c261cecea283a555d9c4eef4778412333d620 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 15 Feb 2017 17:43:43 +0200
Subject: [PATCH 0270/2045] MAGETWO-63640: View Signifyd Guarantee Status in
Order Grid
- Order grid sync after case creation
---
Model/CaseServices/CreationServiceTest.php | 26 ++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/Model/CaseServices/CreationServiceTest.php b/Model/CaseServices/CreationServiceTest.php
index 8f4cc6d188245..d779e98ebd034 100644
--- a/Model/CaseServices/CreationServiceTest.php
+++ b/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 de65c2d0d0d0534c2682405c991c0a94732e691c Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 15 Feb 2017 18:09:41 +0200
Subject: [PATCH 0271/2045] MAGETWO-63640: View Signifyd Guarantee Status in
Order Grid
- Order grid sync after case creation
---
Model/CaseServices/CreationService.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Model/CaseServices/CreationService.php b/Model/CaseServices/CreationService.php
index 0847740e7b928..510cf8ff9e7e7 100644
--- a/Model/CaseServices/CreationService.php
+++ b/Model/CaseServices/CreationService.php
@@ -74,7 +74,7 @@ public function __construct(
public function createForOrder($orderId)
{
$case = $this->caseManagement->create($orderId);
- $this->orderGridUpdater->update($case->getOrderId());
+ $this->orderGridUpdater->update($orderId);
try {
$caseId = $this->signifydGateway->createCase($orderId);
From 5efaca05d5f83b0cc9a167519313a5e50c83d981 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Thu, 16 Feb 2017 13:48:33 +0200
Subject: [PATCH 0272/2045] MAGETWO-63855: Create functional automated for
complete Signifyd flow
- constraints for processing order
---
Test/Block/Adminhtml/Order/Grid.php | 35 +++++
.../Adminhtml/Order/View/FraudProtection.php | 66 +++++++++
.../AssertAuthorizationInCommentsHistory.php | 58 ++++++++
Test/Constraint/AssertCaseInfoOnBackend.php | 73 ++++++++++
.../AssertSignifydCaseInCommentsHistory.php | 17 ++-
.../AssertSignifydCaseInOrdersGrid.php | 55 +++++++
Test/Page/Adminhtml/OrderView.xml | 13 ++
.../OnePageCheckoutWithBraintreeTest.xml | 5 +-
Test/TestStep/OpenOrderGridStep.php | 135 ++++++++++++++++++
Test/etc/testcase.xml | 4 +-
10 files changed, 446 insertions(+), 15 deletions(-)
create mode 100644 Test/Block/Adminhtml/Order/Grid.php
create mode 100644 Test/Block/Adminhtml/Order/View/FraudProtection.php
create mode 100644 Test/Constraint/AssertAuthorizationInCommentsHistory.php
create mode 100644 Test/Constraint/AssertCaseInfoOnBackend.php
create mode 100644 Test/Constraint/AssertSignifydCaseInOrdersGrid.php
create mode 100644 Test/Page/Adminhtml/OrderView.xml
create mode 100644 Test/TestStep/OpenOrderGridStep.php
diff --git a/Test/Block/Adminhtml/Order/Grid.php b/Test/Block/Adminhtml/Order/Grid.php
new file mode 100644
index 0000000000000..6fe08d02ad5e6
--- /dev/null
+++ b/Test/Block/Adminhtml/Order/Grid.php
@@ -0,0 +1,35 @@
+ [
+ 'selector' => '[name="increment_id"]',
+ ],
+ 'status' => [
+ 'selector' => '[name="status"]',
+ 'input' => 'select',
+ ],
+ 'signifyd_guarantee_status' => [
+ 'selector' => '[name="signifyd_guarantee_status"]',
+ 'input' => 'select'
+ ]
+ ];
+}
diff --git a/Test/Block/Adminhtml/Order/View/FraudProtection.php b/Test/Block/Adminhtml/Order/View/FraudProtection.php
new file mode 100644
index 0000000000000..2c9926d08005b
--- /dev/null
+++ b/Test/Block/Adminhtml/Order/View/FraudProtection.php
@@ -0,0 +1,66 @@
+_rootElement->find($this->caseStatus, Locator::SELECTOR_CSS)->getText();
+ }
+
+ /**
+ * Get Case Guarantee Disposition status.
+ *
+ * @return string
+ */
+ public function getCaseGuaranteeDisposition()
+ {
+ return $this->_rootElement->find($this->caseGuaranteeDisposition, Locator::SELECTOR_CSS)->getText();
+ }
+
+ /**
+ * Get Case Review Disposition status.
+ *
+ * @return string
+ */
+ public function getCaseReviewDisposition()
+ {
+ return $this->_rootElement->find($this->caseReviewDisposition, Locator::SELECTOR_CSS)->getText();
+ }
+}
diff --git a/Test/Constraint/AssertAuthorizationInCommentsHistory.php b/Test/Constraint/AssertAuthorizationInCommentsHistory.php
new file mode 100644
index 0000000000000..f455ee1c9f110
--- /dev/null
+++ b/Test/Constraint/AssertAuthorizationInCommentsHistory.php
@@ -0,0 +1,58 @@
+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(
+ sprintf(SalesAssert::AUTHORIZED_AMOUNT_PATTERN, $prices['grandTotal']),
+ implode('. ', $commentsMessages),
+ 'Incorrect authorized amount value for the order #' . $orderId
+ );
+ }
+
+ /**
+ * Returns string representation of successful assertion.
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Message about authorized amount is available in Comments History section.";
+ }
+}
diff --git a/Test/Constraint/AssertCaseInfoOnBackend.php b/Test/Constraint/AssertCaseInfoOnBackend.php
new file mode 100644
index 0000000000000..5b52848309d2a
--- /dev/null
+++ b/Test/Constraint/AssertCaseInfoOnBackend.php
@@ -0,0 +1,73 @@
+open(['order_id' => $orderId]);
+ $fraudBlock = $orderView->getFraudProtectionBlock();
+
+ \PHPUnit_Framework_Assert::assertEquals(
+ self::$caseStatus,
+ $fraudBlock->getCaseStatus(),
+ 'Case status is wrong for order #'.$orderId
+ );
+
+ \PHPUnit_Framework_Assert::assertEquals(
+ self::$guaranteeDisposition,
+ $fraudBlock->getCaseGuaranteeDisposition(),
+ 'Case Guarantee Disposition status is wrong for order #'.$orderId
+ );
+
+ \PHPUnit_Framework_Assert::assertEquals(
+ self::$reviewDisposition,
+ $fraudBlock->getCaseReviewDisposition(),
+ 'Case Review Disposition status is wrong for order #'.$orderId
+ );
+ }
+
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return 'Signifyd Case information is correct on backend.';
+ }
+}
diff --git a/Test/Constraint/AssertSignifydCaseInCommentsHistory.php b/Test/Constraint/AssertSignifydCaseInCommentsHistory.php
index 62d5ac5ab161a..49cb77efa98da 100644
--- a/Test/Constraint/AssertSignifydCaseInCommentsHistory.php
+++ b/Test/Constraint/AssertSignifydCaseInCommentsHistory.php
@@ -11,40 +11,39 @@
use Magento\Mtf\Constraint\AbstractConstraint;
/**
- * Assert that comment about authorized amount exists in Comments History section on order page in Admin.
+ * Assert that comment about created Signifyd Case exists in Comments History section on order page in Admin.
*/
class AssertSignifydCaseInCommentsHistory extends AbstractConstraint
{
/**
- * Pattern of message about authorized amount in order.
+ * Pattern of message about created Signifyd Case in order.
*/
const CASE_CREATED_PATTERN = '/Signifyd Case (\d)+ has been created for order\./';
/**
- * Assert that comment about authorized amount exists in Comments History section on order page in Admin.
+ * Assert that comment about Signifyd Case exists in Comments History section on order page in Admin.
*
* @param SalesOrderView $salesOrderView
* @param OrderIndex $salesOrder
* @param string $orderId
- * @param array $prices
* @return void
*/
public function processAssert(
SalesOrderView $salesOrderView,
OrderIndex $salesOrder,
- $orderId,
- array $prices
+ $orderId
) {
$salesOrder->open();
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
/** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
$infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
- $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment();
+ $orderComments = $infoTab->getCommentsHistoryBlock()->getComments();
+ $commentsMessages = array_column($orderComments, 'comment');
\PHPUnit_Framework_Assert::assertRegExp(
- sprintf(self::CASE_CREATED_PATTERN, $prices['grandTotal']),
- $latestComment['comment'],
+ self::CASE_CREATED_PATTERN,
+ implode('. ', $commentsMessages),
'Signifyd case is not created for the order #' . $orderId
);
}
diff --git a/Test/Constraint/AssertSignifydCaseInOrdersGrid.php b/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
new file mode 100644
index 0000000000000..2c8b1fb0b517b
--- /dev/null
+++ b/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
@@ -0,0 +1,55 @@
+ Orders Grid.
+ *
+ * @param string $orderId
+ * @param string $status
+ * @param OrderView $orderView
+ * @return void
+ */
+ public function processAssert(
+ $orderId,
+ $status,
+ OrderView $orderView
+ ) {
+ $filter = [
+ 'id' => $orderId,
+ 'status' => $status,
+ 'signifyd_guarantee_status' => 'Approved'
+ ];
+
+ $errorMessage = implode(', ', $filter);
+
+ $orderView->open();
+
+ \PHPUnit_Framework_Assert::assertTrue(
+ $orderView->getSalesOrderGrid()->isRowVisible(array_filter($filter)),
+ 'Order with following data \'' . $errorMessage . '\' is absent in Orders grid.'
+ );
+ }
+
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return 'Signifyd case is present in sales orders grid.';
+ }
+}
diff --git a/Test/Page/Adminhtml/OrderView.xml b/Test/Page/Adminhtml/OrderView.xml
new file mode 100644
index 0000000000000..810f1d1f65b0c
--- /dev/null
+++ b/Test/Page/Adminhtml/OrderView.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
diff --git a/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml b/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
index f08262d20f17d..c00053382cfb8 100644
--- a/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
+++ b/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
@@ -29,13 +29,10 @@
sandbox_default
Processing
test_type:3rd_party_test, severity:S1
-
-
+
-
-
diff --git a/Test/TestStep/OpenOrderGridStep.php b/Test/TestStep/OpenOrderGridStep.php
new file mode 100644
index 0000000000000..508d0dbc27126
--- /dev/null
+++ b/Test/TestStep/OpenOrderGridStep.php
@@ -0,0 +1,135 @@
+orderStatus = $status;
+ $this->assertOrderStatus = $assertOrderStatus;
+ $this->assertCaseInfo = $assertCaseInfo;
+ $this->assertOrdersGrid = $assertOrdersGrid;
+ $this->salesOrderView = $salesOrderView;
+ $this->orderView = $orderView;
+ $this->orderIndex = $orderIndex;
+
+ parent::__construct($order, $this->orderIndex);
+ }
+
+ /**
+ * Open order.
+ *
+ * @return void
+ */
+ public function run()
+ {
+ parent::run();
+
+ $this->checkOrdersGrid();
+ $this->checkOrderStatus();
+ $this->checkCaseInfo();
+ }
+
+ /**
+ * Run assert to check order status is valid.
+ */
+ private function checkOrderStatus()
+ {
+ $this->assertOrderStatus->processAssert(
+ $this->orderStatus,
+ $this->order->getId(),
+ $this->orderIndex,
+ $this->salesOrderView
+ );
+ }
+
+ /**
+ * Run assert to check Signifyd Case information is correct on backend.
+ */
+ private function checkCaseInfo()
+ {
+ $this->assertCaseInfo->processAssert(
+ $this->orderView,
+ $this->order->getId()
+ );
+ }
+
+ /**
+ * Run assert to check Signifyd Case Disposition status in orders grid.
+ */
+ private function checkOrdersGrid()
+ {
+ $this->assertOrdersGrid->processAssert(
+ $this->order->getId(),
+ $this->orderStatus,
+ $this->orderView
+ );
+ }
+}
diff --git a/Test/etc/testcase.xml b/Test/etc/testcase.xml
index b2d91929d0ea9..4a177f1545fa9 100644
--- a/Test/etc/testcase.xml
+++ b/Test/etc/testcase.xml
@@ -19,8 +19,8 @@
-
-
+
+
From 22760a1b4aaaaf96ce8583296c69cbaab2889d61 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Fri, 17 Feb 2017 15:35:56 +0200
Subject: [PATCH 0273/2045] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed a comment
---
etc/signifyd_payment_mapping.xml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/etc/signifyd_payment_mapping.xml b/etc/signifyd_payment_mapping.xml
index c6016ce7fddaf..cafea60dd2d79 100644
--- a/etc/signifyd_payment_mapping.xml
+++ b/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 a337032291ebce748b02bba3c5e79a0bb805138a Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 17 Feb 2017 19:20:17 +0200
Subject: [PATCH 0274/2045] MAGETWO-63855: Create functional automated for
complete Signifyd flow
---
Test/Block/{Sanbox => Sandbox}/CaseInfo.php | 76 +++++++++-
Test/Block/{Sanbox => Sandbox}/CaseSearch.php | 23 ++-
.../Login.php => Sandbox/SignifydLogin.php} | 9 +-
Test/Block/Sandbox/WebhookAdd.php | 119 +++++++++++++++
Test/Block/Sandbox/WebhookList.php | 96 +++++++++++++
.../AssertAuthorizationInCommentsHistory.php | 58 --------
Test/Constraint/AssertCaseInfo.php | 135 +++++++++++++++---
Test/Constraint/AssertCaseInfoOnBackend.php | 55 +++++--
...nifydGuaranteeCancelInCommentsHistory.php} | 23 ++-
Test/Page/Sandbox/SignifydCases.xml | 4 +-
Test/Page/Sandbox/SignifydLogin.xml | 2 +-
Test/Page/Sandbox/SignifydNotifications.xml | 13 ++
.../OnePageCheckoutWithBraintreeTest.xml | 9 +-
Test/TestStep/OpenOrderGridStep.php | 4 +-
...seStep.php => SignifydObserveCaseStep.php} | 66 +++++----
.../SignifydSetWebhooksAddressStep.php | 74 ++++++++++
Test/etc/testcase.xml | 7 +-
17 files changed, 625 insertions(+), 148 deletions(-)
rename Test/Block/{Sanbox => Sandbox}/CaseInfo.php (68%)
rename Test/Block/{Sanbox => Sandbox}/CaseSearch.php (78%)
rename Test/Block/{Sanbox/Login.php => Sandbox/SignifydLogin.php} (72%)
create mode 100644 Test/Block/Sandbox/WebhookAdd.php
create mode 100644 Test/Block/Sandbox/WebhookList.php
delete mode 100644 Test/Constraint/AssertAuthorizationInCommentsHistory.php
rename Test/Constraint/{AssertGuaranteeCancelInCommentsHistory.php => AssertSignifydGuaranteeCancelInCommentsHistory.php} (66%)
create mode 100644 Test/Page/Sandbox/SignifydNotifications.xml
rename Test/TestStep/{ObserveSignifydCaseStep.php => SignifydObserveCaseStep.php} (65%)
create mode 100644 Test/TestStep/SignifydSetWebhooksAddressStep.php
diff --git a/Test/Block/Sanbox/CaseInfo.php b/Test/Block/Sandbox/CaseInfo.php
similarity index 68%
rename from Test/Block/Sanbox/CaseInfo.php
rename to Test/Block/Sandbox/CaseInfo.php
index 5373b71f0f8d2..3851788f3880d 100644
--- a/Test/Block/Sanbox/CaseInfo.php
+++ b/Test/Block/Sandbox/CaseInfo.php
@@ -3,28 +3,85 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Block\Sanbox;
+namespace Magento\Signifyd\Test\Block\Sandbox;
use Magento\Mtf\Block\Block;
use Magento\Mtf\Client\Locator;
+/**
+ * Block with case information.
+ */
class CaseInfo extends Block
{
- private $flagGoodButton = 'button.flag-case-good';
+ /**
+ * @var string
+ */
+ private $flagGoodButton = '.flag-case-good';
+
+ /**
+ * @var string
+ */
+ private $guaranteeDisposition = '.guarantee-status';
+
+ /**
+ * @var string
+ */
private $cvvResponseDescription = '//span[contains(@ng-bind, "caseOrderSummary.cvvResponseDescription")]';
+
+ /**
+ * @var string
+ */
private $cvvResponseCode = '//span[contains(@ng-bind, "caseOrderSummary.cvvResponseCode")]';
+
+ /**
+ * @var string
+ */
private $avsResponseDescription = '//span[contains(@ng-bind, "caseOrderSummary.avsResponseDescription")]';
+
+ /**
+ * @var string
+ */
private $avsResponseCode = '//span[contains(@ng-bind, "caseOrderSummary.avsResponseCode")]';
+
+ /**
+ * @var string
+ */
private $orderId = '//span[contains(@ng-bind, "currentCase.caseIdDisplay")]';
+
+ /**
+ * @var string
+ */
private $orderAmount = '//span[contains(@ng-bind, "currentCase.orderAmount")]';
+
+ /**
+ * @var string
+ */
private $cardHolder = '//a[contains(@data-dropdown, "peopleLinks0")]//span';
+
+ /**
+ * @var string
+ */
private $billingAddress = '//a[contains(@data-dropdown, "streetLinks0")]';
+ /**
+ * @return void
+ */
public function flagCaseGood()
{
$this->_rootElement->find($this->flagGoodButton)->click();
}
+ /**
+ * @return array|string
+ */
+ public function getGuaranteeDisposition()
+ {
+ return $this->_rootElement->find($this->guaranteeDisposition)->getText();
+ }
+
+ /**
+ * @return string
+ */
public function getCvvResponse()
{
return sprintf(
@@ -34,6 +91,9 @@ public function getCvvResponse()
);
}
+ /**
+ * @return string
+ */
public function getAvsResponse()
{
return sprintf(
@@ -43,21 +103,33 @@ public function getAvsResponse()
);
}
+ /**
+ * @return array|string
+ */
public function getOrderId()
{
return $this->_rootElement->find($this->orderId, Locator::SELECTOR_XPATH)->getText();
}
+ /**
+ * @return array|string
+ */
public function getOrderAmount()
{
return $this->_rootElement->find($this->orderAmount, Locator::SELECTOR_XPATH)->getText();
}
+ /**
+ * @return array|string
+ */
public function getCardHolder()
{
return $this->_rootElement->find($this->cardHolder, Locator::SELECTOR_XPATH)->getText();
}
+ /**
+ * @return array|string
+ */
public function getBillingAddress()
{
return $this->_rootElement->find($this->billingAddress, Locator::SELECTOR_XPATH)->getText();
diff --git a/Test/Block/Sanbox/CaseSearch.php b/Test/Block/Sandbox/CaseSearch.php
similarity index 78%
rename from Test/Block/Sanbox/CaseSearch.php
rename to Test/Block/Sandbox/CaseSearch.php
index adb1b8b48abe0..aeeaf2c28cf24 100644
--- a/Test/Block/Sanbox/CaseSearch.php
+++ b/Test/Block/Sandbox/CaseSearch.php
@@ -3,22 +3,34 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Block\Sanbox;
+namespace Magento\Signifyd\Test\Block\Sandbox;
use Magento\Mtf\Block\Form;
use Magento\Mtf\Client\Locator;
+/**
+ * Side block with case search and cases list.
+ */
class CaseSearch extends Form
{
/**
- * Submit button for Signifyd case search.
- *
* @var string
*/
private $searchInput = '#queueSearchBar';
+
+ /**
+ * @var string
+ */
private $buttonSubmit = '[type=submit]';
+
+ /**
+ * @var string
+ */
private $buttonCase = '//ul//li[contains(@class, "app-sidebar-item")][1]//a';
+ /**
+ * @param $searchCriteria
+ */
public function fillSearchCriteria($searchCriteria)
{
$this->waitForElementVisible($this->searchInput);
@@ -26,8 +38,6 @@ public function fillSearchCriteria($searchCriteria)
}
/**
- * Search Signifyd case.
- *
* @return void
*/
public function searchCase()
@@ -35,6 +45,9 @@ public function searchCase()
$this->_rootElement->find($this->buttonSubmit)->click();
}
+ /**
+ * @return void
+ */
public function selectCase()
{
$this->_rootElement->find($this->buttonCase, Locator::SELECTOR_XPATH)->click();
diff --git a/Test/Block/Sanbox/Login.php b/Test/Block/Sandbox/SignifydLogin.php
similarity index 72%
rename from Test/Block/Sanbox/Login.php
rename to Test/Block/Sandbox/SignifydLogin.php
index 2232052e2a25a..97e0e0028875e 100644
--- a/Test/Block/Sanbox/Login.php
+++ b/Test/Block/Sandbox/SignifydLogin.php
@@ -3,18 +3,21 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Block\Sanbox;
+namespace Magento\Signifyd\Test\Block\Sandbox;
use Magento\Mtf\Block\Form;
-class Login extends Form
+/**
+ * Signifyd login block.
+ */
+class SignifydLogin extends Form
{
/**
* Login button on Signifyd side.
*
* @var string
*/
- protected $loginButton = '[type=submit]';
+ private $loginButton = '[type=submit]';
/**
* Login to Signifyd Sandbox.
diff --git a/Test/Block/Sandbox/WebhookAdd.php b/Test/Block/Sandbox/WebhookAdd.php
new file mode 100644
index 0000000000000..fc1824799bc18
--- /dev/null
+++ b/Test/Block/Sandbox/WebhookAdd.php
@@ -0,0 +1,119 @@
+ 'Case Creation',
+ 'CASE_RESCORE' => 'Case Rescore',
+ 'CASE_REVIEW' => 'Case Review',
+ 'GUARANTEE_COMPLETION' => 'Guarantee Completion',
+ 'CLAIM_REVIEWED' => 'Claim Review'
+ ];
+
+ public function createWebhooks()
+ {
+ foreach ($this->webhookEventOptionsList as $webhookEventCode => $webhookEventName) {
+ $this->setEvent($webhookEventCode);
+ $this->setTeam();
+ $this->setWebhookUrl();
+ $this->addWebhook($webhookEventName);
+ }
+ }
+
+ /**
+ * @param $webhookEventCode
+ * @return void
+ */
+ private function setEvent($webhookEventCode)
+ {
+ $this->_rootElement->find(sprintf($this->webhookEventOption, $webhookEventCode), Locator::SELECTOR_XPATH)
+ ->click();
+ }
+
+ /**
+ * @return void
+ */
+ private function setTeam()
+ {
+ $this->_rootElement->find($this->webhookTestTeamOption, Locator::SELECTOR_XPATH)->click();
+ }
+
+ /**
+ * @return void
+ */
+ private function setWebhookUrl()
+ {
+ $this->_rootElement->find($this->webhookUrl)->setValue($this->getWebhookUrl());
+ }
+
+ /**
+ * @param $webhookEventName
+ * @return void
+ */
+ private function addWebhook($webhookEventName)
+ {
+ $this->_rootElement->find($this->webhookAddButton)->click();
+
+ // We need to wait until webhook will be added to grid
+ // before proceed to next step
+ $this->_rootElement->waitUntil(
+ function () use ($webhookEventName) {
+ return $this->_rootElement->find(
+ sprintf($this->webhookAddedElement, $this->getWebhookUrl(), $webhookEventName),
+ Locator::SELECTOR_XPATH
+ )->isVisible() ? true : null;
+ }
+ );
+ }
+
+ /**
+ * @return string
+ */
+ private function getWebhookUrl()
+ {
+ return $_ENV['app_frontend_url'] . 'signifyd/webhooks/handler';
+ }
+}
diff --git a/Test/Block/Sandbox/WebhookList.php b/Test/Block/Sandbox/WebhookList.php
new file mode 100644
index 0000000000000..be447990d70f0
--- /dev/null
+++ b/Test/Block/Sandbox/WebhookList.php
@@ -0,0 +1,96 @@
+getWebhooks() as $webhook) {
+ if ($webhook->isPresent() && $this->getWebhookTeam($webhook) === $this->team) {
+ $this->deleteWebhook($webhook);
+ }
+ }
+ }
+
+ /**
+ * @return ElementInterface[]
+ */
+ private function getWebhooks()
+ {
+ return $this->_rootElement->getElements($this->webhooks, Locator::SELECTOR_XPATH);
+ }
+
+ /**
+ * @param ElementInterface $webhookElement
+ * @return array|string
+ */
+ private function getWebhookTeam(ElementInterface $webhookElement)
+ {
+ return $webhookElement->find($this->webhookTeamDisplay)->getText();
+ }
+
+ /**
+ * @param ElementInterface $webhookElement
+ * @return void
+ */
+ private function deleteWebhook(ElementInterface $webhookElement)
+ {
+ $webhookElement->find($this->webhookDeleteButton)->click();
+ $this->_rootElement->find($this->webhookDeleteConfirm, Locator::SELECTOR_XPATH)->click();
+
+ // Signifyd create the same popup every time Selenium click on delete button
+ // So we need to wait that previous popup will be closed
+ $this->_rootElement->waitUntil(
+ function () {
+ return $this->_rootElement->find($this->webhookDeleteOverlay)
+ ->isVisible() ? null : true;
+ }
+ );
+ }
+}
diff --git a/Test/Constraint/AssertAuthorizationInCommentsHistory.php b/Test/Constraint/AssertAuthorizationInCommentsHistory.php
deleted file mode 100644
index f455ee1c9f110..0000000000000
--- a/Test/Constraint/AssertAuthorizationInCommentsHistory.php
+++ /dev/null
@@ -1,58 +0,0 @@
-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(
- sprintf(SalesAssert::AUTHORIZED_AMOUNT_PATTERN, $prices['grandTotal']),
- implode('. ', $commentsMessages),
- 'Incorrect authorized amount value for the order #' . $orderId
- );
- }
-
- /**
- * Returns string representation of successful assertion.
- *
- * @return string
- */
- public function toString()
- {
- return "Message about authorized amount is available in Comments History section.";
- }
-}
diff --git a/Test/Constraint/AssertCaseInfo.php b/Test/Constraint/AssertCaseInfo.php
index 8d5084a0ab0b2..acf67ceaf0505 100644
--- a/Test/Constraint/AssertCaseInfo.php
+++ b/Test/Constraint/AssertCaseInfo.php
@@ -6,51 +6,144 @@
namespace Magento\Signifyd\Test\Constraint;
use Magento\Customer\Test\Fixture\Address;
-use Magento\Customer\Test\Fixture\Customer;
use Magento\Mtf\Constraint\AbstractConstraint;
-use Magento\Sales\Test\Fixture\OrderInjectable;
use Magento\Signifyd\Test\Page\Sandbox\SignifydCases;
+/**
+ * Assert that order information is correct on Signifyd case info page.
+ */
class AssertCaseInfo extends AbstractConstraint
{
- private $cvvResponse = 'CVV2 Match (M)';
- private $avsResponse = 'Full match (Y)';
+ /**
+ * @var SignifydCases
+ */
+ private $signifydCases;
+ /**
+ * @param SignifydCases $signifydCases
+ * @param Address $billingAddress
+ * @param array $prices
+ * @param string $orderId
+ * @param string $customerFullName
+ * @return void
+ */
public function processAssert(
SignifydCases $signifydCases,
- Customer $customer,
- OrderInjectable $order,
Address $billingAddress,
- array $cartPrice
+ array $prices,
+ $orderId,
+ $customerFullName
) {
+ $this->signifydCases = $signifydCases;
+
+ $this->checkGuaranteeDisposition();
+ $this->checkCvvResponse();
+ $this->checkAvsResponse();
+ $this->checkBillingAddress($billingAddress);
+ $this->checkOrderAmount($prices);
+ $this->checkOrderId($orderId);
+ $this->checkCardHolder($customerFullName);
+ }
+
+ /**
+ * Checks guarantee disposition match
+ *
+ * @return void
+ */
+ private function checkGuaranteeDisposition()
+ {
\PHPUnit_Framework_Assert::assertEquals(
- $this->cvvResponse,
- $signifydCases->getCaseInfoBlock()->getCvvResponse()
+ 'Approved',
+ $this->signifydCases->getCaseInfoBlock()->getGuaranteeDisposition(),
+ 'Guarantee disposition in Signifyd sandbox not match.'
);
+ }
+ /**
+ * Checks CVV response match
+ *
+ * @return void
+ */
+ private function checkCvvResponse()
+ {
\PHPUnit_Framework_Assert::assertEquals(
- $this->avsResponse,
- $signifydCases->getCaseInfoBlock()->getAvsResponse()
+ 'CVV2 Match (M)',
+ $this->signifydCases->getCaseInfoBlock()->getCvvResponse(),
+ 'CVV response in Signifyd sandbox not match.'
);
+ }
+ /**
+ * Checks AVS response match
+ *
+ * @return void
+ */
+ private function checkAvsResponse()
+ {
\PHPUnit_Framework_Assert::assertEquals(
- $order->getId(),
- $signifydCases->getCaseInfoBlock()->getOrderId()
+ 'Full match (Y)',
+ $this->signifydCases->getCaseInfoBlock()->getAvsResponse(),
+ 'AVS response in Signifyd sandbox not match.'
+ );
+ }
+
+ /**
+ * Checks billing address match
+ *
+ * @param Address $billingAddress
+ * @return void
+ */
+ private function checkBillingAddress(Address $billingAddress)
+ {
+ \PHPUnit_Framework_Assert::assertContains(
+ $billingAddress->getStreet(),
+ $this->signifydCases->getCaseInfoBlock()->getBillingAddress(),
+ 'Billing address in Signifyd sandbox not match.'
);
+ }
+ /**
+ * Checks order amount match
+ *
+ * @param array $prices
+ * @return void
+ */
+ private function checkOrderAmount(array $prices)
+ {
\PHPUnit_Framework_Assert::assertEquals(
- number_format($cartPrice['grand_total'], 2),
- $signifydCases->getCaseInfoBlock()->getOrderAmount()
+ number_format($prices['grandTotal'], 2),
+ $this->signifydCases->getCaseInfoBlock()->getOrderAmount(),
+ 'Order amount in Signifyd sandbox not match.'
);
+ }
+ /**
+ * Checks order id match
+ *
+ * @param string $orderId
+ * @return void
+ */
+ private function checkOrderId($orderId)
+ {
\PHPUnit_Framework_Assert::assertEquals(
- sprintf('%s %s', $customer->getFirstname(), $customer->getLastname()),
- $signifydCases->getCaseInfoBlock()->getCardHolder()
+ $orderId,
+ $this->signifydCases->getCaseInfoBlock()->getOrderId(),
+ 'Order id in Signifyd sandbox not match.'
);
+ }
- \PHPUnit_Framework_Assert::assertContains(
- $billingAddress->getStreet(),
- $signifydCases->getCaseInfoBlock()->getBillingAddress()
+ /**
+ * Checks card holder match
+ *
+ * @param string $customerFullName
+ * @return void
+ */
+ private function checkCardHolder($customerFullName)
+ {
+ \PHPUnit_Framework_Assert::assertEquals(
+ $customerFullName,
+ $this->signifydCases->getCaseInfoBlock()->getCardHolder(),
+ 'Card holder in Signifyd sandbox not match.'
);
}
@@ -61,6 +154,6 @@ public function processAssert(
*/
public function toString()
{
- return 'Case information is correct.';
+ return 'Signifyd case information in sandbox is correct.';
}
}
diff --git a/Test/Constraint/AssertCaseInfoOnBackend.php b/Test/Constraint/AssertCaseInfoOnBackend.php
index 5b52848309d2a..1d8976777d64e 100644
--- a/Test/Constraint/AssertCaseInfoOnBackend.php
+++ b/Test/Constraint/AssertCaseInfoOnBackend.php
@@ -13,6 +13,16 @@
*/
class AssertCaseInfoOnBackend extends AbstractConstraint
{
+ /**
+ * @var OrderView
+ */
+ private $orderView;
+
+ /**
+ * @var string
+ */
+ private $orderId;
+
/**
* @var string
*/
@@ -39,25 +49,54 @@ public function processAssert(
OrderView $orderView,
$orderId
) {
- $orderView->open(['order_id' => $orderId]);
- $fraudBlock = $orderView->getFraudProtectionBlock();
+ $this->orderView = $orderView;
+ $this->orderView->open(['order_id' => $orderId]);
+ $this->orderId = $orderId;
+ $this->checkCaseStatus();
+ $this->checkCaseGuaranteeDisposition();
+ $this->checkCaseReviewDisposition();
+ }
+
+ /**
+ * Checks case status match
+ *
+ * @return void
+ */
+ private function checkCaseStatus()
+ {
\PHPUnit_Framework_Assert::assertEquals(
self::$caseStatus,
- $fraudBlock->getCaseStatus(),
- 'Case status is wrong for order #'.$orderId
+ $this->orderView->getFraudProtectionBlock()->getCaseStatus(),
+ 'Case status is wrong for order #' . $this->orderId
);
+ }
+ /**
+ * Checks case guarantee disposition match
+ *
+ * @return void
+ */
+ private function checkCaseGuaranteeDisposition()
+ {
\PHPUnit_Framework_Assert::assertEquals(
self::$guaranteeDisposition,
- $fraudBlock->getCaseGuaranteeDisposition(),
- 'Case Guarantee Disposition status is wrong for order #'.$orderId
+ $this->orderView->getFraudProtectionBlock()->getCaseGuaranteeDisposition(),
+ 'Case Guarantee Disposition status is wrong for order #' . $this->orderId
);
+ }
+ /**
+ * Checks case review disposition match
+ *
+ * @return void
+ */
+ private function checkCaseReviewDisposition()
+ {
\PHPUnit_Framework_Assert::assertEquals(
self::$reviewDisposition,
- $fraudBlock->getCaseReviewDisposition(),
- 'Case Review Disposition status is wrong for order #'.$orderId
+ $this->orderView->getFraudProtectionBlock()->getCaseReviewDisposition(),
+ 'Case Review Disposition status is wrong for order #' . $this->orderId
);
}
diff --git a/Test/Constraint/AssertGuaranteeCancelInCommentsHistory.php b/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
similarity index 66%
rename from Test/Constraint/AssertGuaranteeCancelInCommentsHistory.php
rename to Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
index 4fe8a439ec07c..d2913c8375f7f 100644
--- a/Test/Constraint/AssertGuaranteeCancelInCommentsHistory.php
+++ b/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
@@ -9,7 +9,10 @@
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
-class AssertGuaranteeCancelInCommentsHistory extends AbstractConstraint
+/**
+ * Class AssertSignifydGuaranteeCancelInCommentsHistory
+ */
+class AssertSignifydGuaranteeCancelInCommentsHistory extends AbstractConstraint
{
/**
* Pattern of message about canceled amount in order.
@@ -32,19 +35,13 @@ public function processAssert(
/** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
$infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
- $comments = $infoTab->getCommentsHistoryBlock()->getComments();
-
- foreach ($comments as $key => $comment) {
- if (strstr($comment['comment'], 'Case Update') === false) {
- unset($comments[$key]);
- }
- }
- $comments = array_values($comments);
+ $orderComments = $infoTab->getCommentsHistoryBlock()->getComments();
+ $commentsMessages = array_column($orderComments, 'comment');
- \PHPUnit_Framework_Assert::assertRegExp(
+ \PHPUnit_Framework_Assert::assertContains(
$this->guaranteeCancelPattern,
- $comments[0]['comment'],
- 'Incorrect guarantee cancel for the order #' . $orderId
+ implode('. ', $commentsMessages),
+ 'Signifyd guarantee cancel incorrect for the order #' . $orderId
);
}
@@ -55,6 +52,6 @@ public function processAssert(
*/
public function toString()
{
- return "Message about guarantee cancel is available in Comments History section.";
+ return "Message about Signifyd guarantee cancel is available in Comments History section.";
}
}
diff --git a/Test/Page/Sandbox/SignifydCases.xml b/Test/Page/Sandbox/SignifydCases.xml
index 53db0881a8ba9..60d8d9b92f62e 100644
--- a/Test/Page/Sandbox/SignifydCases.xml
+++ b/Test/Page/Sandbox/SignifydCases.xml
@@ -7,7 +7,7 @@
-->
-
-
+
+
diff --git a/Test/Page/Sandbox/SignifydLogin.xml b/Test/Page/Sandbox/SignifydLogin.xml
index 232b6f059e5b7..7d3a60ddd46ed 100644
--- a/Test/Page/Sandbox/SignifydLogin.xml
+++ b/Test/Page/Sandbox/SignifydLogin.xml
@@ -7,6 +7,6 @@
-->
-
+
diff --git a/Test/Page/Sandbox/SignifydNotifications.xml b/Test/Page/Sandbox/SignifydNotifications.xml
new file mode 100644
index 0000000000000..86a1b8a4dc130
--- /dev/null
+++ b/Test/Page/Sandbox/SignifydNotifications.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
diff --git a/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml b/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
index c00053382cfb8..f16b208bea262 100644
--- a/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
+++ b/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
@@ -9,10 +9,6 @@
catalogProductSimple::product_10_dollar
- 15.00
- 15
- 10
- 5
login
signifyd_approve_us_customer
signifyd_approve_us_shipping_address
@@ -29,10 +25,13 @@
sandbox_default
Processing
test_type:3rd_party_test, severity:S1
+
-
+
+
+
diff --git a/Test/TestStep/OpenOrderGridStep.php b/Test/TestStep/OpenOrderGridStep.php
index 508d0dbc27126..b2fc0bd58a300 100644
--- a/Test/TestStep/OpenOrderGridStep.php
+++ b/Test/TestStep/OpenOrderGridStep.php
@@ -10,14 +10,13 @@
use Magento\Sales\Test\TestStep\OpenOrderStep;
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
-use Magento\Mtf\TestStep\TestStepInterface;
use Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect as AssertOrderStatus;
use Magento\Signifyd\Test\Constraint\AssertSignifydCaseInOrdersGrid as AssertOrdersGrid;
use Magento\Signifyd\Test\Constraint\AssertCaseInfoOnBackend;
use Magento\Signifyd\Test\Page\Adminhtml\OrderView;
/**
- * Open order step.
+ * Open order grid step.
*/
class OpenOrderGridStep extends OpenOrderStep
{
@@ -52,7 +51,6 @@ class OpenOrderGridStep extends OpenOrderStep
private $orderView;
/**
- * @constructor
* @param string $status
* @param OrderInjectable $order
* @param OrderIndex $orderIndex
diff --git a/Test/TestStep/ObserveSignifydCaseStep.php b/Test/TestStep/SignifydObserveCaseStep.php
similarity index 65%
rename from Test/TestStep/ObserveSignifydCaseStep.php
rename to Test/TestStep/SignifydObserveCaseStep.php
index c9f5107d34974..4b9c494be2289 100644
--- a/Test/TestStep/ObserveSignifydCaseStep.php
+++ b/Test/TestStep/SignifydObserveCaseStep.php
@@ -8,13 +8,15 @@
use Magento\Customer\Test\Fixture\Address;
use Magento\Customer\Test\Fixture\Customer;
use Magento\Mtf\TestStep\TestStepInterface;
-use Magento\Sales\Test\Fixture\OrderInjectable;
use Magento\Signifyd\Test\Constraint\AssertCaseInfo;
use Magento\Signifyd\Test\Fixture\SandboxMerchant;
use Magento\Signifyd\Test\Page\Sandbox\SignifydCases;
use Magento\Signifyd\Test\Page\Sandbox\SignifydLogin;
-class ObserveSignifydCaseStep implements TestStepInterface
+/**
+ * Class SignifydObserveCaseStep
+ */
+class SignifydObserveCaseStep implements TestStepInterface
{
/**
* Signifyd Sandbox merchant fixture.
@@ -39,50 +41,54 @@ class ObserveSignifydCaseStep implements TestStepInterface
private $customer;
/**
- * @var AssertCaseInfo
+ * @var Address
*/
- private $assertCaseInfo;
+ private $billingAddress;
/**
- * @var OrderInjectable
+ * @var array
*/
- private $order;
+ private $prices;
/**
- * @var array
+ * @var string
*/
- private $cartPrice;
+ private $orderId;
+
/**
- * @var Address
+ * @var AssertCaseInfo
*/
- private $billingAddress;
+ private $assertCaseInfo;
/**
+ * ObserveSignifydCaseStep constructor.
* @param SandboxMerchant $sandboxMerchant
* @param SignifydLogin $signifydLogin
* @param SignifydCases $signifydCases
* @param Customer $customer
+ * @param Address $billingAddress
+ * @param array $prices
+ * @param string $orderId
* @param AssertCaseInfo $assertCaseInfo
- * @param OrderInjectable $order
*/
public function __construct(
SandboxMerchant $sandboxMerchant,
SignifydLogin $signifydLogin,
SignifydCases $signifydCases,
Customer $customer,
- AssertCaseInfo $assertCaseInfo,
- OrderInjectable $order,
Address $billingAddress,
- array $cartPrice
+ array $prices,
+ $orderId,
+ AssertCaseInfo $assertCaseInfo
) {
$this->sandboxMerchant = $sandboxMerchant;
$this->signifydLogin = $signifydLogin;
$this->signifydCases = $signifydCases;
$this->customer = $customer;
- $this->assertCaseInfo = $assertCaseInfo;
- $this->order = $order;
- $this->cartPrice = $cartPrice;
$this->billingAddress = $billingAddress;
+ $this->prices = $prices;
+ $this->orderId = $orderId;
+ $this->assertCaseInfo = $assertCaseInfo;
}
/**
@@ -92,17 +98,29 @@ public function __construct(
*/
public function run()
{
- $this->signifydLogin->open();
- $this->signifydLogin->getLoginBlock()->fill($this->sandboxMerchant);
- $this->signifydLogin->getLoginBlock()->sandboxLogin();
-
+ //Login in Signifyd sandbox provides on signifydSetWebhooksAddress step
+ $this->signifydCases->open();
$this->signifydCases->getCaseSearchBlock()
- ->fillSearchCriteria($this->customer->getFirstname() . ' ' . $this->customer->getLastname());
+ ->fillSearchCriteria($this->getCustomerFullName($this->customer));
$this->signifydCases->getCaseSearchBlock()->searchCase();
-
$this->signifydCases->getCaseSearchBlock()->selectCase();
$this->signifydCases->getCaseInfoBlock()->flagCaseGood();
- $this->assertCaseInfo->processAssert($this->signifydCases, $this->customer, $this->order, $this->billingAddress, $this->cartPrice);
+ $this->assertCaseInfo->processAssert(
+ $this->signifydCases,
+ $this->billingAddress,
+ $this->prices,
+ $this->orderId,
+ $this->getCustomerFullName($this->customer)
+ );
+ }
+
+ /**
+ * @param Customer $customer
+ * @return string
+ */
+ private function getCustomerFullName(Customer $customer)
+ {
+ return sprintf('%s %s', $customer->getFirstname(), $customer->getLastname());
}
}
diff --git a/Test/TestStep/SignifydSetWebhooksAddressStep.php b/Test/TestStep/SignifydSetWebhooksAddressStep.php
new file mode 100644
index 0000000000000..f00e21fea4653
--- /dev/null
+++ b/Test/TestStep/SignifydSetWebhooksAddressStep.php
@@ -0,0 +1,74 @@
+sandboxMerchant = $sandboxMerchant;
+ $this->signifydLogin = $signifydLogin;
+ $this->signifydCases = $signifydCases;
+ $this->signifydNotifications = $signifydNotifications;
+ }
+
+ /**
+ * Run step flow
+ *
+ * @return void
+ */
+ public function run()
+ {
+ $this->signifydLogin->open();
+ $this->signifydLogin->getLoginBlock()->fill($this->sandboxMerchant);
+ $this->signifydLogin->getLoginBlock()->sandboxLogin();
+
+ $this->signifydCases->getCaseSearchBlock()->waitForElementVisible('#queueSearchBar');
+
+ $this->signifydNotifications->open();
+ $this->signifydNotifications->getWebhooksBlock()->cleanup();
+ $this->signifydNotifications->getWebhookAddBlock()->createWebhooks();
+ }
+}
diff --git a/Test/etc/testcase.xml b/Test/etc/testcase.xml
index 4a177f1545fa9..2f600a753ac5a 100644
--- a/Test/etc/testcase.xml
+++ b/Test/etc/testcase.xml
@@ -7,7 +7,8 @@
-->
-
+
+
@@ -18,8 +19,8 @@
-
-
+
+
From 02c464c25fa0e1abdc9e51ec1fe104087e0a976d Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Tue, 21 Feb 2017 15:41:42 +0200
Subject: [PATCH 0275/2045] MAGETWO-63855: Create functional automated for
complete Signifyd flow
- Code review fixes
---
Test/Block/Adminhtml/Order/Grid.php | 2 -
.../Adminhtml/Order/View/FraudProtection.php | 7 +-
Test/Block/Sandbox/CaseInfo.php | 89 +++++++++++------
Test/Block/Sandbox/CaseSearch.php | 36 ++++---
Test/Block/Sandbox/SignifydLogin.php | 6 +-
Test/Block/Sandbox/WebhookAdd.php | 61 ++++++++----
Test/Block/Sandbox/WebhookGrid.php | 94 ++++++++++++++++++
Test/Block/Sandbox/WebhookList.php | 96 ------------------
Test/Constraint/AssertCaseInfoOnBackend.php | 37 ++++---
...hp => AssertCaseInfoOnSignifydConsole.php} | 97 ++++++++++---------
.../AssertSignifydCaseInOrdersGrid.php | 8 +-
...gnifydGuaranteeCancelInCommentsHistory.php | 9 +-
...andboxMerchant.xml => SignifydAccount.xml} | 6 +-
Test/Page/Adminhtml/OrderView.xml | 2 +-
Test/Page/Sandbox/SignifydCases.xml | 4 +-
Test/Page/Sandbox/SignifydLogin.xml | 2 +-
Test/Page/Sandbox/SignifydNotifications.xml | 4 +-
...andboxMerchant.xml => SignifydAccount.xml} | 2 +-
...ateSignifydGuaranteeAndCancelOrderTest.php | 62 ++++++++++++
...teSignifydGuaranteeAndCancelOrderTest.xml} | 16 +--
.../OnePageCheckoutWithBraintreeTest.php | 31 ------
Test/TestStep/OpenOrderGridStep.php | 37 ++++++-
Test/TestStep/SignifydLoginStep.php | 67 +++++++++++++
Test/TestStep/SignifydObserveCaseStep.php | 68 ++++++-------
.../SignifydSetWebhookHandlersStep.php | 53 ++++++++++
.../SignifydSetWebhooksAddressStep.php | 74 --------------
Test/etc/testcase.xml | 10 +-
27 files changed, 586 insertions(+), 394 deletions(-)
create mode 100644 Test/Block/Sandbox/WebhookGrid.php
delete mode 100644 Test/Block/Sandbox/WebhookList.php
rename Test/Constraint/{AssertCaseInfo.php => AssertCaseInfoOnSignifydConsole.php} (62%)
rename Test/Fixture/{SandboxMerchant.xml => SignifydAccount.xml} (80%)
rename Test/Repository/{SandboxMerchant.xml => SignifydAccount.xml} (88%)
create mode 100644 Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
rename Test/TestCase/{OnePageCheckoutWithBraintreeTest.xml => CreateSignifydGuaranteeAndCancelOrderTest.xml} (68%)
delete mode 100644 Test/TestCase/OnePageCheckoutWithBraintreeTest.php
create mode 100644 Test/TestStep/SignifydLoginStep.php
create mode 100644 Test/TestStep/SignifydSetWebhookHandlersStep.php
delete mode 100644 Test/TestStep/SignifydSetWebhooksAddressStep.php
diff --git a/Test/Block/Adminhtml/Order/Grid.php b/Test/Block/Adminhtml/Order/Grid.php
index 6fe08d02ad5e6..03de97f0e3050 100644
--- a/Test/Block/Adminhtml/Order/Grid.php
+++ b/Test/Block/Adminhtml/Order/Grid.php
@@ -3,10 +3,8 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
namespace Magento\Signifyd\Test\Block\Adminhtml\Order;
-use Magento\Mtf\Client\Locator;
use Magento\Ui\Test\Block\Adminhtml\DataGrid;
/**
diff --git a/Test/Block/Adminhtml/Order/View/FraudProtection.php b/Test/Block/Adminhtml/Order/View/FraudProtection.php
index 2c9926d08005b..b3daee7725f13 100644
--- a/Test/Block/Adminhtml/Order/View/FraudProtection.php
+++ b/Test/Block/Adminhtml/Order/View/FraudProtection.php
@@ -6,7 +6,6 @@
namespace Magento\Signifyd\Test\Block\Adminhtml\Order\View;
use Magento\Mtf\Block\Block;
-use Magento\Mtf\Client\Locator;
/**
* Information about fraud protection on order page.
@@ -41,7 +40,7 @@ class FraudProtection extends Block
*/
public function getCaseStatus()
{
- return $this->_rootElement->find($this->caseStatus, Locator::SELECTOR_CSS)->getText();
+ return $this->_rootElement->find($this->caseStatus)->getText();
}
/**
@@ -51,7 +50,7 @@ public function getCaseStatus()
*/
public function getCaseGuaranteeDisposition()
{
- return $this->_rootElement->find($this->caseGuaranteeDisposition, Locator::SELECTOR_CSS)->getText();
+ return $this->_rootElement->find($this->caseGuaranteeDisposition)->getText();
}
/**
@@ -61,6 +60,6 @@ public function getCaseGuaranteeDisposition()
*/
public function getCaseReviewDisposition()
{
- return $this->_rootElement->find($this->caseReviewDisposition, Locator::SELECTOR_CSS)->getText();
+ return $this->_rootElement->find($this->caseReviewDisposition)->getText();
}
}
diff --git a/Test/Block/Sandbox/CaseInfo.php b/Test/Block/Sandbox/CaseInfo.php
index 3851788f3880d..8389daccef627 100644
--- a/Test/Block/Sandbox/CaseInfo.php
+++ b/Test/Block/Sandbox/CaseInfo.php
@@ -6,73 +6,96 @@
namespace Magento\Signifyd\Test\Block\Sandbox;
use Magento\Mtf\Block\Block;
-use Magento\Mtf\Client\Locator;
/**
- * Block with case information.
+ * Case information block.
*/
class CaseInfo extends Block
{
/**
+ * Css selector of "Flag Case As Good" button.
+ *
* @var string
*/
- private $flagGoodButton = '.flag-case-good';
+ private $flagCaseAsGoodButton = '[class*="flag-case-good"]';
/**
+ * Css selector of guarantee status.
+ *
* @var string
*/
- private $guaranteeDisposition = '.guarantee-status';
+ private $guaranteeDisposition = '[class*="guarantee-status"]';
/**
+ * Css selector of CVV response description.
+ *
* @var string
*/
- private $cvvResponseDescription = '//span[contains(@ng-bind, "caseOrderSummary.cvvResponseDescription")]';
+ private $cvvResponseDescription = '[ng-bind="caseOrderSummary.cvvResponseDescription"]';
/**
+ * Css selector of CVV response code.
+ *
* @var string
*/
- private $cvvResponseCode = '//span[contains(@ng-bind, "caseOrderSummary.cvvResponseCode")]';
+ private $cvvResponseCode = '[ng-bind="caseOrderSummary.cvvResponseCode"]';
/**
+ * Css selector of AVS response description.
+ *
* @var string
*/
- private $avsResponseDescription = '//span[contains(@ng-bind, "caseOrderSummary.avsResponseDescription")]';
+ private $avsResponseDescription = '[ng-bind="caseOrderSummary.avsResponseDescription"]';
/**
+ * Css selector of AVS response code.
+ *
* @var string
*/
- private $avsResponseCode = '//span[contains(@ng-bind, "caseOrderSummary.avsResponseCode")]';
+ private $avsResponseCode = '[ng-bind="caseOrderSummary.avsResponseCode"]';
/**
+ * Css selector of displayed case order id.
+ *
* @var string
*/
- private $orderId = '//span[contains(@ng-bind, "currentCase.caseIdDisplay")]';
+ private $orderId = '[ng-bind="currentCase.caseIdDisplay"]';
/**
+ * Css selector of displayed order amount.
+ *
* @var string
*/
- private $orderAmount = '//span[contains(@ng-bind, "currentCase.orderAmount")]';
+ private $orderAmount = '[ng-bind*="currentCase.orderAmount"]';
/**
+ * Css selector of displayed card holder name.
+ *
* @var string
*/
- private $cardHolder = '//a[contains(@data-dropdown, "peopleLinks0")]//span';
+ private $cardHolder = '[data-dropdown="peopleLinks0"] span';
/**
+ * Css selector of displayed billing address.
+ *
* @var string
*/
- private $billingAddress = '//a[contains(@data-dropdown, "streetLinks0")]';
+ private $billingAddress = '[data-dropdown="streetLinks0"]';
/**
+ * Flags case as good.
+ *
* @return void
*/
- public function flagCaseGood()
+ public function flagCaseAsGood()
{
- $this->_rootElement->find($this->flagGoodButton)->click();
+ $this->_rootElement->find($this->flagCaseAsGoodButton)->click();
}
/**
- * @return array|string
+ * Gets guarantee disposition.
+ *
+ * @return string
*/
public function getGuaranteeDisposition()
{
@@ -80,58 +103,70 @@ public function getGuaranteeDisposition()
}
/**
+ * Gets CVV response.
+ *
* @return string
*/
public function getCvvResponse()
{
return sprintf(
'%s (%s)',
- $this->_rootElement->find($this->cvvResponseDescription, Locator::SELECTOR_XPATH)->getText(),
- $this->_rootElement->find($this->cvvResponseCode, Locator::SELECTOR_XPATH)->getText()
+ $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, Locator::SELECTOR_XPATH)->getText(),
- $this->_rootElement->find($this->avsResponseCode, Locator::SELECTOR_XPATH)->getText()
+ $this->_rootElement->find($this->avsResponseDescription)->getText(),
+ $this->_rootElement->find($this->avsResponseCode)->getText()
);
}
/**
- * @return array|string
+ * Gets displayed order id.
+ *
+ * @return string
*/
public function getOrderId()
{
- return $this->_rootElement->find($this->orderId, Locator::SELECTOR_XPATH)->getText();
+ return $this->_rootElement->find($this->orderId)->getText();
}
/**
- * @return array|string
+ * Gets displayed order amount.
+ *
+ * @return string
*/
public function getOrderAmount()
{
- return $this->_rootElement->find($this->orderAmount, Locator::SELECTOR_XPATH)->getText();
+ return $this->_rootElement->find($this->orderAmount)->getText();
}
/**
- * @return array|string
+ * Gets displayed card holder name.
+ *
+ * @return string
*/
public function getCardHolder()
{
- return $this->_rootElement->find($this->cardHolder, Locator::SELECTOR_XPATH)->getText();
+ return $this->_rootElement->find($this->cardHolder)->getText();
}
/**
- * @return array|string
+ * Gets displayed billing address.
+ *
+ * @return string
*/
public function getBillingAddress()
{
- return $this->_rootElement->find($this->billingAddress, Locator::SELECTOR_XPATH)->getText();
+ return $this->_rootElement->find($this->billingAddress)->getText();
}
}
diff --git a/Test/Block/Sandbox/CaseSearch.php b/Test/Block/Sandbox/CaseSearch.php
index aeeaf2c28cf24..d00b0ac5f2e0b 100644
--- a/Test/Block/Sandbox/CaseSearch.php
+++ b/Test/Block/Sandbox/CaseSearch.php
@@ -14,42 +14,56 @@
class CaseSearch extends Form
{
/**
+ * Css selector of search input.
+ *
* @var string
*/
- private $searchInput = '#queueSearchBar';
+ private $searchBar = '[id=queueSearchBar]';
/**
+ * Css selector of search submit button.
+ *
* @var string
*/
- private $buttonSubmit = '[type=submit]';
+ private $submitButton = '[type=submit]';
/**
+ * XPath selector of first searched element in list.
+ *
* @var string
*/
- private $buttonCase = '//ul//li[contains(@class, "app-sidebar-item")][1]//a';
+ private $selectCaseLink = '//ul//li[contains(@class, "app-sidebar-item")][1]//a';
/**
- * @param $searchCriteria
+ * Fill search input with customer name and submit.
+ *
+ * @param string $customerName
+ * @return void
*/
- public function fillSearchCriteria($searchCriteria)
+ public function searchCaseByCustomerName($customerName)
{
- $this->waitForElementVisible($this->searchInput);
- $this->_rootElement->find($this->searchInput)->setValue($searchCriteria);
+ $this->_rootElement->find($this->searchBar)->setValue($customerName);
+ $this->_rootElement->find($this->submitButton)->click();
}
/**
+ * Select searched case.
+ *
* @return void
*/
- public function searchCase()
+ public function selectCase()
{
- $this->_rootElement->find($this->buttonSubmit)->click();
+ $this->_rootElement->find($this->selectCaseLink, Locator::SELECTOR_XPATH)->click();
}
+
/**
+ * Waiting of case page loading.
+ *
* @return void
*/
- public function selectCase()
+ public function waitForLoading()
{
- $this->_rootElement->find($this->buttonCase, Locator::SELECTOR_XPATH)->click();
+ $this->waitForElementVisible($this->searchBar);
}
}
diff --git a/Test/Block/Sandbox/SignifydLogin.php b/Test/Block/Sandbox/SignifydLogin.php
index 97e0e0028875e..070dc6ac3ea0e 100644
--- a/Test/Block/Sandbox/SignifydLogin.php
+++ b/Test/Block/Sandbox/SignifydLogin.php
@@ -13,18 +13,18 @@
class SignifydLogin extends Form
{
/**
- * Login button on Signifyd side.
+ * Css selector of Signifyd login button.
*
* @var string
*/
private $loginButton = '[type=submit]';
/**
- * Login to Signifyd Sandbox.
+ * Login to Signifyd.
*
* @return void
*/
- public function sandboxLogin()
+ public function login()
{
$this->_rootElement->find($this->loginButton)->click();
}
diff --git a/Test/Block/Sandbox/WebhookAdd.php b/Test/Block/Sandbox/WebhookAdd.php
index fc1824799bc18..183868270746c 100644
--- a/Test/Block/Sandbox/WebhookAdd.php
+++ b/Test/Block/Sandbox/WebhookAdd.php
@@ -14,38 +14,46 @@
class WebhookAdd extends Form
{
/**
+ * Css selector of webhook url input.
+ *
* @var string
*/
- private $webhookUrl = '#webhookUrl';
+ private $webhookUrl = '[id="webhookUrl"]';
/**
+ * XPath selector of test team select option.
+ *
* @var string
*/
- private $webhookTestTeamOption = './/select[@id="webhookTeams"]//option[text()="test"]';
+ 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"]';
+ private $webhookEventOption = 'select[id="webhookEvent"] option[value="%s"]';
/**
+ * Css selector of webhook addition button.
+ *
* @var string
*/
- private $webhookAddedElement = '//tr[./td/span/text()="%s" and ./td/span/text()="%s"]';
+ private $webhookAddButton = '[type=submit]';
/**
- * Add webhook button.
+ * XPath selector of webhook element added into grid.
*
* @var string
*/
- private $webhookAddButton = '[type=submit]';
+ private $webhookAddedElement = '//tr[./td/span/text()="%s" and ./td/span/text()="%s"]';
/**
- * List of option values of webhook event select.
+ * Map of webhook event select option values on names of events in webhook grid.
*
* @var array
*/
- private $webhookEventOptionsList = [
+ private $webhookEventOptionsMap = [
'CASE_CREATION' => 'Case Creation',
'CASE_RESCORE' => 'Case Rescore',
'CASE_REVIEW' => 'Case Review',
@@ -53,35 +61,49 @@ class WebhookAdd extends Form
'CLAIM_REVIEWED' => 'Claim Review'
];
- public function createWebhooks()
+ /**
+ * Creates new set of webhooks.
+ *
+ * @param array $signifydData
+ * @return void
+ */
+ public function createWebhooks($signifydData)
{
- foreach ($this->webhookEventOptionsList as $webhookEventCode => $webhookEventName) {
+ foreach ($this->webhookEventOptionsMap as $webhookEventCode => $webhookEventName) {
$this->setEvent($webhookEventCode);
- $this->setTeam();
+ $this->setTeam($signifydData['team']);
$this->setWebhookUrl();
+
$this->addWebhook($webhookEventName);
}
}
/**
+ * Sets appropriate webhook event select option by code.
+ *
* @param $webhookEventCode
* @return void
*/
private function setEvent($webhookEventCode)
{
- $this->_rootElement->find(sprintf($this->webhookEventOption, $webhookEventCode), Locator::SELECTOR_XPATH)
+ $this->_rootElement->find(sprintf($this->webhookEventOption, $webhookEventCode))
->click();
}
/**
+ * Sets test team select option.
+ *
+ * @param string $team
* @return void
*/
- private function setTeam()
+ private function setTeam($team)
{
- $this->_rootElement->find($this->webhookTestTeamOption, Locator::SELECTOR_XPATH)->click();
+ $this->_rootElement->find(sprintf($this->webhookTeamOption, $team), Locator::SELECTOR_XPATH)->click();
}
/**
+ * Sets webhook handler url input value.
+ *
* @return void
*/
private function setWebhookUrl()
@@ -90,15 +112,18 @@ private function setWebhookUrl()
}
/**
- * @param $webhookEventName
+ * Add webhook element.
+ *
+ * Selenium needs to wait until webhook will be added to grid
+ * before proceed to next step.
+ *
+ * @param string $webhookEventName
* @return void
*/
private function addWebhook($webhookEventName)
{
$this->_rootElement->find($this->webhookAddButton)->click();
- // We need to wait until webhook will be added to grid
- // before proceed to next step
$this->_rootElement->waitUntil(
function () use ($webhookEventName) {
return $this->_rootElement->find(
@@ -110,6 +135,8 @@ function () use ($webhookEventName) {
}
/**
+ * Gets webhook handler url.
+ *
* @return string
*/
private function getWebhookUrl()
diff --git a/Test/Block/Sandbox/WebhookGrid.php b/Test/Block/Sandbox/WebhookGrid.php
new file mode 100644
index 0000000000000..fcd9ca54253ee
--- /dev/null
+++ b/Test/Block/Sandbox/WebhookGrid.php
@@ -0,0 +1,94 @@
+getWebhook($team)) {
+ if ($webhook->isPresent()) {
+ $this->deleteWebhook($webhook);
+ continue;
+ }
+ break;
+ }
+ }
+
+ /**
+ * Gets all existing webhook elements from grid.
+ *
+ * @param string $team
+ * @return ElementInterface
+ */
+ private function getWebhook($team)
+ {
+ return $this->_rootElement->find(sprintf($this->webhooks, $team), Locator::SELECTOR_XPATH);
+ }
+
+ /**
+ * Delete webhook element with confirmation popup.
+ *
+ * Signifyd creates the same popup every time Selenium click on delete button,
+ * so we need to wait that previous popup will be closed.
+ *
+ * @param ElementInterface $webhookElement
+ * @return void
+ */
+ private function deleteWebhook(ElementInterface $webhookElement)
+ {
+ $webhookElement->find($this->webhookDeleteButton)->click();
+ $this->_rootElement->find($this->webhookDeleteConfirmButton)->click();
+
+ $this->_rootElement->waitUntil(
+ function () {
+ return $this->_rootElement->find($this->webhookDeleteConfirmOverlay)
+ ->isVisible() ? null : true;
+ }
+ );
+ }
+}
diff --git a/Test/Block/Sandbox/WebhookList.php b/Test/Block/Sandbox/WebhookList.php
deleted file mode 100644
index be447990d70f0..0000000000000
--- a/Test/Block/Sandbox/WebhookList.php
+++ /dev/null
@@ -1,96 +0,0 @@
-getWebhooks() as $webhook) {
- if ($webhook->isPresent() && $this->getWebhookTeam($webhook) === $this->team) {
- $this->deleteWebhook($webhook);
- }
- }
- }
-
- /**
- * @return ElementInterface[]
- */
- private function getWebhooks()
- {
- return $this->_rootElement->getElements($this->webhooks, Locator::SELECTOR_XPATH);
- }
-
- /**
- * @param ElementInterface $webhookElement
- * @return array|string
- */
- private function getWebhookTeam(ElementInterface $webhookElement)
- {
- return $webhookElement->find($this->webhookTeamDisplay)->getText();
- }
-
- /**
- * @param ElementInterface $webhookElement
- * @return void
- */
- private function deleteWebhook(ElementInterface $webhookElement)
- {
- $webhookElement->find($this->webhookDeleteButton)->click();
- $this->_rootElement->find($this->webhookDeleteConfirm, Locator::SELECTOR_XPATH)->click();
-
- // Signifyd create the same popup every time Selenium click on delete button
- // So we need to wait that previous popup will be closed
- $this->_rootElement->waitUntil(
- function () {
- return $this->_rootElement->find($this->webhookDeleteOverlay)
- ->isVisible() ? null : true;
- }
- );
- }
-}
diff --git a/Test/Constraint/AssertCaseInfoOnBackend.php b/Test/Constraint/AssertCaseInfoOnBackend.php
index 1d8976777d64e..b3f5060ba648d 100644
--- a/Test/Constraint/AssertCaseInfoOnBackend.php
+++ b/Test/Constraint/AssertCaseInfoOnBackend.php
@@ -14,44 +14,43 @@
class AssertCaseInfoOnBackend extends AbstractConstraint
{
/**
+ * Customized order view page.
+ *
* @var OrderView
*/
private $orderView;
/**
+ * Order id.
+ *
* @var string
*/
private $orderId;
/**
- * @var string
- */
- private static $caseStatus = 'Open';
-
- /**
- * @var string
- */
- private static $guaranteeDisposition = 'Approved';
-
- /**
- * @var string
+ * Array of Signifyd config data.
+ *
+ * @var array
*/
- private static $reviewDisposition = 'Good';
+ private $signifydData;
/**
* Assert that Signifyd Case information is correct on backend.
*
* @param OrderView $orderView
* @param string $orderId
+ * @param array $signifydData
* @return void
*/
public function processAssert(
OrderView $orderView,
- $orderId
+ $orderId,
+ $signifydData
) {
$this->orderView = $orderView;
$this->orderView->open(['order_id' => $orderId]);
$this->orderId = $orderId;
+ $this->signifydData = $signifydData;
$this->checkCaseStatus();
$this->checkCaseGuaranteeDisposition();
@@ -59,42 +58,42 @@ public function processAssert(
}
/**
- * Checks case status match
+ * Checks that case status matches.
*
* @return void
*/
private function checkCaseStatus()
{
\PHPUnit_Framework_Assert::assertEquals(
- self::$caseStatus,
+ $this->signifydData['caseStatus'],
$this->orderView->getFraudProtectionBlock()->getCaseStatus(),
'Case status is wrong for order #' . $this->orderId
);
}
/**
- * Checks case guarantee disposition match
+ * Checks that case guarantee disposition matches.
*
* @return void
*/
private function checkCaseGuaranteeDisposition()
{
\PHPUnit_Framework_Assert::assertEquals(
- self::$guaranteeDisposition,
+ $this->signifydData['guaranteeDisposition'],
$this->orderView->getFraudProtectionBlock()->getCaseGuaranteeDisposition(),
'Case Guarantee Disposition status is wrong for order #' . $this->orderId
);
}
/**
- * Checks case review disposition match
+ * Checks that case review disposition matches.
*
* @return void
*/
private function checkCaseReviewDisposition()
{
\PHPUnit_Framework_Assert::assertEquals(
- self::$reviewDisposition,
+ $this->signifydData['reviewDisposition'],
$this->orderView->getFraudProtectionBlock()->getCaseReviewDisposition(),
'Case Review Disposition status is wrong for order #' . $this->orderId
);
diff --git a/Test/Constraint/AssertCaseInfo.php b/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
similarity index 62%
rename from Test/Constraint/AssertCaseInfo.php
rename to Test/Constraint/AssertCaseInfoOnSignifydConsole.php
index acf67ceaf0505..f63c4075f5457 100644
--- a/Test/Constraint/AssertCaseInfo.php
+++ b/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
@@ -12,9 +12,11 @@
/**
* Assert that order information is correct on Signifyd case info page.
*/
-class AssertCaseInfo extends AbstractConstraint
+class AssertCaseInfoOnSignifydConsole extends AbstractConstraint
{
/**
+ * Signifyd cases page.
+ *
* @var SignifydCases
*/
private $signifydCases;
@@ -25,6 +27,7 @@ class AssertCaseInfo extends AbstractConstraint
* @param array $prices
* @param string $orderId
* @param string $customerFullName
+ * @param array $signifydData
* @return void
*/
public function processAssert(
@@ -32,118 +35,122 @@ public function processAssert(
Address $billingAddress,
array $prices,
$orderId,
- $customerFullName
+ $customerFullName,
+ $signifydData
) {
$this->signifydCases = $signifydCases;
- $this->checkGuaranteeDisposition();
- $this->checkCvvResponse();
- $this->checkAvsResponse();
- $this->checkBillingAddress($billingAddress);
- $this->checkOrderAmount($prices);
+ $this->checkGuaranteeDisposition($signifydData['guaranteeDisposition']);
+ $this->checkCvvResponse($signifydData['cvvResponse']);
+ $this->checkAvsResponse($signifydData['avsResponse']);
$this->checkOrderId($orderId);
+ $this->checkOrderAmount($prices['grandTotal']);
$this->checkCardHolder($customerFullName);
+ $this->checkBillingAddress($billingAddress);
}
/**
- * Checks guarantee disposition match
+ * Checks that guarantee disposition matches.
*
+ * @param string $guaranteeDisposition
* @return void
*/
- private function checkGuaranteeDisposition()
+ private function checkGuaranteeDisposition($guaranteeDisposition)
{
\PHPUnit_Framework_Assert::assertEquals(
- 'Approved',
+ $guaranteeDisposition,
$this->signifydCases->getCaseInfoBlock()->getGuaranteeDisposition(),
- 'Guarantee disposition in Signifyd sandbox not match.'
+ 'Guarantee disposition is incorrect in Signifyd console.'
);
}
/**
- * Checks CVV response match
+ * Checks that CVV response matches.
*
+ * @param string $cvvResponse
* @return void
*/
- private function checkCvvResponse()
+ private function checkCvvResponse($cvvResponse)
{
\PHPUnit_Framework_Assert::assertEquals(
- 'CVV2 Match (M)',
+ $cvvResponse,
$this->signifydCases->getCaseInfoBlock()->getCvvResponse(),
- 'CVV response in Signifyd sandbox not match.'
+ 'CVV response is incorrect in Signifyd console.'
);
}
/**
- * Checks AVS response match
+ * Checks that AVS response matches.
*
+ * @param string $avsResponse
* @return void
*/
- private function checkAvsResponse()
+ private function checkAvsResponse($avsResponse)
{
\PHPUnit_Framework_Assert::assertEquals(
- 'Full match (Y)',
+ $avsResponse,
$this->signifydCases->getCaseInfoBlock()->getAvsResponse(),
- 'AVS response in Signifyd sandbox not match.'
+ 'AVS response is incorrect in Signifyd console.'
);
}
/**
- * Checks billing address match
+ * Checks that order id matches.
*
- * @param Address $billingAddress
+ * @param string $orderId
* @return void
*/
- private function checkBillingAddress(Address $billingAddress)
+ private function checkOrderId($orderId)
{
- \PHPUnit_Framework_Assert::assertContains(
- $billingAddress->getStreet(),
- $this->signifydCases->getCaseInfoBlock()->getBillingAddress(),
- 'Billing address in Signifyd sandbox not match.'
+ \PHPUnit_Framework_Assert::assertEquals(
+ $orderId,
+ $this->signifydCases->getCaseInfoBlock()->getOrderId(),
+ 'Order id is incorrect in Signifyd console.'
);
}
/**
- * Checks order amount match
+ * Checks that order amount matches.
*
- * @param array $prices
+ * @param string $amount
* @return void
*/
- private function checkOrderAmount(array $prices)
+ private function checkOrderAmount($amount)
{
\PHPUnit_Framework_Assert::assertEquals(
- number_format($prices['grandTotal'], 2),
+ number_format($amount, 2),
$this->signifydCases->getCaseInfoBlock()->getOrderAmount(),
- 'Order amount in Signifyd sandbox not match.'
+ 'Order amount is incorrect in Signifyd console.'
);
}
/**
- * Checks order id match
+ * Checks that card holder matches.
*
- * @param string $orderId
+ * @param string $customerFullName
* @return void
*/
- private function checkOrderId($orderId)
+ private function checkCardHolder($customerFullName)
{
\PHPUnit_Framework_Assert::assertEquals(
- $orderId,
- $this->signifydCases->getCaseInfoBlock()->getOrderId(),
- 'Order id in Signifyd sandbox not match.'
+ $customerFullName,
+ $this->signifydCases->getCaseInfoBlock()->getCardHolder(),
+ 'Card holder name is incorrect in Signifyd console.'
);
}
/**
- * Checks card holder match
+ * Checks that billing address matches.
*
- * @param string $customerFullName
+ * @param Address $billingAddress
* @return void
*/
- private function checkCardHolder($customerFullName)
+ private function checkBillingAddress(Address $billingAddress)
{
- \PHPUnit_Framework_Assert::assertEquals(
- $customerFullName,
- $this->signifydCases->getCaseInfoBlock()->getCardHolder(),
- 'Card holder in Signifyd sandbox not match.'
+ \PHPUnit_Framework_Assert::assertContains(
+ $billingAddress->getStreet(),
+ $this->signifydCases->getCaseInfoBlock()->getBillingAddress(),
+ 'Billing address is incorrect in Signifyd console.'
);
}
@@ -154,6 +161,6 @@ private function checkCardHolder($customerFullName)
*/
public function toString()
{
- return 'Signifyd case information in sandbox is correct.';
+ return 'Case information is correct in Signifyd console.';
}
}
diff --git a/Test/Constraint/AssertSignifydCaseInOrdersGrid.php b/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
index 2c8b1fb0b517b..9907639f7352a 100644
--- a/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
+++ b/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
@@ -20,17 +20,19 @@ class AssertSignifydCaseInOrdersGrid extends AbstractConstraint
* @param string $orderId
* @param string $status
* @param OrderView $orderView
+ * @param array $signifydData
* @return void
*/
public function processAssert(
$orderId,
$status,
- OrderView $orderView
+ OrderView $orderView,
+ array $signifydData
) {
$filter = [
'id' => $orderId,
'status' => $status,
- 'signifyd_guarantee_status' => 'Approved'
+ 'signifyd_guarantee_status' => $signifydData['guaranteeDisposition']
];
$errorMessage = implode(', ', $filter);
@@ -50,6 +52,6 @@ public function processAssert(
*/
public function toString()
{
- return 'Signifyd case is present in sales orders grid.';
+ return 'Signifyd guarantee status is displayed in sales orders grid.';
}
}
diff --git a/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php b/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
index d2913c8375f7f..c47b8f1ab6a33 100644
--- a/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
+++ b/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
@@ -15,9 +15,9 @@
class AssertSignifydGuaranteeCancelInCommentsHistory extends AbstractConstraint
{
/**
- * Pattern of message about canceled amount in order.
+ * Signifyd case guarantee cancel message in order view.
*/
- private $guaranteeCancelPattern = 'Case Update: Case guarantee has been cancelled.';
+ private $guaranteeCancelMessage = 'Case Update: Case guarantee has been cancelled.';
/**
* @param SalesOrderView $salesOrderView
@@ -39,9 +39,10 @@ public function processAssert(
$commentsMessages = array_column($orderComments, 'comment');
\PHPUnit_Framework_Assert::assertContains(
- $this->guaranteeCancelPattern,
+ $this->guaranteeCancelMessage,
implode('. ', $commentsMessages),
- 'Signifyd guarantee cancel incorrect for the order #' . $orderId
+ 'There is no message regarding Signifyd guarantee cancel in Comments History section for the order #'
+ . $orderId
);
}
diff --git a/Test/Fixture/SandboxMerchant.xml b/Test/Fixture/SignifydAccount.xml
similarity index 80%
rename from Test/Fixture/SandboxMerchant.xml
rename to Test/Fixture/SignifydAccount.xml
index 5db0871f0e49f..d22cea8a97744 100644
--- a/Test/Fixture/SandboxMerchant.xml
+++ b/Test/Fixture/SignifydAccount.xml
@@ -6,11 +6,11 @@
*/
-->
-
+ repository_class="Magento\Signifyd\Test\Repository\SignifydAccount"
+ class="Magento\Signifyd\Test\Fixture\SignifydAccount">
diff --git a/Test/Page/Adminhtml/OrderView.xml b/Test/Page/Adminhtml/OrderView.xml
index 810f1d1f65b0c..4caf31d460026 100644
--- a/Test/Page/Adminhtml/OrderView.xml
+++ b/Test/Page/Adminhtml/OrderView.xml
@@ -8,6 +8,6 @@
-
+
diff --git a/Test/Page/Sandbox/SignifydCases.xml b/Test/Page/Sandbox/SignifydCases.xml
index 60d8d9b92f62e..94b771742b546 100644
--- a/Test/Page/Sandbox/SignifydCases.xml
+++ b/Test/Page/Sandbox/SignifydCases.xml
@@ -7,7 +7,7 @@
-->
-
-
+
+
diff --git a/Test/Page/Sandbox/SignifydLogin.xml b/Test/Page/Sandbox/SignifydLogin.xml
index 7d3a60ddd46ed..bf44d195f4b49 100644
--- a/Test/Page/Sandbox/SignifydLogin.xml
+++ b/Test/Page/Sandbox/SignifydLogin.xml
@@ -7,6 +7,6 @@
-->
-
+
diff --git a/Test/Page/Sandbox/SignifydNotifications.xml b/Test/Page/Sandbox/SignifydNotifications.xml
index 86a1b8a4dc130..b8e6e7503a1f4 100644
--- a/Test/Page/Sandbox/SignifydNotifications.xml
+++ b/Test/Page/Sandbox/SignifydNotifications.xml
@@ -7,7 +7,7 @@
-->
-
-
+
+
diff --git a/Test/Repository/SandboxMerchant.xml b/Test/Repository/SignifydAccount.xml
similarity index 88%
rename from Test/Repository/SandboxMerchant.xml
rename to Test/Repository/SignifydAccount.xml
index 34e39ed54c3e0..6952df564d797 100644
--- a/Test/Repository/SandboxMerchant.xml
+++ b/Test/Repository/SignifydAccount.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
SIGNIFYD_EMAIL
SIGNIFYD_PASSWORD
diff --git a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
new file mode 100644
index 0000000000000..d616b4afbb395
--- /dev/null
+++ b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
@@ -0,0 +1,62 @@
+executeScenario();
+ }
+}
diff --git a/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
similarity index 68%
rename from Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
rename to Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
index f16b208bea262..4ddce892e4826 100644
--- a/Test/TestCase/OnePageCheckoutWithBraintreeTest.xml
+++ b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
@@ -6,8 +6,8 @@
*/
-->
-
-
+
+
catalogProductSimple::product_10_dollar
login
signifyd_approve_us_customer
@@ -16,14 +16,18 @@
Flat Rate
Fixed
braintree
-
- - 15.00
-
+ 15.00
visa_default
braintree
braintree,signifyd
- sandbox_default
+ sandbox_default
Processing
+ Magento
+ Open
+ Good
+ Approved
+ CVV2 Match (M)
+ Full match (Y)
test_type:3rd_party_test, severity:S1
diff --git a/Test/TestCase/OnePageCheckoutWithBraintreeTest.php b/Test/TestCase/OnePageCheckoutWithBraintreeTest.php
deleted file mode 100644
index f652c3086216d..0000000000000
--- a/Test/TestCase/OnePageCheckoutWithBraintreeTest.php
+++ /dev/null
@@ -1,31 +0,0 @@
-executeScenario();
- }
-}
diff --git a/Test/TestStep/OpenOrderGridStep.php b/Test/TestStep/OpenOrderGridStep.php
index b2fc0bd58a300..4d471915fa48e 100644
--- a/Test/TestStep/OpenOrderGridStep.php
+++ b/Test/TestStep/OpenOrderGridStep.php
@@ -3,7 +3,6 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
namespace Magento\Signifyd\Test\TestStep;
use Magento\Sales\Test\Fixture\OrderInjectable;
@@ -21,35 +20,54 @@
class OpenOrderGridStep extends OpenOrderStep
{
/**
+ * Magento order status assertion.
+ *
* @var AssertOrderStatus
*/
private $assertOrderStatus;
/**
+ * Case information on Magento backend assertion.
+ *
* @var AssertCaseInfoOnBackend
*/
private $assertCaseInfo;
/**
+ * Case information on Magento order grid assertion.
+ *
* @var AssertOrdersGrid
*/
private $assertOrdersGrid;
/**
+ * Magento order status.
+ *
* @var string
*/
private $orderStatus;
/**
+ * Order View Page.
+ *
* @var SalesOrderView
*/
private $salesOrderView;
/**
+ * Customized order view page.
+ *
* @var OrderView
*/
private $orderView;
+ /**
+ * Array of Signifyd config data.
+ *
+ * @var array
+ */
+ private $signifydData;
+
/**
* @param string $status
* @param OrderInjectable $order
@@ -59,6 +77,7 @@ class OpenOrderGridStep extends OpenOrderStep
* @param AssertOrderStatus $assertOrderStatus
* @param AssertCaseInfoOnBackend $assertCaseInfo
* @param AssertOrdersGrid $assertOrdersGrid
+ * @param array $signifydData
*/
public function __construct(
$status,
@@ -68,7 +87,8 @@ public function __construct(
OrderView $orderView,
AssertOrderStatus $assertOrderStatus,
AssertCaseInfoOnBackend $assertCaseInfo,
- AssertOrdersGrid $assertOrdersGrid
+ AssertOrdersGrid $assertOrdersGrid,
+ array $signifydData
) {
$this->orderStatus = $status;
$this->assertOrderStatus = $assertOrderStatus;
@@ -79,6 +99,7 @@ public function __construct(
$this->orderIndex = $orderIndex;
parent::__construct($order, $this->orderIndex);
+ $this->signifydData = $signifydData;
}
/**
@@ -97,6 +118,8 @@ public function run()
/**
* Run assert to check order status is valid.
+ *
+ * @return void
*/
private function checkOrderStatus()
{
@@ -110,24 +133,30 @@ private function checkOrderStatus()
/**
* Run assert to check Signifyd Case information is correct on backend.
+ *
+ * @return void
*/
private function checkCaseInfo()
{
$this->assertCaseInfo->processAssert(
$this->orderView,
- $this->order->getId()
+ $this->order->getId(),
+ $this->signifydData
);
}
/**
* Run assert to check Signifyd Case Disposition status in orders grid.
+ *
+ * @return void
*/
private function checkOrdersGrid()
{
$this->assertOrdersGrid->processAssert(
$this->order->getId(),
$this->orderStatus,
- $this->orderView
+ $this->orderView,
+ $this->signifydData
);
}
}
diff --git a/Test/TestStep/SignifydLoginStep.php b/Test/TestStep/SignifydLoginStep.php
new file mode 100644
index 0000000000000..dc758e5ba5bea
--- /dev/null
+++ b/Test/TestStep/SignifydLoginStep.php
@@ -0,0 +1,67 @@
+signifydAccount = $signifydAccount;
+ $this->signifydLogin = $signifydLogin;
+ $this->signifydCases = $signifydCases;
+ }
+
+ /**
+ * Run step flow
+ *
+ * @return void
+ */
+ public function run()
+ {
+ $this->signifydLogin->open();
+ $this->signifydLogin->getLoginBlock()->fill($this->signifydAccount);
+ $this->signifydLogin->getLoginBlock()->login();
+
+ $this->signifydCases->getCaseSearchBlock()->waitForLoading();
+ }
+}
diff --git a/Test/TestStep/SignifydObserveCaseStep.php b/Test/TestStep/SignifydObserveCaseStep.php
index 4b9c494be2289..86e4cb64f918d 100644
--- a/Test/TestStep/SignifydObserveCaseStep.php
+++ b/Test/TestStep/SignifydObserveCaseStep.php
@@ -8,87 +8,88 @@
use Magento\Customer\Test\Fixture\Address;
use Magento\Customer\Test\Fixture\Customer;
use Magento\Mtf\TestStep\TestStepInterface;
-use Magento\Signifyd\Test\Constraint\AssertCaseInfo;
-use Magento\Signifyd\Test\Fixture\SandboxMerchant;
+use Magento\Signifyd\Test\Constraint\AssertCaseInfoOnSignifydConsole;
use Magento\Signifyd\Test\Page\Sandbox\SignifydCases;
-use Magento\Signifyd\Test\Page\Sandbox\SignifydLogin;
/**
- * Class SignifydObserveCaseStep
+ * Observe case information in Signifyd console step.
*/
class SignifydObserveCaseStep implements TestStepInterface
{
/**
- * Signifyd Sandbox merchant fixture.
+ * Signifyd cases page.
*
- * @var SandboxMerchant
- */
- private $sandboxMerchant;
-
- /**
- * @var SignifydLogin
- */
- private $signifydLogin;
-
- /**
* @var SignifydCases
*/
private $signifydCases;
/**
+ * Customer fixture.
+ *
* @var Customer
*/
private $customer;
/**
+ * Billing address fixture.
+ *
* @var Address
*/
private $billingAddress;
/**
+ * Prices list.
+ *
* @var array
*/
private $prices;
/**
+ * Order id.
+ *
* @var string
*/
private $orderId;
/**
- * @var AssertCaseInfo
+ * Array of Signifyd config data.
+ *
+ * @var array
+ */
+ private $signifydData;
+
+ /**
+ * Case information on Signifyd console assertion.
+ *
+ * @var AssertCaseInfoOnSignifydConsole
*/
- private $assertCaseInfo;
+ private $assertCaseInfoOnSignifydConsole;
/**
- * ObserveSignifydCaseStep constructor.
- * @param SandboxMerchant $sandboxMerchant
- * @param SignifydLogin $signifydLogin
* @param SignifydCases $signifydCases
* @param Customer $customer
* @param Address $billingAddress
* @param array $prices
* @param string $orderId
- * @param AssertCaseInfo $assertCaseInfo
+ * @param array $signifydData
+ * @param AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole
*/
public function __construct(
- SandboxMerchant $sandboxMerchant,
- SignifydLogin $signifydLogin,
SignifydCases $signifydCases,
Customer $customer,
Address $billingAddress,
array $prices,
$orderId,
- AssertCaseInfo $assertCaseInfo
+ array $signifydData,
+ AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole
) {
- $this->sandboxMerchant = $sandboxMerchant;
- $this->signifydLogin = $signifydLogin;
$this->signifydCases = $signifydCases;
$this->customer = $customer;
$this->billingAddress = $billingAddress;
$this->prices = $prices;
$this->orderId = $orderId;
- $this->assertCaseInfo = $assertCaseInfo;
+ $this->assertCaseInfoOnSignifydConsole = $assertCaseInfoOnSignifydConsole;
+ $this->signifydData = $signifydData;
}
/**
@@ -98,24 +99,25 @@ public function __construct(
*/
public function run()
{
- //Login in Signifyd sandbox provides on signifydSetWebhooksAddress step
$this->signifydCases->open();
$this->signifydCases->getCaseSearchBlock()
- ->fillSearchCriteria($this->getCustomerFullName($this->customer));
- $this->signifydCases->getCaseSearchBlock()->searchCase();
+ ->searchCaseByCustomerName($this->getCustomerFullName($this->customer));
$this->signifydCases->getCaseSearchBlock()->selectCase();
- $this->signifydCases->getCaseInfoBlock()->flagCaseGood();
+ $this->signifydCases->getCaseInfoBlock()->flagCaseAsGood();
- $this->assertCaseInfo->processAssert(
+ $this->assertCaseInfoOnSignifydConsole->processAssert(
$this->signifydCases,
$this->billingAddress,
$this->prices,
$this->orderId,
- $this->getCustomerFullName($this->customer)
+ $this->getCustomerFullName($this->customer),
+ $this->signifydData
);
}
/**
+ * Gets customer full name.
+ *
* @param Customer $customer
* @return string
*/
diff --git a/Test/TestStep/SignifydSetWebhookHandlersStep.php b/Test/TestStep/SignifydSetWebhookHandlersStep.php
new file mode 100644
index 0000000000000..1403a42465779
--- /dev/null
+++ b/Test/TestStep/SignifydSetWebhookHandlersStep.php
@@ -0,0 +1,53 @@
+signifydNotifications = $signifydNotifications;
+ $this->signifydData = $signifydData;
+ }
+
+ /**
+ * Run step flow
+ *
+ * @return void
+ */
+ public function run()
+ {
+ $this->signifydNotifications->open();
+ $this->signifydNotifications->getWebhookGridBlock()->cleanupByTeam($this->signifydData['team']);
+ $this->signifydNotifications->getWebhookAddBlock()->createWebhooks($this->signifydData);
+ }
+}
diff --git a/Test/TestStep/SignifydSetWebhooksAddressStep.php b/Test/TestStep/SignifydSetWebhooksAddressStep.php
deleted file mode 100644
index f00e21fea4653..0000000000000
--- a/Test/TestStep/SignifydSetWebhooksAddressStep.php
+++ /dev/null
@@ -1,74 +0,0 @@
-sandboxMerchant = $sandboxMerchant;
- $this->signifydLogin = $signifydLogin;
- $this->signifydCases = $signifydCases;
- $this->signifydNotifications = $signifydNotifications;
- }
-
- /**
- * Run step flow
- *
- * @return void
- */
- public function run()
- {
- $this->signifydLogin->open();
- $this->signifydLogin->getLoginBlock()->fill($this->sandboxMerchant);
- $this->signifydLogin->getLoginBlock()->sandboxLogin();
-
- $this->signifydCases->getCaseSearchBlock()->waitForElementVisible('#queueSearchBar');
-
- $this->signifydNotifications->open();
- $this->signifydNotifications->getWebhooksBlock()->cleanup();
- $this->signifydNotifications->getWebhookAddBlock()->createWebhooks();
- }
-}
diff --git a/Test/etc/testcase.xml b/Test/etc/testcase.xml
index 2f600a753ac5a..3379cfb128aaf 100644
--- a/Test/etc/testcase.xml
+++ b/Test/etc/testcase.xml
@@ -6,11 +6,11 @@
*/
-->
-
-
-
-
-
+
+
+
+
+
From 8c6591da136abf10e20670898dfd2e75b1917e5e Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Thu, 23 Feb 2017 19:10:33 +0200
Subject: [PATCH 0276/2045] MAGETWO-63855: Create functional automated for
complete Signifyd flow
- code review fixes
---
Test/Block/Sandbox/CaseInfo.php | 2 +-
Test/Constraint/AssertCaseInfoOnBackend.php | 10 +--
.../AssertSignifydCaseInOrdersGrid.php | 12 +--
Test/Page/Adminhtml/OrdersGrid.xml | 12 +++
.../{OrderView.xml => SalesOrderView.xml} | 3 +-
Test/TestStep/OpenOrderGridStep.php | 76 ++++++++++---------
6 files changed, 65 insertions(+), 50 deletions(-)
create mode 100644 Test/Page/Adminhtml/OrdersGrid.xml
rename Test/Page/Adminhtml/{OrderView.xml => SalesOrderView.xml} (66%)
diff --git a/Test/Block/Sandbox/CaseInfo.php b/Test/Block/Sandbox/CaseInfo.php
index 8389daccef627..60eedb64a81a1 100644
--- a/Test/Block/Sandbox/CaseInfo.php
+++ b/Test/Block/Sandbox/CaseInfo.php
@@ -73,7 +73,7 @@ class CaseInfo extends Block
*
* @var string
*/
- private $cardHolder = '[data-dropdown="peopleLinks0"] span';
+ private $cardHolder = '[data-dropdown="peopleLinks0"]';
/**
* Css selector of displayed billing address.
diff --git a/Test/Constraint/AssertCaseInfoOnBackend.php b/Test/Constraint/AssertCaseInfoOnBackend.php
index b3f5060ba648d..303a32a9cf0ff 100644
--- a/Test/Constraint/AssertCaseInfoOnBackend.php
+++ b/Test/Constraint/AssertCaseInfoOnBackend.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Signifyd\Test\Constraint;
-use Magento\Signifyd\Test\Page\Adminhtml\OrderView;
+use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
use Magento\Mtf\Constraint\AbstractConstraint;
/**
@@ -16,7 +16,7 @@ class AssertCaseInfoOnBackend extends AbstractConstraint
/**
* Customized order view page.
*
- * @var OrderView
+ * @var SalesOrderView
*/
private $orderView;
@@ -37,15 +37,15 @@ class AssertCaseInfoOnBackend extends AbstractConstraint
/**
* Assert that Signifyd Case information is correct on backend.
*
- * @param OrderView $orderView
+ * @param SalesOrderView $orderView
* @param string $orderId
* @param array $signifydData
* @return void
*/
public function processAssert(
- OrderView $orderView,
+ SalesOrderView $orderView,
$orderId,
- $signifydData
+ array $signifydData
) {
$this->orderView = $orderView;
$this->orderView->open(['order_id' => $orderId]);
diff --git a/Test/Constraint/AssertSignifydCaseInOrdersGrid.php b/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
index 9907639f7352a..6e4a0f1a4ff85 100644
--- a/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
+++ b/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Test\Constraint;
-use Magento\Signifyd\Test\Page\Adminhtml\OrderView;
+use Magento\Signifyd\Test\Page\Adminhtml\OrdersGrid;
use Magento\Mtf\Constraint\AbstractConstraint;
/**
@@ -19,14 +19,14 @@ class AssertSignifydCaseInOrdersGrid extends AbstractConstraint
*
* @param string $orderId
* @param string $status
- * @param OrderView $orderView
+ * @param OrdersGrid $ordersGrid
* @param array $signifydData
* @return void
*/
public function processAssert(
$orderId,
$status,
- OrderView $orderView,
+ OrdersGrid $ordersGrid,
array $signifydData
) {
$filter = [
@@ -37,11 +37,11 @@ public function processAssert(
$errorMessage = implode(', ', $filter);
- $orderView->open();
+ $ordersGrid->open();
\PHPUnit_Framework_Assert::assertTrue(
- $orderView->getSalesOrderGrid()->isRowVisible(array_filter($filter)),
- 'Order with following data \'' . $errorMessage . '\' is absent in Orders grid.'
+ $ordersGrid->getSignifydOrdersGrid()->isRowVisible(array_filter($filter)),
+ 'Order with following data \'' . $errorMessage . '\' is absent in orders grid.'
);
}
diff --git a/Test/Page/Adminhtml/OrdersGrid.xml b/Test/Page/Adminhtml/OrdersGrid.xml
new file mode 100644
index 0000000000000..1e80d74660cc7
--- /dev/null
+++ b/Test/Page/Adminhtml/OrdersGrid.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/Test/Page/Adminhtml/OrderView.xml b/Test/Page/Adminhtml/SalesOrderView.xml
similarity index 66%
rename from Test/Page/Adminhtml/OrderView.xml
rename to Test/Page/Adminhtml/SalesOrderView.xml
index 4caf31d460026..e869f9892e7c9 100644
--- a/Test/Page/Adminhtml/OrderView.xml
+++ b/Test/Page/Adminhtml/SalesOrderView.xml
@@ -6,8 +6,7 @@
*/
-->
-
+
-
diff --git a/Test/TestStep/OpenOrderGridStep.php b/Test/TestStep/OpenOrderGridStep.php
index 4d471915fa48e..11f904d2802d5 100644
--- a/Test/TestStep/OpenOrderGridStep.php
+++ b/Test/TestStep/OpenOrderGridStep.php
@@ -5,19 +5,18 @@
*/
namespace Magento\Signifyd\Test\TestStep;
-use Magento\Sales\Test\Fixture\OrderInjectable;
-use Magento\Sales\Test\TestStep\OpenOrderStep;
+use Magento\Mtf\TestStep\TestStepInterface;
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
use Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect as AssertOrderStatus;
use Magento\Signifyd\Test\Constraint\AssertSignifydCaseInOrdersGrid as AssertOrdersGrid;
use Magento\Signifyd\Test\Constraint\AssertCaseInfoOnBackend;
-use Magento\Signifyd\Test\Page\Adminhtml\OrderView;
+use Magento\Signifyd\Test\Page\Adminhtml\OrdersGrid;
/**
* Open order grid step.
*/
-class OpenOrderGridStep extends OpenOrderStep
+class OpenOrderGridStep implements TestStepInterface
{
/**
* Magento order status assertion.
@@ -47,6 +46,14 @@ class OpenOrderGridStep extends OpenOrderStep
*/
private $orderStatus;
+ /**
+ * Magento order id.
+ *
+ * @var int
+ */
+ private $orderId;
+
+
/**
* Order View Page.
*
@@ -55,11 +62,11 @@ class OpenOrderGridStep extends OpenOrderStep
private $salesOrderView;
/**
- * Customized order view page.
+ * Orders grid page.
*
- * @var OrderView
+ * @var OrdersGrid
*/
- private $orderView;
+ private $ordersGrid;
/**
* Array of Signifyd config data.
@@ -70,10 +77,10 @@ class OpenOrderGridStep extends OpenOrderStep
/**
* @param string $status
- * @param OrderInjectable $order
+ * @param int $orderId
* @param OrderIndex $orderIndex
* @param SalesOrderView $salesOrderView
- * @param OrderView $orderView
+ * @param OrdersGrid $ordersGrid
* @param AssertOrderStatus $assertOrderStatus
* @param AssertCaseInfoOnBackend $assertCaseInfo
* @param AssertOrdersGrid $assertOrdersGrid
@@ -81,24 +88,23 @@ class OpenOrderGridStep extends OpenOrderStep
*/
public function __construct(
$status,
- OrderInjectable $order,
+ $orderId,
OrderIndex $orderIndex,
SalesOrderView $salesOrderView,
- OrderView $orderView,
+ OrdersGrid $ordersGrid,
AssertOrderStatus $assertOrderStatus,
AssertCaseInfoOnBackend $assertCaseInfo,
AssertOrdersGrid $assertOrdersGrid,
array $signifydData
) {
$this->orderStatus = $status;
+ $this->orderId = $orderId;
+ $this->orderIndex = $orderIndex;
+ $this->salesOrderView = $salesOrderView;
+ $this->ordersGrid = $ordersGrid;
$this->assertOrderStatus = $assertOrderStatus;
$this->assertCaseInfo = $assertCaseInfo;
$this->assertOrdersGrid = $assertOrdersGrid;
- $this->salesOrderView = $salesOrderView;
- $this->orderView = $orderView;
- $this->orderIndex = $orderIndex;
-
- parent::__construct($order, $this->orderIndex);
$this->signifydData = $signifydData;
}
@@ -109,53 +115,51 @@ public function __construct(
*/
public function run()
{
- parent::run();
-
$this->checkOrdersGrid();
$this->checkOrderStatus();
$this->checkCaseInfo();
}
/**
- * Run assert to check order status is valid.
+ * Run assert to check Signifyd Case Disposition status in orders grid.
*
* @return void
*/
- private function checkOrderStatus()
+ private function checkOrdersGrid()
{
- $this->assertOrderStatus->processAssert(
+ $this->assertOrdersGrid->processAssert(
+ $this->orderId,
$this->orderStatus,
- $this->order->getId(),
- $this->orderIndex,
- $this->salesOrderView
+ $this->ordersGrid,
+ $this->signifydData
);
}
/**
- * Run assert to check Signifyd Case information is correct on backend.
+ * Run assert to check order status is valid.
*
* @return void
*/
- private function checkCaseInfo()
+ private function checkOrderStatus()
{
- $this->assertCaseInfo->processAssert(
- $this->orderView,
- $this->order->getId(),
- $this->signifydData
+ $this->assertOrderStatus->processAssert(
+ $this->orderStatus,
+ $this->orderId,
+ $this->orderIndex,
+ $this->salesOrderView
);
}
/**
- * Run assert to check Signifyd Case Disposition status in orders grid.
+ * Run assert to check Signifyd Case information is correct on backend.
*
* @return void
*/
- private function checkOrdersGrid()
+ private function checkCaseInfo()
{
- $this->assertOrdersGrid->processAssert(
- $this->order->getId(),
- $this->orderStatus,
- $this->orderView,
+ $this->assertCaseInfo->processAssert(
+ $this->salesOrderView,
+ $this->orderId,
$this->signifydData
);
}
From 04f56f4204f7369a791bfd1108f519594c02c19f Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 24 Feb 2017 15:03:32 +0200
Subject: [PATCH 0277/2045] MAGETWO-63855: Create functional automated for
complete Signifyd flow
---
Test/Block/Sandbox/CaseSearch.php | 8 +-
Test/Block/Sandbox/WebhookAdd.php | 2 +-
Test/Constraint/AssertCaseInfoOnBackend.php | 10 +-
.../AssertCaseInfoOnSignifydConsole.php | 30 ++---
.../AssertSignifydCaseInCommentsHistory.php | 10 +-
.../AssertSignifydCaseInOrdersGrid.php | 7 +-
...gnifydGuaranteeCancelInCommentsHistory.php | 7 +-
Test/Fixture/SignifydAddress.xml | 15 +++
Test/Fixture/SignifydAddress/Firstname.php | 50 +++++++
Test/Repository/Address.xml | 2 +-
Test/Repository/Customer.xml | 6 -
...ateSignifydGuaranteeAndCancelOrderTest.php | 38 +++---
...ateSignifydGuaranteeAndCancelOrderTest.xml | 15 ++-
Test/TestStep/OpenOrderGridStep.php | 7 +
.../SignifydFillShippingAddressStep.php | 70 ++++++++++
Test/TestStep/SignifydLoginStep.php | 4 +-
Test/TestStep/SignifydObserveCaseStep.php | 123 ++++++++++++------
.../SignifydSetWebhookHandlersStep.php | 4 +-
Test/etc/di.xml | 34 +++++
Test/etc/testcase.xml | 4 +-
20 files changed, 319 insertions(+), 127 deletions(-)
create mode 100644 Test/Fixture/SignifydAddress.xml
create mode 100644 Test/Fixture/SignifydAddress/Firstname.php
create mode 100644 Test/TestStep/SignifydFillShippingAddressStep.php
create mode 100644 Test/etc/di.xml
diff --git a/Test/Block/Sandbox/CaseSearch.php b/Test/Block/Sandbox/CaseSearch.php
index d00b0ac5f2e0b..a45c95e81dbac 100644
--- a/Test/Block/Sandbox/CaseSearch.php
+++ b/Test/Block/Sandbox/CaseSearch.php
@@ -6,7 +6,6 @@
namespace Magento\Signifyd\Test\Block\Sandbox;
use Magento\Mtf\Block\Form;
-use Magento\Mtf\Client\Locator;
/**
* Side block with case search and cases list.
@@ -28,11 +27,11 @@ class CaseSearch extends Form
private $submitButton = '[type=submit]';
/**
- * XPath selector of first searched element in list.
+ * Css selector of searched element in cases list.
*
* @var string
*/
- private $selectCaseLink = '//ul//li[contains(@class, "app-sidebar-item")][1]//a';
+ private $selectCaseLink = 'ul[case-list=cases] li[case-list-case=case] a';
/**
* Fill search input with customer name and submit.
@@ -53,10 +52,9 @@ public function searchCaseByCustomerName($customerName)
*/
public function selectCase()
{
- $this->_rootElement->find($this->selectCaseLink, Locator::SELECTOR_XPATH)->click();
+ $this->_rootElement->find($this->selectCaseLink)->click();
}
-
/**
* Waiting of case page loading.
*
diff --git a/Test/Block/Sandbox/WebhookAdd.php b/Test/Block/Sandbox/WebhookAdd.php
index 183868270746c..c8fc7486ddabf 100644
--- a/Test/Block/Sandbox/WebhookAdd.php
+++ b/Test/Block/Sandbox/WebhookAdd.php
@@ -67,7 +67,7 @@ class WebhookAdd extends Form
* @param array $signifydData
* @return void
*/
- public function createWebhooks($signifydData)
+ public function createWebhooks(array $signifydData)
{
foreach ($this->webhookEventOptionsMap as $webhookEventCode => $webhookEventName) {
$this->setEvent($webhookEventCode);
diff --git a/Test/Constraint/AssertCaseInfoOnBackend.php b/Test/Constraint/AssertCaseInfoOnBackend.php
index 303a32a9cf0ff..731de76e6e494 100644
--- a/Test/Constraint/AssertCaseInfoOnBackend.php
+++ b/Test/Constraint/AssertCaseInfoOnBackend.php
@@ -58,7 +58,7 @@ public function processAssert(
}
/**
- * Checks that case status matches.
+ * Checks case status is correct.
*
* @return void
*/
@@ -72,7 +72,7 @@ private function checkCaseStatus()
}
/**
- * Checks that case guarantee disposition matches.
+ * Checks case guarantee disposition is correct.
*
* @return void
*/
@@ -86,7 +86,7 @@ private function checkCaseGuaranteeDisposition()
}
/**
- * Checks that case review disposition matches.
+ * Checks case review disposition is correct.
*
* @return void
*/
@@ -100,9 +100,7 @@ private function checkCaseReviewDisposition()
}
/**
- * Returns a string representation of the object.
- *
- * @return string
+ * @inheritdoc
*/
public function toString()
{
diff --git a/Test/Constraint/AssertCaseInfoOnSignifydConsole.php b/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
index f63c4075f5457..7d1829d16637e 100644
--- a/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
+++ b/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
@@ -5,8 +5,8 @@
*/
namespace Magento\Signifyd\Test\Constraint;
-use Magento\Customer\Test\Fixture\Address;
use Magento\Mtf\Constraint\AbstractConstraint;
+use Magento\Signifyd\Test\Fixture\SignifydAddress;
use Magento\Signifyd\Test\Page\Sandbox\SignifydCases;
/**
@@ -23,7 +23,7 @@ class AssertCaseInfoOnSignifydConsole extends AbstractConstraint
/**
* @param SignifydCases $signifydCases
- * @param Address $billingAddress
+ * @param SignifydAddress $billingAddress
* @param array $prices
* @param string $orderId
* @param string $customerFullName
@@ -32,11 +32,11 @@ class AssertCaseInfoOnSignifydConsole extends AbstractConstraint
*/
public function processAssert(
SignifydCases $signifydCases,
- Address $billingAddress,
+ SignifydAddress $billingAddress,
array $prices,
$orderId,
$customerFullName,
- $signifydData
+ array $signifydData
) {
$this->signifydCases = $signifydCases;
@@ -50,7 +50,7 @@ public function processAssert(
}
/**
- * Checks that guarantee disposition matches.
+ * Checks guarantee disposition is correct.
*
* @param string $guaranteeDisposition
* @return void
@@ -65,7 +65,7 @@ private function checkGuaranteeDisposition($guaranteeDisposition)
}
/**
- * Checks that CVV response matches.
+ * Checks CVV response is correct.
*
* @param string $cvvResponse
* @return void
@@ -80,7 +80,7 @@ private function checkCvvResponse($cvvResponse)
}
/**
- * Checks that AVS response matches.
+ * Checks AVS response is correct.
*
* @param string $avsResponse
* @return void
@@ -95,7 +95,7 @@ private function checkAvsResponse($avsResponse)
}
/**
- * Checks that order id matches.
+ * Checks order id is correct.
*
* @param string $orderId
* @return void
@@ -110,7 +110,7 @@ private function checkOrderId($orderId)
}
/**
- * Checks that order amount matches.
+ * Checks order amount is correct.
*
* @param string $amount
* @return void
@@ -125,7 +125,7 @@ private function checkOrderAmount($amount)
}
/**
- * Checks that card holder matches.
+ * Checks card holder is correct.
*
* @param string $customerFullName
* @return void
@@ -140,12 +140,12 @@ private function checkCardHolder($customerFullName)
}
/**
- * Checks that billing address matches.
+ * Checks billing address is correct.
*
- * @param Address $billingAddress
+ * @param SignifydAddress $billingAddress
* @return void
*/
- private function checkBillingAddress(Address $billingAddress)
+ private function checkBillingAddress(SignifydAddress $billingAddress)
{
\PHPUnit_Framework_Assert::assertContains(
$billingAddress->getStreet(),
@@ -155,9 +155,7 @@ private function checkBillingAddress(Address $billingAddress)
}
/**
- * Returns a string representation of the object.
- *
- * @return string
+ * @inheritdoc
*/
public function toString()
{
diff --git a/Test/Constraint/AssertSignifydCaseInCommentsHistory.php b/Test/Constraint/AssertSignifydCaseInCommentsHistory.php
index 49cb77efa98da..17ab29063da20 100644
--- a/Test/Constraint/AssertSignifydCaseInCommentsHistory.php
+++ b/Test/Constraint/AssertSignifydCaseInCommentsHistory.php
@@ -3,7 +3,6 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
namespace Magento\Signifyd\Test\Constraint;
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
@@ -11,7 +10,8 @@
use Magento\Mtf\Constraint\AbstractConstraint;
/**
- * Assert that comment about created Signifyd Case exists in Comments History section on order page in Admin.
+ * Assert that comment about created Signifyd Case
+ * exists in Comments History section on order page in Admin.
*/
class AssertSignifydCaseInCommentsHistory extends AbstractConstraint
{
@@ -21,8 +21,6 @@ class AssertSignifydCaseInCommentsHistory extends AbstractConstraint
const CASE_CREATED_PATTERN = '/Signifyd Case (\d)+ has been created for order\./';
/**
- * Assert that comment about Signifyd Case exists in Comments History section on order page in Admin.
- *
* @param SalesOrderView $salesOrderView
* @param OrderIndex $salesOrder
* @param string $orderId
@@ -49,9 +47,7 @@ public function processAssert(
}
/**
- * Returns string representation of successful assertion.
- *
- * @return string
+ * @inheritdoc
*/
public function toString()
{
diff --git a/Test/Constraint/AssertSignifydCaseInOrdersGrid.php b/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
index 6e4a0f1a4ff85..6157fa937d3c8 100644
--- a/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
+++ b/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
@@ -3,7 +3,6 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
namespace Magento\Signifyd\Test\Constraint;
use Magento\Signifyd\Test\Page\Adminhtml\OrdersGrid;
@@ -15,8 +14,6 @@
class AssertSignifydCaseInOrdersGrid extends AbstractConstraint
{
/**
- * Assert that order with fixture data is present in Sales -> Orders Grid.
- *
* @param string $orderId
* @param string $status
* @param OrdersGrid $ordersGrid
@@ -46,9 +43,7 @@ public function processAssert(
}
/**
- * Returns a string representation of the object.
- *
- * @return string
+ * @inheritdoc
*/
public function toString()
{
diff --git a/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php b/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
index c47b8f1ab6a33..633096b0e976b 100644
--- a/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
+++ b/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
@@ -10,7 +10,8 @@
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
/**
- * Class AssertSignifydGuaranteeCancelInCommentsHistory
+ * Assert that comment about created Signifyd Case guarantee
+ * has been cancelled exists in Comments History section on order page in Admin.
*/
class AssertSignifydGuaranteeCancelInCommentsHistory extends AbstractConstraint
{
@@ -47,9 +48,7 @@ public function processAssert(
}
/**
- * Returns a string representation of the object.
- *
- * @return string
+ * @inheritdoc
*/
public function toString()
{
diff --git a/Test/Fixture/SignifydAddress.xml b/Test/Fixture/SignifydAddress.xml
new file mode 100644
index 0000000000000..ccdcfea112836
--- /dev/null
+++ b/Test/Fixture/SignifydAddress.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
diff --git a/Test/Fixture/SignifydAddress/Firstname.php b/Test/Fixture/SignifydAddress/Firstname.php
new file mode 100644
index 0000000000000..d688a3aea5dda
--- /dev/null
+++ b/Test/Fixture/SignifydAddress/Firstname.php
@@ -0,0 +1,50 @@
+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/Test/Repository/Address.xml b/Test/Repository/Address.xml
index 7863c3eec664a..afcc364192f64 100644
--- a/Test/Repository/Address.xml
+++ b/Test/Repository/Address.xml
@@ -8,7 +8,7 @@
- John
+ John%signifyd_isolation%
Doe
Magento
Culver City
diff --git a/Test/Repository/Customer.xml b/Test/Repository/Customer.xml
index 0f2f15f29456b..ca6609b4dee02 100644
--- a/Test/Repository/Customer.xml
+++ b/Test/Repository/Customer.xml
@@ -10,15 +10,9 @@
John
Doe
-
- - General
-
testapprove@magento.com
123123^q
123123^q
-
- - default
-
diff --git a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
index d616b4afbb395..0a4643c2437ec 100644
--- a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
+++ b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
@@ -19,25 +19,25 @@
* 1. Log in to Signifyd account.
* 2. Remove all existing webhooks by test team.
* 3. Add new webhook set.
- * 1. Log in Storefront.
- * 2. Add products to the Shopping Cart.
- * 3. Click the 'Proceed to Checkout' button.
- * 4. Fill shipping information.
- * 5. Select shipping method.
- * 6. Select payment method.
- * 7. Specify credit card data.
- * 8. Click 'Place order' button.
- * 9. Search for created case.
- * 10. Open created case.
- * 11. Click "Flag case as good" button.
- * 12. Perform case info assertions.
- * 13. Log in to Admin.
- * 14. Proceed to order grid.
- * 15. Perform Signifyd guarantee status assertions.
- * 16. Proceed to order view.
- * 17. Perform order status and case info assertions.
- * 18. Click Cancel button.
- * 19. Perform remaining assertions.
+ * 4. Log in Storefront.
+ * 5. Add products to the Shopping Cart.
+ * 6. Click the 'Proceed to Checkout' button.
+ * 7. Fill shipping information.
+ * 8. Select shipping method.
+ * 9. Select payment method.
+ * 10. Specify credit card data.
+ * 11. Click 'Place order' button.
+ * 12. Search for created case.
+ * 13. Open created case.
+ * 14. Click "Flag case as good" button.
+ * 15. Perform case info assertions.
+ * 16. Log in to Admin.
+ * 17. Proceed to order grid.
+ * 18. Perform Signifyd guarantee status assertions.
+ * 19. Proceed to order view.
+ * 20. Perform order status and case info assertions.
+ * 21. Click Cancel button.
+ * 22. Perform remaining assertions.
*
* @group Signifyd
* @ZephyrId MAGETWO-62120, MAGETWO-63221
diff --git a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
index 4ddce892e4826..a2258689173e4 100644
--- a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
+++ b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
@@ -6,13 +6,16 @@
*/
-->
-
-
+
+
catalogProductSimple::product_10_dollar
login
signifyd_approve_us_customer
- signifyd_approve_us_shipping_address
signifyd_approve_us_shipping_address
+ signifyd_approve_us_shipping_address
Flat Rate
Fixed
braintree
@@ -22,7 +25,7 @@
braintree,signifyd
sandbox_default
Processing
- Magento
+ autotest
Open
Good
Approved
@@ -30,11 +33,11 @@
Full match (Y)
test_type:3rd_party_test, severity:S1
-
-
+
+
diff --git a/Test/TestStep/OpenOrderGridStep.php b/Test/TestStep/OpenOrderGridStep.php
index 11f904d2802d5..3e756f0246347 100644
--- a/Test/TestStep/OpenOrderGridStep.php
+++ b/Test/TestStep/OpenOrderGridStep.php
@@ -75,6 +75,13 @@ class OpenOrderGridStep implements TestStepInterface
*/
private $signifydData;
+ /**
+ * Orders Page.
+ *
+ * @var OrderIndex
+ */
+ private $orderIndex;
+
/**
* @param string $status
* @param int $orderId
diff --git a/Test/TestStep/SignifydFillShippingAddressStep.php b/Test/TestStep/SignifydFillShippingAddressStep.php
new file mode 100644
index 0000000000000..b583bbcce1d62
--- /dev/null
+++ b/Test/TestStep/SignifydFillShippingAddressStep.php
@@ -0,0 +1,70 @@
+signifydAddress = $signifydAddress;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function run()
+ {
+ parent::run();
+
+ return [
+ 'signifydAddress' => $this->signifydAddress,
+ ];
+ }
+}
diff --git a/Test/TestStep/SignifydLoginStep.php b/Test/TestStep/SignifydLoginStep.php
index dc758e5ba5bea..5b74cc93f5c4a 100644
--- a/Test/TestStep/SignifydLoginStep.php
+++ b/Test/TestStep/SignifydLoginStep.php
@@ -52,9 +52,7 @@ public function __construct(
}
/**
- * Run step flow
- *
- * @return void
+ * @inheritdoc
*/
public function run()
{
diff --git a/Test/TestStep/SignifydObserveCaseStep.php b/Test/TestStep/SignifydObserveCaseStep.php
index 86e4cb64f918d..26689dffb928c 100644
--- a/Test/TestStep/SignifydObserveCaseStep.php
+++ b/Test/TestStep/SignifydObserveCaseStep.php
@@ -5,10 +5,12 @@
*/
namespace Magento\Signifyd\Test\TestStep;
-use Magento\Customer\Test\Fixture\Address;
-use Magento\Customer\Test\Fixture\Customer;
use Magento\Mtf\TestStep\TestStepInterface;
+use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
+use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
+use Magento\Sales\Test\TestStep\CancelOrderStep;
use Magento\Signifyd\Test\Constraint\AssertCaseInfoOnSignifydConsole;
+use Magento\Signifyd\Test\Fixture\SignifydAddress;
use Magento\Signifyd\Test\Page\Sandbox\SignifydCases;
/**
@@ -17,39 +19,53 @@
class SignifydObserveCaseStep implements TestStepInterface
{
/**
- * Signifyd cases page.
+ * Case information on Signifyd console assertion.
*
- * @var SignifydCases
+ * @var AssertCaseInfoOnSignifydConsole
*/
- private $signifydCases;
+ private $assertCaseInfo;
/**
- * Customer fixture.
+ * Cancel order on backend step.
*
- * @var Customer
+ * @var CancelOrderStep
*/
- private $customer;
+ private $cancelOrderStep;
/**
- * Billing address fixture.
+ * Orders View Page.
*
- * @var Address
+ * @var SalesOrderView
*/
- private $billingAddress;
+ private $salesOrderView;
/**
- * Prices list.
+ * Orders Page.
*
- * @var array
+ * @var OrderIndex
*/
- private $prices;
+ private $orderIndex;
/**
- * Order id.
+ * Signifyd cases page.
*
- * @var string
+ * @var SignifydCases
*/
- private $orderId;
+ private $signifydCases;
+
+ /**
+ * Billing address fixture.
+ *
+ * @var SignifydAddress
+ */
+ private $signifydAddress;
+
+ /**
+ * Prices list.
+ *
+ * @var array
+ */
+ private $prices;
/**
* Array of Signifyd config data.
@@ -59,58 +75,62 @@ class SignifydObserveCaseStep implements TestStepInterface
private $signifydData;
/**
- * Case information on Signifyd console assertion.
+ * Order id.
*
- * @var AssertCaseInfoOnSignifydConsole
+ * @var string
*/
- private $assertCaseInfoOnSignifydConsole;
+ private $orderId;
/**
+ * @param AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole
+ * @param CancelOrderStep $cancelOrderStep
+ * @param OrderIndex $orderIndex
+ * @param SalesOrderView $salesOrderView
* @param SignifydCases $signifydCases
- * @param Customer $customer
- * @param Address $billingAddress
+ * @param SignifydAddress $signifydAddress
* @param array $prices
- * @param string $orderId
* @param array $signifydData
- * @param AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole
+ * @param string $orderId
*/
public function __construct(
+ AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole,
+ CancelOrderStep $cancelOrderStep,
+ OrderIndex $orderIndex,
+ SalesOrderView $salesOrderView,
SignifydCases $signifydCases,
- Customer $customer,
- Address $billingAddress,
+ SignifydAddress $signifydAddress,
array $prices,
- $orderId,
array $signifydData,
- AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole
+ $orderId
) {
+ $this->assertCaseInfo = $assertCaseInfoOnSignifydConsole;
+ $this->cancelOrderStep = $cancelOrderStep;
+ $this->orderIndex = $orderIndex;
+ $this->salesOrderView = $salesOrderView;
$this->signifydCases = $signifydCases;
- $this->customer = $customer;
- $this->billingAddress = $billingAddress;
+ $this->signifydAddress = $signifydAddress;
$this->prices = $prices;
- $this->orderId = $orderId;
- $this->assertCaseInfoOnSignifydConsole = $assertCaseInfoOnSignifydConsole;
$this->signifydData = $signifydData;
+ $this->orderId = $orderId;
}
/**
- * Run step flow
- *
- * @return void
+ * @inheritdoc
*/
public function run()
{
$this->signifydCases->open();
$this->signifydCases->getCaseSearchBlock()
- ->searchCaseByCustomerName($this->getCustomerFullName($this->customer));
+ ->searchCaseByCustomerName($this->signifydAddress->getFirstname());
$this->signifydCases->getCaseSearchBlock()->selectCase();
$this->signifydCases->getCaseInfoBlock()->flagCaseAsGood();
- $this->assertCaseInfoOnSignifydConsole->processAssert(
+ $this->assertCaseInfo->processAssert(
$this->signifydCases,
- $this->billingAddress,
+ $this->signifydAddress,
$this->prices,
$this->orderId,
- $this->getCustomerFullName($this->customer),
+ $this->getCustomerFullName($this->signifydAddress),
$this->signifydData
);
}
@@ -118,11 +138,30 @@ public function run()
/**
* Gets customer full name.
*
- * @param Customer $customer
+ * @param SignifydAddress $billingAddress
* @return string
*/
- private function getCustomerFullName(Customer $customer)
+ private function getCustomerFullName(SignifydAddress $billingAddress)
+ {
+ return sprintf('%s %s', $billingAddress->getFirstname(), $billingAddress->getLastname());
+ }
+
+ /**
+ * Cancel order on backend.
+ *
+ * Signifyd needs this cleanup for guarantee decline. If we had have many cases
+ * with approved guarantees, and same order id, Signifyd will not create
+ * guarantee approve status for new cases.
+ *
+ * @return void
+ */
+ public function cleanup()
{
- return sprintf('%s %s', $customer->getFirstname(), $customer->getLastname());
+ $this->orderIndex->open();
+ $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->orderId]);
+
+ if ($this->salesOrderView->getOrderInfoBlock()->getOrderStatus() !== 'Canceled') {
+ $this->cancelOrderStep->run();
+ }
}
}
diff --git a/Test/TestStep/SignifydSetWebhookHandlersStep.php b/Test/TestStep/SignifydSetWebhookHandlersStep.php
index 1403a42465779..f93405b739efc 100644
--- a/Test/TestStep/SignifydSetWebhookHandlersStep.php
+++ b/Test/TestStep/SignifydSetWebhookHandlersStep.php
@@ -40,9 +40,7 @@ public function __construct(
}
/**
- * Run step flow
- *
- * @return void
+ * @inheritdoc
*/
public function run()
{
diff --git a/Test/etc/di.xml b/Test/etc/di.xml
new file mode 100644
index 0000000000000..375a84d0dafb1
--- /dev/null
+++ b/Test/etc/di.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+ S1
+
+
+
+
+ S1
+
+
+
+
+ S1
+
+
+
+
+ S1
+
+
+
+
+ S2
+
+
+
diff --git a/Test/etc/testcase.xml b/Test/etc/testcase.xml
index 3379cfb128aaf..b12952efbac8b 100644
--- a/Test/etc/testcase.xml
+++ b/Test/etc/testcase.xml
@@ -14,8 +14,8 @@
-
-
+
+
From 26a2cc75310249634e0b22bf7dcc35592d19967e Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 1 Mar 2017 13:37:42 +0200
Subject: [PATCH 0278/2045] MAGETWO-63855: Create functional automated for
complete Signifyd flow
---
Test/Block/Adminhtml/Order/Grid.php | 2 +-
Test/Block/Sandbox/WebhookAdd.php | 146 ----------
Test/Block/Sandbox/WebhookGrid.php | 94 -------
.../{Sandbox => SignifydConsole}/CaseInfo.php | 30 ++-
.../CaseSearch.php | 2 +-
.../SignifydLogin.php | 2 +-
Test/Block/SignifydConsole/Webhooks.php | 249 ++++++++++++++++++
...nBackend.php => AssertCaseInfoOnAdmin.php} | 8 +-
.../AssertCaseInfoOnSignifydConsole.php | 2 +-
Test/Fixture/SignifydAddress/Firstname.php | 6 +-
Test/Page/Sandbox/SignifydNotifications.xml | 13 -
.../SignifydCases.xml | 6 +-
.../SignifydLogin.xml | 4 +-
.../SignifydConsole/SignifydNotifications.xml | 12 +
Test/Repository/Address.xml | 2 +-
Test/Repository/Customer.xml | 7 +
...ateSignifydGuaranteeAndCancelOrderTest.php | 98 ++++++-
...ateSignifydGuaranteeAndCancelOrderTest.xml | 38 ++-
Test/TestStep/OpenOrderGridStep.php | 13 +-
Test/TestStep/SignifydLoginStep.php | 11 +-
Test/TestStep/SignifydObserveCaseStep.php | 56 +---
.../SignifydSetWebhookHandlersStep.php | 6 +-
Test/etc/di.xml | 2 +-
23 files changed, 461 insertions(+), 348 deletions(-)
delete mode 100644 Test/Block/Sandbox/WebhookAdd.php
delete mode 100644 Test/Block/Sandbox/WebhookGrid.php
rename Test/Block/{Sandbox => SignifydConsole}/CaseInfo.php (83%)
rename Test/Block/{Sandbox => SignifydConsole}/CaseSearch.php (96%)
rename Test/Block/{Sandbox => SignifydConsole}/SignifydLogin.php (90%)
create mode 100644 Test/Block/SignifydConsole/Webhooks.php
rename Test/Constraint/{AssertCaseInfoOnBackend.php => AssertCaseInfoOnAdmin.php} (90%)
delete mode 100644 Test/Page/Sandbox/SignifydNotifications.xml
rename Test/Page/{Sandbox => SignifydConsole}/SignifydCases.xml (60%)
rename Test/Page/{Sandbox => SignifydConsole}/SignifydLogin.xml (65%)
create mode 100644 Test/Page/SignifydConsole/SignifydNotifications.xml
diff --git a/Test/Block/Adminhtml/Order/Grid.php b/Test/Block/Adminhtml/Order/Grid.php
index 03de97f0e3050..ba1c7a293cc46 100644
--- a/Test/Block/Adminhtml/Order/Grid.php
+++ b/Test/Block/Adminhtml/Order/Grid.php
@@ -8,7 +8,7 @@
use Magento\Ui\Test\Block\Adminhtml\DataGrid;
/**
- * Backend Data Grid for managing "Sales Order" entities.
+ * Admin Data Grid for managing "Sales Order" entities.
*/
class Grid extends DataGrid
{
diff --git a/Test/Block/Sandbox/WebhookAdd.php b/Test/Block/Sandbox/WebhookAdd.php
deleted file mode 100644
index c8fc7486ddabf..0000000000000
--- a/Test/Block/Sandbox/WebhookAdd.php
+++ /dev/null
@@ -1,146 +0,0 @@
- 'Case Creation',
- 'CASE_RESCORE' => 'Case Rescore',
- 'CASE_REVIEW' => 'Case Review',
- 'GUARANTEE_COMPLETION' => 'Guarantee Completion',
- 'CLAIM_REVIEWED' => 'Claim Review'
- ];
-
- /**
- * Creates new set of webhooks.
- *
- * @param array $signifydData
- * @return void
- */
- public function createWebhooks(array $signifydData)
- {
- foreach ($this->webhookEventOptionsMap as $webhookEventCode => $webhookEventName) {
- $this->setEvent($webhookEventCode);
- $this->setTeam($signifydData['team']);
- $this->setWebhookUrl();
-
- $this->addWebhook($webhookEventName);
- }
- }
-
- /**
- * Sets appropriate webhook event select option by code.
- *
- * @param $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.
- *
- * @return void
- */
- private function setWebhookUrl()
- {
- $this->_rootElement->find($this->webhookUrl)->setValue($this->getWebhookUrl());
- }
-
- /**
- * Add webhook element.
- *
- * Selenium needs to wait until webhook will be added to grid
- * before proceed to next step.
- *
- * @param string $webhookEventName
- * @return void
- */
- private function addWebhook($webhookEventName)
- {
- $this->_rootElement->find($this->webhookAddButton)->click();
-
- $this->_rootElement->waitUntil(
- function () use ($webhookEventName) {
- return $this->_rootElement->find(
- sprintf($this->webhookAddedElement, $this->getWebhookUrl(), $webhookEventName),
- Locator::SELECTOR_XPATH
- )->isVisible() ? true : null;
- }
- );
- }
-
- /**
- * Gets webhook handler url.
- *
- * @return string
- */
- private function getWebhookUrl()
- {
- return $_ENV['app_frontend_url'] . 'signifyd/webhooks/handler';
- }
-}
diff --git a/Test/Block/Sandbox/WebhookGrid.php b/Test/Block/Sandbox/WebhookGrid.php
deleted file mode 100644
index fcd9ca54253ee..0000000000000
--- a/Test/Block/Sandbox/WebhookGrid.php
+++ /dev/null
@@ -1,94 +0,0 @@
-getWebhook($team)) {
- if ($webhook->isPresent()) {
- $this->deleteWebhook($webhook);
- continue;
- }
- break;
- }
- }
-
- /**
- * Gets all existing webhook elements from grid.
- *
- * @param string $team
- * @return ElementInterface
- */
- private function getWebhook($team)
- {
- return $this->_rootElement->find(sprintf($this->webhooks, $team), Locator::SELECTOR_XPATH);
- }
-
- /**
- * Delete webhook element with confirmation popup.
- *
- * Signifyd creates the same popup every time Selenium click on delete button,
- * so we need to wait that previous popup will be closed.
- *
- * @param ElementInterface $webhookElement
- * @return void
- */
- private function deleteWebhook(ElementInterface $webhookElement)
- {
- $webhookElement->find($this->webhookDeleteButton)->click();
- $this->_rootElement->find($this->webhookDeleteConfirmButton)->click();
-
- $this->_rootElement->waitUntil(
- function () {
- return $this->_rootElement->find($this->webhookDeleteConfirmOverlay)
- ->isVisible() ? null : true;
- }
- );
- }
-}
diff --git a/Test/Block/Sandbox/CaseInfo.php b/Test/Block/SignifydConsole/CaseInfo.php
similarity index 83%
rename from Test/Block/Sandbox/CaseInfo.php
rename to Test/Block/SignifydConsole/CaseInfo.php
index 60eedb64a81a1..bc38b1f294032 100644
--- a/Test/Block/Sandbox/CaseInfo.php
+++ b/Test/Block/SignifydConsole/CaseInfo.php
@@ -3,7 +3,7 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Block\Sandbox;
+namespace Magento\Signifyd\Test\Block\SignifydConsole;
use Magento\Mtf\Block\Block;
@@ -19,6 +19,13 @@ class CaseInfo extends Block
*/
private $flagCaseAsGoodButton = '[class*="flag-case-good"]';
+ /**
+ * Css selector of "Flag Case As Bad" button.
+ *
+ * @var string
+ */
+ private $flagCaseAsBadButton = '[class*="flag-case-bad"]';
+
/**
* Css selector of guarantee status.
*
@@ -83,13 +90,28 @@ class CaseInfo extends Block
private $billingAddress = '[data-dropdown="streetLinks0"]';
/**
- * Flags case as good.
+ * 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 flagCaseAsGood()
+ public function flagCaseAsBad()
{
- $this->_rootElement->find($this->flagCaseAsGoodButton)->click();
+ $this->_rootElement->find($this->flagCaseAsBadButton)->click();
}
/**
diff --git a/Test/Block/Sandbox/CaseSearch.php b/Test/Block/SignifydConsole/CaseSearch.php
similarity index 96%
rename from Test/Block/Sandbox/CaseSearch.php
rename to Test/Block/SignifydConsole/CaseSearch.php
index a45c95e81dbac..e1bc5ad27591e 100644
--- a/Test/Block/Sandbox/CaseSearch.php
+++ b/Test/Block/SignifydConsole/CaseSearch.php
@@ -3,7 +3,7 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Block\Sandbox;
+namespace Magento\Signifyd\Test\Block\SignifydConsole;
use Magento\Mtf\Block\Form;
diff --git a/Test/Block/Sandbox/SignifydLogin.php b/Test/Block/SignifydConsole/SignifydLogin.php
similarity index 90%
rename from Test/Block/Sandbox/SignifydLogin.php
rename to Test/Block/SignifydConsole/SignifydLogin.php
index 070dc6ac3ea0e..b10e02bafcfff 100644
--- a/Test/Block/Sandbox/SignifydLogin.php
+++ b/Test/Block/SignifydConsole/SignifydLogin.php
@@ -3,7 +3,7 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Block\Sandbox;
+namespace Magento\Signifyd\Test\Block\SignifydConsole;
use Magento\Mtf\Block\Form;
diff --git a/Test/Block/SignifydConsole/Webhooks.php b/Test/Block/SignifydConsole/Webhooks.php
new file mode 100644
index 0000000000000..396e9063fb446
--- /dev/null
+++ b/Test/Block/SignifydConsole/Webhooks.php
@@ -0,0 +1,249 @@
+ '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 popup block for delete webhook confirmation.
+ *
+ * @var string
+ */
+ private $webhookDeleteConfirmOverlay = '[class="appriseOuter"]';
+
+ /**
+ * 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, $webhookEventName, $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.
+ *
+ * Signifyd creates the same popup every time Selenium click on delete button,
+ * so we need to wait that previous popup will be closed.
+ *
+ * @param ElementInterface $webhook
+ * @return void
+ */
+ private function deleteWebhook(ElementInterface $webhook)
+ {
+ $webhook->find($this->webhookDeleteButton)->click();
+ $this->_rootElement->find($this->webhookDeleteConfirmButton)->click();
+
+ $this->_rootElement->waitUntil(
+ function () {
+ return $this->_rootElement->find($this->webhookDeleteConfirmOverlay)
+ ->isPresent() ? null : true;
+ }
+ );
+ }
+
+ /**
+ * Sets webhook data and add it.
+ *
+ * @param string $handlerUrl
+ * @param string $webhookEventCode
+ * @param string $webhookEventName
+ * @param string $team
+ * @return void
+ */
+ private function addWebhook(
+ $handlerUrl,
+ $webhookEventCode,
+ $webhookEventName,
+ $team
+ ) {
+ $this->setEvent($webhookEventCode);
+ $this->setTeam($team);
+ $this->setUrl($handlerUrl);
+ $this->submit($webhookEventName, $handlerUrl);
+ }
+
+ /**
+ * 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.
+ *
+ * Selenium needs to wait until webhook will be added to grid
+ * before proceed to next step.
+ *
+ * @param string $webhookEventName
+ * @param string $handlerUrl
+ * @return void
+ */
+ private function submit($webhookEventName, $handlerUrl)
+ {
+ $this->_rootElement->find($this->webhookAddButton)->click();
+
+ $this->_rootElement->waitUntil(
+ function () use ($webhookEventName, $handlerUrl) {
+ return $this->_rootElement->find(
+ sprintf($this->webhookAddedElement, $handlerUrl, $webhookEventName),
+ Locator::SELECTOR_XPATH
+ )->isPresent() ? true : null;
+ }
+ );
+ }
+
+ /**
+ * Gets webhook handler url.
+ *
+ * @return string
+ */
+ private function getHandlerUrl()
+ {
+ return $_ENV['app_frontend_url'] . 'signifyd/webhooks/handler';
+ }
+}
diff --git a/Test/Constraint/AssertCaseInfoOnBackend.php b/Test/Constraint/AssertCaseInfoOnAdmin.php
similarity index 90%
rename from Test/Constraint/AssertCaseInfoOnBackend.php
rename to Test/Constraint/AssertCaseInfoOnAdmin.php
index 731de76e6e494..32d8a468e8918 100644
--- a/Test/Constraint/AssertCaseInfoOnBackend.php
+++ b/Test/Constraint/AssertCaseInfoOnAdmin.php
@@ -9,9 +9,9 @@
use Magento\Mtf\Constraint\AbstractConstraint;
/**
- * Assert that Order Case Entity is correct on order page in backend.
+ * Assert that Order Case Entity is correct on order page in Admin.
*/
-class AssertCaseInfoOnBackend extends AbstractConstraint
+class AssertCaseInfoOnAdmin extends AbstractConstraint
{
/**
* Customized order view page.
@@ -35,7 +35,7 @@ class AssertCaseInfoOnBackend extends AbstractConstraint
private $signifydData;
/**
- * Assert that Signifyd Case information is correct on backend.
+ * Assert that Signifyd Case information is correct in Admin.
*
* @param SalesOrderView $orderView
* @param string $orderId
@@ -104,6 +104,6 @@ private function checkCaseReviewDisposition()
*/
public function toString()
{
- return 'Signifyd Case information is correct on backend.';
+ return 'Signifyd Case information is correct in Admin.';
}
}
diff --git a/Test/Constraint/AssertCaseInfoOnSignifydConsole.php b/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
index 7d1829d16637e..97983621922ce 100644
--- a/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
+++ b/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
@@ -7,7 +7,7 @@
use Magento\Mtf\Constraint\AbstractConstraint;
use Magento\Signifyd\Test\Fixture\SignifydAddress;
-use Magento\Signifyd\Test\Page\Sandbox\SignifydCases;
+use Magento\Signifyd\Test\Page\SignifydConsole\SignifydCases;
/**
* Assert that order information is correct on Signifyd case info page.
diff --git a/Test/Fixture/SignifydAddress/Firstname.php b/Test/Fixture/SignifydAddress/Firstname.php
index d688a3aea5dda..2a38ba977f7c7 100644
--- a/Test/Fixture/SignifydAddress/Firstname.php
+++ b/Test/Fixture/SignifydAddress/Firstname.php
@@ -41,10 +41,6 @@ public function getData($key = null)
*/
private function generateIsolation($length = 10)
{
- return substr(
- str_shuffle(
- str_repeat("abcdefghijklmnopqrstuvwxyz", $length)),
- 0, $length
- );
+ return substr(str_shuffle(str_repeat("abcdefghijklmnopqrstuvwxyz", $length)), 0, $length);
}
}
diff --git a/Test/Page/Sandbox/SignifydNotifications.xml b/Test/Page/Sandbox/SignifydNotifications.xml
deleted file mode 100644
index b8e6e7503a1f4..0000000000000
--- a/Test/Page/Sandbox/SignifydNotifications.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/Test/Page/Sandbox/SignifydCases.xml b/Test/Page/SignifydConsole/SignifydCases.xml
similarity index 60%
rename from Test/Page/Sandbox/SignifydCases.xml
rename to Test/Page/SignifydConsole/SignifydCases.xml
index 94b771742b546..da483a0db4d49 100644
--- a/Test/Page/Sandbox/SignifydCases.xml
+++ b/Test/Page/SignifydConsole/SignifydCases.xml
@@ -6,8 +6,8 @@
*/
-->
-
-
-
+
+
+
diff --git a/Test/Page/Sandbox/SignifydLogin.xml b/Test/Page/SignifydConsole/SignifydLogin.xml
similarity index 65%
rename from Test/Page/Sandbox/SignifydLogin.xml
rename to Test/Page/SignifydConsole/SignifydLogin.xml
index bf44d195f4b49..00aa31b936556 100644
--- a/Test/Page/Sandbox/SignifydLogin.xml
+++ b/Test/Page/SignifydConsole/SignifydLogin.xml
@@ -6,7 +6,7 @@
*/
-->
-
-
+
+
diff --git a/Test/Page/SignifydConsole/SignifydNotifications.xml b/Test/Page/SignifydConsole/SignifydNotifications.xml
new file mode 100644
index 0000000000000..d12d2550724d5
--- /dev/null
+++ b/Test/Page/SignifydConsole/SignifydNotifications.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/Test/Repository/Address.xml b/Test/Repository/Address.xml
index afcc364192f64..99d15abb97031 100644
--- a/Test/Repository/Address.xml
+++ b/Test/Repository/Address.xml
@@ -7,7 +7,7 @@
-->
-
+
John%signifyd_isolation%
Doe
Magento
diff --git a/Test/Repository/Customer.xml b/Test/Repository/Customer.xml
index ca6609b4dee02..a21b01fc40bf0 100644
--- a/Test/Repository/Customer.xml
+++ b/Test/Repository/Customer.xml
@@ -14,5 +14,12 @@
123123^q
123123^q
+
+ John
+ Doe
+ testdecline@magento.com
+ 123123^q
+ 123123^q
+
diff --git a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
index 0a4643c2437ec..4baeeb638adb1 100644
--- a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
+++ b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
@@ -6,6 +6,11 @@
namespace Magento\Signifyd\Test\TestCase;
use Magento\Mtf\TestCase\Scenario;
+use Magento\Sales\Test\Fixture\OrderInjectable;
+use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
+use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
+use Magento\Sales\Test\TestStep\CancelOrderStep;
+use Magento\Signifyd\Test\Page\SignifydConsole\SignifydNotifications;
/**
* Preconditions:
@@ -50,13 +55,104 @@ class CreateSignifydGuaranteeAndCancelOrderTest extends Scenario
const SEVERITY = 'S1';
/* end tags */
+ /**
+ * Order page.
+ *
+ * @var OrderIndex
+ */
+ private $orderIndex;
+
+ /**
+ * Sales order view page.
+ *
+ * @var SalesOrderView
+ */
+ private $salesOrderView;
+
+ /**
+ * Cancel order test step.
+ *
+ * @var CancelOrderStep
+ */
+ private $cancelOrderStep;
+
+ /**
+ * Order fixture.
+ *
+ * @var OrderInjectable
+ */
+ private $orderInjectable;
+
+ /**
+ * Signifyd notifications page.
+ *
+ * @var SignifydNotifications
+ */
+ private $signifydNotifications;
+
+ /**
+ * Array of Signifyd config data.
+ *
+ * @var array
+ */
+ private $signifydData;
+
+ /**
+ * @param OrderIndex $orderIndex
+ * @param SalesOrderView $salesOrderView
+ * @param CancelOrderStep $cancelOrderStep
+ * @param OrderInjectable $orderInjectable
+ * @param SignifydNotifications $signifydNotifications
+ */
+ public function __inject(
+ OrderIndex $orderIndex,
+ SalesOrderView $salesOrderView,
+ CancelOrderStep $cancelOrderStep,
+ OrderInjectable $orderInjectable,
+ SignifydNotifications $signifydNotifications
+ ) {
+ $this->orderIndex = $orderIndex;
+ $this->salesOrderView = $salesOrderView;
+ $this->cancelOrderStep = $cancelOrderStep;
+ $this->orderInjectable = $orderInjectable;
+ $this->signifydNotifications = $signifydNotifications;
+ }
+
/**
* Runs one page checkout test.
*
+ * @param array $signifydData
* @return void
*/
- public function test()
+ public function test(array $signifydData)
{
+ $this->signifydData = $signifydData;
+
$this->executeScenario();
}
+
+ /**
+ * Tear down for scenario variations.
+ *
+ * Signifyd needs this cleanup for guarantee decline. If we had have many cases
+ * with approved guarantees, and same order id, Signifyd will not create
+ * guarantee approve status for new cases.
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ $this->orderIndex->open();
+ $this->orderIndex->getSalesOrderGrid()
+ ->searchAndOpen(['id' => $this->orderInjectable->getId()]);
+ if ($this->salesOrderView->getOrderInfoBlock()->getOrderStatus() !== 'Canceled') {
+ $this->cancelOrderStep->run();
+ }
+
+ if ($this->signifydData['cleanupWebhooks']) {
+ $this->signifydNotifications->open();
+ $this->signifydNotifications->getWebhooksBlock()
+ ->cleanup($this->signifydData['team']);
+ }
+ }
}
diff --git a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
index a2258689173e4..133864d797cf2 100644
--- a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
+++ b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
@@ -14,8 +14,7 @@
catalogProductSimple::product_10_dollar
login
signifyd_approve_us_customer
- signifyd_approve_us_shipping_address
- signifyd_approve_us_shipping_address
+ signifyd_us_shipping_address
Flat Rate
Fixed
braintree
@@ -27,10 +26,45 @@
Processing
autotest
Open
+ Good
Good
Approved
CVV2 Match (M)
Full match (Y)
+ false
+ test_type:3rd_party_test, severity:S1
+
+
+
+
+
+
+
+
+
+ catalogProductSimple::product_10_dollar
+ login
+ signifyd_decline_us_customer
+ signifyd_us_shipping_address
+ Flat Rate
+ Fixed
+ braintree
+ 15.00
+ visa_default
+ braintree
+ braintree,signifyd
+ sandbox_default
+ Processing
+ autotest
+ Open
+ Bad
+ Fraudulent
+ Declined
+ CVV2 Match (M)
+ Full match (Y)
+ true
test_type:3rd_party_test, severity:S1
diff --git a/Test/TestStep/OpenOrderGridStep.php b/Test/TestStep/OpenOrderGridStep.php
index 3e756f0246347..b249a954b40b4 100644
--- a/Test/TestStep/OpenOrderGridStep.php
+++ b/Test/TestStep/OpenOrderGridStep.php
@@ -10,7 +10,7 @@
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
use Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect as AssertOrderStatus;
use Magento\Signifyd\Test\Constraint\AssertSignifydCaseInOrdersGrid as AssertOrdersGrid;
-use Magento\Signifyd\Test\Constraint\AssertCaseInfoOnBackend;
+use Magento\Signifyd\Test\Constraint\AssertCaseInfoOnAdmin;
use Magento\Signifyd\Test\Page\Adminhtml\OrdersGrid;
/**
@@ -26,9 +26,9 @@ class OpenOrderGridStep implements TestStepInterface
private $assertOrderStatus;
/**
- * Case information on Magento backend assertion.
+ * Case information on Magento Admin assertion.
*
- * @var AssertCaseInfoOnBackend
+ * @var AssertCaseInfoOnAdmin
*/
private $assertCaseInfo;
@@ -53,7 +53,6 @@ class OpenOrderGridStep implements TestStepInterface
*/
private $orderId;
-
/**
* Order View Page.
*
@@ -89,7 +88,7 @@ class OpenOrderGridStep implements TestStepInterface
* @param SalesOrderView $salesOrderView
* @param OrdersGrid $ordersGrid
* @param AssertOrderStatus $assertOrderStatus
- * @param AssertCaseInfoOnBackend $assertCaseInfo
+ * @param AssertCaseInfoOnAdmin $assertCaseInfo
* @param AssertOrdersGrid $assertOrdersGrid
* @param array $signifydData
*/
@@ -100,7 +99,7 @@ public function __construct(
SalesOrderView $salesOrderView,
OrdersGrid $ordersGrid,
AssertOrderStatus $assertOrderStatus,
- AssertCaseInfoOnBackend $assertCaseInfo,
+ AssertCaseInfoOnAdmin $assertCaseInfo,
AssertOrdersGrid $assertOrdersGrid,
array $signifydData
) {
@@ -158,7 +157,7 @@ private function checkOrderStatus()
}
/**
- * Run assert to check Signifyd Case information is correct on backend.
+ * Run assert to check Signifyd Case information is correct in Admin.
*
* @return void
*/
diff --git a/Test/TestStep/SignifydLoginStep.php b/Test/TestStep/SignifydLoginStep.php
index 5b74cc93f5c4a..bacc098111f57 100644
--- a/Test/TestStep/SignifydLoginStep.php
+++ b/Test/TestStep/SignifydLoginStep.php
@@ -7,8 +7,8 @@
use Magento\Mtf\TestStep\TestStepInterface;
use Magento\Signifyd\Test\Fixture\SignifydAccount;
-use Magento\Signifyd\Test\Page\Sandbox\SignifydCases;
-use Magento\Signifyd\Test\Page\Sandbox\SignifydLogin;
+use Magento\Signifyd\Test\Page\SignifydConsole\SignifydCases;
+use Magento\Signifyd\Test\Page\SignifydConsole\SignifydLogin;
/**
* Login into Signifyd console step.
@@ -57,8 +57,11 @@ public function __construct(
public function run()
{
$this->signifydLogin->open();
- $this->signifydLogin->getLoginBlock()->fill($this->signifydAccount);
- $this->signifydLogin->getLoginBlock()->login();
+
+ if ($this->signifydLogin->getLoginBlock()->isVisible()) {
+ $this->signifydLogin->getLoginBlock()->fill($this->signifydAccount);
+ $this->signifydLogin->getLoginBlock()->login();
+ }
$this->signifydCases->getCaseSearchBlock()->waitForLoading();
}
diff --git a/Test/TestStep/SignifydObserveCaseStep.php b/Test/TestStep/SignifydObserveCaseStep.php
index 26689dffb928c..0ac91665eae96 100644
--- a/Test/TestStep/SignifydObserveCaseStep.php
+++ b/Test/TestStep/SignifydObserveCaseStep.php
@@ -6,12 +6,9 @@
namespace Magento\Signifyd\Test\TestStep;
use Magento\Mtf\TestStep\TestStepInterface;
-use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
-use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
-use Magento\Sales\Test\TestStep\CancelOrderStep;
use Magento\Signifyd\Test\Constraint\AssertCaseInfoOnSignifydConsole;
use Magento\Signifyd\Test\Fixture\SignifydAddress;
-use Magento\Signifyd\Test\Page\Sandbox\SignifydCases;
+use Magento\Signifyd\Test\Page\SignifydConsole\SignifydCases;
/**
* Observe case information in Signifyd console step.
@@ -25,27 +22,6 @@ class SignifydObserveCaseStep implements TestStepInterface
*/
private $assertCaseInfo;
- /**
- * Cancel order on backend step.
- *
- * @var CancelOrderStep
- */
- private $cancelOrderStep;
-
- /**
- * Orders View Page.
- *
- * @var SalesOrderView
- */
- private $salesOrderView;
-
- /**
- * Orders Page.
- *
- * @var OrderIndex
- */
- private $orderIndex;
-
/**
* Signifyd cases page.
*
@@ -83,9 +59,6 @@ class SignifydObserveCaseStep implements TestStepInterface
/**
* @param AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole
- * @param CancelOrderStep $cancelOrderStep
- * @param OrderIndex $orderIndex
- * @param SalesOrderView $salesOrderView
* @param SignifydCases $signifydCases
* @param SignifydAddress $signifydAddress
* @param array $prices
@@ -94,9 +67,6 @@ class SignifydObserveCaseStep implements TestStepInterface
*/
public function __construct(
AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole,
- CancelOrderStep $cancelOrderStep,
- OrderIndex $orderIndex,
- SalesOrderView $salesOrderView,
SignifydCases $signifydCases,
SignifydAddress $signifydAddress,
array $prices,
@@ -104,9 +74,6 @@ public function __construct(
$orderId
) {
$this->assertCaseInfo = $assertCaseInfoOnSignifydConsole;
- $this->cancelOrderStep = $cancelOrderStep;
- $this->orderIndex = $orderIndex;
- $this->salesOrderView = $salesOrderView;
$this->signifydCases = $signifydCases;
$this->signifydAddress = $signifydAddress;
$this->prices = $prices;
@@ -123,7 +90,7 @@ public function run()
$this->signifydCases->getCaseSearchBlock()
->searchCaseByCustomerName($this->signifydAddress->getFirstname());
$this->signifydCases->getCaseSearchBlock()->selectCase();
- $this->signifydCases->getCaseInfoBlock()->flagCaseAsGood();
+ $this->signifydCases->getCaseInfoBlock()->flagCase($this->signifydData['caseFlag']);
$this->assertCaseInfo->processAssert(
$this->signifydCases,
@@ -145,23 +112,4 @@ private function getCustomerFullName(SignifydAddress $billingAddress)
{
return sprintf('%s %s', $billingAddress->getFirstname(), $billingAddress->getLastname());
}
-
- /**
- * Cancel order on backend.
- *
- * Signifyd needs this cleanup for guarantee decline. If we had have many cases
- * with approved guarantees, and same order id, Signifyd will not create
- * guarantee approve status for new cases.
- *
- * @return void
- */
- public function cleanup()
- {
- $this->orderIndex->open();
- $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->orderId]);
-
- if ($this->salesOrderView->getOrderInfoBlock()->getOrderStatus() !== 'Canceled') {
- $this->cancelOrderStep->run();
- }
- }
}
diff --git a/Test/TestStep/SignifydSetWebhookHandlersStep.php b/Test/TestStep/SignifydSetWebhookHandlersStep.php
index f93405b739efc..651b4e1f9b8ca 100644
--- a/Test/TestStep/SignifydSetWebhookHandlersStep.php
+++ b/Test/TestStep/SignifydSetWebhookHandlersStep.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Test\TestStep;
use Magento\Mtf\TestStep\TestStepInterface;
-use Magento\Signifyd\Test\Page\Sandbox\SignifydNotifications;
+use Magento\Signifyd\Test\Page\SignifydConsole\SignifydNotifications;
/**
* Set webhook handlers in Signifyd console step.
@@ -45,7 +45,7 @@ public function __construct(
public function run()
{
$this->signifydNotifications->open();
- $this->signifydNotifications->getWebhookGridBlock()->cleanupByTeam($this->signifydData['team']);
- $this->signifydNotifications->getWebhookAddBlock()->createWebhooks($this->signifydData);
+ $this->signifydNotifications->getWebhooksBlock()
+ ->create($this->signifydData['team']);
}
}
diff --git a/Test/etc/di.xml b/Test/etc/di.xml
index 375a84d0dafb1..d87c17444ce7f 100644
--- a/Test/etc/di.xml
+++ b/Test/etc/di.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
S1
From 18a533c24a6d72a3d29155f9d8c80bf86d7f0a7e Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 1 Mar 2017 15:02:54 +0200
Subject: [PATCH 0279/2045] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Removed some guarantee cancel checks
---
Model/Guarantee/CancelGuaranteeAbility.php | 6 +--
.../Guarantee/CancelGuaranteeAbilityTest.php | 48 +------------------
2 files changed, 2 insertions(+), 52 deletions(-)
diff --git a/Model/Guarantee/CancelGuaranteeAbility.php b/Model/Guarantee/CancelGuaranteeAbility.php
index c5e0561735218..2908914ef3bf7 100644
--- a/Model/Guarantee/CancelGuaranteeAbility.php
+++ b/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/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php b/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
index 00b6910a71a70..280f54e7aa5d3 100644
--- a/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
+++ b/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);
From 5fb868d71f3f12e9dedb2104718ea284df366ccd Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 1 Mar 2017 15:02:54 +0200
Subject: [PATCH 0280/2045] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Removed some guarantee cancel checks
---
Model/Guarantee/CancelingServiceTest.php | 25 ------------------------
1 file changed, 25 deletions(-)
diff --git a/Model/Guarantee/CancelingServiceTest.php b/Model/Guarantee/CancelingServiceTest.php
index 1ccf347f6f33f..054c8c50598ba 100644
--- a/Model/Guarantee/CancelingServiceTest.php
+++ b/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 97c92ac86633a7644e66e354ded829a173ca03ac Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 28 Feb 2017 18:16:39 +0200
Subject: [PATCH 0281/2045] MAGETWO-65105: Unhold on "Approved" guarantee
status
---
Model/CaseServices/UpdatingService.php | 17 +++++++++--
.../CaseServices/UpdatingServiceTest.php | 28 ++++++++++++++++---
2 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/Model/CaseServices/UpdatingService.php b/Model/CaseServices/UpdatingService.php
index 40f28b32ec0eb..d94af78c42430 100644
--- a/Model/CaseServices/UpdatingService.php
+++ b/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/Test/Unit/Model/CaseServices/UpdatingServiceTest.php b/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index a2894939042dd..0717fea7c1644 100644
--- a/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
+++ b/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);
}
From d2a0312d8ecc0302047b4b587b87d34f88dde450 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 28 Feb 2017 18:16:39 +0200
Subject: [PATCH 0282/2045] MAGETWO-65105: Unhold on "Approved" guarantee
status
---
Model/CaseServices/UpdatingServiceTest.php | 60 ++++++++++++++++++++++
_files/case.php | 6 +++
_files/declined_case.php | 38 ++++++++++++++
3 files changed, 104 insertions(+)
create mode 100644 _files/declined_case.php
diff --git a/Model/CaseServices/UpdatingServiceTest.php b/Model/CaseServices/UpdatingServiceTest.php
index f04108d2b3c8a..85730778dc21c 100644
--- a/Model/CaseServices/UpdatingServiceTest.php
+++ b/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/_files/case.php b/_files/case.php
index a7df26f033074..fec40dec4f17f 100644
--- a/_files/case.php
+++ b/_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/_files/declined_case.php b/_files/declined_case.php
new file mode 100644
index 0000000000000..16cf1b1b8df14
--- /dev/null
+++ b/_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 d06f0936dbe28493fb3cb0fffb37421a69eeaf65 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 27 Feb 2017 15:47:11 +0200
Subject: [PATCH 0283/2045] MAGETWO-65103: Setup HOLD status by default after
placing order in case Signifyd was used
---
Model/CaseServices/CreationService.php | 12 +-
Model/CommentsHistoryUpdater.php | 5 +-
Model/OrderStateService.php | 120 +++++++++++
.../Unit/Model/CommentsHistoryUpdaterTest.php | 16 +-
Test/Unit/Model/OrderStateServiceTest.php | 204 ++++++++++++++++++
i18n/en_US.csv | 3 +-
6 files changed, 354 insertions(+), 6 deletions(-)
create mode 100644 Model/OrderStateService.php
create mode 100644 Test/Unit/Model/OrderStateServiceTest.php
diff --git a/Model/CaseServices/CreationService.php b/Model/CaseServices/CreationService.php
index 510cf8ff9e7e7..5503b26958e7f 100644
--- a/Model/CaseServices/CreationService.php
+++ b/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/Model/CommentsHistoryUpdater.php b/Model/CommentsHistoryUpdater.php
index f36a6205fe3fd..4682f71c3cd7a 100644
--- a/Model/CommentsHistoryUpdater.php
+++ b/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/Model/OrderStateService.php b/Model/OrderStateService.php
new file mode 100644
index 0000000000000..8acb9e28a52eb
--- /dev/null
+++ b/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/Test/Unit/Model/CommentsHistoryUpdaterTest.php b/Test/Unit/Model/CommentsHistoryUpdaterTest.php
index fa0a752451917..fe4ccf1c02ea2 100644
--- a/Test/Unit/Model/CommentsHistoryUpdaterTest.php
+++ b/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/Test/Unit/Model/OrderStateServiceTest.php b/Test/Unit/Model/OrderStateServiceTest.php
new file mode 100644
index 0000000000000..93f4d40dba84a
--- /dev/null
+++ b/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/i18n/en_US.csv b/i18n/en_US.csv
index 188419e33ac76..47feacc8c4a2f 100644
--- a/i18n/en_US.csv
+++ b/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
From b95c369e8052a5e5f85877517bdbdca67363443e Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 27 Feb 2017 15:47:11 +0200
Subject: [PATCH 0284/2045] MAGETWO-65103: Setup HOLD status by default after
placing order in case Signifyd was used
---
Model/CaseServices/CreationServiceTest.php | 15 +++++++++++++++
Model/CaseServices/UpdatingServiceTest.php | 1 -
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/Model/CaseServices/CreationServiceTest.php b/Model/CaseServices/CreationServiceTest.php
index d779e98ebd034..a8d31240fb5b0 100644
--- a/Model/CaseServices/CreationServiceTest.php
+++ b/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/Model/CaseServices/UpdatingServiceTest.php b/Model/CaseServices/UpdatingServiceTest.php
index 85730778dc21c..879405a757eaf 100644
--- a/Model/CaseServices/UpdatingServiceTest.php
+++ b/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 19508d0dc9f7bc075376d0b2f5f2a71558b527c3 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 1 Mar 2017 19:07:08 +0200
Subject: [PATCH 0285/2045] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Code review fixes
---
.../Guarantee/CancelGuaranteeAbilityTest.php | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php b/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
index 280f54e7aa5d3..f51b4980ee857 100644
--- a/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
+++ b/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.
*/
From 9750ba18cf8a516b374a8eeb492e2e56fabed44a Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 1 Mar 2017 19:07:08 +0200
Subject: [PATCH 0286/2045] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Code review fixes
---
Model/Guarantee/CancelingServiceTest.php | 25 ++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/Model/Guarantee/CancelingServiceTest.php b/Model/Guarantee/CancelingServiceTest.php
index 054c8c50598ba..682b3338bef02 100644
--- a/Model/Guarantee/CancelingServiceTest.php
+++ b/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 02903679457621655c74fa802783189ec8e4c80b Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Tue, 7 Mar 2017 18:53:15 +0200
Subject: [PATCH 0287/2045] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- Changes in install schema
---
Setup/InstallData.php | 66 -----------------------------------------
Setup/InstallSchema.php | 10 +++++++
composer.json | 1 -
etc/module.xml | 1 -
4 files changed, 10 insertions(+), 68 deletions(-)
delete mode 100644 Setup/InstallData.php
diff --git a/Setup/InstallData.php b/Setup/InstallData.php
deleted file mode 100644
index a7490064a895a..0000000000000
--- a/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/Setup/InstallSchema.php b/Setup/InstallSchema.php
index b66bd5314b6bb..35a373097e736 100644
--- a/Setup/InstallSchema.php
+++ b/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/composer.json b/composer.json
index 315ed2db7495d..0ec646ed17908 100644
--- a/composer.json
+++ b/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/etc/module.xml b/etc/module.xml
index 602860b1be220..81d97d6fdc0d4 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -9,7 +9,6 @@
-
From 28577b6b0db8e126d47b109ae9f542b06db86fd0 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 3 Mar 2017 17:07:30 +0200
Subject: [PATCH 0288/2045] MAGETWO-65119: Create/update automated functional
tests
- Add "Accept order placed within PayPal Payments Pro Hosted Solution with Fraud filters triggered and Signifyd Guarantee Declined" FAT
- Add "Deny order placed within PayPal Payments Pro Hosted Solution with Fraud filters triggered and Signifyd Guarantee Declined" FAT
---
Test/Block/SignifydConsole/CaseInfo.php | 51 ++++++++
...tingSignifydGuaranteeInCommentsHistory.php | 73 ++++++++++++
Test/Constraint/AssertCaseInfoOnAdmin.php | 34 +++---
.../AssertCaseInfoOnSignifydConsole.php | 78 ++++++++++---
.../AssertSignifydCaseInOrdersGrid.php | 7 +-
Test/Fixture/SignifydData.xml | 23 ++++
Test/Repository/SignifydData.xml | 40 +++++++
...ymentWithSignifydGuaranteeDeclinedTest.php | 63 ++++++++++
...ymentWithSignifydGuaranteeDeclinedTest.xml | 38 ++++++
...ateSignifydGuaranteeAndCancelOrderTest.php | 102 +---------------
...ateSignifydGuaranteeAndCancelOrderTest.xml | 36 +++---
...ymentWithSignifydGuaranteeDeclinedTest.php | 68 +++++++++++
...ymentWithSignifydGuaranteeDeclinedTest.xml | 38 ++++++
Test/TestStep/OpenOrderGridStep.php | 24 ++--
Test/TestStep/SignifydCancelOrderStep.php | 110 ++++++++++++++++++
Test/TestStep/SignifydObserveCaseStep.php | 66 ++++++++---
.../SignifydSetWebhookHandlersStep.php | 21 +++-
Test/TestStep/UnholdAndCancelOrderStep.php | 61 ++++++++++
Test/etc/testcase.xml | 38 +++++-
19 files changed, 784 insertions(+), 187 deletions(-)
create mode 100644 Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php
create mode 100644 Test/Fixture/SignifydData.xml
create mode 100644 Test/Repository/SignifydData.xml
create mode 100644 Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
create mode 100644 Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml
create mode 100644 Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
create mode 100644 Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml
create mode 100644 Test/TestStep/SignifydCancelOrderStep.php
create mode 100644 Test/TestStep/UnholdAndCancelOrderStep.php
diff --git a/Test/Block/SignifydConsole/CaseInfo.php b/Test/Block/SignifydConsole/CaseInfo.php
index bc38b1f294032..e41e5ecb430c0 100644
--- a/Test/Block/SignifydConsole/CaseInfo.php
+++ b/Test/Block/SignifydConsole/CaseInfo.php
@@ -75,6 +75,13 @@ class CaseInfo extends Block
*/
private $orderAmount = '[ng-bind*="currentCase.orderAmount"]';
+ /**
+ * Locator value for order amount currency.
+ *
+ * @var string
+ */
+ private $orderAmountCurrency = '[ng-bind*="currentCase.currency"]';
+
/**
* Css selector of displayed card holder name.
*
@@ -89,6 +96,40 @@ class CaseInfo extends Block
*/
private $billingAddress = '[data-dropdown="streetLinks0"]';
+ /**
+ * Locator value for "No analysis available" block in "Device" container.
+ *
+ * @var string
+ */
+ private $noDeviceAnalysisAvailable = '[ng-hide^="caseAnalysis.deviceAnalysis.details.length"]';
+
+ /**
+ * Locator value for "Shipping Price" block.
+ *
+ * @var string
+ */
+ private $shippingPrice = '[ng-if$="caseOrderSummary.shipments[0].shippingPrice"]';
+
+ /**
+ * Check if device data are present.
+ *
+ * @return bool
+ */
+ public function isAvailableDeviceData()
+ {
+ return !$this->_rootElement->find($this->noDeviceAnalysisAvailable)->isVisible();
+ }
+
+ /**
+ * Returns shipping price.
+ *
+ * @return string
+ */
+ public function getShippingPrice()
+ {
+ return $this->_rootElement->find($this->shippingPrice)->getText();
+ }
+
/**
* Flags case as good or bad.
*
@@ -172,6 +213,16 @@ 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.
*
diff --git a/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php b/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php
new file mode 100644
index 0000000000000..ab5e04eba0a83
--- /dev/null
+++ b/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/Test/Constraint/AssertCaseInfoOnAdmin.php b/Test/Constraint/AssertCaseInfoOnAdmin.php
index 32d8a468e8918..6071b0ff90c71 100644
--- a/Test/Constraint/AssertCaseInfoOnAdmin.php
+++ b/Test/Constraint/AssertCaseInfoOnAdmin.php
@@ -5,8 +5,10 @@
*/
namespace Magento\Signifyd\Test\Constraint;
+use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
use Magento\Mtf\Constraint\AbstractConstraint;
+use Magento\Signifyd\Test\Fixture\SignifydData;
/**
* Assert that Order Case Entity is correct on order page in Admin.
@@ -21,36 +23,40 @@ class AssertCaseInfoOnAdmin extends AbstractConstraint
private $orderView;
/**
- * Order id.
+ * Signifyd data fixture.
*
- * @var string
+ * @var SignifydData
*/
- private $orderId;
+ private $signifydData;
/**
- * Array of Signifyd config data.
+ * Order id.
*
- * @var array
+ * @var string
*/
- private $signifydData;
+ private $orderId;
/**
* Assert that Signifyd Case information is correct in Admin.
*
* @param SalesOrderView $orderView
+ * @param OrderIndex $salesOrder
+ * @param SignifydData $signifydData
* @param string $orderId
- * @param array $signifydData
* @return void
*/
public function processAssert(
SalesOrderView $orderView,
- $orderId,
- array $signifydData
+ OrderIndex $salesOrder,
+ SignifydData $signifydData,
+ $orderId
) {
+ $salesOrder->open();
+ $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
+
$this->orderView = $orderView;
- $this->orderView->open(['order_id' => $orderId]);
- $this->orderId = $orderId;
$this->signifydData = $signifydData;
+ $this->orderId = $orderId;
$this->checkCaseStatus();
$this->checkCaseGuaranteeDisposition();
@@ -65,7 +71,7 @@ public function processAssert(
private function checkCaseStatus()
{
\PHPUnit_Framework_Assert::assertEquals(
- $this->signifydData['caseStatus'],
+ $this->signifydData->getCaseStatus(),
$this->orderView->getFraudProtectionBlock()->getCaseStatus(),
'Case status is wrong for order #' . $this->orderId
);
@@ -79,7 +85,7 @@ private function checkCaseStatus()
private function checkCaseGuaranteeDisposition()
{
\PHPUnit_Framework_Assert::assertEquals(
- $this->signifydData['guaranteeDisposition'],
+ $this->signifydData->getGuaranteeDisposition(),
$this->orderView->getFraudProtectionBlock()->getCaseGuaranteeDisposition(),
'Case Guarantee Disposition status is wrong for order #' . $this->orderId
);
@@ -93,7 +99,7 @@ private function checkCaseGuaranteeDisposition()
private function checkCaseReviewDisposition()
{
\PHPUnit_Framework_Assert::assertEquals(
- $this->signifydData['reviewDisposition'],
+ $this->signifydData->getReviewDisposition(),
$this->orderView->getFraudProtectionBlock()->getCaseReviewDisposition(),
'Case Review Disposition status is wrong for order #' . $this->orderId
);
diff --git a/Test/Constraint/AssertCaseInfoOnSignifydConsole.php b/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
index 97983621922ce..217f9e9515e94 100644
--- a/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
+++ b/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
@@ -7,6 +7,7 @@
use Magento\Mtf\Constraint\AbstractConstraint;
use Magento\Signifyd\Test\Fixture\SignifydAddress;
+use Magento\Signifyd\Test\Fixture\SignifydData;
use Magento\Signifyd\Test\Page\SignifydConsole\SignifydCases;
/**
@@ -24,31 +25,65 @@ class AssertCaseInfoOnSignifydConsole extends AbstractConstraint
/**
* @param SignifydCases $signifydCases
* @param SignifydAddress $billingAddress
+ * @param SignifydData $signifydData
* @param array $prices
* @param string $orderId
* @param string $customerFullName
- * @param array $signifydData
* @return void
*/
public function processAssert(
SignifydCases $signifydCases,
SignifydAddress $billingAddress,
+ SignifydData $signifydData,
array $prices,
$orderId,
- $customerFullName,
- array $signifydData
+ $customerFullName
) {
$this->signifydCases = $signifydCases;
- $this->checkGuaranteeDisposition($signifydData['guaranteeDisposition']);
- $this->checkCvvResponse($signifydData['cvvResponse']);
- $this->checkAvsResponse($signifydData['avsResponse']);
+ $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.
*
@@ -60,7 +95,7 @@ private function checkGuaranteeDisposition($guaranteeDisposition)
\PHPUnit_Framework_Assert::assertEquals(
$guaranteeDisposition,
$this->signifydCases->getCaseInfoBlock()->getGuaranteeDisposition(),
- 'Guarantee disposition is incorrect in Signifyd console.'
+ 'Guarantee disposition is incorrect on case page in Signifyd console.'
);
}
@@ -75,7 +110,7 @@ private function checkCvvResponse($cvvResponse)
\PHPUnit_Framework_Assert::assertEquals(
$cvvResponse,
$this->signifydCases->getCaseInfoBlock()->getCvvResponse(),
- 'CVV response is incorrect in Signifyd console.'
+ 'CVV response is incorrect on case page in Signifyd console.'
);
}
@@ -90,7 +125,7 @@ private function checkAvsResponse($avsResponse)
\PHPUnit_Framework_Assert::assertEquals(
$avsResponse,
$this->signifydCases->getCaseInfoBlock()->getAvsResponse(),
- 'AVS response is incorrect in Signifyd console.'
+ 'AVS response is incorrect on case page in Signifyd console.'
);
}
@@ -105,7 +140,7 @@ private function checkOrderId($orderId)
\PHPUnit_Framework_Assert::assertEquals(
$orderId,
$this->signifydCases->getCaseInfoBlock()->getOrderId(),
- 'Order id is incorrect in Signifyd console.'
+ 'Order id is incorrect on case page in Signifyd console.'
);
}
@@ -120,7 +155,22 @@ private function checkOrderAmount($amount)
\PHPUnit_Framework_Assert::assertEquals(
number_format($amount, 2),
$this->signifydCases->getCaseInfoBlock()->getOrderAmount(),
- 'Order amount is incorrect in Signifyd console.'
+ '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.'
);
}
@@ -135,7 +185,7 @@ private function checkCardHolder($customerFullName)
\PHPUnit_Framework_Assert::assertEquals(
$customerFullName,
$this->signifydCases->getCaseInfoBlock()->getCardHolder(),
- 'Card holder name is incorrect in Signifyd console.'
+ 'Card holder name is incorrect on case page in Signifyd console.'
);
}
@@ -150,7 +200,7 @@ private function checkBillingAddress(SignifydAddress $billingAddress)
\PHPUnit_Framework_Assert::assertContains(
$billingAddress->getStreet(),
$this->signifydCases->getCaseInfoBlock()->getBillingAddress(),
- 'Billing address is incorrect in Signifyd console.'
+ 'Billing address is incorrect on case page in Signifyd console.'
);
}
@@ -159,6 +209,6 @@ private function checkBillingAddress(SignifydAddress $billingAddress)
*/
public function toString()
{
- return 'Case information is correct in Signifyd console.';
+ return 'Case information is correct on case page in Signifyd console.';
}
}
diff --git a/Test/Constraint/AssertSignifydCaseInOrdersGrid.php b/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
index 6157fa937d3c8..e48ace3ddb79a 100644
--- a/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
+++ b/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Signifyd\Test\Constraint;
+use Magento\Signifyd\Test\Fixture\SignifydData;
use Magento\Signifyd\Test\Page\Adminhtml\OrdersGrid;
use Magento\Mtf\Constraint\AbstractConstraint;
@@ -17,19 +18,19 @@ class AssertSignifydCaseInOrdersGrid extends AbstractConstraint
* @param string $orderId
* @param string $status
* @param OrdersGrid $ordersGrid
- * @param array $signifydData
+ * @param SignifydData $signifydData
* @return void
*/
public function processAssert(
$orderId,
$status,
OrdersGrid $ordersGrid,
- array $signifydData
+ SignifydData $signifydData
) {
$filter = [
'id' => $orderId,
'status' => $status,
- 'signifyd_guarantee_status' => $signifydData['guaranteeDisposition']
+ 'signifyd_guarantee_status' => $signifydData->getGuaranteeDisposition()
];
$errorMessage = implode(', ', $filter);
diff --git a/Test/Fixture/SignifydData.xml b/Test/Fixture/SignifydData.xml
new file mode 100644
index 0000000000000..91a5425ce4a8f
--- /dev/null
+++ b/Test/Fixture/SignifydData.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Test/Repository/SignifydData.xml b/Test/Repository/SignifydData.xml
new file mode 100644
index 0000000000000..68cffb97c22e7
--- /dev/null
+++ b/Test/Repository/SignifydData.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+ autotest
+ Open
+ Good
+ Good
+ Approved
+ CVV2 Match (M)
+ Full match (Y)
+ USD 5.00
+
+
+ autotest
+ Open
+ Bad
+ Fraudulent
+ Declined
+ CVV2 Match (M)
+ Full match (Y)
+ USD 5.00
+
+
+ autotest
+ Open
+ Bad
+ Fraudulent
+ Declined
+ Unavailable (U)
+ GBP 10.00
+
+
+
diff --git a/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php b/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
new file mode 100644
index 0000000000000..952c0980f2b3e
--- /dev/null
+++ b/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
@@ -0,0 +1,63 @@
+executeScenario();
+ }
+}
diff --git a/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml b/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml
new file mode 100644
index 0000000000000..88815fd823889
--- /dev/null
+++ b/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, severity:S2
+
+
+
+
+
+
+
diff --git a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
index 4baeeb638adb1..4b958f09320bf 100644
--- a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
+++ b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
@@ -6,11 +6,6 @@
namespace Magento\Signifyd\Test\TestCase;
use Magento\Mtf\TestCase\Scenario;
-use Magento\Sales\Test\Fixture\OrderInjectable;
-use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
-use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
-use Magento\Sales\Test\TestStep\CancelOrderStep;
-use Magento\Signifyd\Test\Page\SignifydConsole\SignifydNotifications;
/**
* Preconditions:
@@ -34,7 +29,7 @@
* 11. Click 'Place order' button.
* 12. Search for created case.
* 13. Open created case.
- * 14. Click "Flag case as good" button.
+ * 14. Click "Flag case as good" or "Flag case as bad" button.
* 15. Perform case info assertions.
* 16. Log in to Admin.
* 17. Proceed to order grid.
@@ -45,7 +40,7 @@
* 22. Perform remaining assertions.
*
* @group Signifyd
- * @ZephyrId MAGETWO-62120, MAGETWO-63221
+ * @ZephyrId MAGETWO-62120, MAGETWO-63221, MAGETWO-64305, MAGETWO-65253
*/
class CreateSignifydGuaranteeAndCancelOrderTest extends Scenario
{
@@ -55,104 +50,13 @@ class CreateSignifydGuaranteeAndCancelOrderTest extends Scenario
const SEVERITY = 'S1';
/* end tags */
- /**
- * Order page.
- *
- * @var OrderIndex
- */
- private $orderIndex;
-
- /**
- * Sales order view page.
- *
- * @var SalesOrderView
- */
- private $salesOrderView;
-
- /**
- * Cancel order test step.
- *
- * @var CancelOrderStep
- */
- private $cancelOrderStep;
-
- /**
- * Order fixture.
- *
- * @var OrderInjectable
- */
- private $orderInjectable;
-
- /**
- * Signifyd notifications page.
- *
- * @var SignifydNotifications
- */
- private $signifydNotifications;
-
- /**
- * Array of Signifyd config data.
- *
- * @var array
- */
- private $signifydData;
-
- /**
- * @param OrderIndex $orderIndex
- * @param SalesOrderView $salesOrderView
- * @param CancelOrderStep $cancelOrderStep
- * @param OrderInjectable $orderInjectable
- * @param SignifydNotifications $signifydNotifications
- */
- public function __inject(
- OrderIndex $orderIndex,
- SalesOrderView $salesOrderView,
- CancelOrderStep $cancelOrderStep,
- OrderInjectable $orderInjectable,
- SignifydNotifications $signifydNotifications
- ) {
- $this->orderIndex = $orderIndex;
- $this->salesOrderView = $salesOrderView;
- $this->cancelOrderStep = $cancelOrderStep;
- $this->orderInjectable = $orderInjectable;
- $this->signifydNotifications = $signifydNotifications;
- }
-
/**
* Runs one page checkout test.
*
- * @param array $signifydData
* @return void
*/
- public function test(array $signifydData)
+ public function test()
{
- $this->signifydData = $signifydData;
-
$this->executeScenario();
}
-
- /**
- * Tear down for scenario variations.
- *
- * Signifyd needs this cleanup for guarantee decline. If we had have many cases
- * with approved guarantees, and same order id, Signifyd will not create
- * guarantee approve status for new cases.
- *
- * @return void
- */
- public function tearDown()
- {
- $this->orderIndex->open();
- $this->orderIndex->getSalesOrderGrid()
- ->searchAndOpen(['id' => $this->orderInjectable->getId()]);
- if ($this->salesOrderView->getOrderInfoBlock()->getOrderStatus() !== 'Canceled') {
- $this->cancelOrderStep->run();
- }
-
- if ($this->signifydData['cleanupWebhooks']) {
- $this->signifydNotifications->open();
- $this->signifydNotifications->getWebhooksBlock()
- ->cleanup($this->signifydData['team']);
- }
- }
}
diff --git a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
index 133864d797cf2..94745dba440fd 100644
--- a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
+++ b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
@@ -9,29 +9,23 @@
catalogProductSimple::product_10_dollar
login
signifyd_approve_us_customer
- signifyd_us_shipping_address
Flat Rate
Fixed
braintree
15.00
+ USD
visa_default
braintree
braintree,signifyd
+ Processing
+ signifyd_us_shipping_address
sandbox_default
- Processing
- autotest
- Open
- Good
- Good
- Approved
- CVV2 Match (M)
- Full match (Y)
- false
+ signifyd_guarantee_approve
test_type:3rd_party_test, severity:S1
@@ -39,32 +33,27 @@
+
+ summary="Cancel order placed within Braintree credit card with Signifyd declined guarantee."
+ ticketId="MAGETWO-64305, MAGETWO-65253">
catalogProductSimple::product_10_dollar
login
signifyd_decline_us_customer
- signifyd_us_shipping_address
Flat Rate
Fixed
braintree
15.00
+ USD
visa_default
braintree
braintree,signifyd
+ On Hold
+ signifyd_us_shipping_address
sandbox_default
- Processing
- autotest
- Open
- Bad
- Fraudulent
- Declined
- CVV2 Match (M)
- Full match (Y)
- true
+ signifyd_guarantee_decline
test_type:3rd_party_test, severity:S1
@@ -72,6 +61,7 @@
+
diff --git a/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
new file mode 100644
index 0000000000000..6816eebf9b725
--- /dev/null
+++ b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
@@ -0,0 +1,68 @@
+executeScenario();
+ }
+}
diff --git a/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml
new file mode 100644
index 0000000000000..224bee8a087ab
--- /dev/null
+++ b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.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
+ Canceled
+ signifyd_us_shipping_address
+ sandbox_default
+ signifyd_guarantee_fraudulent
+ test_type:3rd_party_test, severity:S2
+
+
+
+
+
+
+
diff --git a/Test/TestStep/OpenOrderGridStep.php b/Test/TestStep/OpenOrderGridStep.php
index b249a954b40b4..0496eb694944b 100644
--- a/Test/TestStep/OpenOrderGridStep.php
+++ b/Test/TestStep/OpenOrderGridStep.php
@@ -11,6 +11,7 @@
use Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect as AssertOrderStatus;
use Magento\Signifyd\Test\Constraint\AssertSignifydCaseInOrdersGrid as AssertOrdersGrid;
use Magento\Signifyd\Test\Constraint\AssertCaseInfoOnAdmin;
+use Magento\Signifyd\Test\Fixture\SignifydData;
use Magento\Signifyd\Test\Page\Adminhtml\OrdersGrid;
/**
@@ -44,7 +45,7 @@ class OpenOrderGridStep implements TestStepInterface
*
* @var string
*/
- private $orderStatus;
+ private $placeOrderStatus;
/**
* Magento order id.
@@ -68,7 +69,7 @@ class OpenOrderGridStep implements TestStepInterface
private $ordersGrid;
/**
- * Array of Signifyd config data.
+ * Signifyd data fixture.
*
* @var array
*/
@@ -82,7 +83,7 @@ class OpenOrderGridStep implements TestStepInterface
private $orderIndex;
/**
- * @param string $status
+ * @param string $placeOrderStatus
* @param int $orderId
* @param OrderIndex $orderIndex
* @param SalesOrderView $salesOrderView
@@ -90,10 +91,10 @@ class OpenOrderGridStep implements TestStepInterface
* @param AssertOrderStatus $assertOrderStatus
* @param AssertCaseInfoOnAdmin $assertCaseInfo
* @param AssertOrdersGrid $assertOrdersGrid
- * @param array $signifydData
+ * @param SignifydData $signifydData
*/
public function __construct(
- $status,
+ $placeOrderStatus,
$orderId,
OrderIndex $orderIndex,
SalesOrderView $salesOrderView,
@@ -101,9 +102,9 @@ public function __construct(
AssertOrderStatus $assertOrderStatus,
AssertCaseInfoOnAdmin $assertCaseInfo,
AssertOrdersGrid $assertOrdersGrid,
- array $signifydData
+ SignifydData $signifydData
) {
- $this->orderStatus = $status;
+ $this->placeOrderStatus = $placeOrderStatus;
$this->orderId = $orderId;
$this->orderIndex = $orderIndex;
$this->salesOrderView = $salesOrderView;
@@ -135,7 +136,7 @@ private function checkOrdersGrid()
{
$this->assertOrdersGrid->processAssert(
$this->orderId,
- $this->orderStatus,
+ $this->placeOrderStatus,
$this->ordersGrid,
$this->signifydData
);
@@ -149,7 +150,7 @@ private function checkOrdersGrid()
private function checkOrderStatus()
{
$this->assertOrderStatus->processAssert(
- $this->orderStatus,
+ $this->placeOrderStatus,
$this->orderId,
$this->orderIndex,
$this->salesOrderView
@@ -165,8 +166,9 @@ private function checkCaseInfo()
{
$this->assertCaseInfo->processAssert(
$this->salesOrderView,
- $this->orderId,
- $this->signifydData
+ $this->orderIndex,
+ $this->signifydData,
+ $this->orderId
);
}
}
diff --git a/Test/TestStep/SignifydCancelOrderStep.php b/Test/TestStep/SignifydCancelOrderStep.php
new file mode 100644
index 0000000000000..b0bbd150e01cf
--- /dev/null
+++ b/Test/TestStep/SignifydCancelOrderStep.php
@@ -0,0 +1,110 @@
+orderIndex = $orderIndex;
+ $this->orderInjectable = $orderInjectable;
+ $this->salesOrderView = $salesOrderView;
+ $this->cancelOrderStep = $cancelOrderStep;
+ $this->denyPaymentStep = $denyPaymentStep;
+ $this->unholdOrderStep = $unholdOrderStep;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function run()
+ {
+ $this->orderIndex->open();
+ $this->orderIndex->getSalesOrderGrid()
+ ->searchAndOpen(['id' => $this->orderInjectable->getId()]);
+
+ switch ($this->salesOrderView->getOrderInfoBlock()->getOrderStatus()) {
+ case 'Suspected Fraud':
+ $this->denyPaymentStep->run();
+ break;
+ case 'On Hold':
+ $this->unholdOrderStep->run();
+ $this->cancelOrderStep->run();
+ break;
+ case 'Canceled':
+ break;
+ default:
+ $this->cancelOrderStep->run();
+ }
+ }
+}
diff --git a/Test/TestStep/SignifydObserveCaseStep.php b/Test/TestStep/SignifydObserveCaseStep.php
index 0ac91665eae96..e587304f1e08f 100644
--- a/Test/TestStep/SignifydObserveCaseStep.php
+++ b/Test/TestStep/SignifydObserveCaseStep.php
@@ -8,7 +8,9 @@
use Magento\Mtf\TestStep\TestStepInterface;
use Magento\Signifyd\Test\Constraint\AssertCaseInfoOnSignifydConsole;
use Magento\Signifyd\Test\Fixture\SignifydAddress;
+use Magento\Signifyd\Test\Fixture\SignifydData;
use Magento\Signifyd\Test\Page\SignifydConsole\SignifydCases;
+use Magento\Signifyd\Test\Page\SignifydConsole\SignifydNotifications;
/**
* Observe case information in Signifyd console step.
@@ -22,6 +24,13 @@ class SignifydObserveCaseStep implements TestStepInterface
*/
private $assertCaseInfo;
+ /**
+ * Billing address fixture.
+ *
+ * @var SignifydAddress
+ */
+ private $signifydAddress;
+
/**
* Signifyd cases page.
*
@@ -30,25 +39,32 @@ class SignifydObserveCaseStep implements TestStepInterface
private $signifydCases;
/**
- * Billing address fixture.
+ * Signifyd notifications page.
*
- * @var SignifydAddress
+ * @var SignifydNotifications
*/
- private $signifydAddress;
+ private $signifydNotifications;
/**
- * Prices list.
+ * Signifyd data fixture.
*
* @var array
*/
- private $prices;
+ private $signifydData;
+
+ /**
+ * Signifyd cancel order step.
+ *
+ * @var SignifydCancelOrderStep
+ */
+ private $signifydCancelOrderStep;
/**
- * Array of Signifyd config data.
+ * Prices list.
*
* @var array
*/
- private $signifydData;
+ private $prices;
/**
* Order id.
@@ -59,25 +75,31 @@ class SignifydObserveCaseStep implements TestStepInterface
/**
* @param AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole
- * @param SignifydCases $signifydCases
* @param SignifydAddress $signifydAddress
+ * @param SignifydCases $signifydCases
+ * @param SignifydNotifications $signifydNotifications
+ * @param SignifydData $signifydData
+ * @param SignifydCancelOrderStep $signifydCancelOrderStep
* @param array $prices
- * @param array $signifydData
- * @param string $orderId
+ * @param $orderId
*/
public function __construct(
AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole,
- SignifydCases $signifydCases,
SignifydAddress $signifydAddress,
+ SignifydCases $signifydCases,
+ SignifydNotifications $signifydNotifications,
+ SignifydData $signifydData,
+ SignifydCancelOrderStep $signifydCancelOrderStep,
array $prices,
- array $signifydData,
$orderId
) {
$this->assertCaseInfo = $assertCaseInfoOnSignifydConsole;
- $this->signifydCases = $signifydCases;
$this->signifydAddress = $signifydAddress;
- $this->prices = $prices;
+ $this->signifydCases = $signifydCases;
+ $this->signifydNotifications = $signifydNotifications;
$this->signifydData = $signifydData;
+ $this->signifydCancelOrderStep = $signifydCancelOrderStep;
+ $this->prices = $prices;
$this->orderId = $orderId;
}
@@ -90,18 +112,28 @@ public function run()
$this->signifydCases->getCaseSearchBlock()
->searchCaseByCustomerName($this->signifydAddress->getFirstname());
$this->signifydCases->getCaseSearchBlock()->selectCase();
- $this->signifydCases->getCaseInfoBlock()->flagCase($this->signifydData['caseFlag']);
+ $this->signifydCases->getCaseInfoBlock()->flagCase($this->signifydData->getCaseFlag());
$this->assertCaseInfo->processAssert(
$this->signifydCases,
$this->signifydAddress,
+ $this->signifydData,
$this->prices,
$this->orderId,
- $this->getCustomerFullName($this->signifydAddress),
- $this->signifydData
+ $this->getCustomerFullName($this->signifydAddress)
);
}
+ /**
+ * Cancel order if test fails, or in the end of variation.
+ *
+ * @return void
+ */
+ public function cleanup()
+ {
+ $this->signifydCancelOrderStep->run();
+ }
+
/**
* Gets customer full name.
*
diff --git a/Test/TestStep/SignifydSetWebhookHandlersStep.php b/Test/TestStep/SignifydSetWebhookHandlersStep.php
index 651b4e1f9b8ca..90de0ae0c0cbf 100644
--- a/Test/TestStep/SignifydSetWebhookHandlersStep.php
+++ b/Test/TestStep/SignifydSetWebhookHandlersStep.php
@@ -6,6 +6,7 @@
namespace Magento\Signifyd\Test\TestStep;
use Magento\Mtf\TestStep\TestStepInterface;
+use Magento\Signifyd\Test\Fixture\SignifydData;
use Magento\Signifyd\Test\Page\SignifydConsole\SignifydNotifications;
/**
@@ -21,7 +22,7 @@ class SignifydSetWebhookHandlersStep implements TestStepInterface
private $signifydNotifications;
/**
- * Array of Signifyd config data.
+ * Signifyd data fixture.
*
* @var array
*/
@@ -29,11 +30,11 @@ class SignifydSetWebhookHandlersStep implements TestStepInterface
/**
* @param SignifydNotifications $signifydNotifications
- * @param array $signifydData
+ * @param SignifydData $signifydData
*/
public function __construct(
SignifydNotifications $signifydNotifications,
- array $signifydData
+ SignifydData $signifydData
) {
$this->signifydNotifications = $signifydNotifications;
$this->signifydData = $signifydData;
@@ -46,6 +47,18 @@ public function run()
{
$this->signifydNotifications->open();
$this->signifydNotifications->getWebhooksBlock()
- ->create($this->signifydData['team']);
+ ->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/Test/TestStep/UnholdAndCancelOrderStep.php b/Test/TestStep/UnholdAndCancelOrderStep.php
new file mode 100644
index 0000000000000..30e810a61ab62
--- /dev/null
+++ b/Test/TestStep/UnholdAndCancelOrderStep.php
@@ -0,0 +1,61 @@
+placeOrderStatus = $placeOrderStatus;
+ $this->cancelOrderStep = $cancelOrderStep;
+ $this->unholdOrderStep = $unholdOrderStep;
+ }
+
+ /**
+ * Cancel order step.
+ *
+ * If order was held - unhold and then cancel the order.
+ *
+ * @return void
+ */
+ public function run()
+ {
+ if ($this->placeOrderStatus === 'On Hold') {
+ $this->unholdOrderStep->run();
+ }
+
+ $this->cancelOrderStep->run();
+ }
+}
diff --git a/Test/etc/testcase.xml b/Test/etc/testcase.xml
index b12952efbac8b..ab7238f48fb33 100644
--- a/Test/etc/testcase.xml
+++ b/Test/etc/testcase.xml
@@ -21,7 +21,41 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 30820ffc81dea35fdb9281a818c461cf1a3a22fa Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 1 Mar 2017 17:48:40 +0200
Subject: [PATCH 0289/2045] MAGETWO-63641: Signifyd Marketing Materials on
Configuration Page
---
.../System/Config/Field/WebhookUrl.php | 60 +++++++++++++++
.../Adminhtml/System/Config/Fieldset/Info.php | 31 ++++++++
composer.json | 1 +
etc/adminhtml/system.xml | 69 ++++++++++++------
i18n/en_US.csv | 19 ++++-
view/adminhtml/web/images/logo.png | Bin 0 -> 5218 bytes
6 files changed, 157 insertions(+), 23 deletions(-)
create mode 100644 Block/Adminhtml/System/Config/Field/WebhookUrl.php
create mode 100644 Block/Adminhtml/System/Config/Fieldset/Info.php
create mode 100644 view/adminhtml/web/images/logo.png
diff --git a/Block/Adminhtml/System/Config/Field/WebhookUrl.php b/Block/Adminhtml/System/Config/Field/WebhookUrl.php
new file mode 100644
index 0000000000000..1fbb15953dbc7
--- /dev/null
+++ b/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/Block/Adminhtml/System/Config/Fieldset/Info.php b/Block/Adminhtml/System/Config/Fieldset/Info.php
new file mode 100644
index 0000000000000..a2501be28395e
--- /dev/null
+++ b/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/composer.json b/composer.json
index cf9b2311bbba5..09a26f2dacb6a 100644
--- a/composer.json
+++ b/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/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 20445a953edce..1da4c75cea0c3 100644
--- a/etc/adminhtml/system.xml
+++ b/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/i18n/en_US.csv b/i18n/en_US.csv
index 516147e01cfd8..dca6bcade0eb8 100644
--- a/i18n/en_US.csv
+++ b/i18n/en_US.csv
@@ -23,4 +23,21 @@
"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 your order.","Guarantee has been cancelled for your order."
-"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
\ No newline at end of file
+"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."
\ No newline at end of file
diff --git a/view/adminhtml/web/images/logo.png b/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 aaac3fd3e8a7482591b827cc882396c37a69c4dc Mon Sep 17 00:00:00 2001
From: Oleksii Korshenko
Date: Tue, 14 Mar 2017 14:27:17 -0500
Subject: [PATCH 0290/2045] MAGETWO-65199: [GitHub][PR] [PSR-2 Compliance] Fix
#8612: Hundreds of PHPCS-based static tests violations in mainline
magento/magento2#8685
- automatic fix of code style issues:
- Step 1. Install php-cs-fixer globally: composer global require friendsofphp/php-cs-fixer:2.1.0
- Step 2. Execute tool: ~/.composer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix . --rules=no_extra_consecutive_blank_lines,method_separation -v
---
_files/order_with_customer_and_two_simple_products.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/_files/order_with_customer_and_two_simple_products.php b/_files/order_with_customer_and_two_simple_products.php
index 90df998d78a01..2800ca2da9525 100644
--- a/_files/order_with_customer_and_two_simple_products.php
+++ b/_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 a2a1dd57ebe0710d413a6b1d9504ab68d722dfae Mon Sep 17 00:00:00 2001
From: Oleksii Korshenko
Date: Tue, 14 Mar 2017 14:39:52 -0500
Subject: [PATCH 0291/2045] MAGETWO-65199: [GitHub][PR] [PSR-2 Compliance] Fix
#8612: Hundreds of PHPCS-based static tests violations in mainline
magento/magento2#8685
- automatic fix of code style issues:
- Step 1. Install phpcs globally: composer global require squizlabs/php_codesniffer:2.8.0
- Step 1. Execute tool to fix PSR-2 violations in PHP files: ~/.composer/vendor/squizlabs/php_codesniffer/scripts/phpcbf --standard=PSR2 --extensions=php --ignore=generated/*,vendor/*,var/* .
---
Test/Unit/Model/MessageGenerators/CaseRescoreTest.php | 1 -
Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php | 1 -
2 files changed, 2 deletions(-)
diff --git a/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 3e808564e5e33..0738f457ddb71 100644
--- a/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -59,7 +59,6 @@ protected function setUp()
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseRepository' => $this->caseRepository
]);
-
}
/**
diff --git a/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php b/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php
index d85d86c221e7a..623ea119a1543 100644
--- a/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php
+++ b/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php
@@ -70,7 +70,6 @@ public function setUp()
$this->responseHandler = $this->objectManager->getObject(ResponseHandler::class, [
'dataDecoder' => $this->dataDecoder
]);
-
}
/**
From 69e4de3e81758fd4abc34c0daef1b086d83b89bf Mon Sep 17 00:00:00 2001
From: Yevhen Miroshnychenko
Date: Thu, 16 Mar 2017 13:00:57 +0200
Subject: [PATCH 0292/2045] MAGETWO-65544: Cloud deployment support for
configuration
---
etc/di.xml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/etc/di.xml b/etc/di.xml
index 878272a9531a2..7d961b275d9fc 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -106,4 +106,12 @@
PaymentMethodConfigData
+
+
+
+ - 1
+ - 1
+
+
+
From ac9d4dcf45b4ad5075b9ed28babb6dd90be1cac9 Mon Sep 17 00:00:00 2001
From: ashevtsov
Date: Thu, 16 Mar 2017 15:52:22 +0200
Subject: [PATCH 0293/2045] MAGETWO-65544: Cloud deployment support for
configuration
---
etc/di.xml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/etc/di.xml b/etc/di.xml
index 7d961b275d9fc..f01e5c0a1b4b6 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -112,6 +112,10 @@
- 1
- 1
+
+ - 1
+ - 1
+
From edc2a466d1e76336ebc8579a441f9d62331deeda Mon Sep 17 00:00:00 2001
From: Yevhen Miroshnychenko
Date: Fri, 17 Mar 2017 11:08:53 +0200
Subject: [PATCH 0294/2045] MAGETWO-65544: Cloud deployment support for
configuration
---
composer.json | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 0ec646ed17908..288a8af412646 100644
--- a/composer.json
+++ b/composer.json
@@ -10,7 +10,8 @@
"magento/module-directory": "100.2.*",
"magento/module-checkout": "100.2.*",
"magento/module-backend": "100.2.*",
- "magento/module-payment": "100.2.*"
+ "magento/module-payment": "100.2.*",
+ "magento/module-config": "100.2.*"
},
"suggest": {
"magento/module-scalable-oms": "100.2.*"
From cef7cd2988363747d7441a5d1867cafd01d3300a Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 1 Mar 2017 12:58:33 +0200
Subject: [PATCH 0295/2045] 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
---
Observer/PlaceOrder.php | 4 +-
.../_files/expected_array.php | 1 -
Test/Unit/Observer/PlaceOrderTest.php | 254 ++++++++++++++++++
etc/signifyd_payment_mapping.xml | 12 -
4 files changed, 256 insertions(+), 15 deletions(-)
create mode 100644 Test/Unit/Observer/PlaceOrderTest.php
diff --git a/Observer/PlaceOrder.php b/Observer/PlaceOrder.php
index d260de96c5a9e..cf5b03026bfb3 100644
--- a/Observer/PlaceOrder.php
+++ b/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/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php b/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php
index 0578513ab228e..f4f60058be295 100644
--- a/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php
+++ b/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/Test/Unit/Observer/PlaceOrderTest.php b/Test/Unit/Observer/PlaceOrderTest.php
new file mode 100644
index 0000000000000..2c64b4a90101a
--- /dev/null
+++ b/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/etc/signifyd_payment_mapping.xml b/etc/signifyd_payment_mapping.xml
index cafea60dd2d79..24f722d9e7246 100644
--- a/etc/signifyd_payment_mapping.xml
+++ b/etc/signifyd_payment_mapping.xml
@@ -74,18 +74,6 @@
cybersource
PAYMENT_CARD
-
- checkmo
- CHECK
-
-
- banktransfer
- CHECK
-
-
- cashondelivery
- CASH
-
free
FREE
From 23602845bcaa210cd0317f3eb696c54f818334ad Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 1 Mar 2017 12:58:33 +0200
Subject: [PATCH 0296/2045] 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
---
Observer/PlaceOrderTest.php | 181 ++++++++++++++++++++++++++++++++++++
1 file changed, 181 insertions(+)
create mode 100644 Observer/PlaceOrderTest.php
diff --git a/Observer/PlaceOrderTest.php b/Observer/PlaceOrderTest.php
new file mode 100644
index 0000000000000..f0136aadd0cce
--- /dev/null
+++ b/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 b1fc798a942eb0eb1f82fec46f2478916d9cec81 Mon Sep 17 00:00:00 2001
From: Yevhen Miroshnychenko
Date: Fri, 17 Mar 2017 15:27:21 +0200
Subject: [PATCH 0297/2045] MAGETWO-65544: Cloud deployment support for
configuration
---
composer.json | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/composer.json b/composer.json
index 288a8af412646..6bd583ee19535 100644
--- a/composer.json
+++ b/composer.json
@@ -10,11 +10,11 @@
"magento/module-directory": "100.2.*",
"magento/module-checkout": "100.2.*",
"magento/module-backend": "100.2.*",
- "magento/module-payment": "100.2.*",
- "magento/module-config": "100.2.*"
+ "magento/module-payment": "100.2.*"
},
"suggest": {
- "magento/module-scalable-oms": "100.2.*"
+ "magento/module-scalable-oms": "100.2.*",
+ "magento/module-config": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
From e3fc7e4975bab8584eddc13b3460af1e85137b81 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 17 Mar 2017 18:08:59 +0200
Subject: [PATCH 0298/2045] MAGETWO-66178: Update marketing information, order
page and order list with new labels
---
Block/Adminhtml/CaseInfo.php | 46 -----------
Test/Unit/Block/Adminhtml/CaseInfoTest.php | 80 -------------------
etc/adminhtml/system.xml | 4 +-
i18n/en_US.csv | 3 +-
view/adminhtml/templates/case_info.phtml | 10 +--
.../ui_component/sales_order_grid.xml | 2 +-
6 files changed, 6 insertions(+), 139 deletions(-)
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index 43c138bb5150f..a17f9f58f2976 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/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/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/Test/Unit/Block/Adminhtml/CaseInfoTest.php
index 0d046800d9523..b1c2aa023aa82 100644
--- a/Test/Unit/Block/Adminhtml/CaseInfoTest.php
+++ b/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/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 1da4c75cea0c3..e0a5fad5bf334 100644
--- a/etc/adminhtml/system.xml
+++ b/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/i18n/en_US.csv b/i18n/en_US.csv
index dca6bcade0eb8..474efd51d03fe 100644
--- a/i18n/en_US.csv
+++ b/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/view/adminhtml/templates/case_info.phtml b/view/adminhtml/templates/case_info.phtml
index fef28b05ebb8c..07d4bb4f656d7 100644
--- a/view/adminhtml/templates/case_info.phtml
+++ b/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/view/adminhtml/ui_component/sales_order_grid.xml b/view/adminhtml/ui_component/sales_order_grid.xml
index 324dc089d3dfb..1a6515e69c3d6 100644
--- a/view/adminhtml/ui_component/sales_order_grid.xml
+++ b/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
From e01d3f635e0a5400eb6ad3e2d40b8735cc0cb74c Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 17 Mar 2017 18:08:59 +0200
Subject: [PATCH 0299/2045] MAGETWO-66178: Update marketing information, order
page and order list with new labels
---
Block/Adminhtml/CaseInfoTest.php | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/Block/Adminhtml/CaseInfoTest.php b/Block/Adminhtml/CaseInfoTest.php
index 1f55beea98a37..48b2b33513a6a 100644
--- a/Block/Adminhtml/CaseInfoTest.php
+++ b/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 6bd751c9a1613813446083dea1ccfb562ef0e468 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 20 Mar 2017 15:35:41 +0200
Subject: [PATCH 0300/2045] MAGETWO-65119: Create/update automated functional
tests
- Guarantee cancel flow using plugins now
- Webhook wait functions deleted
---
Test/Block/SignifydConsole/Webhooks.php | 39 ++-----------------------
1 file changed, 3 insertions(+), 36 deletions(-)
diff --git a/Test/Block/SignifydConsole/Webhooks.php b/Test/Block/SignifydConsole/Webhooks.php
index 396e9063fb446..1065dd50c3128 100644
--- a/Test/Block/SignifydConsole/Webhooks.php
+++ b/Test/Block/SignifydConsole/Webhooks.php
@@ -67,13 +67,6 @@ class Webhooks extends Block
*/
private $webhookDeleteButton = '[class*="webhook-delete"]';
- /**
- * Css selector of popup block for delete webhook confirmation.
- *
- * @var string
- */
- private $webhookDeleteConfirmOverlay = '[class="appriseOuter"]';
-
/**
* Css selector of confirming button for deleting webhook.
*
@@ -96,7 +89,7 @@ public function create($team)
continue;
}
- $this->addWebhook($handlerUrl, $webhookEventCode, $webhookEventName, $team);
+ $this->addWebhook($handlerUrl, $webhookEventCode, $team);
}
}
@@ -135,9 +128,6 @@ private function getWebhook($team, $webhookEventName)
/**
* Delete webhook element with confirmation popup.
*
- * Signifyd creates the same popup every time Selenium click on delete button,
- * so we need to wait that previous popup will be closed.
- *
* @param ElementInterface $webhook
* @return void
*/
@@ -145,13 +135,6 @@ private function deleteWebhook(ElementInterface $webhook)
{
$webhook->find($this->webhookDeleteButton)->click();
$this->_rootElement->find($this->webhookDeleteConfirmButton)->click();
-
- $this->_rootElement->waitUntil(
- function () {
- return $this->_rootElement->find($this->webhookDeleteConfirmOverlay)
- ->isPresent() ? null : true;
- }
- );
}
/**
@@ -159,20 +142,18 @@ function () {
*
* @param string $handlerUrl
* @param string $webhookEventCode
- * @param string $webhookEventName
* @param string $team
* @return void
*/
private function addWebhook(
$handlerUrl,
$webhookEventCode,
- $webhookEventName,
$team
) {
$this->setEvent($webhookEventCode);
$this->setTeam($team);
$this->setUrl($handlerUrl);
- $this->submit($webhookEventName, $handlerUrl);
+ $this->submit();
}
/**
@@ -216,25 +197,11 @@ private function setUrl($handlerUrl)
/**
* Add webhook element.
*
- * Selenium needs to wait until webhook will be added to grid
- * before proceed to next step.
- *
- * @param string $webhookEventName
- * @param string $handlerUrl
* @return void
*/
- private function submit($webhookEventName, $handlerUrl)
+ private function submit()
{
$this->_rootElement->find($this->webhookAddButton)->click();
-
- $this->_rootElement->waitUntil(
- function () use ($webhookEventName, $handlerUrl) {
- return $this->_rootElement->find(
- sprintf($this->webhookAddedElement, $handlerUrl, $webhookEventName),
- Locator::SELECTOR_XPATH
- )->isPresent() ? true : null;
- }
- );
}
/**
From 4873b1026397b01b962a414f2d61b04b336e99f7 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 20 Mar 2017 15:35:41 +0200
Subject: [PATCH 0301/2045] MAGETWO-65119: Create/update automated functional
tests
- Guarantee cancel flow using plugins now
- Webhook wait functions deleted
---
Observer/CancelOrder.php | 73 -------------------------------------
Plugin/OrderPlugin.php | 51 ++++++++++++++++++++++++++
Plugin/PaymentPlugin.php | 77 ++++++++++++++++++++++++++++++++++++++++
etc/adminhtml/di.xml | 6 ++++
etc/events.xml | 3 --
5 files changed, 134 insertions(+), 76 deletions(-)
delete mode 100644 Observer/CancelOrder.php
create mode 100644 Plugin/OrderPlugin.php
create mode 100644 Plugin/PaymentPlugin.php
diff --git a/Observer/CancelOrder.php b/Observer/CancelOrder.php
deleted file mode 100644
index 2710f89be3d24..0000000000000
--- a/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/Plugin/OrderPlugin.php b/Plugin/OrderPlugin.php
new file mode 100644
index 0000000000000..584f2d3e3ac2f
--- /dev/null
+++ b/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/Plugin/PaymentPlugin.php b/Plugin/PaymentPlugin.php
new file mode 100644
index 0000000000000..2949cd01fbfda
--- /dev/null
+++ b/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/etc/adminhtml/di.xml b/etc/adminhtml/di.xml
index 1c827afa99dbc..0a64a591ccd3b 100644
--- a/etc/adminhtml/di.xml
+++ b/etc/adminhtml/di.xml
@@ -7,4 +7,10 @@
-->
+
+
+
+
+
+
diff --git a/etc/events.xml b/etc/events.xml
index 17cbe99ec96a1..c5e69449793a5 100644
--- a/etc/events.xml
+++ b/etc/events.xml
@@ -9,7 +9,4 @@
-
-
-
From d944924da14debeaada9c1491fea068bae6a263b Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 20 Mar 2017 15:36:41 +0200
Subject: [PATCH 0302/2045] MAGETWO-66240: Add tags for tests that require
single flow run
---
.../AcceptPaymentWithSignifydGuaranteeDeclinedTest.php | 2 +-
.../AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml | 2 +-
Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php | 2 +-
Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml | 4 ++--
.../TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php | 2 +-
.../TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php b/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
index 952c0980f2b3e..aa91cd6db1e57 100644
--- a/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
+++ b/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
@@ -47,7 +47,7 @@ class AcceptPaymentWithSignifydGuaranteeDeclinedTest extends Scenario
{
/* tags */
const MVP = 'yes';
- const TEST_TYPE = '3rd_party_test';
+ const TEST_TYPE = '3rd_party_test_single_flow';
const SEVERITY = 'S2';
/* end tags */
diff --git a/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml b/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml
index 88815fd823889..796a2aa889016 100644
--- a/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml
+++ b/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml
@@ -28,7 +28,7 @@
sandbox_default
signifyd_guarantee_fraudulent
Processing
- test_type:3rd_party_test, severity:S2
+ test_type:3rd_party_test_single_flow, severity:S2
diff --git a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
index 4b958f09320bf..2f5072739f525 100644
--- a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
+++ b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
@@ -46,7 +46,7 @@ class CreateSignifydGuaranteeAndCancelOrderTest extends Scenario
{
/* tags */
const MVP = 'yes';
- const TEST_TYPE = '3rd_party_test';
+ const TEST_TYPE = '3rd_party_test_single_flow';
const SEVERITY = 'S1';
/* end tags */
diff --git a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
index 94745dba440fd..44eb3abbb82af 100644
--- a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
+++ b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
@@ -26,7 +26,7 @@
signifyd_us_shipping_address
sandbox_default
signifyd_guarantee_approve
- test_type:3rd_party_test, severity:S1
+ test_type:3rd_party_test_single_flow, severity:S1
@@ -54,7 +54,7 @@
signifyd_us_shipping_address
sandbox_default
signifyd_guarantee_decline
- test_type:3rd_party_test, severity:S1
+ test_type:3rd_party_test_single_flow, severity:S1
diff --git a/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
index 6816eebf9b725..9cde5c3b6be09 100644
--- a/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
+++ b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
@@ -52,7 +52,7 @@ class DenyPaymentWithSignifydGuaranteeDeclinedTest extends Scenario
{
/* tags */
const MVP = 'yes';
- const TEST_TYPE = '3rd_party_test';
+ const TEST_TYPE = '3rd_party_test_single_flow';
const SEVERITY = 'S2';
/* end tags */
diff --git a/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml
index 224bee8a087ab..63e124f386145 100644
--- a/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml
+++ b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml
@@ -28,7 +28,7 @@
signifyd_us_shipping_address
sandbox_default
signifyd_guarantee_fraudulent
- test_type:3rd_party_test, severity:S2
+ test_type:3rd_party_test_single_flow, severity:S2
From 9568a259a742ca5e83be4ad6abd7a7ef138a6497 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 20 Mar 2017 16:01:39 +0200
Subject: [PATCH 0303/2045] 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
---
.../CreateSignifydGuaranteeAndCancelOrderTest.xml | 2 --
...DenyPaymentWithSignifydGuaranteeDeclinedTest.xml | 1 +
Test/TestStep/SignifydObserveCaseStep.php | 13 +++++++++++++
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
index 44eb3abbb82af..7ce7c27ba9e2d 100644
--- a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
+++ b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
@@ -27,7 +27,6 @@
sandbox_default
signifyd_guarantee_approve
test_type:3rd_party_test_single_flow, severity:S1
-
@@ -55,7 +54,6 @@
sandbox_default
signifyd_guarantee_decline
test_type:3rd_party_test_single_flow, severity:S1
-
diff --git a/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml
index 63e124f386145..f1c262bc350e9 100644
--- a/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml
+++ b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml
@@ -33,6 +33,7 @@
+
diff --git a/Test/TestStep/SignifydObserveCaseStep.php b/Test/TestStep/SignifydObserveCaseStep.php
index e587304f1e08f..720cde37f5ccc 100644
--- a/Test/TestStep/SignifydObserveCaseStep.php
+++ b/Test/TestStep/SignifydObserveCaseStep.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Signifyd\Test\TestStep;
+use Magento\Customer\Test\TestStep\DeleteCustomerStep;
use Magento\Mtf\TestStep\TestStepInterface;
use Magento\Signifyd\Test\Constraint\AssertCaseInfoOnSignifydConsole;
use Magento\Signifyd\Test\Fixture\SignifydAddress;
@@ -59,6 +60,13 @@ class SignifydObserveCaseStep implements TestStepInterface
*/
private $signifydCancelOrderStep;
+ /**
+ * Delete customer step.
+ *
+ * @var DeleteCustomerStep
+ */
+ private $deleteCustomerStep;
+
/**
* Prices list.
*
@@ -80,6 +88,7 @@ class SignifydObserveCaseStep implements TestStepInterface
* @param SignifydNotifications $signifydNotifications
* @param SignifydData $signifydData
* @param SignifydCancelOrderStep $signifydCancelOrderStep
+ * @param DeleteCustomerStep $deleteCustomerStep
* @param array $prices
* @param $orderId
*/
@@ -90,6 +99,7 @@ public function __construct(
SignifydNotifications $signifydNotifications,
SignifydData $signifydData,
SignifydCancelOrderStep $signifydCancelOrderStep,
+ DeleteCustomerStep $deleteCustomerStep,
array $prices,
$orderId
) {
@@ -99,6 +109,7 @@ public function __construct(
$this->signifydNotifications = $signifydNotifications;
$this->signifydData = $signifydData;
$this->signifydCancelOrderStep = $signifydCancelOrderStep;
+ $this->deleteCustomerStep = $deleteCustomerStep;
$this->prices = $prices;
$this->orderId = $orderId;
}
@@ -126,12 +137,14 @@ public function run()
/**
* Cancel order if test fails, or in the end of variation.
+ * Cleanup customer for next variations.
*
* @return void
*/
public function cleanup()
{
$this->signifydCancelOrderStep->run();
+ $this->deleteCustomerStep->run();
}
/**
From 252a41c8cdb6e75c40060f9084a211fcc7fff01b Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 20 Mar 2017 16:01:39 +0200
Subject: [PATCH 0304/2045] 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
---
Plugin/OrderPlugin.php | 5 +-
Plugin/PaymentPlugin.php | 5 +-
Test/Unit/Observer/CancelOrderTest.php | 209 -------------------------
etc/adminhtml/di.xml | 6 -
etc/di.xml | 6 +
5 files changed, 12 insertions(+), 219 deletions(-)
delete mode 100644 Test/Unit/Observer/CancelOrderTest.php
diff --git a/Plugin/OrderPlugin.php b/Plugin/OrderPlugin.php
index 584f2d3e3ac2f..0d8ea10529c9e 100644
--- a/Plugin/OrderPlugin.php
+++ b/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/Plugin/PaymentPlugin.php b/Plugin/PaymentPlugin.php
index 2949cd01fbfda..3cec11bee82ce 100644
--- a/Plugin/PaymentPlugin.php
+++ b/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/Test/Unit/Observer/CancelOrderTest.php b/Test/Unit/Observer/CancelOrderTest.php
deleted file mode 100644
index f3d52e31776ef..0000000000000
--- a/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/etc/adminhtml/di.xml b/etc/adminhtml/di.xml
index 0a64a591ccd3b..1c827afa99dbc 100644
--- a/etc/adminhtml/di.xml
+++ b/etc/adminhtml/di.xml
@@ -7,10 +7,4 @@
-->
-
-
-
-
-
-
diff --git a/etc/di.xml b/etc/di.xml
index 878272a9531a2..9b7d32f6c8696 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -106,4 +106,10 @@
PaymentMethodConfigData
+
+
+
+
+
+
From fef8d3fe166f68e451ff97a4fb73028be878e7d1 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 20 Mar 2017 16:01:39 +0200
Subject: [PATCH 0305/2045] 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
---
{Observer => Plugin}/CancelOrderTest.php | 12 +-
Plugin/DenyPaymentTest.php | 218 +++++++++++++++++++++++
2 files changed, 225 insertions(+), 5 deletions(-)
rename {Observer => Plugin}/CancelOrderTest.php (92%)
create mode 100644 Plugin/DenyPaymentTest.php
diff --git a/Observer/CancelOrderTest.php b/Plugin/CancelOrderTest.php
similarity index 92%
rename from Observer/CancelOrderTest.php
rename to Plugin/CancelOrderTest.php
index 94f1779312f1f..4a7be25913a81 100644
--- a/Observer/CancelOrderTest.php
+++ b/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/Plugin/DenyPaymentTest.php b/Plugin/DenyPaymentTest.php
new file mode 100644
index 0000000000000..e6b249221a36f
--- /dev/null
+++ b/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 2b44fd1a9ec9e6f1664fa940ddf7f66d0a7e7cce Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Thu, 23 Mar 2017 11:51:33 +0200
Subject: [PATCH 0306/2045] MAGETWO-65119: Create/update automated functional
tests
- Reimplemented customer cleanup logic
---
...ymentWithSignifydGuaranteeDeclinedTest.php | 5 --
Test/TestStep/SignifydCancelOrderStep.php | 65 ++++++++--------
Test/TestStep/SignifydCreateCustomerStep.php | 76 +++++++++++++++++++
Test/TestStep/SignifydObserveCaseStep.php | 54 ++++++-------
Test/TestStep/UnholdAndCancelOrderStep.php | 47 +++++++++---
Test/etc/testcase.xml | 17 ++---
6 files changed, 171 insertions(+), 93 deletions(-)
create mode 100644 Test/TestStep/SignifydCreateCustomerStep.php
diff --git a/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
index 9cde5c3b6be09..8ba76696b0999 100644
--- a/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
+++ b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
@@ -6,11 +6,6 @@
namespace Magento\Signifyd\Test\TestCase;
use Magento\Mtf\TestCase\Scenario;
-use Magento\Sales\Test\Fixture\OrderInjectable;
-use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
-use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
-use Magento\Sales\Test\TestStep\CancelOrderStep;
-use Magento\Signifyd\Test\Page\SignifydConsole\SignifydNotifications;
/**
* * Preconditions:
diff --git a/Test/TestStep/SignifydCancelOrderStep.php b/Test/TestStep/SignifydCancelOrderStep.php
index b0bbd150e01cf..1b060fca2aa6f 100644
--- a/Test/TestStep/SignifydCancelOrderStep.php
+++ b/Test/TestStep/SignifydCancelOrderStep.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Signifyd\Test\TestStep;
+use Magento\Mtf\TestStep\TestStepFactory;
use Magento\Mtf\TestStep\TestStepInterface;
use Magento\Sales\Test\Fixture\OrderInjectable;
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
@@ -30,7 +31,7 @@ class SignifydCancelOrderStep implements TestStepInterface
*
* @var OrderInjectable
*/
- private $orderInjectable;
+ private $order;
/**
* Order View page.
@@ -40,48 +41,28 @@ class SignifydCancelOrderStep implements TestStepInterface
private $salesOrderView;
/**
- * Cancel order step.
+ * Test step factory.
*
- * @var CancelOrderStep
+ * @var TestStepFactory
*/
- private $cancelOrderStep;
-
- /**
- * Deny order step.
- *
- * @var DenyPaymentStep
- */
- private $denyPaymentStep;
-
- /**
- * Unhold order step.
- *
- * @var UnholdOrderStep
- */
- private $unholdOrderStep;
+ private $testStepFactory;
/**
* @param OrderIndex $orderIndex
- * @param OrderInjectable $orderInjectable
+ * @param OrderInjectable $order
* @param SalesOrderView $salesOrderView
- * @param CancelOrderStep $cancelOrderStep
- * @param DenyPaymentStep $denyPaymentStep
- * @param UnholdOrderStep $unholdOrderStep
+ * @param TestStepFactory $testStepFactory
*/
public function __construct(
OrderIndex $orderIndex,
- OrderInjectable $orderInjectable,
+ OrderInjectable $order,
SalesOrderView $salesOrderView,
- CancelOrderStep $cancelOrderStep,
- DenyPaymentStep $denyPaymentStep,
- UnholdOrderStep $unholdOrderStep
+ TestStepFactory $testStepFactory
) {
$this->orderIndex = $orderIndex;
- $this->orderInjectable = $orderInjectable;
+ $this->order = $order;
$this->salesOrderView = $salesOrderView;
- $this->cancelOrderStep = $cancelOrderStep;
- $this->denyPaymentStep = $denyPaymentStep;
- $this->unholdOrderStep = $unholdOrderStep;
+ $this->testStepFactory = $testStepFactory;
}
/**
@@ -91,20 +72,34 @@ public function run()
{
$this->orderIndex->open();
$this->orderIndex->getSalesOrderGrid()
- ->searchAndOpen(['id' => $this->orderInjectable->getId()]);
+ ->searchAndOpen(['id' => $this->order->getId()]);
switch ($this->salesOrderView->getOrderInfoBlock()->getOrderStatus()) {
case 'Suspected Fraud':
- $this->denyPaymentStep->run();
+ $this->getStepInstance(DenyPaymentStep::class)->run();
break;
case 'On Hold':
- $this->unholdOrderStep->run();
- $this->cancelOrderStep->run();
+ $this->getStepInstance(UnholdOrderStep::class)->run();
+ $this->getStepInstance(CancelOrderStep::class)->run();
break;
case 'Canceled':
break;
default:
- $this->cancelOrderStep->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/Test/TestStep/SignifydCreateCustomerStep.php b/Test/TestStep/SignifydCreateCustomerStep.php
new file mode 100644
index 0000000000000..ca57d7c3b97b6
--- /dev/null
+++ b/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]
+ );
+ }
+}
diff --git a/Test/TestStep/SignifydObserveCaseStep.php b/Test/TestStep/SignifydObserveCaseStep.php
index 720cde37f5ccc..3da7979b4e84b 100644
--- a/Test/TestStep/SignifydObserveCaseStep.php
+++ b/Test/TestStep/SignifydObserveCaseStep.php
@@ -5,8 +5,9 @@
*/
namespace Magento\Signifyd\Test\TestStep;
-use Magento\Customer\Test\TestStep\DeleteCustomerStep;
+use Magento\Mtf\TestStep\TestStepFactory;
use Magento\Mtf\TestStep\TestStepInterface;
+use Magento\Sales\Test\Fixture\OrderInjectable;
use Magento\Signifyd\Test\Constraint\AssertCaseInfoOnSignifydConsole;
use Magento\Signifyd\Test\Fixture\SignifydAddress;
use Magento\Signifyd\Test\Fixture\SignifydData;
@@ -53,20 +54,6 @@ class SignifydObserveCaseStep implements TestStepInterface
*/
private $signifydData;
- /**
- * Signifyd cancel order step.
- *
- * @var SignifydCancelOrderStep
- */
- private $signifydCancelOrderStep;
-
- /**
- * Delete customer step.
- *
- * @var DeleteCustomerStep
- */
- private $deleteCustomerStep;
-
/**
* Prices list.
*
@@ -75,11 +62,18 @@ class SignifydObserveCaseStep implements TestStepInterface
private $prices;
/**
- * Order id.
+ * Order fixture.
*
* @var string
*/
- private $orderId;
+ private $order;
+
+ /**
+ * Test step factory.
+ *
+ * @var TestStepFactory
+ */
+ private $testStepFactory;
/**
* @param AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole
@@ -87,10 +81,9 @@ class SignifydObserveCaseStep implements TestStepInterface
* @param SignifydCases $signifydCases
* @param SignifydNotifications $signifydNotifications
* @param SignifydData $signifydData
- * @param SignifydCancelOrderStep $signifydCancelOrderStep
- * @param DeleteCustomerStep $deleteCustomerStep
+ * @param OrderInjectable $order
+ * @param TestStepFactory $testStepFactory
* @param array $prices
- * @param $orderId
*/
public function __construct(
AssertCaseInfoOnSignifydConsole $assertCaseInfoOnSignifydConsole,
@@ -98,20 +91,18 @@ public function __construct(
SignifydCases $signifydCases,
SignifydNotifications $signifydNotifications,
SignifydData $signifydData,
- SignifydCancelOrderStep $signifydCancelOrderStep,
- DeleteCustomerStep $deleteCustomerStep,
- array $prices,
- $orderId
+ OrderInjectable $order,
+ TestStepFactory $testStepFactory,
+ array $prices
) {
$this->assertCaseInfo = $assertCaseInfoOnSignifydConsole;
$this->signifydAddress = $signifydAddress;
$this->signifydCases = $signifydCases;
$this->signifydNotifications = $signifydNotifications;
$this->signifydData = $signifydData;
- $this->signifydCancelOrderStep = $signifydCancelOrderStep;
- $this->deleteCustomerStep = $deleteCustomerStep;
+ $this->order = $order;
+ $this->testStepFactory = $testStepFactory;
$this->prices = $prices;
- $this->orderId = $orderId;
}
/**
@@ -130,21 +121,22 @@ public function run()
$this->signifydAddress,
$this->signifydData,
$this->prices,
- $this->orderId,
+ $this->order->getId(),
$this->getCustomerFullName($this->signifydAddress)
);
}
/**
* Cancel order if test fails, or in the end of variation.
- * Cleanup customer for next variations.
*
* @return void
*/
public function cleanup()
{
- $this->signifydCancelOrderStep->run();
- $this->deleteCustomerStep->run();
+ $this->testStepFactory->create(
+ SignifydCancelOrderStep::class,
+ ['order' => $this->order]
+ )->run();
}
/**
diff --git a/Test/TestStep/UnholdAndCancelOrderStep.php b/Test/TestStep/UnholdAndCancelOrderStep.php
index 30e810a61ab62..6e0dd05f85c2b 100644
--- a/Test/TestStep/UnholdAndCancelOrderStep.php
+++ b/Test/TestStep/UnholdAndCancelOrderStep.php
@@ -5,10 +5,15 @@
*/
namespace Magento\Signifyd\Test\TestStep;
+use Magento\Mtf\TestStep\TestStepFactory;
use Magento\Mtf\TestStep\TestStepInterface;
+use Magento\Sales\Test\Fixture\OrderInjectable;
use Magento\Sales\Test\TestStep\CancelOrderStep;
use Magento\Sales\Test\TestStep\UnholdOrderStep;
+/**
+ * Unhold and cancel order.
+ */
class UnholdAndCancelOrderStep implements TestStepInterface
{
/**
@@ -19,28 +24,32 @@ class UnholdAndCancelOrderStep implements TestStepInterface
private $placeOrderStatus;
/**
- * @var CancelOrderStep
+ * Order fixture.
+ *
+ * @var OrderInjectable
*/
- private $cancelOrderStep;
+ private $order;
/**
- * @var UnholdOrderStep
+ * Test step factory.
+ *
+ * @var TestStepFactory
*/
- private $unholdOrderStep;
+ private $testStepFactory;
/**
* @param string $placeOrderStatus
- * @param CancelOrderStep $cancelOrderStep
- * @param UnholdOrderStep $unholdOrderStep
+ * @param OrderInjectable $order
+ * @param TestStepFactory $testStepFactory
*/
public function __construct(
$placeOrderStatus,
- CancelOrderStep $cancelOrderStep,
- UnholdOrderStep $unholdOrderStep
+ OrderInjectable $order,
+ TestStepFactory $testStepFactory
) {
$this->placeOrderStatus = $placeOrderStatus;
- $this->cancelOrderStep = $cancelOrderStep;
- $this->unholdOrderStep = $unholdOrderStep;
+ $this->order = $order;
+ $this->testStepFactory = $testStepFactory;
}
/**
@@ -53,9 +62,23 @@ public function __construct(
public function run()
{
if ($this->placeOrderStatus === 'On Hold') {
- $this->unholdOrderStep->run();
+ $this->getStepInstance(UnholdOrderStep::class)->run();
}
- $this->cancelOrderStep->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/Test/etc/testcase.xml b/Test/etc/testcase.xml
index ab7238f48fb33..794f596928e57 100644
--- a/Test/etc/testcase.xml
+++ b/Test/etc/testcase.xml
@@ -12,13 +12,12 @@
-
-
+
+
-
-
+
@@ -30,11 +29,10 @@
-
-
+
+
-
@@ -47,11 +45,10 @@
-
-
+
+
-
From 504f03c76357e991c25c0fe3444e340b0e67e6ad Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 27 Mar 2017 13:35:17 +0300
Subject: [PATCH 0307/2045] MAGETWO-65119: Create/update automated functional
tests
- Added cleanup for customer
---
Test/TestStep/SignifydCreateCustomerStep.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/Test/TestStep/SignifydCreateCustomerStep.php b/Test/TestStep/SignifydCreateCustomerStep.php
index ca57d7c3b97b6..039c8c50da3f9 100644
--- a/Test/TestStep/SignifydCreateCustomerStep.php
+++ b/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 bd39aca4e024e17f875fb0b7420aa820a368e042 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 27 Mar 2017 16:52:24 +0300
Subject: [PATCH 0308/2045] MAGETWO-65119: Create/update automated functional
tests
- Syncronized checks with new requirements
---
.../Adminhtml/Order/View/FraudProtection.php | 34 -------------------
Test/Constraint/AssertCaseInfoOnAdmin.php | 31 -----------------
Test/Fixture/SignifydData.xml | 2 --
Test/Repository/SignifydData.xml | 6 ----
4 files changed, 73 deletions(-)
diff --git a/Test/Block/Adminhtml/Order/View/FraudProtection.php b/Test/Block/Adminhtml/Order/View/FraudProtection.php
index b3daee7725f13..b6b4ef0772ab2 100644
--- a/Test/Block/Adminhtml/Order/View/FraudProtection.php
+++ b/Test/Block/Adminhtml/Order/View/FraudProtection.php
@@ -12,13 +12,6 @@
*/
class FraudProtection extends Block
{
- /**
- * Case Status.
- *
- * @var string
- */
- private $caseStatus = 'td.col-case-status';
-
/**
* Case Guarantee Disposition.
*
@@ -26,23 +19,6 @@ class FraudProtection extends Block
*/
private $caseGuaranteeDisposition = 'td.col-guarantee-disposition';
- /**
- * Case Review Disposition.
- *
- * @var string
- */
- private $caseReviewDisposition = 'td.col-case-review';
-
- /**
- * Get Case Status information.
- *
- * @return string
- */
- public function getCaseStatus()
- {
- return $this->_rootElement->find($this->caseStatus)->getText();
- }
-
/**
* Get Case Guarantee Disposition status.
*
@@ -52,14 +28,4 @@ public function getCaseGuaranteeDisposition()
{
return $this->_rootElement->find($this->caseGuaranteeDisposition)->getText();
}
-
- /**
- * Get Case Review Disposition status.
- *
- * @return string
- */
- public function getCaseReviewDisposition()
- {
- return $this->_rootElement->find($this->caseReviewDisposition)->getText();
- }
}
diff --git a/Test/Constraint/AssertCaseInfoOnAdmin.php b/Test/Constraint/AssertCaseInfoOnAdmin.php
index 6071b0ff90c71..411e2b1c5096e 100644
--- a/Test/Constraint/AssertCaseInfoOnAdmin.php
+++ b/Test/Constraint/AssertCaseInfoOnAdmin.php
@@ -58,25 +58,8 @@ public function processAssert(
$this->signifydData = $signifydData;
$this->orderId = $orderId;
- $this->checkCaseStatus();
$this->checkCaseGuaranteeDisposition();
- $this->checkCaseReviewDisposition();
}
-
- /**
- * Checks case status is correct.
- *
- * @return void
- */
- private function checkCaseStatus()
- {
- \PHPUnit_Framework_Assert::assertEquals(
- $this->signifydData->getCaseStatus(),
- $this->orderView->getFraudProtectionBlock()->getCaseStatus(),
- 'Case status is wrong for order #' . $this->orderId
- );
- }
-
/**
* Checks case guarantee disposition is correct.
*
@@ -91,20 +74,6 @@ private function checkCaseGuaranteeDisposition()
);
}
- /**
- * Checks case review disposition is correct.
- *
- * @return void
- */
- private function checkCaseReviewDisposition()
- {
- \PHPUnit_Framework_Assert::assertEquals(
- $this->signifydData->getReviewDisposition(),
- $this->orderView->getFraudProtectionBlock()->getCaseReviewDisposition(),
- 'Case Review Disposition status is wrong for order #' . $this->orderId
- );
- }
-
/**
* @inheritdoc
*/
diff --git a/Test/Fixture/SignifydData.xml b/Test/Fixture/SignifydData.xml
index 91a5425ce4a8f..6092943ae48eb 100644
--- a/Test/Fixture/SignifydData.xml
+++ b/Test/Fixture/SignifydData.xml
@@ -12,9 +12,7 @@
repository_class="Magento\Signifyd\Test\Repository\SignifydData"
class="Magento\Signifyd\Test\Fixture\SignifydData">
-
-
diff --git a/Test/Repository/SignifydData.xml b/Test/Repository/SignifydData.xml
index 68cffb97c22e7..dc7c110e8a90e 100644
--- a/Test/Repository/SignifydData.xml
+++ b/Test/Repository/SignifydData.xml
@@ -9,9 +9,7 @@
autotest
- Open
Good
- Good
Approved
CVV2 Match (M)
Full match (Y)
@@ -19,9 +17,7 @@
autotest
- Open
Bad
- Fraudulent
Declined
CVV2 Match (M)
Full match (Y)
@@ -29,9 +25,7 @@
autotest
- Open
Bad
- Fraudulent
Declined
Unavailable (U)
GBP 10.00
From 0230e254344a786563551c09f3267582f97f94a5 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Tue, 28 Mar 2017 14:18:30 +0300
Subject: [PATCH 0309/2045] MAGETWO-65119: Create/update automated functional
tests
- Updated tests with new variables
---
Test/Constraint/AssertCaseInfoOnAdmin.php | 1 +
Test/Repository/ConfigData.xml | 4 ++--
Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml | 2 ++
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Test/Constraint/AssertCaseInfoOnAdmin.php b/Test/Constraint/AssertCaseInfoOnAdmin.php
index 411e2b1c5096e..4a3f0b39b08f7 100644
--- a/Test/Constraint/AssertCaseInfoOnAdmin.php
+++ b/Test/Constraint/AssertCaseInfoOnAdmin.php
@@ -60,6 +60,7 @@ public function processAssert(
$this->checkCaseGuaranteeDisposition();
}
+
/**
* Checks case guarantee disposition is correct.
*
diff --git a/Test/Repository/ConfigData.xml b/Test/Repository/ConfigData.xml
index c4d89ea5fd890..d48ae21429703 100644
--- a/Test/Repository/ConfigData.xml
+++ b/Test/Repository/ConfigData.xml
@@ -14,11 +14,11 @@
- Yes
- 1
-
+
- fraud_protection
- 1
- - SIGNIFYD_API_KEY
+ - SIGNIFYD_CONFIG_API_KEY
- fraud_protection
diff --git a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
index 7ce7c27ba9e2d..617d072781e03 100644
--- a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
+++ b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
@@ -17,6 +17,7 @@
Flat Rate
Fixed
braintree
+ braintree
15.00
USD
visa_default
@@ -44,6 +45,7 @@
Flat Rate
Fixed
braintree
+ braintree
15.00
USD
visa_default
From a222a5cb72ba5e1004b914a9d43fbf0b4a852ebe Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 29 Mar 2017 18:06:36 +0300
Subject: [PATCH 0310/2045] MAGETWO-65119: Create/update automated functional
tests
- Fixed usage of registry in plugin
---
Plugin/PaymentPlugin.php | 31 ++++++++++---------------------
1 file changed, 10 insertions(+), 21 deletions(-)
diff --git a/Plugin/PaymentPlugin.php b/Plugin/PaymentPlugin.php
index 3cec11bee82ce..031cdac6738b2 100644
--- a/Plugin/PaymentPlugin.php
+++ b/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 30c14bab9206006b35fb6b32ccb0fdbb6399e87a Mon Sep 17 00:00:00 2001
From: Oleksii Korshenko
Date: Wed, 29 Mar 2017 19:43:04 +0300
Subject: [PATCH 0311/2045] MAGETWO-66875: Remove the copyright year from file
headers #8648
---
Api/CaseCreationServiceInterface.php | 2 +-
Api/CaseManagementInterface.php | 2 +-
Api/CaseRepositoryInterface.php | 2 +-
Api/Data/CaseInterface.php | 2 +-
Api/Data/CaseSearchResultsInterface.php | 2 +-
Api/GuaranteeCancelingServiceInterface.php | 2 +-
Api/GuaranteeCreationServiceInterface.php | 2 +-
Block/Adminhtml/CaseInfo.php | 2 +-
Block/Adminhtml/System/Config/Field/WebhookUrl.php | 2 +-
Block/Adminhtml/System/Config/Fieldset/Info.php | 2 +-
Block/Fingerprint.php | 2 +-
Controller/Webhooks/Handler.php | 2 +-
Model/CaseEntity.php | 2 +-
Model/CaseManagement.php | 2 +-
Model/CaseRepository.php | 2 +-
Model/CaseServices/CreationService.php | 2 +-
Model/CaseServices/StubUpdatingService.php | 2 +-
Model/CaseServices/UpdatingService.php | 2 +-
Model/CaseServices/UpdatingServiceFactory.php | 2 +-
Model/CaseServices/UpdatingServiceInterface.php | 2 +-
Model/CommentsHistoryUpdater.php | 2 +-
Model/Config.php | 2 +-
Model/CustomerOrders.php | 2 +-
Model/Guarantee/CancelGuaranteeAbility.php | 2 +-
Model/Guarantee/CancelingService.php | 2 +-
Model/Guarantee/CreateGuaranteeAbility.php | 2 +-
Model/Guarantee/CreationService.php | 2 +-
Model/MessageGenerators/CaseRescore.php | 2 +-
Model/MessageGenerators/GeneratorException.php | 2 +-
Model/MessageGenerators/GeneratorFactory.php | 2 +-
Model/MessageGenerators/GeneratorInterface.php | 2 +-
Model/MessageGenerators/PatternGenerator.php | 2 +-
Model/PaymentMethodMapper/PaymentMethodMapper.php | 2 +-
Model/PaymentMethodMapper/XmlToArrayConfigConverter.php | 2 +-
Model/PaymentVerificationFactory.php | 2 +-
Model/PredefinedVerificationCode.php | 2 +-
Model/QuoteSession/Adminhtml/BackendSession.php | 2 +-
Model/QuoteSession/FrontendSession.php | 2 +-
Model/QuoteSession/QuoteSessionInterface.php | 2 +-
Model/ResourceModel/CaseEntity.php | 2 +-
Model/ResourceModel/CaseEntity/Collection.php | 2 +-
Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php | 2 +-
Model/SalesOrderGrid/OrderGridUpdater.php | 2 +-
Model/SignifydGateway/ApiCallException.php | 2 +-
Model/SignifydGateway/ApiClient.php | 2 +-
Model/SignifydGateway/Client/HttpClientFactory.php | 2 +-
Model/SignifydGateway/Client/RequestBuilder.php | 2 +-
Model/SignifydGateway/Client/RequestSender.php | 2 +-
Model/SignifydGateway/Client/ResponseHandler.php | 2 +-
Model/SignifydGateway/Debugger/BlackHole.php | 2 +-
Model/SignifydGateway/Debugger/DebuggerFactory.php | 2 +-
Model/SignifydGateway/Debugger/DebuggerInterface.php | 2 +-
Model/SignifydGateway/Debugger/Log.php | 2 +-
Model/SignifydGateway/Gateway.php | 2 +-
Model/SignifydGateway/GatewayException.php | 2 +-
Model/SignifydGateway/Request/AddressBuilder.php | 2 +-
Model/SignifydGateway/Request/CardBuilder.php | 2 +-
Model/SignifydGateway/Request/ClientVersionBuilder.php | 2 +-
Model/SignifydGateway/Request/CreateCaseBuilder.php | 2 +-
Model/SignifydGateway/Request/CreateCaseBuilderInterface.php | 2 +-
Model/SignifydGateway/Request/PurchaseBuilder.php | 2 +-
Model/SignifydGateway/Request/RecipientBuilder.php | 2 +-
Model/SignifydGateway/Request/SellerBuilder.php | 2 +-
Model/SignifydGateway/Request/UserAccountBuilder.php | 2 +-
Model/SignifydGateway/Response/WebhookMessage.php | 2 +-
Model/SignifydGateway/Response/WebhookMessageReader.php | 2 +-
Model/SignifydGateway/Response/WebhookRequest.php | 2 +-
Model/SignifydGateway/Response/WebhookRequestValidator.php | 2 +-
Model/SignifydOrderSessionId.php | 2 +-
Observer/CancelOrder.php | 2 +-
Observer/PlaceOrder.php | 2 +-
Setup/InstallSchema.php | 2 +-
Test/Unit/Block/Adminhtml/CaseInfoTest.php | 2 +-
Test/Unit/Controller/Webhooks/HandlerTest.php | 2 +-
Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php | 2 +-
Test/Unit/Model/CaseServices/UpdatingServiceTest.php | 2 +-
Test/Unit/Model/CommentsHistoryUpdaterTest.php | 2 +-
Test/Unit/Model/CustomerOrdersTest.php | 2 +-
Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php | 2 +-
Test/Unit/Model/Guarantee/CancelingServiceTest.php | 2 +-
Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php | 2 +-
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 +-
Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php | 2 +-
.../PaymentMethodMapper/_files/signifyd_payment_mapping.xml | 2 +-
Test/Unit/Model/PaymentVerificationFactoryTest.php | 2 +-
Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php | 2 +-
.../Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php | 2 +-
Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php | 2 +-
Test/Unit/Model/SignifydGateway/GatewayTest.php | 2 +-
.../Model/SignifydGateway/Response/WebhookMessageReaderTest.php | 2 +-
.../SignifydGateway/Response/WebhookRequestValidatorTest.php | 2 +-
Test/Unit/Model/SignifydOrderSessionIdTest.php | 2 +-
Test/Unit/Observer/CancelOrderTest.php | 2 +-
Test/Unit/Observer/PlaceOrderTest.php | 2 +-
Ui/Component/Listing/Column/Guarantee/Options.php | 2 +-
etc/acl.xml | 2 +-
etc/adminhtml/di.xml | 2 +-
etc/adminhtml/routes.xml | 2 +-
etc/adminhtml/system.xml | 2 +-
etc/config.xml | 2 +-
etc/di.xml | 2 +-
etc/events.xml | 2 +-
etc/frontend/di.xml | 2 +-
etc/frontend/routes.xml | 2 +-
etc/module.xml | 2 +-
etc/signifyd_payment_mapping.xml | 2 +-
etc/signifyd_payment_mapping.xsd | 2 +-
registration.php | 2 +-
view/adminhtml/layout/sales_order_view.xml | 2 +-
view/adminhtml/templates/case_info.phtml | 2 +-
view/adminhtml/ui_component/sales_order_grid.xml | 2 +-
view/adminhtml/web/js/request-send.js | 2 +-
view/frontend/layout/checkout_cart_index.xml | 2 +-
view/frontend/layout/checkout_index_index.xml | 2 +-
view/frontend/templates/fingerprint.phtml | 2 +-
119 files changed, 119 insertions(+), 119 deletions(-)
diff --git a/Api/CaseCreationServiceInterface.php b/Api/CaseCreationServiceInterface.php
index 3cf727ee696eb..4664431ead85f 100644
--- a/Api/CaseCreationServiceInterface.php
+++ b/Api/CaseCreationServiceInterface.php
@@ -1,6 +1,6 @@
diff --git a/Test/Unit/Model/PaymentVerificationFactoryTest.php b/Test/Unit/Model/PaymentVerificationFactoryTest.php
index 6c4ffaf7c142e..377c83a340a01 100644
--- a/Test/Unit/Model/PaymentVerificationFactoryTest.php
+++ b/Test/Unit/Model/PaymentVerificationFactoryTest.php
@@ -1,6 +1,6 @@
diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml
index 1c827afa99dbc..c771d67216d43 100644
--- a/etc/adminhtml/di.xml
+++ b/etc/adminhtml/di.xml
@@ -1,7 +1,7 @@
diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml
index 1f94759c1b7b6..c078ab3c8c4c1 100644
--- a/etc/adminhtml/routes.xml
+++ b/etc/adminhtml/routes.xml
@@ -1,7 +1,7 @@
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 1da4c75cea0c3..237e3076f8feb 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -1,7 +1,7 @@
diff --git a/etc/config.xml b/etc/config.xml
index a02a363358533..804342a14bb08 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -1,7 +1,7 @@
diff --git a/etc/di.xml b/etc/di.xml
index f01e5c0a1b4b6..445e95ce9e516 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -1,7 +1,7 @@
diff --git a/etc/events.xml b/etc/events.xml
index 17cbe99ec96a1..6877d9c1bb96f 100644
--- a/etc/events.xml
+++ b/etc/events.xml
@@ -1,7 +1,7 @@
diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml
index 69a57a123344f..08a690d1a9930 100644
--- a/etc/frontend/di.xml
+++ b/etc/frontend/di.xml
@@ -1,7 +1,7 @@
diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml
index a21f612e54bba..5803f59d8624b 100644
--- a/etc/frontend/routes.xml
+++ b/etc/frontend/routes.xml
@@ -1,7 +1,7 @@
diff --git a/etc/module.xml b/etc/module.xml
index 81d97d6fdc0d4..d5adcba88ad9a 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -1,7 +1,7 @@
diff --git a/etc/signifyd_payment_mapping.xml b/etc/signifyd_payment_mapping.xml
index 24f722d9e7246..096a968167173 100644
--- a/etc/signifyd_payment_mapping.xml
+++ b/etc/signifyd_payment_mapping.xml
@@ -1,7 +1,7 @@
diff --git a/registration.php b/registration.php
index f3a11ab0a1183..9f35e0bb2f41b 100644
--- a/registration.php
+++ b/registration.php
@@ -1,6 +1,6 @@
diff --git a/view/adminhtml/templates/case_info.phtml b/view/adminhtml/templates/case_info.phtml
index fef28b05ebb8c..3d8c42ce490d7 100644
--- a/view/adminhtml/templates/case_info.phtml
+++ b/view/adminhtml/templates/case_info.phtml
@@ -1,6 +1,6 @@
diff --git a/view/adminhtml/web/js/request-send.js b/view/adminhtml/web/js/request-send.js
index 881bb27477800..f55170336ca03 100644
--- a/view/adminhtml/web/js/request-send.js
+++ b/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/view/frontend/layout/checkout_cart_index.xml b/view/frontend/layout/checkout_cart_index.xml
index a9ea616735d56..30472ae5e9ae9 100644
--- a/view/frontend/layout/checkout_cart_index.xml
+++ b/view/frontend/layout/checkout_cart_index.xml
@@ -1,7 +1,7 @@
diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml
index a9ea616735d56..30472ae5e9ae9 100644
--- a/view/frontend/layout/checkout_index_index.xml
+++ b/view/frontend/layout/checkout_index_index.xml
@@ -1,7 +1,7 @@
diff --git a/view/frontend/templates/fingerprint.phtml b/view/frontend/templates/fingerprint.phtml
index a68d46c7da2ef..fdcecf7d1865e 100644
--- a/view/frontend/templates/fingerprint.phtml
+++ b/view/frontend/templates/fingerprint.phtml
@@ -1,6 +1,6 @@
Date: Wed, 29 Mar 2017 19:43:04 +0300
Subject: [PATCH 0312/2045] MAGETWO-66875: Remove the copyright year from file
headers #8648
---
Test/Block/Adminhtml/Order/Grid.php | 2 +-
Test/Block/Adminhtml/Order/View/FraudProtection.php | 2 +-
Test/Block/SignifydConsole/CaseInfo.php | 2 +-
Test/Block/SignifydConsole/CaseSearch.php | 2 +-
Test/Block/SignifydConsole/SignifydLogin.php | 2 +-
Test/Block/SignifydConsole/Webhooks.php | 2 +-
Test/Constraint/AssertCaseInfoOnAdmin.php | 2 +-
Test/Constraint/AssertCaseInfoOnSignifydConsole.php | 2 +-
Test/Constraint/AssertSignifydCaseInCommentsHistory.php | 2 +-
Test/Constraint/AssertSignifydCaseInOrdersGrid.php | 2 +-
.../AssertSignifydGuaranteeCancelInCommentsHistory.php | 2 +-
Test/Fixture/SignifydAccount.xml | 2 +-
Test/Fixture/SignifydAddress.xml | 2 +-
Test/Fixture/SignifydAddress/Firstname.php | 2 +-
Test/Page/Adminhtml/OrdersGrid.xml | 2 +-
Test/Page/Adminhtml/SalesOrderView.xml | 2 +-
Test/Page/SignifydConsole/SignifydCases.xml | 2 +-
Test/Page/SignifydConsole/SignifydLogin.xml | 2 +-
Test/Page/SignifydConsole/SignifydNotifications.xml | 2 +-
Test/Repository/Address.xml | 2 +-
Test/Repository/ConfigData.xml | 2 +-
Test/Repository/Customer.xml | 2 +-
Test/Repository/SignifydAccount.xml | 2 +-
Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php | 2 +-
Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml | 2 +-
Test/TestStep/OpenOrderGridStep.php | 2 +-
Test/TestStep/SignifydFillShippingAddressStep.php | 2 +-
Test/TestStep/SignifydLoginStep.php | 4 ++--
Test/TestStep/SignifydObserveCaseStep.php | 2 +-
Test/TestStep/SignifydSetWebhookHandlersStep.php | 2 +-
Test/etc/di.xml | 2 +-
Test/etc/testcase.xml | 2 +-
32 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/Test/Block/Adminhtml/Order/Grid.php b/Test/Block/Adminhtml/Order/Grid.php
index ba1c7a293cc46..54f580f48dcf4 100644
--- a/Test/Block/Adminhtml/Order/Grid.php
+++ b/Test/Block/Adminhtml/Order/Grid.php
@@ -1,6 +1,6 @@
diff --git a/Test/Fixture/SignifydAddress.xml b/Test/Fixture/SignifydAddress.xml
index ccdcfea112836..02b5cc8211d89 100644
--- a/Test/Fixture/SignifydAddress.xml
+++ b/Test/Fixture/SignifydAddress.xml
@@ -1,7 +1,7 @@
diff --git a/Test/Fixture/SignifydAddress/Firstname.php b/Test/Fixture/SignifydAddress/Firstname.php
index 2a38ba977f7c7..9e4930484eef0 100644
--- a/Test/Fixture/SignifydAddress/Firstname.php
+++ b/Test/Fixture/SignifydAddress/Firstname.php
@@ -1,6 +1,6 @@
diff --git a/Test/Page/Adminhtml/SalesOrderView.xml b/Test/Page/Adminhtml/SalesOrderView.xml
index e869f9892e7c9..36d77723dfcee 100644
--- a/Test/Page/Adminhtml/SalesOrderView.xml
+++ b/Test/Page/Adminhtml/SalesOrderView.xml
@@ -1,7 +1,7 @@
diff --git a/Test/Page/SignifydConsole/SignifydCases.xml b/Test/Page/SignifydConsole/SignifydCases.xml
index da483a0db4d49..cfe889bb8de44 100644
--- a/Test/Page/SignifydConsole/SignifydCases.xml
+++ b/Test/Page/SignifydConsole/SignifydCases.xml
@@ -1,7 +1,7 @@
diff --git a/Test/Page/SignifydConsole/SignifydLogin.xml b/Test/Page/SignifydConsole/SignifydLogin.xml
index 00aa31b936556..5fe5da6d28013 100644
--- a/Test/Page/SignifydConsole/SignifydLogin.xml
+++ b/Test/Page/SignifydConsole/SignifydLogin.xml
@@ -1,7 +1,7 @@
diff --git a/Test/Page/SignifydConsole/SignifydNotifications.xml b/Test/Page/SignifydConsole/SignifydNotifications.xml
index d12d2550724d5..dd12f14c28800 100644
--- a/Test/Page/SignifydConsole/SignifydNotifications.xml
+++ b/Test/Page/SignifydConsole/SignifydNotifications.xml
@@ -1,7 +1,7 @@
diff --git a/Test/Repository/Address.xml b/Test/Repository/Address.xml
index 99d15abb97031..a534cbc6107fe 100644
--- a/Test/Repository/Address.xml
+++ b/Test/Repository/Address.xml
@@ -1,7 +1,7 @@
diff --git a/Test/Repository/ConfigData.xml b/Test/Repository/ConfigData.xml
index c4d89ea5fd890..2b0acc22755c5 100644
--- a/Test/Repository/ConfigData.xml
+++ b/Test/Repository/ConfigData.xml
@@ -1,7 +1,7 @@
diff --git a/Test/Repository/Customer.xml b/Test/Repository/Customer.xml
index a21b01fc40bf0..b45e3d01b8ec8 100644
--- a/Test/Repository/Customer.xml
+++ b/Test/Repository/Customer.xml
@@ -1,7 +1,7 @@
diff --git a/Test/Repository/SignifydAccount.xml b/Test/Repository/SignifydAccount.xml
index 6952df564d797..4d3dd5229eae3 100644
--- a/Test/Repository/SignifydAccount.xml
+++ b/Test/Repository/SignifydAccount.xml
@@ -1,7 +1,7 @@
diff --git a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
index 4baeeb638adb1..2104d1cb1e27d 100644
--- a/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
+++ b/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
@@ -1,6 +1,6 @@
diff --git a/Test/TestStep/OpenOrderGridStep.php b/Test/TestStep/OpenOrderGridStep.php
index b249a954b40b4..5e33946b09016 100644
--- a/Test/TestStep/OpenOrderGridStep.php
+++ b/Test/TestStep/OpenOrderGridStep.php
@@ -1,6 +1,6 @@
signifydLogin->open();
-
+
if ($this->signifydLogin->getLoginBlock()->isVisible()) {
$this->signifydLogin->getLoginBlock()->fill($this->signifydAccount);
$this->signifydLogin->getLoginBlock()->login();
diff --git a/Test/TestStep/SignifydObserveCaseStep.php b/Test/TestStep/SignifydObserveCaseStep.php
index 0ac91665eae96..9f4212dca3480 100644
--- a/Test/TestStep/SignifydObserveCaseStep.php
+++ b/Test/TestStep/SignifydObserveCaseStep.php
@@ -1,6 +1,6 @@
diff --git a/Test/etc/testcase.xml b/Test/etc/testcase.xml
index b12952efbac8b..9b34ac4eb8b9d 100644
--- a/Test/etc/testcase.xml
+++ b/Test/etc/testcase.xml
@@ -1,7 +1,7 @@
From 6b149cd40b4ece639187717982f527771594570d Mon Sep 17 00:00:00 2001
From: Oleksii Korshenko
Date: Wed, 29 Mar 2017 19:43:04 +0300
Subject: [PATCH 0313/2045] MAGETWO-66875: Remove the copyright year from file
headers #8648
---
Block/Adminhtml/CaseInfoTest.php | 2 +-
Block/FingerprintTest.php | 2 +-
Controller/Webhooks/HandlerTest.php | 2 +-
Model/CaseManagementTest.php | 2 +-
Model/CaseRepositoryTest.php | 2 +-
Model/CaseServices/CreationServiceTest.php | 2 +-
Model/CaseServices/UpdatingServiceTest.php | 2 +-
Model/Guarantee/CancelingServiceTest.php | 2 +-
Model/Guarantee/CreationServiceTest.php | 2 +-
Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 4 ++--
Observer/CancelOrderTest.php | 2 +-
Observer/PlaceOrderTest.php | 2 +-
_files/approved_case.php | 2 +-
_files/case.php | 2 +-
_files/customer.php | 2 +-
_files/multiple_cases.php | 2 +-
_files/order_with_customer_and_two_simple_products.php | 2 +-
_files/order_with_guest_and_virtual_product.php | 2 +-
_files/store.php | 2 +-
19 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/Block/Adminhtml/CaseInfoTest.php b/Block/Adminhtml/CaseInfoTest.php
index 1f55beea98a37..ee8ef25e481eb 100644
--- a/Block/Adminhtml/CaseInfoTest.php
+++ b/Block/Adminhtml/CaseInfoTest.php
@@ -1,6 +1,6 @@
objectManager->create(Order::class);
$order->loadByIncrementId('100000001');
-
+
$orderItems = $order->getAllItems();
$product = $orderItems[0]->getProduct();
$payment = $order->getPayment();
diff --git a/Observer/CancelOrderTest.php b/Observer/CancelOrderTest.php
index 94f1779312f1f..852322f8f1ca0 100644
--- a/Observer/CancelOrderTest.php
+++ b/Observer/CancelOrderTest.php
@@ -1,6 +1,6 @@
Date: Fri, 31 Mar 2017 14:09:39 +0300
Subject: [PATCH 0314/2045] MAGETWO-63642: Update Order Status Based on
Signifyd Guarantee Status
- Fixed copyrights
---
Model/OrderStateService.php | 2 +-
Plugin/OrderPlugin.php | 2 +-
Plugin/PaymentPlugin.php | 2 +-
Test/Unit/Model/OrderStateServiceTest.php | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Model/OrderStateService.php b/Model/OrderStateService.php
index 8acb9e28a52eb..47e3c7a4d1f14 100644
--- a/Model/OrderStateService.php
+++ b/Model/OrderStateService.php
@@ -1,6 +1,6 @@
Date: Fri, 31 Mar 2017 14:09:39 +0300
Subject: [PATCH 0315/2045] MAGETWO-63642: Update Order Status Based on
Signifyd Guarantee Status
- Fixed copyrights
---
.../AssertAwaitingSignifydGuaranteeInCommentsHistory.php | 2 +-
Test/Fixture/SignifydData.xml | 2 +-
Test/Repository/SignifydData.xml | 2 +-
.../TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php | 2 +-
.../TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml | 2 +-
Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php | 2 +-
Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml | 2 +-
Test/TestStep/SignifydCancelOrderStep.php | 2 +-
Test/TestStep/SignifydCreateCustomerStep.php | 2 +-
Test/TestStep/UnholdAndCancelOrderStep.php | 2 +-
10 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php b/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php
index ab5e04eba0a83..55134b8d94548 100644
--- a/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php
+++ b/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php
@@ -1,6 +1,6 @@
diff --git a/Test/Repository/SignifydData.xml b/Test/Repository/SignifydData.xml
index dc7c110e8a90e..5b3be4b9d570a 100644
--- a/Test/Repository/SignifydData.xml
+++ b/Test/Repository/SignifydData.xml
@@ -1,7 +1,7 @@
diff --git a/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php b/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
index aa91cd6db1e57..1dd742c9f7096 100644
--- a/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
+++ b/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
@@ -1,6 +1,6 @@
diff --git a/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
index 8ba76696b0999..698861da26018 100644
--- a/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
+++ b/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
@@ -1,6 +1,6 @@
diff --git a/Test/TestStep/SignifydCancelOrderStep.php b/Test/TestStep/SignifydCancelOrderStep.php
index 1b060fca2aa6f..54f4dd75223e0 100644
--- a/Test/TestStep/SignifydCancelOrderStep.php
+++ b/Test/TestStep/SignifydCancelOrderStep.php
@@ -1,6 +1,6 @@
Date: Fri, 31 Mar 2017 14:09:39 +0300
Subject: [PATCH 0316/2045] MAGETWO-63642: Update Order Status Based on
Signifyd Guarantee Status
- Fixed copyrights
---
Plugin/DenyPaymentTest.php | 2 +-
_files/declined_case.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Plugin/DenyPaymentTest.php b/Plugin/DenyPaymentTest.php
index e6b249221a36f..ff7e30046c338 100644
--- a/Plugin/DenyPaymentTest.php
+++ b/Plugin/DenyPaymentTest.php
@@ -1,6 +1,6 @@
Date: Mon, 10 Apr 2017 03:52:07 +0300
Subject: [PATCH 0317/2045] MAGETWO-52958: Better Semantic for UI Components
- apply patch with new semantic
---
.../ui_component/sales_order_grid.xml | 29 +++++++++----------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/view/adminhtml/ui_component/sales_order_grid.xml b/view/adminhtml/ui_component/sales_order_grid.xml
index 21195adcc8bcf..91053d617f31f 100644
--- a/view/adminhtml/ui_component/sales_order_grid.xml
+++ b/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
+
From b84070e313f080c77ddf10c3812a0a25f008b9a6 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 11 Apr 2017 11:57:35 +0300
Subject: [PATCH 0318/2045] MAGETWO-67298: Push the file (Signifyd readme) to
the repo
---
README.md | 144 +++++++++++++++++++++++++++---------------------------
1 file changed, 73 insertions(+), 71 deletions(-)
diff --git a/README.md b/README.md
index 6ade95e78c2a5..149bd9d6401a0 100644
--- a/README.md
+++ b/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 90327a926d45135df599f1ee551c8f00673e4c4a Mon Sep 17 00:00:00 2001
From: Ievgen Shakhsuvarov
Date: Tue, 11 Apr 2017 15:23:21 +0300
Subject: [PATCH 0319/2045] MAGETWO-67344: Solve issues with API #9124
- Updated getList method signatures to be compatible with SearchCriteriaInterface instead of SearchCriteria
---
Api/CaseRepositoryInterface.php | 4 ++--
Model/CaseRepository.php | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Api/CaseRepositoryInterface.php b/Api/CaseRepositoryInterface.php
index 2be176ba41111..707cc4f3ccb12 100644
--- a/Api/CaseRepositoryInterface.php
+++ b/Api/CaseRepositoryInterface.php
@@ -47,8 +47,8 @@ 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
*/
- public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria);
+ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
}
diff --git a/Model/CaseRepository.php b/Model/CaseRepository.php
index aefed3b52199b..ea3ea3e67aafd 100644
--- a/Model/CaseRepository.php
+++ b/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();
From 20e23bc66548f1f42886bee79a7558667af13d2d Mon Sep 17 00:00:00 2001
From: Alex Paliarush
Date: Fri, 14 Apr 2017 09:51:22 -0500
Subject: [PATCH 0320/2045] MAGETWO-65444: Add @api annotation to exception
framework
---
Model/MessageGenerators/GeneratorException.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Model/MessageGenerators/GeneratorException.php b/Model/MessageGenerators/GeneratorException.php
index 03f6e495b7c56..edbbfcb5e4758 100644
--- a/Model/MessageGenerators/GeneratorException.php
+++ b/Model/MessageGenerators/GeneratorException.php
@@ -9,6 +9,8 @@
/**
* Common exception for Signifyd message generators.
+ *
+ * @api
*/
class GeneratorException extends LocalizedException
{
From 0ddaa1f659712dc4936d5736f138b1e66d64af01 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 19 Apr 2017 11:56:16 +0300
Subject: [PATCH 0321/2045] MAGETWO-67298: Push the file (Signifyd readme) to
the repo
- Replace class names with FQCN
---
README.md | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index 149bd9d6401a0..9479972cb21b6 100644
--- a/README.md
+++ b/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 f159d4f1e68c9153caeb152a05de316e4b5896ba Mon Sep 17 00:00:00 2001
From: Anton Kril
Date: Sat, 22 Apr 2017 15:14:30 -0500
Subject: [PATCH 0322/2045] MAGETWO-67718: @api coverage integrity test
---
Block/Adminhtml/CaseInfo.php | 2 ++
Block/Fingerprint.php | 1 +
2 files changed, 3 insertions(+)
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index fe7f810981389..cdf4f4caefc0d 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/Block/Adminhtml/CaseInfo.php
@@ -12,6 +12,8 @@
/**
* Get Signifyd Case Info
+ *
+ * @api
*/
class CaseInfo extends Template
{
diff --git a/Block/Fingerprint.php b/Block/Fingerprint.php
index dbafd8be2554d..f547f272bed6e 100644
--- a/Block/Fingerprint.php
+++ b/Block/Fingerprint.php
@@ -17,6 +17,7 @@
* 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
*/
class Fingerprint extends Template
From 9f9ea8e0f042d7dd5abe8594451a3ada95553e02 Mon Sep 17 00:00:00 2001
From: Illia Grybkov
Date: Wed, 26 Apr 2017 12:37:12 +0300
Subject: [PATCH 0323/2045] MAGETWO-65525: Add support for PHP 7.1.x
- Drop PHP 5.6 support
- Add PHP 7.1.x to the list of supported versions
MAGETWO-63672: Upgrade outdated libraries w/composer (minor versions)
MAGETWO-52770: Upgrade composer to stable version
- Now Magento uses stable composer/composer v1.4.1
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index dfb11224b205b..42f0ca9338cb6 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"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",
+ "php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
"magento/module-config": "100.2.*",
"magento/framework": "100.2.*",
"magento/module-sales": "100.2.*",
From 5a72877e616e9fe4cd7aa7106d375e47541d4aed Mon Sep 17 00:00:00 2001
From: Elena Marchenko
Date: Mon, 10 Apr 2017 12:31:38 +0300
Subject: [PATCH 0324/2045] MAGETWO-67272:
Magento\Signifyd\Test\TestCase\CreateSignifydGuaranteeAndCancelOrderTest test
fails
---
Test/Block/SignifydConsole/CaseInfo.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Test/Block/SignifydConsole/CaseInfo.php b/Test/Block/SignifydConsole/CaseInfo.php
index 83855ec5028d8..5fe6096035803 100644
--- a/Test/Block/SignifydConsole/CaseInfo.php
+++ b/Test/Block/SignifydConsole/CaseInfo.php
@@ -87,7 +87,7 @@ class CaseInfo extends Block
*
* @var string
*/
- private $cardHolder = '[data-dropdown="peopleLinks0"]';
+ private $cardHolder = '[data-dropdown="peopleLinks0_card_holders"]';
/**
* Css selector of displayed billing address.
From 19a98fbcd5f46bebc8325a21653d0442b62f41a8 Mon Sep 17 00:00:00 2001
From: Elena Marchenko
Date: Tue, 11 Apr 2017 11:56:40 +0300
Subject: [PATCH 0325/2045] MAGETWO-67272:
Magento\Signifyd\Test\TestCase\CreateSignifydGuaranteeAndCancelOrderTest test
fails
---
Test/Constraint/AssertSignifydCaseInOrdersGrid.php | 3 ---
Test/TestStep/OpenOrderGridStep.php | 3 +--
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/Test/Constraint/AssertSignifydCaseInOrdersGrid.php b/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
index 92df053382418..2f08ac8f40a3e 100644
--- a/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
+++ b/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
@@ -16,20 +16,17 @@ class AssertSignifydCaseInOrdersGrid extends AbstractConstraint
{
/**
* @param string $orderId
- * @param string $status
* @param OrdersGrid $ordersGrid
* @param SignifydData $signifydData
* @return void
*/
public function processAssert(
$orderId,
- $status,
OrdersGrid $ordersGrid,
SignifydData $signifydData
) {
$filter = [
'id' => $orderId,
- 'status' => $status,
'signifyd_guarantee_status' => $signifydData->getGuaranteeDisposition()
];
diff --git a/Test/TestStep/OpenOrderGridStep.php b/Test/TestStep/OpenOrderGridStep.php
index 2fd7a988c8cfd..409dffc8340b7 100644
--- a/Test/TestStep/OpenOrderGridStep.php
+++ b/Test/TestStep/OpenOrderGridStep.php
@@ -123,8 +123,8 @@ public function __construct(
public function run()
{
$this->checkOrdersGrid();
- $this->checkOrderStatus();
$this->checkCaseInfo();
+ $this->checkOrderStatus();
}
/**
@@ -136,7 +136,6 @@ private function checkOrdersGrid()
{
$this->assertOrdersGrid->processAssert(
$this->orderId,
- $this->placeOrderStatus,
$this->ordersGrid,
$this->signifydData
);
From fd2d00ca420b6b3e82578864b25ae858e8f56889 Mon Sep 17 00:00:00 2001
From: Tommy Wiebell
Date: Fri, 23 Jun 2017 15:17:28 -0500
Subject: [PATCH 0326/2045] MAGETWO-67296: String localization is not working
when phrase contains quote (\')
- Regenerate language files to include new escaping logic. Additionally merge in aliases not compiled from core.
---
i18n/en_US.csv | 87 +++++++++++++++++++++++++-------------------------
1 file changed, 44 insertions(+), 43 deletions(-)
diff --git a/i18n/en_US.csv b/i18n/en_US.csv
index b9a4ff29a4599..40772188dac9e 100644
--- a/i18n/en_US.csv
+++ b/i18n/en_US.csv
@@ -1,45 +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."
+"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."
-"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
+"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"
From 8f5f223032a0d5f6744d8c948e8d4961502a4e45 Mon Sep 17 00:00:00 2001
From: Oleksii Korshenko
Date: Tue, 27 Jun 2017 10:21:49 -0500
Subject: [PATCH 0327/2045] MAGETWO-70191: Convert long form tags with echo to
use short-echo tags #1563
- converted
- 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/view/frontend/templates/fingerprint.phtml b/view/frontend/templates/fingerprint.phtml
index fdcecf7d1865e..356bab9c62ded 100644
--- a/view/frontend/templates/fingerprint.phtml
+++ b/view/frontend/templates/fingerprint.phtml
@@ -12,7 +12,7 @@
From a5605073acbb771a446557262a0180c19eb3948d Mon Sep 17 00:00:00 2001
From: Oleksandr Shmyheliuk
Date: Thu, 29 Jun 2017 16:32:58 +0300
Subject: [PATCH 0328/2045] MAGETWO-69964: PHPCS cannot parse correctly syntax
of PHP 7.x return types
---
Model/CustomerOrders.php | 4 ++--
Model/OrderStateService.php | 3 +--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/Model/CustomerOrders.php b/Model/CustomerOrders.php
index 4cd725d642e97..c326cf06424c0 100644
--- a/Model/CustomerOrders.php
+++ b/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/Model/OrderStateService.php b/Model/OrderStateService.php
index 47e3c7a4d1f14..2b3f0e155981e 100644
--- a/Model/OrderStateService.php
+++ b/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;
From 58459d72e1ee4e0cdeb35630512b31697bf96d61 Mon Sep 17 00:00:00 2001
From: Robert He
Date: Thu, 13 Jul 2017 11:25:17 -0500
Subject: [PATCH 0329/2045] MAGETWO-69137: upgrading Magento2 Project PHPUnit
version to latest
---
Test/Unit/Block/Adminhtml/CaseInfoTest.php | 2 +-
Test/Unit/Controller/Webhooks/HandlerTest.php | 4 +--
.../UpdatingServiceFactoryTest.php | 2 +-
.../CaseServices/UpdatingServiceTest.php | 2 +-
.../Unit/Model/CommentsHistoryUpdaterTest.php | 4 +--
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 | 2 +-
.../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 | 2 +-
.../Model/SignifydGateway/GatewayTest.php | 35 +++++++++++--------
.../Response/WebhookMessageReaderTest.php | 2 +-
.../Response/WebhookRequestValidatorTest.php | 2 +-
.../Unit/Model/SignifydOrderSessionIdTest.php | 2 +-
Test/Unit/Observer/PlaceOrderTest.php | 5 +--
24 files changed, 48 insertions(+), 40 deletions(-)
diff --git a/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/Test/Unit/Block/Adminhtml/CaseInfoTest.php
index 4e23d32b6de67..164cd8018fb69 100644
--- a/Test/Unit/Block/Adminhtml/CaseInfoTest.php
+++ b/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/Test/Unit/Controller/Webhooks/HandlerTest.php b/Test/Unit/Controller/Webhooks/HandlerTest.php
index 6e17432fa0e4f..1a8cfdc703247 100644
--- a/Test/Unit/Controller/Webhooks/HandlerTest.php
+++ b/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/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php b/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
index f903c1ad0efad..f0184c032b550 100644
--- a/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
+++ b/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/Test/Unit/Model/CaseServices/UpdatingServiceTest.php b/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index 2dfcc5c7ea862..6eb7e5c37d5fc 100644
--- a/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
+++ b/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/Test/Unit/Model/CommentsHistoryUpdaterTest.php b/Test/Unit/Model/CommentsHistoryUpdaterTest.php
index 2dc9ad4d2d457..1c3390119dc6b 100644
--- a/Test/Unit/Model/CommentsHistoryUpdaterTest.php
+++ b/Test/Unit/Model/CommentsHistoryUpdaterTest.php
@@ -15,7 +15,7 @@
/**
* Contains tests for comments history updater class.
*/
-class CommentsHistoryUpdaterTest extends \PHPUnit_Framework_TestCase
+class CommentsHistoryUpdaterTest extends \PHPUnit\Framework\TestCase
{
/**
* @var int
@@ -61,7 +61,7 @@ protected function setUp()
$this->historyFactory = $this->getMockBuilder(HistoryFactory::class)
->disableOriginalConstructor()
- ->setMethods(['create'])
+ ->setMethods(['create', 'save'])
->getMock();
$this->caseEntity = $this->getMockBuilder(CaseInterface::class)
diff --git a/Test/Unit/Model/CustomerOrdersTest.php b/Test/Unit/Model/CustomerOrdersTest.php
index 67a508be20c0d..02d3b4b9ad7a7 100644
--- a/Test/Unit/Model/CustomerOrdersTest.php
+++ b/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/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php b/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
index 572bb48f87a46..f7b4e473a0ec8 100644
--- a/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
+++ b/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/Test/Unit/Model/Guarantee/CancelingServiceTest.php b/Test/Unit/Model/Guarantee/CancelingServiceTest.php
index 90365d1ec788a..f8f1d4a4522c9 100644
--- a/Test/Unit/Model/Guarantee/CancelingServiceTest.php
+++ b/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/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php b/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
index cae198d54c618..7ba3ab3eef4f6 100644
--- a/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
+++ b/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/Test/Unit/Model/Guarantee/CreationServiceTest.php b/Test/Unit/Model/Guarantee/CreationServiceTest.php
index 0d488949b20d5..a22bfe12222a6 100644
--- a/Test/Unit/Model/Guarantee/CreationServiceTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 550fc72c0f164..ba14036cd68d0 100644
--- a/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/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,
diff --git a/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
index 8ada5eb71bdb1..50f87df3b694f 100644
--- a/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
+++ b/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/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php b/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
index 1fb060471319f..9d5f71f657a1e 100644
--- a/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
+++ b/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/Test/Unit/Model/OrderStateServiceTest.php b/Test/Unit/Model/OrderStateServiceTest.php
index 1555685b78d32..3a567a79891f8 100644
--- a/Test/Unit/Model/OrderStateServiceTest.php
+++ b/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/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php b/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
index bff9401217355..319229e326c4b 100644
--- a/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
+++ b/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/Test/Unit/Model/PaymentVerificationFactoryTest.php b/Test/Unit/Model/PaymentVerificationFactoryTest.php
index 377c83a340a01..b0f9239d43bfa 100644
--- a/Test/Unit/Model/PaymentVerificationFactoryTest.php
+++ b/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/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php b/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
index 1dedb56f27d44..885c9f018a488 100644
--- a/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
+++ b/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/Test/Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php b/Test/Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php
index 89bd0c64efe67..776e8a75b9646 100644
--- a/Test/Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php
+++ b/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/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php b/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php
index 2476717c690b9..bf0c6ee238d5f 100644
--- a/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php
+++ b/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
diff --git a/Test/Unit/Model/SignifydGateway/GatewayTest.php b/Test/Unit/Model/SignifydGateway/GatewayTest.php
index ee59617aad926..f7aa65f842b91 100644
--- a/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/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/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php b/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
index 604c9c63c935f..0dfdf4980fb58 100644
--- a/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
+++ b/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/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php b/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
index 5a4ab570f655c..5ae6b95a77548 100644
--- a/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
+++ b/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/Test/Unit/Model/SignifydOrderSessionIdTest.php b/Test/Unit/Model/SignifydOrderSessionIdTest.php
index 1f8875fa9cbdb..9d3061f240c21 100644
--- a/Test/Unit/Model/SignifydOrderSessionIdTest.php
+++ b/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/Test/Unit/Observer/PlaceOrderTest.php b/Test/Unit/Observer/PlaceOrderTest.php
index 100fe1052e035..e2870953ec280 100644
--- a/Test/Unit/Observer/PlaceOrderTest.php
+++ b/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);
}
/**
From b2797e550fe98518263ffae2f99a65a2c3efdd96 Mon Sep 17 00:00:00 2001
From: Robert He
Date: Thu, 13 Jul 2017 11:25:17 -0500
Subject: [PATCH 0330/2045] MAGETWO-69137: upgrading Magento2 Project PHPUnit
version to latest
---
Block/Adminhtml/CaseInfoTest.php | 2 +-
Block/FingerprintTest.php | 2 +-
Controller/Webhooks/HandlerTest.php | 4 ++--
Model/CaseManagementTest.php | 2 +-
Model/CaseRepositoryTest.php | 2 +-
Model/CaseServices/CreationServiceTest.php | 4 ++--
Model/CaseServices/UpdatingServiceTest.php | 2 +-
Model/Guarantee/CancelingServiceTest.php | 4 ++--
Model/Guarantee/CreationServiceTest.php | 4 ++--
Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 2 +-
Observer/PlaceOrderTest.php | 4 ++--
Plugin/CancelOrderTest.php | 4 ++--
Plugin/DenyPaymentTest.php | 4 ++--
13 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/Block/Adminhtml/CaseInfoTest.php b/Block/Adminhtml/CaseInfoTest.php
index 60fa3e7c65e44..75cd84e5b6c7f 100644
--- a/Block/Adminhtml/CaseInfoTest.php
+++ b/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
diff --git a/Block/FingerprintTest.php b/Block/FingerprintTest.php
index aa31e1f65d34d..a5004461cfe83 100644
--- a/Block/FingerprintTest.php
+++ b/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
diff --git a/Controller/Webhooks/HandlerTest.php b/Controller/Webhooks/HandlerTest.php
index a0802e3fdcb5d..f3c57fbb8b7f0 100644
--- a/Controller/Webhooks/HandlerTest.php
+++ b/Controller/Webhooks/HandlerTest.php
@@ -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/Model/CaseManagementTest.php b/Model/CaseManagementTest.php
index 217b54621f26d..462ebc5d4c7f4 100644
--- a/Model/CaseManagementTest.php
+++ b/Model/CaseManagementTest.php
@@ -16,7 +16,7 @@
/**
* Contains test methods for case management service
*/
-class CaseManagementTest extends \PHPUnit_Framework_TestCase
+class CaseManagementTest extends \PHPUnit\Framework\TestCase
{
/**
* @var CaseManagement
diff --git a/Model/CaseRepositoryTest.php b/Model/CaseRepositoryTest.php
index 44972b6094ef0..137ce634d09bf 100644
--- a/Model/CaseRepositoryTest.php
+++ b/Model/CaseRepositoryTest.php
@@ -14,7 +14,7 @@
/**
* Testing case repository
*/
-class CaseRepositoryTest extends \PHPUnit_Framework_TestCase
+class CaseRepositoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
diff --git a/Model/CaseServices/CreationServiceTest.php b/Model/CaseServices/CreationServiceTest.php
index 0fd303b644141..eda2628db8892 100644
--- a/Model/CaseServices/CreationServiceTest.php
+++ b/Model/CaseServices/CreationServiceTest.php
@@ -18,7 +18,7 @@
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
diff --git a/Model/CaseServices/UpdatingServiceTest.php b/Model/CaseServices/UpdatingServiceTest.php
index cffcc4a456578..2a7178292fa03 100644
--- a/Model/CaseServices/UpdatingServiceTest.php
+++ b/Model/CaseServices/UpdatingServiceTest.php
@@ -17,7 +17,7 @@
/**
* Contains tests for case entity updating service.
*/
-class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
+class UpdatingServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
diff --git a/Model/Guarantee/CancelingServiceTest.php b/Model/Guarantee/CancelingServiceTest.php
index dcd39e02d0f06..873aab671a449 100644
--- a/Model/Guarantee/CancelingServiceTest.php
+++ b/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;
diff --git a/Model/Guarantee/CreationServiceTest.php b/Model/Guarantee/CreationServiceTest.php
index 66008cdee39e5..ece90fffb4aff 100644
--- a/Model/Guarantee/CreationServiceTest.php
+++ b/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
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 9559e8a86fc0b..7e7e20c873948 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/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
diff --git a/Observer/PlaceOrderTest.php b/Observer/PlaceOrderTest.php
index 5e80d4f4138c2..a6dedbad46113 100644
--- a/Observer/PlaceOrderTest.php
+++ b/Observer/PlaceOrderTest.php
@@ -14,10 +14,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
diff --git a/Plugin/CancelOrderTest.php b/Plugin/CancelOrderTest.php
index f58ae5d52b1ba..07d5a06615baa 100644
--- a/Plugin/CancelOrderTest.php
+++ b/Plugin/CancelOrderTest.php
@@ -15,9 +15,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
diff --git a/Plugin/DenyPaymentTest.php b/Plugin/DenyPaymentTest.php
index ff7e30046c338..a1c682569656d 100644
--- a/Plugin/DenyPaymentTest.php
+++ b/Plugin/DenyPaymentTest.php
@@ -22,12 +22,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
From d90957d286445d8af60d882916dab0bc6a780da3 Mon Sep 17 00:00:00 2001
From: Oleksii Korshenko
Date: Fri, 28 Jul 2017 15:51:44 -0500
Subject: [PATCH 0331/2045] MAGETWO-71174: Update doc block information in php
classes with @deprecated and @since tags
- added release number to all existing @deprecated tag in php classes, methods and properties (app/code/Magento, lib/internal/Magento, setup/src/Magento/Setup)
- added tag @since to all existing php classes, methods and properties (app/code/Magento, lib/internal/Magento, setup/src/Magento/Setup)
---
Api/CaseCreationServiceInterface.php | 2 ++
Api/CaseManagementInterface.php | 3 +++
Api/CaseRepositoryInterface.php | 6 +++++
Api/Data/CaseInterface.php | 23 ++++++++++++++++
Api/Data/CaseSearchResultsInterface.php | 3 +++
Api/GuaranteeCancelingServiceInterface.php | 2 ++
Api/GuaranteeCreationServiceInterface.php | 2 ++
Block/Adminhtml/CaseInfo.php | 9 +++++++
.../System/Config/Field/WebhookUrl.php | 4 +++
.../Adminhtml/System/Config/Fieldset/Info.php | 2 ++
Block/Fingerprint.php | 8 ++++++
Controller/Webhooks/Handler.php | 11 ++++++++
Model/CaseEntity.php | 27 +++++++++++++++++++
Model/CaseManagement.php | 8 ++++++
Model/CaseRepository.php | 12 +++++++++
Model/CaseServices/CreationService.php | 9 +++++++
Model/CaseServices/StubUpdatingService.php | 2 ++
Model/CaseServices/UpdatingService.php | 9 +++++++
Model/CaseServices/UpdatingServiceFactory.php | 7 +++++
.../CaseServices/UpdatingServiceInterface.php | 2 ++
Model/CommentsHistoryUpdater.php | 4 +++
Model/Config.php | 7 +++++
Model/CustomerOrders.php | 13 +++++++++
Model/Guarantee/CancelGuaranteeAbility.php | 6 +++++
Model/Guarantee/CancelingService.php | 8 ++++++
Model/Guarantee/CreateGuaranteeAbility.php | 9 +++++++
Model/Guarantee/CreationService.php | 8 ++++++
Model/MessageGenerators/CaseRescore.php | 4 +++
.../MessageGenerators/GeneratorException.php | 1 +
Model/MessageGenerators/GeneratorFactory.php | 9 +++++++
.../MessageGenerators/GeneratorInterface.php | 2 ++
Model/MessageGenerators/PatternGenerator.php | 5 ++++
Model/OrderStateService.php | 9 +++++++
.../PaymentMethodMapper.php | 4 +++
.../XmlToArrayConfigConverter.php | 7 +++++
Model/PaymentVerificationFactory.php | 9 +++++++
Model/PredefinedVerificationCode.php | 4 +++
.../QuoteSession/Adminhtml/BackendSession.php | 4 +++
Model/QuoteSession/FrontendSession.php | 4 +++
Model/QuoteSession/QuoteSessionInterface.php | 2 ++
Model/ResourceModel/CaseEntity.php | 2 ++
Model/ResourceModel/CaseEntity/Collection.php | 2 ++
.../NotSyncedOrderIdListProvider.php | 4 +++
Model/SalesOrderGrid/OrderGridUpdater.php | 5 ++++
Model/SignifydGateway/ApiCallException.php | 4 +++
Model/SignifydGateway/ApiClient.php | 4 +++
.../Client/HttpClientFactory.php | 13 +++++++++
.../SignifydGateway/Client/RequestBuilder.php | 6 +++++
.../SignifydGateway/Client/RequestSender.php | 4 +++
.../Client/ResponseHandler.php | 9 +++++++
Model/SignifydGateway/Debugger/BlackHole.php | 3 +++
.../Debugger/DebuggerFactory.php | 5 ++++
.../Debugger/DebuggerInterface.php | 3 +++
Model/SignifydGateway/Debugger/Log.php | 11 ++++++++
Model/SignifydGateway/Gateway.php | 8 ++++++
Model/SignifydGateway/GatewayException.php | 1 +
.../Request/AddressBuilder.php | 3 +++
Model/SignifydGateway/Request/CardBuilder.php | 4 +++
.../Request/ClientVersionBuilder.php | 5 ++++
.../Request/CreateCaseBuilder.php | 12 +++++++++
.../Request/CreateCaseBuilderInterface.php | 2 ++
.../Request/PurchaseBuilder.php | 15 +++++++++++
.../Request/RecipientBuilder.php | 4 +++
.../SignifydGateway/Request/SellerBuilder.php | 9 +++++++
.../Request/UserAccountBuilder.php | 7 +++++
.../Response/WebhookMessage.php | 6 +++++
.../Response/WebhookMessageReader.php | 5 ++++
.../Response/WebhookRequest.php | 6 +++++
.../Response/WebhookRequestValidator.php | 9 +++++++
Model/SignifydOrderSessionId.php | 4 +++
Observer/PlaceOrder.php | 8 ++++++
Plugin/OrderPlugin.php | 4 +++
Plugin/PaymentPlugin.php | 5 ++++
Setup/InstallSchema.php | 4 +++
.../Listing/Column/Guarantee/Options.php | 4 +++
75 files changed, 470 insertions(+)
diff --git a/Api/CaseCreationServiceInterface.php b/Api/CaseCreationServiceInterface.php
index 4664431ead85f..324e3eb36730f 100644
--- a/Api/CaseCreationServiceInterface.php
+++ b/Api/CaseCreationServiceInterface.php
@@ -12,6 +12,7 @@
* Implementation should send request to Signifyd API and create new entity in Magento.
*
* @api
+ * @since 2.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 2.2.0
*/
public function createForOrder($orderId);
}
diff --git a/Api/CaseManagementInterface.php b/Api/CaseManagementInterface.php
index d12abebe8b98a..06b2d0d6e4f51 100644
--- a/Api/CaseManagementInterface.php
+++ b/Api/CaseManagementInterface.php
@@ -10,6 +10,7 @@
* Allows to performs operations with Signifyd cases.
*
* @api
+ * @since 2.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 2.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 2.2.0
*/
public function getByOrderId($orderId);
}
diff --git a/Api/CaseRepositoryInterface.php b/Api/CaseRepositoryInterface.php
index 707cc4f3ccb12..4dd4dee881232 100644
--- a/Api/CaseRepositoryInterface.php
+++ b/Api/CaseRepositoryInterface.php
@@ -9,6 +9,7 @@
* Signifyd Case repository interface
*
* @api
+ * @since 2.2.0
*/
interface CaseRepositoryInterface
{
@@ -17,6 +18,7 @@ interface CaseRepositoryInterface
*
* @param \Magento\Signifyd\Api\Data\CaseInterface $case
* @return \Magento\Signifyd\Api\Data\CaseInterface
+ * @since 2.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 2.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 2.2.0
*/
public function getByCaseId($caseId);
@@ -41,6 +45,7 @@ public function getByCaseId($caseId);
*
* @param \Magento\Signifyd\Api\Data\CaseInterface $case
* @return bool
+ * @since 2.2.0
*/
public function delete(\Magento\Signifyd\Api\Data\CaseInterface $case);
@@ -49,6 +54,7 @@ public function delete(\Magento\Signifyd\Api\Data\CaseInterface $case);
*
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
* @return \Magento\Signifyd\Api\Data\CaseSearchResultsInterface
+ * @since 2.2.0
*/
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
}
diff --git a/Api/Data/CaseInterface.php b/Api/Data/CaseInterface.php
index a14d81eb18465..5394ceb8238df 100644
--- a/Api/Data/CaseInterface.php
+++ b/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 2.2.0
*/
interface CaseInterface
{
@@ -48,6 +49,7 @@ interface CaseInterface
* Returns local case entity identifier.
*
* @return int
+ * @since 2.2.0
*/
public function getEntityId();
@@ -56,6 +58,7 @@ public function getEntityId();
*
* @param int $id
* @return $this
+ * @since 2.2.0
*/
public function setEntityId($id);
@@ -63,6 +66,7 @@ public function setEntityId($id);
* Returns Signifyd case identifier.
*
* @return int
+ * @since 2.2.0
*/
public function getCaseId();
@@ -71,6 +75,7 @@ public function getCaseId();
*
* @param int $id
* @return $this
+ * @since 2.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 2.2.0
*/
public function isGuaranteeEligible();
@@ -87,6 +93,7 @@ public function isGuaranteeEligible();
*
* @param bool $guaranteeEligible
* @return $this
+ * @since 2.2.0
*/
public function setGuaranteeEligible($guaranteeEligible);
@@ -94,6 +101,7 @@ public function setGuaranteeEligible($guaranteeEligible);
* Returns decision state of the guarantee.
*
* @return string
+ * @since 2.2.0
*/
public function getGuaranteeDisposition();
@@ -102,6 +110,7 @@ public function getGuaranteeDisposition();
*
* @param string $disposition
* @return $this
+ * @since 2.2.0
*/
public function setGuaranteeDisposition($disposition);
@@ -109,6 +118,7 @@ public function setGuaranteeDisposition($disposition);
* Returns case status.
*
* @return string
+ * @since 2.2.0
*/
public function getStatus();
@@ -117,6 +127,7 @@ public function getStatus();
*
* @param string $status
* @return $this
+ * @since 2.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 2.2.0
*/
public function getScore();
@@ -132,6 +144,7 @@ public function getScore();
*
* @param int $score
* @return $this
+ * @since 2.2.0
*/
public function setScore($score);
@@ -139,6 +152,7 @@ public function setScore($score);
* Get order id for a case.
*
* @return int
+ * @since 2.2.0
*/
public function getOrderId();
@@ -147,6 +161,7 @@ public function getOrderId();
*
* @param int $orderId
* @return $this
+ * @since 2.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 2.2.0
*/
public function getAssociatedTeam();
@@ -162,6 +178,7 @@ public function getAssociatedTeam();
*
* @param array $team
* @return $this
+ * @since 2.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 2.2.0
*/
public function getReviewDisposition();
@@ -177,6 +195,7 @@ public function getReviewDisposition();
*
* @param string $disposition
* @return $this
+ * @since 2.2.0
*/
public function setReviewDisposition($disposition);
@@ -184,6 +203,7 @@ public function setReviewDisposition($disposition);
* Returns creation datetime for a case.
*
* @return string
+ * @since 2.2.0
*/
public function getCreatedAt();
@@ -192,6 +212,7 @@ public function getCreatedAt();
*
* @param string $datetime in DATE_ATOM format
* @return $this
+ * @since 2.2.0
*/
public function setCreatedAt($datetime);
@@ -199,6 +220,7 @@ public function setCreatedAt($datetime);
* Returns updating datetime for a case.
*
* @return string
+ * @since 2.2.0
*/
public function getUpdatedAt();
@@ -207,6 +229,7 @@ public function getUpdatedAt();
*
* @param string $datetime in DATE_ATOM format
* @return $this
+ * @since 2.2.0
*/
public function setUpdatedAt($datetime);
}
diff --git a/Api/Data/CaseSearchResultsInterface.php b/Api/Data/CaseSearchResultsInterface.php
index a0a571613d3b1..0733afd8fe8e2 100644
--- a/Api/Data/CaseSearchResultsInterface.php
+++ b/Api/Data/CaseSearchResultsInterface.php
@@ -11,6 +11,7 @@
* Retrieve and set list of case entities.
*
* @api
+ * @since 2.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 2.2.0
*/
public function getItems();
@@ -26,6 +28,7 @@ public function getItems();
*
* @param \Magento\Signifyd\Api\Data\CaseInterface[] $items
* @return $this
+ * @since 2.2.0
*/
public function setItems(array $items);
}
diff --git a/Api/GuaranteeCancelingServiceInterface.php b/Api/GuaranteeCancelingServiceInterface.php
index 9c000cecb37ee..585444099e6c6 100644
--- a/Api/GuaranteeCancelingServiceInterface.php
+++ b/Api/GuaranteeCancelingServiceInterface.php
@@ -12,6 +12,7 @@
* Implementation should send request to Signifyd API and update existing case entity with guarantee information.
*
* @api
+ * @since 2.2.0
*/
interface GuaranteeCancelingServiceInterface
{
@@ -20,6 +21,7 @@ interface GuaranteeCancelingServiceInterface
*
* @param int $orderId
* @return bool
+ * @since 2.2.0
*/
public function cancelForOrder($orderId);
}
diff --git a/Api/GuaranteeCreationServiceInterface.php b/Api/GuaranteeCreationServiceInterface.php
index 609f3166df0a2..b6dc3b9e1cdeb 100644
--- a/Api/GuaranteeCreationServiceInterface.php
+++ b/Api/GuaranteeCreationServiceInterface.php
@@ -12,6 +12,7 @@
* Implementation should send request to Signifyd API and update existing case entity with guarantee infromation.
*
* @api
+ * @since 2.2.0
*/
interface GuaranteeCreationServiceInterface
{
@@ -20,6 +21,7 @@ interface GuaranteeCreationServiceInterface
*
* @param int $orderId
* @return bool
+ * @since 2.2.0
*/
public function createForOrder($orderId);
}
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index cdf4f4caefc0d..c301460af3259 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/Block/Adminhtml/CaseInfo.php
@@ -14,16 +14,19 @@
* Get Signifyd Case Info
*
* @api
+ * @since 2.2.0
*/
class CaseInfo extends Template
{
/**
* @var CaseInterface
+ * @since 2.2.0
*/
private $caseEntity = false;
/**
* @var CaseManagement
+ * @since 2.2.0
*/
private $caseManagement;
@@ -31,6 +34,7 @@ class CaseInfo extends Template
* @param Context $context
* @param CaseManagement $caseManagement
* @param array $data
+ * @since 2.2.0
*/
public function __construct(
Context $context,
@@ -46,6 +50,7 @@ public function __construct(
* Gets case entity associated with order id.
*
* @return CaseInterface|null
+ * @since 2.2.0
*/
private function getCaseEntity()
{
@@ -64,6 +69,7 @@ private function getCaseEntity()
* @param mixed $defaultValue
* @param callable $callback
* @return mixed
+ * @since 2.2.0
*/
private function getCaseProperty($defaultValue, callable $callback)
{
@@ -74,6 +80,7 @@ private function getCaseProperty($defaultValue, callable $callback)
* Checks if case is exists for order
*
* @return bool
+ * @since 2.2.0
*/
public function isEmptyCase()
{
@@ -84,6 +91,7 @@ public function isEmptyCase()
* Gets case guarantee disposition status.
*
* @return string
+ * @since 2.2.0
*/
public function getCaseGuaranteeDisposition()
{
@@ -109,6 +117,7 @@ public function getCaseGuaranteeDisposition()
* Retrieves current order Id.
*
* @return integer
+ * @since 2.2.0
*/
private function getOrderId()
{
diff --git a/Block/Adminhtml/System/Config/Field/WebhookUrl.php b/Block/Adminhtml/System/Config/Field/WebhookUrl.php
index 7964d6b1af397..e71d7387bc5ce 100644
--- a/Block/Adminhtml/System/Config/Field/WebhookUrl.php
+++ b/Block/Adminhtml/System/Config/Field/WebhookUrl.php
@@ -12,11 +12,13 @@
/**
* Input field transformed to text node with link to store Signifyd webhooks controller.
+ * @since 2.2.0
*/
class WebhookUrl extends Field
{
/**
* @inheritdoc
+ * @since 2.2.0
*/
protected function _getElementHtml(AbstractElement $element)
{
@@ -32,6 +34,7 @@ protected function _getElementHtml(AbstractElement $element)
/**
* @inheritdoc
+ * @since 2.2.0
*/
protected function _isInheritCheckboxRequired(AbstractElement $element)
{
@@ -42,6 +45,7 @@ protected function _isInheritCheckboxRequired(AbstractElement $element)
* Return base store URL.
*
* @return string
+ * @since 2.2.0
*/
private function getStoreUrl()
{
diff --git a/Block/Adminhtml/System/Config/Fieldset/Info.php b/Block/Adminhtml/System/Config/Fieldset/Info.php
index c18c3dc596e21..0a4b184fc5d2a 100644
--- a/Block/Adminhtml/System/Config/Fieldset/Info.php
+++ b/Block/Adminhtml/System/Config/Fieldset/Info.php
@@ -9,11 +9,13 @@
/**
* Fieldset renderer with url attached to comment.
+ * @since 2.2.0
*/
class Info extends Fieldset
{
/**
* @inheritdoc
+ * @since 2.2.0
*/
protected function _getHeaderCommentHtml($element)
{
diff --git a/Block/Fingerprint.php b/Block/Fingerprint.php
index f547f272bed6e..fea1b4c84a36c 100644
--- a/Block/Fingerprint.php
+++ b/Block/Fingerprint.php
@@ -19,26 +19,31 @@
*
* @api
* @see https://www.signifyd.com/docs/api/#/reference/device-fingerprint/create-a-case
+ * @since 2.2.0
*/
class Fingerprint extends Template
{
/**
* @var SignifydOrderSessionId
+ * @since 2.2.0
*/
private $signifydOrderSessionId;
/**
* @var Config
+ * @since 2.2.0
*/
private $config;
/**
* @var QuoteSessionInterface
+ * @since 2.2.0
*/
private $quoteSession;
/**
* @var string
+ * @since 2.2.0
*/
protected $_template = 'fingerprint.phtml';
@@ -48,6 +53,7 @@ class Fingerprint extends Template
* @param SignifydOrderSessionId $signifydOrderSessionId
* @param QuoteSessionInterface $quoteSession
* @param array $data
+ * @since 2.2.0
*/
public function __construct(
Context $context,
@@ -66,6 +72,7 @@ public function __construct(
* Returns a unique Signifyd order session id.
*
* @return string
+ * @since 2.2.0
*/
public function getSignifydOrderSessionId()
{
@@ -78,6 +85,7 @@ public function getSignifydOrderSessionId()
* Checks if module is enabled.
*
* @return boolean
+ * @since 2.2.0
*/
public function isModuleActive()
{
diff --git a/Controller/Webhooks/Handler.php b/Controller/Webhooks/Handler.php
index 12bd773d35a2f..9ba3723ac3c7c 100644
--- a/Controller/Webhooks/Handler.php
+++ b/Controller/Webhooks/Handler.php
@@ -20,6 +20,7 @@
* Responsible for handling webhook posts from Signifyd service.
*
* @see https://www.signifyd.com/docs/api/#/reference/webhooks/
+ * @since 2.2.0
*/
class Handler extends Action
{
@@ -27,41 +28,49 @@ class Handler extends Action
* Event topic of test webhook request.
*
* @var string
+ * @since 2.2.0
*/
private static $eventTopicTest = 'cases/test';
/**
* @var WebhookRequest
+ * @since 2.2.0
*/
private $webhookRequest;
/**
* @var LoggerInterface
+ * @since 2.2.0
*/
private $logger;
/**
* @var WebhookMessageReader
+ * @since 2.2.0
*/
private $webhookMessageReader;
/**
* @var UpdatingServiceFactory
+ * @since 2.2.0
*/
private $caseUpdatingServiceFactory;
/**
* @var WebhookRequestValidator
+ * @since 2.2.0
*/
private $webhookRequestValidator;
/**
* @var CaseRepositoryInterface
+ * @since 2.2.0
*/
private $caseRepository;
/**
* @var Config
+ * @since 2.2.0
*/
private $config;
@@ -74,6 +83,7 @@ class Handler extends Action
* @param WebhookRequestValidator $webhookRequestValidator
* @param CaseRepositoryInterface $caseRepository
* @param Config $config
+ * @since 2.2.0
*/
public function __construct(
Context $context,
@@ -99,6 +109,7 @@ public function __construct(
* Processes webhook request data and updates case entity
*
* @return void
+ * @since 2.2.0
*/
public function execute()
{
diff --git a/Model/CaseEntity.php b/Model/CaseEntity.php
index c11c72db79f16..2acd609179ea4 100644
--- a/Model/CaseEntity.php
+++ b/Model/CaseEntity.php
@@ -15,16 +15,19 @@
/**
* Implementation of Signifyd Case interface.
+ * @since 2.2.0
*/
class CaseEntity extends AbstractModel implements CaseInterface
{
/**
* @var string
+ * @since 2.2.0
*/
protected $_eventPrefix = 'signifyd_case';
/**
* @var SerializerInterface
+ * @since 2.2.0
*/
private $serializer;
@@ -37,6 +40,7 @@ class CaseEntity extends AbstractModel implements CaseInterface
* @param array $data
* @param AbstractResource|null $resource
* @param AbstractDb|null $resourceCollection
+ * @since 2.2.0
*/
public function __construct(
Context $context,
@@ -52,6 +56,7 @@ public function __construct(
/**
* @inheritdoc
+ * @since 2.2.0
*/
protected function _construct()
{
@@ -60,6 +65,7 @@ protected function _construct()
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getEntityId()
{
@@ -68,6 +74,7 @@ public function getEntityId()
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function setEntityId($id)
{
@@ -77,6 +84,7 @@ public function setEntityId($id)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getCaseId()
{
@@ -85,6 +93,7 @@ public function getCaseId()
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function setCaseId($id)
{
@@ -94,6 +103,7 @@ public function setCaseId($id)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function isGuaranteeEligible()
{
@@ -103,6 +113,7 @@ public function isGuaranteeEligible()
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function setGuaranteeEligible($guaranteeEligible)
{
@@ -112,6 +123,7 @@ public function setGuaranteeEligible($guaranteeEligible)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getGuaranteeDisposition()
{
@@ -120,6 +132,7 @@ public function getGuaranteeDisposition()
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function setGuaranteeDisposition($disposition)
{
@@ -129,6 +142,7 @@ public function setGuaranteeDisposition($disposition)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getStatus()
{
@@ -137,6 +151,7 @@ public function getStatus()
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function setStatus($status)
{
@@ -146,6 +161,7 @@ public function setStatus($status)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getScore()
{
@@ -154,6 +170,7 @@ public function getScore()
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function setScore($score)
{
@@ -163,6 +180,7 @@ public function setScore($score)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getOrderId()
{
@@ -171,6 +189,7 @@ public function getOrderId()
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function setOrderId($orderId)
{
@@ -180,6 +199,7 @@ public function setOrderId($orderId)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getAssociatedTeam()
{
@@ -189,6 +209,7 @@ public function getAssociatedTeam()
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function setAssociatedTeam(array $team)
{
@@ -198,6 +219,7 @@ public function setAssociatedTeam(array $team)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getReviewDisposition()
{
@@ -206,6 +228,7 @@ public function getReviewDisposition()
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function setReviewDisposition($disposition)
{
@@ -215,6 +238,7 @@ public function setReviewDisposition($disposition)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getCreatedAt()
{
@@ -223,6 +247,7 @@ public function getCreatedAt()
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function setCreatedAt($datetime)
{
@@ -232,6 +257,7 @@ public function setCreatedAt($datetime)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getUpdatedAt()
{
@@ -240,6 +266,7 @@ public function getUpdatedAt()
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function setUpdatedAt($datetime)
{
diff --git a/Model/CaseManagement.php b/Model/CaseManagement.php
index 1913f1e7a17b3..b42d76127fc0c 100644
--- a/Model/CaseManagement.php
+++ b/Model/CaseManagement.php
@@ -17,26 +17,31 @@
/**
*
* Default case management implementation
+ * @since 2.2.0
*/
class CaseManagement implements CaseManagementInterface
{
/**
* @var CaseRepositoryInterface
+ * @since 2.2.0
*/
private $caseRepository;
/**
* @var CaseInterfaceFactory
+ * @since 2.2.0
*/
private $caseFactory;
/**
* @var FilterBuilder
+ * @since 2.2.0
*/
private $filterBuilder;
/**
* @var SearchCriteriaBuilder
+ * @since 2.2.0
*/
private $searchCriteriaBuilder;
@@ -46,6 +51,7 @@ class CaseManagement implements CaseManagementInterface
* @param CaseInterfaceFactory $caseFactory
* @param FilterBuilder $filterBuilder
* @param SearchCriteriaBuilder $searchCriteriaBuilder
+ * @since 2.2.0
*/
public function __construct(
CaseRepositoryInterface $caseRepository,
@@ -61,6 +67,7 @@ public function __construct(
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function create($orderId)
{
@@ -78,6 +85,7 @@ public function create($orderId)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getByOrderId($orderId)
{
diff --git a/Model/CaseRepository.php b/Model/CaseRepository.php
index ea3ea3e67aafd..18ff3d5561ff3 100644
--- a/Model/CaseRepository.php
+++ b/Model/CaseRepository.php
@@ -20,31 +20,37 @@
* Repository for Case interface
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ * @since 2.2.0
*/
class CaseRepository implements CaseRepositoryInterface
{
/**
* @var CollectionProcessorInterface
+ * @since 2.2.0
*/
private $collectionProcessor;
/**
* @var CollectionFactory
+ * @since 2.2.0
*/
private $collectionFactory;
/**
* @var CaseSearchResultsInterfaceFactory
+ * @since 2.2.0
*/
private $searchResultsFactory;
/**
* @var CaseInterfaceFactory
+ * @since 2.2.0
*/
private $caseFactory;
/**
* @var CaseResourceModel
+ * @since 2.2.0
*/
private $resourceModel;
@@ -55,6 +61,7 @@ class CaseRepository implements CaseRepositoryInterface
* @param CaseSearchResultsInterfaceFactory $searchResultsFactory
* @param CaseInterfaceFactory $caseFactory
* @param CaseResourceModel $resourceModel
+ * @since 2.2.0
*/
public function __construct(
CollectionProcessorInterface $collectionProcessor,
@@ -72,6 +79,7 @@ public function __construct(
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function save(CaseInterface $case)
{
@@ -83,6 +91,7 @@ public function save(CaseInterface $case)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getById($id)
{
@@ -95,6 +104,7 @@ public function getById($id)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getByCaseId($caseId)
{
@@ -107,6 +117,7 @@ public function getByCaseId($caseId)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function delete(CaseInterface $case)
{
@@ -117,6 +128,7 @@ public function delete(CaseInterface $case)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getList(SearchCriteriaInterface $searchCriteria)
{
diff --git a/Model/CaseServices/CreationService.php b/Model/CaseServices/CreationService.php
index 8413838bd7d5f..6a90e5db919e3 100644
--- a/Model/CaseServices/CreationService.php
+++ b/Model/CaseServices/CreationService.php
@@ -18,36 +18,43 @@
* Case Creation Service
*
* Creates new Case entity and register it at Signifyd
+ * @since 2.2.0
*/
class CreationService implements CaseCreationServiceInterface
{
/**
* @var CaseManagementInterface
+ * @since 2.2.0
*/
private $caseManagement;
/**
* @var Gateway;
+ * @since 2.2.0
*/
private $signifydGateway;
/**
* @var LoggerInterface
+ * @since 2.2.0
*/
private $logger;
/**
* @var CaseRepositoryInterface
+ * @since 2.2.0
*/
private $caseRepository;
/**
* @var OrderGridUpdater
+ * @since 2.2.0
*/
private $orderGridUpdater;
/**
* @var OrderStateService
+ * @since 2.2.0
*/
private $orderStateService;
@@ -60,6 +67,7 @@ class CreationService implements CaseCreationServiceInterface
* @param CaseRepositoryInterface $caseRepository
* @param OrderGridUpdater $orderGridUpdater
* @param OrderStateService $orderStateService
+ * @since 2.2.0
*/
public function __construct(
CaseManagementInterface $caseManagement,
@@ -79,6 +87,7 @@ public function __construct(
/**
* {@inheritdoc}
+ * @since 2.2.0
*/
public function createForOrder($orderId)
{
diff --git a/Model/CaseServices/StubUpdatingService.php b/Model/CaseServices/StubUpdatingService.php
index 295d7f13fb0ac..1a5e6c44c15b1 100644
--- a/Model/CaseServices/StubUpdatingService.php
+++ b/Model/CaseServices/StubUpdatingService.php
@@ -10,11 +10,13 @@
/**
* Stub implementation for case updating service interface and might be used
* for test Signifyd webhooks
+ * @since 2.2.0
*/
class StubUpdatingService implements UpdatingServiceInterface
{
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function update(CaseInterface $case, array $data)
{
diff --git a/Model/CaseServices/UpdatingService.php b/Model/CaseServices/UpdatingService.php
index 870705db941cc..5afb6141e1fe5 100644
--- a/Model/CaseServices/UpdatingService.php
+++ b/Model/CaseServices/UpdatingService.php
@@ -16,31 +16,37 @@
/**
* Performs Signifyd case entity updating operations.
+ * @since 2.2.0
*/
class UpdatingService implements UpdatingServiceInterface
{
/**
* @var GeneratorInterface
+ * @since 2.2.0
*/
private $messageGenerator;
/**
* @var CaseRepositoryInterface
+ * @since 2.2.0
*/
private $caseRepository;
/**
* @var CommentsHistoryUpdater
+ * @since 2.2.0
*/
private $commentsHistoryUpdater;
/**
* @var \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater
+ * @since 2.2.0
*/
private $orderGridUpdater;
/**
* @var OrderStateService
+ * @since 2.2.0
*/
private $orderStateService;
@@ -52,6 +58,7 @@ class UpdatingService implements UpdatingServiceInterface
* @param CommentsHistoryUpdater $commentsHistoryUpdater
* @param \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater $orderGridUpdater
* @param OrderStateService $orderStateService
+ * @since 2.2.0
*/
public function __construct(
GeneratorInterface $messageGenerator,
@@ -75,6 +82,7 @@ public function __construct(
* @return void
* @throws NotFoundException
* @throws LocalizedException
+ * @since 2.2.0
*/
public function update(CaseInterface $case, array $data)
{
@@ -103,6 +111,7 @@ public function update(CaseInterface $case, array $data)
* @param CaseInterface $case
* @param array $data
* @return void
+ * @since 2.2.0
*/
private function setCaseData(CaseInterface $case, array $data)
{
diff --git a/Model/CaseServices/UpdatingServiceFactory.php b/Model/CaseServices/UpdatingServiceFactory.php
index 5415044b5edc4..c98bb7f0daf2e 100644
--- a/Model/CaseServices/UpdatingServiceFactory.php
+++ b/Model/CaseServices/UpdatingServiceFactory.php
@@ -13,27 +13,32 @@
* 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).
+ * @since 2.2.0
*/
class UpdatingServiceFactory
{
/**
* Type of testing Signifyd case
* @var string
+ * @since 2.2.0
*/
private static $caseTest = 'cases/test';
/**
* @var ObjectManagerInterface
+ * @since 2.2.0
*/
private $objectManager;
/**
* @var GeneratorFactory
+ * @since 2.2.0
*/
private $generatorFactory;
/**
* @var Config
+ * @since 2.2.0
*/
private $config;
@@ -43,6 +48,7 @@ class UpdatingServiceFactory
* @param ObjectManagerInterface $objectManager
* @param GeneratorFactory $generatorFactory
* @param Config $config
+ * @since 2.2.0
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -61,6 +67,7 @@ public function __construct(
* @param string $type
* @return UpdatingServiceInterface
* @throws \InvalidArgumentException
+ * @since 2.2.0
*/
public function create($type)
{
diff --git a/Model/CaseServices/UpdatingServiceInterface.php b/Model/CaseServices/UpdatingServiceInterface.php
index daa7b40bfd674..8ebcf9991a664 100644
--- a/Model/CaseServices/UpdatingServiceInterface.php
+++ b/Model/CaseServices/UpdatingServiceInterface.php
@@ -9,6 +9,7 @@
/**
* Common abstraction to perform updating operations with Signifyd case entity.
+ * @since 2.2.0
*/
interface UpdatingServiceInterface
{
@@ -18,6 +19,7 @@ interface UpdatingServiceInterface
* @param CaseInterface $case
* @param array $data
* @return void
+ * @since 2.2.0
*/
public function update(CaseInterface $case, array $data);
}
diff --git a/Model/CommentsHistoryUpdater.php b/Model/CommentsHistoryUpdater.php
index 0a24c972c4c6b..0d6b1a362716e 100644
--- a/Model/CommentsHistoryUpdater.php
+++ b/Model/CommentsHistoryUpdater.php
@@ -11,11 +11,13 @@
/**
* Updates case order comments history.
+ * @since 2.2.0
*/
class CommentsHistoryUpdater
{
/**
* @var HistoryFactory
+ * @since 2.2.0
*/
private $historyFactory;
@@ -23,6 +25,7 @@ class CommentsHistoryUpdater
* CommentsHistoryUpdater constructor.
*
* @param HistoryFactory $historyFactory
+ * @since 2.2.0
*/
public function __construct(HistoryFactory $historyFactory)
{
@@ -37,6 +40,7 @@ public function __construct(HistoryFactory $historyFactory)
* @param Phrase $message
* @param string $status
* @return void
+ * @since 2.2.0
*/
public function addComment(CaseInterface $case, Phrase $message, $status = '')
{
diff --git a/Model/Config.php b/Model/Config.php
index b68380ee15bf3..ab70da2adc984 100644
--- a/Model/Config.php
+++ b/Model/Config.php
@@ -12,11 +12,13 @@
* Signifyd integration configuration.
*
* Class is a proxy service for retrieving configuration settings.
+ * @since 2.2.0
*/
class Config
{
/**
* @var ScopeConfigInterface
+ * @since 2.2.0
*/
private $scopeConfig;
@@ -24,6 +26,7 @@ class Config
* Config constructor.
*
* @param ScopeConfigInterface $scopeConfig
+ * @since 2.2.0
*/
public function __construct(ScopeConfigInterface $scopeConfig)
{
@@ -35,6 +38,7 @@ public function __construct(ScopeConfigInterface $scopeConfig)
* (only possibility to configure Signifyd setting in admin)
*
* @return bool
+ * @since 2.2.0
*/
public function isActive()
{
@@ -52,6 +56,7 @@ public function isActive()
* @see https://app.signifyd.com/settings
*
* @return string
+ * @since 2.2.0
*/
public function getApiKey()
{
@@ -67,6 +72,7 @@ public function getApiKey()
* Usually equals to https://api.signifyd.com/v2 and should not be changed
*
* @return string
+ * @since 2.2.0
*/
public function getApiUrl()
{
@@ -81,6 +87,7 @@ public function getApiUrl()
* If is "true" extra information about interaction with Signifyd API are written to debug.log file
*
* @return bool
+ * @since 2.2.0
*/
public function isDebugModeEnabled()
{
diff --git a/Model/CustomerOrders.php b/Model/CustomerOrders.php
index c326cf06424c0..2c72e0582332d 100644
--- a/Model/CustomerOrders.php
+++ b/Model/CustomerOrders.php
@@ -18,41 +18,49 @@
* Provides information about customer orders.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ * @since 2.2.0
*/
class CustomerOrders
{
/**
* @var SearchCriteriaBuilder
+ * @since 2.2.0
*/
private $searchCriteriaBuilder;
/**
* @var FilterBuilder
+ * @since 2.2.0
*/
private $filterBuilder;
/**
* @var OrderRepositoryInterface
+ * @since 2.2.0
*/
private $orderRepository;
/**
* @var LoggerInterface
+ * @since 2.2.0
*/
private $logger;
/**
* @var CurrencyFactory
+ * @since 2.2.0
*/
private $currencyFactory;
/**
* @var array
+ * @since 2.2.0
*/
private $currencies = [];
/**
* @var string
+ * @since 2.2.0
*/
private static $usdCurrencyCode = 'USD';
@@ -62,6 +70,7 @@ class CustomerOrders
* @param OrderRepositoryInterface $orderRepository
* @param CurrencyFactory $currencyFactory
* @param LoggerInterface $logger
+ * @since 2.2.0
*/
public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
@@ -86,6 +95,7 @@ public function __construct(
*
* @param int $customerId
* @return array
+ * @since 2.2.0
*/
public function getAggregatedOrdersInfo($customerId)
{
@@ -121,6 +131,7 @@ public function getAggregatedOrdersInfo($customerId)
*
* @param int $customerId
* @return OrderInterface[]
+ * @since 2.2.0
*/
private function getCustomerOrders($customerId)
{
@@ -140,6 +151,7 @@ private function getCustomerOrders($customerId)
* @param float $amount
* @param string $currency
* @return float
+ * @since 2.2.0
*/
private function getUsdOrderTotal($amount, $currency)
{
@@ -157,6 +169,7 @@ private function getUsdOrderTotal($amount, $currency)
*
* @param string|null $currencyCode
* @return Currency
+ * @since 2.2.0
*/
private function getCurrencyByCode($currencyCode)
{
diff --git a/Model/Guarantee/CancelGuaranteeAbility.php b/Model/Guarantee/CancelGuaranteeAbility.php
index 65bede6f0cea5..d63a22f9eb02b 100644
--- a/Model/Guarantee/CancelGuaranteeAbility.php
+++ b/Model/Guarantee/CancelGuaranteeAbility.php
@@ -13,22 +13,26 @@
/**
* Checks if is possible to cancel Guarantee for order.
+ * @since 2.2.0
*/
class CancelGuaranteeAbility
{
/**
* @var CaseManagement
+ * @since 2.2.0
*/
private $caseManagement;
/**
* @var OrderRepositoryInterface
+ * @since 2.2.0
*/
private $orderRepository;
/**
* @param CaseManagement $caseManagement
* @param OrderRepositoryInterface $orderRepository
+ * @since 2.2.0
*/
public function __construct(
CaseManagement $caseManagement,
@@ -43,6 +47,7 @@ public function __construct(
*
* @param int $orderId
* @return bool
+ * @since 2.2.0
*/
public function isAvailable($orderId)
{
@@ -68,6 +73,7 @@ public function isAvailable($orderId)
*
* @param int $orderId
* @return OrderInterface|null
+ * @since 2.2.0
*/
private function getOrder($orderId)
{
diff --git a/Model/Guarantee/CancelingService.php b/Model/Guarantee/CancelingService.php
index b30efac8c2190..9351dad376b60 100644
--- a/Model/Guarantee/CancelingService.php
+++ b/Model/Guarantee/CancelingService.php
@@ -14,31 +14,37 @@
/**
* Sends request to Signifyd to cancel guarantee and updates case entity.
+ * @since 2.2.0
*/
class CancelingService implements GuaranteeCancelingServiceInterface
{
/**
* @var CaseManagementInterface
+ * @since 2.2.0
*/
private $caseManagement;
/**
* @var UpdatingServiceFactory
+ * @since 2.2.0
*/
private $serviceFactory;
/**
* @var Gateway
+ * @since 2.2.0
*/
private $gateway;
/**
* @var CancelGuaranteeAbility
+ * @since 2.2.0
*/
private $cancelGuaranteeAbility;
/**
* @var LoggerInterface
+ * @since 2.2.0
*/
private $logger;
@@ -50,6 +56,7 @@ class CancelingService implements GuaranteeCancelingServiceInterface
* @param Gateway $gateway
* @param CancelGuaranteeAbility $cancelGuaranteeAbility
* @param LoggerInterface $logger
+ * @since 2.2.0
*/
public function __construct(
CaseManagementInterface $caseManagement,
@@ -67,6 +74,7 @@ public function __construct(
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function cancelForOrder($orderId)
{
diff --git a/Model/Guarantee/CreateGuaranteeAbility.php b/Model/Guarantee/CreateGuaranteeAbility.php
index 15addba3ec4fd..a7873e370f1f1 100644
--- a/Model/Guarantee/CreateGuaranteeAbility.php
+++ b/Model/Guarantee/CreateGuaranteeAbility.php
@@ -15,21 +15,25 @@
/**
* Checks if is possible to create Guarantee for order.
+ * @since 2.2.0
*/
class CreateGuaranteeAbility
{
/**
* @var CaseManagement
+ * @since 2.2.0
*/
private $caseManagement;
/**
* @var OrderRepositoryInterface
+ * @since 2.2.0
*/
private $orderRepository;
/**
* @var DateTimeFactory
+ * @since 2.2.0
*/
private $dateTimeFactory;
@@ -37,6 +41,7 @@ class CreateGuaranteeAbility
* Eligible count of days from the order creation date to submit a case for Guarantee.
*
* @var int
+ * @since 2.2.0
*/
private static $guarantyEligibleDays = 7;
@@ -44,6 +49,7 @@ class CreateGuaranteeAbility
* @param CaseManagement $caseManagement
* @param OrderRepositoryInterface $orderRepository
* @param DateTimeFactory $dateTimeFactory
+ * @since 2.2.0
*/
public function __construct(
CaseManagement $caseManagement,
@@ -60,6 +66,7 @@ public function __construct(
*
* @param int $orderId
* @return bool
+ * @since 2.2.0
*/
public function isAvailable($orderId)
{
@@ -94,6 +101,7 @@ public function isAvailable($orderId)
* @param OrderInterface $order
* @param int $days number of days from the order creation date to submit a case for Guarantee.
* @return bool
+ * @since 2.2.0
*/
private function isOrderOlderThen($days, OrderInterface $order)
{
@@ -108,6 +116,7 @@ private function isOrderOlderThen($days, OrderInterface $order)
*
* @param int $orderId
* @return OrderInterface|null
+ * @since 2.2.0
*/
private function getOrder($orderId)
{
diff --git a/Model/Guarantee/CreationService.php b/Model/Guarantee/CreationService.php
index 4080aee453f18..bb6c30a62a524 100644
--- a/Model/Guarantee/CreationService.php
+++ b/Model/Guarantee/CreationService.php
@@ -16,31 +16,37 @@
/**
* Register guarantee at Signifyd and updates case entity
+ * @since 2.2.0
*/
class CreationService implements GuaranteeCreationServiceInterface
{
/**
* @var CaseManagementInterface
+ * @since 2.2.0
*/
private $caseManagement;
/**
* @var UpdatingServiceFactory
+ * @since 2.2.0
*/
private $caseUpdatingServiceFactory;
/**
* @var Gateway
+ * @since 2.2.0
*/
private $gateway;
/**
* @var CreateGuaranteeAbility
+ * @since 2.2.0
*/
private $createGuaranteeAbility;
/**
* @var LoggerInterface
+ * @since 2.2.0
*/
private $logger;
@@ -52,6 +58,7 @@ class CreationService implements GuaranteeCreationServiceInterface
* @param Gateway $gateway
* @param CreateGuaranteeAbility $createGuaranteeAbility
* @param LoggerInterface $logger
+ * @since 2.2.0
*/
public function __construct(
CaseManagementInterface $caseManagement,
@@ -69,6 +76,7 @@ public function __construct(
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function createForOrder($orderId)
{
diff --git a/Model/MessageGenerators/CaseRescore.php b/Model/MessageGenerators/CaseRescore.php
index d0e89854e3909..344eb086b5cb6 100644
--- a/Model/MessageGenerators/CaseRescore.php
+++ b/Model/MessageGenerators/CaseRescore.php
@@ -9,11 +9,13 @@
/**
* Generates message based on previous and current Case scores.
+ * @since 2.2.0
*/
class CaseRescore implements GeneratorInterface
{
/**
* @var CaseRepositoryInterface
+ * @since 2.2.0
*/
private $caseRepository;
@@ -21,6 +23,7 @@ class CaseRescore implements GeneratorInterface
* CaseRescore constructor.
*
* @param CaseRepositoryInterface $caseRepository
+ * @since 2.2.0
*/
public function __construct(CaseRepositoryInterface $caseRepository)
{
@@ -29,6 +32,7 @@ public function __construct(CaseRepositoryInterface $caseRepository)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function generate(array $data)
{
diff --git a/Model/MessageGenerators/GeneratorException.php b/Model/MessageGenerators/GeneratorException.php
index 10a609c6fb73c..63eb000d2bd6e 100644
--- a/Model/MessageGenerators/GeneratorException.php
+++ b/Model/MessageGenerators/GeneratorException.php
@@ -11,6 +11,7 @@
* Common exception for Signifyd message generators.
*
* @api
+ * @since 2.2.0
*/
class GeneratorException extends LocalizedException
{
diff --git a/Model/MessageGenerators/GeneratorFactory.php b/Model/MessageGenerators/GeneratorFactory.php
index 66e02a3803950..580b7c949bf31 100644
--- a/Model/MessageGenerators/GeneratorFactory.php
+++ b/Model/MessageGenerators/GeneratorFactory.php
@@ -10,42 +10,49 @@
/**
* Creates instance of message generator based on received type of message.
+ * @since 2.2.0
*/
class GeneratorFactory
{
/**
* Type of message for Signifyd case creation.
* @var string
+ * @since 2.2.0
*/
private static $caseCreation = 'cases/creation';
/**
* Type of message for Signifyd case re-scoring.
* @var string
+ * @since 2.2.0
*/
private static $caseRescore = 'cases/rescore';
/**
* Type of message for Signifyd case reviewing
* @var string
+ * @since 2.2.0
*/
private static $caseReview = 'cases/review';
/**
* Type of message of Signifyd guarantee completion
* @var string
+ * @since 2.2.0
*/
private static $guaranteeCompletion = 'guarantees/completion';
/**
* Type of message of Signifyd guarantee creation
* @var string
+ * @since 2.2.0
*/
private static $guaranteeCreation = 'guarantees/creation';
/**
* Type of message of Signifyd guarantee canceling
* @var string
+ * @since 2.2.0
*/
private static $guaranteeCancel = 'guarantees/cancel';
@@ -53,6 +60,7 @@ class GeneratorFactory
* UpdatingServiceFactory constructor.
*
* @param ObjectManagerInterface $objectManager
+ * @since 2.2.0
*/
public function __construct(ObjectManagerInterface $objectManager)
{
@@ -66,6 +74,7 @@ public function __construct(ObjectManagerInterface $objectManager)
* @param string $type
* @return GeneratorInterface
* @throws \InvalidArgumentException
+ * @since 2.2.0
*/
public function create($type)
{
diff --git a/Model/MessageGenerators/GeneratorInterface.php b/Model/MessageGenerators/GeneratorInterface.php
index 385cbe35f05ac..eab9dafb4f32f 100644
--- a/Model/MessageGenerators/GeneratorInterface.php
+++ b/Model/MessageGenerators/GeneratorInterface.php
@@ -8,6 +8,7 @@
/**
* Represents common abstraction for Signifyd Case/Guarantee messages.
* Each interface implementation might use Case/Guarantee data to generate specific message.
+ * @since 2.2.0
*/
interface GeneratorInterface
{
@@ -16,6 +17,7 @@ interface GeneratorInterface
* @param array $data
* @return \Magento\Framework\Phrase
* @throws GeneratorException
+ * @since 2.2.0
*/
public function generate(array $data);
}
diff --git a/Model/MessageGenerators/PatternGenerator.php b/Model/MessageGenerators/PatternGenerator.php
index 8501934bebbc5..3c90d8584049c 100644
--- a/Model/MessageGenerators/PatternGenerator.php
+++ b/Model/MessageGenerators/PatternGenerator.php
@@ -14,16 +14,19 @@
* placeholders, for example:
* 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'].
+ * @since 2.2.0
*/
class PatternGenerator implements GeneratorInterface
{
/**
* @var string
+ * @since 2.2.0
*/
private $template;
/**
* @var array
+ * @since 2.2.0
*/
private $requiredParams;
@@ -32,6 +35,7 @@ class PatternGenerator implements GeneratorInterface
*
* @param string $template
* @param array $requiredParams
+ * @since 2.2.0
*/
public function __construct($template, array $requiredParams = [])
{
@@ -41,6 +45,7 @@ public function __construct($template, array $requiredParams = [])
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function generate(array $data)
{
diff --git a/Model/OrderStateService.php b/Model/OrderStateService.php
index 2b3f0e155981e..e409d6c735680 100644
--- a/Model/OrderStateService.php
+++ b/Model/OrderStateService.php
@@ -12,21 +12,25 @@
/**
* Updates order state.
+ * @since 2.2.0
*/
class OrderStateService
{
/**
* @var OrderFactory
+ * @since 2.2.0
*/
private $orderFactory;
/**
* @var OrderManagementInterface
+ * @since 2.2.0
*/
private $orderManagement;
/**
* @var CommentsHistoryUpdater
+ * @since 2.2.0
*/
private $commentsHistoryUpdater;
@@ -34,6 +38,7 @@ class OrderStateService
* @param OrderFactory $orderFactory
* @param OrderManagementInterface $orderManagement
* @param CommentsHistoryUpdater $commentsHistoryUpdater
+ * @since 2.2.0
*/
public function __construct(
OrderFactory $orderFactory,
@@ -50,6 +55,7 @@ public function __construct(
*
* @param CaseInterface $case
* @return void
+ * @since 2.2.0
*/
public function updateByCase(CaseInterface $case)
{
@@ -79,6 +85,7 @@ public function updateByCase(CaseInterface $case)
*
* @param int $orderId
* @return bool
+ * @since 2.2.0
*/
private function unHold($orderId)
{
@@ -95,6 +102,7 @@ private function unHold($orderId)
*
* @param int $orderId
* @return bool
+ * @since 2.2.0
*/
private function hold($orderId)
{
@@ -111,6 +119,7 @@ private function hold($orderId)
*
* @param int $orderId
* @return Order
+ * @since 2.2.0
*/
private function getOrder($orderId)
{
diff --git a/Model/PaymentMethodMapper/PaymentMethodMapper.php b/Model/PaymentMethodMapper/PaymentMethodMapper.php
index cdf9041510b45..21f11ad6fbe79 100644
--- a/Model/PaymentMethodMapper/PaymentMethodMapper.php
+++ b/Model/PaymentMethodMapper/PaymentMethodMapper.php
@@ -9,11 +9,13 @@
/**
* Load and cache configuration data.
+ * @since 2.2.0
*/
class PaymentMethodMapper
{
/**
* @var Data
+ * @since 2.2.0
*/
private $paymentMethodMapping;
@@ -21,6 +23,7 @@ class PaymentMethodMapper
* PaymentMapper constructor.
*
* @param Data $paymentMapping
+ * @since 2.2.0
*/
public function __construct(Data $paymentMapping)
{
@@ -32,6 +35,7 @@ public function __construct(Data $paymentMapping)
*
* @param string $paymentMethod
* @return string
+ * @since 2.2.0
*/
public function getSignifydPaymentMethodCode($paymentMethod)
{
diff --git a/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php b/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
index 5c3f23bb92729..9a5f65ac64c1b 100644
--- a/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
+++ b/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
@@ -9,6 +9,7 @@
/**
* Converts XML config file to payment methods mapping.
+ * @since 2.2.0
*/
class XmlToArrayConfigConverter implements \Magento\Framework\Config\ConverterInterface
{
@@ -16,6 +17,7 @@ class XmlToArrayConfigConverter implements \Magento\Framework\Config\ConverterIn
* Node type wrapper for magento and signifyd payment codes
*
* @var string
+ * @since 2.2.0
*/
private static $paymentMethodNodeType = 'payment_method';
@@ -23,6 +25,7 @@ class XmlToArrayConfigConverter implements \Magento\Framework\Config\ConverterIn
* Node type for payment methods code
*
* @var string
+ * @since 2.2.0
*/
private static $magentoCodeNodeType = 'magento_code';
@@ -30,11 +33,13 @@ class XmlToArrayConfigConverter implements \Magento\Framework\Config\ConverterIn
* Node type for Sygnifyd payment methods code
*
* @var string
+ * @since 2.2.0
*/
private static $signifydCodeNodeType = 'signifyd_code';
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function convert($source)
{
@@ -54,6 +59,7 @@ public function convert($source)
* @param \DOMElement $payment
* @return array
* @throws ValidationSchemaException
+ * @since 2.2.0
*/
private function getPaymentMethodMapping(\DOMElement $payment)
{
@@ -70,6 +76,7 @@ private function getPaymentMethodMapping(\DOMElement $payment)
* @param string $subNodeType
* @return mixed
* @throws ValidationSchemaException
+ * @since 2.2.0
*/
private function readSubnodeValue(\DOMElement $element, $subNodeType)
{
diff --git a/Model/PaymentVerificationFactory.php b/Model/PaymentVerificationFactory.php
index a26beda520944..d06b5c1205761 100644
--- a/Model/PaymentVerificationFactory.php
+++ b/Model/PaymentVerificationFactory.php
@@ -13,26 +13,31 @@
/**
* Creates verification service for provided payment method, or PaymentVerificationInterface::class
* if payment method does not support AVS, CVV verifications.
+ * @since 2.2.0
*/
class PaymentVerificationFactory
{
/**
* @var ConfigInterface
+ * @since 2.2.0
*/
private $config;
/**
* @var ObjectManagerInterface
+ * @since 2.2.0
*/
private $objectManager;
/**
* @var PaymentVerificationInterface
+ * @since 2.2.0
*/
private $avsDefaultAdapter;
/**
* @var PaymentVerificationInterface
+ * @since 2.2.0
*/
private $cvvDefaultAdapter;
@@ -41,6 +46,7 @@ class PaymentVerificationFactory
* @param ConfigInterface|Config $config
* @param PaymentVerificationInterface $avsDefaultAdapter
* @param PaymentVerificationInterface $cvvDefaultAdapter
+ * @since 2.2.0
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -61,6 +67,7 @@ public function __construct(
* @param string $paymentCode
* @return PaymentVerificationInterface
* @throws \Exception
+ * @since 2.2.0
*/
public function createPaymentCvv($paymentCode)
{
@@ -74,6 +81,7 @@ public function createPaymentCvv($paymentCode)
* @param string $paymentCode
* @return PaymentVerificationInterface
* @throws \Exception
+ * @since 2.2.0
*/
public function createPaymentAvs($paymentCode)
{
@@ -90,6 +98,7 @@ public function createPaymentAvs($paymentCode)
* @return PaymentVerificationInterface
* @throws ConfigurationMismatchException If payment verification instance
* does not implement PaymentVerificationInterface.
+ * @since 2.2.0
*/
private function create(PaymentVerificationInterface $defaultAdapter, $paymentCode, $configKey)
{
diff --git a/Model/PredefinedVerificationCode.php b/Model/PredefinedVerificationCode.php
index 618d74b2a52e9..661a6f9f5d009 100644
--- a/Model/PredefinedVerificationCode.php
+++ b/Model/PredefinedVerificationCode.php
@@ -11,16 +11,19 @@
/**
* Default implementation of payment verification interface.
* The default code value can be configured via DI.
+ * @since 2.2.0
*/
class PredefinedVerificationCode implements PaymentVerificationInterface
{
/**
* @var string
+ * @since 2.2.0
*/
private $code;
/**
* @param string $code
+ * @since 2.2.0
*/
public function __construct($code = '')
{
@@ -29,6 +32,7 @@ public function __construct($code = '')
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getCode(OrderPaymentInterface $orderPayment)
{
diff --git a/Model/QuoteSession/Adminhtml/BackendSession.php b/Model/QuoteSession/Adminhtml/BackendSession.php
index 9be02719545c7..8e1c0a8797ce7 100644
--- a/Model/QuoteSession/Adminhtml/BackendSession.php
+++ b/Model/QuoteSession/Adminhtml/BackendSession.php
@@ -10,11 +10,13 @@
/**
* Implementation of QuoteSessionInterface for Magento backend checkout.
+ * @since 2.2.0
*/
class BackendSession implements QuoteSessionInterface
{
/**
* @var BackendQuoteSession
+ * @since 2.2.0
*/
private $backendQuoteSession;
@@ -24,6 +26,7 @@ class BackendSession implements QuoteSessionInterface
* Class uses backend session for retrieving quote.
*
* @param BackendQuoteSession $backendQuoteSession
+ * @since 2.2.0
*/
public function __construct(BackendQuoteSession $backendQuoteSession)
{
@@ -32,6 +35,7 @@ public function __construct(BackendQuoteSession $backendQuoteSession)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getQuote()
{
diff --git a/Model/QuoteSession/FrontendSession.php b/Model/QuoteSession/FrontendSession.php
index 44c226ae4a47e..973f58ca72b55 100644
--- a/Model/QuoteSession/FrontendSession.php
+++ b/Model/QuoteSession/FrontendSession.php
@@ -9,11 +9,13 @@
/**
* Implementation of QuoteSessionInterface for Magento frontend checkout.
+ * @since 2.2.0
*/
class FrontendSession implements QuoteSessionInterface
{
/**
* @var CheckoutSession
+ * @since 2.2.0
*/
private $checkoutSession;
@@ -23,6 +25,7 @@ class FrontendSession implements QuoteSessionInterface
* Class uses checkout session for retrieving quote.
*
* @param CheckoutSession $checkoutSession
+ * @since 2.2.0
*/
public function __construct(CheckoutSession $checkoutSession)
{
@@ -31,6 +34,7 @@ public function __construct(CheckoutSession $checkoutSession)
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getQuote()
{
diff --git a/Model/QuoteSession/QuoteSessionInterface.php b/Model/QuoteSession/QuoteSessionInterface.php
index 14958ac65a6ee..6775d0923dcc8 100644
--- a/Model/QuoteSession/QuoteSessionInterface.php
+++ b/Model/QuoteSession/QuoteSessionInterface.php
@@ -7,6 +7,7 @@
/**
* Interface QuoteSessionInterface
+ * @since 2.2.0
*/
interface QuoteSessionInterface
{
@@ -14,6 +15,7 @@ interface QuoteSessionInterface
* Returns quote from session.
*
* @return \Magento\Quote\Api\Data\CartInterface
+ * @since 2.2.0
*/
public function getQuote();
}
diff --git a/Model/ResourceModel/CaseEntity.php b/Model/ResourceModel/CaseEntity.php
index 9c6ffde4504b9..dc77fd0179385 100644
--- a/Model/ResourceModel/CaseEntity.php
+++ b/Model/ResourceModel/CaseEntity.php
@@ -9,11 +9,13 @@
/**
* Implementation of case resource model
+ * @since 2.2.0
*/
class CaseEntity extends AbstractDb
{
/**
* @inheritdoc
+ * @since 2.2.0
*/
protected function _construct()
{
diff --git a/Model/ResourceModel/CaseEntity/Collection.php b/Model/ResourceModel/CaseEntity/Collection.php
index 92e233dd42dbc..a09e16d58af6a 100644
--- a/Model/ResourceModel/CaseEntity/Collection.php
+++ b/Model/ResourceModel/CaseEntity/Collection.php
@@ -11,11 +11,13 @@
/**
* Collection of case entities
+ * @since 2.2.0
*/
class Collection extends AbstractCollection
{
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function _construct()
{
diff --git a/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php b/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
index 360225ae37b7b..3c9b4308200b3 100644
--- a/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
+++ b/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
@@ -11,16 +11,19 @@
/**
* Provides order ids list which Signifyd Case guaranty status were changed
+ * @since 2.2.0
*/
class NotSyncedOrderIdListProvider implements NotSyncedDataProviderInterface
{
/**
* @var ResourceModel\CaseEntity
+ * @since 2.2.0
*/
private $caseEntity;
/**
* @param ResourceModel\CaseEntity $caseEntity
+ * @since 2.2.0
*/
public function __construct(
CaseEntity $caseEntity
@@ -30,6 +33,7 @@ public function __construct(
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function getIds($mainTableName, $gridTableName)
{
diff --git a/Model/SalesOrderGrid/OrderGridUpdater.php b/Model/SalesOrderGrid/OrderGridUpdater.php
index fff42b300be58..9b4d345b2b98c 100644
--- a/Model/SalesOrderGrid/OrderGridUpdater.php
+++ b/Model/SalesOrderGrid/OrderGridUpdater.php
@@ -12,22 +12,26 @@
* Perfoms sales order grid updating operations.
*
* Serves order grid updates in both synchronous and asynchronous modes.
+ * @since 2.2.0
*/
class OrderGridUpdater
{
/**
* @var ScopeConfigInterface
+ * @since 2.2.0
*/
private $globalConfig;
/**
* @var GridInterface
+ * @since 2.2.0
*/
private $entityGrid;
/**
* @param GridInterface $entityGrid
* @param ScopeConfigInterface $globalConfig
+ * @since 2.2.0
*/
public function __construct(
GridInterface $entityGrid,
@@ -45,6 +49,7 @@ public function __construct(
*
* @param int $orderId
* @return void
+ * @since 2.2.0
*/
public function update($orderId)
{
diff --git a/Model/SignifydGateway/ApiCallException.php b/Model/SignifydGateway/ApiCallException.php
index 73338c8ea4d62..e5fe17e577850 100644
--- a/Model/SignifydGateway/ApiCallException.php
+++ b/Model/SignifydGateway/ApiCallException.php
@@ -7,11 +7,13 @@
/**
* Exception of interaction with Signifyd API
+ * @since 2.2.0
*/
class ApiCallException extends GatewayException
{
/**
* @var string
+ * @since 2.2.0
*/
private $requestData;
@@ -21,6 +23,7 @@ class ApiCallException extends GatewayException
* @param int $code
* @param \Exception|null $previous
* @param string $requestData in JSON format
+ * @since 2.2.0
*/
public function __construct($message = '', $code = 0, \Exception $previous = null, $requestData = '')
{
@@ -31,6 +34,7 @@ public function __construct($message = '', $code = 0, \Exception $previous = nul
/**
* Gets request data for unsuccessful request in JSON format
* @return string
+ * @since 2.2.0
*/
public function getRequestData()
{
diff --git a/Model/SignifydGateway/ApiClient.php b/Model/SignifydGateway/ApiClient.php
index 0950ca1e22cfa..5377f05c99b12 100644
--- a/Model/SignifydGateway/ApiClient.php
+++ b/Model/SignifydGateway/ApiClient.php
@@ -9,11 +9,13 @@
/**
* Encapsulates Signifyd API protocol.
+ * @since 2.2.0
*/
class ApiClient
{
/**
* @var RequestBuilder
+ * @since 2.2.0
*/
private $requestBuilder;
@@ -21,6 +23,7 @@ class ApiClient
* ApiClient constructor.
*
* @param RequestBuilder $requestBuilder
+ * @since 2.2.0
*/
public function __construct(
RequestBuilder $requestBuilder
@@ -38,6 +41,7 @@ public function __construct(
* @param string $method
* @param array $params
* @return array
+ * @since 2.2.0
*/
public function makeApiCall($url, $method, array $params = [])
{
diff --git a/Model/SignifydGateway/Client/HttpClientFactory.php b/Model/SignifydGateway/Client/HttpClientFactory.php
index 41006bd7d1e0e..8117bf00653c2 100644
--- a/Model/SignifydGateway/Client/HttpClientFactory.php
+++ b/Model/SignifydGateway/Client/HttpClientFactory.php
@@ -13,6 +13,7 @@
/**
* Class HttpClientFactory
* Creates and configures HTTP client for RequestBuilder
+ * @since 2.2.0
*/
class HttpClientFactory
{
@@ -20,6 +21,7 @@ class HttpClientFactory
* Specifies basic HTTP access authentication Header.
*
* @var string
+ * @since 2.2.0
*/
private static $authorizationType = 'Authorization';
@@ -27,26 +29,31 @@ class HttpClientFactory
* JSON HTTP Content-Type Header.
*
* @var string
+ * @since 2.2.0
*/
private static $jsonDataType = 'application/json';
/**
* @var string
+ * @since 2.2.0
*/
private static $urlSeparator = '/';
/**
* @var Config
+ * @since 2.2.0
*/
private $config;
/**
* @var ZendClientFactory
+ * @since 2.2.0
*/
private $clientFactory;
/**
* @var EncoderInterface
+ * @since 2.2.0
*/
private $dataEncoder;
@@ -56,6 +63,7 @@ class HttpClientFactory
* @param Config $config
* @param ZendClientFactory $clientFactory
* @param EncoderInterface $dataEncoder
+ * @since 2.2.0
*/
public function __construct(
Config $config,
@@ -74,6 +82,7 @@ public function __construct(
* @param string $method
* @param array $params
* @return ZendClient
+ * @since 2.2.0
*/
public function create($url, $method, array $params = [])
{
@@ -97,6 +106,7 @@ public function create($url, $method, array $params = [])
/**
* @return ZendClient
+ * @since 2.2.0
*/
private function createNewClient()
{
@@ -108,6 +118,7 @@ private function createNewClient()
*
* @see https://www.signifyd.com/docs/api/#/introduction/authentication
* @return string
+ * @since 2.2.0
*/
private function getApiKey()
{
@@ -119,6 +130,7 @@ private function getApiKey()
*
* @param string $url
* @return string
+ * @since 2.2.0
*/
private function buildFullApiUrl($url)
{
@@ -132,6 +144,7 @@ private function buildFullApiUrl($url)
* Base Sigifyd API URL without trailing slash.
*
* @return string
+ * @since 2.2.0
*/
private function getBaseApiUrl()
{
diff --git a/Model/SignifydGateway/Client/RequestBuilder.php b/Model/SignifydGateway/Client/RequestBuilder.php
index 2ab4395e1990d..f4f40bdff2190 100644
--- a/Model/SignifydGateway/Client/RequestBuilder.php
+++ b/Model/SignifydGateway/Client/RequestBuilder.php
@@ -10,21 +10,25 @@
/**
* Class RequestBuilder
* Creates HTTP client, sends request to Signifyd and handles response
+ * @since 2.2.0
*/
class RequestBuilder
{
/**
* @var HttpClientFactory
+ * @since 2.2.0
*/
private $clientCreator;
/**
* @var RequestSender
+ * @since 2.2.0
*/
private $requestSender;
/**
* @var ResponseHandler
+ * @since 2.2.0
*/
private $responseHandler;
@@ -34,6 +38,7 @@ class RequestBuilder
* @param HttpClientFactory $clientCreator
* @param RequestSender $requestSender
* @param ResponseHandler $responseHandler
+ * @since 2.2.0
*/
public function __construct(
HttpClientFactory $clientCreator,
@@ -52,6 +57,7 @@ public function __construct(
* @param string $method
* @param array $params
* @return array
+ * @since 2.2.0
*/
public function doRequest($url, $method, array $params = [])
{
diff --git a/Model/SignifydGateway/Client/RequestSender.php b/Model/SignifydGateway/Client/RequestSender.php
index 38128a799fd59..84fa207a6a382 100644
--- a/Model/SignifydGateway/Client/RequestSender.php
+++ b/Model/SignifydGateway/Client/RequestSender.php
@@ -12,11 +12,13 @@
/**
* Class RequestSender
* Gets HTTP client end sends request to Signifyd API
+ * @since 2.2.0
*/
class RequestSender
{
/**
* @var DebuggerFactory
+ * @since 2.2.0
*/
private $debuggerFactory;
@@ -24,6 +26,7 @@ class RequestSender
* RequestSender constructor.
*
* @param DebuggerFactory $debuggerFactory
+ * @since 2.2.0
*/
public function __construct(
DebuggerFactory $debuggerFactory
@@ -41,6 +44,7 @@ public function __construct(
* @param ZendClient $client
* @return \Zend_Http_Response
* @throws ApiCallException
+ * @since 2.2.0
*/
public function send(ZendClient $client)
{
diff --git a/Model/SignifydGateway/Client/ResponseHandler.php b/Model/SignifydGateway/Client/ResponseHandler.php
index 614e59b7c29a2..1023684bc21e5 100644
--- a/Model/SignifydGateway/Client/ResponseHandler.php
+++ b/Model/SignifydGateway/Client/ResponseHandler.php
@@ -10,6 +10,7 @@
/**
* Class ResponseHandler
+ * @since 2.2.0
*/
class ResponseHandler
{
@@ -17,11 +18,13 @@ class ResponseHandler
* Successful HTTP response codes.
*
* @var array
+ * @since 2.2.0
*/
private static $successResponseCodes = [200, 201, 204];
/**
* Current servers PHP version id.
+ * @since 2.2.0
*/
private static $phpVersionId = PHP_VERSION_ID;
@@ -29,6 +32,7 @@ class ResponseHandler
* Failure HTTP response codes with messages.
*
* @var array
+ * @since 2.2.0
*/
private static $failureResponses = [
400 => 'Bad Request - The request could not be parsed. Response: %s',
@@ -43,11 +47,13 @@ class ResponseHandler
* Unexpected Signifyd API response message.
*
* @var string
+ * @since 2.2.0
*/
private static $unexpectedResponse = 'Unexpected Signifyd API response code "%s" with content "%s".';
/**
* @var DecoderInterface
+ * @since 2.2.0
*/
private $dataDecoder;
@@ -55,6 +61,7 @@ class ResponseHandler
* ResponseHandler constructor.
*
* @param DecoderInterface $dataDecoder
+ * @since 2.2.0
*/
public function __construct(
DecoderInterface $dataDecoder
@@ -68,6 +75,7 @@ public function __construct(
* @param \Zend_Http_Response $response
* @return array
* @throws ApiCallException
+ * @since 2.2.0
*/
public function handle(\Zend_Http_Response $response)
{
@@ -106,6 +114,7 @@ public function handle(\Zend_Http_Response $response)
*
* @param \Zend_Http_Response $response
* @return string
+ * @since 2.2.0
*/
private function buildApiCallFailureMessage(\Zend_Http_Response $response)
{
diff --git a/Model/SignifydGateway/Debugger/BlackHole.php b/Model/SignifydGateway/Debugger/BlackHole.php
index 7057313b5e415..dcf436f5a15ce 100644
--- a/Model/SignifydGateway/Debugger/BlackHole.php
+++ b/Model/SignifydGateway/Debugger/BlackHole.php
@@ -10,12 +10,14 @@
/**
* This debugger ignores any information.
* Optimal production environment.
+ * @since 2.2.0
*/
class BlackHole implements DebuggerInterface
{
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ * @since 2.2.0
*/
public function success($requestUrl, $requestData, $responseStatus, $responseBody)
{
@@ -25,6 +27,7 @@ public function success($requestUrl, $requestData, $responseStatus, $responseBod
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ * @since 2.2.0
*/
public function failure($requestUrl, $requestData, Exception $exception)
{
diff --git a/Model/SignifydGateway/Debugger/DebuggerFactory.php b/Model/SignifydGateway/Debugger/DebuggerFactory.php
index 02031e6f5b9b5..3cb91611020bf 100644
--- a/Model/SignifydGateway/Debugger/DebuggerFactory.php
+++ b/Model/SignifydGateway/Debugger/DebuggerFactory.php
@@ -14,16 +14,19 @@
* Configuration may be changed by
* - config.xml
* - at Admin panel (Stores > Configuration > Sales > Fraud Detection > Signifyd > Debug)
+ * @since 2.2.0
*/
class DebuggerFactory
{
/**
* @var ObjectManagerInterface
+ * @since 2.2.0
*/
private $objectManager;
/**
* @var Config
+ * @since 2.2.0
*/
private $config;
@@ -32,6 +35,7 @@ class DebuggerFactory
*
* @param bjectManagerInterface $objectManager
* @param Config $config
+ * @since 2.2.0
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -45,6 +49,7 @@ public function __construct(
* Create debugger instance
*
* @return DebuggerInterface
+ * @since 2.2.0
*/
public function create()
{
diff --git a/Model/SignifydGateway/Debugger/DebuggerInterface.php b/Model/SignifydGateway/Debugger/DebuggerInterface.php
index f4a2f9cc56a8f..931d3109bc2f2 100644
--- a/Model/SignifydGateway/Debugger/DebuggerInterface.php
+++ b/Model/SignifydGateway/Debugger/DebuggerInterface.php
@@ -9,6 +9,7 @@
/**
* Interface for debugging interaction with Signifyd API
+ * @since 2.2.0
*/
interface DebuggerInterface
{
@@ -20,6 +21,7 @@ interface DebuggerInterface
* @param string $responseStatus
* @param string $responseBody
* @return void
+ * @since 2.2.0
*/
public function success($requestUrl, $requestData, $responseStatus, $responseBody);
@@ -30,6 +32,7 @@ public function success($requestUrl, $requestData, $responseStatus, $responseBod
* @param string $requestData
* @param Exception $exception
* @return mixed
+ * @since 2.2.0
*/
public function failure($requestUrl, $requestData, Exception $exception);
}
diff --git a/Model/SignifydGateway/Debugger/Log.php b/Model/SignifydGateway/Debugger/Log.php
index 4b7258180f53e..a89ba1fa1d18f 100644
--- a/Model/SignifydGateway/Debugger/Log.php
+++ b/Model/SignifydGateway/Debugger/Log.php
@@ -10,11 +10,13 @@
/**
* Debugger writes information about request, response and possible exception to standard system log.
+ * @since 2.2.0
*/
class Log implements DebuggerInterface
{
/**
* @var LoggerInterface
+ * @since 2.2.0
*/
private $logger;
@@ -22,6 +24,7 @@ class Log implements DebuggerInterface
* Log constructor.
*
* @param LoggerInterface $logger
+ * @since 2.2.0
*/
public function __construct(LoggerInterface $logger)
{
@@ -30,6 +33,7 @@ public function __construct(LoggerInterface $logger)
/**
* {@inheritdoc}
+ * @since 2.2.0
*/
public function success($requestUrl, $requestData, $responseStatus, $responseBody)
{
@@ -44,6 +48,7 @@ public function success($requestUrl, $requestData, $responseStatus, $responseBod
/**
* {@inheritdoc}
+ * @since 2.2.0
*/
public function failure($requestUrl, $requestData, Exception $exception)
{
@@ -62,6 +67,7 @@ public function failure($requestUrl, $requestData, Exception $exception)
* @param string $requestUrl
* @param string $requestData
* @return string
+ * @since 2.2.0
*/
private function buildRequestInfo($requestUrl, $requestData)
{
@@ -78,6 +84,7 @@ private function buildRequestInfo($requestUrl, $requestData)
* @param string $responseStatus
* @param string $responseBody
* @return string
+ * @since 2.2.0
*/
private function buildResponseInfo($responseStatus, $responseBody)
{
@@ -93,6 +100,7 @@ private function buildResponseInfo($responseStatus, $responseBody)
*
* @param Exception $exception
* @return string
+ * @since 2.2.0
*/
private function buildExceptionInfo(Exception $exception)
{
@@ -106,6 +114,7 @@ private function buildExceptionInfo(Exception $exception)
*
* @param string $info
* @return void
+ * @since 2.2.0
*/
private function writeToLog($info)
{
@@ -119,6 +128,7 @@ private function writeToLog($info)
* @param string $title
* @param string $content
* @return string
+ * @since 2.2.0
*/
private function buildInfoSection($title, $content)
{
@@ -133,6 +143,7 @@ private function buildInfoSection($title, $content)
* @param string $content
* @param string $indent
* @return string
+ * @since 2.2.0
*/
private function addIndent($content, $indent = ' ')
{
diff --git a/Model/SignifydGateway/Gateway.php b/Model/SignifydGateway/Gateway.php
index ddcaa6cd696f2..da9d9c85bca5a 100644
--- a/Model/SignifydGateway/Gateway.php
+++ b/Model/SignifydGateway/Gateway.php
@@ -12,6 +12,7 @@
* Signifyd Gateway.
*
* Encapsulates interaction with Signifyd API.
+ * @since 2.2.0
*/
class Gateway
{
@@ -45,11 +46,13 @@ class Gateway
/**
* @var CreateCaseBuilderInterface
+ * @since 2.2.0
*/
private $createCaseBuilder;
/**
* @var ApiClient
+ * @since 2.2.0
*/
private $apiClient;
@@ -58,6 +61,7 @@ class Gateway
*
* @param CreateCaseBuilderInterface $createCaseBuilder
* @param ApiClient $apiClient
+ * @since 2.2.0
*/
public function __construct(
CreateCaseBuilderInterface $createCaseBuilder,
@@ -74,6 +78,7 @@ public function __construct(
* @param int $orderId
* @return int Signifyd case (investigation) identifier
* @throws GatewayException
+ * @since 2.2.0
*/
public function createCase($orderId)
{
@@ -99,6 +104,7 @@ public function createCase($orderId)
* @param int $signifydCaseId
* @return string
* @throws GatewayException
+ * @since 2.2.0
*/
public function submitCaseForGuarantee($signifydCaseId)
{
@@ -121,6 +127,7 @@ public function submitCaseForGuarantee($signifydCaseId)
* @param int $caseId
* @return string
* @throws GatewayException
+ * @since 2.2.0
*/
public function cancelGuarantee($caseId)
{
@@ -148,6 +155,7 @@ public function cancelGuarantee($caseId)
* @param array $result
* @return string
* @throws GatewayException
+ * @since 2.2.0
*/
private function processDispositionResult(array $result)
{
diff --git a/Model/SignifydGateway/GatewayException.php b/Model/SignifydGateway/GatewayException.php
index 666217f8ccc85..416826a54c793 100644
--- a/Model/SignifydGateway/GatewayException.php
+++ b/Model/SignifydGateway/GatewayException.php
@@ -7,6 +7,7 @@
/**
* Exception of interaction with Signifyd API
+ * @since 2.2.0
*/
class GatewayException extends \Exception
{
diff --git a/Model/SignifydGateway/Request/AddressBuilder.php b/Model/SignifydGateway/Request/AddressBuilder.php
index f95968d4a1bf7..161870b3a87ab 100644
--- a/Model/SignifydGateway/Request/AddressBuilder.php
+++ b/Model/SignifydGateway/Request/AddressBuilder.php
@@ -9,6 +9,7 @@
/**
* Prepare address data
+ * @since 2.2.0
*/
class AddressBuilder
{
@@ -17,6 +18,7 @@ class AddressBuilder
*
* @param OrderAddressInterface $address
* @return array
+ * @since 2.2.0
*/
public function build(OrderAddressInterface $address)
{
@@ -36,6 +38,7 @@ public function build(OrderAddressInterface $address)
* @param int $number
* @param string[]|null $street
* @return string
+ * @since 2.2.0
*/
private function getStreetLine($number, $street)
{
diff --git a/Model/SignifydGateway/Request/CardBuilder.php b/Model/SignifydGateway/Request/CardBuilder.php
index 5e3a1a83e7aeb..53ea7e2541639 100644
--- a/Model/SignifydGateway/Request/CardBuilder.php
+++ b/Model/SignifydGateway/Request/CardBuilder.php
@@ -9,16 +9,19 @@
/**
* Prepare data related to the card that was used for the purchase and its cardholder.
+ * @since 2.2.0
*/
class CardBuilder
{
/**
* @var AddressBuilder
+ * @since 2.2.0
*/
private $addressBuilder;
/**
* @param AddressBuilder $addressBuilder
+ * @since 2.2.0
*/
public function __construct(
AddressBuilder $addressBuilder
@@ -31,6 +34,7 @@ public function __construct(
*
* @param Order $order
* @return array
+ * @since 2.2.0
*/
public function build(Order $order)
{
diff --git a/Model/SignifydGateway/Request/ClientVersionBuilder.php b/Model/SignifydGateway/Request/ClientVersionBuilder.php
index 8db06473b96d8..8507cec083721 100644
--- a/Model/SignifydGateway/Request/ClientVersionBuilder.php
+++ b/Model/SignifydGateway/Request/ClientVersionBuilder.php
@@ -9,21 +9,25 @@
/**
* Provides platform name, edition and version info
+ * @since 2.2.0
*/
class ClientVersionBuilder
{
/**
* @var string
+ * @since 2.2.0
*/
private static $clientVersion = '1.0';
/**
* @var ProductMetadataInterface
+ * @since 2.2.0
*/
private $productMetadata;
/**
* @param ProductMetadataInterface $productMetadata
+ * @since 2.2.0
*/
public function __construct(
ProductMetadataInterface $productMetadata
@@ -35,6 +39,7 @@ public function __construct(
* Returns version info
*
* @return array
+ * @since 2.2.0
*/
public function build()
{
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilder.php b/Model/SignifydGateway/Request/CreateCaseBuilder.php
index 3e41003d47842..6bd567fd2070d 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/Model/SignifydGateway/Request/CreateCaseBuilder.php
@@ -12,41 +12,49 @@
*
* Handles the conversion from Magento Order to Signifyd Case.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ * @since 2.2.0
*/
class CreateCaseBuilder implements CreateCaseBuilderInterface
{
/**
* @var OrderFactory
+ * @since 2.2.0
*/
private $orderFactory;
/**
* @var PurchaseBuilder
+ * @since 2.2.0
*/
private $purchaseBuilder;
/**
* @var CardBuilder
+ * @since 2.2.0
*/
private $cardBuilder;
/**
* @var RecipientBuilder
+ * @since 2.2.0
*/
private $recipientBuilder;
/**
* @var SellerBuilder
+ * @since 2.2.0
*/
private $sellerBuilder;
/**
* @var ClientVersionBuilder
+ * @since 2.2.0
*/
private $clientVersionBuilder;
/**
* @var UserAccountBuilder
+ * @since 2.2.0
*/
private $userAccountBuilder;
@@ -58,6 +66,7 @@ class CreateCaseBuilder implements CreateCaseBuilderInterface
* @param SellerBuilder $sellerBuilder
* @param ClientVersionBuilder $clientVersionBuilder
* @param UserAccountBuilder $userAccountBuilder
+ * @since 2.2.0
*/
public function __construct(
OrderFactory $orderFactory,
@@ -79,6 +88,7 @@ public function __construct(
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function build($orderId)
{
@@ -102,6 +112,7 @@ public function build($orderId)
*
* @param array $data
* @return array
+ * @since 2.2.0
*/
private function removeEmptyValues($data)
{
@@ -123,6 +134,7 @@ private function removeEmptyValues($data)
*
* @param mixed $value
* @return bool
+ * @since 2.2.0
*/
private function isEmpty($value)
{
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php b/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
index 56662f69e7c5a..ea8b044277aa3 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
+++ b/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
@@ -9,6 +9,7 @@
* 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
+ * @since 2.2.0
*/
interface CreateCaseBuilderInterface
{
@@ -17,6 +18,7 @@ interface CreateCaseBuilderInterface
*
* @param int $orderId
* @return array
+ * @since 2.2.0
*/
public function build($orderId);
}
diff --git a/Model/SignifydGateway/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
index 858ce0f0f3287..1d9ca9256a6f3 100644
--- a/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -16,31 +16,37 @@
/**
* Prepare data related to purchase event represented in case creation request.
+ * @since 2.2.0
*/
class PurchaseBuilder
{
/**
* @var DateTimeFactory
+ * @since 2.2.0
*/
private $dateTimeFactory;
/**
* @var ScopeInterface
+ * @since 2.2.0
*/
private $scope;
/**
* @var SignifydOrderSessionId
+ * @since 2.2.0
*/
private $signifydOrderSessionId;
/**
* @var PaymentVerificationFactory
+ * @since 2.2.0
*/
private $paymentVerificationFactory;
/**
* @var PaymentMethodMapper
+ * @since 2.2.0
*/
private $paymentMethodMapper;
@@ -52,6 +58,7 @@ class PurchaseBuilder
* @param SignifydOrderSessionId $signifydOrderSessionId
* @param PaymentVerificationFactory $paymentVerificationFactory
* @param PaymentMethodMapper $paymentMethodMapper
+ * @since 2.2.0
*/
public function __construct(
DateTimeFactory $dateTimeFactory,
@@ -72,6 +79,7 @@ public function __construct(
*
* @param Order $order
* @return array
+ * @since 2.2.0
*/
public function build(Order $order)
{
@@ -123,6 +131,7 @@ public function build(Order $order)
*
* @param Order $order
* @return array
+ * @since 2.2.0
*/
private function getProducts(Order $order)
{
@@ -146,6 +155,7 @@ private function getProducts(Order $order)
*
* @param string $shippingDescription
* @return string
+ * @since 2.2.0
*/
private function getShipper($shippingDescription)
{
@@ -159,6 +169,7 @@ private function getShipper($shippingDescription)
*
* @param string $shippingDescription
* @return string
+ * @since 2.2.0
*/
private function getShippingMethod($shippingDescription)
{
@@ -172,6 +183,7 @@ private function getShippingMethod($shippingDescription)
*
* @param string $gatewayCode
* @return string
+ * @since 2.2.0
*/
private function getPaymentGateway($gatewayCode)
{
@@ -191,6 +203,7 @@ private function getPaymentGateway($gatewayCode)
* Returns WEB for web-orders, PHONE for orders created by Admin
*
* @return string
+ * @since 2.2.0
*/
private function getOrderChannel()
{
@@ -202,6 +215,7 @@ private function getOrderChannel()
*
* @param OrderPaymentInterface $orderPayment
* @return string
+ * @since 2.2.0
*/
private function getAvsCode(OrderPaymentInterface $orderPayment)
{
@@ -214,6 +228,7 @@ private function getAvsCode(OrderPaymentInterface $orderPayment)
*
* @param OrderPaymentInterface $orderPayment
* @return string
+ * @since 2.2.0
*/
private function getCvvCode(OrderPaymentInterface $orderPayment)
{
diff --git a/Model/SignifydGateway/Request/RecipientBuilder.php b/Model/SignifydGateway/Request/RecipientBuilder.php
index d9d26c8943b88..cea8171dcd243 100644
--- a/Model/SignifydGateway/Request/RecipientBuilder.php
+++ b/Model/SignifydGateway/Request/RecipientBuilder.php
@@ -9,16 +9,19 @@
/**
* Prepare data related to person or organization receiving the items purchased
+ * @since 2.2.0
*/
class RecipientBuilder
{
/**
* @var AddressBuilder
+ * @since 2.2.0
*/
private $addressBuilder;
/**
* @param AddressBuilder $addressBuilder
+ * @since 2.2.0
*/
public function __construct(
AddressBuilder $addressBuilder
@@ -31,6 +34,7 @@ public function __construct(
*
* @param Order $order
* @return array
+ * @since 2.2.0
*/
public function build(Order $order)
{
diff --git a/Model/SignifydGateway/Request/SellerBuilder.php b/Model/SignifydGateway/Request/SellerBuilder.php
index b2cf0401b247f..be24a9ef098b5 100644
--- a/Model/SignifydGateway/Request/SellerBuilder.php
+++ b/Model/SignifydGateway/Request/SellerBuilder.php
@@ -18,27 +18,32 @@
*
* This information is optional unless you are operating a marketplace,
* listing goods on behalf of multiple sellers who each hold a seller account registered with your site.
+ * @since 2.2.0
*/
class SellerBuilder
{
/**
* @var ScopeConfigInterface
+ * @since 2.2.0
*/
private $scopeConfig;
/**
* @var RegionFactory
+ * @since 2.2.0
*/
private $regionFactory;
/**
* @var array
+ * @since 2.2.0
*/
private $regionCodes = [];
/**
* @param ScopeConfigInterface $scopeConfig
* @param RegionFactory $regionFactory
+ * @since 2.2.0
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
@@ -53,6 +58,7 @@ public function __construct(
*
* @param Order $order
* @return array
+ * @since 2.2.0
*/
public function build(Order $order)
{
@@ -91,6 +97,7 @@ public function build(Order $order)
*
* @param int $regionId
* @return string
+ * @since 2.2.0
*/
private function getRegionCodeById($regionId)
{
@@ -107,6 +114,7 @@ private function getRegionCodeById($regionId)
* @param string $value
* @param StoreInterface $store
* @return mixed
+ * @since 2.2.0
*/
private function getConfigValue($value, StoreInterface $store)
{
@@ -122,6 +130,7 @@ private function getConfigValue($value, StoreInterface $store)
*
* @param StoreInterface $store
* @return string|null null if no DNS records corresponding to a current host found
+ * @since 2.2.0
*/
private function getPublicDomain(StoreInterface $store)
{
diff --git a/Model/SignifydGateway/Request/UserAccountBuilder.php b/Model/SignifydGateway/Request/UserAccountBuilder.php
index 0da49b85da869..2b9d920e94e26 100644
--- a/Model/SignifydGateway/Request/UserAccountBuilder.php
+++ b/Model/SignifydGateway/Request/UserAccountBuilder.php
@@ -10,21 +10,25 @@
/**
* Prepares details based on registered user account info
+ * @since 2.2.0
*/
class UserAccountBuilder
{
/**
* @var \Magento\Customer\Api\CustomerRepositoryInterface
+ * @since 2.2.0
*/
private $customerRepository;
/**
* @var \Magento\Framework\Intl\DateTimeFactory
+ * @since 2.2.0
*/
private $dateTimeFactory;
/**
* @var CustomerOrders
+ * @since 2.2.0
*/
private $customerOrders;
@@ -32,6 +36,7 @@ class UserAccountBuilder
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
* @param CustomerOrders $customerOrders
* @param \Magento\Framework\Intl\DateTimeFactory $dateTimeFactory
+ * @since 2.2.0
*/
public function __construct(
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
@@ -49,6 +54,7 @@ public function __construct(
*
* @param Order $order
* @return array
+ * @since 2.2.0
*/
public function build(Order $order)
{
@@ -87,6 +93,7 @@ public function build(Order $order)
*
* @param string $date
* @return string
+ * @since 2.2.0
*/
private function formatDate($date)
{
diff --git a/Model/SignifydGateway/Response/WebhookMessage.php b/Model/SignifydGateway/Response/WebhookMessage.php
index f77db737473c0..d8e974b955109 100644
--- a/Model/SignifydGateway/Response/WebhookMessage.php
+++ b/Model/SignifydGateway/Response/WebhookMessage.php
@@ -13,6 +13,7 @@
* They allow your application to receive pushed updates about a case, rather than poll SIGNIFYD for status changes.
*
* @see https://www.signifyd.com/docs/api/#/reference/webhooks
+ * @since 2.2.0
*/
class WebhookMessage
{
@@ -20,6 +21,7 @@ class WebhookMessage
* Decoded webhook request body.
*
* @var array
+ * @since 2.2.0
*/
private $data;
@@ -27,12 +29,14 @@ class WebhookMessage
* Event topic identifier.
*
* @var string
+ * @since 2.2.0
*/
private $eventTopic;
/**
* @param array $data
* @param string $eventTopic
+ * @since 2.2.0
*/
public function __construct(
array $data,
@@ -46,6 +50,7 @@ public function __construct(
* Returns decoded webhook request body.
*
* @return array
+ * @since 2.2.0
*/
public function getData()
{
@@ -56,6 +61,7 @@ public function getData()
* Returns event topic identifier.
*
* @return string
+ * @since 2.2.0
*/
public function getEventTopic()
{
diff --git a/Model/SignifydGateway/Response/WebhookMessageReader.php b/Model/SignifydGateway/Response/WebhookMessageReader.php
index 50389102359b1..7c4ea14ad9104 100644
--- a/Model/SignifydGateway/Response/WebhookMessageReader.php
+++ b/Model/SignifydGateway/Response/WebhookMessageReader.php
@@ -9,22 +9,26 @@
/**
* Reads request and produces webhook message data object based on request params.
+ * @since 2.2.0
*/
class WebhookMessageReader
{
/**
* @var DecoderInterface
+ * @since 2.2.0
*/
private $dataDecoder;
/**
* @var WebhookMessageFactory
+ * @since 2.2.0
*/
private $webhookMessageFactory;
/**
* @param DecoderInterface $decoder
* @param WebhookMessageFactory $webhookMessageFactory
+ * @since 2.2.0
*/
public function __construct(
DecoderInterface $decoder,
@@ -40,6 +44,7 @@ public function __construct(
* @param WebhookRequest $request
* @return WebhookMessage
* @throws \InvalidArgumentException
+ * @since 2.2.0
*/
public function read(WebhookRequest $request)
{
diff --git a/Model/SignifydGateway/Response/WebhookRequest.php b/Model/SignifydGateway/Response/WebhookRequest.php
index 214ccf0eeb70f..8768f0dfbe4db 100644
--- a/Model/SignifydGateway/Response/WebhookRequest.php
+++ b/Model/SignifydGateway/Response/WebhookRequest.php
@@ -9,16 +9,19 @@
/**
* Reads Signifyd webhook request data.
+ * @since 2.2.0
*/
class WebhookRequest
{
/**
* @var Http
+ * @since 2.2.0
*/
private $request;
/**
* @param Http $request
+ * @since 2.2.0
*/
public function __construct(
Http $request
@@ -30,6 +33,7 @@ public function __construct(
* Returns Base64 encoded output of the HMAC SHA256 encoding of the JSON body of the message.
*
* @return string
+ * @since 2.2.0
*/
public function getHash()
{
@@ -40,6 +44,7 @@ public function getHash()
* Returns event topic identifier.
*
* @return string
+ * @since 2.2.0
*/
public function getEventTopic()
{
@@ -50,6 +55,7 @@ public function getEventTopic()
* Returns raw data from the request body.
*
* @return string
+ * @since 2.2.0
*/
public function getBody()
{
diff --git a/Model/SignifydGateway/Response/WebhookRequestValidator.php b/Model/SignifydGateway/Response/WebhookRequestValidator.php
index 274ef2f854684..2326a54833f0a 100644
--- a/Model/SignifydGateway/Response/WebhookRequestValidator.php
+++ b/Model/SignifydGateway/Response/WebhookRequestValidator.php
@@ -11,6 +11,7 @@
/**
* Validates webhook request.
*
+ * @since 2.2.0
*/
class WebhookRequestValidator
{
@@ -18,6 +19,7 @@ class WebhookRequestValidator
* Allowed topic identifiers which will be sent in the X-SIGNIFYD-TOPIC header of the webhook.
*
* @var array
+ * @since 2.2.0
*/
private $allowedTopicValues = [
'cases/creation',
@@ -29,17 +31,20 @@ class WebhookRequestValidator
/**
* @var Config
+ * @since 2.2.0
*/
private $config;
/**
* @var DecoderInterface
+ * @since 2.2.0
*/
private $decoder;
/**
* @param Config $config
* @param DecoderInterface $decoder
+ * @since 2.2.0
*/
public function __construct(
Config $config,
@@ -54,6 +59,7 @@ public function __construct(
*
* @param WebhookRequest $webhookRequest
* @return bool
+ * @since 2.2.0
*/
public function validate(WebhookRequest $webhookRequest)
{
@@ -71,6 +77,7 @@ public function validate(WebhookRequest $webhookRequest)
*
* @param string $topic topic identifier.
* @return bool
+ * @since 2.2.0
*/
private function isValidTopic($topic)
{
@@ -82,6 +89,7 @@ private function isValidTopic($topic)
*
* @param string $body
* @return bool
+ * @since 2.2.0
*/
private function isValidBody($body)
{
@@ -101,6 +109,7 @@ private function isValidBody($body)
* @param string $body
* @param string $hash
* @return bool
+ * @since 2.2.0
*/
private function isValidHash($eventTopic, $body, $hash)
{
diff --git a/Model/SignifydOrderSessionId.php b/Model/SignifydOrderSessionId.php
index 52746bc4ec6c5..18f2734896ed4 100644
--- a/Model/SignifydOrderSessionId.php
+++ b/Model/SignifydOrderSessionId.php
@@ -9,16 +9,19 @@
/**
* Encapsulates generation of uuid by quote id.
+ * @since 2.2.0
*/
class SignifydOrderSessionId
{
/**
* @var IdentityGeneratorInterface
+ * @since 2.2.0
*/
private $identityGenerator;
/**
* @param IdentityGeneratorInterface $identityGenerator
+ * @since 2.2.0
*/
public function __construct(
IdentityGeneratorInterface $identityGenerator
@@ -31,6 +34,7 @@ public function __construct(
*
* @param int $quoteId
* @return string
+ * @since 2.2.0
*/
public function get($quoteId)
{
diff --git a/Observer/PlaceOrder.php b/Observer/PlaceOrder.php
index 3798522dbe506..1d75ec200c666 100644
--- a/Observer/PlaceOrder.php
+++ b/Observer/PlaceOrder.php
@@ -17,21 +17,25 @@
/**
* Observer should be triggered when new order is created and placed.
* If Signifyd integration enabled in configuration then new case will be created.
+ * @since 2.2.0
*/
class PlaceOrder implements ObserverInterface
{
/**
* @var Config
+ * @since 2.2.0
*/
private $signifydIntegrationConfig;
/**
* @var CaseCreationServiceInterface
+ * @since 2.2.0
*/
private $caseCreationService;
/**
* @var LoggerInterface
+ * @since 2.2.0
*/
private $logger;
@@ -39,6 +43,7 @@ class PlaceOrder implements ObserverInterface
* @param Config $signifydIntegrationConfig
* @param CaseCreationServiceInterface $caseCreationService
* @param LoggerInterface $logger
+ * @since 2.2.0
*/
public function __construct(
Config $signifydIntegrationConfig,
@@ -52,6 +57,7 @@ public function __construct(
/**
* {@inheritdoc}
+ * @since 2.2.0
*/
public function execute(Observer $observer)
{
@@ -77,6 +83,7 @@ public function execute(Observer $observer)
*
* @param OrderInterface $order
* @return void
+ * @since 2.2.0
*/
private function createCaseForOrder($order)
{
@@ -97,6 +104,7 @@ private function createCaseForOrder($order)
*
* @param Event $event
* @return OrderInterface[]|null
+ * @since 2.2.0
*/
private function extractOrders(Event $event)
{
diff --git a/Plugin/OrderPlugin.php b/Plugin/OrderPlugin.php
index 663409d0eb824..3d746fa58bf0d 100644
--- a/Plugin/OrderPlugin.php
+++ b/Plugin/OrderPlugin.php
@@ -13,16 +13,19 @@
* Plugin for Magento\Sales\Model\Order.
*
* @see Order
+ * @since 2.2.0
*/
class OrderPlugin
{
/**
* @var GuaranteeCancelingServiceInterface
+ * @since 2.2.0
*/
private $guaranteeCancelingService;
/**
* @param GuaranteeCancelingServiceInterface $guaranteeCancelingService
+ * @since 2.2.0
*/
public function __construct(
GuaranteeCancelingServiceInterface $guaranteeCancelingService
@@ -38,6 +41,7 @@ public function __construct(
* @param Order $order
* @param OrderInterface $result
* @return OrderInterface
+ * @since 2.2.0
*/
public function afterCancel(Order $order, $result)
{
diff --git a/Plugin/PaymentPlugin.php b/Plugin/PaymentPlugin.php
index 17cf4d7e7dbe9..8b95ac97f151b 100644
--- a/Plugin/PaymentPlugin.php
+++ b/Plugin/PaymentPlugin.php
@@ -13,16 +13,19 @@
* Plugin for Magento\Payment\Model\MethodInterface.
*
* @see MethodInterface
+ * @since 2.2.0
*/
class PaymentPlugin
{
/**
* @var GuaranteeCancelingServiceInterface
+ * @since 2.2.0
*/
private $guaranteeCancelingService;
/**
* @param GuaranteeCancelingServiceInterface $guaranteeCancelingService
+ * @since 2.2.0
*/
public function __construct(
GuaranteeCancelingServiceInterface $guaranteeCancelingService
@@ -40,6 +43,7 @@ public function __construct(
* @param MethodInterface|bool $result
* @param InfoInterface $payment
* @return bool|MethodInterface
+ * @since 2.2.0
*/
public function afterDenyPayment(MethodInterface $subject, $result, InfoInterface $payment)
{
@@ -59,6 +63,7 @@ public function afterDenyPayment(MethodInterface $subject, $result, InfoInterfac
* @param InfoInterface $payment
* @param MethodInterface $result
* @return bool
+ * @since 2.2.0
*/
private function isPaymentDenied($payment, $result)
{
diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php
index 101afd584484a..e0498397ddd7d 100644
--- a/Setup/InstallSchema.php
+++ b/Setup/InstallSchema.php
@@ -14,21 +14,25 @@
/**
* Creates all required table and keys for Signifyd case
+ * @since 2.2.0
*/
class InstallSchema implements InstallSchemaInterface
{
/**
* @var string
+ * @since 2.2.0
*/
private static $table = 'signifyd_case';
/**
* @var string
+ * @since 2.2.0
*/
private static $connectionName = 'sales';
/**
* @inheritdoc
+ * @since 2.2.0
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
diff --git a/Ui/Component/Listing/Column/Guarantee/Options.php b/Ui/Component/Listing/Column/Guarantee/Options.php
index 1e6234a8e27a9..517090706565b 100644
--- a/Ui/Component/Listing/Column/Guarantee/Options.php
+++ b/Ui/Component/Listing/Column/Guarantee/Options.php
@@ -11,11 +11,13 @@
/**
* Class Options
+ * @since 2.2.0
*/
class Options implements OptionSourceInterface
{
/**
* @var Escaper
+ * @since 2.2.0
*/
private $escaper;
@@ -23,6 +25,7 @@ class Options implements OptionSourceInterface
* Constructor
*
* @param Escaper $escaper
+ * @since 2.2.0
*/
public function __construct(Escaper $escaper)
{
@@ -31,6 +34,7 @@ public function __construct(Escaper $escaper)
/**
* {@inheritdoc}
+ * @since 2.2.0
*/
public function toOptionArray()
{
From 2d475f2c331a527317ccb9e3a4f8bbd5cab2e20e Mon Sep 17 00:00:00 2001
From: Oleksii Korshenko
Date: Fri, 4 Aug 2017 19:17:23 -0500
Subject: [PATCH 0332/2045] MAGETWO-71174: Update doc block information in php
classes with @deprecated and @since tags
- replaced release version with package version in @since and @depreacated tags
- removed @since tag from private properties/methods and non @api classes
---
Api/CaseCreationServiceInterface.php | 4 +-
Api/CaseManagementInterface.php | 6 +--
Api/CaseRepositoryInterface.php | 12 ++---
Api/Data/CaseInterface.php | 46 +++++++++----------
Api/Data/CaseSearchResultsInterface.php | 6 +--
Api/GuaranteeCancelingServiceInterface.php | 4 +-
Api/GuaranteeCreationServiceInterface.php | 4 +-
Block/Adminhtml/CaseInfo.php | 13 ++----
.../System/Config/Field/WebhookUrl.php | 4 --
.../Adminhtml/System/Config/Fieldset/Info.php | 2 -
Block/Fingerprint.php | 13 ++----
Controller/Webhooks/Handler.php | 11 -----
Model/CaseEntity.php | 27 -----------
Model/CaseManagement.php | 8 ----
Model/CaseRepository.php | 12 -----
Model/CaseServices/CreationService.php | 9 ----
Model/CaseServices/StubUpdatingService.php | 2 -
Model/CaseServices/UpdatingService.php | 9 ----
Model/CaseServices/UpdatingServiceFactory.php | 7 ---
.../CaseServices/UpdatingServiceInterface.php | 2 -
Model/CommentsHistoryUpdater.php | 4 --
Model/Config.php | 7 ---
Model/CustomerOrders.php | 13 ------
Model/Guarantee/CancelGuaranteeAbility.php | 6 ---
Model/Guarantee/CancelingService.php | 8 ----
Model/Guarantee/CreateGuaranteeAbility.php | 9 ----
Model/Guarantee/CreationService.php | 8 ----
Model/MessageGenerators/CaseRescore.php | 4 --
.../MessageGenerators/GeneratorException.php | 2 +-
Model/MessageGenerators/GeneratorFactory.php | 9 ----
.../MessageGenerators/GeneratorInterface.php | 2 -
Model/MessageGenerators/PatternGenerator.php | 5 --
Model/OrderStateService.php | 9 ----
.../PaymentMethodMapper.php | 4 --
.../XmlToArrayConfigConverter.php | 7 ---
Model/PaymentVerificationFactory.php | 9 ----
Model/PredefinedVerificationCode.php | 4 --
.../QuoteSession/Adminhtml/BackendSession.php | 4 --
Model/QuoteSession/FrontendSession.php | 4 --
Model/QuoteSession/QuoteSessionInterface.php | 2 -
Model/ResourceModel/CaseEntity.php | 2 -
Model/ResourceModel/CaseEntity/Collection.php | 2 -
.../NotSyncedOrderIdListProvider.php | 4 --
Model/SalesOrderGrid/OrderGridUpdater.php | 5 --
Model/SignifydGateway/ApiCallException.php | 4 --
Model/SignifydGateway/ApiClient.php | 4 --
.../Client/HttpClientFactory.php | 13 ------
.../SignifydGateway/Client/RequestBuilder.php | 6 ---
.../SignifydGateway/Client/RequestSender.php | 4 --
.../Client/ResponseHandler.php | 9 ----
Model/SignifydGateway/Debugger/BlackHole.php | 3 --
.../Debugger/DebuggerFactory.php | 5 --
.../Debugger/DebuggerInterface.php | 3 --
Model/SignifydGateway/Debugger/Log.php | 11 -----
Model/SignifydGateway/Gateway.php | 8 ----
Model/SignifydGateway/GatewayException.php | 1 -
.../Request/AddressBuilder.php | 3 --
Model/SignifydGateway/Request/CardBuilder.php | 4 --
.../Request/ClientVersionBuilder.php | 5 --
.../Request/CreateCaseBuilder.php | 12 -----
.../Request/CreateCaseBuilderInterface.php | 2 -
.../Request/PurchaseBuilder.php | 15 ------
.../Request/RecipientBuilder.php | 4 --
.../SignifydGateway/Request/SellerBuilder.php | 9 ----
.../Request/UserAccountBuilder.php | 7 ---
.../Response/WebhookMessage.php | 6 ---
.../Response/WebhookMessageReader.php | 5 --
.../Response/WebhookRequest.php | 6 ---
.../Response/WebhookRequestValidator.php | 9 ----
Model/SignifydOrderSessionId.php | 4 --
Observer/PlaceOrder.php | 8 ----
Plugin/OrderPlugin.php | 4 --
Plugin/PaymentPlugin.php | 5 --
Setup/InstallSchema.php | 4 --
.../Listing/Column/Guarantee/Options.php | 4 --
75 files changed, 51 insertions(+), 470 deletions(-)
diff --git a/Api/CaseCreationServiceInterface.php b/Api/CaseCreationServiceInterface.php
index 324e3eb36730f..f7611660b93a1 100644
--- a/Api/CaseCreationServiceInterface.php
+++ b/Api/CaseCreationServiceInterface.php
@@ -12,7 +12,7 @@
* Implementation should send request to Signifyd API and create new entity in Magento.
*
* @api
- * @since 2.2.0
+ * @since 100.2.0
*/
interface CaseCreationServiceInterface
{
@@ -23,7 +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 2.2.0
+ * @since 100.2.0
*/
public function createForOrder($orderId);
}
diff --git a/Api/CaseManagementInterface.php b/Api/CaseManagementInterface.php
index 06b2d0d6e4f51..69075a308cb96 100644
--- a/Api/CaseManagementInterface.php
+++ b/Api/CaseManagementInterface.php
@@ -10,7 +10,7 @@
* Allows to performs operations with Signifyd cases.
*
* @api
- * @since 2.2.0
+ * @since 100.2.0
*/
interface CaseManagementInterface
{
@@ -21,7 +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 2.2.0
+ * @since 100.2.0
*/
public function create($orderId);
@@ -30,7 +30,7 @@ public function create($orderId);
*
* @param int $orderId
* @return \Magento\Signifyd\Api\Data\CaseInterface|null
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getByOrderId($orderId);
}
diff --git a/Api/CaseRepositoryInterface.php b/Api/CaseRepositoryInterface.php
index 4dd4dee881232..4f148a082b300 100644
--- a/Api/CaseRepositoryInterface.php
+++ b/Api/CaseRepositoryInterface.php
@@ -9,7 +9,7 @@
* Signifyd Case repository interface
*
* @api
- * @since 2.2.0
+ * @since 100.2.0
*/
interface CaseRepositoryInterface
{
@@ -18,7 +18,7 @@ interface CaseRepositoryInterface
*
* @param \Magento\Signifyd\Api\Data\CaseInterface $case
* @return \Magento\Signifyd\Api\Data\CaseInterface
- * @since 2.2.0
+ * @since 100.2.0
*/
public function save(\Magento\Signifyd\Api\Data\CaseInterface $case);
@@ -27,7 +27,7 @@ public function save(\Magento\Signifyd\Api\Data\CaseInterface $case);
*
* @param int $id
* @return \Magento\Signifyd\Api\Data\CaseInterface
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getById($id);
@@ -36,7 +36,7 @@ public function getById($id);
*
* @param int $caseId
* @return \Magento\Signifyd\Api\Data\CaseInterface|null
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getByCaseId($caseId);
@@ -45,7 +45,7 @@ public function getByCaseId($caseId);
*
* @param \Magento\Signifyd\Api\Data\CaseInterface $case
* @return bool
- * @since 2.2.0
+ * @since 100.2.0
*/
public function delete(\Magento\Signifyd\Api\Data\CaseInterface $case);
@@ -54,7 +54,7 @@ public function delete(\Magento\Signifyd\Api\Data\CaseInterface $case);
*
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
* @return \Magento\Signifyd\Api\Data\CaseSearchResultsInterface
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
}
diff --git a/Api/Data/CaseInterface.php b/Api/Data/CaseInterface.php
index 5394ceb8238df..eff46b972fc02 100644
--- a/Api/Data/CaseInterface.php
+++ b/Api/Data/CaseInterface.php
@@ -12,7 +12,7 @@
*
* @api
* @see https://www.signifyd.com/docs/api/#/reference/cases/retrieve-a-case/get-a-case
- * @since 2.2.0
+ * @since 100.2.0
*/
interface CaseInterface
{
@@ -49,7 +49,7 @@ interface CaseInterface
* Returns local case entity identifier.
*
* @return int
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getEntityId();
@@ -58,7 +58,7 @@ public function getEntityId();
*
* @param int $id
* @return $this
- * @since 2.2.0
+ * @since 100.2.0
*/
public function setEntityId($id);
@@ -66,7 +66,7 @@ public function setEntityId($id);
* Returns Signifyd case identifier.
*
* @return int
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getCaseId();
@@ -75,7 +75,7 @@ public function getCaseId();
*
* @param int $id
* @return $this
- * @since 2.2.0
+ * @since 100.2.0
*/
public function setCaseId($id);
@@ -84,7 +84,7 @@ public function setCaseId($id);
* Returns null if state of guarantee eligible does not set yet.
*
* @return boolean|null
- * @since 2.2.0
+ * @since 100.2.0
*/
public function isGuaranteeEligible();
@@ -93,7 +93,7 @@ public function isGuaranteeEligible();
*
* @param bool $guaranteeEligible
* @return $this
- * @since 2.2.0
+ * @since 100.2.0
*/
public function setGuaranteeEligible($guaranteeEligible);
@@ -101,7 +101,7 @@ public function setGuaranteeEligible($guaranteeEligible);
* Returns decision state of the guarantee.
*
* @return string
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getGuaranteeDisposition();
@@ -110,7 +110,7 @@ public function getGuaranteeDisposition();
*
* @param string $disposition
* @return $this
- * @since 2.2.0
+ * @since 100.2.0
*/
public function setGuaranteeDisposition($disposition);
@@ -118,7 +118,7 @@ public function setGuaranteeDisposition($disposition);
* Returns case status.
*
* @return string
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getStatus();
@@ -127,7 +127,7 @@ public function getStatus();
*
* @param string $status
* @return $this
- * @since 2.2.0
+ * @since 100.2.0
*/
public function setStatus($status);
@@ -135,7 +135,7 @@ public function setStatus($status);
* Returns value, which indicates the likelihood that the order is fraud.
*
* @return int
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getScore();
@@ -144,7 +144,7 @@ public function getScore();
*
* @param int $score
* @return $this
- * @since 2.2.0
+ * @since 100.2.0
*/
public function setScore($score);
@@ -152,7 +152,7 @@ public function setScore($score);
* Get order id for a case.
*
* @return int
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getOrderId();
@@ -161,7 +161,7 @@ public function getOrderId();
*
* @param int $orderId
* @return $this
- * @since 2.2.0
+ * @since 100.2.0
*/
public function setOrderId($orderId);
@@ -169,7 +169,7 @@ public function setOrderId($orderId);
* Returns data about a team associated with a case.
*
* @return array
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getAssociatedTeam();
@@ -178,7 +178,7 @@ public function getAssociatedTeam();
*
* @param array $team
* @return $this
- * @since 2.2.0
+ * @since 100.2.0
*/
public function setAssociatedTeam(array $team);
@@ -186,7 +186,7 @@ public function setAssociatedTeam(array $team);
* Returns disposition of an agent's opinion after reviewing the case.
*
* @return string
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getReviewDisposition();
@@ -195,7 +195,7 @@ public function getReviewDisposition();
*
* @param string $disposition
* @return $this
- * @since 2.2.0
+ * @since 100.2.0
*/
public function setReviewDisposition($disposition);
@@ -203,7 +203,7 @@ public function setReviewDisposition($disposition);
* Returns creation datetime for a case.
*
* @return string
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getCreatedAt();
@@ -212,7 +212,7 @@ public function getCreatedAt();
*
* @param string $datetime in DATE_ATOM format
* @return $this
- * @since 2.2.0
+ * @since 100.2.0
*/
public function setCreatedAt($datetime);
@@ -220,7 +220,7 @@ public function setCreatedAt($datetime);
* Returns updating datetime for a case.
*
* @return string
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getUpdatedAt();
@@ -229,7 +229,7 @@ public function getUpdatedAt();
*
* @param string $datetime in DATE_ATOM format
* @return $this
- * @since 2.2.0
+ * @since 100.2.0
*/
public function setUpdatedAt($datetime);
}
diff --git a/Api/Data/CaseSearchResultsInterface.php b/Api/Data/CaseSearchResultsInterface.php
index 0733afd8fe8e2..78d37841cff69 100644
--- a/Api/Data/CaseSearchResultsInterface.php
+++ b/Api/Data/CaseSearchResultsInterface.php
@@ -11,7 +11,7 @@
* Retrieve and set list of case entities.
*
* @api
- * @since 2.2.0
+ * @since 100.2.0
*/
interface CaseSearchResultsInterface extends SearchResultsInterface
{
@@ -19,7 +19,7 @@ interface CaseSearchResultsInterface extends SearchResultsInterface
* Gets collection of case entities.
*
* @return \Magento\Signifyd\Api\Data\CaseInterface[]
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getItems();
@@ -28,7 +28,7 @@ public function getItems();
*
* @param \Magento\Signifyd\Api\Data\CaseInterface[] $items
* @return $this
- * @since 2.2.0
+ * @since 100.2.0
*/
public function setItems(array $items);
}
diff --git a/Api/GuaranteeCancelingServiceInterface.php b/Api/GuaranteeCancelingServiceInterface.php
index 585444099e6c6..41f4753d036a7 100644
--- a/Api/GuaranteeCancelingServiceInterface.php
+++ b/Api/GuaranteeCancelingServiceInterface.php
@@ -12,7 +12,7 @@
* Implementation should send request to Signifyd API and update existing case entity with guarantee information.
*
* @api
- * @since 2.2.0
+ * @since 100.2.0
*/
interface GuaranteeCancelingServiceInterface
{
@@ -21,7 +21,7 @@ interface GuaranteeCancelingServiceInterface
*
* @param int $orderId
* @return bool
- * @since 2.2.0
+ * @since 100.2.0
*/
public function cancelForOrder($orderId);
}
diff --git a/Api/GuaranteeCreationServiceInterface.php b/Api/GuaranteeCreationServiceInterface.php
index b6dc3b9e1cdeb..b4502ea861acd 100644
--- a/Api/GuaranteeCreationServiceInterface.php
+++ b/Api/GuaranteeCreationServiceInterface.php
@@ -12,7 +12,7 @@
* Implementation should send request to Signifyd API and update existing case entity with guarantee infromation.
*
* @api
- * @since 2.2.0
+ * @since 100.2.0
*/
interface GuaranteeCreationServiceInterface
{
@@ -21,7 +21,7 @@ interface GuaranteeCreationServiceInterface
*
* @param int $orderId
* @return bool
- * @since 2.2.0
+ * @since 100.2.0
*/
public function createForOrder($orderId);
}
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index c301460af3259..79ca7074b46da 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/Block/Adminhtml/CaseInfo.php
@@ -14,19 +14,17 @@
* Get Signifyd Case Info
*
* @api
- * @since 2.2.0
+ * @since 100.2.0
*/
class CaseInfo extends Template
{
/**
* @var CaseInterface
- * @since 2.2.0
*/
private $caseEntity = false;
/**
* @var CaseManagement
- * @since 2.2.0
*/
private $caseManagement;
@@ -34,7 +32,7 @@ class CaseInfo extends Template
* @param Context $context
* @param CaseManagement $caseManagement
* @param array $data
- * @since 2.2.0
+ * @since 100.2.0
*/
public function __construct(
Context $context,
@@ -50,7 +48,6 @@ public function __construct(
* Gets case entity associated with order id.
*
* @return CaseInterface|null
- * @since 2.2.0
*/
private function getCaseEntity()
{
@@ -69,7 +66,6 @@ private function getCaseEntity()
* @param mixed $defaultValue
* @param callable $callback
* @return mixed
- * @since 2.2.0
*/
private function getCaseProperty($defaultValue, callable $callback)
{
@@ -80,7 +76,7 @@ private function getCaseProperty($defaultValue, callable $callback)
* Checks if case is exists for order
*
* @return bool
- * @since 2.2.0
+ * @since 100.2.0
*/
public function isEmptyCase()
{
@@ -91,7 +87,7 @@ public function isEmptyCase()
* Gets case guarantee disposition status.
*
* @return string
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getCaseGuaranteeDisposition()
{
@@ -117,7 +113,6 @@ public function getCaseGuaranteeDisposition()
* Retrieves current order Id.
*
* @return integer
- * @since 2.2.0
*/
private function getOrderId()
{
diff --git a/Block/Adminhtml/System/Config/Field/WebhookUrl.php b/Block/Adminhtml/System/Config/Field/WebhookUrl.php
index e71d7387bc5ce..7964d6b1af397 100644
--- a/Block/Adminhtml/System/Config/Field/WebhookUrl.php
+++ b/Block/Adminhtml/System/Config/Field/WebhookUrl.php
@@ -12,13 +12,11 @@
/**
* Input field transformed to text node with link to store Signifyd webhooks controller.
- * @since 2.2.0
*/
class WebhookUrl extends Field
{
/**
* @inheritdoc
- * @since 2.2.0
*/
protected function _getElementHtml(AbstractElement $element)
{
@@ -34,7 +32,6 @@ protected function _getElementHtml(AbstractElement $element)
/**
* @inheritdoc
- * @since 2.2.0
*/
protected function _isInheritCheckboxRequired(AbstractElement $element)
{
@@ -45,7 +42,6 @@ protected function _isInheritCheckboxRequired(AbstractElement $element)
* Return base store URL.
*
* @return string
- * @since 2.2.0
*/
private function getStoreUrl()
{
diff --git a/Block/Adminhtml/System/Config/Fieldset/Info.php b/Block/Adminhtml/System/Config/Fieldset/Info.php
index 0a4b184fc5d2a..c18c3dc596e21 100644
--- a/Block/Adminhtml/System/Config/Fieldset/Info.php
+++ b/Block/Adminhtml/System/Config/Fieldset/Info.php
@@ -9,13 +9,11 @@
/**
* Fieldset renderer with url attached to comment.
- * @since 2.2.0
*/
class Info extends Fieldset
{
/**
* @inheritdoc
- * @since 2.2.0
*/
protected function _getHeaderCommentHtml($element)
{
diff --git a/Block/Fingerprint.php b/Block/Fingerprint.php
index fea1b4c84a36c..f25ff97804503 100644
--- a/Block/Fingerprint.php
+++ b/Block/Fingerprint.php
@@ -19,31 +19,28 @@
*
* @api
* @see https://www.signifyd.com/docs/api/#/reference/device-fingerprint/create-a-case
- * @since 2.2.0
+ * @since 100.2.0
*/
class Fingerprint extends Template
{
/**
* @var SignifydOrderSessionId
- * @since 2.2.0
*/
private $signifydOrderSessionId;
/**
* @var Config
- * @since 2.2.0
*/
private $config;
/**
* @var QuoteSessionInterface
- * @since 2.2.0
*/
private $quoteSession;
/**
* @var string
- * @since 2.2.0
+ * @since 100.2.0
*/
protected $_template = 'fingerprint.phtml';
@@ -53,7 +50,7 @@ class Fingerprint extends Template
* @param SignifydOrderSessionId $signifydOrderSessionId
* @param QuoteSessionInterface $quoteSession
* @param array $data
- * @since 2.2.0
+ * @since 100.2.0
*/
public function __construct(
Context $context,
@@ -72,7 +69,7 @@ public function __construct(
* Returns a unique Signifyd order session id.
*
* @return string
- * @since 2.2.0
+ * @since 100.2.0
*/
public function getSignifydOrderSessionId()
{
@@ -85,7 +82,7 @@ public function getSignifydOrderSessionId()
* Checks if module is enabled.
*
* @return boolean
- * @since 2.2.0
+ * @since 100.2.0
*/
public function isModuleActive()
{
diff --git a/Controller/Webhooks/Handler.php b/Controller/Webhooks/Handler.php
index 9ba3723ac3c7c..12bd773d35a2f 100644
--- a/Controller/Webhooks/Handler.php
+++ b/Controller/Webhooks/Handler.php
@@ -20,7 +20,6 @@
* Responsible for handling webhook posts from Signifyd service.
*
* @see https://www.signifyd.com/docs/api/#/reference/webhooks/
- * @since 2.2.0
*/
class Handler extends Action
{
@@ -28,49 +27,41 @@ class Handler extends Action
* Event topic of test webhook request.
*
* @var string
- * @since 2.2.0
*/
private static $eventTopicTest = 'cases/test';
/**
* @var WebhookRequest
- * @since 2.2.0
*/
private $webhookRequest;
/**
* @var LoggerInterface
- * @since 2.2.0
*/
private $logger;
/**
* @var WebhookMessageReader
- * @since 2.2.0
*/
private $webhookMessageReader;
/**
* @var UpdatingServiceFactory
- * @since 2.2.0
*/
private $caseUpdatingServiceFactory;
/**
* @var WebhookRequestValidator
- * @since 2.2.0
*/
private $webhookRequestValidator;
/**
* @var CaseRepositoryInterface
- * @since 2.2.0
*/
private $caseRepository;
/**
* @var Config
- * @since 2.2.0
*/
private $config;
@@ -83,7 +74,6 @@ class Handler extends Action
* @param WebhookRequestValidator $webhookRequestValidator
* @param CaseRepositoryInterface $caseRepository
* @param Config $config
- * @since 2.2.0
*/
public function __construct(
Context $context,
@@ -109,7 +99,6 @@ public function __construct(
* Processes webhook request data and updates case entity
*
* @return void
- * @since 2.2.0
*/
public function execute()
{
diff --git a/Model/CaseEntity.php b/Model/CaseEntity.php
index 2acd609179ea4..c11c72db79f16 100644
--- a/Model/CaseEntity.php
+++ b/Model/CaseEntity.php
@@ -15,19 +15,16 @@
/**
* Implementation of Signifyd Case interface.
- * @since 2.2.0
*/
class CaseEntity extends AbstractModel implements CaseInterface
{
/**
* @var string
- * @since 2.2.0
*/
protected $_eventPrefix = 'signifyd_case';
/**
* @var SerializerInterface
- * @since 2.2.0
*/
private $serializer;
@@ -40,7 +37,6 @@ class CaseEntity extends AbstractModel implements CaseInterface
* @param array $data
* @param AbstractResource|null $resource
* @param AbstractDb|null $resourceCollection
- * @since 2.2.0
*/
public function __construct(
Context $context,
@@ -56,7 +52,6 @@ public function __construct(
/**
* @inheritdoc
- * @since 2.2.0
*/
protected function _construct()
{
@@ -65,7 +60,6 @@ protected function _construct()
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getEntityId()
{
@@ -74,7 +68,6 @@ public function getEntityId()
/**
* @inheritdoc
- * @since 2.2.0
*/
public function setEntityId($id)
{
@@ -84,7 +77,6 @@ public function setEntityId($id)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getCaseId()
{
@@ -93,7 +85,6 @@ public function getCaseId()
/**
* @inheritdoc
- * @since 2.2.0
*/
public function setCaseId($id)
{
@@ -103,7 +94,6 @@ public function setCaseId($id)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function isGuaranteeEligible()
{
@@ -113,7 +103,6 @@ public function isGuaranteeEligible()
/**
* @inheritdoc
- * @since 2.2.0
*/
public function setGuaranteeEligible($guaranteeEligible)
{
@@ -123,7 +112,6 @@ public function setGuaranteeEligible($guaranteeEligible)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getGuaranteeDisposition()
{
@@ -132,7 +120,6 @@ public function getGuaranteeDisposition()
/**
* @inheritdoc
- * @since 2.2.0
*/
public function setGuaranteeDisposition($disposition)
{
@@ -142,7 +129,6 @@ public function setGuaranteeDisposition($disposition)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getStatus()
{
@@ -151,7 +137,6 @@ public function getStatus()
/**
* @inheritdoc
- * @since 2.2.0
*/
public function setStatus($status)
{
@@ -161,7 +146,6 @@ public function setStatus($status)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getScore()
{
@@ -170,7 +154,6 @@ public function getScore()
/**
* @inheritdoc
- * @since 2.2.0
*/
public function setScore($score)
{
@@ -180,7 +163,6 @@ public function setScore($score)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getOrderId()
{
@@ -189,7 +171,6 @@ public function getOrderId()
/**
* @inheritdoc
- * @since 2.2.0
*/
public function setOrderId($orderId)
{
@@ -199,7 +180,6 @@ public function setOrderId($orderId)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getAssociatedTeam()
{
@@ -209,7 +189,6 @@ public function getAssociatedTeam()
/**
* @inheritdoc
- * @since 2.2.0
*/
public function setAssociatedTeam(array $team)
{
@@ -219,7 +198,6 @@ public function setAssociatedTeam(array $team)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getReviewDisposition()
{
@@ -228,7 +206,6 @@ public function getReviewDisposition()
/**
* @inheritdoc
- * @since 2.2.0
*/
public function setReviewDisposition($disposition)
{
@@ -238,7 +215,6 @@ public function setReviewDisposition($disposition)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getCreatedAt()
{
@@ -247,7 +223,6 @@ public function getCreatedAt()
/**
* @inheritdoc
- * @since 2.2.0
*/
public function setCreatedAt($datetime)
{
@@ -257,7 +232,6 @@ public function setCreatedAt($datetime)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getUpdatedAt()
{
@@ -266,7 +240,6 @@ public function getUpdatedAt()
/**
* @inheritdoc
- * @since 2.2.0
*/
public function setUpdatedAt($datetime)
{
diff --git a/Model/CaseManagement.php b/Model/CaseManagement.php
index b42d76127fc0c..1913f1e7a17b3 100644
--- a/Model/CaseManagement.php
+++ b/Model/CaseManagement.php
@@ -17,31 +17,26 @@
/**
*
* Default case management implementation
- * @since 2.2.0
*/
class CaseManagement implements CaseManagementInterface
{
/**
* @var CaseRepositoryInterface
- * @since 2.2.0
*/
private $caseRepository;
/**
* @var CaseInterfaceFactory
- * @since 2.2.0
*/
private $caseFactory;
/**
* @var FilterBuilder
- * @since 2.2.0
*/
private $filterBuilder;
/**
* @var SearchCriteriaBuilder
- * @since 2.2.0
*/
private $searchCriteriaBuilder;
@@ -51,7 +46,6 @@ class CaseManagement implements CaseManagementInterface
* @param CaseInterfaceFactory $caseFactory
* @param FilterBuilder $filterBuilder
* @param SearchCriteriaBuilder $searchCriteriaBuilder
- * @since 2.2.0
*/
public function __construct(
CaseRepositoryInterface $caseRepository,
@@ -67,7 +61,6 @@ public function __construct(
/**
* @inheritdoc
- * @since 2.2.0
*/
public function create($orderId)
{
@@ -85,7 +78,6 @@ public function create($orderId)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getByOrderId($orderId)
{
diff --git a/Model/CaseRepository.php b/Model/CaseRepository.php
index 18ff3d5561ff3..ea3ea3e67aafd 100644
--- a/Model/CaseRepository.php
+++ b/Model/CaseRepository.php
@@ -20,37 +20,31 @@
* Repository for Case interface
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
- * @since 2.2.0
*/
class CaseRepository implements CaseRepositoryInterface
{
/**
* @var CollectionProcessorInterface
- * @since 2.2.0
*/
private $collectionProcessor;
/**
* @var CollectionFactory
- * @since 2.2.0
*/
private $collectionFactory;
/**
* @var CaseSearchResultsInterfaceFactory
- * @since 2.2.0
*/
private $searchResultsFactory;
/**
* @var CaseInterfaceFactory
- * @since 2.2.0
*/
private $caseFactory;
/**
* @var CaseResourceModel
- * @since 2.2.0
*/
private $resourceModel;
@@ -61,7 +55,6 @@ class CaseRepository implements CaseRepositoryInterface
* @param CaseSearchResultsInterfaceFactory $searchResultsFactory
* @param CaseInterfaceFactory $caseFactory
* @param CaseResourceModel $resourceModel
- * @since 2.2.0
*/
public function __construct(
CollectionProcessorInterface $collectionProcessor,
@@ -79,7 +72,6 @@ public function __construct(
/**
* @inheritdoc
- * @since 2.2.0
*/
public function save(CaseInterface $case)
{
@@ -91,7 +83,6 @@ public function save(CaseInterface $case)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getById($id)
{
@@ -104,7 +95,6 @@ public function getById($id)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getByCaseId($caseId)
{
@@ -117,7 +107,6 @@ public function getByCaseId($caseId)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function delete(CaseInterface $case)
{
@@ -128,7 +117,6 @@ public function delete(CaseInterface $case)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getList(SearchCriteriaInterface $searchCriteria)
{
diff --git a/Model/CaseServices/CreationService.php b/Model/CaseServices/CreationService.php
index 6a90e5db919e3..8413838bd7d5f 100644
--- a/Model/CaseServices/CreationService.php
+++ b/Model/CaseServices/CreationService.php
@@ -18,43 +18,36 @@
* Case Creation Service
*
* Creates new Case entity and register it at Signifyd
- * @since 2.2.0
*/
class CreationService implements CaseCreationServiceInterface
{
/**
* @var CaseManagementInterface
- * @since 2.2.0
*/
private $caseManagement;
/**
* @var Gateway;
- * @since 2.2.0
*/
private $signifydGateway;
/**
* @var LoggerInterface
- * @since 2.2.0
*/
private $logger;
/**
* @var CaseRepositoryInterface
- * @since 2.2.0
*/
private $caseRepository;
/**
* @var OrderGridUpdater
- * @since 2.2.0
*/
private $orderGridUpdater;
/**
* @var OrderStateService
- * @since 2.2.0
*/
private $orderStateService;
@@ -67,7 +60,6 @@ class CreationService implements CaseCreationServiceInterface
* @param CaseRepositoryInterface $caseRepository
* @param OrderGridUpdater $orderGridUpdater
* @param OrderStateService $orderStateService
- * @since 2.2.0
*/
public function __construct(
CaseManagementInterface $caseManagement,
@@ -87,7 +79,6 @@ public function __construct(
/**
* {@inheritdoc}
- * @since 2.2.0
*/
public function createForOrder($orderId)
{
diff --git a/Model/CaseServices/StubUpdatingService.php b/Model/CaseServices/StubUpdatingService.php
index 1a5e6c44c15b1..295d7f13fb0ac 100644
--- a/Model/CaseServices/StubUpdatingService.php
+++ b/Model/CaseServices/StubUpdatingService.php
@@ -10,13 +10,11 @@
/**
* Stub implementation for case updating service interface and might be used
* for test Signifyd webhooks
- * @since 2.2.0
*/
class StubUpdatingService implements UpdatingServiceInterface
{
/**
* @inheritdoc
- * @since 2.2.0
*/
public function update(CaseInterface $case, array $data)
{
diff --git a/Model/CaseServices/UpdatingService.php b/Model/CaseServices/UpdatingService.php
index 5afb6141e1fe5..870705db941cc 100644
--- a/Model/CaseServices/UpdatingService.php
+++ b/Model/CaseServices/UpdatingService.php
@@ -16,37 +16,31 @@
/**
* Performs Signifyd case entity updating operations.
- * @since 2.2.0
*/
class UpdatingService implements UpdatingServiceInterface
{
/**
* @var GeneratorInterface
- * @since 2.2.0
*/
private $messageGenerator;
/**
* @var CaseRepositoryInterface
- * @since 2.2.0
*/
private $caseRepository;
/**
* @var CommentsHistoryUpdater
- * @since 2.2.0
*/
private $commentsHistoryUpdater;
/**
* @var \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater
- * @since 2.2.0
*/
private $orderGridUpdater;
/**
* @var OrderStateService
- * @since 2.2.0
*/
private $orderStateService;
@@ -58,7 +52,6 @@ class UpdatingService implements UpdatingServiceInterface
* @param CommentsHistoryUpdater $commentsHistoryUpdater
* @param \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater $orderGridUpdater
* @param OrderStateService $orderStateService
- * @since 2.2.0
*/
public function __construct(
GeneratorInterface $messageGenerator,
@@ -82,7 +75,6 @@ public function __construct(
* @return void
* @throws NotFoundException
* @throws LocalizedException
- * @since 2.2.0
*/
public function update(CaseInterface $case, array $data)
{
@@ -111,7 +103,6 @@ public function update(CaseInterface $case, array $data)
* @param CaseInterface $case
* @param array $data
* @return void
- * @since 2.2.0
*/
private function setCaseData(CaseInterface $case, array $data)
{
diff --git a/Model/CaseServices/UpdatingServiceFactory.php b/Model/CaseServices/UpdatingServiceFactory.php
index c98bb7f0daf2e..5415044b5edc4 100644
--- a/Model/CaseServices/UpdatingServiceFactory.php
+++ b/Model/CaseServices/UpdatingServiceFactory.php
@@ -13,32 +13,27 @@
* 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).
- * @since 2.2.0
*/
class UpdatingServiceFactory
{
/**
* Type of testing Signifyd case
* @var string
- * @since 2.2.0
*/
private static $caseTest = 'cases/test';
/**
* @var ObjectManagerInterface
- * @since 2.2.0
*/
private $objectManager;
/**
* @var GeneratorFactory
- * @since 2.2.0
*/
private $generatorFactory;
/**
* @var Config
- * @since 2.2.0
*/
private $config;
@@ -48,7 +43,6 @@ class UpdatingServiceFactory
* @param ObjectManagerInterface $objectManager
* @param GeneratorFactory $generatorFactory
* @param Config $config
- * @since 2.2.0
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -67,7 +61,6 @@ public function __construct(
* @param string $type
* @return UpdatingServiceInterface
* @throws \InvalidArgumentException
- * @since 2.2.0
*/
public function create($type)
{
diff --git a/Model/CaseServices/UpdatingServiceInterface.php b/Model/CaseServices/UpdatingServiceInterface.php
index 8ebcf9991a664..daa7b40bfd674 100644
--- a/Model/CaseServices/UpdatingServiceInterface.php
+++ b/Model/CaseServices/UpdatingServiceInterface.php
@@ -9,7 +9,6 @@
/**
* Common abstraction to perform updating operations with Signifyd case entity.
- * @since 2.2.0
*/
interface UpdatingServiceInterface
{
@@ -19,7 +18,6 @@ interface UpdatingServiceInterface
* @param CaseInterface $case
* @param array $data
* @return void
- * @since 2.2.0
*/
public function update(CaseInterface $case, array $data);
}
diff --git a/Model/CommentsHistoryUpdater.php b/Model/CommentsHistoryUpdater.php
index 0d6b1a362716e..0a24c972c4c6b 100644
--- a/Model/CommentsHistoryUpdater.php
+++ b/Model/CommentsHistoryUpdater.php
@@ -11,13 +11,11 @@
/**
* Updates case order comments history.
- * @since 2.2.0
*/
class CommentsHistoryUpdater
{
/**
* @var HistoryFactory
- * @since 2.2.0
*/
private $historyFactory;
@@ -25,7 +23,6 @@ class CommentsHistoryUpdater
* CommentsHistoryUpdater constructor.
*
* @param HistoryFactory $historyFactory
- * @since 2.2.0
*/
public function __construct(HistoryFactory $historyFactory)
{
@@ -40,7 +37,6 @@ public function __construct(HistoryFactory $historyFactory)
* @param Phrase $message
* @param string $status
* @return void
- * @since 2.2.0
*/
public function addComment(CaseInterface $case, Phrase $message, $status = '')
{
diff --git a/Model/Config.php b/Model/Config.php
index ab70da2adc984..b68380ee15bf3 100644
--- a/Model/Config.php
+++ b/Model/Config.php
@@ -12,13 +12,11 @@
* Signifyd integration configuration.
*
* Class is a proxy service for retrieving configuration settings.
- * @since 2.2.0
*/
class Config
{
/**
* @var ScopeConfigInterface
- * @since 2.2.0
*/
private $scopeConfig;
@@ -26,7 +24,6 @@ class Config
* Config constructor.
*
* @param ScopeConfigInterface $scopeConfig
- * @since 2.2.0
*/
public function __construct(ScopeConfigInterface $scopeConfig)
{
@@ -38,7 +35,6 @@ public function __construct(ScopeConfigInterface $scopeConfig)
* (only possibility to configure Signifyd setting in admin)
*
* @return bool
- * @since 2.2.0
*/
public function isActive()
{
@@ -56,7 +52,6 @@ public function isActive()
* @see https://app.signifyd.com/settings
*
* @return string
- * @since 2.2.0
*/
public function getApiKey()
{
@@ -72,7 +67,6 @@ public function getApiKey()
* Usually equals to https://api.signifyd.com/v2 and should not be changed
*
* @return string
- * @since 2.2.0
*/
public function getApiUrl()
{
@@ -87,7 +81,6 @@ public function getApiUrl()
* If is "true" extra information about interaction with Signifyd API are written to debug.log file
*
* @return bool
- * @since 2.2.0
*/
public function isDebugModeEnabled()
{
diff --git a/Model/CustomerOrders.php b/Model/CustomerOrders.php
index 2c72e0582332d..c326cf06424c0 100644
--- a/Model/CustomerOrders.php
+++ b/Model/CustomerOrders.php
@@ -18,49 +18,41 @@
* Provides information about customer orders.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
- * @since 2.2.0
*/
class CustomerOrders
{
/**
* @var SearchCriteriaBuilder
- * @since 2.2.0
*/
private $searchCriteriaBuilder;
/**
* @var FilterBuilder
- * @since 2.2.0
*/
private $filterBuilder;
/**
* @var OrderRepositoryInterface
- * @since 2.2.0
*/
private $orderRepository;
/**
* @var LoggerInterface
- * @since 2.2.0
*/
private $logger;
/**
* @var CurrencyFactory
- * @since 2.2.0
*/
private $currencyFactory;
/**
* @var array
- * @since 2.2.0
*/
private $currencies = [];
/**
* @var string
- * @since 2.2.0
*/
private static $usdCurrencyCode = 'USD';
@@ -70,7 +62,6 @@ class CustomerOrders
* @param OrderRepositoryInterface $orderRepository
* @param CurrencyFactory $currencyFactory
* @param LoggerInterface $logger
- * @since 2.2.0
*/
public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
@@ -95,7 +86,6 @@ public function __construct(
*
* @param int $customerId
* @return array
- * @since 2.2.0
*/
public function getAggregatedOrdersInfo($customerId)
{
@@ -131,7 +121,6 @@ public function getAggregatedOrdersInfo($customerId)
*
* @param int $customerId
* @return OrderInterface[]
- * @since 2.2.0
*/
private function getCustomerOrders($customerId)
{
@@ -151,7 +140,6 @@ private function getCustomerOrders($customerId)
* @param float $amount
* @param string $currency
* @return float
- * @since 2.2.0
*/
private function getUsdOrderTotal($amount, $currency)
{
@@ -169,7 +157,6 @@ private function getUsdOrderTotal($amount, $currency)
*
* @param string|null $currencyCode
* @return Currency
- * @since 2.2.0
*/
private function getCurrencyByCode($currencyCode)
{
diff --git a/Model/Guarantee/CancelGuaranteeAbility.php b/Model/Guarantee/CancelGuaranteeAbility.php
index d63a22f9eb02b..65bede6f0cea5 100644
--- a/Model/Guarantee/CancelGuaranteeAbility.php
+++ b/Model/Guarantee/CancelGuaranteeAbility.php
@@ -13,26 +13,22 @@
/**
* Checks if is possible to cancel Guarantee for order.
- * @since 2.2.0
*/
class CancelGuaranteeAbility
{
/**
* @var CaseManagement
- * @since 2.2.0
*/
private $caseManagement;
/**
* @var OrderRepositoryInterface
- * @since 2.2.0
*/
private $orderRepository;
/**
* @param CaseManagement $caseManagement
* @param OrderRepositoryInterface $orderRepository
- * @since 2.2.0
*/
public function __construct(
CaseManagement $caseManagement,
@@ -47,7 +43,6 @@ public function __construct(
*
* @param int $orderId
* @return bool
- * @since 2.2.0
*/
public function isAvailable($orderId)
{
@@ -73,7 +68,6 @@ public function isAvailable($orderId)
*
* @param int $orderId
* @return OrderInterface|null
- * @since 2.2.0
*/
private function getOrder($orderId)
{
diff --git a/Model/Guarantee/CancelingService.php b/Model/Guarantee/CancelingService.php
index 9351dad376b60..b30efac8c2190 100644
--- a/Model/Guarantee/CancelingService.php
+++ b/Model/Guarantee/CancelingService.php
@@ -14,37 +14,31 @@
/**
* Sends request to Signifyd to cancel guarantee and updates case entity.
- * @since 2.2.0
*/
class CancelingService implements GuaranteeCancelingServiceInterface
{
/**
* @var CaseManagementInterface
- * @since 2.2.0
*/
private $caseManagement;
/**
* @var UpdatingServiceFactory
- * @since 2.2.0
*/
private $serviceFactory;
/**
* @var Gateway
- * @since 2.2.0
*/
private $gateway;
/**
* @var CancelGuaranteeAbility
- * @since 2.2.0
*/
private $cancelGuaranteeAbility;
/**
* @var LoggerInterface
- * @since 2.2.0
*/
private $logger;
@@ -56,7 +50,6 @@ class CancelingService implements GuaranteeCancelingServiceInterface
* @param Gateway $gateway
* @param CancelGuaranteeAbility $cancelGuaranteeAbility
* @param LoggerInterface $logger
- * @since 2.2.0
*/
public function __construct(
CaseManagementInterface $caseManagement,
@@ -74,7 +67,6 @@ public function __construct(
/**
* @inheritdoc
- * @since 2.2.0
*/
public function cancelForOrder($orderId)
{
diff --git a/Model/Guarantee/CreateGuaranteeAbility.php b/Model/Guarantee/CreateGuaranteeAbility.php
index a7873e370f1f1..15addba3ec4fd 100644
--- a/Model/Guarantee/CreateGuaranteeAbility.php
+++ b/Model/Guarantee/CreateGuaranteeAbility.php
@@ -15,25 +15,21 @@
/**
* Checks if is possible to create Guarantee for order.
- * @since 2.2.0
*/
class CreateGuaranteeAbility
{
/**
* @var CaseManagement
- * @since 2.2.0
*/
private $caseManagement;
/**
* @var OrderRepositoryInterface
- * @since 2.2.0
*/
private $orderRepository;
/**
* @var DateTimeFactory
- * @since 2.2.0
*/
private $dateTimeFactory;
@@ -41,7 +37,6 @@ class CreateGuaranteeAbility
* Eligible count of days from the order creation date to submit a case for Guarantee.
*
* @var int
- * @since 2.2.0
*/
private static $guarantyEligibleDays = 7;
@@ -49,7 +44,6 @@ class CreateGuaranteeAbility
* @param CaseManagement $caseManagement
* @param OrderRepositoryInterface $orderRepository
* @param DateTimeFactory $dateTimeFactory
- * @since 2.2.0
*/
public function __construct(
CaseManagement $caseManagement,
@@ -66,7 +60,6 @@ public function __construct(
*
* @param int $orderId
* @return bool
- * @since 2.2.0
*/
public function isAvailable($orderId)
{
@@ -101,7 +94,6 @@ public function isAvailable($orderId)
* @param OrderInterface $order
* @param int $days number of days from the order creation date to submit a case for Guarantee.
* @return bool
- * @since 2.2.0
*/
private function isOrderOlderThen($days, OrderInterface $order)
{
@@ -116,7 +108,6 @@ private function isOrderOlderThen($days, OrderInterface $order)
*
* @param int $orderId
* @return OrderInterface|null
- * @since 2.2.0
*/
private function getOrder($orderId)
{
diff --git a/Model/Guarantee/CreationService.php b/Model/Guarantee/CreationService.php
index bb6c30a62a524..4080aee453f18 100644
--- a/Model/Guarantee/CreationService.php
+++ b/Model/Guarantee/CreationService.php
@@ -16,37 +16,31 @@
/**
* Register guarantee at Signifyd and updates case entity
- * @since 2.2.0
*/
class CreationService implements GuaranteeCreationServiceInterface
{
/**
* @var CaseManagementInterface
- * @since 2.2.0
*/
private $caseManagement;
/**
* @var UpdatingServiceFactory
- * @since 2.2.0
*/
private $caseUpdatingServiceFactory;
/**
* @var Gateway
- * @since 2.2.0
*/
private $gateway;
/**
* @var CreateGuaranteeAbility
- * @since 2.2.0
*/
private $createGuaranteeAbility;
/**
* @var LoggerInterface
- * @since 2.2.0
*/
private $logger;
@@ -58,7 +52,6 @@ class CreationService implements GuaranteeCreationServiceInterface
* @param Gateway $gateway
* @param CreateGuaranteeAbility $createGuaranteeAbility
* @param LoggerInterface $logger
- * @since 2.2.0
*/
public function __construct(
CaseManagementInterface $caseManagement,
@@ -76,7 +69,6 @@ public function __construct(
/**
* @inheritdoc
- * @since 2.2.0
*/
public function createForOrder($orderId)
{
diff --git a/Model/MessageGenerators/CaseRescore.php b/Model/MessageGenerators/CaseRescore.php
index 344eb086b5cb6..d0e89854e3909 100644
--- a/Model/MessageGenerators/CaseRescore.php
+++ b/Model/MessageGenerators/CaseRescore.php
@@ -9,13 +9,11 @@
/**
* Generates message based on previous and current Case scores.
- * @since 2.2.0
*/
class CaseRescore implements GeneratorInterface
{
/**
* @var CaseRepositoryInterface
- * @since 2.2.0
*/
private $caseRepository;
@@ -23,7 +21,6 @@ class CaseRescore implements GeneratorInterface
* CaseRescore constructor.
*
* @param CaseRepositoryInterface $caseRepository
- * @since 2.2.0
*/
public function __construct(CaseRepositoryInterface $caseRepository)
{
@@ -32,7 +29,6 @@ public function __construct(CaseRepositoryInterface $caseRepository)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function generate(array $data)
{
diff --git a/Model/MessageGenerators/GeneratorException.php b/Model/MessageGenerators/GeneratorException.php
index 63eb000d2bd6e..103cb9fc1e2d3 100644
--- a/Model/MessageGenerators/GeneratorException.php
+++ b/Model/MessageGenerators/GeneratorException.php
@@ -11,7 +11,7 @@
* Common exception for Signifyd message generators.
*
* @api
- * @since 2.2.0
+ * @since 100.2.0
*/
class GeneratorException extends LocalizedException
{
diff --git a/Model/MessageGenerators/GeneratorFactory.php b/Model/MessageGenerators/GeneratorFactory.php
index 580b7c949bf31..66e02a3803950 100644
--- a/Model/MessageGenerators/GeneratorFactory.php
+++ b/Model/MessageGenerators/GeneratorFactory.php
@@ -10,49 +10,42 @@
/**
* Creates instance of message generator based on received type of message.
- * @since 2.2.0
*/
class GeneratorFactory
{
/**
* Type of message for Signifyd case creation.
* @var string
- * @since 2.2.0
*/
private static $caseCreation = 'cases/creation';
/**
* Type of message for Signifyd case re-scoring.
* @var string
- * @since 2.2.0
*/
private static $caseRescore = 'cases/rescore';
/**
* Type of message for Signifyd case reviewing
* @var string
- * @since 2.2.0
*/
private static $caseReview = 'cases/review';
/**
* Type of message of Signifyd guarantee completion
* @var string
- * @since 2.2.0
*/
private static $guaranteeCompletion = 'guarantees/completion';
/**
* Type of message of Signifyd guarantee creation
* @var string
- * @since 2.2.0
*/
private static $guaranteeCreation = 'guarantees/creation';
/**
* Type of message of Signifyd guarantee canceling
* @var string
- * @since 2.2.0
*/
private static $guaranteeCancel = 'guarantees/cancel';
@@ -60,7 +53,6 @@ class GeneratorFactory
* UpdatingServiceFactory constructor.
*
* @param ObjectManagerInterface $objectManager
- * @since 2.2.0
*/
public function __construct(ObjectManagerInterface $objectManager)
{
@@ -74,7 +66,6 @@ public function __construct(ObjectManagerInterface $objectManager)
* @param string $type
* @return GeneratorInterface
* @throws \InvalidArgumentException
- * @since 2.2.0
*/
public function create($type)
{
diff --git a/Model/MessageGenerators/GeneratorInterface.php b/Model/MessageGenerators/GeneratorInterface.php
index eab9dafb4f32f..385cbe35f05ac 100644
--- a/Model/MessageGenerators/GeneratorInterface.php
+++ b/Model/MessageGenerators/GeneratorInterface.php
@@ -8,7 +8,6 @@
/**
* Represents common abstraction for Signifyd Case/Guarantee messages.
* Each interface implementation might use Case/Guarantee data to generate specific message.
- * @since 2.2.0
*/
interface GeneratorInterface
{
@@ -17,7 +16,6 @@ interface GeneratorInterface
* @param array $data
* @return \Magento\Framework\Phrase
* @throws GeneratorException
- * @since 2.2.0
*/
public function generate(array $data);
}
diff --git a/Model/MessageGenerators/PatternGenerator.php b/Model/MessageGenerators/PatternGenerator.php
index 3c90d8584049c..8501934bebbc5 100644
--- a/Model/MessageGenerators/PatternGenerator.php
+++ b/Model/MessageGenerators/PatternGenerator.php
@@ -14,19 +14,16 @@
* placeholders, for example:
* 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'].
- * @since 2.2.0
*/
class PatternGenerator implements GeneratorInterface
{
/**
* @var string
- * @since 2.2.0
*/
private $template;
/**
* @var array
- * @since 2.2.0
*/
private $requiredParams;
@@ -35,7 +32,6 @@ class PatternGenerator implements GeneratorInterface
*
* @param string $template
* @param array $requiredParams
- * @since 2.2.0
*/
public function __construct($template, array $requiredParams = [])
{
@@ -45,7 +41,6 @@ public function __construct($template, array $requiredParams = [])
/**
* @inheritdoc
- * @since 2.2.0
*/
public function generate(array $data)
{
diff --git a/Model/OrderStateService.php b/Model/OrderStateService.php
index e409d6c735680..2b3f0e155981e 100644
--- a/Model/OrderStateService.php
+++ b/Model/OrderStateService.php
@@ -12,25 +12,21 @@
/**
* Updates order state.
- * @since 2.2.0
*/
class OrderStateService
{
/**
* @var OrderFactory
- * @since 2.2.0
*/
private $orderFactory;
/**
* @var OrderManagementInterface
- * @since 2.2.0
*/
private $orderManagement;
/**
* @var CommentsHistoryUpdater
- * @since 2.2.0
*/
private $commentsHistoryUpdater;
@@ -38,7 +34,6 @@ class OrderStateService
* @param OrderFactory $orderFactory
* @param OrderManagementInterface $orderManagement
* @param CommentsHistoryUpdater $commentsHistoryUpdater
- * @since 2.2.0
*/
public function __construct(
OrderFactory $orderFactory,
@@ -55,7 +50,6 @@ public function __construct(
*
* @param CaseInterface $case
* @return void
- * @since 2.2.0
*/
public function updateByCase(CaseInterface $case)
{
@@ -85,7 +79,6 @@ public function updateByCase(CaseInterface $case)
*
* @param int $orderId
* @return bool
- * @since 2.2.0
*/
private function unHold($orderId)
{
@@ -102,7 +95,6 @@ private function unHold($orderId)
*
* @param int $orderId
* @return bool
- * @since 2.2.0
*/
private function hold($orderId)
{
@@ -119,7 +111,6 @@ private function hold($orderId)
*
* @param int $orderId
* @return Order
- * @since 2.2.0
*/
private function getOrder($orderId)
{
diff --git a/Model/PaymentMethodMapper/PaymentMethodMapper.php b/Model/PaymentMethodMapper/PaymentMethodMapper.php
index 21f11ad6fbe79..cdf9041510b45 100644
--- a/Model/PaymentMethodMapper/PaymentMethodMapper.php
+++ b/Model/PaymentMethodMapper/PaymentMethodMapper.php
@@ -9,13 +9,11 @@
/**
* Load and cache configuration data.
- * @since 2.2.0
*/
class PaymentMethodMapper
{
/**
* @var Data
- * @since 2.2.0
*/
private $paymentMethodMapping;
@@ -23,7 +21,6 @@ class PaymentMethodMapper
* PaymentMapper constructor.
*
* @param Data $paymentMapping
- * @since 2.2.0
*/
public function __construct(Data $paymentMapping)
{
@@ -35,7 +32,6 @@ public function __construct(Data $paymentMapping)
*
* @param string $paymentMethod
* @return string
- * @since 2.2.0
*/
public function getSignifydPaymentMethodCode($paymentMethod)
{
diff --git a/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php b/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
index 9a5f65ac64c1b..5c3f23bb92729 100644
--- a/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
+++ b/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
@@ -9,7 +9,6 @@
/**
* Converts XML config file to payment methods mapping.
- * @since 2.2.0
*/
class XmlToArrayConfigConverter implements \Magento\Framework\Config\ConverterInterface
{
@@ -17,7 +16,6 @@ class XmlToArrayConfigConverter implements \Magento\Framework\Config\ConverterIn
* Node type wrapper for magento and signifyd payment codes
*
* @var string
- * @since 2.2.0
*/
private static $paymentMethodNodeType = 'payment_method';
@@ -25,7 +23,6 @@ class XmlToArrayConfigConverter implements \Magento\Framework\Config\ConverterIn
* Node type for payment methods code
*
* @var string
- * @since 2.2.0
*/
private static $magentoCodeNodeType = 'magento_code';
@@ -33,13 +30,11 @@ class XmlToArrayConfigConverter implements \Magento\Framework\Config\ConverterIn
* Node type for Sygnifyd payment methods code
*
* @var string
- * @since 2.2.0
*/
private static $signifydCodeNodeType = 'signifyd_code';
/**
* @inheritdoc
- * @since 2.2.0
*/
public function convert($source)
{
@@ -59,7 +54,6 @@ public function convert($source)
* @param \DOMElement $payment
* @return array
* @throws ValidationSchemaException
- * @since 2.2.0
*/
private function getPaymentMethodMapping(\DOMElement $payment)
{
@@ -76,7 +70,6 @@ private function getPaymentMethodMapping(\DOMElement $payment)
* @param string $subNodeType
* @return mixed
* @throws ValidationSchemaException
- * @since 2.2.0
*/
private function readSubnodeValue(\DOMElement $element, $subNodeType)
{
diff --git a/Model/PaymentVerificationFactory.php b/Model/PaymentVerificationFactory.php
index d06b5c1205761..a26beda520944 100644
--- a/Model/PaymentVerificationFactory.php
+++ b/Model/PaymentVerificationFactory.php
@@ -13,31 +13,26 @@
/**
* Creates verification service for provided payment method, or PaymentVerificationInterface::class
* if payment method does not support AVS, CVV verifications.
- * @since 2.2.0
*/
class PaymentVerificationFactory
{
/**
* @var ConfigInterface
- * @since 2.2.0
*/
private $config;
/**
* @var ObjectManagerInterface
- * @since 2.2.0
*/
private $objectManager;
/**
* @var PaymentVerificationInterface
- * @since 2.2.0
*/
private $avsDefaultAdapter;
/**
* @var PaymentVerificationInterface
- * @since 2.2.0
*/
private $cvvDefaultAdapter;
@@ -46,7 +41,6 @@ class PaymentVerificationFactory
* @param ConfigInterface|Config $config
* @param PaymentVerificationInterface $avsDefaultAdapter
* @param PaymentVerificationInterface $cvvDefaultAdapter
- * @since 2.2.0
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -67,7 +61,6 @@ public function __construct(
* @param string $paymentCode
* @return PaymentVerificationInterface
* @throws \Exception
- * @since 2.2.0
*/
public function createPaymentCvv($paymentCode)
{
@@ -81,7 +74,6 @@ public function createPaymentCvv($paymentCode)
* @param string $paymentCode
* @return PaymentVerificationInterface
* @throws \Exception
- * @since 2.2.0
*/
public function createPaymentAvs($paymentCode)
{
@@ -98,7 +90,6 @@ public function createPaymentAvs($paymentCode)
* @return PaymentVerificationInterface
* @throws ConfigurationMismatchException If payment verification instance
* does not implement PaymentVerificationInterface.
- * @since 2.2.0
*/
private function create(PaymentVerificationInterface $defaultAdapter, $paymentCode, $configKey)
{
diff --git a/Model/PredefinedVerificationCode.php b/Model/PredefinedVerificationCode.php
index 661a6f9f5d009..618d74b2a52e9 100644
--- a/Model/PredefinedVerificationCode.php
+++ b/Model/PredefinedVerificationCode.php
@@ -11,19 +11,16 @@
/**
* Default implementation of payment verification interface.
* The default code value can be configured via DI.
- * @since 2.2.0
*/
class PredefinedVerificationCode implements PaymentVerificationInterface
{
/**
* @var string
- * @since 2.2.0
*/
private $code;
/**
* @param string $code
- * @since 2.2.0
*/
public function __construct($code = '')
{
@@ -32,7 +29,6 @@ public function __construct($code = '')
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getCode(OrderPaymentInterface $orderPayment)
{
diff --git a/Model/QuoteSession/Adminhtml/BackendSession.php b/Model/QuoteSession/Adminhtml/BackendSession.php
index 8e1c0a8797ce7..9be02719545c7 100644
--- a/Model/QuoteSession/Adminhtml/BackendSession.php
+++ b/Model/QuoteSession/Adminhtml/BackendSession.php
@@ -10,13 +10,11 @@
/**
* Implementation of QuoteSessionInterface for Magento backend checkout.
- * @since 2.2.0
*/
class BackendSession implements QuoteSessionInterface
{
/**
* @var BackendQuoteSession
- * @since 2.2.0
*/
private $backendQuoteSession;
@@ -26,7 +24,6 @@ class BackendSession implements QuoteSessionInterface
* Class uses backend session for retrieving quote.
*
* @param BackendQuoteSession $backendQuoteSession
- * @since 2.2.0
*/
public function __construct(BackendQuoteSession $backendQuoteSession)
{
@@ -35,7 +32,6 @@ public function __construct(BackendQuoteSession $backendQuoteSession)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getQuote()
{
diff --git a/Model/QuoteSession/FrontendSession.php b/Model/QuoteSession/FrontendSession.php
index 973f58ca72b55..44c226ae4a47e 100644
--- a/Model/QuoteSession/FrontendSession.php
+++ b/Model/QuoteSession/FrontendSession.php
@@ -9,13 +9,11 @@
/**
* Implementation of QuoteSessionInterface for Magento frontend checkout.
- * @since 2.2.0
*/
class FrontendSession implements QuoteSessionInterface
{
/**
* @var CheckoutSession
- * @since 2.2.0
*/
private $checkoutSession;
@@ -25,7 +23,6 @@ class FrontendSession implements QuoteSessionInterface
* Class uses checkout session for retrieving quote.
*
* @param CheckoutSession $checkoutSession
- * @since 2.2.0
*/
public function __construct(CheckoutSession $checkoutSession)
{
@@ -34,7 +31,6 @@ public function __construct(CheckoutSession $checkoutSession)
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getQuote()
{
diff --git a/Model/QuoteSession/QuoteSessionInterface.php b/Model/QuoteSession/QuoteSessionInterface.php
index 6775d0923dcc8..14958ac65a6ee 100644
--- a/Model/QuoteSession/QuoteSessionInterface.php
+++ b/Model/QuoteSession/QuoteSessionInterface.php
@@ -7,7 +7,6 @@
/**
* Interface QuoteSessionInterface
- * @since 2.2.0
*/
interface QuoteSessionInterface
{
@@ -15,7 +14,6 @@ interface QuoteSessionInterface
* Returns quote from session.
*
* @return \Magento\Quote\Api\Data\CartInterface
- * @since 2.2.0
*/
public function getQuote();
}
diff --git a/Model/ResourceModel/CaseEntity.php b/Model/ResourceModel/CaseEntity.php
index dc77fd0179385..9c6ffde4504b9 100644
--- a/Model/ResourceModel/CaseEntity.php
+++ b/Model/ResourceModel/CaseEntity.php
@@ -9,13 +9,11 @@
/**
* Implementation of case resource model
- * @since 2.2.0
*/
class CaseEntity extends AbstractDb
{
/**
* @inheritdoc
- * @since 2.2.0
*/
protected function _construct()
{
diff --git a/Model/ResourceModel/CaseEntity/Collection.php b/Model/ResourceModel/CaseEntity/Collection.php
index a09e16d58af6a..92e233dd42dbc 100644
--- a/Model/ResourceModel/CaseEntity/Collection.php
+++ b/Model/ResourceModel/CaseEntity/Collection.php
@@ -11,13 +11,11 @@
/**
* Collection of case entities
- * @since 2.2.0
*/
class Collection extends AbstractCollection
{
/**
* @inheritdoc
- * @since 2.2.0
*/
public function _construct()
{
diff --git a/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php b/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
index 3c9b4308200b3..360225ae37b7b 100644
--- a/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
+++ b/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
@@ -11,19 +11,16 @@
/**
* Provides order ids list which Signifyd Case guaranty status were changed
- * @since 2.2.0
*/
class NotSyncedOrderIdListProvider implements NotSyncedDataProviderInterface
{
/**
* @var ResourceModel\CaseEntity
- * @since 2.2.0
*/
private $caseEntity;
/**
* @param ResourceModel\CaseEntity $caseEntity
- * @since 2.2.0
*/
public function __construct(
CaseEntity $caseEntity
@@ -33,7 +30,6 @@ public function __construct(
/**
* @inheritdoc
- * @since 2.2.0
*/
public function getIds($mainTableName, $gridTableName)
{
diff --git a/Model/SalesOrderGrid/OrderGridUpdater.php b/Model/SalesOrderGrid/OrderGridUpdater.php
index 9b4d345b2b98c..fff42b300be58 100644
--- a/Model/SalesOrderGrid/OrderGridUpdater.php
+++ b/Model/SalesOrderGrid/OrderGridUpdater.php
@@ -12,26 +12,22 @@
* Perfoms sales order grid updating operations.
*
* Serves order grid updates in both synchronous and asynchronous modes.
- * @since 2.2.0
*/
class OrderGridUpdater
{
/**
* @var ScopeConfigInterface
- * @since 2.2.0
*/
private $globalConfig;
/**
* @var GridInterface
- * @since 2.2.0
*/
private $entityGrid;
/**
* @param GridInterface $entityGrid
* @param ScopeConfigInterface $globalConfig
- * @since 2.2.0
*/
public function __construct(
GridInterface $entityGrid,
@@ -49,7 +45,6 @@ public function __construct(
*
* @param int $orderId
* @return void
- * @since 2.2.0
*/
public function update($orderId)
{
diff --git a/Model/SignifydGateway/ApiCallException.php b/Model/SignifydGateway/ApiCallException.php
index e5fe17e577850..73338c8ea4d62 100644
--- a/Model/SignifydGateway/ApiCallException.php
+++ b/Model/SignifydGateway/ApiCallException.php
@@ -7,13 +7,11 @@
/**
* Exception of interaction with Signifyd API
- * @since 2.2.0
*/
class ApiCallException extends GatewayException
{
/**
* @var string
- * @since 2.2.0
*/
private $requestData;
@@ -23,7 +21,6 @@ class ApiCallException extends GatewayException
* @param int $code
* @param \Exception|null $previous
* @param string $requestData in JSON format
- * @since 2.2.0
*/
public function __construct($message = '', $code = 0, \Exception $previous = null, $requestData = '')
{
@@ -34,7 +31,6 @@ public function __construct($message = '', $code = 0, \Exception $previous = nul
/**
* Gets request data for unsuccessful request in JSON format
* @return string
- * @since 2.2.0
*/
public function getRequestData()
{
diff --git a/Model/SignifydGateway/ApiClient.php b/Model/SignifydGateway/ApiClient.php
index 5377f05c99b12..0950ca1e22cfa 100644
--- a/Model/SignifydGateway/ApiClient.php
+++ b/Model/SignifydGateway/ApiClient.php
@@ -9,13 +9,11 @@
/**
* Encapsulates Signifyd API protocol.
- * @since 2.2.0
*/
class ApiClient
{
/**
* @var RequestBuilder
- * @since 2.2.0
*/
private $requestBuilder;
@@ -23,7 +21,6 @@ class ApiClient
* ApiClient constructor.
*
* @param RequestBuilder $requestBuilder
- * @since 2.2.0
*/
public function __construct(
RequestBuilder $requestBuilder
@@ -41,7 +38,6 @@ public function __construct(
* @param string $method
* @param array $params
* @return array
- * @since 2.2.0
*/
public function makeApiCall($url, $method, array $params = [])
{
diff --git a/Model/SignifydGateway/Client/HttpClientFactory.php b/Model/SignifydGateway/Client/HttpClientFactory.php
index 8117bf00653c2..41006bd7d1e0e 100644
--- a/Model/SignifydGateway/Client/HttpClientFactory.php
+++ b/Model/SignifydGateway/Client/HttpClientFactory.php
@@ -13,7 +13,6 @@
/**
* Class HttpClientFactory
* Creates and configures HTTP client for RequestBuilder
- * @since 2.2.0
*/
class HttpClientFactory
{
@@ -21,7 +20,6 @@ class HttpClientFactory
* Specifies basic HTTP access authentication Header.
*
* @var string
- * @since 2.2.0
*/
private static $authorizationType = 'Authorization';
@@ -29,31 +27,26 @@ class HttpClientFactory
* JSON HTTP Content-Type Header.
*
* @var string
- * @since 2.2.0
*/
private static $jsonDataType = 'application/json';
/**
* @var string
- * @since 2.2.0
*/
private static $urlSeparator = '/';
/**
* @var Config
- * @since 2.2.0
*/
private $config;
/**
* @var ZendClientFactory
- * @since 2.2.0
*/
private $clientFactory;
/**
* @var EncoderInterface
- * @since 2.2.0
*/
private $dataEncoder;
@@ -63,7 +56,6 @@ class HttpClientFactory
* @param Config $config
* @param ZendClientFactory $clientFactory
* @param EncoderInterface $dataEncoder
- * @since 2.2.0
*/
public function __construct(
Config $config,
@@ -82,7 +74,6 @@ public function __construct(
* @param string $method
* @param array $params
* @return ZendClient
- * @since 2.2.0
*/
public function create($url, $method, array $params = [])
{
@@ -106,7 +97,6 @@ public function create($url, $method, array $params = [])
/**
* @return ZendClient
- * @since 2.2.0
*/
private function createNewClient()
{
@@ -118,7 +108,6 @@ private function createNewClient()
*
* @see https://www.signifyd.com/docs/api/#/introduction/authentication
* @return string
- * @since 2.2.0
*/
private function getApiKey()
{
@@ -130,7 +119,6 @@ private function getApiKey()
*
* @param string $url
* @return string
- * @since 2.2.0
*/
private function buildFullApiUrl($url)
{
@@ -144,7 +132,6 @@ private function buildFullApiUrl($url)
* Base Sigifyd API URL without trailing slash.
*
* @return string
- * @since 2.2.0
*/
private function getBaseApiUrl()
{
diff --git a/Model/SignifydGateway/Client/RequestBuilder.php b/Model/SignifydGateway/Client/RequestBuilder.php
index f4f40bdff2190..2ab4395e1990d 100644
--- a/Model/SignifydGateway/Client/RequestBuilder.php
+++ b/Model/SignifydGateway/Client/RequestBuilder.php
@@ -10,25 +10,21 @@
/**
* Class RequestBuilder
* Creates HTTP client, sends request to Signifyd and handles response
- * @since 2.2.0
*/
class RequestBuilder
{
/**
* @var HttpClientFactory
- * @since 2.2.0
*/
private $clientCreator;
/**
* @var RequestSender
- * @since 2.2.0
*/
private $requestSender;
/**
* @var ResponseHandler
- * @since 2.2.0
*/
private $responseHandler;
@@ -38,7 +34,6 @@ class RequestBuilder
* @param HttpClientFactory $clientCreator
* @param RequestSender $requestSender
* @param ResponseHandler $responseHandler
- * @since 2.2.0
*/
public function __construct(
HttpClientFactory $clientCreator,
@@ -57,7 +52,6 @@ public function __construct(
* @param string $method
* @param array $params
* @return array
- * @since 2.2.0
*/
public function doRequest($url, $method, array $params = [])
{
diff --git a/Model/SignifydGateway/Client/RequestSender.php b/Model/SignifydGateway/Client/RequestSender.php
index 84fa207a6a382..38128a799fd59 100644
--- a/Model/SignifydGateway/Client/RequestSender.php
+++ b/Model/SignifydGateway/Client/RequestSender.php
@@ -12,13 +12,11 @@
/**
* Class RequestSender
* Gets HTTP client end sends request to Signifyd API
- * @since 2.2.0
*/
class RequestSender
{
/**
* @var DebuggerFactory
- * @since 2.2.0
*/
private $debuggerFactory;
@@ -26,7 +24,6 @@ class RequestSender
* RequestSender constructor.
*
* @param DebuggerFactory $debuggerFactory
- * @since 2.2.0
*/
public function __construct(
DebuggerFactory $debuggerFactory
@@ -44,7 +41,6 @@ public function __construct(
* @param ZendClient $client
* @return \Zend_Http_Response
* @throws ApiCallException
- * @since 2.2.0
*/
public function send(ZendClient $client)
{
diff --git a/Model/SignifydGateway/Client/ResponseHandler.php b/Model/SignifydGateway/Client/ResponseHandler.php
index 1023684bc21e5..614e59b7c29a2 100644
--- a/Model/SignifydGateway/Client/ResponseHandler.php
+++ b/Model/SignifydGateway/Client/ResponseHandler.php
@@ -10,7 +10,6 @@
/**
* Class ResponseHandler
- * @since 2.2.0
*/
class ResponseHandler
{
@@ -18,13 +17,11 @@ class ResponseHandler
* Successful HTTP response codes.
*
* @var array
- * @since 2.2.0
*/
private static $successResponseCodes = [200, 201, 204];
/**
* Current servers PHP version id.
- * @since 2.2.0
*/
private static $phpVersionId = PHP_VERSION_ID;
@@ -32,7 +29,6 @@ class ResponseHandler
* Failure HTTP response codes with messages.
*
* @var array
- * @since 2.2.0
*/
private static $failureResponses = [
400 => 'Bad Request - The request could not be parsed. Response: %s',
@@ -47,13 +43,11 @@ class ResponseHandler
* Unexpected Signifyd API response message.
*
* @var string
- * @since 2.2.0
*/
private static $unexpectedResponse = 'Unexpected Signifyd API response code "%s" with content "%s".';
/**
* @var DecoderInterface
- * @since 2.2.0
*/
private $dataDecoder;
@@ -61,7 +55,6 @@ class ResponseHandler
* ResponseHandler constructor.
*
* @param DecoderInterface $dataDecoder
- * @since 2.2.0
*/
public function __construct(
DecoderInterface $dataDecoder
@@ -75,7 +68,6 @@ public function __construct(
* @param \Zend_Http_Response $response
* @return array
* @throws ApiCallException
- * @since 2.2.0
*/
public function handle(\Zend_Http_Response $response)
{
@@ -114,7 +106,6 @@ public function handle(\Zend_Http_Response $response)
*
* @param \Zend_Http_Response $response
* @return string
- * @since 2.2.0
*/
private function buildApiCallFailureMessage(\Zend_Http_Response $response)
{
diff --git a/Model/SignifydGateway/Debugger/BlackHole.php b/Model/SignifydGateway/Debugger/BlackHole.php
index dcf436f5a15ce..7057313b5e415 100644
--- a/Model/SignifydGateway/Debugger/BlackHole.php
+++ b/Model/SignifydGateway/Debugger/BlackHole.php
@@ -10,14 +10,12 @@
/**
* This debugger ignores any information.
* Optimal production environment.
- * @since 2.2.0
*/
class BlackHole implements DebuggerInterface
{
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
- * @since 2.2.0
*/
public function success($requestUrl, $requestData, $responseStatus, $responseBody)
{
@@ -27,7 +25,6 @@ public function success($requestUrl, $requestData, $responseStatus, $responseBod
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
- * @since 2.2.0
*/
public function failure($requestUrl, $requestData, Exception $exception)
{
diff --git a/Model/SignifydGateway/Debugger/DebuggerFactory.php b/Model/SignifydGateway/Debugger/DebuggerFactory.php
index 3cb91611020bf..02031e6f5b9b5 100644
--- a/Model/SignifydGateway/Debugger/DebuggerFactory.php
+++ b/Model/SignifydGateway/Debugger/DebuggerFactory.php
@@ -14,19 +14,16 @@
* Configuration may be changed by
* - config.xml
* - at Admin panel (Stores > Configuration > Sales > Fraud Detection > Signifyd > Debug)
- * @since 2.2.0
*/
class DebuggerFactory
{
/**
* @var ObjectManagerInterface
- * @since 2.2.0
*/
private $objectManager;
/**
* @var Config
- * @since 2.2.0
*/
private $config;
@@ -35,7 +32,6 @@ class DebuggerFactory
*
* @param bjectManagerInterface $objectManager
* @param Config $config
- * @since 2.2.0
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -49,7 +45,6 @@ public function __construct(
* Create debugger instance
*
* @return DebuggerInterface
- * @since 2.2.0
*/
public function create()
{
diff --git a/Model/SignifydGateway/Debugger/DebuggerInterface.php b/Model/SignifydGateway/Debugger/DebuggerInterface.php
index 931d3109bc2f2..f4a2f9cc56a8f 100644
--- a/Model/SignifydGateway/Debugger/DebuggerInterface.php
+++ b/Model/SignifydGateway/Debugger/DebuggerInterface.php
@@ -9,7 +9,6 @@
/**
* Interface for debugging interaction with Signifyd API
- * @since 2.2.0
*/
interface DebuggerInterface
{
@@ -21,7 +20,6 @@ interface DebuggerInterface
* @param string $responseStatus
* @param string $responseBody
* @return void
- * @since 2.2.0
*/
public function success($requestUrl, $requestData, $responseStatus, $responseBody);
@@ -32,7 +30,6 @@ public function success($requestUrl, $requestData, $responseStatus, $responseBod
* @param string $requestData
* @param Exception $exception
* @return mixed
- * @since 2.2.0
*/
public function failure($requestUrl, $requestData, Exception $exception);
}
diff --git a/Model/SignifydGateway/Debugger/Log.php b/Model/SignifydGateway/Debugger/Log.php
index a89ba1fa1d18f..4b7258180f53e 100644
--- a/Model/SignifydGateway/Debugger/Log.php
+++ b/Model/SignifydGateway/Debugger/Log.php
@@ -10,13 +10,11 @@
/**
* Debugger writes information about request, response and possible exception to standard system log.
- * @since 2.2.0
*/
class Log implements DebuggerInterface
{
/**
* @var LoggerInterface
- * @since 2.2.0
*/
private $logger;
@@ -24,7 +22,6 @@ class Log implements DebuggerInterface
* Log constructor.
*
* @param LoggerInterface $logger
- * @since 2.2.0
*/
public function __construct(LoggerInterface $logger)
{
@@ -33,7 +30,6 @@ public function __construct(LoggerInterface $logger)
/**
* {@inheritdoc}
- * @since 2.2.0
*/
public function success($requestUrl, $requestData, $responseStatus, $responseBody)
{
@@ -48,7 +44,6 @@ public function success($requestUrl, $requestData, $responseStatus, $responseBod
/**
* {@inheritdoc}
- * @since 2.2.0
*/
public function failure($requestUrl, $requestData, Exception $exception)
{
@@ -67,7 +62,6 @@ public function failure($requestUrl, $requestData, Exception $exception)
* @param string $requestUrl
* @param string $requestData
* @return string
- * @since 2.2.0
*/
private function buildRequestInfo($requestUrl, $requestData)
{
@@ -84,7 +78,6 @@ private function buildRequestInfo($requestUrl, $requestData)
* @param string $responseStatus
* @param string $responseBody
* @return string
- * @since 2.2.0
*/
private function buildResponseInfo($responseStatus, $responseBody)
{
@@ -100,7 +93,6 @@ private function buildResponseInfo($responseStatus, $responseBody)
*
* @param Exception $exception
* @return string
- * @since 2.2.0
*/
private function buildExceptionInfo(Exception $exception)
{
@@ -114,7 +106,6 @@ private function buildExceptionInfo(Exception $exception)
*
* @param string $info
* @return void
- * @since 2.2.0
*/
private function writeToLog($info)
{
@@ -128,7 +119,6 @@ private function writeToLog($info)
* @param string $title
* @param string $content
* @return string
- * @since 2.2.0
*/
private function buildInfoSection($title, $content)
{
@@ -143,7 +133,6 @@ private function buildInfoSection($title, $content)
* @param string $content
* @param string $indent
* @return string
- * @since 2.2.0
*/
private function addIndent($content, $indent = ' ')
{
diff --git a/Model/SignifydGateway/Gateway.php b/Model/SignifydGateway/Gateway.php
index da9d9c85bca5a..ddcaa6cd696f2 100644
--- a/Model/SignifydGateway/Gateway.php
+++ b/Model/SignifydGateway/Gateway.php
@@ -12,7 +12,6 @@
* Signifyd Gateway.
*
* Encapsulates interaction with Signifyd API.
- * @since 2.2.0
*/
class Gateway
{
@@ -46,13 +45,11 @@ class Gateway
/**
* @var CreateCaseBuilderInterface
- * @since 2.2.0
*/
private $createCaseBuilder;
/**
* @var ApiClient
- * @since 2.2.0
*/
private $apiClient;
@@ -61,7 +58,6 @@ class Gateway
*
* @param CreateCaseBuilderInterface $createCaseBuilder
* @param ApiClient $apiClient
- * @since 2.2.0
*/
public function __construct(
CreateCaseBuilderInterface $createCaseBuilder,
@@ -78,7 +74,6 @@ public function __construct(
* @param int $orderId
* @return int Signifyd case (investigation) identifier
* @throws GatewayException
- * @since 2.2.0
*/
public function createCase($orderId)
{
@@ -104,7 +99,6 @@ public function createCase($orderId)
* @param int $signifydCaseId
* @return string
* @throws GatewayException
- * @since 2.2.0
*/
public function submitCaseForGuarantee($signifydCaseId)
{
@@ -127,7 +121,6 @@ public function submitCaseForGuarantee($signifydCaseId)
* @param int $caseId
* @return string
* @throws GatewayException
- * @since 2.2.0
*/
public function cancelGuarantee($caseId)
{
@@ -155,7 +148,6 @@ public function cancelGuarantee($caseId)
* @param array $result
* @return string
* @throws GatewayException
- * @since 2.2.0
*/
private function processDispositionResult(array $result)
{
diff --git a/Model/SignifydGateway/GatewayException.php b/Model/SignifydGateway/GatewayException.php
index 416826a54c793..666217f8ccc85 100644
--- a/Model/SignifydGateway/GatewayException.php
+++ b/Model/SignifydGateway/GatewayException.php
@@ -7,7 +7,6 @@
/**
* Exception of interaction with Signifyd API
- * @since 2.2.0
*/
class GatewayException extends \Exception
{
diff --git a/Model/SignifydGateway/Request/AddressBuilder.php b/Model/SignifydGateway/Request/AddressBuilder.php
index 161870b3a87ab..f95968d4a1bf7 100644
--- a/Model/SignifydGateway/Request/AddressBuilder.php
+++ b/Model/SignifydGateway/Request/AddressBuilder.php
@@ -9,7 +9,6 @@
/**
* Prepare address data
- * @since 2.2.0
*/
class AddressBuilder
{
@@ -18,7 +17,6 @@ class AddressBuilder
*
* @param OrderAddressInterface $address
* @return array
- * @since 2.2.0
*/
public function build(OrderAddressInterface $address)
{
@@ -38,7 +36,6 @@ public function build(OrderAddressInterface $address)
* @param int $number
* @param string[]|null $street
* @return string
- * @since 2.2.0
*/
private function getStreetLine($number, $street)
{
diff --git a/Model/SignifydGateway/Request/CardBuilder.php b/Model/SignifydGateway/Request/CardBuilder.php
index 53ea7e2541639..5e3a1a83e7aeb 100644
--- a/Model/SignifydGateway/Request/CardBuilder.php
+++ b/Model/SignifydGateway/Request/CardBuilder.php
@@ -9,19 +9,16 @@
/**
* Prepare data related to the card that was used for the purchase and its cardholder.
- * @since 2.2.0
*/
class CardBuilder
{
/**
* @var AddressBuilder
- * @since 2.2.0
*/
private $addressBuilder;
/**
* @param AddressBuilder $addressBuilder
- * @since 2.2.0
*/
public function __construct(
AddressBuilder $addressBuilder
@@ -34,7 +31,6 @@ public function __construct(
*
* @param Order $order
* @return array
- * @since 2.2.0
*/
public function build(Order $order)
{
diff --git a/Model/SignifydGateway/Request/ClientVersionBuilder.php b/Model/SignifydGateway/Request/ClientVersionBuilder.php
index 8507cec083721..8db06473b96d8 100644
--- a/Model/SignifydGateway/Request/ClientVersionBuilder.php
+++ b/Model/SignifydGateway/Request/ClientVersionBuilder.php
@@ -9,25 +9,21 @@
/**
* Provides platform name, edition and version info
- * @since 2.2.0
*/
class ClientVersionBuilder
{
/**
* @var string
- * @since 2.2.0
*/
private static $clientVersion = '1.0';
/**
* @var ProductMetadataInterface
- * @since 2.2.0
*/
private $productMetadata;
/**
* @param ProductMetadataInterface $productMetadata
- * @since 2.2.0
*/
public function __construct(
ProductMetadataInterface $productMetadata
@@ -39,7 +35,6 @@ public function __construct(
* Returns version info
*
* @return array
- * @since 2.2.0
*/
public function build()
{
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilder.php b/Model/SignifydGateway/Request/CreateCaseBuilder.php
index 6bd567fd2070d..3e41003d47842 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/Model/SignifydGateway/Request/CreateCaseBuilder.php
@@ -12,49 +12,41 @@
*
* Handles the conversion from Magento Order to Signifyd Case.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
- * @since 2.2.0
*/
class CreateCaseBuilder implements CreateCaseBuilderInterface
{
/**
* @var OrderFactory
- * @since 2.2.0
*/
private $orderFactory;
/**
* @var PurchaseBuilder
- * @since 2.2.0
*/
private $purchaseBuilder;
/**
* @var CardBuilder
- * @since 2.2.0
*/
private $cardBuilder;
/**
* @var RecipientBuilder
- * @since 2.2.0
*/
private $recipientBuilder;
/**
* @var SellerBuilder
- * @since 2.2.0
*/
private $sellerBuilder;
/**
* @var ClientVersionBuilder
- * @since 2.2.0
*/
private $clientVersionBuilder;
/**
* @var UserAccountBuilder
- * @since 2.2.0
*/
private $userAccountBuilder;
@@ -66,7 +58,6 @@ class CreateCaseBuilder implements CreateCaseBuilderInterface
* @param SellerBuilder $sellerBuilder
* @param ClientVersionBuilder $clientVersionBuilder
* @param UserAccountBuilder $userAccountBuilder
- * @since 2.2.0
*/
public function __construct(
OrderFactory $orderFactory,
@@ -88,7 +79,6 @@ public function __construct(
/**
* @inheritdoc
- * @since 2.2.0
*/
public function build($orderId)
{
@@ -112,7 +102,6 @@ public function build($orderId)
*
* @param array $data
* @return array
- * @since 2.2.0
*/
private function removeEmptyValues($data)
{
@@ -134,7 +123,6 @@ private function removeEmptyValues($data)
*
* @param mixed $value
* @return bool
- * @since 2.2.0
*/
private function isEmpty($value)
{
diff --git a/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php b/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
index ea8b044277aa3..56662f69e7c5a 100644
--- a/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
+++ b/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
@@ -9,7 +9,6 @@
* 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
- * @since 2.2.0
*/
interface CreateCaseBuilderInterface
{
@@ -18,7 +17,6 @@ interface CreateCaseBuilderInterface
*
* @param int $orderId
* @return array
- * @since 2.2.0
*/
public function build($orderId);
}
diff --git a/Model/SignifydGateway/Request/PurchaseBuilder.php b/Model/SignifydGateway/Request/PurchaseBuilder.php
index 1d9ca9256a6f3..858ce0f0f3287 100644
--- a/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -16,37 +16,31 @@
/**
* Prepare data related to purchase event represented in case creation request.
- * @since 2.2.0
*/
class PurchaseBuilder
{
/**
* @var DateTimeFactory
- * @since 2.2.0
*/
private $dateTimeFactory;
/**
* @var ScopeInterface
- * @since 2.2.0
*/
private $scope;
/**
* @var SignifydOrderSessionId
- * @since 2.2.0
*/
private $signifydOrderSessionId;
/**
* @var PaymentVerificationFactory
- * @since 2.2.0
*/
private $paymentVerificationFactory;
/**
* @var PaymentMethodMapper
- * @since 2.2.0
*/
private $paymentMethodMapper;
@@ -58,7 +52,6 @@ class PurchaseBuilder
* @param SignifydOrderSessionId $signifydOrderSessionId
* @param PaymentVerificationFactory $paymentVerificationFactory
* @param PaymentMethodMapper $paymentMethodMapper
- * @since 2.2.0
*/
public function __construct(
DateTimeFactory $dateTimeFactory,
@@ -79,7 +72,6 @@ public function __construct(
*
* @param Order $order
* @return array
- * @since 2.2.0
*/
public function build(Order $order)
{
@@ -131,7 +123,6 @@ public function build(Order $order)
*
* @param Order $order
* @return array
- * @since 2.2.0
*/
private function getProducts(Order $order)
{
@@ -155,7 +146,6 @@ private function getProducts(Order $order)
*
* @param string $shippingDescription
* @return string
- * @since 2.2.0
*/
private function getShipper($shippingDescription)
{
@@ -169,7 +159,6 @@ private function getShipper($shippingDescription)
*
* @param string $shippingDescription
* @return string
- * @since 2.2.0
*/
private function getShippingMethod($shippingDescription)
{
@@ -183,7 +172,6 @@ private function getShippingMethod($shippingDescription)
*
* @param string $gatewayCode
* @return string
- * @since 2.2.0
*/
private function getPaymentGateway($gatewayCode)
{
@@ -203,7 +191,6 @@ private function getPaymentGateway($gatewayCode)
* Returns WEB for web-orders, PHONE for orders created by Admin
*
* @return string
- * @since 2.2.0
*/
private function getOrderChannel()
{
@@ -215,7 +202,6 @@ private function getOrderChannel()
*
* @param OrderPaymentInterface $orderPayment
* @return string
- * @since 2.2.0
*/
private function getAvsCode(OrderPaymentInterface $orderPayment)
{
@@ -228,7 +214,6 @@ private function getAvsCode(OrderPaymentInterface $orderPayment)
*
* @param OrderPaymentInterface $orderPayment
* @return string
- * @since 2.2.0
*/
private function getCvvCode(OrderPaymentInterface $orderPayment)
{
diff --git a/Model/SignifydGateway/Request/RecipientBuilder.php b/Model/SignifydGateway/Request/RecipientBuilder.php
index cea8171dcd243..d9d26c8943b88 100644
--- a/Model/SignifydGateway/Request/RecipientBuilder.php
+++ b/Model/SignifydGateway/Request/RecipientBuilder.php
@@ -9,19 +9,16 @@
/**
* Prepare data related to person or organization receiving the items purchased
- * @since 2.2.0
*/
class RecipientBuilder
{
/**
* @var AddressBuilder
- * @since 2.2.0
*/
private $addressBuilder;
/**
* @param AddressBuilder $addressBuilder
- * @since 2.2.0
*/
public function __construct(
AddressBuilder $addressBuilder
@@ -34,7 +31,6 @@ public function __construct(
*
* @param Order $order
* @return array
- * @since 2.2.0
*/
public function build(Order $order)
{
diff --git a/Model/SignifydGateway/Request/SellerBuilder.php b/Model/SignifydGateway/Request/SellerBuilder.php
index be24a9ef098b5..b2cf0401b247f 100644
--- a/Model/SignifydGateway/Request/SellerBuilder.php
+++ b/Model/SignifydGateway/Request/SellerBuilder.php
@@ -18,32 +18,27 @@
*
* This information is optional unless you are operating a marketplace,
* listing goods on behalf of multiple sellers who each hold a seller account registered with your site.
- * @since 2.2.0
*/
class SellerBuilder
{
/**
* @var ScopeConfigInterface
- * @since 2.2.0
*/
private $scopeConfig;
/**
* @var RegionFactory
- * @since 2.2.0
*/
private $regionFactory;
/**
* @var array
- * @since 2.2.0
*/
private $regionCodes = [];
/**
* @param ScopeConfigInterface $scopeConfig
* @param RegionFactory $regionFactory
- * @since 2.2.0
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
@@ -58,7 +53,6 @@ public function __construct(
*
* @param Order $order
* @return array
- * @since 2.2.0
*/
public function build(Order $order)
{
@@ -97,7 +91,6 @@ public function build(Order $order)
*
* @param int $regionId
* @return string
- * @since 2.2.0
*/
private function getRegionCodeById($regionId)
{
@@ -114,7 +107,6 @@ private function getRegionCodeById($regionId)
* @param string $value
* @param StoreInterface $store
* @return mixed
- * @since 2.2.0
*/
private function getConfigValue($value, StoreInterface $store)
{
@@ -130,7 +122,6 @@ private function getConfigValue($value, StoreInterface $store)
*
* @param StoreInterface $store
* @return string|null null if no DNS records corresponding to a current host found
- * @since 2.2.0
*/
private function getPublicDomain(StoreInterface $store)
{
diff --git a/Model/SignifydGateway/Request/UserAccountBuilder.php b/Model/SignifydGateway/Request/UserAccountBuilder.php
index 2b9d920e94e26..0da49b85da869 100644
--- a/Model/SignifydGateway/Request/UserAccountBuilder.php
+++ b/Model/SignifydGateway/Request/UserAccountBuilder.php
@@ -10,25 +10,21 @@
/**
* Prepares details based on registered user account info
- * @since 2.2.0
*/
class UserAccountBuilder
{
/**
* @var \Magento\Customer\Api\CustomerRepositoryInterface
- * @since 2.2.0
*/
private $customerRepository;
/**
* @var \Magento\Framework\Intl\DateTimeFactory
- * @since 2.2.0
*/
private $dateTimeFactory;
/**
* @var CustomerOrders
- * @since 2.2.0
*/
private $customerOrders;
@@ -36,7 +32,6 @@ class UserAccountBuilder
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
* @param CustomerOrders $customerOrders
* @param \Magento\Framework\Intl\DateTimeFactory $dateTimeFactory
- * @since 2.2.0
*/
public function __construct(
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
@@ -54,7 +49,6 @@ public function __construct(
*
* @param Order $order
* @return array
- * @since 2.2.0
*/
public function build(Order $order)
{
@@ -93,7 +87,6 @@ public function build(Order $order)
*
* @param string $date
* @return string
- * @since 2.2.0
*/
private function formatDate($date)
{
diff --git a/Model/SignifydGateway/Response/WebhookMessage.php b/Model/SignifydGateway/Response/WebhookMessage.php
index d8e974b955109..f77db737473c0 100644
--- a/Model/SignifydGateway/Response/WebhookMessage.php
+++ b/Model/SignifydGateway/Response/WebhookMessage.php
@@ -13,7 +13,6 @@
* They allow your application to receive pushed updates about a case, rather than poll SIGNIFYD for status changes.
*
* @see https://www.signifyd.com/docs/api/#/reference/webhooks
- * @since 2.2.0
*/
class WebhookMessage
{
@@ -21,7 +20,6 @@ class WebhookMessage
* Decoded webhook request body.
*
* @var array
- * @since 2.2.0
*/
private $data;
@@ -29,14 +27,12 @@ class WebhookMessage
* Event topic identifier.
*
* @var string
- * @since 2.2.0
*/
private $eventTopic;
/**
* @param array $data
* @param string $eventTopic
- * @since 2.2.0
*/
public function __construct(
array $data,
@@ -50,7 +46,6 @@ public function __construct(
* Returns decoded webhook request body.
*
* @return array
- * @since 2.2.0
*/
public function getData()
{
@@ -61,7 +56,6 @@ public function getData()
* Returns event topic identifier.
*
* @return string
- * @since 2.2.0
*/
public function getEventTopic()
{
diff --git a/Model/SignifydGateway/Response/WebhookMessageReader.php b/Model/SignifydGateway/Response/WebhookMessageReader.php
index 7c4ea14ad9104..50389102359b1 100644
--- a/Model/SignifydGateway/Response/WebhookMessageReader.php
+++ b/Model/SignifydGateway/Response/WebhookMessageReader.php
@@ -9,26 +9,22 @@
/**
* Reads request and produces webhook message data object based on request params.
- * @since 2.2.0
*/
class WebhookMessageReader
{
/**
* @var DecoderInterface
- * @since 2.2.0
*/
private $dataDecoder;
/**
* @var WebhookMessageFactory
- * @since 2.2.0
*/
private $webhookMessageFactory;
/**
* @param DecoderInterface $decoder
* @param WebhookMessageFactory $webhookMessageFactory
- * @since 2.2.0
*/
public function __construct(
DecoderInterface $decoder,
@@ -44,7 +40,6 @@ public function __construct(
* @param WebhookRequest $request
* @return WebhookMessage
* @throws \InvalidArgumentException
- * @since 2.2.0
*/
public function read(WebhookRequest $request)
{
diff --git a/Model/SignifydGateway/Response/WebhookRequest.php b/Model/SignifydGateway/Response/WebhookRequest.php
index 8768f0dfbe4db..214ccf0eeb70f 100644
--- a/Model/SignifydGateway/Response/WebhookRequest.php
+++ b/Model/SignifydGateway/Response/WebhookRequest.php
@@ -9,19 +9,16 @@
/**
* Reads Signifyd webhook request data.
- * @since 2.2.0
*/
class WebhookRequest
{
/**
* @var Http
- * @since 2.2.0
*/
private $request;
/**
* @param Http $request
- * @since 2.2.0
*/
public function __construct(
Http $request
@@ -33,7 +30,6 @@ public function __construct(
* Returns Base64 encoded output of the HMAC SHA256 encoding of the JSON body of the message.
*
* @return string
- * @since 2.2.0
*/
public function getHash()
{
@@ -44,7 +40,6 @@ public function getHash()
* Returns event topic identifier.
*
* @return string
- * @since 2.2.0
*/
public function getEventTopic()
{
@@ -55,7 +50,6 @@ public function getEventTopic()
* Returns raw data from the request body.
*
* @return string
- * @since 2.2.0
*/
public function getBody()
{
diff --git a/Model/SignifydGateway/Response/WebhookRequestValidator.php b/Model/SignifydGateway/Response/WebhookRequestValidator.php
index 2326a54833f0a..274ef2f854684 100644
--- a/Model/SignifydGateway/Response/WebhookRequestValidator.php
+++ b/Model/SignifydGateway/Response/WebhookRequestValidator.php
@@ -11,7 +11,6 @@
/**
* Validates webhook request.
*
- * @since 2.2.0
*/
class WebhookRequestValidator
{
@@ -19,7 +18,6 @@ class WebhookRequestValidator
* Allowed topic identifiers which will be sent in the X-SIGNIFYD-TOPIC header of the webhook.
*
* @var array
- * @since 2.2.0
*/
private $allowedTopicValues = [
'cases/creation',
@@ -31,20 +29,17 @@ class WebhookRequestValidator
/**
* @var Config
- * @since 2.2.0
*/
private $config;
/**
* @var DecoderInterface
- * @since 2.2.0
*/
private $decoder;
/**
* @param Config $config
* @param DecoderInterface $decoder
- * @since 2.2.0
*/
public function __construct(
Config $config,
@@ -59,7 +54,6 @@ public function __construct(
*
* @param WebhookRequest $webhookRequest
* @return bool
- * @since 2.2.0
*/
public function validate(WebhookRequest $webhookRequest)
{
@@ -77,7 +71,6 @@ public function validate(WebhookRequest $webhookRequest)
*
* @param string $topic topic identifier.
* @return bool
- * @since 2.2.0
*/
private function isValidTopic($topic)
{
@@ -89,7 +82,6 @@ private function isValidTopic($topic)
*
* @param string $body
* @return bool
- * @since 2.2.0
*/
private function isValidBody($body)
{
@@ -109,7 +101,6 @@ private function isValidBody($body)
* @param string $body
* @param string $hash
* @return bool
- * @since 2.2.0
*/
private function isValidHash($eventTopic, $body, $hash)
{
diff --git a/Model/SignifydOrderSessionId.php b/Model/SignifydOrderSessionId.php
index 18f2734896ed4..52746bc4ec6c5 100644
--- a/Model/SignifydOrderSessionId.php
+++ b/Model/SignifydOrderSessionId.php
@@ -9,19 +9,16 @@
/**
* Encapsulates generation of uuid by quote id.
- * @since 2.2.0
*/
class SignifydOrderSessionId
{
/**
* @var IdentityGeneratorInterface
- * @since 2.2.0
*/
private $identityGenerator;
/**
* @param IdentityGeneratorInterface $identityGenerator
- * @since 2.2.0
*/
public function __construct(
IdentityGeneratorInterface $identityGenerator
@@ -34,7 +31,6 @@ public function __construct(
*
* @param int $quoteId
* @return string
- * @since 2.2.0
*/
public function get($quoteId)
{
diff --git a/Observer/PlaceOrder.php b/Observer/PlaceOrder.php
index 1d75ec200c666..3798522dbe506 100644
--- a/Observer/PlaceOrder.php
+++ b/Observer/PlaceOrder.php
@@ -17,25 +17,21 @@
/**
* Observer should be triggered when new order is created and placed.
* If Signifyd integration enabled in configuration then new case will be created.
- * @since 2.2.0
*/
class PlaceOrder implements ObserverInterface
{
/**
* @var Config
- * @since 2.2.0
*/
private $signifydIntegrationConfig;
/**
* @var CaseCreationServiceInterface
- * @since 2.2.0
*/
private $caseCreationService;
/**
* @var LoggerInterface
- * @since 2.2.0
*/
private $logger;
@@ -43,7 +39,6 @@ class PlaceOrder implements ObserverInterface
* @param Config $signifydIntegrationConfig
* @param CaseCreationServiceInterface $caseCreationService
* @param LoggerInterface $logger
- * @since 2.2.0
*/
public function __construct(
Config $signifydIntegrationConfig,
@@ -57,7 +52,6 @@ public function __construct(
/**
* {@inheritdoc}
- * @since 2.2.0
*/
public function execute(Observer $observer)
{
@@ -83,7 +77,6 @@ public function execute(Observer $observer)
*
* @param OrderInterface $order
* @return void
- * @since 2.2.0
*/
private function createCaseForOrder($order)
{
@@ -104,7 +97,6 @@ private function createCaseForOrder($order)
*
* @param Event $event
* @return OrderInterface[]|null
- * @since 2.2.0
*/
private function extractOrders(Event $event)
{
diff --git a/Plugin/OrderPlugin.php b/Plugin/OrderPlugin.php
index 3d746fa58bf0d..663409d0eb824 100644
--- a/Plugin/OrderPlugin.php
+++ b/Plugin/OrderPlugin.php
@@ -13,19 +13,16 @@
* Plugin for Magento\Sales\Model\Order.
*
* @see Order
- * @since 2.2.0
*/
class OrderPlugin
{
/**
* @var GuaranteeCancelingServiceInterface
- * @since 2.2.0
*/
private $guaranteeCancelingService;
/**
* @param GuaranteeCancelingServiceInterface $guaranteeCancelingService
- * @since 2.2.0
*/
public function __construct(
GuaranteeCancelingServiceInterface $guaranteeCancelingService
@@ -41,7 +38,6 @@ public function __construct(
* @param Order $order
* @param OrderInterface $result
* @return OrderInterface
- * @since 2.2.0
*/
public function afterCancel(Order $order, $result)
{
diff --git a/Plugin/PaymentPlugin.php b/Plugin/PaymentPlugin.php
index 8b95ac97f151b..17cf4d7e7dbe9 100644
--- a/Plugin/PaymentPlugin.php
+++ b/Plugin/PaymentPlugin.php
@@ -13,19 +13,16 @@
* Plugin for Magento\Payment\Model\MethodInterface.
*
* @see MethodInterface
- * @since 2.2.0
*/
class PaymentPlugin
{
/**
* @var GuaranteeCancelingServiceInterface
- * @since 2.2.0
*/
private $guaranteeCancelingService;
/**
* @param GuaranteeCancelingServiceInterface $guaranteeCancelingService
- * @since 2.2.0
*/
public function __construct(
GuaranteeCancelingServiceInterface $guaranteeCancelingService
@@ -43,7 +40,6 @@ public function __construct(
* @param MethodInterface|bool $result
* @param InfoInterface $payment
* @return bool|MethodInterface
- * @since 2.2.0
*/
public function afterDenyPayment(MethodInterface $subject, $result, InfoInterface $payment)
{
@@ -63,7 +59,6 @@ public function afterDenyPayment(MethodInterface $subject, $result, InfoInterfac
* @param InfoInterface $payment
* @param MethodInterface $result
* @return bool
- * @since 2.2.0
*/
private function isPaymentDenied($payment, $result)
{
diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php
index e0498397ddd7d..101afd584484a 100644
--- a/Setup/InstallSchema.php
+++ b/Setup/InstallSchema.php
@@ -14,25 +14,21 @@
/**
* Creates all required table and keys for Signifyd case
- * @since 2.2.0
*/
class InstallSchema implements InstallSchemaInterface
{
/**
* @var string
- * @since 2.2.0
*/
private static $table = 'signifyd_case';
/**
* @var string
- * @since 2.2.0
*/
private static $connectionName = 'sales';
/**
* @inheritdoc
- * @since 2.2.0
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
diff --git a/Ui/Component/Listing/Column/Guarantee/Options.php b/Ui/Component/Listing/Column/Guarantee/Options.php
index 517090706565b..1e6234a8e27a9 100644
--- a/Ui/Component/Listing/Column/Guarantee/Options.php
+++ b/Ui/Component/Listing/Column/Guarantee/Options.php
@@ -11,13 +11,11 @@
/**
* Class Options
- * @since 2.2.0
*/
class Options implements OptionSourceInterface
{
/**
* @var Escaper
- * @since 2.2.0
*/
private $escaper;
@@ -25,7 +23,6 @@ class Options implements OptionSourceInterface
* Constructor
*
* @param Escaper $escaper
- * @since 2.2.0
*/
public function __construct(Escaper $escaper)
{
@@ -34,7 +31,6 @@ public function __construct(Escaper $escaper)
/**
* {@inheritdoc}
- * @since 2.2.0
*/
public function toOptionArray()
{
From 26801a18c646b8a389dea9c697acb02fd60259f0 Mon Sep 17 00:00:00 2001
From: Cristian Partica
Date: Thu, 10 Aug 2017 15:18:54 -0500
Subject: [PATCH 0333/2045] MAGETWO-69634: Product with a special price must be
showed with this price in the wishlist
- fix block
---
.../product/price/configured_price.phtml | 49 +++++++++++++++----
1 file changed, 40 insertions(+), 9 deletions(-)
diff --git a/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml b/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml
index 98b713be685d0..ec93fb431ed10 100644
--- a/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml
+++ b/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml
@@ -12,13 +12,44 @@ $schema = ($block->getZone() == 'item_view') ? true : false;
$priceLabel = ($block->getPriceLabel() !== null)
? $block->getPriceLabel()
: '';
+
+/** @var \Magento\Framework\Pricing\Price\PriceInterface $priceModel */
+$priceModel = $block->getPriceType('regular_price');
+
+$finalPriceModel = $block->getPriceType('final_price');
+$idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
?>
-
- = /* @escapeNotVerified */ $block->renderAmount($configuredPrice->getAmount(), [
- 'display_label' => $priceLabel,
- 'price_id' => $block->getPriceId('product-price-'),
- 'price_type' => 'finalPrice',
- 'include_container' => true,
- 'schema' => $schema
- ]); ?>
-
+
+hasSpecialPrice()) : ?>
+
+
+ renderAmount($finalPriceModel->getAmount(), [
+ 'display_label' => __('Special Price'),
+ 'price_id' => $block->getPriceId('product-price-' . $idSuffix),
+ 'price_type' => 'finalPrice',
+ 'include_container' => true,
+ 'schema' => $schema
+ ]); ?>
+
+
+ renderAmount($priceModel->getAmount(), [
+ 'display_label' => __('Regular Price'),
+ 'price_id' => $block->getPriceId('old-price-' . $idSuffix),
+ 'price_type' => 'oldPrice',
+ 'include_container' => true,
+ 'skip_adjustments' => true
+ ]); ?>
+
+
+
+
+ = /* @escapeNotVerified */ $block->renderAmount($configuredPrice->getAmount(), [
+ 'display_label' => $priceLabel,
+ 'price_id' => $block->getPriceId('product-price-'),
+ 'price_type' => 'finalPrice',
+ 'include_container' => true,
+ 'schema' => $schema
+ ]); ?>
+
+
+
From 0dd21c6e8b833e37e80c2eb062f2e9cfd66be19c Mon Sep 17 00:00:00 2001
From: Cristian Partica
Date: Thu, 10 Aug 2017 18:03:49 -0500
Subject: [PATCH 0334/2045] MAGETWO-69634: Product with a special price must be
showed with this price in the wishlist
- fix block
---
.../product/price/configured_price.phtml | 30 ++++++++++---------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml b/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml
index ec93fb431ed10..5b2b3aefb21bf 100644
--- a/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml
+++ b/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml
@@ -6,24 +6,20 @@
?>
getPrice();
$schema = ($block->getZone() == 'item_view') ? true : false;
-$priceLabel = ($block->getPriceLabel() !== null)
- ? $block->getPriceLabel()
- : '';
-
-/** @var \Magento\Framework\Pricing\Price\PriceInterface $priceModel */
-$priceModel = $block->getPriceType('regular_price');
-
-$finalPriceModel = $block->getPriceType('final_price');
$idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
?>
hasSpecialPrice()) : ?>
+ getPriceType('regular_price');
+
+ $finalPriceModel = $block->getPriceType('final_price');
+ ?>
- renderAmount($finalPriceModel->getAmount(), [
+ = /* @escapeNotVerified */ $block->renderAmount($finalPriceModel->getAmount(), [
'display_label' => __('Special Price'),
'price_id' => $block->getPriceId('product-price-' . $idSuffix),
'price_type' => 'finalPrice',
@@ -32,7 +28,7 @@ $idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
]); ?>
- renderAmount($priceModel->getAmount(), [
+ = /* @escapeNotVerified */ $block->renderAmount($priceModel->getAmount(), [
'display_label' => __('Regular Price'),
'price_id' => $block->getPriceId('old-price-' . $idSuffix),
'price_type' => 'oldPrice',
@@ -42,14 +38,20 @@ $idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
+ getPrice();
+ $priceLabel = ($block->getPriceLabel() !== null)
+ ? $block->getPriceLabel()
+ : '';
+ ?>
= /* @escapeNotVerified */ $block->renderAmount($configuredPrice->getAmount(), [
'display_label' => $priceLabel,
- 'price_id' => $block->getPriceId('product-price-'),
+ 'price_id' => $block->getPriceId('product-price-' . $idSuffix),
'price_type' => 'finalPrice',
'include_container' => true,
'schema' => $schema
]); ?>
-
From 5d949e9ce10453b8940185682ab71d9d02baa0ed Mon Sep 17 00:00:00 2001
From: Cristian Partica
Date: Thu, 10 Aug 2017 18:21:11 -0500
Subject: [PATCH 0335/2045] MAGETWO-69634: Product with a special price must be
showed with this price in the wishlist
- fix block
---
.../product/price/configured_price.phtml | 60 ++++++++++++-------
1 file changed, 39 insertions(+), 21 deletions(-)
diff --git a/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml b/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml
index 5b2b3aefb21bf..ec3ee5671f82c 100644
--- a/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml
+++ b/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml
@@ -19,22 +19,34 @@ $idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
?>
- = /* @escapeNotVerified */ $block->renderAmount($finalPriceModel->getAmount(), [
- 'display_label' => __('Special Price'),
- 'price_id' => $block->getPriceId('product-price-' . $idSuffix),
- 'price_type' => 'finalPrice',
- 'include_container' => true,
- 'schema' => $schema
- ]); ?>
+ = $block->escapeHtml(
+ $block->renderAmount(
+ $finalPriceModel->getAmount(),
+ [
+ 'display_label' => __('Special Price'),
+ 'price_id' => $block->getPriceId('product-price-' . $idSuffix),
+ 'price_type' => 'finalPrice',
+ 'include_container' => true,
+ 'schema' => $schema
+ ]
+ ),
+ ['span']
+ ); ?>
- = /* @escapeNotVerified */ $block->renderAmount($priceModel->getAmount(), [
- 'display_label' => __('Regular Price'),
- 'price_id' => $block->getPriceId('old-price-' . $idSuffix),
- 'price_type' => 'oldPrice',
- 'include_container' => true,
- 'skip_adjustments' => true
- ]); ?>
+ = $block->escapeHtml(
+ $block->renderAmount(
+ $priceModel->getAmount(),
+ [
+ 'display_label' => __('Regular Price'),
+ 'price_id' => $block->getPriceId('old-price-' . $idSuffix),
+ 'price_type' => 'oldPrice',
+ 'include_container' => true,
+ 'skip_adjustments' => true
+ ]
+ ),
+ ['span']
+ ); ?>
@@ -46,12 +58,18 @@ $idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
: '';
?>
- = /* @escapeNotVerified */ $block->renderAmount($configuredPrice->getAmount(), [
- 'display_label' => $priceLabel,
- 'price_id' => $block->getPriceId('product-price-' . $idSuffix),
- 'price_type' => 'finalPrice',
- 'include_container' => true,
- 'schema' => $schema
- ]); ?>
+ = $block->escapeHtml(
+ $block->renderAmount(
+ $configuredPrice->getAmount(),
+ [
+ 'display_label' => $priceLabel,
+ 'price_id' => $block->getPriceId('product-price-' . $idSuffix),
+ 'price_type' => 'finalPrice',
+ 'include_container' => true,
+ 'schema' => $schema
+ ]
+ ),
+ ['span']
+ ); ?>
From 19356f92a55a8cf8a3681fb24f32a300b283819e Mon Sep 17 00:00:00 2001
From: Cristian Partica
Date: Fri, 11 Aug 2017 12:31:41 -0500
Subject: [PATCH 0336/2045] MAGETWO-69634: Product with a special price must be
showed with this price in the wishlist
- fix block
---
.../product/price/configured_price.phtml | 63 ++++++++-----------
1 file changed, 27 insertions(+), 36 deletions(-)
diff --git a/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml b/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml
index ec3ee5671f82c..fa4e93f7851a5 100644
--- a/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml
+++ b/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml
@@ -19,33 +19,27 @@ $idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
?>
- = $block->escapeHtml(
- $block->renderAmount(
- $finalPriceModel->getAmount(),
- [
- 'display_label' => __('Special Price'),
- 'price_id' => $block->getPriceId('product-price-' . $idSuffix),
- 'price_type' => 'finalPrice',
- 'include_container' => true,
- 'schema' => $schema
- ]
- ),
- ['span']
+ = $block->renderAmount(
+ $finalPriceModel->getAmount(),
+ [
+ 'display_label' => $block->escapeHtml(__('Special Price')),
+ 'price_id' => $block->escapeHtml($block->getPriceId('product-price-' . $idSuffix)),
+ 'price_type' => 'finalPrice',
+ 'include_container' => true,
+ 'schema' => $schema
+ ]
); ?>
- = $block->escapeHtml(
- $block->renderAmount(
- $priceModel->getAmount(),
- [
- 'display_label' => __('Regular Price'),
- 'price_id' => $block->getPriceId('old-price-' . $idSuffix),
- 'price_type' => 'oldPrice',
- 'include_container' => true,
- 'skip_adjustments' => true
- ]
- ),
- ['span']
+ = $block->renderAmount(
+ $priceModel->getAmount(),
+ [
+ 'display_label' => $block->escapeHtml(__('Regular Price')),
+ 'price_id' => $block->escapeHtml($block->getPriceId('old-price-' . $idSuffix)),
+ 'price_type' => 'oldPrice',
+ 'include_container' => true,
+ 'skip_adjustments' => true
+ ]
); ?>
@@ -58,18 +52,15 @@ $idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
: '';
?>
- = $block->escapeHtml(
- $block->renderAmount(
- $configuredPrice->getAmount(),
- [
- 'display_label' => $priceLabel,
- 'price_id' => $block->getPriceId('product-price-' . $idSuffix),
- 'price_type' => 'finalPrice',
- 'include_container' => true,
- 'schema' => $schema
- ]
- ),
- ['span']
+ = $block->renderAmount(
+ $configuredPrice->getAmount(),
+ [
+ 'display_label' => $block->escapeHtml($priceLabel),
+ 'price_id' => $block->escapeHtml($block->getPriceId('product-price-' . $idSuffix)),
+ 'price_type' => 'finalPrice',
+ 'include_container' => true,
+ 'schema' => $schema
+ ]
); ?>
From 66cf2c796639dfecd3659f90ca726af2add2f0e8 Mon Sep 17 00:00:00 2001
From: Oleksii Korshenko
Date: Fri, 11 Aug 2017 17:11:06 -0500
Subject: [PATCH 0337/2045] MAGETWO-71174: Update doc block information in php
classes with @deprecated and @since tags
- removed @since tag from class constructors
---
Block/Adminhtml/CaseInfo.php | 1 -
Block/Fingerprint.php | 1 -
2 files changed, 2 deletions(-)
diff --git a/Block/Adminhtml/CaseInfo.php b/Block/Adminhtml/CaseInfo.php
index 79ca7074b46da..87d09e392e091 100644
--- a/Block/Adminhtml/CaseInfo.php
+++ b/Block/Adminhtml/CaseInfo.php
@@ -32,7 +32,6 @@ class CaseInfo extends Template
* @param Context $context
* @param CaseManagement $caseManagement
* @param array $data
- * @since 100.2.0
*/
public function __construct(
Context $context,
diff --git a/Block/Fingerprint.php b/Block/Fingerprint.php
index f25ff97804503..7afa092b3d0da 100644
--- a/Block/Fingerprint.php
+++ b/Block/Fingerprint.php
@@ -50,7 +50,6 @@ class Fingerprint extends Template
* @param SignifydOrderSessionId $signifydOrderSessionId
* @param QuoteSessionInterface $quoteSession
* @param array $data
- * @since 100.2.0
*/
public function __construct(
Context $context,
From d2880bade7f96686b3c00201174943df7c39ab5b Mon Sep 17 00:00:00 2001
From: Oleksandr Miroshnichenko
Date: Wed, 16 Aug 2017 15:05:16 +0300
Subject: [PATCH 0338/2045] MAGETWO-71615: Mark JS modules as deprecated
---
view/adminhtml/web/js/request-send.js | 24 ------------------------
1 file changed, 24 deletions(-)
delete mode 100644 view/adminhtml/web/js/request-send.js
diff --git a/view/adminhtml/web/js/request-send.js b/view/adminhtml/web/js/request-send.js
deleted file mode 100644
index f55170336ca03..0000000000000
--- a/view/adminhtml/web/js/request-send.js
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
-
-define([
- 'mageUtils',
- 'Magento_Ui/js/form/components/button'
-], function (utils, Button) {
- 'use strict';
-
- return Button.extend({
-
- /**
- * Creates and submits form for Guarantee create/cancel
- */
- sendRequest: function () {
- utils.submit({
- url: this.requestURL,
- data: this.data
- });
- }
- });
-});
From 42b5db59827129433298c489e92b04d1226eb7f8 Mon Sep 17 00:00:00 2001
From: Lewis Voncken
Date: Fri, 18 Aug 2017 10:04:33 +0000
Subject: [PATCH 0339/2045] [BUGFIX] Flat Category reindexList of AllChildren
if the url_key of the current category has changed
---
app/code/Magento/Catalog/Model/Category.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index 9c472385f6db4..d2010de3ffc10 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -1095,6 +1095,9 @@ public function reindex()
$flatIndexer = $this->indexerRegistry->get(Indexer\Category\Flat\State::INDEXER_ID);
if (!$flatIndexer->isScheduled()) {
$flatIndexer->reindexRow($this->getId());
+ if ($this->dataHasChangedFor('url_key')) {
+ $flatIndexer->reindexList(explode(',', $this->getAllChildren()));
+ }
}
}
$productIndexer = $this->indexerRegistry->get(Indexer\Category\Product::INDEXER_ID);
From 813dca51db834b899ddffb30b8ad465372dbacf0 Mon Sep 17 00:00:00 2001
From: Lewis Voncken
Date: Fri, 18 Aug 2017 10:15:08 +0000
Subject: [PATCH 0340/2045] [FEATURE] Change the store code in Swagger based on
a param
---
app/code/Magento/Swagger/Helper/Data.php | 39 +++++++++++++++++++
.../frontend/templates/swagger-ui/index.phtml | 2 +-
2 files changed, 40 insertions(+), 1 deletion(-)
create mode 100644 app/code/Magento/Swagger/Helper/Data.php
diff --git a/app/code/Magento/Swagger/Helper/Data.php b/app/code/Magento/Swagger/Helper/Data.php
new file mode 100644
index 0000000000000..9bc53c3a2caeb
--- /dev/null
+++ b/app/code/Magento/Swagger/Helper/Data.php
@@ -0,0 +1,39 @@
+request = $request;
+ parent::__construct($context);
+ }
+
+ /**
+ * @return mixed|string
+ */
+ public function getParamStore()
+ {
+ return ($this->request->getParam('store')) ? $this->request->getParam('store') : 'all';
+ }
+}
\ No newline at end of file
diff --git a/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/index.phtml b/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/index.phtml
index 79040081f115d..6ef83eb116f39 100644
--- a/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/index.phtml
+++ b/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/index.phtml
@@ -14,7 +14,7 @@
/** @var \Magento\Framework\View\Element\Template $block */
-$schemaUrl = rtrim($block->getBaseUrl(), '/') . '/rest/all/schema?services=all';
+$schemaUrl = rtrim($block->getBaseUrl(), '/') . '/rest/' . $this->helper('Magento\Swagger\Helper\Data')->getParamStore() . '/schema?services=all';
?>