From add35b529492ea2dec2309879ab57850105095ba Mon Sep 17 00:00:00 2001 From: Wojtek Kaminski Date: Tue, 13 Oct 2020 09:07:27 +0200 Subject: [PATCH 01/15] Added default payment processor --- .../DefaultPaymentProcessor.php | 20 +++++++++++++++++++ Model/Api/Order/PaymentProcessorFactory.php | 13 ++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 Model/Api/Order/PaymentProcessor/DefaultPaymentProcessor.php diff --git a/Model/Api/Order/PaymentProcessor/DefaultPaymentProcessor.php b/Model/Api/Order/PaymentProcessor/DefaultPaymentProcessor.php new file mode 100644 index 0000000..f642c7c --- /dev/null +++ b/Model/Api/Order/PaymentProcessor/DefaultPaymentProcessor.php @@ -0,0 +1,20 @@ +payment->getCcCidStatus(); + $details['avs_result_code'] = $this->payment->getCcAvsStatus(); + $details['credit_card_company'] = $this->payment->getCcType(); + $details['credit_card_number'] = $this->payment->getCcLast4(); + + return $details; + } +} diff --git a/Model/Api/Order/PaymentProcessorFactory.php b/Model/Api/Order/PaymentProcessorFactory.php index 83daf3f..629ac6e 100644 --- a/Model/Api/Order/PaymentProcessorFactory.php +++ b/Model/Api/Order/PaymentProcessorFactory.php @@ -4,23 +4,24 @@ use Magento\Framework\ObjectManagerInterface; use Riskified\Decider\Model\Api\Order\PaymentProcessor\AbstractPayment; -use Riskified\Decider\Model\Api\Order\PaymentProcessor\DirectPost; +use Riskified\Decider\Model\Api\Order\PaymentProcessor\Adyen; use Riskified\Decider\Model\Api\Order\PaymentProcessor\Authcim; +use Riskified\Decider\Model\Api\Order\PaymentProcessor\Braintree; +use Riskified\Decider\Model\Api\Order\PaymentProcessor\Cryozonic; +use Riskified\Decider\Model\Api\Order\PaymentProcessor\DefaultPaymentProcessor; +use Riskified\Decider\Model\Api\Order\PaymentProcessor\DirectPost; use Riskified\Decider\Model\Api\Order\PaymentProcessor\OptimalHosted; +use Riskified\Decider\Model\Api\Order\PaymentProcessor\Payflowpro; use Riskified\Decider\Model\Api\Order\PaymentProcessor\Paypal; use Riskified\Decider\Model\Api\Order\PaymentProcessor\PaypalDirect; use Riskified\Decider\Model\Api\Order\PaymentProcessor\SagePay; use Riskified\Decider\Model\Api\Order\PaymentProcessor\Transarmor; -use Riskified\Decider\Model\Api\Order\PaymentProcessor\Braintree; -use Riskified\Decider\Model\Api\Order\PaymentProcessor\Payflowpro; -use Riskified\Decider\Model\Api\Order\PaymentProcessor\Adyen; -use Riskified\Decider\Model\Api\Order\PaymentProcessor\Cryozonic; use Riskified\Decider\Model\Api\Order\PaymentProcessor\Vantiv; class PaymentProcessorFactory { const GATEWAY_INSTANCE = [ - 'default' => Paypal::class, + 'default' => DefaultPaymentProcessor::class, 'authorizenet_directpost' => DirectPost::class, 'authnetcim' => Authcim::class, 'optimal_hosted' => OptimalHosted::class, From 8b6e74425b7db77081e3ee1e6550a0849566958f Mon Sep 17 00:00:00 2001 From: Wojtek Kaminski Date: Thu, 22 Oct 2020 14:32:15 +0200 Subject: [PATCH 02/15] Added missing usage of order class, code refactoring --- Model/Observer/OrderSaveAfter.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Model/Observer/OrderSaveAfter.php b/Model/Observer/OrderSaveAfter.php index 943445d..1782028 100644 --- a/Model/Observer/OrderSaveAfter.php +++ b/Model/Observer/OrderSaveAfter.php @@ -3,9 +3,12 @@ namespace Riskified\Decider\Model\Observer; use Magento\Framework\Event\ObserverInterface; +use Magento\Sales\Model\Order; +use Magento\Framework\Registry; +use Magento\Framework\Event\Observer; use Riskified\Decider\Model\Api\Api; -use Riskified\Decider\Model\Logger\Order as OrderLogger; use Riskified\Decider\Model\Api\Order as OrderApi; +use Riskified\Decider\Model\Logger\Order as OrderLogger; class OrderSaveAfter implements ObserverInterface { @@ -19,7 +22,7 @@ class OrderSaveAfter implements ObserverInterface */ private $_orderApi; /** - * @var \Magento\Framework\Registry + * @var Registry */ protected $_registry; @@ -28,23 +31,22 @@ class OrderSaveAfter implements ObserverInterface * * @param OrderLogger $logger * @param OrderApi $orderApi - * @param \Magento\Framework\Registry $registry + * @param $registry */ public function __construct( OrderLogger $logger, OrderApi $orderApi, - \Magento\Framework\Registry $registry - ) - { + Registry $registry + ) { $this->_logger = $logger; $this->_orderApi = $orderApi; $this->_registry = $registry; } /** - * @param \Magento\Framework\Event\Observer $observer + * @param Observer $observer */ - public function execute(\Magento\Framework\Event\Observer $observer) + public function execute(Observer $observer) { $order = $observer->getOrder(); @@ -54,7 +56,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) $newState = $order->getState(); - if((int)$order->dataHasChangedFor('state') === 1) { + if ((int)$order->dataHasChangedFor('state') === 1) { $oldState = $order->getOrigData('state'); if ($oldState == Order::STATE_HOLDED and $newState == Order::STATE_PROCESSING) { @@ -71,7 +73,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) } try { - if(!$this->_registry->registry("riskified-order")) { + if (!$this->_registry->registry("riskified-order")) { $this->_registry->register("riskified-order", $order); } $this->_orderApi->post($order, Api::ACTION_UPDATE); @@ -81,7 +83,6 @@ public function execute(\Magento\Framework\Event\Observer $observer) // There is no need to do anything here. The exception has already been handled and a retry scheduled. // We catch this exception so that the order is still saved in Magento. } - } else { $this->_logger->debug( sprintf( From a19f8852caeea461450ebe3954b86ef00f3e94a2 Mon Sep 17 00:00:00 2001 From: Wojtek Kaminski Date: Wed, 18 Nov 2020 14:45:12 +0100 Subject: [PATCH 03/15] - updated data points --- Model/Api/Order.php | 43 +++++++++++++++----------------------- Model/Api/Order/Helper.php | 26 +++++++++++++---------- 2 files changed, 32 insertions(+), 37 deletions(-) diff --git a/Model/Api/Order.php b/Model/Api/Order.php index 01a7697..4b724ca 100755 --- a/Model/Api/Order.php +++ b/Model/Api/Order.php @@ -2,7 +2,6 @@ namespace Riskified\Decider\Model\Api; -use Magento\Checkout\Model\Session; use Riskified\OrderWebhook\Model; class Order @@ -138,10 +137,10 @@ public function post($order, $action) throw new \Exception("Order doesn't not exists"); } $this->_orderHelper->setOrder($order); - $eventData = array( + $eventData = [ 'order' => $order, 'action' => $action - ); + ]; try { switch ($action) { case Api::ACTION_CREATE: @@ -166,7 +165,7 @@ public function post($order, $action) case Api::ACTION_FULFILL: $this->_orderHelper->setOrder($order->getOrder()); $orderForTransport = $this->_orderHelper->getOrderFulfillments($order); - + $order = $order->getOrder(); $eventData['order'] = $order->getOrder(); @@ -185,7 +184,6 @@ public function post($order, $action) 'riskified_decider_post_order_success', $eventData ); - } catch (\Riskified\OrderWebhook\Exception\CurlException $curlException) { $this->_raiseOrderUpdateEvent($order, 'error', null, 'Error transferring order data to Riskified'); $this->scheduleSubmissionRetry($order, $action); @@ -225,12 +223,12 @@ public function post($order, $action) */ private function _raiseOrderUpdateEvent($order, $status, $oldStatus, $description) { - $eventData = array( + $eventData = [ 'order' => $order, 'status' => $status, 'old_status' => $oldStatus, 'description' => $description - ); + ]; $this->_eventManager->dispatch( 'riskified_decider_order_update', $eventData @@ -272,15 +270,15 @@ private function load($model) if ($model->getPayment()) { $gateway = $model->getPayment()->getMethod(); } - if(is_null($model->getRiskifiedCartToken())){ + if (is_null($model->getRiskifiedCartToken())) { $cartToken = $this->session->getSessionId(); //save card_token into db $model->setRiskifiedCartToken($cartToken); $model->save(); - }else{ + } else { $cartToken = $model->getRiskifiedCartToken(); } - $order_array = array( + $order_array = [ 'id' => $this->_orderHelper->getOrderOrigId(), 'name' => $model->getIncrementId(), 'email' => $model->getCustomerEmail(), @@ -290,28 +288,21 @@ private function load($model) 'gateway' => $gateway, 'browser_ip' => $this->_orderHelper->getRemoteIp(), 'note' => $model->getCustomerNote(), - 'total_price' => $model->getGrandTotal(), + 'total_price' => floatval($model->getGrandTotal()), 'total_discounts' => $model->getDiscountAmount(), - 'subtotal_price' => $model->getBaseSubtotalInclTax(), - 'discount_codes' => $this->_orderHelper->getDiscountCodes($model), - 'taxes_included' => true, - 'total_tax' => $model->getBaseTaxAmount(), - 'total_weight' => $model->getWeight(), + 'discount_codes' => $this->_orderHelper->getDiscountCodes(), 'cancelled_at' => $this->_orderHelper->formatDateAsIso8601($this->_orderHelper->getCancelledAt()), - 'financial_status' => $model->getState(), - 'fulfillment_status' => $model->getStatus(), 'vendor_id' => strval($model->getStoreId()), 'vendor_name' => $model->getStoreName(), 'cart_token' => $cartToken - ); - + ]; if ($this->_orderHelper->isAdmin()) { unset($order_array['browser_ip']); unset($order_array['cart_token']); $order_array['source'] = 'admin'; } else { - $order_array['source'] = 'web'; + $order_array['source'] = 'desktop_web'; } $order = new Model\Order(array_filter($order_array, 'strlen')); @@ -349,12 +340,12 @@ public function update($order, $status, $oldStatus, $description) $this->logger->log('Dispatching event for order ' . $order->getId() . ' with status "' . $status . '" old status "' . $oldStatus . '" and description "' . $description . '"'); - $eventData = array( + $eventData = [ 'order' => $order, 'status' => $status, 'old_status' => $oldStatus, 'description' => $description - ); + ]; $this->_eventManager->dispatch( 'riskified_decider_order_update', @@ -442,7 +433,7 @@ public function postHistoricalOrders($models) if (!$this->_apiConfig->isEnabled()) { return; } - $orders = array(); + $orders = []; foreach ($models as $model) { $orders[] = $this->getOrder($model); @@ -467,11 +458,11 @@ public function scheduleSubmissionRetry(\Magento\Sales\Model\Order $order, $acti if ($existingRetries->getSize() == 0) { $queue = $this->queueFactory->create(); - $queue->addData(array( + $queue->addData([ 'order_id' => $order->getId(), 'action' => $action, 'updated_at' => $this->date->gmtDate() - ))->save(); + ])->save(); $this->logger->log("New retry scheduled successfully"); } diff --git a/Model/Api/Order/Helper.php b/Model/Api/Order/Helper.php index 63ca36a..e02a6ca 100755 --- a/Model/Api/Order/Helper.php +++ b/Model/Api/Order/Helper.php @@ -246,7 +246,6 @@ public function getCustomer() 'first_name' => $this->getOrder()->getCustomerFirstname(), 'last_name' => $this->getOrder()->getCustomerLastname(), 'note' => $this->getOrder()->getCustomerNote(), - 'group_name' => $this->getOrder()->getCustomerGroupId() ); if ($customer_id) { $customer_details = $this->customer->load($customer_id); @@ -346,9 +345,7 @@ public function getAllShipmentItems($object) */ protected function getPreparedLineItem($item) { - $prod_type = null; - - $prod_type = null; + $prod_type = "physical"; $category = null; $sub_categories = null; $brand = null; @@ -379,6 +376,10 @@ protected function getPreparedLineItem($item) } } + if ($item->getIsVirtual()) { + $prod_type = "digital"; + } + $line_item = new Model\LineItem(array_filter(array( 'price' => floatval($item->getPrice()), 'quantity' => intval($item->getQtyOrdered()), @@ -389,7 +390,8 @@ protected function getPreparedLineItem($item) 'product_type' => $prod_type, 'brand' => $brand, 'category' => (isset($categories) && !empty($categories)) ? implode('|', $categories) : '', - 'sub_category' => (isset($sub_categories) && !empty($sub_categories)) ? implode('|', $sub_categories) : '' + 'sub_category' => (isset($sub_categories) && !empty($sub_categories)) ? implode('|', $sub_categories) : '', + 'required_shipping' => $item->getIsVirtual() ? true : false ), 'strlen')); return $line_item; @@ -569,16 +571,18 @@ public function preparePaymentData($payment, &$paymentData) } /** - * @return Model\ShippingLine + * @return array * @throws \Exception */ public function getShippingLines() { - return [new Model\ShippingLine(array_filter(array( - 'price' => $this->getOrder()->getShippingAmount(), - 'title' => strip_tags($this->getOrder()->getShippingDescription()), - 'code' => $this->getOrder()->getShippingMethod() - ), 'strlen'))]; + return [ + [ + 'price' => floatval($this->getOrder()->getShippingAmount()), + 'title' => strip_tags($this->getOrder()->getShippingDescription()), + 'code' => $this->getOrder()->getShippingMethod() + ] + ]; } /** From 6fff8f57b276fb53963625bc487ea26017dfd6b1 Mon Sep 17 00:00:00 2001 From: Rich Spitkovsky <44982954+rich-spitkovsky-riskified@users.noreply.github.com> Date: Wed, 25 Nov 2020 08:37:42 -0500 Subject: [PATCH 04/15] bump version number --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 82825ba..ce5c89f 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "riskified/magento2new", "type": "magento2-module", "description": "Riskified decider module for Magento 2", - "version": "1.1.0", + "version": "1.9.1-1", "require": { "magento/framework": ">=100.1.0", "riskified/php_sdk": "*" From f778a1812799654c8077847723f8978837361d2d Mon Sep 17 00:00:00 2001 From: Wojtek Kaminski Date: Fri, 4 Dec 2020 13:57:59 +0100 Subject: [PATCH 05/15] Added fix for building refund object --- Model/Api/Order/Helper.php | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/Model/Api/Order/Helper.php b/Model/Api/Order/Helper.php index 63ca36a..b9dde48 100755 --- a/Model/Api/Order/Helper.php +++ b/Model/Api/Order/Helper.php @@ -435,24 +435,6 @@ public function getAddress($address) return new Model\Address($addrArray); } - /** - * @param $payload - * @return Model\RefundDetails - * @throws \Exception - */ - public function buildRefundDetailsObject($payload) - { - $refundObject = new Model\RefundDetails(array_filter(array( - 'refund_id' => $payload->getIncrementId(), - 'amount' => $payload->getSubtotal(), - 'currency' => $payload->getBaseCurrencyCode(), - 'refunded_at' => $payload->getCreatedAt(), - 'reason' => $payload->getCustomerNote() - ), 'strlen')); - - return $refundObject; - } - /** * @return array * @throws \Exception @@ -462,9 +444,16 @@ public function getRefundDetails() $order = $this->getOrder(); $creditMemos = $order->getCreditmemosCollection(); $refundObjectCollection = array(); - if($creditMemos->getSize() > 0){ - foreach($creditMemos as $memo){ - array_push($refundObjectCollection, $this->buildRefundDetailsObject($memo)); + if ($creditMemos->getSize() > 0) { + foreach ($creditMemos->getData() as $memo) { + $refundObjectCollection[] = new Model\RefundDetails(array_filter([ + 'refund_id' => $memo['increment_id'], + 'amount' => $memo['subtotal'], + 'currency' => $memo['base_currency_code'], + 'refunded_at' => $memo['created_at'], + 'reason' => $memo['customer_note'] + ], 'strlen')); + } } From f66f06c71ac13cba026ef99ae74d5030c4d2e356 Mon Sep 17 00:00:00 2001 From: Wojtek Kaminski Date: Fri, 4 Dec 2020 14:22:52 +0100 Subject: [PATCH 06/15] Added checking double notification sent --- Model/Observer/Order/Declined.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Model/Observer/Order/Declined.php b/Model/Observer/Order/Declined.php index 2d0cd61..beab106 100644 --- a/Model/Observer/Order/Declined.php +++ b/Model/Observer/Order/Declined.php @@ -146,6 +146,10 @@ public function execute(\Magento\Framework\Event\Observer $observer) return $this; } + if (!$order->getDeclineNotificationSent()) { + return $this; + } + $subject = $this->apiConfig->getDeclineNotificationSubject(); $content = $this->apiConfig->getDeclineNotificationContent(); @@ -220,6 +224,8 @@ public function execute(\Magento\Framework\Event\Observer $observer) ->addStatusHistoryComment($orderComment) ->setIsCustomerNotified(true); + $order->setDeclineNotificationSent(true); + $this->orderRepository->save($order); } catch (\Exception $e) { $this->logger->critical($e->getMessage()); From 2a8f68c75bea9832b3d4895b88f9332f910594b7 Mon Sep 17 00:00:00 2001 From: Rich Spitkovsky <44982954+rich-spitkovsky-riskified@users.noreply.github.com> Date: Mon, 7 Dec 2020 10:04:40 -0500 Subject: [PATCH 07/15] bump version number --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ce5c89f..66702f4 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "riskified/magento2new", "type": "magento2-module", "description": "Riskified decider module for Magento 2", - "version": "1.9.1-1", + "version": "1.9.1-2", "require": { "magento/framework": ">=100.1.0", "riskified/php_sdk": "*" From e88381f74f208c3986bd37e27c59fa1452093c10 Mon Sep 17 00:00:00 2001 From: Rich Spitkovsky <44982954+rich-spitkovsky-riskified@users.noreply.github.com> Date: Mon, 7 Dec 2020 11:50:52 -0500 Subject: [PATCH 08/15] recapture financial_status, fulfillment_status --- Model/Api/Order.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Model/Api/Order.php b/Model/Api/Order.php index 4b724ca..eb813a7 100755 --- a/Model/Api/Order.php +++ b/Model/Api/Order.php @@ -290,6 +290,8 @@ private function load($model) 'note' => $model->getCustomerNote(), 'total_price' => floatval($model->getGrandTotal()), 'total_discounts' => $model->getDiscountAmount(), + 'financial_status' => $model->getState(), + 'fulfillment_status' => $model->getStatus(), 'discount_codes' => $this->_orderHelper->getDiscountCodes(), 'cancelled_at' => $this->_orderHelper->formatDateAsIso8601($this->_orderHelper->getCancelledAt()), 'vendor_id' => strval($model->getStoreId()), From 1b521a6cddb38e35811f67c585af9fb2be577c6a Mon Sep 17 00:00:00 2001 From: Rich Spitkovsky <44982954+rich-spitkovsky-riskified@users.noreply.github.com> Date: Mon, 7 Dec 2020 11:57:37 -0500 Subject: [PATCH 09/15] Modified conditional for sending decline email --- Model/Observer/Order/Declined.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Observer/Order/Declined.php b/Model/Observer/Order/Declined.php index beab106..53e19c7 100644 --- a/Model/Observer/Order/Declined.php +++ b/Model/Observer/Order/Declined.php @@ -146,7 +146,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) return $this; } - if (!$order->getDeclineNotificationSent()) { + if ($order->getDeclineNotificationSent()) { return $this; } From 33b025de1725ba17ae024080b4dda4f551267cbd Mon Sep 17 00:00:00 2001 From: Wojtek Kaminski Date: Wed, 9 Dec 2020 07:56:10 +0100 Subject: [PATCH 10/15] Added fix for setting area --- Model/Command/UploadHistoricalOrders.php | 54 +++++++++++++++--------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/Model/Command/UploadHistoricalOrders.php b/Model/Command/UploadHistoricalOrders.php index 17ec675..7803098 100644 --- a/Model/Command/UploadHistoricalOrders.php +++ b/Model/Command/UploadHistoricalOrders.php @@ -2,6 +2,13 @@ namespace Riskified\Decider\Model\Command; +use Magento\Framework\Api\SearchCriteria; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\State; +use Magento\Framework\Exception\LocalizedException; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Api\Data\OrderSearchResultInterface; +use Magento\Sales\Api\OrderRepositoryInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -17,17 +24,17 @@ class UploadHistoricalOrders extends Command const BATCH_SIZE = 10; /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface + * @var ScopeConfigInterface */ protected $_scopeConfig; /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ protected $_orderRepository; /** - * @var \Magento\Framework\Api\SearchCriteria + * @var SearchCriteria */ protected $_searchCriteriaBuilder; @@ -52,34 +59,39 @@ class UploadHistoricalOrders extends Command protected $_currentPage = 1; /** - * @var + * @var OrderInterface[] */ protected $_orders; + /** + * @var State + */ + private $state; + /** * UploadHistoricalOrders constructor. * - * @param \Magento\Framework\App\State $state - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Magento\Framework\Api\SearchCriteria $searchCriteriaBuilder + * @param State $state + * @param ScopeConfigInterface $scopeConfig + * @param OrderRepositoryInterface $orderRepository + * @param SearchCriteria $searchCriteriaBuilder * @param Helper $helper */ public function __construct( - \Magento\Framework\App\State $state, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Sales\Api\OrderRepositoryInterface $orderRepository, - \Magento\Framework\Api\SearchCriteria $searchCriteriaBuilder, + State $state, + ScopeConfigInterface $scopeConfig, + OrderRepositoryInterface $orderRepository, + SearchCriteria $searchCriteriaBuilder, Helper $helper ) { - $state->setAreaCode('adminhtml'); - $this->_scopeConfig = $scopeConfig; $this->_orderRepository = $orderRepository; $this->_searchCriteriaBuilder = $searchCriteriaBuilder; $this->_orderHelper = $helper; + $this->state = $state; + $this->_transport = new CurlTransport(new Signature\HttpDataSignature()); $this->_transport->timeout = 15; @@ -99,9 +111,11 @@ protected function configure() /** * @inheritdoc + * @throws LocalizedException */ protected function execute(InputInterface $input, OutputInterface $output) { + $this->state->setAreaCode('adminhtml'); $authToken = $this->_scopeConfig->getValue('riskified/riskified/key', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); $env = constant('\Riskified\Common\Env::' . $this->_scopeConfig->getValue('riskified/riskified/env')); @@ -142,14 +156,13 @@ protected function execute(InputInterface $input, OutputInterface $output) /** * Retrieve prepared order collection for counting values * - * @return \Magento\Sales\Api\Data\OrderSearchResultInterface + * @return OrderSearchResultInterface */ protected function getEntireCollection() { - $orderResult = $this + return $this ->_orderRepository ->getList($this->_searchCriteriaBuilder); - return $orderResult; } /** @@ -162,6 +175,7 @@ protected function getCollection() $this->_searchCriteriaBuilder ->setPageSize(self::BATCH_SIZE) ->setCurrentPage($this->_currentPage); + $orderResult = $this->_orderRepository->getList($this->_searchCriteriaBuilder); $this->_orders = $orderResult->getItems(); } @@ -170,6 +184,7 @@ protected function getCollection() * Sends orders to endpoint * * @return void + * @throws \Exception */ protected function postOrders() { @@ -185,9 +200,10 @@ protected function postOrders() } /** - * @param Model\Order $model + * @param OrderInterface $model * * @return Model\Order + * @throws \Exception */ protected function prepareOrder($model) { @@ -211,7 +227,7 @@ protected function prepareOrder($model) 'total_price' => $model->getGrandTotal(), 'total_discounts' => $model->getDiscountAmount(), 'subtotal_price' => $model->getBaseSubtotalInclTax(), - 'discount_codes' => $this->_orderHelper->getDiscountCodes($model), + 'discount_codes' => $this->_orderHelper->getDiscountCodes(), 'taxes_included' => true, 'total_tax' => $model->getBaseTaxAmount(), 'total_weight' => $model->getWeight(), From 0500e4af987c205c6e66fc8793681401e6b7d6ab Mon Sep 17 00:00:00 2001 From: Rich Spitkovsky <44982954+rich-spitkovsky-riskified@users.noreply.github.com> Date: Wed, 9 Dec 2020 09:24:57 -0500 Subject: [PATCH 11/15] Update di.xml --- etc/di.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/di.xml b/etc/di.xml index 6fa9a08..8cf43ef 100755 --- a/etc/di.xml +++ b/etc/di.xml @@ -26,11 +26,11 @@ - + Riskified\Decider\Model\Command\UploadHistoricalOrders - \ No newline at end of file + From c5373b08a5b2ce90242aff330c1927bab2ab65a0 Mon Sep 17 00:00:00 2001 From: Rich Spitkovsky <44982954+rich-spitkovsky-riskified@users.noreply.github.com> Date: Thu, 10 Dec 2020 12:35:28 -0500 Subject: [PATCH 12/15] Update Helper.php --- Model/Api/Order/Helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Api/Order/Helper.php b/Model/Api/Order/Helper.php index 87eeab1..22ac7fc 100755 --- a/Model/Api/Order/Helper.php +++ b/Model/Api/Order/Helper.php @@ -391,7 +391,7 @@ protected function getPreparedLineItem($item) 'brand' => $brand, 'category' => (isset($categories) && !empty($categories)) ? implode('|', $categories) : '', 'sub_category' => (isset($sub_categories) && !empty($sub_categories)) ? implode('|', $sub_categories) : '', - 'required_shipping' => $item->getIsVirtual() ? true : false + 'requires_shipping' => $item->getIsVirtual() ? false : true ), 'strlen')); return $line_item; From 920e65a5246dd2e6ca621fb61f4730d37eea8502 Mon Sep 17 00:00:00 2001 From: Rich Spitkovsky <44982954+rich-spitkovsky-riskified@users.noreply.github.com> Date: Wed, 16 Dec 2020 17:33:02 -0500 Subject: [PATCH 13/15] add adyen_hpp to gateway instance --- Model/Api/Order/PaymentProcessorFactory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Model/Api/Order/PaymentProcessorFactory.php b/Model/Api/Order/PaymentProcessorFactory.php index 629ac6e..d072ebd 100644 --- a/Model/Api/Order/PaymentProcessorFactory.php +++ b/Model/Api/Order/PaymentProcessorFactory.php @@ -39,6 +39,7 @@ class PaymentProcessorFactory 'payflowpro' => Payflowpro::class, 'adyen_oneclick' => Adyen::class, 'adyen_cc' => Adyen::class, + 'adyen_hpp' => Paypal::class, 'cryozonic_stripe' => Cryozonic::class, 'vantiv_cc' => Vantiv::class ]; From 85409d5d28d890b160e03440ba648dd54ad56e2b Mon Sep 17 00:00:00 2001 From: Rich Spitkovsky <44982954+rich-spitkovsky-riskified@users.noreply.github.com> Date: Wed, 16 Dec 2020 17:47:37 -0500 Subject: [PATCH 14/15] alternative requires_shipping function --- Model/Api/Order/Helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Api/Order/Helper.php b/Model/Api/Order/Helper.php index 22ac7fc..939ecd7 100755 --- a/Model/Api/Order/Helper.php +++ b/Model/Api/Order/Helper.php @@ -391,7 +391,7 @@ protected function getPreparedLineItem($item) 'brand' => $brand, 'category' => (isset($categories) && !empty($categories)) ? implode('|', $categories) : '', 'sub_category' => (isset($sub_categories) && !empty($sub_categories)) ? implode('|', $sub_categories) : '', - 'requires_shipping' => $item->getIsVirtual() ? false : true + 'requires_shipping' => (bool)!$item->getIsVirtual() ), 'strlen')); return $line_item; From 9b1699b039d308597ec5f113654b28794a395de2 Mon Sep 17 00:00:00 2001 From: Wojtek Kaminski Date: Thu, 7 Jan 2021 17:24:21 +0100 Subject: [PATCH 15/15] Removed populating cc data --- Model/Api/Order/Helper.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/Model/Api/Order/Helper.php b/Model/Api/Order/Helper.php index 63ca36a..351a8d0 100755 --- a/Model/Api/Order/Helper.php +++ b/Model/Api/Order/Helper.php @@ -563,9 +563,6 @@ public function preparePaymentData($payment, &$paymentData) if (!isset($paymentData['credit_card_bin']) || !$paymentData['credit_card_bin']) { $paymentData['credit_card_bin'] = $this->registry->registry('riskified_cc_bin'); } - if (isset($paymentData['credit_card_bin'])) { - $paymentData['credit_card_bin'] = "XXXX-XXXX-XXXX-" . $paymentData['credit_card_bin']; - } } /**