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 ae4a6d04 authored by Rik ter Beek's avatar Rik ter Beek

fix based on the PR comments + fixed backend order layout css

parent ad418cf9
...@@ -126,14 +126,9 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface ...@@ -126,14 +126,9 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface
*/ */
public function getText() public function getText()
{ {
$message = ''; return 'Please provide API-KEY for the webservice user ' .
if (!empty($this->adyenHelper->getWsUsername())) { $this->adyenHelper->getWsUsername() . ' for default/store ' .
$message = 'Please provide API-KEY for the webservice user ' . $this->storeManagerInterface->getStore()->getName();
$this->adyenHelper->getWsUsername() . ' for default/store ' .
$this->storeManagerInterface->getStore()->getName();
}
return $message;
} }
/** /**
......
...@@ -45,16 +45,15 @@ class Cc extends \Magento\Payment\Block\Form\Cc ...@@ -45,16 +45,15 @@ class Cc extends \Magento\Payment\Block\Form\Cc
*/ */
protected $checkoutSession; protected $checkoutSession;
/** /**
* Cc constructor. * Cc constructor.
* *
* @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Payment\Model\Config $paymentConfig * @param \Magento\Payment\Model\Config $paymentConfig
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger * @param array $data
* @param array $data */
*/
public function __construct( public function __construct(
\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\View\Element\Template\Context $context,
\Magento\Payment\Model\Config $paymentConfig, \Magento\Payment\Model\Config $paymentConfig,
......
...@@ -30,47 +30,42 @@ use Magento\Payment\Gateway\Http\ClientInterface; ...@@ -30,47 +30,42 @@ use Magento\Payment\Gateway\Http\ClientInterface;
*/ */
class TransactionPayment implements ClientInterface class TransactionPayment implements ClientInterface
{ {
/**
* PaymentRequest constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\RecurringType $recurringType
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\RecurringType $recurringType,
array $data = []
) {
$this->_encryptor = $encryptor;
$this->_adyenHelper = $adyenHelper;
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
}
/** /**
* @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject * @var \Adyen\Payment\Helper\Data
* @return mixed */
* @throws ClientException private $adyenHelper;
*/
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{
$request = $transferObject->getBody();
$client = $this->_adyenHelper->initializeAdyenClient();
$service = new \Adyen\Service\Checkout($client); /**
* TransactionPayment constructor.
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
) {
$this->adyenHelper = $adyenHelper;
}
try { /**
$response = $service->payments($request); * @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject
} catch(\Adyen\AdyenException $e) { * @return mixed
$response['error'] = $e->getMessage(); * @throws ClientException
} */
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{
$request = $transferObject->getBody();
return $response; $client = $this->adyenHelper->initializeAdyenClient();
}
$service = new \Adyen\Service\Checkout($client);
try {
$response = $service->payments($request);
} catch (\Adyen\AdyenException $e) {
$response['error'] = $e->getMessage();
}
return $response;
}
} }
...@@ -67,8 +67,8 @@ class CcAuthorizationDataBuilder implements BuilderInterface ...@@ -67,8 +67,8 @@ class CcAuthorizationDataBuilder implements BuilderInterface
// If ccType is set use this. For bcmc you need bcmc otherwise it will fail // If ccType is set use this. For bcmc you need bcmc otherwise it will fail
$request['paymentMethod']['type'] = "scheme"; $request['paymentMethod']['type'] = "scheme";
if ($payment->getAdditionalInformation(AdyenCcDataAssignObserver::VARIANT)) { if ($variant = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::VARIANT)) {
$request['paymentMethod']['type'] = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::VARIANT); $request['paymentMethod']['type'] = $variant;
} }
if ($cardNumber = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::CREDIT_CARD_NUMBER)) { if ($cardNumber = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::CREDIT_CARD_NUMBER)) {
......
...@@ -28,50 +28,50 @@ use Magento\Payment\Gateway\Response\HandlerInterface; ...@@ -28,50 +28,50 @@ use Magento\Payment\Gateway\Response\HandlerInterface;
class CheckoutPaymentCommentHistoryHandler implements HandlerInterface class CheckoutPaymentCommentHistoryHandler implements HandlerInterface
{ {
/** /**
* @param array $handlingSubject * @param array $handlingSubject
* @param array $response * @param array $response
* @return $this * @return $this
*/ */
public function handle(array $handlingSubject, array $response) public function handle(array $handlingSubject, array $response)
{ {
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject); $payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
/** @var OrderPaymentInterface $payment */ /** @var OrderPaymentInterface $payment */
$payment = $payment->getPayment(); $payment = $payment->getPayment();
$commentText = "Adyen Result response:"; $commentText = "Adyen Result response:";
if (isset($response['resultCode'])) { if (isset($response['resultCode'])) {
$responseCode = $response['resultCode']; $responseCode = $response['resultCode'];
} else { } else {
// try to get response from response key (used for modifications // try to get response from response key (used for modifications
if (isset($response['response'])) { if (isset($response['response'])) {
$responseCode = $response['response']; $responseCode = $response['response'];
} else { } else {
$responseCode = ""; $responseCode = "";
} }
} }
if (isset($response['pspReference'])) { if (isset($response['pspReference'])) {
$pspReference = $response['pspReference']; $pspReference = $response['pspReference'];
} else { } else {
$pspReference = ""; $pspReference = "";
} }
if ($responseCode) { if ($responseCode) {
$commentText .= '<br /> authResult: ' . $responseCode; $commentText .= '<br /> authResult: ' . $responseCode;
$payment->getOrder()->setAdyenResulturlEventCode($responseCode); $payment->getOrder()->setAdyenResulturlEventCode($responseCode);
} }
if ($pspReference) { if ($pspReference) {
$commentText .= '<br /> authResult: ' . $pspReference; $commentText .= '<br /> pspReference: ' . $pspReference;
} }
$comment = __($commentText); $comment = __($commentText);
$payment->getOrder()->addStatusHistoryComment($comment); $payment->getOrder()->addStatusHistoryComment($comment);
return $this; return $this;
} }
} }
...@@ -44,28 +44,22 @@ echo $code; ?>" style="display:none"> ...@@ -44,28 +44,22 @@ echo $code; ?>" style="display:none">
title="<?php echo $block->escapeHtml(__('Name on Card')); ?>" class="admin__control-text" title="<?php echo $block->escapeHtml(__('Name on Card')); ?>" class="admin__control-text"
value="<?php /* @noEscape */ value="<?php /* @noEscape */
echo $block->getInfoData('cc_owner'); ?>" echo $block->getInfoData('cc_owner'); ?>"
placeholder="<?php echo $block->escapeHtml(__('Name on Card')); ?>"/> placeholder="<?php echo $block->escapeHtml(__('Name on Card')); ?>"/>
</div> </div>
</div> </div>
<div> <div id="cardContainer-<?php /* @noEscape */
<div>Available card types:</div> echo $code; ?>"></div>
<div> <input id="<?php /* @noEscape */
<?php foreach ($block->getCcAvailableTypes() as $typeCode => $typeName): ?> echo $code; ?>-number" type="hidden" name="payment[number]">
<span class="cc-type-<?php echo $block->escapeHtml($typeCode); ?>"> <input id="<?php /* @noEscape */
<?php echo $block->escapeHtml($typeName); ?> echo $code; ?>-cvc" type="hidden" name="payment[cvc]">
</span> <input id="<?php /* @noEscape */
<?php endforeach ?> echo $code; ?>-expiryMonth" type="hidden" name="payment[expiryMonth]">
</div> <input id="<?php /* @noEscape */
<p class="helper-text" id="cc-type-helper-text"><?php echo $block->escapeHtml(__('(Please provide a card with the type from the list above)')); ?></p> echo $code; ?>-expiryYear" type="hidden" name="payment[expiryYear]">
</div> <input id="<?php /* @noEscape */
echo $code; ?>-cc_type" type="hidden" name="payment[cc_type]">
<div id="cardContainer-<?php /* @noEscape */ echo $code; ?>"></div>
<input id="<?php /* @noEscape */ echo $code; ?>-number" type="hidden" name="payment[number]">
<input id="<?php /* @noEscape */ echo $code; ?>-cvc" type="hidden" name="payment[cvc]">
<input id="<?php /* @noEscape */ echo $code; ?>-expiryMonth" type="hidden" name="payment[expiryMonth]">
<input id="<?php /* @noEscape */ echo $code; ?>-expiryYear" type="hidden" name="payment[expiryYear]">
<input id="<?php /* @noEscape */ echo $code; ?>-cc_type" type="hidden" name="payment[cc_type]">
<script> <script>
require( require(
...@@ -86,9 +80,9 @@ echo $code; ?>" style="display:none"> ...@@ -86,9 +80,9 @@ echo $code; ?>" style="display:none">
document.body.appendChild(scriptTag); document.body.appendChild(scriptTag);
// Get cc type by adyen cc type // Get cc type by adyen cc type
var getCcCodeByAltCode = function(altCode) { var getCcCodeByAltCode = function (altCode) {
if (ccTypes.hasOwnProperty(altCode)) { if (ccTypes.hasOwnProperty(altCode)) {
return ccTypes[altCode]; return ccTypes[altCode];
} }
...@@ -114,14 +108,7 @@ echo $code; ?>" style="display:none"> ...@@ -114,14 +108,7 @@ echo $code; ?>" style="display:none">
type: 'card', type: 'card',
groupTypes: ccTypes, groupTypes: ccTypes,
onChange: function(state) { onChange: function (state) {
if (state.isCardValid) {
jQuery("#cc-type-helper-text").hide();
} else {
jQuery("#cc-type-helper-text").show();
}
// When the state is valid update the input fields // When the state is valid update the input fields
if (state.isValid) { if (state.isValid) {
// Here we enable the button if the component is now valid // Here we enable the button if the component is now valid
...@@ -132,38 +119,28 @@ echo $code; ?>" style="display:none"> ...@@ -132,38 +119,28 @@ echo $code; ?>" style="display:none">
jQuery("#<?php /* @noEscape */ echo $code; ?>-cc_type").val(getCcCodeByAltCode(state.brand)); jQuery("#<?php /* @noEscape */ echo $code; ?>-cc_type").val(getCcCodeByAltCode(state.brand));
} }
}, },
onError: function() {} onError: function () {
}
}); });
card.mount(cardNode); card.mount(cardNode);
/*order.submit = order.submit.wrap(function (originalSaveMethod) {
attachSecureFieldsData.call(this);
originalSaveMethod();
});*/
} }
// Load card components and force wait until the external script is loaded // Load card components and force wait until the external script is loaded
if (scriptTag.readyState) { if (scriptTag.readyState) {
scriptTag.onreadystatechange = function(){ scriptTag.onreadystatechange = function () {
if (script.readyState == "loaded" || if (script.readyState == "loaded" ||
script.readyState == "complete"){ script.readyState == "complete") {
script.onreadystatechange = null; script.onreadystatechange = null;
secureFieldsInitialize(); secureFieldsInitialize();
} }
}; };
} }
else { else {
scriptTag.onload = function(){ scriptTag.onload = function () {
secureFieldsInitialize(); secureFieldsInitialize();
}; };
} }
//]]> //]]>
}); });
// TODO Oneclick
// cvc is not required so cvchide: true or hidecvc
</script> </script>
</fieldset> </fieldset>
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