diff --git a/Gateway/Request/AuthorizationRequest.php b/Gateway/Request/AuthorizationRequest.php
index 8b35f9e4..504a97d9 100644
--- a/Gateway/Request/AuthorizationRequest.php
+++ b/Gateway/Request/AuthorizationRequest.php
@@ -39,7 +39,6 @@ public function build(array $buildSubject)
'xExp' => sprintf('%02d%02d', $payment->getAdditionalInformation("cc_exp_month"), substr($payment->getAdditionalInformation("cc_exp_year"), -2)),
'xCVV' => $payment->getAdditionalInformation("xCVV"),
'xCommand' => 'cc:authonly',
-// 'xToken' => $payment->getAdditionalInformation("xToken"),
'xInvoice' => $order->getOrderIncrementId(),
'xCurrency' => $order->getCurrencyCode(),
'xCardNum' => $payment->getAdditionalInformation("xCardNum"),
diff --git a/Gateway/Request/BaseRequest.php b/Gateway/Request/BaseRequest.php
index 1ba93ec2..05e94548 100644
--- a/Gateway/Request/BaseRequest.php
+++ b/Gateway/Request/BaseRequest.php
@@ -53,11 +53,10 @@ public function build(array $buildSubject)
$order = $paymentDO->getOrder();
-// $this->productMetadata->getEdition();
return [
'xVersion' => '4.5.8',
'xSoftwareName' => 'Magento ' . $this->productMetadata->getEdition() . " ". $this->productMetadata->getVersion(),
- 'xSoftwareVersion' => '1.0.7',
+ 'xSoftwareVersion' => '1.0.8',
'xKey' => $this->config->getValue(
'cardknox_transaction_key',
$order->getStoreId()
diff --git a/Gateway/Response/VaultHandler.php b/Gateway/Response/VaultHandler.php
index 5109579e..35943ed3 100644
--- a/Gateway/Response/VaultHandler.php
+++ b/Gateway/Response/VaultHandler.php
@@ -15,6 +15,7 @@
//use Magento\Vault\Model\CreditCardTokenFactory;
use Magento\Payment\Model\InfoInterface;
use CardknoxDevelopment\Cardknox\Gateway\Config\Config;
+use Magento\Payment\Model\Method\Logger;
class VaultHandler implements HandlerInterface
{
@@ -26,7 +27,7 @@ class VaultHandler implements HandlerInterface
/**
* @var CreditCardTokenFactory
*/
-// protected $creditCardTokenFactory;
+ // protected $creditCardTokenFactory;
protected $paymentTokenFactory;
/**
@@ -35,6 +36,16 @@ class VaultHandler implements HandlerInterface
protected $paymentExtensionFactory;
protected $config;
+
+ /**
+ * @var Logger
+ */
+ private $logger;
+
+ /**
+ * @param Logger $logger
+ */
+
/**
* Constructor
*
@@ -44,11 +55,13 @@ class VaultHandler implements HandlerInterface
public function __construct(
PaymentTokenInterfaceFactory $paymentTokenFactory,
OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory,
- Config $config
+ Config $config,
+ Logger $logger
) {
$this->paymentTokenFactory = $paymentTokenFactory;
$this->paymentExtensionFactory = $paymentExtensionFactory;
$this->config = $config;
+ $this->logger = $logger;
}
/**
@@ -60,7 +73,8 @@ public function __construct(
*/
public function handle(array $handlingSubject, array $response)
{
- if (!isset($handlingSubject['payment'])
+ if (
+ !isset($handlingSubject['payment'])
|| !$handlingSubject['payment'] instanceof PaymentDataObjectInterface
) {
throw new \InvalidArgumentException('Payment data object should be provided');
@@ -71,6 +85,12 @@ public function handle(array $handlingSubject, array $response)
$payment = $paymentDO->getPayment();
+ if ($payment->getAdditionalInformation("is_active_payment_token_enabler") == "") {
+ return;
+ }
+
+ $log['VaultHandler save card'] = true;
+
$xExp = "";
if (isset($response[$this::xExp])) {
$xExp = $response[$this::xExp];
@@ -86,6 +106,8 @@ public function handle(array $handlingSubject, array $response)
$extensionAttributes->setVaultPaymentToken($paymentToken);
}
}
+
+ $this->logger->debug($log);
}
/**
@@ -97,7 +119,7 @@ public function handle(array $handlingSubject, array $response)
private function getVaultPaymentToken(array $response, string $xExp)
{
// Check token existing in gateway response
- if (isset($response[$this::xToken])){
+ if (isset($response[$this::xToken])) {
$token = $response[$this::xToken];
if (empty($token)) {
return null;
@@ -106,7 +128,6 @@ private function getVaultPaymentToken(array $response, string $xExp)
return null;
}
-
/** @var PaymentTokenInterface $paymentToken */
$paymentToken = $this->paymentTokenFactory->create();
$paymentToken->setGatewayToken($token);
@@ -128,15 +149,14 @@ private function getExpirationDate(string $xExp)
{
$expDate = new \DateTime(
'20' . substr($xExp, -2)
- . '-'
- . substr($xExp, 0, 2)
- . '-'
- . '01'
- . ' '
- . '00:00:00',
+ . '-'
+ . substr($xExp, 0, 2)
+ . '-'
+ . '01'
+ . ' '
+ . '00:00:00',
new \DateTimeZone('UTC')
);
-// $expDate->add(new \DateInterval('P1M'));
return $expDate->format('Y-m-d 00:00:00');
}
/**
@@ -158,7 +178,6 @@ private function convertDetailsToJSON($details)
*/
private function getCreditCardType($type)
{
-// $replaced = str_replace(' ', '-', strtolower($type));
$mapper = $this->config->getCctypesMapper();
return $mapper[$type];
}
diff --git a/Observer/DataAssignObserver.php b/Observer/DataAssignObserver.php
index 28ad5470..506b2d0c 100644
--- a/Observer/DataAssignObserver.php
+++ b/Observer/DataAssignObserver.php
@@ -32,8 +32,8 @@ class DataAssignObserver extends AbstractDataAssignObserver
self::xCardNum,
self::xCVV,
self::cc_exp_month,
- self::cc_exp_year
-
+ self::cc_exp_year,
+ "is_active_payment_token_enabler"
];
public function execute(Observer $observer)
diff --git a/composer.json b/composer.json
index 2d48831b..4f9d98ca 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "cardknox/cardknox",
"description": "Cardknox integration for Magento 2",
"type": "magento2-module",
- "version": "1.0.7",
+ "version": "1.0.8",
"license": [
"GPL-3.0"
],
diff --git a/etc/di.xml b/etc/di.xml
index f6d8ca0e..c43d22b7 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -115,6 +115,12 @@
+
+
+ CardknoxLogger
+
+
+