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

Resolve code review comments

parent d734f023
...@@ -46,9 +46,6 @@ class CcAuthorizationDataBuilder implements BuilderInterface ...@@ -46,9 +46,6 @@ class CcAuthorizationDataBuilder implements BuilderInterface
$request = $response; $request = $response;
// Remove from additional data // Remove from additional data
$payment->unsAdditionalInformation("paymentsResponse"); $payment->unsAdditionalInformation("paymentsResponse");
// TODO check if qoupte needs to be saved or not
} else { } else {
$errorMsg = __('Error with payment method please select different payment method.'); $errorMsg = __('Error with payment method please select different payment method.');
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg)); throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
......
...@@ -58,25 +58,21 @@ class ThreeDS2ResponseValidator extends AbstractValidator ...@@ -58,25 +58,21 @@ class ThreeDS2ResponseValidator extends AbstractValidator
// validate result // validate result
if (!empty($response['resultCode'])) { if (!empty($response['resultCode'])) {
// 3DS2.0 should have IdentifyShopper or ChallengeShopper as a resultCode // 3DS2.0 should have IdentifyShopper or ChallengeShopper as a resultCode
switch ($response['resultCode']) { if ($response['resultCode'] == "IdentifyShopper" &&
case "IdentifyShopper": !empty($response['authentication']['threeds2.fingerprintToken'])
if (!empty($response['authentication']['threeds2.fingerprintToken'])) { ) {
$payment->setAdditionalInformation('threeDS2Type', $response['resultCode']); $payment->setAdditionalInformation('threeDS2Type', $response['resultCode']);
$payment->setAdditionalInformation('threeDS2Token', $response['authentication']['threeds2.fingerprintToken']); $payment->setAdditionalInformation('threeDS2Token', $response['authentication']['threeds2.fingerprintToken']);
$payment->setAdditionalInformation('threeDS2PaymentData', $response['paymentData']); $payment->setAdditionalInformation('threeDS2PaymentData', $response['paymentData']);
} } elseif ($response['resultCode'] == "ChallengeShopper" &&
break; !empty($response['authentication']['threeds2.challengeToken'])
case "ChallengeShopper": ) {
if (!empty($response['authentication']['threeds2.challengeToken'])) { $payment->setAdditionalInformation('threeDS2Type', $response['resultCode']);
$payment->setAdditionalInformation('threeDS2Type', $response['resultCode']); $payment->setAdditionalInformation('threeDS2Token', $response['authentication']['threeds2.challengeToken']);
$payment->setAdditionalInformation('threeDS2Token', $response['authentication']['threeds2.challengeToken']); $payment->setAdditionalInformation('threeDS2PaymentData', $response['paymentData']);
$payment->setAdditionalInformation('threeDS2PaymentData', $response['paymentData']); } else {
} $errorMsg = __('Error with payment method please select different payment method.');
break; throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
default:
$errorMsg = __('Error with payment method please select different payment method.');
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
break;
} }
} else { } else {
$errorMsg = __('Error with payment method please select different payment method.'); $errorMsg = __('Error with payment method please select different payment method.');
......
...@@ -364,7 +364,7 @@ class Data extends AbstractHelper ...@@ -364,7 +364,7 @@ class Data extends AbstractHelper
*/ */
public function getStreetFromString($streetLine) public function getStreetFromString($streetLine)
{ {
$street = self::formatStreet(array($streetLine)); $street = self::formatStreet([$streetLine]);
$streetName = $street['0']; $streetName = $street['0'];
unset($street['0']); unset($street['0']);
$streetNr = implode(' ', $street); $streetNr = implode(' ', $street);
...@@ -1520,7 +1520,7 @@ class Data extends AbstractHelper ...@@ -1520,7 +1520,7 @@ class Data extends AbstractHelper
if (!$originKey = $this->cache->load($cacheKey)) { if (!$originKey = $this->cache->load($cacheKey)) {
if ($originKey = $this->getOriginKeyForOrigin($origin, $storeId)) { if ($originKey = $this->getOriginKeyForOrigin($origin, $storeId)) {
$this->cache->save($originKey, $cacheKey, array(), 60 * 60 * 24); $this->cache->save($originKey, $cacheKey, [], 60 * 60 * 24);
} }
} }
...@@ -1537,11 +1537,11 @@ class Data extends AbstractHelper ...@@ -1537,11 +1537,11 @@ class Data extends AbstractHelper
*/ */
private function getOriginKeyForOrigin($origin, $storeId = null) private function getOriginKeyForOrigin($origin, $storeId = null)
{ {
$params = array( $params = [
"originDomains" => array( "originDomains" => [
$origin $origin
) ]
); ];
$client = $this->initializeAdyenClient($storeId); $client = $this->initializeAdyenClient($storeId);
...@@ -1785,18 +1785,18 @@ class Data extends AbstractHelper ...@@ -1785,18 +1785,18 @@ class Data extends AbstractHelper
public function buildThreeDS2ProcessResponseJson($type = null, $token = null) public function buildThreeDS2ProcessResponseJson($type = null, $token = null)
{ {
$response = json_encode( $response = json_encode(
array( [
'threeDS2' => false 'threeDS2' => false
) ]
); );
if ($type && $token) { if ($type && $token) {
$response = json_encode( $response = json_encode(
array( [
"threeDS2" => true, "threeDS2" => true,
"type" => $type, "type" => $type,
"token" => $token "token" => $token
) ]
); );
} }
......
...@@ -72,13 +72,12 @@ class Requests extends AbstractHelper ...@@ -72,13 +72,12 @@ class Requests extends AbstractHelper
$request['shopperReference'] = $customerId; $request['shopperReference'] = $customerId;
} }
$paymentMethod = $payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE);
if (!empty($billingAddress)) { if (!empty($billingAddress)) {
// Openinvoice and afterpayTouch methods requires different request format // Openinvoice (klarna and afterpay BUT not afterpay touch) methods requires different request format
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod( if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod) &&
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE) !$this->adyenHelper->isPaymentMethodAfterpayTouchMethod($paymentMethod)
) && !$this->adyenHelper->isPaymentMethodAfterpayTouchMethod(
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
)
) { ) {
if ($customerEmail = $billingAddress->getEmail()) { if ($customerEmail = $billingAddress->getEmail()) {
$request['paymentMethod']['personalDetails']['shopperEmail'] = $customerEmail; $request['paymentMethod']['personalDetails']['shopperEmail'] = $customerEmail;
......
...@@ -87,6 +87,13 @@ define( ...@@ -87,6 +87,13 @@ define(
return this; return this;
}, },
getInstallments: installments.getInstallments(), getInstallments: installments.getInstallments(),
/**
* Returns true if card details can be stored
* @returns {*|boolean}
*/
getEnableStoreDetails: function() {
return this.canCreateBillingAgreement() && !this.isVaultEnabled();
},
/** /**
* Renders the secure fields, * Renders the secure fields,
* creates the card component, * creates the card component,
...@@ -106,18 +113,13 @@ define( ...@@ -106,18 +113,13 @@ define(
var allInstallments = self.getAllInstallments(); var allInstallments = self.getAllInstallments();
var cardNode = document.getElementById('cardContainer'); var cardNode = document.getElementById('cardContainer');
var enableStoreDetails = false;
if (self.canCreateBillingAgreement() && !self.isVaultEnabled()) {
enableStoreDetails = true;
}
self.cardComponent = self.checkout.create('card', { self.cardComponent = self.checkout.create('card', {
originKey: self.getOriginKey(), originKey: self.getOriginKey(),
loadingContext: self.getLoadingContext(), loadingContext: self.getLoadingContext(),
type: 'card', type: 'card',
hasHolderName: true, hasHolderName: true,
holderNameRequired: true, holderNameRequired: true,
enableStoreDetails: enableStoreDetails, enableStoreDetails: self.getEnableStoreDetails(),
groupTypes: self.getAvailableCardTypeAltCodes(), groupTypes: self.getAvailableCardTypeAltCodes(),
onChange: function (state, component) { onChange: function (state, component) {
...@@ -271,9 +273,9 @@ define( ...@@ -271,9 +273,9 @@ define(
* @returns {{method: *, additional_data: {card_brand: *, cc_type: *, number: *, cvc: *, expiryMonth: *, expiryYear: *, holderName: *, store_cc: (boolean|*), number_of_installments: *, java_enabled: boolean, screen_color_depth: number, screen_width, screen_height, timezone_offset: *}}} * @returns {{method: *, additional_data: {card_brand: *, cc_type: *, number: *, cvc: *, expiryMonth: *, expiryYear: *, holderName: *, store_cc: (boolean|*), number_of_installments: *, java_enabled: boolean, screen_color_depth: number, screen_width, screen_height, timezone_offset: *}}}
*/ */
getCcData: function () { getCcData: function () {
var browserInfo = threeDS2Utils.getBrowserInfo(); const browserInfo = threeDS2Utils.getBrowserInfo();
var data = { let data = {
'method': this.item.method, 'method': this.item.method,
additional_data: { additional_data: {
'card_brand': this.variant(), 'card_brand': this.variant(),
...@@ -292,6 +294,7 @@ define( ...@@ -292,6 +294,7 @@ define(
'timezone_offset': browserInfo.timeZoneOffset 'timezone_offset': browserInfo.timeZoneOffset
} }
}; };
this.vaultEnabler.visitAdditionalData(data); this.vaultEnabler.visitAdditionalData(data);
return data; return data;
}, },
...@@ -300,10 +303,9 @@ define( ...@@ -300,10 +303,9 @@ define(
* @returns {{method: *}} * @returns {{method: *}}
*/ */
getData: function() { getData: function() {
var data = { return {
'method': this.item.method 'method': this.item.method
}; };
return data;
}, },
/** /**
* Returns state of place order button * Returns state of place order button
......
...@@ -180,7 +180,6 @@ define( ...@@ -180,7 +180,6 @@ define(
*/ */
placeOrder: function (data, event) { placeOrder: function (data, event) {
var self = this; var self = this;
console.log("placeorder");
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
......
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