We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 36ae37bf authored by Rik ter Beek's avatar Rik ter Beek Committed by Aleffio

optimize code

parent f4c67f1f
...@@ -73,6 +73,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -73,6 +73,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
$client = new \Adyen\Client(); $client = new \Adyen\Client();
$client->setApplicationName("Magento 2 plugin"); $client->setApplicationName("Magento 2 plugin");
$client->setXApiKey($apiKey); $client->setXApiKey($apiKey);
$client->setInputType('json');
//Set configurable option in M2 //Set configurable option in M2
$posTimeout = $this->_adyenHelper->getAdyenPosCloudConfigData('pos_timeout'); $posTimeout = $this->_adyenHelper->getAdyenPosCloudConfigData('pos_timeout');
...@@ -111,9 +112,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -111,9 +112,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
// if custom is logged in send data accross // if custom is logged in send data accross
$customerId = $quote->getCustomerId(); $customerId = $quote->getCustomerId();
$storeCustomer = "";
$newStructureValue = "";
// $oldValueStructure = "";
if (!empty($customerId)) { if (!empty($customerId)) {
$shopperEmail = $quote->getCustomerEmail(); $shopperEmail = $quote->getCustomerEmail();
$recurringContract = $this->_adyenHelper->getAdyenPosCloudConfigData('recurring_type'); $recurringContract = $this->_adyenHelper->getAdyenPosCloudConfigData('recurring_type');
...@@ -124,10 +123,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -124,10 +123,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
"recurringContract": "' . $recurringContract . '" "recurringContract": "' . $recurringContract . '"
}'; }';
$jsonValueBase64 = base64_encode($jsonValue); $storeCustomer = '"SaleToAcquirerData":"' . base64_encode($jsonValue) . '",';
$newStructureValue = '"SaleToAcquirerData":"' . $jsonValueBase64 . '",';
// $oldValueStructure = '"SaleToAcquirerData":"shopperEmail=' . $shopperEmail . '&shopperReference=' . $customerId . '&recurringContract=' . $recurringContract . '",';
} }
$json = '{ $json = '{
...@@ -143,7 +139,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -143,7 +139,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
}, },
"PaymentRequest": { "PaymentRequest": {
"SaleData": { "SaleData": {
' . $newStructureValue . ' ' . $storeCustomer . '
"TokenRequestedType":"Customer", "TokenRequestedType":"Customer",
"SaleTransactionID": { "SaleTransactionID": {
"TransactionID": "' . $reference . '", "TransactionID": "' . $reference . '",
...@@ -165,13 +161,11 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -165,13 +161,11 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
} }
'; ';
$params = json_decode($json, true); //Create associative array for passing along
$quote->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalInformation('serviceID', $quote->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalInformation('serviceID',
$serviceID); $serviceID);
try { try {
$response = $service->runTenderSync($params); $response = $service->runTenderSync($json);
} catch (\Adyen\AdyenException $e) { } catch (\Adyen\AdyenException $e) {
//Not able to perform a payment //Not able to perform a payment
$this->_adyenLogger->addAdyenDebug("adyenexception"); $this->_adyenLogger->addAdyenDebug("adyenexception");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment