diff --git a/Block/Adminhtml/Order/View/View.php b/Block/Adminhtml/Order/View/View.php
index 78340e3b..a25f74d6 100644
--- a/Block/Adminhtml/Order/View/View.php
+++ b/Block/Adminhtml/Order/View/View.php
@@ -17,7 +17,10 @@
namespace CheckoutCom\Magento2\Block\Adminhtml\Order\View;
+use CheckoutCom\Magento2\Gateway\Config\Loader;
use CheckoutCom\Magento2\Helper\Utilities;
+use CheckoutCom\Magento2\Model\Config\Backend\Source\ConfigAlternativePayments;
+use CheckoutCom\Magento2\Model\Methods\AlternativePaymentMethod;
use Magento\Backend\Block\Template;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\App\Request\Http;
@@ -27,37 +30,19 @@
class View extends Template
{
- /**
- * $utilities field
- *
- * @var Utilities $utilities
- */
- private $utilities;
- /**
- * $request field
- *
- * @var Http $request
- */
- private $request;
- /**
- * $orderRepository field
- *
- * @var OrderRepositoryInterface $orderRepository
- */
- private $orderRepository;
-
- /**
- * @param Context $context
- * @param Utilities $utilities
- * @param Http $request
- * @param OrderRepositoryInterface $orderRepository
- * @param array $data
- */
+ private Utilities $utilities;
+ private Http $request;
+ private OrderRepositoryInterface $orderRepository;
+ private ConfigAlternativePayments $configAlternativePayments;
+ private Loader $configLoader;
+
public function __construct(
Context $context,
Utilities $utilities,
Http $request,
OrderRepositoryInterface $orderRepository,
+ ConfigAlternativePayments $configAlternativePayments,
+ Loader $configLoader,
array $data = []
) {
parent::__construct($context, $data);
@@ -65,14 +50,10 @@ public function __construct(
$this->utilities = $utilities;
$this->request = $request;
$this->orderRepository = $orderRepository;
+ $this->configAlternativePayments = $configAlternativePayments;
+ $this->configLoader = $configLoader;
}
- /**
- * @param string $data
- *
- * @return string|null
- * @throws LocalizedException
- */
public function getCkoPaymentData(string $data): ?string
{
$paymentData = $this->utilities->getPaymentData($this->getOrder(), 'cko_payment_information')['source'] ?? [];
@@ -83,12 +64,6 @@ public function getCkoPaymentData(string $data): ?string
return null;
}
- /**
- * @param string $data
- *
- * @return string|null
- * @throws LocalizedException
- */
public function getCko3dsPaymentData(string $data): ?string
{
$paymentData = $this->utilities->getPaymentData($this->getOrder(), 'cko_threeDs')['threeDs'] ?? [];
@@ -99,21 +74,11 @@ public function getCko3dsPaymentData(string $data): ?string
return null;
}
- /**
- * Get order
- *
- * @return OrderInterface $order
- */
private function getOrder(): OrderInterface
{
return $this->orderRepository->get($this->request->getParam('order_id'));
}
- /**
- * @param string $avsCheckCode
- *
- * @return string
- */
public function getAvsCheckDescription(string $avsCheckCode): string
{
switch ($avsCheckCode) {
@@ -163,11 +128,6 @@ public function getAvsCheckDescription(string $avsCheckCode): string
}
}
- /**
- * @param string $cvvCheckCode
- *
- * @return string
- */
public function getCvvCheckDescription(string $cvvCheckCode): string
{
switch ($cvvCheckCode) {
@@ -188,11 +148,6 @@ public function getCvvCheckDescription(string $cvvCheckCode): string
}
}
- /**
- * @param string $threeDsCode
- *
- * @return string
- */
public function get3dsDescription(string $threeDsCode): string
{
switch ($threeDsCode) {
@@ -216,4 +171,15 @@ public function get3dsDescription(string $threeDsCode): string
return '';
}
}
+
+ public function getAlternativePaymentMethodName(): string
+ {
+ $methodId = $this->getOrder()->getPayment()->getAdditionalInformation()['method_id'] ?? '';
+ return $methodId ?? $this->configLoader->getApmLabel($methodId)[$methodId];
+ }
+
+ public function getAlternativePaymentMethodTransactionInfo(): string
+ {
+ return $this->getOrder()->getPayment()->getAdditionalInformation()['transaction_info']['id'] ?? '';
+ }
}
diff --git a/Block/Cart/ApplePay.php b/Block/Cart/ApplePay.php
index c8ac27fa..8b1ea55d 100644
--- a/Block/Cart/ApplePay.php
+++ b/Block/Cart/ApplePay.php
@@ -19,33 +19,33 @@
namespace CheckoutCom\Magento2\Block\Cart;
+use CheckoutCom\Magento2\Gateway\Config\Config;
+use CheckoutCom\Magento2\Model\Ui\ConfigProvider;
use Magento\Checkout\Block\Onepage;
use Magento\Checkout\Model\Cart;
use Magento\Checkout\Model\CompositeConfigProvider;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\Data\Form\FormKey;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Serialize\Serializer\Json;
+use Magento\Framework\Serialize\Serializer\JsonHexTag;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Framework\View\Element\Template\Context;
class ApplePay extends Onepage
{
- protected Cart $cart;
+ private Cart $cart;
+ private ConfigProvider $checkoutComConfigProvider;
+ private SerializerInterface $serializer;
- /**
- * @param Cart $cart
- * @param Context $context
- * @param FormKey $formKey
- * @param CompositeConfigProvider $configProvider
- * @param array $layoutProcessors
- * @param array $data
- * @param Json|null $serializer
- * @param SerializerInterface|null $serializerInterface
- */
public function __construct(
Cart $cart,
Context $context,
FormKey $formKey,
CompositeConfigProvider $configProvider,
+ Config $checkoutComConfig,
+ ConfigProvider $checkoutComConfigProvider,
array $layoutProcessors = [],
array $data = [],
Json $serializer = null,
@@ -61,12 +61,11 @@ public function __construct(
$serializerInterface
);
$this->cart = $cart;
+ $this->checkoutComConfigProvider = $checkoutComConfigProvider;
+ $this->serializer = $serializerInterface ?: ObjectManager::getInstance()
+ ->get(JsonHexTag::class);
}
- /**
- *
- * @return int
- */
public function getProductCount(): int
{
$productCount = 0;
@@ -76,4 +75,15 @@ public function getProductCount(): int
return $productCount;
}
+
+ /**
+ * @throws NoSuchEntityException
+ * @throws LocalizedException
+ */
+ public function getSerializedCheckoutComConfig(): string
+ {
+ $config = $this->checkoutComConfigProvider->getConfig();
+
+ return $this->serializer->serialize($config);
+ }
}
diff --git a/Gateway/Config/Loader.php b/Gateway/Config/Loader.php
index c640d25b..457d6af9 100755
--- a/Gateway/Config/Loader.php
+++ b/Gateway/Config/Loader.php
@@ -145,6 +145,21 @@ public function loadApmList(): array
return $output;
}
+ public function getApmLabel(string $value = ''): array
+ {
+ /** @var array $apmXmlData */
+ $apmXmlData = $this->loadApmXmlData();
+
+ foreach ($apmXmlData as $row) {
+ if ($value === $row['id']) {
+ return [$row['id'] => $row['title']];
+ }
+ $output[$row['id']] = $row['title'];
+ }
+
+ return $output;
+ }
+
/**
* Finds a file path from file name.
*
diff --git a/Model/Vault/VaultToken.php b/Model/Vault/VaultToken.php
index 6a6022a5..f5f829d9 100755
--- a/Model/Vault/VaultToken.php
+++ b/Model/Vault/VaultToken.php
@@ -25,9 +25,9 @@
use DateTimeZone;
use Exception;
use Magento\Framework\Encryption\EncryptorInterface;
+use Magento\Framework\Serialize\Serializer\Json as JsonSerializer;
use Magento\Vault\Api\Data\PaymentTokenFactoryInterface;
use Magento\Vault\Api\Data\PaymentTokenInterface;
-use Zend_Json;
/**
* Class VaultToken
@@ -52,22 +52,31 @@ class VaultToken
* @var CardHandlerService $cardHandler
*/
private $cardHandler;
+ /**
+ * $json field
+ *
+ * @var JsonSerializer
+ */
+ private $json;
/**
* VaultToken constructor
*
* @param PaymentTokenFactoryInterface $paymentTokenFactory
- * @param EncryptorInterface $encryptor
- * @param CardHandlerService $cardHandler
+ * @param EncryptorInterface $encryptor
+ * @param CardHandlerService $cardHandler
+ * @param JsonSerializer $json
*/
public function __construct(
PaymentTokenFactoryInterface $paymentTokenFactory,
EncryptorInterface $encryptor,
- CardHandlerService $cardHandler
+ CardHandlerService $cardHandler,
+ JsonSerializer $json
) {
$this->paymentTokenFactory = $paymentTokenFactory;
- $this->encryptor = $encryptor;
- $this->cardHandler = $cardHandler;
+ $this->encryptor = $encryptor;
+ $this->cardHandler = $cardHandler;
+ $this->json = $json;
}
/**
@@ -165,7 +174,7 @@ private function generatePublicHash(PaymentTokenInterface $paymentToken): string
*/
private function convertDetailsToJSON(array $details): string
{
- $json = Zend_Json::encode($details);
+ $json = $this->json->serialize($details);
return $json ?: '{}';
}
diff --git a/Plugin/AddConfigDataToCart.php b/Plugin/AddConfigDataToCart.php
new file mode 100644
index 00000000..ba75c840
--- /dev/null
+++ b/Plugin/AddConfigDataToCart.php
@@ -0,0 +1,30 @@
+config = $config;
+ $this->compositeConfigProvider = $compositeConfigProvider;
+ }
+
+ public function afterGetSectionData(Cart $subject, array $result): array
+ {
+ $configProvider = ['checkoutConfigProvider' => $this->compositeConfigProvider->getConfig()];
+
+ return array_merge($this->config->getMethodsConfig(), $configProvider, $result);
+ }
+}
diff --git a/composer.json b/composer.json
index b2100d2b..1a847bed 100755
--- a/composer.json
+++ b/composer.json
@@ -7,7 +7,7 @@
"magento/framework": ">=100.0.1"
},
"type": "magento2-module",
- "version": "5.0.0",
+ "version": "5.1.0",
"autoload": {
"files": [
"registration.php"
diff --git a/etc/apm.xml b/etc/apm.xml
index a536866c..9e235be0 100755
--- a/etc/apm.xml
+++ b/etc/apm.xml
@@ -70,9 +70,9 @@
= $block->escapeHtml(__('Alternative payment method')) ?> | += $alternativePaymentMethodName ?> | +||
---|---|---|---|
= $block->escapeHtml(__('Transaction Id')) ?> | += $alternativePaymentMethodTransactionInfo ?> | +||
= $block->escapeHtml(__('Card type')) ?> | = $block->getCkoPaymentData('scheme') ?> (= $block->getCkoPaymentData('product_type') ?>) | @@ -32,36 +49,38 @@ $threeDsVersion = $block->getCko3dsPaymentData('version');= $block->escapeHtml(__('Card Country')) ?> | = $block->getCkoPaymentData('issuer_country') ?> |
= $block->escapeHtml(__('Issuing Bank')) ?> | = $issuer ?> | ||
= $block->escapeHtml(__('AVS Check')) ?> | = $avsCheck ?> (= $block->getAvsCheckDescription($avsCheck) ?>) | ||
= $block->escapeHtml(__('CVV Check')) ?> | = $cvvCheck ?> (= $block->getCvvCheckDescription($cvvCheck) ?>) | ||
= $block->escapeHtml(__('3DS authorization code')) ?> | = $threeDsCode ?> (= $block->get3dsDescription($threeDsCode) ?>) | ||
= $block->escapeHtml(__('3DS version')) ?> | = $threeDsVersion ?> |