Skip to content

Commit 121a611

Browse files
committed
Release 13-03-2024
- Fix: remove double checkout payment initialization
1 parent eda00ea commit 121a611

File tree

4 files changed

+20
-29
lines changed

4 files changed

+20
-29
lines changed

Controller/Order/EmbeddedSaveOrder.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Framework\App\ResponseInterface;
1111
use Magento\Customer\Api\AccountManagementInterface;
1212
use Magento\Customer\Api\CustomerRepositoryInterface;
13-
use Magento\Framework\Controller\Result\JsonFactory;
1413
use Magento\Framework\Serialize\Serializer\Json;
1514
use Magento\Sales\Model\Order;
1615

@@ -72,22 +71,22 @@ public function execute() {
7271
if (!$quote->getId()) {
7372
return $this->respondWithError('Empty quote');
7473
}
75-
74+
7675
$this->logInfo("in EmbeddedSaveOrder to create order");
77-
76+
7877
if (!$this->validateQuoteSignature()) {
7978
$this->logInfo("validation of quote signature failed");
80-
79+
8180
return;
8281
}
83-
82+
8483
$paymentId = $this->getRequest()->getPostValue('pid', null);
8584
if (!$paymentId) {
8685
return $this->respondWithError('Invalid payment id');
8786
}
88-
87+
8988
$this->dibsCheckout->checkCart();
90-
89+
9190
try {
9291
$this->logInfo("validation successful, creating order");
9392
$dibsPayment = $this->dibsCheckout->getDibsPaymentHandler()->loadDibsPaymentById($paymentId, $quote->getStoreId());
@@ -106,7 +105,8 @@ public function execute() {
106105
$result = $this->resultFactory->create('json');
107106
$result->setData([
108107
'status' => 'Success.',
109-
'paymentId' => $paymentId
108+
'paymentId' => $paymentId,
109+
'reload' => 0,
110110
]);
111111
$result->setHttpResponseCode(200);
112112

view/frontend/web/js/action/checkout-handler.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ define([
5353
payment.thawCheckout();
5454
}
5555
});
56-
},
57-
validateTest: function() {
58-
5956
},
6057
saveOrder: function(paymentId) {
6158
const ctrlkey = this.ctrlkey;
@@ -73,13 +70,13 @@ define([
7370
},
7471
success: function (response) {
7572
if ($.type(response) === 'object' && !$.isEmptyObject(response) && !response.reload) {
76-
this.sendPaymentOrderFinalizedEvent(true);
73+
this.send('payment-order-finalized', true);
7774
if (response.messages) {
7875
alert(jQuery.mage.__(response.messages));
7976
}
8077
} else {
8178
netsAlert({
82-
title: 'Error',
79+
title: 'Warning',
8380
content: response.messages,
8481
clickableOverlay: false,
8582
responsive: true,
@@ -96,7 +93,7 @@ define([
9693
}]
9794
});
9895
checkoutLoader.stopLoader();
99-
this.sendPaymentOrderFinalizedEvent(false);
96+
this.send('payment-order-finalized', false);
10097
messageList.addErrorMessage({
10198
message: response.messages
10299
});
@@ -121,7 +118,7 @@ define([
121118
}
122119
}]
123120
});
124-
this.sendPaymentOrderFinalizedEvent(false);
121+
this.send('payment-order-finalized', false);
125122
}
126123
});
127124
}

view/frontend/web/js/mixin/model/muodc/shipping-rate-processor.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ define([
6868
}
6969

7070
var dibsCheckout = uiRegistry.get('nwtdibsCheckout');
71-
if (dibsCheckout) {
72-
dibsCheckout.initializeNewPayment();
73-
}
7471

7572
if (window.dibs_msuodc_enabled && dibsCheckout) {
7673
dibsCheckout._ajaxSubmit(

view/frontend/web/js/view/payment/method-renderer/checkout-method.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@ define(
3030
'use strict';
3131
var agreementsConfig = window.checkoutConfig.checkoutAgreements;
3232
var agreementsCheck = agreementsConfig.isEnabled;
33-
33+
3434
var component = Component.extend({
3535

3636
defaults: {
3737
template: 'Dibs_EasyCheckout/payment/checkout',
3838
iframeUrl: null,
3939
hideLoader: false
4040
},
41-
eventsInstantiated: false,
4241
continueToDibsRedirect: function () {
4342
let billingAddressComponent = require('uiRegistry').get('checkout.steps.billing-step.payment.payments-list.'+this.getCode()+'-form');
4443
billingAddressComponent.updateAddress();
@@ -57,7 +56,7 @@ define(
5756
$.mage.redirect(paymentConfiguration.checkoutUrl);
5857
}
5958
};
60-
59+
6160
this.initPaymentConfiguration(0, callback);
6261
}.bind(this));
6362
return false;
@@ -117,14 +116,12 @@ define(
117116
};
118117
self.dibsPayment = new Dibs.Checkout(checkoutOptions);
119118
self.dibsPayment.ctrlkey = paymentConfiguration.ctrlkey;
120-
if (self.eventsInstantiated == false) {
121-
self.dibsPayment.on('payment-completed', vanillaCheckoutHandler.onCheckoutCompleteAction);
122-
self.dibsPayment.on('pay-initialized', vanillaCheckoutHandler.saveOrder);
123-
self.dibsPayment.on('payment-created', vanillaCheckoutHandler.validateTest);
124-
setCouponCodeAction.registerSuccessCallback(vanillaCheckoutHandler.updatePayment);
125-
cancelCouponCodeAction.registerSuccessCallback(vanillaCheckoutHandler.updatePayment);
126-
self.eventsInstantiated = true;
127-
}
119+
self.dibsPayment.on('pay-initialized', vanillaCheckoutHandler.saveOrder);
120+
self.dibsPayment.on('payment-completed', vanillaCheckoutHandler.onCheckoutCompleteAction);
121+
122+
setCouponCodeAction.registerSuccessCallback(vanillaCheckoutHandler.updatePayment);
123+
cancelCouponCodeAction.registerSuccessCallback(vanillaCheckoutHandler.updatePayment);
124+
128125
self.hideLoader(true);
129126
}
130127
}.bind(this);

0 commit comments

Comments
 (0)