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