Skip to content

Commit 172b588

Browse files
Merge pull request #399 from mercadopago/release/8.4.4
Release v8.4.4
2 parents 76571af + b1ac9b6 commit 172b588

13 files changed

+110
-48
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [8.4.4] - 2025-08-11
9+
### Fixed
10+
- Does not block payment if email is not filled in
11+
12+
## [8.4.3] - 2025-08-11
13+
### Changed
14+
- Ensure that it uses the same SDK instance in transparent checkout
15+
### Fixed
16+
- Prevents clickable areas from being removed when the fast pay flow is not fully loaded
17+
818
## [8.4.2] - 2025-08-07
919
### Fixed
1020
- Sync CardForm ID with checkout context for pay-for-order compatibility

assets/js/checkouts/custom/entities/card-form.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ class MPCardForm {
1414
this.createLoadSpinner();
1515
}
1616

17-
const mp = new MercadoPago(wc_mercadopago_custom_checkout_params.public_key, {
18-
locale: wc_mercadopago_custom_checkout_params.locale,
19-
});
17+
if (!window.mpSdkInstance) {
18+
const mp = new MercadoPago(wc_mercadopago_custom_checkout_params.public_key, {
19+
locale: wc_mercadopago_custom_checkout_params.locale,
20+
});
2021

21-
window.mpSdkInstance = mp;
22+
window.mpSdkInstance = mp;
23+
}
2224

2325
return new Promise((resolve, reject) => {
24-
this.form = mp.cardForm({
26+
this.form = window.mpSdkInstance.cardForm({
2527
amount: amount,
2628
iframe: true,
2729
form: this.getCardFormConfig(),

assets/js/checkouts/custom/entities/card-form.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/checkouts/custom/mp-custom-checkout.js

Lines changed: 57 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
class MPCustomCheckoutHandler {
44
static FORM_SELECTORS = {
55
CLASSIC: 'form[name=checkout]',
6-
BLOCKS: '.wc-block-components-form.wc-block-checkout__form'
6+
BLOCKS: '.wc-block-components-form.wc-block-checkout__form',
7+
ORDER_REVIEW: 'form#order_review',
78
};
89

910
static FORM_IDS = {
@@ -20,8 +21,8 @@ class MPCustomCheckoutHandler {
2021
this.init();
2122
}
2223

23-
init() {
24-
this.setupFormConfiguration();
24+
async init() {
25+
await this.setupFormConfiguration();
2526

2627
if (!this.eventHandler.triggeredPaymentMethodSelectedEvent) {
2728
jQuery('body').trigger('payment_method_selected');
@@ -30,38 +31,67 @@ class MPCustomCheckoutHandler {
3031
this.eventHandler.bindEvents();
3132
}
3233

33-
setupFormConfiguration() {
34-
const formConfig = this.getFormConfig();
35-
36-
if (formConfig.element) {
37-
formConfig.element.id = formConfig.formId;
38-
}
34+
async setupFormConfiguration() {
35+
try {
36+
const formConfig = await this.getFormConfig();
37+
38+
if (formConfig.element) {
39+
formConfig.element.id = formConfig.formId;
40+
}
3941

40-
this.syncFormIds(formConfig.formId);
42+
this.syncFormIds(formConfig.formId);
43+
} catch (error) {
44+
console.error('Failed to configure checkout form:', error);
45+
}
4146
}
4247

4348
getFormConfig() {
44-
const classicForm = document.querySelector(MPCustomCheckoutHandler.FORM_SELECTORS.CLASSIC);
45-
const blocksForm = document.querySelector(MPCustomCheckoutHandler.FORM_SELECTORS.BLOCKS);
49+
return new Promise((resolve, reject) => {
50+
const maxTries = 10;
51+
const intervalMs = 500;
52+
let tries = 0;
4653

47-
if (classicForm) {
48-
return {
49-
element: classicForm,
50-
formId: MPCustomCheckoutHandler.FORM_IDS.CLASSIC_CHECKOUT,
51-
};
52-
}
54+
const tryFindForm = () => {
55+
tries++;
56+
57+
const classicForm = document.querySelector(MPCustomCheckoutHandler.FORM_SELECTORS.CLASSIC);
58+
const blocksForm = document.querySelector(MPCustomCheckoutHandler.FORM_SELECTORS.BLOCKS);
59+
const orderReviewForm = document.querySelector(MPCustomCheckoutHandler.FORM_SELECTORS.ORDER_REVIEW);
5360

54-
if (blocksForm) {
55-
return {
56-
element: blocksForm,
57-
formId: MPCustomCheckoutHandler.FORM_IDS.BLOCKS_CHECKOUT,
61+
if (classicForm) {
62+
resolve({
63+
element: classicForm,
64+
formId: MPCustomCheckoutHandler.FORM_IDS.CLASSIC_CHECKOUT,
65+
});
66+
return;
67+
}
68+
69+
if (blocksForm) {
70+
resolve({
71+
element: blocksForm,
72+
formId: MPCustomCheckoutHandler.FORM_IDS.BLOCKS_CHECKOUT,
73+
});
74+
return;
75+
}
76+
77+
if (orderReviewForm) {
78+
resolve({
79+
element: orderReviewForm,
80+
formId: MPCustomCheckoutHandler.FORM_IDS.PAY_FOR_ORDER,
81+
});
82+
return;
83+
}
84+
85+
if (tries >= maxTries) {
86+
reject(new Error(`No checkout form found after ${maxTries} attempts`));
87+
return;
88+
}
89+
90+
setTimeout(tryFindForm, intervalMs);
5891
};
59-
}
6092

61-
return {
62-
element: null,
63-
formId: MPCustomCheckoutHandler.FORM_IDS.PAY_FOR_ORDER,
64-
};
93+
tryFindForm();
94+
});
6595
}
6696

6797
syncFormIds(formId) {

assets/js/checkouts/custom/mp-custom-checkout.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/checkouts/super-token/entities/super-token-trigger-handler.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class MPSuperTokenTriggerHandler {
1414
wcBuyerEmail = null;
1515
currentAmount = null;
1616
isAlreadyListeningForm = false;
17+
isAuthenticating = false;
1718

1819
// Dependencies
1920
mpSuperTokenAuthenticator = null;
@@ -28,6 +29,7 @@ class MPSuperTokenTriggerHandler {
2829

2930
reset() {
3031
this.removeClickableAreas();
32+
this.isAuthenticating = false;
3133
}
3234

3335
amountHasChanged() {
@@ -138,14 +140,24 @@ class MPSuperTokenTriggerHandler {
138140
}
139141

140142
onTrigger() {
141-
this.removeClickableAreas();
143+
if (this.isAuthenticating) {
144+
return;
145+
}
146+
147+
this.isAuthenticating = true;
142148

143149
const buyerEmail = this.wcBuyerEmail || this.wcEmailListener.getEmail();
144150
if (!buyerEmail) {
151+
this.isAuthenticating = false;
152+
this.removeClickableAreas();
145153
return;
146154
}
147155

148-
this.mpSuperTokenAuthenticator.authenticate(this.currentAmount, buyerEmail);
156+
this.mpSuperTokenAuthenticator.authenticate(this.currentAmount, buyerEmail)
157+
.finally(() => {
158+
this.isAuthenticating = false;
159+
this.removeClickableAreas();
160+
});
149161
}
150162

151163
resetFlow() {
@@ -167,9 +179,8 @@ class MPSuperTokenTriggerHandler {
167179
resetSuperTokenOnError() {
168180
if (document.querySelector('#mp_checkout_type')?.value === 'super_token') {
169181
console.log('Resetting ST flow due to checkout error');
170-
171182
this.resetCustomCheckout();
172-
183+
this.isAuthenticating = false;
173184
document.querySelector('#mp_checkout_type').value = '';
174185
}
175186
}

assets/js/checkouts/super-token/entities/super-token-trigger-handler.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

changelog.log

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
CHANGELOG:
22
== Changelog ==
33

4+
= v8.4.4 (11/08/2025) =
5+
* Fixed
6+
- Does not block payment if email is not filled in
7+
8+
= v8.4.3 (11/08/2025) =
9+
* Changed
10+
- Ensure that it uses the same SDK instance in transparent checkout
11+
* Fixed
12+
- Prevents clickable areas from being removed when the fast pay flow is not fully loaded
13+
414
= v8.4.2 (07/08/2025) =
515
* Fixed
616
- Sync CardForm ID with checkout context for pay-for-order compatibility

0 commit comments

Comments
 (0)