@@ -72,10 +72,6 @@ public function __construct()
72
72
$ this ->mercadopago ->hooks ->cart ->registerCartCalculateFees ([$ this , 'registerDiscountAndCommissionFeesOnCart ' ]);
73
73
74
74
$ this ->mercadopago ->helpers ->currency ->handleCurrencyNotices ($ this );
75
-
76
- $ this ->mercadopago ->hooks ->checkout ->registerBeforeCheckoutForm (function () {
77
- $ this ->registerCheckoutScripts ();
78
- });
79
75
}
80
76
81
77
/**
@@ -224,6 +220,10 @@ public function init_form_fields(): void
224
220
public function payment_scripts (string $ gatewaySection ): void
225
221
{
226
222
parent ::payment_scripts ($ gatewaySection );
223
+
224
+ if ($ this ->canCheckoutLoadScriptsAndStyles ()) {
225
+ $ this ->registerCheckoutScripts ();
226
+ }
227
227
}
228
228
229
229
/**
@@ -233,86 +233,84 @@ public function payment_scripts(string $gatewaySection): void
233
233
*/
234
234
public function registerCheckoutScripts (): void
235
235
{
236
- if ($ this ->mercadopago ->hooks ->gateway ->isEnabled ($ this )) {
237
- parent ::registerCheckoutScripts ();
236
+ parent ::registerCheckoutScripts ();
238
237
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
+ );
243
242
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
+ );
248
247
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
+ );
253
252
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
+ );
258
257
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 ' ],
284
288
],
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 ' ],
303
292
],
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 ' ],
312
297
],
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
+ );
316
314
}
317
315
318
316
/**
@@ -411,7 +409,7 @@ public function process_payment($order_id): array
411
409
'result ' => 'success ' ,
412
410
'redirect ' => $ this ->mercadopago ->helpers ->url ->setQueryVar (
413
411
'wallet_button ' ,
414
- 'open ' ,
412
+ 'autoOpen ' ,
415
413
$ order ->get_checkout_payment_url (true )
416
414
),
417
415
];
@@ -573,7 +571,7 @@ public function renderInstallmentsRateDetails($order_id): void
573
571
{
574
572
$ order = wc_get_order ($ order_id );
575
573
$ currency = $ this ->countryConfigs ['currency_symbol ' ];
576
- $ installments = $ this ->mercadopago ->orderMetadata ->getInstallmentsMeta ($ order );
574
+ $ installments = ( float ) $ this ->mercadopago ->orderMetadata ->getInstallmentsMeta ($ order );
577
575
$ installmentAmount = $ this ->mercadopago ->orderMetadata ->getTransactionDetailsMeta ($ order );
578
576
$ transactionAmount = Numbers::makesValueSafe ($ this ->mercadopago ->orderMetadata ->getTransactionAmountMeta ($ order ));
579
577
$ totalPaidAmount = Numbers::makesValueSafe ($ this ->mercadopago ->orderMetadata ->getTotalPaidAmountMeta ($ order ));
0 commit comments