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 38b1c397 authored by attilak's avatar attilak

Changes based on code review

parent d8991b0b
...@@ -30,12 +30,6 @@ use Magento\Payment\Gateway\Http\ClientInterface; ...@@ -30,12 +30,6 @@ use Magento\Payment\Gateway\Http\ClientInterface;
*/ */
class TransactionPayment implements ClientInterface class TransactionPayment implements ClientInterface
{ {
/**
* @var \Adyen\Client
*/
protected $client;
/** /**
* PaymentRequest constructor. * PaymentRequest constructor.
* *
...@@ -59,8 +53,6 @@ class TransactionPayment implements ClientInterface ...@@ -59,8 +53,6 @@ class TransactionPayment implements ClientInterface
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
$this->_recurringType = $recurringType; $this->_recurringType = $recurringType;
$this->_appState = $context->getAppState(); $this->_appState = $context->getAppState();
$this->client = $this->_adyenHelper->initializeAdyenClient();
} }
/** /**
...@@ -72,7 +64,9 @@ class TransactionPayment implements ClientInterface ...@@ -72,7 +64,9 @@ class TransactionPayment implements ClientInterface
{ {
$request = $transferObject->getBody(); $request = $transferObject->getBody();
$service = new \Adyen\Service\Checkout($this->client); $client = $this->_adyenHelper->initializeAdyenClient();
$service = new \Adyen\Service\Checkout($client);
try { try {
$response = $service->payments($request); $response = $service->payments($request);
......
...@@ -1175,7 +1175,7 @@ class Data extends AbstractHelper ...@@ -1175,7 +1175,7 @@ class Data extends AbstractHelper
// initialize client // initialize client
$apiKey = $this->getAPIKey($storeId); $apiKey = $this->getAPIKey($storeId);
$client = new \Adyen\Client(); $client = $this->createAdyenClient();
$client->setApplicationName("Magento 2 plugin"); $client->setApplicationName("Magento 2 plugin");
$client->setXApiKey($apiKey); $client->setXApiKey($apiKey);
...@@ -1194,6 +1194,14 @@ class Data extends AbstractHelper ...@@ -1194,6 +1194,14 @@ class Data extends AbstractHelper
return $client; return $client;
} }
/**
* @return \Adyen\Client
* @throws \Adyen\AdyenException
*/
private function createAdyenClient() {
return new \Adyen\Client();
}
/** /**
* Retrieve origin keys for platform's base url * Retrieve origin keys for platform's base url
* *
...@@ -1209,8 +1217,7 @@ class Data extends AbstractHelper ...@@ -1209,8 +1217,7 @@ class Data extends AbstractHelper
if (!$originKey = $this->cache->load("Adyen_origin_key_for_" . $domain)) { if (!$originKey = $this->cache->load("Adyen_origin_key_for_" . $domain)) {
$originKey = ""; $originKey = "";
if ($originKeys = $this->getOriginKeys($domain)) { if ($originKey = $this->getOriginKeyForUrl($domain)) {
$originKey = $originKeys[$domain];
$this->cache->save($originKey, "Adyen_origin_key_for_" . $domain, array(), 60 * 60 * 24); $this->cache->save($originKey, "Adyen_origin_key_for_" . $domain, array(), 60 * 60 * 24);
} }
} }
...@@ -1219,13 +1226,13 @@ class Data extends AbstractHelper ...@@ -1219,13 +1226,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 * @param $url
* @return mixed * @return mixed
* @throws \Adyen\AdyenException * @throws \Adyen\AdyenException
*/ */
private function getOriginKeys($url) private function getOriginKeyForUrl($url)
{ {
$params = array( $params = array(
"originDomains" => array( "originDomains" => array(
...@@ -1237,7 +1244,12 @@ class Data extends AbstractHelper ...@@ -1237,7 +1244,12 @@ class Data extends AbstractHelper
$service = $this->adyenServiceFactory->createCheckoutUtility($client); $service = $this->adyenServiceFactory->createCheckoutUtility($client);
$respone = $service->originKeys($params); $respone = $service->originKeys($params);
return $respone['originKeys'];
if (empty($originKey = $respone['originKeys'][$url])) {
$originKey = "";
}
return $originKey;
} }
/** /**
......
...@@ -174,6 +174,10 @@ ...@@ -174,6 +174,10 @@
font-weight: 400; font-weight: 400;
} }
#adyen-cc-form .fieldset > .holdername.field{
margin-bottom: 10px;
}
#adyen-cc-form .helper-text{ #adyen-cc-form .helper-text{
font-size: 11px; font-size: 11px;
color: rgb(144, 162, 189); color: rgb(144, 162, 189);
......
This diff is collapsed.
...@@ -30,8 +30,7 @@ define( ...@@ -30,8 +30,7 @@ define(
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'Adyen_Payment/js/model/installments', 'Adyen_Payment/js/model/installments',
'mage/url', 'mage/url',
'Adyen_Payment/js/adyen.2.0.0', 'Adyen_Payment/js/adyen.2.0.0'
'Adyen_Payment/js/adyen.checkout'
], ],
function ($, ko, Component, customer, creditCardData, additionalValidators, quote, installments, url) { function ($, ko, Component, customer, creditCardData, additionalValidators, quote, installments, url) {
......
...@@ -68,29 +68,6 @@ ...@@ -68,29 +68,6 @@
<br/> <br/>
<!-- /ko --> <!-- /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"> <div class="field type">
<label data-bind="attr: {for: getCode() + '_cc_type'}" class="label"> <label data-bind="attr: {for: getCode() + '_cc_type'}" class="label">
<span><!-- ko text: $t('Credit Card Type')--><!-- /ko --></span> <span><!-- ko text: $t('Credit Card Type')--><!-- /ko --></span>
...@@ -120,6 +97,30 @@ ...@@ -120,6 +97,30 @@
"> ">
</div> </div>
</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 class="field number cardContainerField">
<div afterRender="renderSecureFields()" data-bind="attr: { id: 'cardContainer'}" ></div> <div afterRender="renderSecureFields()" data-bind="attr: { id: 'cardContainer'}" ></div>
</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