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 14b4cb63 authored by attilak's avatar attilak Committed by Rik ter Beek

Changes based on code review

parent 99397b67
......@@ -30,12 +30,6 @@ use Magento\Payment\Gateway\Http\ClientInterface;
*/
class TransactionPayment implements ClientInterface
{
/**
* @var \Adyen\Client
*/
protected $client;
/**
* PaymentRequest constructor.
*
......@@ -59,8 +53,6 @@ class TransactionPayment implements ClientInterface
$this->_adyenLogger = $adyenLogger;
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
$this->client = $this->_adyenHelper->initializeAdyenClient();
}
/**
......@@ -72,7 +64,9 @@ class TransactionPayment implements ClientInterface
{
$request = $transferObject->getBody();
$service = new \Adyen\Service\Checkout($this->client);
$client = $this->_adyenHelper->initializeAdyenClient();
$service = new \Adyen\Service\Checkout($client);
try {
$response = $service->payments($request);
......
......@@ -1307,7 +1307,7 @@ class Data extends AbstractHelper
// initialize client
$apiKey = $this->getAPIKey($storeId);
$client = new \Adyen\Client();
$client = $this->createAdyenClient();
$client->setApplicationName("Magento 2 plugin");
$client->setXApiKey($apiKey);
......@@ -1338,6 +1338,14 @@ class Data extends AbstractHelper
return $client;
}
/**
* @return \Adyen\Client
* @throws \Adyen\AdyenException
*/
private function createAdyenClient() {
return new \Adyen\Client();
}
/**
* Retrieve origin keys for platform's base url
*
......@@ -1353,8 +1361,7 @@ class Data extends AbstractHelper
if (!$originKey = $this->cache->load("Adyen_origin_key_for_" . $domain)) {
$originKey = "";
if ($originKeys = $this->getOriginKeys($domain)) {
$originKey = $originKeys[$domain];
if ($originKey = $this->getOriginKeyForUrl($domain)) {
$this->cache->save($originKey, "Adyen_origin_key_for_" . $domain, array(), 60 * 60 * 24);
}
}
......@@ -1363,13 +1370,13 @@ class Data extends AbstractHelper
}
/**
* Get origin keys for a specific url using the adyen api library client
* Get origin key for a specific url using the adyen api library client
*
* @param $url
* @return mixed
* @throws \Adyen\AdyenException
*/
private function getOriginKeys($url)
private function getOriginKeyForUrl($url)
{
$params = array(
"originDomains" => array(
......@@ -1381,7 +1388,12 @@ class Data extends AbstractHelper
$service = $this->adyenServiceFactory->createCheckoutUtility($client);
$respone = $service->originKeys($params);
return $respone['originKeys'];
if (empty($originKey = $respone['originKeys'][$url])) {
$originKey = "";
}
return $originKey;
}
/**
......
......@@ -178,6 +178,10 @@
font-weight: 400;
}
#adyen-cc-form .fieldset > .holdername.field{
margin-bottom: 10px;
}
#adyen-cc-form .helper-text{
font-size: 11px;
color: rgb(144, 162, 189);
......
This diff is collapsed.
......@@ -30,8 +30,7 @@ define(
'Magento_Checkout/js/model/quote',
'Adyen_Payment/js/model/installments',
'mage/url',
'Adyen_Payment/js/adyen.2.0.0',
'Adyen_Payment/js/adyen.checkout'
'Adyen_Payment/js/adyen.2.0.0'
],
function ($, ko, Component, customer, creditCardData, additionalValidators, quote, installments, url) {
......
......@@ -68,29 +68,6 @@
<br/>
<!-- /ko -->
<div class="field holdername type">
<label data-bind="attr: {for: 'creditCardHolderName'}" class="label">
<span><!-- ko text: $t('Credit Card Owner')--><!-- /ko --></span>
</label>
<div class="control">
<input type="text"
class="input-text required-entry"
data-encrypted-name="holderName"
value=""
data-bind="attr: {
id: 'creditCardHolderName',
title: $t('Credit Card Owner'),
placeholder: $t('Credit Card Owner'),
'data-container': getCode() + '-cc-owner'
},
enable: isActive($parents),
value: creditCardOwner,
valueUpdate: 'keyup' "
data-validate="{required:true}"
/>
</div>
</div>
<div class="field type">
<label data-bind="attr: {for: getCode() + '_cc_type'}" class="label">
<span><!-- ko text: $t('Credit Card Type')--><!-- /ko --></span>
......@@ -120,6 +97,30 @@
">
</div>
</div>
<div class="field holdername type">
<label data-bind="attr: {for: 'creditCardHolderName'}" class="label">
<span><!-- ko text: $t('Credit Card Owner')--><!-- /ko --></span>
</label>
<div class="control">
<input type="text"
class="input-text required-entry"
data-encrypted-name="holderName"
value=""
data-bind="attr: {
id: 'creditCardHolderName',
title: $t('Credit Card Owner'),
placeholder: $t('Credit Card Owner'),
'data-container': getCode() + '-cc-owner'
},
enable: isActive($parents),
value: creditCardOwner,
valueUpdate: 'keyup' "
data-validate="{required:true}"
/>
</div>
</div>
<div class="field number cardContainerField">
<div afterRender="renderSecureFields()" data-bind="attr: { id: 'cardContainer'}" ></div>
</div>
......
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