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

[WIP]

works with challenge shopper
parent 5727c8d0
...@@ -60,7 +60,6 @@ class ThreeDS2ResponseValidator extends AbstractValidator ...@@ -60,7 +60,6 @@ class ThreeDS2ResponseValidator extends AbstractValidator
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg)); throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
} }
$payment->setAdditionalInformation('3ds2Active', false);
$isValid = true; $isValid = true;
$errorMessages = []; $errorMessages = [];
......
...@@ -250,7 +250,7 @@ class Requests extends AbstractHelper ...@@ -250,7 +250,7 @@ class Requests extends AbstractHelper
{ {
$request['amount'] = [ $request['amount'] = [
'currency' => $currencyCode, 'currency' => $currencyCode,
'value' =>$this->adyenHelper->formatAmount($amount, $currencyCode) 'value' => $this->adyenHelper->formatAmount($amount, $currencyCode)
]; ];
...@@ -292,6 +292,13 @@ class Requests extends AbstractHelper ...@@ -292,6 +292,13 @@ class Requests extends AbstractHelper
$request['browserInfo']['language'] = $this->adyenHelper->getCurrentLocaleCode($store); $request['browserInfo']['language'] = $this->adyenHelper->getCurrentLocaleCode($store);
$request['browserInfo']['javaEnabled'] = true; //$payment->getAdditionalInformation(AdyenCcDataAssignObserver::JAVA_ENABLED); $request['browserInfo']['javaEnabled'] = true; //$payment->getAdditionalInformation(AdyenCcDataAssignObserver::JAVA_ENABLED);
// uset browser related data from additional information
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::SCREEN_WIDTH);
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::SCREEN_HEIGHT);
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::SCREEN_COLOR_DEPTH);
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::TIMEZONE_OFFSET);
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::JAVA_ENABLED);
return $request; return $request;
} }
......
...@@ -75,10 +75,13 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface ...@@ -75,10 +75,13 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
"paymentData" => $payment->getAdditionalInformation("threeDS2PaymentData") "paymentData" => $payment->getAdditionalInformation("threeDS2PaymentData")
]; ];
// unset payment data from additional information
$payment->unsAdditionalInformation("threeDS2PaymentData");
// Depends on the component's response we send a fingerprint or the challenge result // Depends on the component's response we send a fingerprint or the challenge result
if (!empty($payload['details']['threeds2.fingerprint'])) { if (!empty($payload['details']['threeds2.fingerprint'])) {
$request['details']['threeds2.fingerprint'] = $payload['details']['threeds2.fingerprint']; $request['details']['threeds2.fingerprint'] = $payload['details']['threeds2.fingerprint'];
} elseif (!empty($payload['threeds2.challengeResult'])) { } elseif (!empty($payload['details']['threeds2.challengeResult'])) {
$request['details']['threeds2.challengeResult'] = $payload['details']['threeds2.challengeResult']; $request['details']['threeds2.challengeResult'] = $payload['details']['threeds2.challengeResult'];
} }
...@@ -94,19 +97,20 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface ...@@ -94,19 +97,20 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
// Check if result is challenge shopper, if yes return the token // Check if result is challenge shopper, if yes return the token
if (!empty($result['resultCode']) && if (!empty($result['resultCode']) &&
$result['resultCode'] === 'ChallengeShopper' && $result['resultCode'] === 'ChallengeShopper' &&
!empty(result['authentication']['threeds2.fingerprintToken']) !empty($result['authentication']['threeds2.challengeToken'])
) { ) {
return json_encode( return json_encode(
array( array(
'threeDS2' => true, 'threeDS2' => true,
'type' => 'ChallengeShopper', 'type' => $result['resultCode'],
'token' => $result['authentication']['threeds2.challengeResult'] 'token' => $result['authentication']['threeds2.challengeToken']
) )
); );
} }
// Payment can get back to the original flow // Payment can get back to the original flow
$payment->setAdditionalInformation("paymentsResponse", $result); $payment->setAdditionalInformation("paymentsResponse", $result);
$payment->setAdditionalInformation('3ds2Active', false);
$quote->save(); $quote->save();
// 3DS2 flow is done, original place order flow can continue from frontend // 3DS2 flow is done, original place order flow can continue from frontend
......
...@@ -72,6 +72,11 @@ class PaymentInformationManagement ...@@ -72,6 +72,11 @@ class PaymentInformationManagement
$quote = $this->checkoutSession->getQuote(); $quote = $this->checkoutSession->getQuote();
$payment = $quote->getPayment(); $payment = $quote->getPayment();
// in case payments response is already there we don't need to perform another payments call
if ($payment->getAdditionalInformation('paymentsResponse')) {
return true;
}
// Init request array // Init request array
$request = []; $request = [];
...@@ -132,6 +137,7 @@ class PaymentInformationManagement ...@@ -132,6 +137,7 @@ class PaymentInformationManagement
) { ) {
if ($this->threeDS2ResponseValidator->validate(array("response" => $paymentsResponse, "payment" => $payment))->isValid()) { if ($this->threeDS2ResponseValidator->validate(array("response" => $paymentsResponse, "payment" => $payment))->isValid()) {
$payment->setAdditionalInformation('3ds2Active', true);
$quote->save(); $quote->save();
return json_encode( return json_encode(
array( array(
...@@ -140,6 +146,8 @@ class PaymentInformationManagement ...@@ -140,6 +146,8 @@ class PaymentInformationManagement
"token" => $payment->getAdditionalInformation('threeDS2Token') "token" => $payment->getAdditionalInformation('threeDS2Token')
) )
); );
} else {
// TODO Handle error
} }
} else { } else {
$payment->setAdditionalInformation('paymentsResponse', $paymentsResponse); $payment->setAdditionalInformation('paymentsResponse', $paymentsResponse);
......
...@@ -61,6 +61,7 @@ define( ...@@ -61,6 +61,7 @@ define(
this.vaultEnabler.setPaymentCode(this.getVaultCode()); this.vaultEnabler.setPaymentCode(this.getVaultCode());
this.vaultEnabler.isActivePaymentTokenEnabler(false); this.vaultEnabler.isActivePaymentTokenEnabler(false);
// initialize adyen component for general use
this.checkout = new AdyenCheckout({ this.checkout = new AdyenCheckout({
locale: this.getLocale() locale: this.getLocale()
}); });
...@@ -104,7 +105,7 @@ define( ...@@ -104,7 +105,7 @@ define(
var allInstallments = self.getAllInstallments(); var allInstallments = self.getAllInstallments();
var cardNode = document.getElementById('cardContainer'); var cardNode = document.getElementById('cardContainer');
var card = 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',
...@@ -178,9 +179,7 @@ define( ...@@ -178,9 +179,7 @@ define(
installments.setInstallments(0); installments.setInstallments(0);
} }
} }
}); }).mount(cardNode);
card.mount(cardNode);
}, },
/** /**
* Rendering the 3DS2.0 components * Rendering the 3DS2.0 components
...@@ -189,17 +188,12 @@ define( ...@@ -189,17 +188,12 @@ define(
* @param token * @param token
*/ */
renderThreeDS2Component: function(type, token) { renderThreeDS2Component: function(type, token) {
console.log("ati 2");
var self = this; var self = this;
// hide card component
var cardNode = document.getElementById('cardContainer'); var cardNode = document.getElementById('cardContainer');
$(cardNode).slideUp();
var threeDS2Node = document.getElementById('threeDS2Container');
if (type == "IdentifyShopper") { if (type == "IdentifyShopper") {
var threeDS2Component = self.checkout self.threeDS2Component = self.checkout
.create('threeDS2DeviceFingerprint', { .create('threeDS2DeviceFingerprint', {
fingerprintToken: token, fingerprintToken: token,
onComplete: function(result) { onComplete: function(result) {
...@@ -211,12 +205,16 @@ define( ...@@ -211,12 +205,16 @@ define(
} }
}); });
} else if (type == "ChallengeShopper") { } else if (type == "ChallengeShopper") {
var threeDS2Component = self.checkout self.cardComponent.unmount(cardNode);
if (self.threeDS2Component) {
self.threeDS2Component.unmount(cardNode);
}
self.threeDS2Component = self.checkout
.create('threeDS2Challenge', { .create('threeDS2Challenge', {
challengeToken: token, challengeToken: token,
onComplete: function(result) { onComplete: function(result) {
console.log(result); self.processThreeDS2(result.data);
//self.processThreeDS2(result);
}, },
onError: function(result) { onError: function(result) {
// TODO error handling show error message // TODO error handling show error message
...@@ -225,7 +223,7 @@ define( ...@@ -225,7 +223,7 @@ define(
}); });
} }
threeDS2Component.mount(threeDS2Node); self.threeDS2Component.mount(cardNode);
}, },
/** /**
* *
...@@ -267,7 +265,7 @@ define( ...@@ -267,7 +265,7 @@ define(
'holderName': this.creditCardOwner(), 'holderName': this.creditCardOwner(),
'store_cc': this.setStoreCc(), 'store_cc': this.setStoreCc(),
'number_of_installments': this.installment(), 'number_of_installments': this.installment(),
'java_enabled': navigator.javaEnabled(), 'java_enabled': navigator.javaEnabled().toString(),
'screen_color_depth': screen.colorDepth, 'screen_color_depth': screen.colorDepth,
'screen_width': screen.width, 'screen_width': screen.width,
'screen_height': screen.height, 'screen_height': screen.height,
...@@ -330,6 +328,7 @@ define( ...@@ -330,6 +328,7 @@ define(
if (!!response.threeDS2) { if (!!response.threeDS2) {
// render component // render component
self.cardComponent.unmount();
self.renderThreeDS2Component(response.type, response.token); self.renderThreeDS2Component(response.type, response.token);
} else { } else {
self.getPlaceOrderDeferredObject() self.getPlaceOrderDeferredObject()
......
...@@ -77,8 +77,6 @@ ...@@ -77,8 +77,6 @@
<div afterRender="renderSecureFields()" data-bind="attr: { id: 'cardContainer'}"></div> <div afterRender="renderSecureFields()" data-bind="attr: { id: 'cardContainer'}"></div>
</div> </div>
<div id="threeDS2Container"></div>
<!-- ko if: (hasInstallments())--> <!-- ko if: (hasInstallments())-->
<div class="field required" <div class="field required"
......
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