Skip to content

Commit

Permalink
Merge pull request #29 from signifyd/stage
Browse files Browse the repository at this point in the history
3.5.0
  • Loading branch information
sig-chrismorris528 authored Nov 20, 2019
2 parents 2a0d385 + 5543f0a commit c851dc7
Show file tree
Hide file tree
Showing 94 changed files with 768 additions and 352 deletions.
3 changes: 1 addition & 2 deletions Api/Core/SignifydAPIFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
* After remove this class it is necessary to replace all its occurrences with \Signifyd\Core\SignifydAPIFactory
*
* Class SignifydAPIFactory
* @package Signifyd\Connect\Api\Core
*/
class SignifydAPIFactory extends \Signifyd\Core\SignifydAPIFactory
{
}
}
2 changes: 1 addition & 1 deletion Block/Adminhtml/CaseInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ public function getCaseScore()
{
return floor($this->getCaseEntity()->getData('score'));
}
}
}
4 changes: 2 additions & 2 deletions Block/Adminhtml/Order/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public function getCase(\Magento\Sales\Model\Order $order)
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

/** @var $case \Signifyd\Connect\Model\Casedata */
$case = $objectManager->get('Signifyd\Connect\Model\Casedata');
$case = $objectManager->get(\Signifyd\Connect\Model\Casedata::class);
$case->load($order->getIncrementId());
return $case;
}
}
}
2 changes: 1 addition & 1 deletion Block/Adminhtml/System/Config/Field/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ protected function _getElementHtml(AbstractElement $element)
{
return $this->moduleResource->getDbVersion('Signifyd_Connect');
}
}
}
2 changes: 1 addition & 1 deletion Block/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ public function isEnabled()
return false;
}
}
}
}
5 changes: 3 additions & 2 deletions Controller/Adminhtml/Order/Unhold.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function execute()
}

/** @var $case \Signifyd\Connect\Model\Casedata */
$case = $this->_objectManager->get('Signifyd\Connect\Model\Casedata');
$case = $this->_objectManager->get(\Signifyd\Connect\Model\Casedata::class);
$case->load($order->getIncrementId());

if (!$case->isHoldReleased()) {
Expand All @@ -72,7 +72,8 @@ public function execute()

$resultRedirect = parent::execute();

$order->addStatusHistoryComment("Signifyd: order status updated by {$this->authSession->getUser()->getUserName()}");
$message = "Signifyd: order status updated by {$this->authSession->getUser()->getUserName()}";
$order->addStatusHistoryComment($message);
$order->save();

return $resultRedirect;
Expand Down
19 changes: 5 additions & 14 deletions Controller/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,19 @@ public function match(\Magento\Framework\App\RequestInterface $request)
if ($request->getModuleName() === 'signifyd_connect') {
return;
}
/*
* We will search “examplerouter” and “exampletocms” words and make forward depend on word
* -examplerouter will forward to base router to match Signifydtest front name, test controller path and test controller class
* -exampletocms will set front name to cms, controller path to page and action to view
*/

$identifier = trim($request->getPathInfo(), '/');

if(strpos($identifier, 'signifyd/webhooks') !== false && strpos($identifier, 'signifyd/webhooks/handler') === false) {
/*
* We must set module, controller path and action name for our controller class(Controller/Test/Test.php)
*/
if (strpos($identifier, 'signifyd/webhooks') !== false &&
strpos($identifier, 'signifyd/webhooks/handler') === false
) {
$request->setModuleName('signifyd_connect')->setControllerName('webhooks')->setActionName('index');
} else {
//There is no match
return;
}

/*
* We have match and now we will forward action
*/
return $this->actionFactory->create(
'Magento\Framework\App\Action\Forward',
\Magento\Framework\App\Action\Forward::class,
['request' => $request]
);
}
Expand Down
10 changes: 5 additions & 5 deletions Controller/Webhooks/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(
// Compatibility with Magento 2.3+ which required form_key on every request
// Magento expects class to implement \Magento\Framework\App\CsrfAwareActionInterface but this causes
// a backward incompatibility to Magento versions below 2.3
if (interface_exists("\Magento\Framework\App\CsrfAwareActionInterface")) {
if (interface_exists(\Magento\Framework\App\CsrfAwareActionInterface::class)) {
$request = $this->getRequest();
if ($request instanceof RequestInterface && $request->isPost() && empty($request->getParam('form_key'))) {
$request->setParam('form_key', $formKey->getFormKey());
Expand Down Expand Up @@ -121,13 +121,13 @@ public function processRequest($request, $hash, $topic)
/** @var $order \Magento\Sales\Model\Order */
$order = $this->orderFactory->create()->loadByIncrementId($requestJson->orderId);
/** @var $case \Signifyd\Connect\Model\Casedata */
$case = $this->objectManager->create('Signifyd\Connect\Model\Casedata')->load($requestJson->orderId);
$case = $this->objectManager->create(\Signifyd\Connect\Model\Casedata::class)->load($requestJson->orderId);

$caseData = array(
$caseData = [
"case" => $case,
"order" => $order,
"response" => $requestJson
);
];

if ($case->isEmpty()) {
$message = "Case {$requestJson->orderId} on request not found on Magento";
Expand Down Expand Up @@ -156,7 +156,7 @@ public function processRequest($request, $hash, $topic)

if ($signifydApi->validWebhookRequest($request, $hash, $topic)) {
/** @var \Signifyd\Connect\Model\Casedata $caseObj */
$caseObj = $this->objectManager->create('Signifyd\Connect\Model\Casedata');
$caseObj = $this->objectManager->create(\Signifyd\Connect\Model\Casedata::class);
$caseObj->updateCase($caseData);
$this->getResponse()->setStatusCode(Http::STATUS_CODE_200);
return;
Expand Down
13 changes: 8 additions & 5 deletions Cron/RetryCaseJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public function execute()
$waitingCases = $this->caseRetryObj->getRetryCasesByStatus(Casedata::WAITING_SUBMISSION_STATUS);

foreach ($waitingCases as $case) {
$this->logger->debug("Signifyd: preparing for send case no: {$case['order_increment']}", array('entity' => $case));
$message = "Signifyd: preparing for send case no: {$case['order_increment']}";
$this->logger->debug($message, ['entity' => $case]);

$order = $this->getOrder($case['order_increment']);

Expand All @@ -70,7 +71,7 @@ public function execute()

if ($result) {
/** @var \Signifyd\Connect\Model\Casedata $caseObj */
$caseObj = $this->_objectManager->create('Signifyd\Connect\Model\Casedata')
$caseObj = $this->_objectManager->create(\Signifyd\Connect\Model\Casedata::class)
->load($case->getOrderIncrement())
->setCode($result)
->setMagentoStatus(Casedata::IN_REVIEW_STATUS)
Expand All @@ -85,7 +86,8 @@ public function execute()
$inReviewCases = $this->caseRetryObj->getRetryCasesByStatus(Casedata::IN_REVIEW_STATUS);

foreach ($inReviewCases as $case) {
$this->logger->debug("Signifyd: preparing for review case no: {$case['order_increment']}", array('entity' => $case));
$message = "Signifyd: preparing for review case no: {$case['order_increment']}";
$this->logger->debug($message, ['entity' => $case]);

$this->caseRetryObj->processInReviewCase($case, $this->getOrder($case['order_increment']));
}
Expand All @@ -96,7 +98,8 @@ public function execute()
$inProcessingCases = $this->caseRetryObj->getRetryCasesByStatus(Casedata::PROCESSING_RESPONSE_STATUS);

foreach ($inProcessingCases as $case) {
$this->logger->debug("Signifyd: preparing for process case no: {$case['order_increment']}", array('entity' => $case));
$message = "Signifyd: preparing for process case no: {$case['order_increment']}";
$this->logger->debug($message, ['entity' => $case]);

$this->caseRetryObj->processResponseStatus($case, $this->getOrder($case['order_increment']));
}
Expand All @@ -108,6 +111,6 @@ public function execute()

public function getOrder($incrementId)
{
return $this->_objectManager->get('Magento\Sales\Model\Order')->loadByIncrementId($incrementId);
return $this->_objectManager->get(\Magento\Sales\Model\Order::class)->loadByIncrementId($incrementId);
}
}
6 changes: 1 addition & 5 deletions CustomerData/Fingerprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
use Magento\Checkout\Model\Session;
use Signifyd\Connect\Helper\DeviceHelper;

/**
* Class FingerprintSection
* @package Signifyd\Connect\CustomerData
*/
class Fingerprint extends DataObject implements SectionSourceInterface
{
/**
Expand Down Expand Up @@ -75,4 +71,4 @@ public function getSectionData()

return $data;
}
}
}
8 changes: 4 additions & 4 deletions Helper/ConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public function __construct(
\Signifyd\Connect\Helper\SignifydSettingsMagentoFactory $signifydSettingsMagentoFactory,
\Signifyd\Connect\Api\Core\SignifydAPIFactory $signifydAPIFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager
)
{
) {
$this->scopeConfigInterface = $scopeConfigInterface;
$this->signifydSettingsMagentoFactory = $signifydSettingsMagentoFactory;
$this->signifydAPIFactory = $signifydAPIFactory;
Expand Down Expand Up @@ -151,7 +150,8 @@ public function getSignifydApi(\Magento\Framework\Model\AbstractModel $entity =
if (isset($this->signifydAPI[$storeCode]) === false ||
$this->signifydAPI[$storeCode] instanceof \Signifyd\Core\SignifydAPI == false) {
$signifydSettingsMagento = $this->getSignifydSettingsMagento($entity);
$this->signifydAPI[$storeCode] = $this->signifydAPIFactory->create(array('settings' => $signifydSettingsMagento));
$data = ['settings' => $signifydSettingsMagento];
$this->signifydAPI[$storeCode] = $this->signifydAPIFactory->create($data);
}

return $this->signifydAPI[$storeCode];
Expand All @@ -171,4 +171,4 @@ public function isEnabled(\Magento\Framework\Model\AbstractModel $entity = null)

return $this->getConfigData('signifyd/general/enabled', $entity, true);
}
}
}
2 changes: 1 addition & 1 deletion Helper/DeviceHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ public function generateFingerprint($quoteId)
$baseUrl = $this->storeManager->getStore()->getBaseUrl();
return 'M2' . base64_encode($baseUrl) . $quoteId;
}
}
}
18 changes: 9 additions & 9 deletions Helper/FulfillmentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function generateFulfillmentData(\Magento\Sales\Model\Order\Shipment $shi
}

/** @var \Signifyd\Models\Fulfillment $fulfillment */
$fulfillment = SignifydModel::Make("\\Signifyd\\Models\\Fulfillment");
$fulfillment = SignifydModel::Make(\Signifyd\Models\Fulfillment::class);
$fulfillment->id = $shipment->getIncrementId();
$fulfillment->orderId = $shipment->getOrder()->getIncrementId();
$fulfillment->createdAt = $this->getCreatedAt($shipment);
Expand All @@ -240,7 +240,7 @@ public function generateFulfillmentData(\Magento\Sales\Model\Order\Shipment $shi
*/
public function getTrackingNumbers(\Magento\Sales\Model\Order\Shipment $shipment)
{
$trackingNumbers = array();
$trackingNumbers = [];

$trackingCollection = $shipment->getTracksCollection();
/**
Expand Down Expand Up @@ -317,7 +317,7 @@ public function getFulfillmentStatus(\Magento\Sales\Model\Order\Shipment $shipme
*/
public function getTrackingUrls(\Magento\Sales\Model\Order\Shipment $shipment)
{
return array();
return [];
}

/**
Expand All @@ -326,7 +326,7 @@ public function getTrackingUrls(\Magento\Sales\Model\Order\Shipment $shipment)
*/
public function getProducts(\Magento\Sales\Model\Order\Shipment $shipment)
{
$products = array();
$products = [];

/** @var \Magento\Sales\Model\Order\Shipment\Item $item */
foreach ($shipment->getAllItems() as $item) {
Expand All @@ -338,7 +338,7 @@ public function getProducts(\Magento\Sales\Model\Order\Shipment $shipment)
*/

/** @var \Signifyd\Models\Product $product */
$product = SignifydModel::Make("\\Signifyd\\Models\\Product");
$product = SignifydModel::Make(\Signifyd\Models\Product::class);
$product->itemId = $item->getSku();
$product->itemName = $item->getName();
$product->itemIsDigital = (bool) $item->getOrderItem()->getIsVirtual();
Expand Down Expand Up @@ -394,14 +394,14 @@ public function getItemImage(\Magento\Sales\Model\Order\Shipment\Item $item)
*/
public function getShipmentStatus(\Magento\Sales\Model\Order\Shipment $shipment)
{
$validShipmentStatus = array(
$validShipmentStatus = [
'in transit',
'out for delivery',
'waiting for pickup',
'failed attempt',
'delivered',
'exception'
);
];

return null;
}
Expand All @@ -413,7 +413,7 @@ public function getShipmentStatus(\Magento\Sales\Model\Order\Shipment $shipment)
public function getDeliveryAddress(\Magento\Sales\Model\Order\Shipment $shipment)
{
/** @var \Signifyd\Models\Address $deliveryAddress */
$deliveryAddress = SignifydModel::Make("\\Signifyd\\Models\\Address");
$deliveryAddress = SignifydModel::Make(\Signifyd\Models\Address::class);
$deliveryAddress->streetAddress = $this->getStreetAddress($shipment);
$deliveryAddress->unit = null;
$deliveryAddress->city = $shipment->getShippingAddress()->getCity();
Expand All @@ -433,4 +433,4 @@ public function getStreetAddress(\Magento\Sales\Model\Order\Shipment $shipment)
$street = $shipment->getShippingAddress()->getStreet();
return implode(', ', $street);
}
}
}
Loading

0 comments on commit c851dc7

Please sign in to comment.