diff --git a/Block/Info.php b/Block/Info.php index 91b559e..4687187 100644 --- a/Block/Info.php +++ b/Block/Info.php @@ -20,6 +20,8 @@ use Magento\Framework\Phrase; use Magento\Payment\Block\ConfigurableInfo; +use Magento\Sales\Model\Order; +use Magento\Store\Model\ScopeInterface; /** * Payment Block Info class @@ -97,8 +99,28 @@ public function getLoanId() */ public function getAdminAffirmUrl() { + /** @var Order $order */ + $order = $this->getInfo()->getOrder(); + $mode = $this->_scopeConfig->getValue( + 'payment/affirm_gateway/mode', + ScopeInterface::SCOPE_STORE, + $order->getStoreId() + ); + + $isSandbox = $mode === 'sandbox'; + $country = $this->getInfo()->getOrder()->getPayment()->getAdditionalInformation('country_code') ?? 'USA'; + $isCanada = $country === 'CAN'; + + $domain = $isCanada ? 'www.affirm.ca' : 'www.affirm.com'; + if ($isSandbox) { + $domain = $isCanada ? 'sandbox.affirm.ca' : 'sandbox.affirm.com'; + } + $loanId = $this->getLoanId(); - return sprintf('https://%s/dashboard/#/details/%s?trk=%s', $this->getDomainUrl(), $loanId, + return sprintf( + 'https://%s/dashboard/#/details/%s?trk=%s', + $domain, + $loanId, $this->getPublicApiKey() ); } diff --git a/view/adminhtml/templates/payment/info/edit.phtml b/view/adminhtml/templates/payment/info/edit.phtml index 4a83d9a..ecebe88 100644 --- a/view/adminhtml/templates/payment/info/edit.phtml +++ b/view/adminhtml/templates/payment/info/edit.phtml @@ -2,8 +2,7 @@ // @codingStandardsIgnoreFile /** - * @var \Magento\Payment\Block\Info $block - * @see \Magento\Payment\Block\Info + * @var \Astound\Affirm\Block\Info $block */ $specificInfo = $block->getSpecificInformation(); $title = $block->escapeHtml($block->getMethod()->getTitle());