Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/code/Riskified/Decider/Api/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ public function __construct(Config $apiConfig)

public function initSdk($order = null)
{
$storeId = (!is_null($order)) ? $order->getStore() : null;
$this->_apiConfig->setStore($storeId);

$authToken = $this->_apiConfig->getAuthToken();
$env = constant($this->_apiConfig->getConfigEnv());
$shopDomain = $this->_apiConfig->getShopDomain();
$this->version = $this->_apiConfig->getExtensionVersion();
$storeId = (!is_null($order)) ? $order->getStore() : null;
$this->_apiConfig->setStore($storeId);

Riskified::init($shopDomain, $authToken, $env, Validations::SKIP);
}
Expand Down
24 changes: 21 additions & 3 deletions app/code/Riskified/Decider/Api/Config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Riskified\Decider\Api;

use Magento\Framework\App\Config\ScopeConfigInterface;
use \Magento\Store\Model\ScopeInterface as ScopeInterface;

class Config
Expand All @@ -15,7 +16,7 @@ class Config
const BEACON_URL = 'beacon.riskified.com';

public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
ScopeConfigInterface $scopeConfig,
\Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
\Magento\Framework\Module\FullModuleList $fullModuleList,
\Magento\Checkout\Model\Session $checkoutSession
Expand Down Expand Up @@ -44,6 +45,7 @@ public function getAuthToken()
{
return $this->_scopeConfig->getValue(
'riskified/riskified/key',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -52,6 +54,7 @@ public function getConfigStatusControlActive()
{
return $this->_scopeConfig->getValue(
'riskified/riskified/order_status_sync',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -60,6 +63,7 @@ public function getConfigEnv()
{
return '\Riskified\Common\Env::' . $this->_scopeConfig->getValue(
'riskified/riskified/env',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -73,6 +77,7 @@ public function getConfigEnableAutoInvoice()
{
return $this->_scopeConfig->getValue(
'riskified/riskified/auto_invoice_enabled',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -81,6 +86,7 @@ public function getConfigAutoInvoiceCaptureCase()
{
return $this->_scopeConfig->getValue(
'riskified/riskified/auto_invoice_capture_case',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -94,6 +100,7 @@ public function getShopDomain()
{
return $this->_scopeConfig->getValue(
'riskified/riskified/domain',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -108,6 +115,7 @@ public function getDeclinedState()
{
return $this->_scopeConfig->getValue(
'riskified/riskified/declined_state',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -117,6 +125,7 @@ public function getDeclinedStatus()
$state = $this->getDeclinedState();
return $this->_scopeConfig->getValue(
'riskified/riskified/declined_status_' . $state,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -125,6 +134,7 @@ public function getApprovedState()
{
return $this->_scopeConfig->getValue(
'riskified/riskified/approved_state',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -134,6 +144,7 @@ public function getApprovedStatus()
$state = $this->getApprovedState();
return $this->_scopeConfig->getValue(
'riskified/riskified/approved_status_' . $state,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -142,6 +153,7 @@ public function isLoggingEnabled()
{
return (bool)$this->_scopeConfig->getValue(
'riskified/riskified/debug_logs',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -150,6 +162,7 @@ public function isAutoInvoiceEnabled()
{
return (bool)$this->_scopeConfig->getValue(
'riskified/riskified/auto_invoice_enabled',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -158,6 +171,7 @@ public function getInvoiceCaptureCase()
{
$captureCase = $this->_scopeConfig->getValue(
'riskified/riskified/auto_invoice_capture_case',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);

Expand All @@ -177,6 +191,7 @@ public function getCaptureCase()
{
$captureCase = $this->_scopeConfig->getValue(
'riskified/riskified/auto_invoice_capture_case',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);

Expand Down Expand Up @@ -209,6 +224,7 @@ public function getDeclineNotificationSender()
{
return $this->_scopeConfig->getValue(
'riskified/decline_notification/email_identity',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -217,6 +233,7 @@ public function getDeclineNotificationSenderEmail()
{
return $this->_scopeConfig->getValue(
'trans_email/ident_' . $this->getDeclineNotificationSender() . '/email',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand All @@ -225,6 +242,7 @@ public function getDeclineNotificationSenderName()
{
return $this->_scopeConfig->getValue(
'trans_email/ident_' . $this->getDeclineNotificationSender() . '/name',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getStore()
);
}
Expand Down Expand Up @@ -272,6 +290,6 @@ public function setStore($id)
*/
public function getStore()
{
return (!is_null($this->store)) ? $this->store : ScopeInterface::SCOPE_STORES;
return (!is_null($this->store)) ? $this->store : null;
}
}
}