Skip to content

Commit a7f4a1f

Browse files
Merge pull request #357 from mercadopago/release/7.3.4
Release v7.3.4
2 parents 35a432f + a2210ca commit a7f4a1f

18 files changed

+180
-181
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ 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+
## [7.3.4] - 2024-04-15
9+
### Fixed:
10+
- Thankyou page redirect for PIX and Ticket Payments working again.
11+
- Prevents type error on checkout screen due to amount values.
12+
- Removed console error message when custom checkout is not enabled.
813

914
## [7.3.3] - 2024-04-11
1015
### Changed:

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,9 @@ jQuery('body').on('payment_method_selected', function () {
363363
});
364364

365365
jQuery('form#order_review').submit(function (event) {
366-
if (document.getElementById('payment_method_woo-mercado-pago-custom').checked) {
366+
const selectPaymentMethod = document.getElementById('payment_method_woo-mercado-pago-custom');
367+
368+
if (selectPaymentMethod && selectPaymentMethod.checked) {
367369
event.preventDefault();
368370
return mercadoPagoFormHandler();
369371
} else {

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

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

changelog.log

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG:
22
== Changelog ==
33

4+
= v7.3.4 (15/04/2024) =
5+
* Changed:
6+
- Thankyou page redirect for PIX and Ticket Payments working again.
7+
- Prevents type error on checkout screen due to amount values.
8+
- Removed console error message when custom checkout is not enabled.
9+
410
= v7.3.3 (11/04/2024) =
511
* Changed:
612
- Our latest plugin update (version 7.3.2) aimed to optimize script loading during checkout using the woocommerce_before_checkout_form and woocommerce_blocks_enqueue_checkout_block_scripts_before hooks. However, to ensure compatibility with a wider range of themes, this functionality has been temporarily disabled. We're actively exploring solutions to achieve optimal script loading across all themes and will implement them in a future update.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "woocommerce-mercadopago",
33
"description": "Woocommerce MercadoPago Payment Gateway",
4-
"version": "7.3.3",
4+
"version": "7.3.4",
55
"main": "main.js",
66
"repository": {
77
"type": "git",

readme.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: ecommerce, mercadopago, woocommerce
44
Requires at least: 6.3
55
Tested up to: 6.4
66
Requires PHP: 7.4
7-
Stable tag: 7.3.3
7+
Stable tag: 7.3.4
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -136,9 +136,9 @@ Check out our <a href="https://www.mercadopago.com.br/developers/pt/plugins_sdks
136136

137137
== Changelog ==
138138

139-
* Changed:
140-
- Our latest plugin update (version 7.3.2) aimed to optimize script loading during checkout using the woocommerce_before_checkout_form and woocommerce_blocks_enqueue_checkout_block_scripts_before hooks.
141-
However, to ensure compatibility with a wider range of themes, this functionality has been temporarily disabled.
142-
We're actively exploring solutions to achieve optimal script loading across all themes and will implement them in a future update.
139+
* Fixed:
140+
- Thankyou page redirect for PIX and Ticket Payments working again.
141+
- Prevents type error on checkout screen due to amount values.
142+
- Removed console error message when custom checkout is not enabled.
143143

144144
[See changelog for all versions](https://github.com/mercadopago/cart-woocommerce/blob/main/CHANGELOG.md).

src/Blocks/AbstractBlock.php

+1-12
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,12 @@ public function get_payment_method_script_handles(): array
141141
$deps = $asset['dependencies'] ?? [];
142142
}
143143

144-
$this->mercadopago->hooks->blocks->registerBlocksEnqueueCheckoutScriptsBefore([$this, 'loadGatewayCheckoutScripts']);
144+
$this->gateway->registerCheckoutScripts();
145145
$this->mercadopago->hooks->scripts->registerPaymentBlockScript($scriptName, $scriptPath, $version, $deps);
146146
$this->gateway->registerCheckoutScripts();
147147
return [$scriptName];
148148
}
149149

150-
151-
/**
152-
* Load gateway script that is not related to blocks but is still needed for proper functioning.
153-
*
154-
* @return void
155-
*/
156-
public function loadGatewayCheckoutScripts(): void
157-
{
158-
$this->gateway->registerCheckoutScripts();
159-
}
160-
161150
/**
162151
* Returns an array of key=>value pairs of data made available to the payment methods script
163152
*

src/Gateways/AbstractGateway.php

+16
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ public function payment_scripts(string $gatewaySection): void
243243
if ($this->canAdminLoadScriptsAndStyles($gatewaySection)) {
244244
$this->registerAdminScripts();
245245
}
246+
247+
if ($this->canCheckoutLoadScriptsAndStyles()) {
248+
$this->registerCheckoutScripts();
249+
}
246250
}
247251

248252
/**
@@ -380,6 +384,18 @@ public function canAdminLoadScriptsAndStyles(string $gatewaySection): bool
380384
);
381385
}
382386

387+
/**
388+
* Check if admin scripts and styles can be loaded
389+
*
390+
* @return bool
391+
*/
392+
public function canCheckoutLoadScriptsAndStyles(): bool
393+
{
394+
return $this->mercadopago->hooks->checkout->isCheckout() &&
395+
$this->mercadopago->hooks->gateway->isEnabled($this) &&
396+
!$this->mercadopago->helpers->url->validateQueryVar('order-received');
397+
}
398+
383399
/**
384400
* Load research component
385401
*

src/Gateways/BasicGateway.php

+9-11
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ public function __construct()
6464
$this->mercadopago->hooks->cart->registerCartCalculateFees([$this, 'registerDiscountAndCommissionFeesOnCart']);
6565

6666
$this->mercadopago->helpers->currency->handleCurrencyNotices($this);
67-
68-
$this->mercadopago->hooks->checkout->registerBeforeCheckoutForm(function () {
69-
$this->registerCheckoutScripts();
70-
});
7167
}
7268

7369
/**
@@ -247,6 +243,10 @@ public function init_form_fields(): void
247243
public function payment_scripts(string $gatewaySection): void
248244
{
249245
parent::payment_scripts($gatewaySection);
246+
247+
if ($this->canCheckoutLoadScriptsAndStyles()) {
248+
$this->registerCheckoutScripts();
249+
}
250250
}
251251

252252
/**
@@ -256,14 +256,12 @@ public function payment_scripts(string $gatewaySection): void
256256
*/
257257
public function registerCheckoutScripts(): void
258258
{
259+
parent::registerCheckoutScripts();
259260

260-
if ($this->mercadopago->hooks->gateway->isEnabled($this)) {
261-
parent::registerCheckoutScripts();
262-
$this->mercadopago->hooks->scripts->registerCheckoutScript(
263-
'wc_mercadopago_sdk',
264-
'https://sdk.mercadopago.com/js/v2'
265-
);
266-
}
261+
$this->mercadopago->hooks->scripts->registerCheckoutScript(
262+
'wc_mercadopago_sdk',
263+
'https://sdk.mercadopago.com/js/v2'
264+
);
267265
}
268266

269267
/**

src/Gateways/CreditsGateway.php

-4
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ public function __construct()
6262
$this->mercadopago->hooks->cart->registerCartCalculateFees([$this, 'registerDiscountAndCommissionFeesOnCart']);
6363

6464
$this->mercadopago->helpers->currency->handleCurrencyNotices($this);
65-
66-
$this->mercadopago->hooks->checkout->registerBeforeCheckoutForm(function () {
67-
$this->registerCheckoutScripts();
68-
});
6965
}
7066

7167
/**

src/Gateways/CustomGateway.php

+76-78
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ public function __construct()
7272
$this->mercadopago->hooks->cart->registerCartCalculateFees([$this, 'registerDiscountAndCommissionFeesOnCart']);
7373

7474
$this->mercadopago->helpers->currency->handleCurrencyNotices($this);
75-
76-
$this->mercadopago->hooks->checkout->registerBeforeCheckoutForm(function () {
77-
$this->registerCheckoutScripts();
78-
});
7975
}
8076

8177
/**
@@ -224,6 +220,10 @@ public function init_form_fields(): void
224220
public function payment_scripts(string $gatewaySection): void
225221
{
226222
parent::payment_scripts($gatewaySection);
223+
224+
if ($this->canCheckoutLoadScriptsAndStyles()) {
225+
$this->registerCheckoutScripts();
226+
}
227227
}
228228

229229
/**
@@ -233,86 +233,84 @@ public function payment_scripts(string $gatewaySection): void
233233
*/
234234
public function registerCheckoutScripts(): void
235235
{
236-
if ($this->mercadopago->hooks->gateway->isEnabled($this)) {
237-
parent::registerCheckoutScripts();
236+
parent::registerCheckoutScripts();
238237

239-
$this->mercadopago->hooks->scripts->registerCheckoutScript(
240-
'wc_mercadopago_security_session',
241-
$this->mercadopago->helpers->url->getPluginFileUrl('assets/js/checkouts/custom/session', '.js')
242-
);
238+
$this->mercadopago->hooks->scripts->registerCheckoutScript(
239+
'wc_mercadopago_security_session',
240+
$this->mercadopago->helpers->url->getPluginFileUrl('assets/js/checkouts/custom/session', '.js')
241+
);
243242

244-
$this->mercadopago->hooks->scripts->registerCheckoutScript(
245-
'wc_mercadopago_sdk',
246-
'https://sdk.mercadopago.com/js/v2'
247-
);
243+
$this->mercadopago->hooks->scripts->registerCheckoutScript(
244+
'wc_mercadopago_sdk',
245+
'https://sdk.mercadopago.com/js/v2'
246+
);
248247

249-
$this->mercadopago->hooks->scripts->registerCheckoutScript(
250-
'wc_mercadopago_custom_page',
251-
$this->mercadopago->helpers->url->getPluginFileUrl('assets/js/checkouts/custom/mp-custom-page', '.js')
252-
);
248+
$this->mercadopago->hooks->scripts->registerCheckoutScript(
249+
'wc_mercadopago_custom_page',
250+
$this->mercadopago->helpers->url->getPluginFileUrl('assets/js/checkouts/custom/mp-custom-page', '.js')
251+
);
253252

254-
$this->mercadopago->hooks->scripts->registerCheckoutScript(
255-
'wc_mercadopago_custom_elements',
256-
$this->mercadopago->helpers->url->getPluginFileUrl('assets/js/checkouts/custom/mp-custom-elements', '.js')
257-
);
253+
$this->mercadopago->hooks->scripts->registerCheckoutScript(
254+
'wc_mercadopago_custom_elements',
255+
$this->mercadopago->helpers->url->getPluginFileUrl('assets/js/checkouts/custom/mp-custom-elements', '.js')
256+
);
258257

259-
$this->mercadopago->hooks->scripts->registerCheckoutScript(
260-
'wc_mercadopago_custom_checkout',
261-
$this->mercadopago->helpers->url->getPluginFileUrl('assets/js/checkouts/custom/mp-custom-checkout', '.js'),
262-
[
263-
'public_key' => $this->mercadopago->sellerConfig->getCredentialsPublicKey(),
264-
'intl' => $this->countryConfigs['intl'],
265-
'site_id' => $this->countryConfigs['site_id'],
266-
'currency' => $this->countryConfigs['currency'],
267-
'theme' => get_stylesheet(),
268-
'location' => '/checkout',
269-
'plugin_version' => MP_VERSION,
270-
'platform_version' => $this->mercadopago->woocommerce->version,
271-
'cvvText' => $this->storeTranslations['cvv_text'],
272-
'installmentObsFee' => $this->storeTranslations['installment_obs_fee'],
273-
'installmentButton' => $this->storeTranslations['installment_button'],
274-
'bankInterestText' => $this->storeTranslations['bank_interest_text'],
275-
'interestText' => $this->storeTranslations['interest_text'],
276-
'placeholders' => [
277-
'issuer' => $this->storeTranslations['placeholders_issuer'],
278-
'installments' => $this->storeTranslations['placeholders_installments'],
279-
'cardExpirationDate' => $this->storeTranslations['placeholders_card_expiration_date'],
280-
],
281-
'cvvHint' => [
282-
'back' => $this->storeTranslations['cvv_hint_back'],
283-
'front' => $this->storeTranslations['cvv_hint_front'],
258+
$this->mercadopago->hooks->scripts->registerCheckoutScript(
259+
'wc_mercadopago_custom_checkout',
260+
$this->mercadopago->helpers->url->getPluginFileUrl('assets/js/checkouts/custom/mp-custom-checkout', '.js'),
261+
[
262+
'public_key' => $this->mercadopago->sellerConfig->getCredentialsPublicKey(),
263+
'intl' => $this->countryConfigs['intl'],
264+
'site_id' => $this->countryConfigs['site_id'],
265+
'currency' => $this->countryConfigs['currency'],
266+
'theme' => get_stylesheet(),
267+
'location' => '/checkout',
268+
'plugin_version' => MP_VERSION,
269+
'platform_version' => $this->mercadopago->woocommerce->version,
270+
'cvvText' => $this->storeTranslations['cvv_text'],
271+
'installmentObsFee' => $this->storeTranslations['installment_obs_fee'],
272+
'installmentButton' => $this->storeTranslations['installment_button'],
273+
'bankInterestText' => $this->storeTranslations['bank_interest_text'],
274+
'interestText' => $this->storeTranslations['interest_text'],
275+
'placeholders' => [
276+
'issuer' => $this->storeTranslations['placeholders_issuer'],
277+
'installments' => $this->storeTranslations['placeholders_installments'],
278+
'cardExpirationDate' => $this->storeTranslations['placeholders_card_expiration_date'],
279+
],
280+
'cvvHint' => [
281+
'back' => $this->storeTranslations['cvv_hint_back'],
282+
'front' => $this->storeTranslations['cvv_hint_front'],
283+
],
284+
'input_helper_message' => [
285+
'cardNumber' => [
286+
'invalid_type' => $this->storeTranslations['input_helper_message_invalid_type'],
287+
'invalid_length' => $this->storeTranslations['input_helper_message_invalid_length'],
284288
],
285-
'input_helper_message' => [
286-
'cardNumber' => [
287-
'invalid_type' => $this->storeTranslations['input_helper_message_invalid_type'],
288-
'invalid_length' => $this->storeTranslations['input_helper_message_invalid_length'],
289-
],
290-
'cardholderName' => [
291-
'221' => $this->storeTranslations['input_helper_message_card_holder_name_221'],
292-
'316' => $this->storeTranslations['input_helper_message_card_holder_name_316'],
293-
],
294-
'expirationDate' => [
295-
'invalid_type' => $this->storeTranslations['input_helper_message_expiration_date_invalid_type'],
296-
'invalid_length' => $this->storeTranslations['input_helper_message_expiration_date_invalid_length'],
297-
'invalid_value' => $this->storeTranslations['input_helper_message_expiration_date_invalid_value'],
298-
],
299-
'securityCode' => [
300-
'invalid_type' => $this->storeTranslations['input_helper_message_security_code_invalid_type'],
301-
'invalid_length' => $this->storeTranslations['input_helper_message_security_code_invalid_length'],
302-
]
289+
'cardholderName' => [
290+
'221' => $this->storeTranslations['input_helper_message_card_holder_name_221'],
291+
'316' => $this->storeTranslations['input_helper_message_card_holder_name_316'],
303292
],
304-
'threeDsText' => [
305-
'title_loading' => $this->mercadopago->storeTranslations->threeDsTranslations['title_loading_3ds_frame'],
306-
'title_loading2' => $this->mercadopago->storeTranslations->threeDsTranslations['title_loading_3ds_frame2'],
307-
'text_loading' => $this->mercadopago->storeTranslations->threeDsTranslations['text_loading_3ds_frame'],
308-
'title_loading_response' => $this->mercadopago->storeTranslations->threeDsTranslations['title_loading_3ds_response'],
309-
'title_frame' => $this->mercadopago->storeTranslations->threeDsTranslations['title_3ds_frame'],
310-
'tooltip_frame' => $this->mercadopago->storeTranslations->threeDsTranslations['tooltip_3ds_frame'],
311-
'message_close' => $this->mercadopago->storeTranslations->threeDsTranslations['message_3ds_declined'],
293+
'expirationDate' => [
294+
'invalid_type' => $this->storeTranslations['input_helper_message_expiration_date_invalid_type'],
295+
'invalid_length' => $this->storeTranslations['input_helper_message_expiration_date_invalid_length'],
296+
'invalid_value' => $this->storeTranslations['input_helper_message_expiration_date_invalid_value'],
312297
],
313-
]
314-
);
315-
}
298+
'securityCode' => [
299+
'invalid_type' => $this->storeTranslations['input_helper_message_security_code_invalid_type'],
300+
'invalid_length' => $this->storeTranslations['input_helper_message_security_code_invalid_length'],
301+
]
302+
],
303+
'threeDsText' => [
304+
'title_loading' => $this->mercadopago->storeTranslations->threeDsTranslations['title_loading_3ds_frame'],
305+
'title_loading2' => $this->mercadopago->storeTranslations->threeDsTranslations['title_loading_3ds_frame2'],
306+
'text_loading' => $this->mercadopago->storeTranslations->threeDsTranslations['text_loading_3ds_frame'],
307+
'title_loading_response' => $this->mercadopago->storeTranslations->threeDsTranslations['title_loading_3ds_response'],
308+
'title_frame' => $this->mercadopago->storeTranslations->threeDsTranslations['title_3ds_frame'],
309+
'tooltip_frame' => $this->mercadopago->storeTranslations->threeDsTranslations['tooltip_3ds_frame'],
310+
'message_close' => $this->mercadopago->storeTranslations->threeDsTranslations['message_3ds_declined'],
311+
],
312+
]
313+
);
316314
}
317315

318316
/**
@@ -411,7 +409,7 @@ public function process_payment($order_id): array
411409
'result' => 'success',
412410
'redirect' => $this->mercadopago->helpers->url->setQueryVar(
413411
'wallet_button',
414-
'open',
412+
'autoOpen',
415413
$order->get_checkout_payment_url(true)
416414
),
417415
];
@@ -573,7 +571,7 @@ public function renderInstallmentsRateDetails($order_id): void
573571
{
574572
$order = wc_get_order($order_id);
575573
$currency = $this->countryConfigs['currency_symbol'];
576-
$installments = $this->mercadopago->orderMetadata->getInstallmentsMeta($order);
574+
$installments = (float) $this->mercadopago->orderMetadata->getInstallmentsMeta($order);
577575
$installmentAmount = $this->mercadopago->orderMetadata->getTransactionDetailsMeta($order);
578576
$transactionAmount = Numbers::makesValueSafe($this->mercadopago->orderMetadata->getTransactionAmountMeta($order));
579577
$totalPaidAmount = Numbers::makesValueSafe($this->mercadopago->orderMetadata->getTotalPaidAmountMeta($order));

src/Gateways/PixGateway.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ public function __construct()
7777
$this->mercadopago->hooks->cart->registerCartCalculateFees([$this, 'registerDiscountAndCommissionFeesOnCart']);
7878

7979
$this->mercadopago->helpers->currency->handleCurrencyNotices($this);
80-
81-
$this->mercadopago->hooks->checkout->registerBeforeCheckoutForm(function () {
82-
$this->registerCheckoutScripts();
83-
});
8480
}
8581

8682
/**
@@ -521,7 +517,7 @@ public function renderThankYouPage($order_id): void
521517
{
522518
$order = wc_get_order($order_id);
523519

524-
$transactionAmount = $this->mercadopago->orderMetadata->getTransactionAmountMeta($order);
520+
$transactionAmount = (float) $this->mercadopago->orderMetadata->getTransactionAmountMeta($order);
525521
$transactionAmount = Numbers::format($transactionAmount);
526522

527523
$defaultValue = $this->storeTranslations['expiration_30_minutes'];

0 commit comments

Comments
 (0)