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

[WIP]

fix bug placing the order after a refused one won't go through the
3ds2.0 flow
remove store card details from magento and use the component rendered
one
parent 6ed050b3
...@@ -110,7 +110,7 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface ...@@ -110,7 +110,7 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
// 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); $payment->setAdditionalInformation('placeOrder', true);
$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
......
...@@ -73,7 +73,10 @@ class PaymentInformationManagement ...@@ -73,7 +73,10 @@ class PaymentInformationManagement
$payment = $quote->getPayment(); $payment = $quote->getPayment();
// in case payments response is already there we don't need to perform another payments call // in case payments response is already there we don't need to perform another payments call
if ($payment->getAdditionalInformation('paymentsResponse')) { // we indicate it with the placeOrder additionalInformation
if ($payment->getAdditionalInformation('placeOrder')) {
$payment->unsAdditionalInformation('placeOrder');
$quote->save();
return true; return true;
} }
...@@ -137,7 +140,6 @@ class PaymentInformationManagement ...@@ -137,7 +140,6 @@ 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(
...@@ -154,6 +156,8 @@ class PaymentInformationManagement ...@@ -154,6 +156,8 @@ class PaymentInformationManagement
$quote->save(); $quote->save();
} }
$payment->setAdditionalInformation('placeOrder', true);
$quote->save();
// Original flow can continue, return to frontend and place the order // Original flow can continue, return to frontend and place the order
return json_encode( return json_encode(
array( array(
......
...@@ -77,7 +77,6 @@ define( ...@@ -77,7 +77,6 @@ define(
'securityCode', 'securityCode',
'expiryMonth', 'expiryMonth',
'expiryYear', 'expiryYear',
'setStoreCc',
'installment', 'installment',
'creditCardDetailsValid', 'creditCardDetailsValid',
'variant', 'variant',
...@@ -95,6 +94,7 @@ define( ...@@ -95,6 +94,7 @@ define(
*/ */
renderSecureFields: function () { renderSecureFields: function () {
var self = this; var self = this;
if (!self.getOriginKey()) { if (!self.getOriginKey()) {
return; return;
} }
...@@ -105,16 +105,23 @@ define( ...@@ -105,16 +105,23 @@ 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,
groupTypes: self.getAvailableCardTypeAltCodes(), groupTypes: self.getAvailableCardTypeAltCodes(),
onChange: function (state, component) { onChange: function (state, component) {
if (!!state.isValid && !component.state.errors.encryptedSecurityCode) { if (!!state.isValid && !component.state.errors.encryptedSecurityCode) {
self.setStoreCc = !!state.data.storeDetails;
self.variant(state.brand); self.variant(state.brand);
self.creditCardNumber(state.data.encryptedCardNumber); self.creditCardNumber(state.data.encryptedCardNumber);
self.expiryMonth(state.data.encryptedExpiryMonth); self.expiryMonth(state.data.encryptedExpiryMonth);
...@@ -190,7 +197,7 @@ define( ...@@ -190,7 +197,7 @@ define(
renderThreeDS2Component: function(type, token) { renderThreeDS2Component: function(type, token) {
var self = this; var self = this;
var cardNode = document.getElementById('cardContainer'); var threeDS2Node = document.getElementById('threeDS2Container');
if (type == "IdentifyShopper") { if (type == "IdentifyShopper") {
self.threeDS2Component = self.checkout self.threeDS2Component = self.checkout
...@@ -198,6 +205,7 @@ define( ...@@ -198,6 +205,7 @@ define(
fingerprintToken: token, fingerprintToken: token,
onComplete: function(result) { onComplete: function(result) {
self.processThreeDS2(result.data); self.processThreeDS2(result.data);
$('#modal_content').modal("closeModal");
}, },
onError: function(result) { onError: function(result) {
// TODO error handling show error message // TODO error handling show error message
...@@ -205,7 +213,7 @@ define( ...@@ -205,7 +213,7 @@ define(
} }
}); });
} else if (type == "ChallengeShopper") { } else if (type == "ChallengeShopper") {
self.cardComponent.unmount(cardNode); self.threeDS2Component.unmount(threeDS2Node);
if (self.threeDS2Component) { if (self.threeDS2Component) {
self.threeDS2Component.unmount(cardNode); self.threeDS2Component.unmount(cardNode);
} }
...@@ -215,6 +223,7 @@ define( ...@@ -215,6 +223,7 @@ define(
challengeToken: token, challengeToken: token,
onComplete: function(result) { onComplete: function(result) {
self.processThreeDS2(result.data); self.processThreeDS2(result.data);
$('#modal_content').modal("closeModal");
}, },
onError: function(result) { onError: function(result) {
// TODO error handling show error message // TODO error handling show error message
...@@ -223,7 +232,7 @@ define( ...@@ -223,7 +232,7 @@ define(
}); });
} }
self.threeDS2Component.mount(cardNode); self.threeDS2Component.mount(threeDS2Node);
}, },
/** /**
* *
...@@ -232,6 +241,8 @@ define( ...@@ -232,6 +241,8 @@ define(
processThreeDS2: function(data) { processThreeDS2: function(data) {
var self = this; var self = this;
fullScreenLoader.startLoader();
var payload = { var payload = {
"payload": JSON.stringify(data) "payload": JSON.stringify(data)
}; };
...@@ -263,7 +274,7 @@ define( ...@@ -263,7 +274,7 @@ define(
'expiryMonth': this.expiryMonth(), 'expiryMonth': this.expiryMonth(),
'expiryYear': this.expiryYear(), 'expiryYear': this.expiryYear(),
'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().toString(), 'java_enabled': navigator.javaEnabled().toString(),
'screen_color_depth': screen.colorDepth, 'screen_color_depth': screen.colorDepth,
...@@ -327,8 +338,17 @@ define( ...@@ -327,8 +338,17 @@ define(
var response = JSON.parse(responseJSON); var response = JSON.parse(responseJSON);
if (!!response.threeDS2) { if (!!response.threeDS2) {
$('#modal_content').modal({
// disable user to hide popup
clickableOverlay: false,
// empty buttons, we don't need that
buttons: []
});
$('#modal_content').modal("openModal");
// 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,6 +77,10 @@ ...@@ -77,6 +77,10 @@
<div afterRender="renderSecureFields()" data-bind="attr: { id: 'cardContainer'}"></div> <div afterRender="renderSecureFields()" data-bind="attr: { id: 'cardContainer'}"></div>
</div> </div>
<div id="modal_content">
<div id="threeDS2Container"></div>
</div>
<!-- ko if: (hasInstallments())--> <!-- ko if: (hasInstallments())-->
<div class="field required" <div class="field required"
...@@ -116,23 +120,6 @@ ...@@ -116,23 +120,6 @@
</div> </div>
<!-- /ko --> <!-- /ko -->
<!-- ko if: (canCreateBillingAgreement() && !isVaultEnabled())-->
<div class="field choice">
<input type="checkbox"
name="payment[store_cc]"
autocomplete="off"
class="checkbox"
data-bind="attr: {title: $t('Remember Me')}, checked: setStoreCc"
/>
<label data-bind="attr: {for: getCode() + '_remember_details'}" class="label">
<span><!-- ko text: $t('Remember these details')--><!-- /ko --></span>
</label>
</div>
<!-- /ko -->
</fieldset> </fieldset>
</form> </form>
......
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