Version Description
Download this release
Release Info
Developer | mercadopago |
Plugin | WooCommerce MercadoPago |
Version | 3.0.16 |
Comparing to | |
See all releases |
Code changes from version 3.0.15 to 3.0.16
- assets/css/custom_checkout_mercadopago.css +0 -0
- assets/images/MCO/CUPOM_MCO.jpg +0 -0
- assets/images/MCO/MCO.png +0 -0
- assets/images/MCO/banner_all_methods.png +0 -0
- assets/images/MCO/credit_card.png +0 -0
- assets/images/MCO/standard_mco.jpg +0 -0
- assets/images/MLA/CUPOM_MLA.jpg +0 -0
- assets/images/MLA/MLA.png +0 -0
- assets/images/MLA/banner_all_methods.png +0 -0
- assets/images/MLA/credit_card.png +0 -0
- assets/images/MLA/standard_mla.jpg +0 -0
- assets/images/MLB/CUPOM_MLB.jpg +0 -0
- assets/images/MLB/MLB.png +0 -0
- assets/images/MLB/banner_all_methods.png +0 -0
- assets/images/MLB/credit_card.png +0 -0
- assets/images/MLB/cupom1.jpg +0 -0
- assets/images/MLB/cupom2.jpg +0 -0
- assets/images/MLB/cupom3.jpg +0 -0
- assets/images/MLB/desconto_MLB.jpg +0 -0
- assets/images/MLB/standard_mlb.jpg +0 -0
- assets/images/MLC/CUPOM_MLC.jpg +0 -0
- assets/images/MLC/MLC.png +0 -0
- assets/images/MLC/banner_all_methods.png +0 -0
- assets/images/MLC/credit_card.png +0 -0
- assets/images/MLC/standard_mlc.gif +0 -0
- assets/images/MLM/CUPOM_MLM.jpg +0 -0
- assets/images/MLM/MLM.png +0 -0
- assets/images/MLM/banner_all_methods.png +0 -0
- assets/images/MLM/credit_card.png +0 -0
- assets/images/MLM/standard_mlm.jpg +0 -0
- assets/images/MLU/CUPOM_MLU.png +0 -0
- assets/images/MLU/MLU.png +0 -0
- assets/images/MLU/banner_all_methods.png +0 -0
- assets/images/MLU/credit_card.png +0 -0
- assets/images/MLU/standard_mlu.png +0 -0
- assets/images/MLV/CUPOM_MLV.jpg +0 -0
- assets/images/MLV/MLV.png +0 -0
- assets/images/MLV/banner_all_methods.png +0 -0
- assets/images/MLV/credit_card.png +0 -0
- assets/images/MLV/standard_mlv.jpg +0 -0
- assets/images/MPE/CUPOM_MPE.png +0 -0
- assets/images/MPE/MPE.png +0 -0
- assets/images/MPE/banner_all_methods.png +0 -0
- assets/images/MPE/credit_card.png +0 -0
- assets/images/MPE/standard_mpe.png +0 -0
- assets/images/bandeiras/amex.png +0 -0
- assets/images/bandeiras/boleto.png +0 -0
- assets/images/bandeiras/cash.png +0 -0
- assets/images/bandeiras/diners.png +0 -0
- assets/images/bandeiras/elo.png +0 -0
- assets/images/bandeiras/hipercard.png +0 -0
- assets/images/bandeiras/master.png +0 -0
- assets/images/bandeiras/melicard.png +0 -0
- assets/images/bandeiras/visa.png +0 -0
- assets/images/banner.png +0 -0
- assets/images/bar_code.png +0 -0
- assets/images/boleto.png +0 -0
- assets/images/cart.png +0 -0
- assets/images/check.png +0 -0
- assets/images/credit_card.png +0 -0
- assets/images/cvv.png +0 -0
- assets/images/error.png +0 -0
- assets/images/loading.gif +0 -0
- assets/images/mercadopago.png +0 -0
- assets/images/mplogo.png +0 -0
- assets/images/warning.png +0 -0
- assets/js/credit-card.js +0 -0
- assets/js/ticket.js +0 -0
- i18n/languages/woocommerce-mercadopago-es_AR.po +18 -0
- i18n/languages/woocommerce-mercadopago-es_CL.po +6 -0
- i18n/languages/woocommerce-mercadopago-es_CO.po +18 -0
- i18n/languages/woocommerce-mercadopago-es_ES.po +18 -0
- i18n/languages/woocommerce-mercadopago-es_MX.po +18 -0
- i18n/languages/woocommerce-mercadopago-es_PE.po +18 -0
- i18n/languages/woocommerce-mercadopago-es_UY.po +18 -0
- i18n/languages/woocommerce-mercadopago-es_VE.po +18 -0
- i18n/languages/woocommerce-mercadopago-pt_BR.po +18 -0
- i18n/languages/woocommerce-mercadopago.pot +0 -0
- includes/WC_WooMercadoPago_BasicGateway.php +1 -1
- includes/WC_WooMercadoPago_CustomGateway.php +1 -1
- includes/WC_WooMercadoPago_PSEGateway.php +1315 -0
- includes/WC_WooMercadoPago_SubscriptionGateway.php +1 -1
- includes/WC_WooMercadoPago_TicketGateway.php +1 -1
- includes/class-wc-product-mp_recurrent.php +0 -0
- includes/sdk/lib/mercadopago.php +14 -1
- readme.txt +9 -3
- templates/credit-card/payment-form.php +0 -0
- templates/mp_main_settings.php +6 -2
- templates/pse/pse-form.php +508 -0
- templates/ticket/ticket-form.php +0 -0
- woocommerce-mercadopago.php +64 -204
assets/css/custom_checkout_mercadopago.css
CHANGED
File without changes
|
assets/images/MCO/CUPOM_MCO.jpg
CHANGED
File without changes
|
assets/images/MCO/MCO.png
CHANGED
File without changes
|
assets/images/MCO/banner_all_methods.png
CHANGED
File without changes
|
assets/images/MCO/credit_card.png
CHANGED
File without changes
|
assets/images/MCO/standard_mco.jpg
CHANGED
File without changes
|
assets/images/MLA/CUPOM_MLA.jpg
CHANGED
File without changes
|
assets/images/MLA/MLA.png
CHANGED
File without changes
|
assets/images/MLA/banner_all_methods.png
CHANGED
File without changes
|
assets/images/MLA/credit_card.png
CHANGED
File without changes
|
assets/images/MLA/standard_mla.jpg
CHANGED
File without changes
|
assets/images/MLB/CUPOM_MLB.jpg
CHANGED
File without changes
|
assets/images/MLB/MLB.png
CHANGED
File without changes
|
assets/images/MLB/banner_all_methods.png
CHANGED
File without changes
|
assets/images/MLB/credit_card.png
CHANGED
File without changes
|
assets/images/MLB/cupom1.jpg
CHANGED
File without changes
|
assets/images/MLB/cupom2.jpg
CHANGED
File without changes
|
assets/images/MLB/cupom3.jpg
CHANGED
File without changes
|
assets/images/MLB/desconto_MLB.jpg
CHANGED
File without changes
|
assets/images/MLB/standard_mlb.jpg
CHANGED
File without changes
|
assets/images/MLC/CUPOM_MLC.jpg
CHANGED
File without changes
|
assets/images/MLC/MLC.png
CHANGED
File without changes
|
assets/images/MLC/banner_all_methods.png
CHANGED
File without changes
|
assets/images/MLC/credit_card.png
CHANGED
File without changes
|
assets/images/MLC/standard_mlc.gif
CHANGED
File without changes
|
assets/images/MLM/CUPOM_MLM.jpg
CHANGED
File without changes
|
assets/images/MLM/MLM.png
CHANGED
File without changes
|
assets/images/MLM/banner_all_methods.png
CHANGED
File without changes
|
assets/images/MLM/credit_card.png
CHANGED
File without changes
|
assets/images/MLM/standard_mlm.jpg
CHANGED
File without changes
|
assets/images/MLU/CUPOM_MLU.png
CHANGED
File without changes
|
assets/images/MLU/MLU.png
CHANGED
File without changes
|
assets/images/MLU/banner_all_methods.png
CHANGED
File without changes
|
assets/images/MLU/credit_card.png
CHANGED
File without changes
|
assets/images/MLU/standard_mlu.png
CHANGED
File without changes
|
assets/images/MLV/CUPOM_MLV.jpg
CHANGED
File without changes
|
assets/images/MLV/MLV.png
CHANGED
File without changes
|
assets/images/MLV/banner_all_methods.png
CHANGED
File without changes
|
assets/images/MLV/credit_card.png
CHANGED
File without changes
|
assets/images/MLV/standard_mlv.jpg
CHANGED
File without changes
|
assets/images/MPE/CUPOM_MPE.png
CHANGED
File without changes
|
assets/images/MPE/MPE.png
CHANGED
File without changes
|
assets/images/MPE/banner_all_methods.png
CHANGED
File without changes
|
assets/images/MPE/credit_card.png
CHANGED
File without changes
|
assets/images/MPE/standard_mpe.png
CHANGED
File without changes
|
assets/images/bandeiras/amex.png
CHANGED
File without changes
|
assets/images/bandeiras/boleto.png
CHANGED
File without changes
|
assets/images/bandeiras/cash.png
CHANGED
File without changes
|
assets/images/bandeiras/diners.png
CHANGED
File without changes
|
assets/images/bandeiras/elo.png
CHANGED
File without changes
|
assets/images/bandeiras/hipercard.png
CHANGED
File without changes
|
assets/images/bandeiras/master.png
CHANGED
File without changes
|
assets/images/bandeiras/melicard.png
CHANGED
File without changes
|
assets/images/bandeiras/visa.png
CHANGED
File without changes
|
assets/images/banner.png
CHANGED
File without changes
|
assets/images/bar_code.png
CHANGED
File without changes
|
assets/images/boleto.png
CHANGED
File without changes
|
assets/images/cart.png
CHANGED
File without changes
|
assets/images/check.png
CHANGED
File without changes
|
assets/images/credit_card.png
CHANGED
File without changes
|
assets/images/cvv.png
CHANGED
File without changes
|
assets/images/error.png
CHANGED
File without changes
|
assets/images/loading.gif
CHANGED
File without changes
|
assets/images/mercadopago.png
CHANGED
File without changes
|
assets/images/mplogo.png
CHANGED
File without changes
|
assets/images/warning.png
CHANGED
File without changes
|
assets/js/credit-card.js
CHANGED
File without changes
|
assets/js/ticket.js
CHANGED
File without changes
|
i18n/languages/woocommerce-mercadopago-es_AR.po
CHANGED
@@ -457,6 +457,9 @@ msgstr "Su cliente será capaz de utilizar dos tarjetas diferentes para pagar el
|
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
|
|
|
|
|
|
460 |
msgid "Cancel order & Clear cart"
|
461 |
msgstr "Cancelar & Limpiar carrito"
|
462 |
|
@@ -943,6 +946,9 @@ msgstr "Importante: La solicitud sólo será confirmada después de la aprobaci
|
|
943 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
944 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
945 |
|
|
|
|
|
|
|
946 |
msgid "Please, select the ticket issuer of your preference."
|
947 |
msgstr "Por favor, seleccione el emisor de su elección."
|
948 |
|
@@ -973,6 +979,12 @@ msgstr "ESTADO"
|
|
973 |
msgid "ZIP"
|
974 |
msgstr "CÓDIGO POSTAL"
|
975 |
|
|
|
|
|
|
|
|
|
|
|
|
|
976 |
msgid "You must inform you NAME"
|
977 |
msgstr "Obligatorio informar su NOMBRE"
|
978 |
|
@@ -997,6 +1009,12 @@ msgstr "Obligatorio informar su ESTADO"
|
|
997 |
msgid "You must inform your ZIP"
|
998 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
999 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1000 |
msgid "Fisical Person"
|
1001 |
msgstr "Persona Física"
|
1002 |
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
460 |
+
msgid "Thank you for your order. Please, transfer the money to get your order approved."
|
461 |
+
msgstr "Obrigado pela sua compra. Por favor, transfiera el dinero para tener su compra aprobada."
|
462 |
+
|
463 |
msgid "Cancel order & Clear cart"
|
464 |
msgstr "Cancelar & Limpiar carrito"
|
465 |
|
946 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
947 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
948 |
|
949 |
+
msgid "Click [Place order] button. The bank transfer will be setup and you will be redirected to pay it."
|
950 |
+
msgstr "Haga clic en el botón [Realizar el pedido]. La transferencia bancaria se inicializará y usted será redirigido para pagarla."
|
951 |
+
|
952 |
msgid "Please, select the ticket issuer of your preference."
|
953 |
msgstr "Por favor, seleccione el emisor de su elección."
|
954 |
|
979 |
msgid "ZIP"
|
980 |
msgstr "CÓDIGO POSTAL"
|
981 |
|
982 |
+
msgid "BANK"
|
983 |
+
msgstr "BANCO"
|
984 |
+
|
985 |
+
msgid "PERSON TYPE"
|
986 |
+
msgstr "TIPO DE PERSONA"
|
987 |
+
|
988 |
msgid "You must inform you NAME"
|
989 |
msgstr "Obligatorio informar su NOMBRE"
|
990 |
|
1009 |
msgid "You must inform your ZIP"
|
1010 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
1011 |
|
1012 |
+
msgid "You must inform the FINANCIAL INSTITUTION"
|
1013 |
+
msgstr "Obligatorio informar el BANCO"
|
1014 |
+
|
1015 |
+
msgid "You must inform your PERSON TYPE"
|
1016 |
+
msgstr "Obligatorio informar su TIPO DE PERSONA"
|
1017 |
+
|
1018 |
msgid "Fisical Person"
|
1019 |
msgstr "Persona Física"
|
1020 |
|
i18n/languages/woocommerce-mercadopago-es_CL.po
CHANGED
@@ -457,6 +457,9 @@ msgstr "Su cliente será capaz de utilizar dos tarjetas diferentes para pagar el
|
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
|
|
|
|
|
|
460 |
msgid "Cancel order & Clear cart"
|
461 |
msgstr "Cancelar & Limpiar carrito"
|
462 |
|
@@ -943,6 +946,9 @@ msgstr "Importante: La solicitud sólo será confirmada después de la aprobaci
|
|
943 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
944 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
945 |
|
|
|
|
|
|
|
946 |
msgid "Please, select the ticket issuer of your preference."
|
947 |
msgstr "Por favor, seleccione el emisor de su elección."
|
948 |
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
460 |
+
msgid "Thank you for your order. Please, transfer the money to get your order approved."
|
461 |
+
msgstr "Obrigado pela sua compra. Por favor, transfiera el dinero para tener su compra aprobada."
|
462 |
+
|
463 |
msgid "Cancel order & Clear cart"
|
464 |
msgstr "Cancelar & Limpiar carrito"
|
465 |
|
946 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
947 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
948 |
|
949 |
+
msgid "Click [Place order] button. The bank transfer will be setup and you will be redirected to pay it."
|
950 |
+
msgstr "Haga clic en el botón [Realizar el pedido]. La transferencia bancaria se inicializará y usted será redirigido para pagarla."
|
951 |
+
|
952 |
msgid "Please, select the ticket issuer of your preference."
|
953 |
msgstr "Por favor, seleccione el emisor de su elección."
|
954 |
|
i18n/languages/woocommerce-mercadopago-es_CO.po
CHANGED
@@ -457,6 +457,9 @@ msgstr "Su cliente será capaz de utilizar dos tarjetas diferentes para pagar el
|
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
|
|
|
|
|
|
460 |
msgid "Cancel order & Clear cart"
|
461 |
msgstr "Cancelar & Limpiar carrito"
|
462 |
|
@@ -943,6 +946,9 @@ msgstr "Importante: La solicitud sólo será confirmada después de la aprobaci
|
|
943 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
944 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
945 |
|
|
|
|
|
|
|
946 |
msgid "Please, select the ticket issuer of your preference."
|
947 |
msgstr "Por favor, seleccione el emisor de su elección."
|
948 |
|
@@ -973,6 +979,12 @@ msgstr "ESTADO"
|
|
973 |
msgid "ZIP"
|
974 |
msgstr "CÓDIGO POSTAL"
|
975 |
|
|
|
|
|
|
|
|
|
|
|
|
|
976 |
msgid "You must inform you NAME"
|
977 |
msgstr "Obligatorio informar su NOMBRE"
|
978 |
|
@@ -997,6 +1009,12 @@ msgstr "Obligatorio informar su ESTADO"
|
|
997 |
msgid "You must inform your ZIP"
|
998 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
999 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1000 |
msgid "Fisical Person"
|
1001 |
msgstr "Persona Física"
|
1002 |
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
460 |
+
msgid "Thank you for your order. Please, transfer the money to get your order approved."
|
461 |
+
msgstr "Obrigado pela sua compra. Por favor, transfiera el dinero para tener su compra aprobada."
|
462 |
+
|
463 |
msgid "Cancel order & Clear cart"
|
464 |
msgstr "Cancelar & Limpiar carrito"
|
465 |
|
946 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
947 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
948 |
|
949 |
+
msgid "Click [Place order] button. The bank transfer will be setup and you will be redirected to pay it."
|
950 |
+
msgstr "Haga clic en el botón [Realizar el pedido]. La transferencia bancaria se inicializará y usted será redirigido para pagarla."
|
951 |
+
|
952 |
msgid "Please, select the ticket issuer of your preference."
|
953 |
msgstr "Por favor, seleccione el emisor de su elección."
|
954 |
|
979 |
msgid "ZIP"
|
980 |
msgstr "CÓDIGO POSTAL"
|
981 |
|
982 |
+
msgid "BANK"
|
983 |
+
msgstr "BANCO"
|
984 |
+
|
985 |
+
msgid "PERSON TYPE"
|
986 |
+
msgstr "TIPO DE PERSONA"
|
987 |
+
|
988 |
msgid "You must inform you NAME"
|
989 |
msgstr "Obligatorio informar su NOMBRE"
|
990 |
|
1009 |
msgid "You must inform your ZIP"
|
1010 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
1011 |
|
1012 |
+
msgid "You must inform the FINANCIAL INSTITUTION"
|
1013 |
+
msgstr "Obligatorio informar el BANCO"
|
1014 |
+
|
1015 |
+
msgid "You must inform your PERSON TYPE"
|
1016 |
+
msgstr "Obligatorio informar su TIPO DE PERSONA"
|
1017 |
+
|
1018 |
msgid "Fisical Person"
|
1019 |
msgstr "Persona Física"
|
1020 |
|
i18n/languages/woocommerce-mercadopago-es_ES.po
CHANGED
@@ -457,6 +457,9 @@ msgstr "Su cliente será capaz de utilizar dos tarjetas diferentes para pagar el
|
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
|
|
|
|
|
|
460 |
msgid "Cancel order & Clear cart"
|
461 |
msgstr "Cancelar & Limpiar carrito"
|
462 |
|
@@ -943,6 +946,9 @@ msgstr "Importante: La solicitud sólo será confirmada después de la aprobaci
|
|
943 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
944 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
945 |
|
|
|
|
|
|
|
946 |
msgid "Please, select the ticket issuer of your preference."
|
947 |
msgstr "Por favor, seleccione el emisor de su elección."
|
948 |
|
@@ -973,6 +979,12 @@ msgstr "ESTADO"
|
|
973 |
msgid "ZIP"
|
974 |
msgstr "CÓDIGO POSTAL"
|
975 |
|
|
|
|
|
|
|
|
|
|
|
|
|
976 |
msgid "You must inform you NAME"
|
977 |
msgstr "Obligatorio informar su NOMBRE"
|
978 |
|
@@ -997,6 +1009,12 @@ msgstr "Obligatorio informar su ESTADO"
|
|
997 |
msgid "You must inform your ZIP"
|
998 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
999 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1000 |
msgid "Fisical Person"
|
1001 |
msgstr "Persona Física"
|
1002 |
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
460 |
+
msgid "Thank you for your order. Please, transfer the money to get your order approved."
|
461 |
+
msgstr "Obrigado pela sua compra. Por favor, transfiera el dinero para tener su compra aprobada."
|
462 |
+
|
463 |
msgid "Cancel order & Clear cart"
|
464 |
msgstr "Cancelar & Limpiar carrito"
|
465 |
|
946 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
947 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
948 |
|
949 |
+
msgid "Click [Place order] button. The bank transfer will be setup and you will be redirected to pay it."
|
950 |
+
msgstr "Haga clic en el botón [Realizar el pedido]. La transferencia bancaria se inicializará y usted será redirigido para pagarla."
|
951 |
+
|
952 |
msgid "Please, select the ticket issuer of your preference."
|
953 |
msgstr "Por favor, seleccione el emisor de su elección."
|
954 |
|
979 |
msgid "ZIP"
|
980 |
msgstr "CÓDIGO POSTAL"
|
981 |
|
982 |
+
msgid "BANK"
|
983 |
+
msgstr "BANCO"
|
984 |
+
|
985 |
+
msgid "PERSON TYPE"
|
986 |
+
msgstr "TIPO DE PERSONA"
|
987 |
+
|
988 |
msgid "You must inform you NAME"
|
989 |
msgstr "Obligatorio informar su NOMBRE"
|
990 |
|
1009 |
msgid "You must inform your ZIP"
|
1010 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
1011 |
|
1012 |
+
msgid "You must inform the FINANCIAL INSTITUTION"
|
1013 |
+
msgstr "Obligatorio informar el BANCO"
|
1014 |
+
|
1015 |
+
msgid "You must inform your PERSON TYPE"
|
1016 |
+
msgstr "Obligatorio informar su TIPO DE PERSONA"
|
1017 |
+
|
1018 |
msgid "Fisical Person"
|
1019 |
msgstr "Persona Física"
|
1020 |
|
i18n/languages/woocommerce-mercadopago-es_MX.po
CHANGED
@@ -457,6 +457,9 @@ msgstr "Su cliente será capaz de utilizar dos tarjetas diferentes para pagar el
|
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
|
|
|
|
|
|
460 |
msgid "Cancel order & Clear cart"
|
461 |
msgstr "Cancelar & Limpiar carrito"
|
462 |
|
@@ -943,6 +946,9 @@ msgstr "Importante: La solicitud sólo será confirmada después de la aprobaci
|
|
943 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
944 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
945 |
|
|
|
|
|
|
|
946 |
msgid "Please, select the ticket issuer of your preference."
|
947 |
msgstr "Por favor, seleccione el emisor de su elección."
|
948 |
|
@@ -973,6 +979,12 @@ msgstr "ESTADO"
|
|
973 |
msgid "ZIP"
|
974 |
msgstr "CÓDIGO POSTAL"
|
975 |
|
|
|
|
|
|
|
|
|
|
|
|
|
976 |
msgid "You must inform you NAME"
|
977 |
msgstr "Obligatorio informar su NOMBRE"
|
978 |
|
@@ -997,6 +1009,12 @@ msgstr "Obligatorio informar su ESTADO"
|
|
997 |
msgid "You must inform your ZIP"
|
998 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
999 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1000 |
msgid "Fisical Person"
|
1001 |
msgstr "Persona Física"
|
1002 |
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
460 |
+
msgid "Thank you for your order. Please, transfer the money to get your order approved."
|
461 |
+
msgstr "Obrigado pela sua compra. Por favor, transfiera el dinero para tener su compra aprobada."
|
462 |
+
|
463 |
msgid "Cancel order & Clear cart"
|
464 |
msgstr "Cancelar & Limpiar carrito"
|
465 |
|
946 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
947 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
948 |
|
949 |
+
msgid "Click [Place order] button. The bank transfer will be setup and you will be redirected to pay it."
|
950 |
+
msgstr "Haga clic en el botón [Realizar el pedido]. La transferencia bancaria se inicializará y usted será redirigido para pagarla."
|
951 |
+
|
952 |
msgid "Please, select the ticket issuer of your preference."
|
953 |
msgstr "Por favor, seleccione el emisor de su elección."
|
954 |
|
979 |
msgid "ZIP"
|
980 |
msgstr "CÓDIGO POSTAL"
|
981 |
|
982 |
+
msgid "BANK"
|
983 |
+
msgstr "BANCO"
|
984 |
+
|
985 |
+
msgid "PERSON TYPE"
|
986 |
+
msgstr "TIPO DE PERSONA"
|
987 |
+
|
988 |
msgid "You must inform you NAME"
|
989 |
msgstr "Obligatorio informar su NOMBRE"
|
990 |
|
1009 |
msgid "You must inform your ZIP"
|
1010 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
1011 |
|
1012 |
+
msgid "You must inform the FINANCIAL INSTITUTION"
|
1013 |
+
msgstr "Obligatorio informar el BANCO"
|
1014 |
+
|
1015 |
+
msgid "You must inform your PERSON TYPE"
|
1016 |
+
msgstr "Obligatorio informar su TIPO DE PERSONA"
|
1017 |
+
|
1018 |
msgid "Fisical Person"
|
1019 |
msgstr "Persona Física"
|
1020 |
|
i18n/languages/woocommerce-mercadopago-es_PE.po
CHANGED
@@ -457,6 +457,9 @@ msgstr "Su cliente será capaz de utilizar dos tarjetas diferentes para pagar el
|
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
|
|
|
|
|
|
460 |
msgid "Cancel order & Clear cart"
|
461 |
msgstr "Cancelar & Limpiar carrito"
|
462 |
|
@@ -943,6 +946,9 @@ msgstr "Importante: La solicitud sólo será confirmada después de la aprobaci
|
|
943 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
944 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
945 |
|
|
|
|
|
|
|
946 |
msgid "Please, select the ticket issuer of your preference."
|
947 |
msgstr "Por favor, seleccione el emisor de su elección."
|
948 |
|
@@ -973,6 +979,12 @@ msgstr "ESTADO"
|
|
973 |
msgid "ZIP"
|
974 |
msgstr "CÓDIGO POSTAL"
|
975 |
|
|
|
|
|
|
|
|
|
|
|
|
|
976 |
msgid "You must inform you NAME"
|
977 |
msgstr "Obligatorio informar su NOMBRE"
|
978 |
|
@@ -997,6 +1009,12 @@ msgstr "Obligatorio informar su ESTADO"
|
|
997 |
msgid "You must inform your ZIP"
|
998 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
999 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1000 |
msgid "Fisical Person"
|
1001 |
msgstr "Persona Física"
|
1002 |
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
460 |
+
msgid "Thank you for your order. Please, transfer the money to get your order approved."
|
461 |
+
msgstr "Obrigado pela sua compra. Por favor, transfiera el dinero para tener su compra aprobada."
|
462 |
+
|
463 |
msgid "Cancel order & Clear cart"
|
464 |
msgstr "Cancelar & Limpiar carrito"
|
465 |
|
946 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
947 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
948 |
|
949 |
+
msgid "Click [Place order] button. The bank transfer will be setup and you will be redirected to pay it."
|
950 |
+
msgstr "Haga clic en el botón [Realizar el pedido]. La transferencia bancaria se inicializará y usted será redirigido para pagarla."
|
951 |
+
|
952 |
msgid "Please, select the ticket issuer of your preference."
|
953 |
msgstr "Por favor, seleccione el emisor de su elección."
|
954 |
|
979 |
msgid "ZIP"
|
980 |
msgstr "CÓDIGO POSTAL"
|
981 |
|
982 |
+
msgid "BANK"
|
983 |
+
msgstr "BANCO"
|
984 |
+
|
985 |
+
msgid "PERSON TYPE"
|
986 |
+
msgstr "TIPO DE PERSONA"
|
987 |
+
|
988 |
msgid "You must inform you NAME"
|
989 |
msgstr "Obligatorio informar su NOMBRE"
|
990 |
|
1009 |
msgid "You must inform your ZIP"
|
1010 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
1011 |
|
1012 |
+
msgid "You must inform the FINANCIAL INSTITUTION"
|
1013 |
+
msgstr "Obligatorio informar el BANCO"
|
1014 |
+
|
1015 |
+
msgid "You must inform your PERSON TYPE"
|
1016 |
+
msgstr "Obligatorio informar su TIPO DE PERSONA"
|
1017 |
+
|
1018 |
msgid "Fisical Person"
|
1019 |
msgstr "Persona Física"
|
1020 |
|
i18n/languages/woocommerce-mercadopago-es_UY.po
CHANGED
@@ -457,6 +457,9 @@ msgstr "Su cliente será capaz de utilizar dos tarjetas diferentes para pagar el
|
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
|
|
|
|
|
|
460 |
msgid "Cancel order & Clear cart"
|
461 |
msgstr "Cancelar & Limpiar carrito"
|
462 |
|
@@ -943,6 +946,9 @@ msgstr "Importante: La solicitud sólo será confirmada después de la aprobaci
|
|
943 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
944 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
945 |
|
|
|
|
|
|
|
946 |
msgid "Please, select the ticket issuer of your preference."
|
947 |
msgstr "Por favor, seleccione el emisor de su elección."
|
948 |
|
@@ -973,6 +979,12 @@ msgstr "ESTADO"
|
|
973 |
msgid "ZIP"
|
974 |
msgstr "CÓDIGO POSTAL"
|
975 |
|
|
|
|
|
|
|
|
|
|
|
|
|
976 |
msgid "You must inform you NAME"
|
977 |
msgstr "Obligatorio informar su NOMBRE"
|
978 |
|
@@ -997,6 +1009,12 @@ msgstr "Obligatorio informar su ESTADO"
|
|
997 |
msgid "You must inform your ZIP"
|
998 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
999 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1000 |
msgid "Fisical Person"
|
1001 |
msgstr "Persona Física"
|
1002 |
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
460 |
+
msgid "Thank you for your order. Please, transfer the money to get your order approved."
|
461 |
+
msgstr "Obrigado pela sua compra. Por favor, transfiera el dinero para tener su compra aprobada."
|
462 |
+
|
463 |
msgid "Cancel order & Clear cart"
|
464 |
msgstr "Cancelar & Limpiar carrito"
|
465 |
|
946 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
947 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
948 |
|
949 |
+
msgid "Click [Place order] button. The bank transfer will be setup and you will be redirected to pay it."
|
950 |
+
msgstr "Haga clic en el botón [Realizar el pedido]. La transferencia bancaria se inicializará y usted será redirigido para pagarla."
|
951 |
+
|
952 |
msgid "Please, select the ticket issuer of your preference."
|
953 |
msgstr "Por favor, seleccione el emisor de su elección."
|
954 |
|
979 |
msgid "ZIP"
|
980 |
msgstr "CÓDIGO POSTAL"
|
981 |
|
982 |
+
msgid "BANK"
|
983 |
+
msgstr "BANCO"
|
984 |
+
|
985 |
+
msgid "PERSON TYPE"
|
986 |
+
msgstr "TIPO DE PERSONA"
|
987 |
+
|
988 |
msgid "You must inform you NAME"
|
989 |
msgstr "Obligatorio informar su NOMBRE"
|
990 |
|
1009 |
msgid "You must inform your ZIP"
|
1010 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
1011 |
|
1012 |
+
msgid "You must inform the FINANCIAL INSTITUTION"
|
1013 |
+
msgstr "Obligatorio informar el BANCO"
|
1014 |
+
|
1015 |
+
msgid "You must inform your PERSON TYPE"
|
1016 |
+
msgstr "Obligatorio informar su TIPO DE PERSONA"
|
1017 |
+
|
1018 |
msgid "Fisical Person"
|
1019 |
msgstr "Persona Física"
|
1020 |
|
i18n/languages/woocommerce-mercadopago-es_VE.po
CHANGED
@@ -457,6 +457,9 @@ msgstr "Su cliente será capaz de utilizar dos tarjetas diferentes para pagar el
|
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
|
|
|
|
|
|
460 |
msgid "Cancel order & Clear cart"
|
461 |
msgstr "Cancelar & Limpiar carrito"
|
462 |
|
@@ -943,6 +946,9 @@ msgstr "Importante: La solicitud sólo será confirmada después de la aprobaci
|
|
943 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
944 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
945 |
|
|
|
|
|
|
|
946 |
msgid "Please, select the ticket issuer of your preference."
|
947 |
msgstr "Por favor, seleccione el emisor de su elección."
|
948 |
|
@@ -973,6 +979,12 @@ msgstr "ESTADO"
|
|
973 |
msgid "ZIP"
|
974 |
msgstr "CÓDIGO POSTAL"
|
975 |
|
|
|
|
|
|
|
|
|
|
|
|
|
976 |
msgid "You must inform you NAME"
|
977 |
msgstr "Obligatorio informar su NOMBRE"
|
978 |
|
@@ -997,6 +1009,12 @@ msgstr "Obligatorio informar su ESTADO"
|
|
997 |
msgid "You must inform your ZIP"
|
998 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
999 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1000 |
msgid "Fisical Person"
|
1001 |
msgstr "Persona Física"
|
1002 |
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Gracias por su compra. Por favor, prosiga a la página de pago haciendo click en el botón de abajo."
|
459 |
|
460 |
+
msgid "Thank you for your order. Please, transfer the money to get your order approved."
|
461 |
+
msgstr "Obrigado pela sua compra. Por favor, transfiera el dinero para tener su compra aprobada."
|
462 |
+
|
463 |
msgid "Cancel order & Clear cart"
|
464 |
msgstr "Cancelar & Limpiar carrito"
|
465 |
|
946 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
947 |
msgstr "Haga clic en el botón [Realizar el pedido]. El ticket será generado y usted será redirigido a imprimirlo."
|
948 |
|
949 |
+
msgid "Click [Place order] button. The bank transfer will be setup and you will be redirected to pay it."
|
950 |
+
msgstr "Haga clic en el botón [Realizar el pedido]. La transferencia bancaria se inicializará y usted será redirigido para pagarla."
|
951 |
+
|
952 |
msgid "Please, select the ticket issuer of your preference."
|
953 |
msgstr "Por favor, seleccione el emisor de su elección."
|
954 |
|
979 |
msgid "ZIP"
|
980 |
msgstr "CÓDIGO POSTAL"
|
981 |
|
982 |
+
msgid "BANK"
|
983 |
+
msgstr "BANCO"
|
984 |
+
|
985 |
+
msgid "PERSON TYPE"
|
986 |
+
msgstr "TIPO DE PERSONA"
|
987 |
+
|
988 |
msgid "You must inform you NAME"
|
989 |
msgstr "Obligatorio informar su NOMBRE"
|
990 |
|
1009 |
msgid "You must inform your ZIP"
|
1010 |
msgstr "Obligatorio informar su CÓDIGO POSTAL"
|
1011 |
|
1012 |
+
msgid "You must inform the FINANCIAL INSTITUTION"
|
1013 |
+
msgstr "Obligatorio informar el BANCO"
|
1014 |
+
|
1015 |
+
msgid "You must inform your PERSON TYPE"
|
1016 |
+
msgstr "Obligatorio informar su TIPO DE PERSONA"
|
1017 |
+
|
1018 |
msgid "Fisical Person"
|
1019 |
msgstr "Persona Física"
|
1020 |
|
i18n/languages/woocommerce-mercadopago-pt_BR.po
CHANGED
@@ -457,6 +457,9 @@ msgstr "Seus clientes poderão utilizar dois diferentes cartões para pagar pedi
|
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Obrigado pela sua compra. Por favor, prossiga para a página de pagamento clicando no botão abaixo."
|
459 |
|
|
|
|
|
|
|
460 |
msgid "Cancel order & Clear cart"
|
461 |
msgstr "Cancelar & Limpar carrinho"
|
462 |
|
@@ -943,6 +946,9 @@ msgstr "Importante: O pedido só será confirmado após a aprovação do pagamen
|
|
943 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
944 |
msgstr "Clique no botão [Finalizar compra]. O boleto será gerado e você será redirecionado para imprimí-lo."
|
945 |
|
|
|
|
|
|
|
946 |
msgid "Please, select the ticket issuer of your preference."
|
947 |
msgstr "Por favor, selecione o emissor de sua preferência."
|
948 |
|
@@ -973,6 +979,12 @@ msgstr "ESTADO"
|
|
973 |
msgid "ZIP"
|
974 |
msgstr "CEP"
|
975 |
|
|
|
|
|
|
|
|
|
|
|
|
|
976 |
msgid "You must inform you NAME"
|
977 |
msgstr "Obrigatório o preenchimento do Nome"
|
978 |
|
@@ -997,6 +1009,12 @@ msgstr "Obrigatório informar o estado"
|
|
997 |
msgid "You must inform your ZIP"
|
998 |
msgstr "Obrigatório informar o CEP"
|
999 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1000 |
msgid "Fisical Person"
|
1001 |
msgstr "Pessoa Física"
|
1002 |
|
457 |
msgid "Thank you for your order. Please, proceed with your payment clicking in the bellow button."
|
458 |
msgstr "Obrigado pela sua compra. Por favor, prossiga para a página de pagamento clicando no botão abaixo."
|
459 |
|
460 |
+
msgid "Thank you for your order. Please, transfer the money to get your order approved."
|
461 |
+
msgstr "Obrigado pela sua compra. Por favor, transfira o dinheiro para ter seu pedido aprovado."
|
462 |
+
|
463 |
msgid "Cancel order & Clear cart"
|
464 |
msgstr "Cancelar & Limpar carrinho"
|
465 |
|
946 |
msgid "Click [Place order] button. The ticket will be generated and you will be redirected to print it."
|
947 |
msgstr "Clique no botão [Finalizar compra]. O boleto será gerado e você será redirecionado para imprimí-lo."
|
948 |
|
949 |
+
msgid "Click [Place order] button. The bank transfer will be setup and you will be redirected to pay it."
|
950 |
+
msgstr "Clique no botão [Finalizar compra]. A tranferência bancária será inicializada e você será redirecionado para pagá-la."
|
951 |
+
|
952 |
msgid "Please, select the ticket issuer of your preference."
|
953 |
msgstr "Por favor, selecione o emissor de sua preferência."
|
954 |
|
979 |
msgid "ZIP"
|
980 |
msgstr "CEP"
|
981 |
|
982 |
+
msgid "BANK"
|
983 |
+
msgstr "BANCO"
|
984 |
+
|
985 |
+
msgid "PERSON TYPE"
|
986 |
+
msgstr "TIPO DE PESSOA"
|
987 |
+
|
988 |
msgid "You must inform you NAME"
|
989 |
msgstr "Obrigatório o preenchimento do Nome"
|
990 |
|
1009 |
msgid "You must inform your ZIP"
|
1010 |
msgstr "Obrigatório informar o CEP"
|
1011 |
|
1012 |
+
msgid "You must inform the FINANCIAL INSTITUTION"
|
1013 |
+
msgstr "Obrigatório informar o BANCO"
|
1014 |
+
|
1015 |
+
msgid "You must inform your PERSON TYPE"
|
1016 |
+
msgstr "Obrigatório informar seu TIPO DE PESSOA"
|
1017 |
+
|
1018 |
msgid "Fisical Person"
|
1019 |
msgstr "Pessoa Física"
|
1020 |
|
i18n/languages/woocommerce-mercadopago.pot
CHANGED
File without changes
|
includes/WC_WooMercadoPago_BasicGateway.php
CHANGED
@@ -1322,7 +1322,7 @@ class WC_WooMercadoPago_BasicGateway extends WC_Payment_Gateway {
|
|
1322 |
break;
|
1323 |
case 'rejected':
|
1324 |
$order->update_status(
|
1325 |
-
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( '
|
1326 |
'Mercado Pago: ' . __( 'The payment was refused. The customer can try again.', 'woocommerce-mercadopago' )
|
1327 |
);
|
1328 |
break;
|
1322 |
break;
|
1323 |
case 'rejected':
|
1324 |
$order->update_status(
|
1325 |
+
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( 'rejected' ),
|
1326 |
'Mercado Pago: ' . __( 'The payment was refused. The customer can try again.', 'woocommerce-mercadopago' )
|
1327 |
);
|
1328 |
break;
|
includes/WC_WooMercadoPago_CustomGateway.php
CHANGED
@@ -1350,7 +1350,7 @@ class WC_WooMercadoPago_CustomGateway extends WC_Payment_Gateway {
|
|
1350 |
break;
|
1351 |
case 'rejected':
|
1352 |
$order->update_status(
|
1353 |
-
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( '
|
1354 |
'Mercado Pago: ' . __( 'The payment was refused. The customer can try again.', 'woocommerce-mercadopago' )
|
1355 |
);
|
1356 |
break;
|
1350 |
break;
|
1351 |
case 'rejected':
|
1352 |
$order->update_status(
|
1353 |
+
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( 'rejected' ),
|
1354 |
'Mercado Pago: ' . __( 'The payment was refused. The customer can try again.', 'woocommerce-mercadopago' )
|
1355 |
);
|
1356 |
break;
|
includes/WC_WooMercadoPago_PSEGateway.php
ADDED
@@ -0,0 +1,1315 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Part of Woo Mercado Pago Module
|
5 |
+
* Author - Mercado Pago
|
6 |
+
* Developer - Marcelo Mita / marcelo.mita@mercadolivre.com
|
7 |
+
* Copyright - Copyright(c) MercadoPago [https://www.mercadopago.com]
|
8 |
+
* License - https://www.gnu.org/licenses/gpl.html GPL version 2 or higher
|
9 |
+
*/
|
10 |
+
|
11 |
+
// This include Mercado Pago library SDK
|
12 |
+
require_once dirname( __FILE__ ) . '/sdk/lib/mercadopago.php';
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Summary: Extending from WooCommerce Payment Gateway class.
|
16 |
+
* Description: This class implements Mercado Pago pse payment method.
|
17 |
+
* @since 3.0.16
|
18 |
+
*/
|
19 |
+
class WC_WooMercadoPago_PSEGateway extends WC_Payment_Gateway {
|
20 |
+
|
21 |
+
public function __construct( $is_instance = false ) {
|
22 |
+
|
23 |
+
// Mercao Pago instance.
|
24 |
+
$this->site_data = WC_Woo_Mercado_Pago_Module::get_site_data( true );
|
25 |
+
$this->mp = new MP(
|
26 |
+
WC_Woo_Mercado_Pago_Module::get_module_version(),
|
27 |
+
get_option( '_mp_access_token' )
|
28 |
+
);
|
29 |
+
$email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
|
30 |
+
$this->mp->set_email( $email );
|
31 |
+
$locale = get_locale();
|
32 |
+
$locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
|
33 |
+
$this->mp->set_locale( $locale[1] );
|
34 |
+
|
35 |
+
// WooCommerce fields.
|
36 |
+
$this->id = 'woo-mercado-pago-pse';
|
37 |
+
$this->supports = array( 'products', 'refunds' );
|
38 |
+
$this->icon = apply_filters(
|
39 |
+
'woocommerce_mercadopago_icon',
|
40 |
+
plugins_url( 'assets/images/mercadopago.png', plugin_dir_path( __FILE__ ) )
|
41 |
+
);
|
42 |
+
|
43 |
+
$this->method_title = __( 'Mercado Pago - PSE', 'woocommerce-mercadopago' );
|
44 |
+
$this->method_description = '<img width="200" height="52" src="' .
|
45 |
+
plugins_url( 'assets/images/mplogo.png', plugin_dir_path( __FILE__ ) ) .
|
46 |
+
'"><br><br><strong>' .
|
47 |
+
__( 'We give you the possibility to adapt the payment experience you want to offer 100% in your website, mobile app or anywhere you want. You can build the design that best fits your business model, aiming to maximize conversion.', 'woocommerce-mercadopago' ) .
|
48 |
+
'</strong>';
|
49 |
+
|
50 |
+
//$this->sandbox = get_option( '_mp_sandbox_mode', false );
|
51 |
+
$this->sandbox = false;
|
52 |
+
$this->mp->sandbox_mode( $this->sandbox );
|
53 |
+
|
54 |
+
// How checkout is shown.
|
55 |
+
$this->title = $this->get_option( 'title', __( 'Mercado Pago - PSE', 'woocommerce-mercadopago' ) );
|
56 |
+
$this->description = $this->get_option( 'description' );
|
57 |
+
// How checkout payment behaves.
|
58 |
+
// $this->coupon_mode = $this->get_option( 'coupon_mode', 'no' );
|
59 |
+
$this->stock_reduce_mode = $this->get_option( 'stock_reduce_mode', 'no' );
|
60 |
+
$this->gateway_discount = $this->get_option( 'gateway_discount', 0 );
|
61 |
+
|
62 |
+
// Logging and debug.
|
63 |
+
$_mp_debug_mode = get_option( '_mp_debug_mode', '' );
|
64 |
+
if ( ! empty ( $_mp_debug_mode ) ) {
|
65 |
+
if ( class_exists( 'WC_Logger' ) ) {
|
66 |
+
$this->log = new WC_Logger();
|
67 |
+
} else {
|
68 |
+
$this->log = WC_Woo_Mercado_Pago_Module::woocommerce_instance()->logger();
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
// Render our configuration page and init/load fields.
|
73 |
+
$this->init_form_fields();
|
74 |
+
$this->init_settings();
|
75 |
+
|
76 |
+
// Used by IPN to receive IPN incomings.
|
77 |
+
add_action(
|
78 |
+
'woocommerce_api_wc_woomercadopago_psegateway',
|
79 |
+
array( $this, 'check_ipn_response' )
|
80 |
+
);
|
81 |
+
// Used by IPN to process valid incomings.
|
82 |
+
add_action(
|
83 |
+
'valid_mercadopago_pse_ipn_request',
|
84 |
+
array( $this, 'successful_request' )
|
85 |
+
);
|
86 |
+
// process the cancel order meta box order action
|
87 |
+
add_action(
|
88 |
+
'woocommerce_order_action_cancel_order',
|
89 |
+
array( $this, 'process_cancel_order_meta_box_actions' )
|
90 |
+
);
|
91 |
+
// Used in settings page to hook "save settings" action.
|
92 |
+
add_action(
|
93 |
+
'woocommerce_update_options_payment_gateways_' . $this->id,
|
94 |
+
array( $this, 'custom_process_admin_options' )
|
95 |
+
);
|
96 |
+
// Scripts for custom checkout.
|
97 |
+
add_action(
|
98 |
+
'wp_enqueue_scripts',
|
99 |
+
array( $this, 'add_checkout_scripts_pse' )
|
100 |
+
);
|
101 |
+
// Apply the discounts.
|
102 |
+
add_action(
|
103 |
+
'woocommerce_cart_calculate_fees',
|
104 |
+
array( $this, 'add_discount_pse' ), 10
|
105 |
+
);
|
106 |
+
// Display discount in payment method title.
|
107 |
+
add_filter(
|
108 |
+
'woocommerce_gateway_title',
|
109 |
+
array( $this, 'get_payment_method_title_pse' ), 10, 2
|
110 |
+
);
|
111 |
+
|
112 |
+
if ( ! empty( $this->settings['enabled'] ) && $this->settings['enabled'] == 'yes' ) {
|
113 |
+
if ( ! $is_instance ) {
|
114 |
+
// Scripts for order configuration.
|
115 |
+
add_action(
|
116 |
+
'woocommerce_after_checkout_form',
|
117 |
+
array( $this, 'add_mp_settings_script_pse' )
|
118 |
+
);
|
119 |
+
// Checkout updates.
|
120 |
+
add_action(
|
121 |
+
'woocommerce_thankyou_' . $this->id,
|
122 |
+
array( $this, 'update_mp_settings_script_pse' )
|
123 |
+
);
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Summary: Initialise Gateway Settings Form Fields.
|
131 |
+
* Description: Initialise Gateway settings form fields with a customized page.
|
132 |
+
*/
|
133 |
+
public function init_form_fields() {
|
134 |
+
|
135 |
+
// Show message if credentials are not properly configured.
|
136 |
+
$_site_id_v1 = get_option( '_site_id_v1', '' );
|
137 |
+
if ( empty( $_site_id_v1 ) ) {
|
138 |
+
$this->form_fields = array(
|
139 |
+
'no_credentials_title' => array(
|
140 |
+
'title' => sprintf(
|
141 |
+
__( 'It appears that your credentials are not properly configured.<br/>Please, go to %s and configure it.', 'woocommerce-mercadopago' ),
|
142 |
+
'<a href="' . esc_url( admin_url( 'admin.php?page=mercado-pago-settings' ) ) . '">' .
|
143 |
+
__( 'Mercado Pago Settings', 'woocommerce-mercadopago' ) .
|
144 |
+
'</a>'
|
145 |
+
),
|
146 |
+
'type' => 'title'
|
147 |
+
),
|
148 |
+
);
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
|
152 |
+
// If module is disabled, we do not need to load and process the settings page.
|
153 |
+
if ( empty( $this->settings['enabled'] ) || 'no' == $this->settings['enabled'] ) {
|
154 |
+
$this->form_fields = array(
|
155 |
+
'enabled' => array(
|
156 |
+
'title' => __( 'Enable/Disable', 'woocommerce-mercadopago' ),
|
157 |
+
'type' => 'checkbox',
|
158 |
+
'label' => __( 'Enable PSE Payment Method', 'woocommerce-mercadopago' ),
|
159 |
+
'default' => 'no'
|
160 |
+
)
|
161 |
+
);
|
162 |
+
return;
|
163 |
+
}
|
164 |
+
|
165 |
+
// This array draws each UI (text, selector, checkbox, label, etc).
|
166 |
+
$this->form_fields = array(
|
167 |
+
'enabled' => array(
|
168 |
+
'title' => __( 'Enable/Disable', 'woocommerce-mercadopago' ),
|
169 |
+
'type' => 'checkbox',
|
170 |
+
'label' => __( 'Enable PSE Payment Method', 'woocommerce-mercadopago' ),
|
171 |
+
'default' => 'no'
|
172 |
+
),
|
173 |
+
'checkout_options_title' => array(
|
174 |
+
'title' => __( 'PSE Interface: How checkout is shown', 'woocommerce-mercadopago' ),
|
175 |
+
'type' => 'title'
|
176 |
+
),
|
177 |
+
'title' => array(
|
178 |
+
'title' => __( 'Title', 'woocommerce-mercadopago' ),
|
179 |
+
'type' => 'text',
|
180 |
+
'description' => __( 'Title shown to the client in the pse.', 'woocommerce-mercadopago' ),
|
181 |
+
'default' => __( 'Mercado Pago - PSE', 'woocommerce-mercadopago' )
|
182 |
+
),
|
183 |
+
'description' => array(
|
184 |
+
'title' => __( 'Description', 'woocommerce-mercadopago' ),
|
185 |
+
'type' => 'textarea',
|
186 |
+
'description' => __( 'Description shown to the client in the pse.', 'woocommerce-mercadopago' ),
|
187 |
+
'default' => __( 'Pay with Mercado Pago', 'woocommerce-mercadopago' )
|
188 |
+
),
|
189 |
+
'payment_title' => array(
|
190 |
+
'title' => __( 'Payment Options: How payment options behaves', 'woocommerce-mercadopago' ),
|
191 |
+
'type' => 'title'
|
192 |
+
),
|
193 |
+
// 'coupon_mode' => array(
|
194 |
+
// 'title' => __( 'Coupons', 'woocommerce-mercadopago' ),
|
195 |
+
// 'type' => 'checkbox',
|
196 |
+
// 'label' => __( 'Enable coupons of discounts', 'woocommerce-mercadopago' ),
|
197 |
+
// 'default' => 'no',
|
198 |
+
// 'description' => __( 'If there is a Mercado Pago campaign, allow your store to give discounts to customers.', 'woocommerce-mercadopago' )
|
199 |
+
// ),
|
200 |
+
'stock_reduce_mode' => array(
|
201 |
+
'title' => __( 'Stock Reduce', 'woocommerce-mercadopago' ),
|
202 |
+
'type' => 'checkbox',
|
203 |
+
'label' => __( 'Reduce Stock in Order Generation', 'woocommerce-mercadopago' ),
|
204 |
+
'default' => 'no',
|
205 |
+
'description' => __( 'Enable this to reduce the stock on order creation. Disable this to reduce <strong>after</strong> the payment approval.', 'woocommerce-mercadopago' )
|
206 |
+
),
|
207 |
+
'gateway_discount' => array(
|
208 |
+
'title' => __( 'Discount/Fee by Gateway', 'woocommerce-mercadopago' ),
|
209 |
+
'type' => 'number',
|
210 |
+
'description' => __( 'Give a percentual (-99 to 99) discount or fee for your customers if they use this payment gateway. Use negative for fees, positive for discounts.', 'woocommerce-mercadopago' ),
|
211 |
+
'default' => '0',
|
212 |
+
'custom_attributes' => array(
|
213 |
+
'step' => '0.01',
|
214 |
+
'min' => '-99',
|
215 |
+
'max' => '99'
|
216 |
+
)
|
217 |
+
)
|
218 |
+
);
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Processes and saves options.
|
223 |
+
* If there is an error thrown, will continue to save and validate fields, but will leave the
|
224 |
+
* erroring field out.
|
225 |
+
* @return bool was anything saved?
|
226 |
+
*/
|
227 |
+
public function custom_process_admin_options() {
|
228 |
+
$this->init_settings();
|
229 |
+
$post_data = $this->get_post_data();
|
230 |
+
foreach ( $this->get_form_fields() as $key => $field ) {
|
231 |
+
if ( 'title' !== $this->get_field_type( $field ) ) {
|
232 |
+
$value = $this->get_field_value( $key, $field, $post_data );
|
233 |
+
if ( $key == 'gateway_discount') {
|
234 |
+
if ( ! is_numeric( $value ) || empty ( $value ) || $value < -99 || $value > 99 ) {
|
235 |
+
$this->settings[$key] = 0;
|
236 |
+
} else {
|
237 |
+
$this->settings[$key] = $value;
|
238 |
+
}
|
239 |
+
} else {
|
240 |
+
$this->settings[$key] = $this->get_field_value( $key, $field, $post_data );
|
241 |
+
}
|
242 |
+
}
|
243 |
+
}
|
244 |
+
$_site_id_v1 = get_option( '_site_id_v1', '' );
|
245 |
+
$is_test_user = get_option( '_test_user_v1', false );
|
246 |
+
if ( ! empty( $_site_id_v1 ) && ! $is_test_user ) {
|
247 |
+
// Create MP instance.
|
248 |
+
$mp = new MP(
|
249 |
+
WC_Woo_Mercado_Pago_Module::get_module_version(),
|
250 |
+
get_option( '_mp_access_token' )
|
251 |
+
);
|
252 |
+
$email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
|
253 |
+
$mp->set_email( $email );
|
254 |
+
$locale = get_locale();
|
255 |
+
$locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
|
256 |
+
$mp->set_locale( $locale[1] );
|
257 |
+
// Analytics.
|
258 |
+
$infra_data = WC_Woo_Mercado_Pago_Module::get_common_settings();
|
259 |
+
$infra_data['checkout_custom_pse'] = ( $this->settings['enabled'] == 'yes' ? 'true' : 'false' );
|
260 |
+
// $infra_data['checkout_custom_pse_coupon'] = ( $this->settings['coupon_mode'] == 'yes' ? 'true' : 'false' );
|
261 |
+
$response = $mp->analytics_save_settings( $infra_data );
|
262 |
+
}
|
263 |
+
// Apply updates.
|
264 |
+
return update_option(
|
265 |
+
$this->get_option_key(),
|
266 |
+
apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $this->id, $this->settings )
|
267 |
+
);
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Handles the manual order refunding in server-side.
|
272 |
+
*/
|
273 |
+
public function process_refund( $order_id, $amount = null, $reason = '' ) {
|
274 |
+
|
275 |
+
$payments = get_post_meta( $order_id, '_Mercado_Pago_Payment_IDs', true );
|
276 |
+
|
277 |
+
// Validate.
|
278 |
+
if ( $this->mp == null || empty( $payments ) ) {
|
279 |
+
$this->write_log( __FUNCTION__, 'no payments or credentials invalid' );
|
280 |
+
return false;
|
281 |
+
}
|
282 |
+
|
283 |
+
// Processing data about this refund.
|
284 |
+
$total_available = 0;
|
285 |
+
$payment_structs = array();
|
286 |
+
$payment_ids = explode( ', ', $payments );
|
287 |
+
foreach ( $payment_ids as $p_id ) {
|
288 |
+
$p = get_post_meta( $order_id, 'Mercado Pago - Payment ' . $p_id, true );
|
289 |
+
$p = explode( '/', $p );
|
290 |
+
$paid_arr = explode( ' ', substr( $p[2], 1, -1 ) );
|
291 |
+
$paid = ( (float) $paid_arr[1] );
|
292 |
+
$refund_arr = explode( ' ', substr( $p[3], 1, -1 ) );
|
293 |
+
$refund = ( (float) $refund_arr[1] );
|
294 |
+
$p_struct = array( 'id' => $p_id, 'available_to_refund' => $paid - $refund );
|
295 |
+
$total_available += $paid - $refund;
|
296 |
+
$payment_structs[] = $p_struct;
|
297 |
+
}
|
298 |
+
|
299 |
+
$this->write_log( __FUNCTION__,
|
300 |
+
'refunding ' . $amount . ' because of ' . $reason . ' and payments ' .
|
301 |
+
json_encode( $payment_structs, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE )
|
302 |
+
);
|
303 |
+
|
304 |
+
// Do not allow refund more than available or invalid amounts.
|
305 |
+
if ( $amount > $total_available || $amount <= 0 ) {
|
306 |
+
return false;
|
307 |
+
}
|
308 |
+
|
309 |
+
// Iteratively refunfind amount, taking in consideration multiple payments.
|
310 |
+
$remaining_to_refund = $amount;
|
311 |
+
foreach ( $payment_structs as $to_refund ) {
|
312 |
+
if ( $remaining_to_refund <= $to_refund['available_to_refund'] ) {
|
313 |
+
// We want to refund an amount that is less than the available for this payment, so we
|
314 |
+
// can just refund and return.
|
315 |
+
$response = $this->mp->partial_refund_payment(
|
316 |
+
$to_refund['id'], $remaining_to_refund,
|
317 |
+
$reason, $this->invoice_prefix . $order_id
|
318 |
+
);
|
319 |
+
$message = $response['response']['message'];
|
320 |
+
$status = $response['status'];
|
321 |
+
$this->write_log( __FUNCTION__,
|
322 |
+
'refund payment of id ' . $p_id . ' => ' .
|
323 |
+
( $status >= 200 && $status < 300 ? 'SUCCESS' : 'FAIL - ' . $message )
|
324 |
+
);
|
325 |
+
if ( $status >= 200 && $status < 300 ) {
|
326 |
+
return true;
|
327 |
+
} else {
|
328 |
+
return false;
|
329 |
+
}
|
330 |
+
} elseif ( $to_refund['available_to_refund'] > 0 ) {
|
331 |
+
// We want to refund an amount that exceeds the available for this payment, so we
|
332 |
+
// totally refund this payment, and try to complete refund in other/next payments.
|
333 |
+
$response = $this->mp->partial_refund_payment(
|
334 |
+
$to_refund['id'], $to_refund['available_to_refund'],
|
335 |
+
$reason, $this->invoice_prefix . $order_id
|
336 |
+
);
|
337 |
+
$message = $response['response']['message'];
|
338 |
+
$status = $response['status'];
|
339 |
+
$this->write_log( __FUNCTION__,
|
340 |
+
'refund payment of id ' . $p_id . ' => ' .
|
341 |
+
( $status >= 200 && $status < 300 ? 'SUCCESS' : 'FAIL - ' . $message )
|
342 |
+
);
|
343 |
+
if ( $status < 200 || $status >= 300 ) {
|
344 |
+
return false;
|
345 |
+
}
|
346 |
+
$remaining_to_refund -= $to_refund['available_to_refund'];
|
347 |
+
}
|
348 |
+
if ( $remaining_to_refund == 0 )
|
349 |
+
return true;
|
350 |
+
}
|
351 |
+
|
352 |
+
// Reaching here means that there we run out of payments, and there is an amount
|
353 |
+
// remaining to be refund, which is impossible as it implies refunding more than
|
354 |
+
// available on paid amounts.
|
355 |
+
return false;
|
356 |
+
}
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Handles the manual order cancellation in server-side.
|
360 |
+
*/
|
361 |
+
public function process_cancel_order_meta_box_actions( $order ) {
|
362 |
+
|
363 |
+
$used_gateway = ( method_exists( $order, 'get_meta' ) ) ?
|
364 |
+
$order->get_meta( '_used_gateway' ) :
|
365 |
+
get_post_meta( $order->id, '_used_gateway', true );
|
366 |
+
$payments = ( method_exists( $order, 'get_meta' ) ) ?
|
367 |
+
$order->get_meta( '_Mercado_Pago_Payment_IDs' ) :
|
368 |
+
get_post_meta( $order->id, '_Mercado_Pago_Payment_IDs', true );
|
369 |
+
|
370 |
+
// A watchdog to prevent operations from other gateways.
|
371 |
+
if ( $used_gateway != 'WC_WooMercadoPago_PSEGateway' ) {
|
372 |
+
return;
|
373 |
+
}
|
374 |
+
|
375 |
+
$this->write_log( __FUNCTION__, 'cancelling payments for ' . $payments );
|
376 |
+
|
377 |
+
// Canceling the order and all of its payments.
|
378 |
+
if ( $this->mp != null && ! empty( $payments ) ) {
|
379 |
+
$payment_ids = explode( ', ', $payments );
|
380 |
+
foreach ( $payment_ids as $p_id ) {
|
381 |
+
$response = $this->mp->cancel_payment( $p_id );
|
382 |
+
$message = $response['response']['message'];
|
383 |
+
$status = $response['status'];
|
384 |
+
$this->write_log( __FUNCTION__,
|
385 |
+
'cancel payment of id ' . $p_id . ' => ' .
|
386 |
+
( $status >= 200 && $status < 300 ? 'SUCCESS' : 'FAIL - ' . $message )
|
387 |
+
);
|
388 |
+
}
|
389 |
+
} else {
|
390 |
+
$this->write_log( __FUNCTION__, 'no payments or credentials invalid' );
|
391 |
+
}
|
392 |
+
}
|
393 |
+
|
394 |
+
// Write log.
|
395 |
+
private function write_log( $function, $message ) {
|
396 |
+
$_mp_debug_mode = get_option( '_mp_debug_mode', '' );
|
397 |
+
if ( ! empty ( $_mp_debug_mode ) ) {
|
398 |
+
$this->log->add(
|
399 |
+
$this->id,
|
400 |
+
'[' . $function . ']: ' . $message
|
401 |
+
);
|
402 |
+
}
|
403 |
+
}
|
404 |
+
|
405 |
+
/*
|
406 |
+
* ========================================================================
|
407 |
+
* CHECKOUT BUSINESS RULES (CLIENT SIDE)
|
408 |
+
* ========================================================================
|
409 |
+
*/
|
410 |
+
|
411 |
+
public function add_mp_settings_script_pse() {
|
412 |
+
$client_id = WC_Woo_Mercado_Pago_Module::get_client_id( get_option( '_mp_access_token' ) );
|
413 |
+
$is_test_user = get_option( '_test_user_v1', false );
|
414 |
+
if ( ! empty( $client_id ) && ! $is_test_user ) {
|
415 |
+
$w = WC_Woo_Mercado_Pago_Module::woocommerce_instance();
|
416 |
+
$available_payments = array();
|
417 |
+
$gateways = WC()->payment_gateways->get_available_payment_gateways();
|
418 |
+
foreach ( $gateways as $g ) {
|
419 |
+
$available_payments[] = $g->id;
|
420 |
+
}
|
421 |
+
$available_payments = str_replace( '-', '_', implode( ', ', $available_payments ) );
|
422 |
+
if ( wp_get_current_user()->ID != 0 ) {
|
423 |
+
$logged_user_email = wp_get_current_user()->user_email;
|
424 |
+
} else {
|
425 |
+
$logged_user_email = null;
|
426 |
+
}
|
427 |
+
?>
|
428 |
+
<script src="https://secure.mlstatic.com/modules/javascript/analytics.js"></script>
|
429 |
+
<script type="text/javascript">
|
430 |
+
try {
|
431 |
+
var MA = ModuleAnalytics;
|
432 |
+
MA.setToken( '<?php echo $client_id; ?>' );
|
433 |
+
MA.setPlatform( 'WooCommerce' );
|
434 |
+
MA.setPlatformVersion( '<?php echo $w->version; ?>' );
|
435 |
+
MA.setModuleVersion( '<?php echo WC_Woo_Mercado_Pago_Module::VERSION; ?>' );
|
436 |
+
MA.setPayerEmail( '<?php echo ( $logged_user_email != null ? $logged_user_email : "" ); ?>' );
|
437 |
+
MA.setUserLogged( <?php echo ( empty( $logged_user_email ) ? 0 : 1 ); ?> );
|
438 |
+
MA.setInstalledModules( '<?php echo $available_payments; ?>' );
|
439 |
+
MA.post();
|
440 |
+
} catch(err) {}
|
441 |
+
</script>
|
442 |
+
<?php
|
443 |
+
}
|
444 |
+
}
|
445 |
+
|
446 |
+
public function update_mp_settings_script_pse( $order_id ) {
|
447 |
+
$access_token = get_option( '_mp_access_token' );
|
448 |
+
$is_test_user = get_option( '_test_user_v1', false );
|
449 |
+
if ( ! empty( $access_token ) && ! $is_test_user ) {
|
450 |
+
if ( get_post_meta( $order_id, '_used_gateway', true ) != 'WC_WooMercadoPago_PSEGateway' ) {
|
451 |
+
return;
|
452 |
+
}
|
453 |
+
$this->write_log( __FUNCTION__, 'updating order of ID ' . $order_id );
|
454 |
+
echo '<script src="https://secure.mlstatic.com/modules/javascript/analytics.js"></script>
|
455 |
+
<script type="text/javascript">
|
456 |
+
try {
|
457 |
+
var MA = ModuleAnalytics;
|
458 |
+
MA.setToken( ' . $access_token . ' );
|
459 |
+
MA.setPaymentType("pse");
|
460 |
+
MA.setCheckoutType("custom");
|
461 |
+
MA.put();
|
462 |
+
} catch(err) {}
|
463 |
+
</script>';
|
464 |
+
}
|
465 |
+
|
466 |
+
$order = wc_get_order( $order_id );
|
467 |
+
$used_gateway = ( method_exists( $order, 'get_meta' ) ) ?
|
468 |
+
$order->get_meta( '_used_gateway' ) :
|
469 |
+
get_post_meta( $order->id, '_used_gateway', true );
|
470 |
+
$transaction_details = ( method_exists( $order, 'get_meta' ) ) ?
|
471 |
+
$order->get_meta( '_transaction_details_pse' ) :
|
472 |
+
get_post_meta( $order->id, '_transaction_details_pse', true );
|
473 |
+
|
474 |
+
// A watchdog to prevent operations from other gateways.
|
475 |
+
if ( $used_gateway != 'WC_WooMercadoPago_PSEGateway' || empty( $transaction_details ) ) {
|
476 |
+
return;
|
477 |
+
}
|
478 |
+
|
479 |
+
$html = '<p>' .
|
480 |
+
__( 'Thank you for your order. Please, transfer the money to get your order approved.', 'woocommerce-mercadopago' ) .
|
481 |
+
'</p>' .
|
482 |
+
'<p><iframe src="' . $transaction_details . '" style="width:100%; height:1000px;"></iframe></p>' .
|
483 |
+
'<a id="submit-payment" target="_blank" href="' . $transaction_details . '" class="button alt"' .
|
484 |
+
' style="font-size:1.25rem; width:75%; height:48px; line-height:24px; text-align:center;">' .
|
485 |
+
__( 'Transfer', 'woocommerce-mercadopago' ) .
|
486 |
+
'</a> ';
|
487 |
+
$added_text = '<p>' . $html . '</p>';
|
488 |
+
echo $added_text;
|
489 |
+
}
|
490 |
+
|
491 |
+
public function add_checkout_scripts_pse() {
|
492 |
+
if ( is_checkout() && $this->is_available() ) {
|
493 |
+
if ( ! get_query_var( 'order-received' ) ) {
|
494 |
+
wp_enqueue_style(
|
495 |
+
'woocommerce-mercadopago-style',
|
496 |
+
plugins_url( 'assets/css/custom_checkout_mercadopago.css', plugin_dir_path( __FILE__ ) )
|
497 |
+
);
|
498 |
+
wp_enqueue_script(
|
499 |
+
'woocommerce-mercadopago-pse-js',
|
500 |
+
'https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js'
|
501 |
+
);
|
502 |
+
}
|
503 |
+
}
|
504 |
+
}
|
505 |
+
|
506 |
+
public function payment_fields() {
|
507 |
+
|
508 |
+
$amount = $this->get_order_total();
|
509 |
+
$logged_user_email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
|
510 |
+
$customer = isset( $logged_user_email ) ? $this->mp->get_or_create_customer( $logged_user_email ) : null;
|
511 |
+
$discount_action_url = get_site_url() . '/index.php/woocommerce-mercadopago/?wc-api=WC_WooMercadoPago_PSEGateway';
|
512 |
+
$address = get_user_meta( wp_get_current_user()->ID, 'shipping_address_1', true );
|
513 |
+
$address_2 = get_user_meta( wp_get_current_user()->ID, 'shipping_address_2', true );
|
514 |
+
$address .= ( ! empty( $address_2 ) ? ' - ' . $address_2 : '' );
|
515 |
+
$country = get_user_meta( wp_get_current_user()->ID, 'shipping_country', true );
|
516 |
+
$address .= ( ! empty( $country ) ? ' - ' . $country : '' );
|
517 |
+
|
518 |
+
$currency_ratio = 1;
|
519 |
+
$_mp_currency_conversion_v1 = get_option( '_mp_currency_conversion_v1', '' );
|
520 |
+
if ( ! empty( $_mp_currency_conversion_v1 ) ) {
|
521 |
+
$currency_ratio = WC_Woo_Mercado_Pago_Module::get_conversion_rate( $this->site_data['currency'] );
|
522 |
+
$currency_ratio = $currency_ratio > 0 ? $currency_ratio : 1;
|
523 |
+
}
|
524 |
+
|
525 |
+
$payment_methods = $this->mp->get_payment_methods();
|
526 |
+
$financial_institutions = null;
|
527 |
+
if($payment_methods['status'] == '200') {
|
528 |
+
foreach($payment_methods['response'] as $payment_method) {
|
529 |
+
if( $payment_method['id'] == 'pse' ) {
|
530 |
+
$financial_institutions = $payment_method['financial_institutions'];
|
531 |
+
}
|
532 |
+
}
|
533 |
+
}
|
534 |
+
|
535 |
+
|
536 |
+
$parameters = array(
|
537 |
+
'amount' => $amount,
|
538 |
+
// ===
|
539 |
+
'site_id' => get_option( '_site_id_v1' ),
|
540 |
+
// 'coupon_mode' => isset( $logged_user_email ) ? $this->coupon_mode : 'no',
|
541 |
+
'discount_action_url' => $discount_action_url,
|
542 |
+
'payer_email' => $logged_user_email,
|
543 |
+
// ===
|
544 |
+
'images_path' => plugins_url( 'assets/images/', plugin_dir_path( __FILE__ ) ),
|
545 |
+
'currency_ratio' => $currency_ratio,
|
546 |
+
'woocommerce_currency' => get_woocommerce_currency(),
|
547 |
+
'account_currency' => $this->site_data['currency'],
|
548 |
+
// ===
|
549 |
+
'financial_institutions' => $financial_institutions,
|
550 |
+
'pse_data' => array(
|
551 |
+
'docType' => '',
|
552 |
+
'docNumber' => '',
|
553 |
+
'bank' => '',
|
554 |
+
'personType' => ''
|
555 |
+
),
|
556 |
+
'path_to_javascript' => plugins_url( 'assets/js/pse.js', plugin_dir_path( __FILE__ ) )
|
557 |
+
);
|
558 |
+
|
559 |
+
wc_get_template(
|
560 |
+
'pse/pse-form.php',
|
561 |
+
$parameters,
|
562 |
+
'woo/mercado/pago/module/',
|
563 |
+
WC_Woo_Mercado_Pago_Module::get_templates_path()
|
564 |
+
);
|
565 |
+
}
|
566 |
+
|
567 |
+
/**
|
568 |
+
* Summary: Handle the payment and processing the order.
|
569 |
+
* Description: This function is called after we click on [place_order] button, and each field is
|
570 |
+
* passed to this function through $_POST variable.
|
571 |
+
* @return an array containing the result of the processment and the URL to redirect.
|
572 |
+
*/
|
573 |
+
public function process_payment( $order_id ) {
|
574 |
+
|
575 |
+
if ( ! isset( $_POST['mercadopago_pse'] ) ) {
|
576 |
+
return;
|
577 |
+
}
|
578 |
+
$pse_checkout = apply_filters( 'wc_mercadopagopse_pse_checkout', $_POST['mercadopago_pse'] );
|
579 |
+
|
580 |
+
$order = wc_get_order( $order_id );
|
581 |
+
|
582 |
+
if ( method_exists( $order, 'update_meta_data' ) ) {
|
583 |
+
$order->update_meta_data( '_used_gateway', 'WC_WooMercadoPago_PSEGateway' );
|
584 |
+
$order->save();
|
585 |
+
} else {
|
586 |
+
update_post_meta( $order_id, '_used_gateway', 'WC_WooMercadoPago_PSEGateway' );
|
587 |
+
}
|
588 |
+
|
589 |
+
// Check fullfilment of PSE form.
|
590 |
+
if ( get_option( '_site_id_v1' ) == 'MCO' ) {
|
591 |
+
if ( ! isset( $pse_checkout['docType'] ) || empty( $pse_checkout['docType'] ) ||
|
592 |
+
! isset( $pse_checkout['docNumber'] ) || empty( $pse_checkout['docNumber'] ) ||
|
593 |
+
! isset( $pse_checkout['bank'] ) || empty( $pse_checkout['bank'] ) ||
|
594 |
+
! isset( $pse_checkout['personType'] ) || empty( $pse_checkout['personType'] ) ) {
|
595 |
+
wc_add_notice(
|
596 |
+
'<p>' .
|
597 |
+
__( 'A problem was occurred when processing your payment. Are you sure you have correctly filled all information in the checkout form?', 'woocommerce-mercadopago' ) .
|
598 |
+
'</p>',
|
599 |
+
'error'
|
600 |
+
);
|
601 |
+
return array(
|
602 |
+
'result' => 'fail',
|
603 |
+
'redirect' => '',
|
604 |
+
);
|
605 |
+
}
|
606 |
+
}
|
607 |
+
|
608 |
+
if ( isset( $pse_checkout['amount'] ) && ! empty( $pse_checkout['amount'] ) &&
|
609 |
+
isset( $pse_checkout['paymentMethodId'] ) && ! empty( $pse_checkout['paymentMethodId'] ) ) {
|
610 |
+
|
611 |
+
$response = $this->create_url( $order, $pse_checkout );
|
612 |
+
|
613 |
+
if ( array_key_exists( 'status', $response ) ) {
|
614 |
+
if ( $response['status'] == 'pending' ) {
|
615 |
+
if ( $response['status_detail'] == 'pending_waiting_transfer' ) {
|
616 |
+
WC()->cart->empty_cart();
|
617 |
+
if ( $this->stock_reduce_mode == 'yes' ) {
|
618 |
+
$order->reduce_order_stock();
|
619 |
+
}
|
620 |
+
// WooCommerce 3.0 or later.
|
621 |
+
if ( method_exists( $order, 'update_meta_data' ) ) {
|
622 |
+
$order->update_meta_data( '_transaction_details_pse', $response['transaction_details']['external_resource_url'] );
|
623 |
+
$order->save();
|
624 |
+
} else {
|
625 |
+
update_post_meta(
|
626 |
+
$order->id,
|
627 |
+
'_transaction_details_pse',
|
628 |
+
$response['transaction_details']['external_resource_url']
|
629 |
+
);
|
630 |
+
}
|
631 |
+
// Shows some info in checkout page.
|
632 |
+
$order->add_order_note(
|
633 |
+
'Mercado Pago: ' .
|
634 |
+
__( 'Customer haven\'t paid yet.', 'woocommerce-mercadopago' )
|
635 |
+
);
|
636 |
+
$order->add_order_note(
|
637 |
+
'Mercado Pago: ' .
|
638 |
+
__( 'Link to bank transfer ', 'woocommerce-mercadopago' ) .
|
639 |
+
'<a target="_blank" href="' .
|
640 |
+
$response['transaction_details']['external_resource_url'] . '">' .
|
641 |
+
__( 'here', 'woocommerce-mercadopago' ) .
|
642 |
+
'</a>', 1, false
|
643 |
+
);
|
644 |
+
return array(
|
645 |
+
'result' => 'success',
|
646 |
+
'redirect' => $order->get_checkout_order_received_url()
|
647 |
+
);
|
648 |
+
}
|
649 |
+
}
|
650 |
+
} else {
|
651 |
+
// Process when fields are imcomplete.
|
652 |
+
wc_add_notice(
|
653 |
+
'<p>' .
|
654 |
+
__( 'A problem was occurred when processing your payment. Are you sure you have correctly filled all information in the checkout form? ', 'woocommerce-mercadopago' ) . ' MERCADO PAGO: ' .
|
655 |
+
WC_Woo_Mercado_Pago_Module::get_common_error_messages( $response ) .
|
656 |
+
'</p>',
|
657 |
+
'error'
|
658 |
+
);
|
659 |
+
return array(
|
660 |
+
'result' => 'fail',
|
661 |
+
'redirect' => '',
|
662 |
+
);
|
663 |
+
}
|
664 |
+
} else {
|
665 |
+
// Process when fields are imcomplete.
|
666 |
+
wc_add_notice(
|
667 |
+
'<p>' .
|
668 |
+
__( 'A problem was occurred when processing your payment. Please, try again.', 'woocommerce-mercadopago' ) .
|
669 |
+
'</p>',
|
670 |
+
'error'
|
671 |
+
);
|
672 |
+
return array(
|
673 |
+
'result' => 'fail',
|
674 |
+
'redirect' => '',
|
675 |
+
);
|
676 |
+
}
|
677 |
+
|
678 |
+
}
|
679 |
+
|
680 |
+
/**
|
681 |
+
* Summary: Build Mercado Pago preference.
|
682 |
+
* Description: Create Mercado Pago preference and get init_point URL based in the order options
|
683 |
+
* from the cart.
|
684 |
+
* @return the preference object.
|
685 |
+
*/
|
686 |
+
private function build_payment_preference( $order, $pse_checkout ) {
|
687 |
+
|
688 |
+
// A string to register items (workaround to deal with API problem that shows only first item).
|
689 |
+
$items = array();
|
690 |
+
$order_total = 0;
|
691 |
+
$list_of_items = array();
|
692 |
+
// Find currency rate.
|
693 |
+
$currency_ratio = 1;
|
694 |
+
$_mp_currency_conversion_v1 = get_option( '_mp_currency_conversion_v1', '' );
|
695 |
+
if ( ! empty( $_mp_currency_conversion_v1 ) ) {
|
696 |
+
$currency_ratio = WC_Woo_Mercado_Pago_Module::get_conversion_rate( $this->site_data['currency'] );
|
697 |
+
$currency_ratio = $currency_ratio > 0 ? $currency_ratio : 1;
|
698 |
+
}
|
699 |
+
|
700 |
+
// Here we build the array that contains ordered items, from customer cart.
|
701 |
+
if ( sizeof( $order->get_items() ) > 0 ) {
|
702 |
+
foreach ( $order->get_items() as $item ) {
|
703 |
+
if ( $item['qty'] ) {
|
704 |
+
$product = new WC_product( $item['product_id'] );
|
705 |
+
$product_title = method_exists( $product, 'get_description' ) ?
|
706 |
+
$product->get_name() :
|
707 |
+
$product->post->post_title;
|
708 |
+
$product_content = method_exists( $product, 'get_description' ) ?
|
709 |
+
$product->get_description() :
|
710 |
+
$product->post->post_content;
|
711 |
+
// Calculates line amount and discounts.
|
712 |
+
$line_amount = $item['line_total'] + $item['line_tax'];
|
713 |
+
$discount_by_gateway = (float) $line_amount * ( $this->gateway_discount / 100 );
|
714 |
+
$order_total += ($line_amount - $discount_by_gateway);
|
715 |
+
// Add the item.
|
716 |
+
array_push( $list_of_items, $product_title . ' x ' . $item['qty'] );
|
717 |
+
array_push( $items, array(
|
718 |
+
'id' => $item['product_id'],
|
719 |
+
'title' => html_entity_decode( $product_title ) . ' x ' . $item['qty'],
|
720 |
+
'description' => sanitize_file_name( html_entity_decode(
|
721 |
+
strlen( $product_content ) > 230 ?
|
722 |
+
substr( $product_content, 0, 230 ) . '...' :
|
723 |
+
$product_content
|
724 |
+
) ),
|
725 |
+
'picture_url' => sizeof( $order->get_items() ) > 1 ?
|
726 |
+
plugins_url( 'assets/images/cart.png', plugin_dir_path( __FILE__ ) ) :
|
727 |
+
wp_get_attachment_url( $product->get_image_id() ),
|
728 |
+
'category_id' => get_option( '_mp_category_name', 'others' ),
|
729 |
+
'quantity' => 1,
|
730 |
+
'unit_price' => ( $this->site_data['currency'] == 'COP' || $this->site_data['currency'] == 'CLP' ) ?
|
731 |
+
floor( ( $line_amount - $discount_by_gateway ) * $currency_ratio ) :
|
732 |
+
floor( ( $line_amount - $discount_by_gateway ) * $currency_ratio * 100 ) / 100
|
733 |
+
) );
|
734 |
+
}
|
735 |
+
}
|
736 |
+
}
|
737 |
+
|
738 |
+
// Creates the shipment cost structure.
|
739 |
+
$ship_cost = ($order->get_total_shipping() + $order->get_shipping_tax());
|
740 |
+
if ( $ship_cost > 0 ) {
|
741 |
+
$order_total += $ship_cost;
|
742 |
+
$item = array(
|
743 |
+
'title' => method_exists( $order, 'get_id' ) ?
|
744 |
+
$order->get_shipping_method() :
|
745 |
+
$order->shipping_method,
|
746 |
+
'description' => __( 'Shipping service used by store', 'woocommerce-mercadopago' ),
|
747 |
+
'category_id' => get_option( '_mp_category_name', 'others' ),
|
748 |
+
'quantity' => 1,
|
749 |
+
'unit_price' => ( $this->site_data['currency'] == 'COP' || $this->site_data['currency'] == 'CLP' ) ?
|
750 |
+
floor( $ship_cost * $currency_ratio ) :
|
751 |
+
floor( $ship_cost * $currency_ratio * 100 ) / 100
|
752 |
+
);
|
753 |
+
$items[] = $item;
|
754 |
+
}
|
755 |
+
|
756 |
+
// Discounts features.
|
757 |
+
if ( isset( $pse_checkout['discount'] ) && ! empty( $pse_checkout['discount'] ) &&
|
758 |
+
isset( $pse_checkout['coupon_code'] ) && ! empty( $pse_checkout['coupon_code'] ) &&
|
759 |
+
$pse_checkout['discount'] > 0 && WC()->session->chosen_payment_method == 'woo-mercado-pago-pse' ) {
|
760 |
+
$item = array(
|
761 |
+
'title' => __( 'Discount provided by store', 'woocommerce-mercadopago' ),
|
762 |
+
'description' => __( 'Discount provided by store', 'woocommerce-mercadopago' ),
|
763 |
+
'category_id' => get_option( '_mp_category_name', 'others' ),
|
764 |
+
'quantity' => 1,
|
765 |
+
'unit_price' => ( $this->site_data['currency'] == 'COP' || $this->site_data['currency'] == 'CLP' ) ?
|
766 |
+
-floor( $pse_checkout['discount'] * $currency_ratio ) :
|
767 |
+
-floor( $pse_checkout['discount'] * $currency_ratio * 100 ) / 100
|
768 |
+
);
|
769 |
+
$items[] = $item;
|
770 |
+
}
|
771 |
+
|
772 |
+
// Build additional information from the customer data.
|
773 |
+
$payer_additional_info = array(
|
774 |
+
'first_name' => ( method_exists( $order, 'get_id' ) ?
|
775 |
+
html_entity_decode( $order->get_billing_first_name() ) :
|
776 |
+
html_entity_decode( $order->billing_first_name ) ),
|
777 |
+
'last_name' => ( method_exists( $order, 'get_id' ) ?
|
778 |
+
html_entity_decode( $order->get_billing_last_name() ) :
|
779 |
+
html_entity_decode( $order->billing_last_name ) ),
|
780 |
+
//'registration_date' =>
|
781 |
+
'phone' => array(
|
782 |
+
//'area_code' =>
|
783 |
+
'number' => ( method_exists( $order, 'get_id' ) ?
|
784 |
+
$order->get_billing_phone() :
|
785 |
+
$order->billing_phone )
|
786 |
+
),
|
787 |
+
'address' => array(
|
788 |
+
'zip_code' => ( method_exists( $order, 'get_id' ) ?
|
789 |
+
$order->get_billing_postcode() :
|
790 |
+
$order->billing_postcode
|
791 |
+
),
|
792 |
+
//'street_number' =>
|
793 |
+
'street_name' => html_entity_decode( method_exists( $order, 'get_id' ) ?
|
794 |
+
$order->get_billing_address_1() . ' / ' .
|
795 |
+
$order->get_billing_city() . ' ' .
|
796 |
+
$order->get_billing_state() . ' ' .
|
797 |
+
$order->get_billing_country() :
|
798 |
+
$order->billing_address_1 . ' / ' .
|
799 |
+
$order->billing_city . ' ' .
|
800 |
+
$order->billing_state . ' ' .
|
801 |
+
$order->billing_country
|
802 |
+
)
|
803 |
+
)
|
804 |
+
);
|
805 |
+
|
806 |
+
// Create the shipment address information set.
|
807 |
+
$shipments = array(
|
808 |
+
'receiver_address' => array(
|
809 |
+
'zip_code' => method_exists( $order, 'get_id' ) ?
|
810 |
+
$order->get_shipping_postcode() :
|
811 |
+
$order->shipping_postcode,
|
812 |
+
//'street_number' =>
|
813 |
+
'street_name' => html_entity_decode( method_exists( $order, 'get_id' ) ?
|
814 |
+
$order->get_shipping_address_1() . ' ' .
|
815 |
+
$order->get_shipping_address_2() . ' ' .
|
816 |
+
$order->get_shipping_city() . ' ' .
|
817 |
+
$order->get_shipping_state() . ' ' .
|
818 |
+
$order->get_shipping_country() :
|
819 |
+
$order->shipping_address_1 . ' ' .
|
820 |
+
$order->shipping_address_2 . ' ' .
|
821 |
+
$order->shipping_city . ' ' .
|
822 |
+
$order->shipping_state . ' ' .
|
823 |
+
$order->shipping_country
|
824 |
+
),
|
825 |
+
//'floor' =>
|
826 |
+
'apartment' => method_exists( $order, 'get_id' ) ?
|
827 |
+
$order->get_shipping_address_2() :
|
828 |
+
$order->shipping_address_2
|
829 |
+
)
|
830 |
+
);
|
831 |
+
|
832 |
+
$ip = "";
|
833 |
+
if ( ! empty($_SERVER['HTTP_CLIENT_IP'] ) ) {
|
834 |
+
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
835 |
+
} elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
|
836 |
+
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
837 |
+
} else {
|
838 |
+
$ip = $_SERVER['REMOTE_ADDR'];
|
839 |
+
}
|
840 |
+
|
841 |
+
// The payment preference.
|
842 |
+
$preferences = array(
|
843 |
+
'date_of_expiration' => $date_of_expiration,
|
844 |
+
'transaction_amount' => ( $this->site_data['currency'] == 'COP' || $this->site_data['currency'] == 'CLP' ) ?
|
845 |
+
floor( $order_total * $currency_ratio ) :
|
846 |
+
floor( $order_total * $currency_ratio * 100 ) / 100,
|
847 |
+
'description' => implode( ', ', $list_of_items ),
|
848 |
+
'payment_method_id' => $pse_checkout['paymentMethodId'],
|
849 |
+
'payer' => array(
|
850 |
+
'email' => method_exists( $order, 'get_id' ) ?
|
851 |
+
$order->get_billing_email() :
|
852 |
+
$order->billing_email
|
853 |
+
),
|
854 |
+
'external_reference' => get_option( '_mp_store_identificator', 'WC-' ) .
|
855 |
+
( method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id ),
|
856 |
+
'statement_descriptor' => get_option( '_mp_statement_descriptor', 'Mercado Pago' ),
|
857 |
+
'binary_mode' => ( $this->binary_mode == 'yes' ),
|
858 |
+
'additional_info' => array(
|
859 |
+
'items' => $items,
|
860 |
+
'payer' => $payer_additional_info,
|
861 |
+
'shipments' => $shipments
|
862 |
+
),
|
863 |
+
'callback_url' => $order->get_checkout_order_received_url()
|
864 |
+
);
|
865 |
+
|
866 |
+
// PSE Fields
|
867 |
+
if( $pse_checkout['paymentMethodId'] == 'pse' ) {
|
868 |
+
$preferences['additional_info']['ip_address'] = $ip;
|
869 |
+
$preferences['payer']['identification'] = array(
|
870 |
+
'type' => $pse_checkout['docType'],
|
871 |
+
'number' => $pse_checkout['docNumber'],
|
872 |
+
);
|
873 |
+
$preferences['transaction_details'] = array(
|
874 |
+
'financial_institution' => $pse_checkout['bank']
|
875 |
+
);
|
876 |
+
$preferences['payer']['entity_type'] = $pse_checkout['personType'];
|
877 |
+
}
|
878 |
+
|
879 |
+
// Do not set IPN url if it is a localhost.
|
880 |
+
if ( ! strrpos( get_site_url(), 'localhost' ) ) {
|
881 |
+
$notification_url = get_option( '_mp_custom_domain', '' );
|
882 |
+
// Check if we have a custom URL.
|
883 |
+
if ( empty( $notification_url ) || filter_var( $notification_url, FILTER_VALIDATE_URL ) === FALSE ) {
|
884 |
+
$preferences['notification_url'] = WC()->api_request_url( 'WC_WooMercadoPago_PSEGateway' );
|
885 |
+
} else {
|
886 |
+
$preferences['notification_url'] = WC_Woo_Mercado_Pago_Module::fix_url_ampersand( esc_url(
|
887 |
+
$notification_url . '/wc-api/WC_WooMercadoPago_PSEGateway/'
|
888 |
+
) );
|
889 |
+
}
|
890 |
+
}
|
891 |
+
|
892 |
+
// Discounts features.
|
893 |
+
if ( isset( $pse_checkout['discount'] ) && ! empty( $pse_checkout['discount'] ) &&
|
894 |
+
isset( $pse_checkout['coupon_code'] ) && ! empty( $pse_checkout['coupon_code'] ) &&
|
895 |
+
$pse_checkout['discount'] > 0 && WC()->session->chosen_payment_method == 'woo-mercado-pago-pse' ) {
|
896 |
+
$preferences['campaign_id'] = (int) $pse_checkout['campaign_id'];
|
897 |
+
$preferences['coupon_amount'] = ( $this->site_data['currency'] == 'COP' || $this->site_data['currency'] == 'CLP' ) ?
|
898 |
+
floor( $pse_checkout['discount'] * $currency_ratio ) :
|
899 |
+
floor( $pse_checkout['discount'] * $currency_ratio * 100 ) / 100;
|
900 |
+
$preferences['coupon_code'] = strtoupper( $pse_checkout['coupon_code'] );
|
901 |
+
}
|
902 |
+
|
903 |
+
// Set sponsor ID.
|
904 |
+
$_test_user_v1 = get_option( '_test_user_v1', false );
|
905 |
+
if ( ! $_test_user_v1 ) {
|
906 |
+
$preferences['sponsor_id'] = $this->site_data['sponsor_id'];
|
907 |
+
}
|
908 |
+
|
909 |
+
// Debug/log this preference.
|
910 |
+
$this->write_log(
|
911 |
+
__FUNCTION__,
|
912 |
+
'returning just created [$preferences] structure: ' .
|
913 |
+
json_encode( $preferences, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE )
|
914 |
+
);
|
915 |
+
|
916 |
+
return $preferences;
|
917 |
+
}
|
918 |
+
|
919 |
+
protected function create_url( $order, $pse_checkout ) {
|
920 |
+
// Creates the order parameters by checking the cart configuration.
|
921 |
+
$preferences = $this->build_payment_preference( $order, $pse_checkout );
|
922 |
+
// Checks for sandbox mode.
|
923 |
+
$this->mp->sandbox_mode( $this->sandbox );
|
924 |
+
// Create order preferences with Mercado Pago API request.
|
925 |
+
try {
|
926 |
+
$checkout_info = $this->mp->create_payment( json_encode( $preferences ) );
|
927 |
+
if ( $checkout_info['status'] < 200 || $checkout_info['status'] >= 300 ) {
|
928 |
+
// Mercado Pago throwed an error.
|
929 |
+
$this->write_log(
|
930 |
+
__FUNCTION__,
|
931 |
+
'mercado pago gave error, payment creation failed with error: ' . $checkout_info['response']['message']
|
932 |
+
);
|
933 |
+
return $checkout_info['response']['message'];
|
934 |
+
} elseif ( is_wp_error( $checkout_info ) ) {
|
935 |
+
// WordPress throwed an error.
|
936 |
+
$this->write_log(
|
937 |
+
__FUNCTION__,
|
938 |
+
'wordpress gave error, payment creation failed with error: ' . $checkout_info['response']['message']
|
939 |
+
);
|
940 |
+
return $checkout_info['response']['message'];
|
941 |
+
} else {
|
942 |
+
// Obtain the URL.
|
943 |
+
$this->write_log(
|
944 |
+
__FUNCTION__,
|
945 |
+
'payment link generated with success from mercado pago, with structure as follow: ' .
|
946 |
+
json_encode( $checkout_info, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE )
|
947 |
+
);
|
948 |
+
// TODO: Verify sandbox availability.
|
949 |
+
//if ( 'yes' == $this->sandbox ) {
|
950 |
+
// return $checkout_info['response']['sandbox_init_point'];
|
951 |
+
//} else {
|
952 |
+
return $checkout_info['response'];
|
953 |
+
//}
|
954 |
+
}
|
955 |
+
} catch ( MercadoPagoException $ex ) {
|
956 |
+
// Something went wrong with the payment creation.
|
957 |
+
$this->write_log(
|
958 |
+
__FUNCTION__,
|
959 |
+
'payment creation failed with exception: ' .
|
960 |
+
json_encode( $ex, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE )
|
961 |
+
);
|
962 |
+
return $ex->getMessage();
|
963 |
+
}
|
964 |
+
}
|
965 |
+
|
966 |
+
/**
|
967 |
+
* Summary: Receive post data and applies a discount based in the received values.
|
968 |
+
* Description: Receive post data and applies a discount based in the received values.
|
969 |
+
*/
|
970 |
+
public function add_discount_pse() {
|
971 |
+
|
972 |
+
if ( ! isset( $_POST['mercadopago_pse'] ) ) {
|
973 |
+
return;
|
974 |
+
}
|
975 |
+
|
976 |
+
if ( is_admin() && ! defined( 'DOING_AJAX' ) || is_cart() ) {
|
977 |
+
return;
|
978 |
+
}
|
979 |
+
|
980 |
+
$pse_checkout = $_POST['mercadopago_pse'];
|
981 |
+
if ( isset( $pse_checkout['discount'] ) && ! empty( $pse_checkout['discount'] ) &&
|
982 |
+
isset( $pse_checkout['coupon_code'] ) && ! empty( $pse_checkout['coupon_code'] ) &&
|
983 |
+
$pse_checkout['discount'] > 0 && WC()->session->chosen_payment_method == 'woo-mercado-pago-pse' ) {
|
984 |
+
|
985 |
+
$this->write_log( __FUNCTION__, 'pse checkout trying to apply discount...' );
|
986 |
+
|
987 |
+
$value = ( $this->site_data['currency'] == 'COP' || $this->site_data['currency'] == 'CLP' ) ?
|
988 |
+
floor( $pse_checkout['discount'] / $pse_checkout['currency_ratio'] ) :
|
989 |
+
floor( $pse_checkout['discount'] / $pse_checkout['currency_ratio'] * 100 ) / 100;
|
990 |
+
global $woocommerce;
|
991 |
+
if ( apply_filters(
|
992 |
+
'wc_mercadopagopse_module_apply_discount',
|
993 |
+
0 < $value, $woocommerce->cart )
|
994 |
+
) {
|
995 |
+
$woocommerce->cart->add_fee( sprintf(
|
996 |
+
__( 'Discount for %s coupon', 'woocommerce-mercadopago' ),
|
997 |
+
esc_attr( $pse_checkout['campaign']
|
998 |
+
) ), ( $value * -1 ), false
|
999 |
+
);
|
1000 |
+
}
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
// Display the discount in payment method title.
|
1006 |
+
public function get_payment_method_title_pse( $title, $id ) {
|
1007 |
+
if ( ! is_checkout() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
1008 |
+
return $title;
|
1009 |
+
}
|
1010 |
+
if ( $title != $this->title || $this->gateway_discount == 0 ) {
|
1011 |
+
return $title;
|
1012 |
+
}
|
1013 |
+
if ( ! is_numeric( $this->gateway_discount ) || $this->gateway_discount < -99 || $this->gateway_discount > 99 ) {
|
1014 |
+
return $title;
|
1015 |
+
}
|
1016 |
+
$total = (float) WC()->cart->subtotal;
|
1017 |
+
$price_percent = $this->gateway_discount / 100;
|
1018 |
+
if ( $price_percent > 0 ) {
|
1019 |
+
$title .= ' (' . __( 'Discount of', 'woocommerce-mercadopago' ) . ' ' .
|
1020 |
+
strip_tags( wc_price( $total * $price_percent ) ) . ')';
|
1021 |
+
} elseif ( $price_percent < 0 ) {
|
1022 |
+
$title .= ' (' . __( 'Fee of', 'woocommerce-mercadopago' ) . ' ' .
|
1023 |
+
strip_tags( wc_price( -$total * $price_percent ) ) . ')';
|
1024 |
+
}
|
1025 |
+
return $title;
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
/*
|
1029 |
+
* ========================================================================
|
1030 |
+
* AUXILIARY AND FEEDBACK METHODS (SERVER SIDE)
|
1031 |
+
* ========================================================================
|
1032 |
+
*/
|
1033 |
+
|
1034 |
+
// Called automatically by WooCommerce, verify if Module is available to use.
|
1035 |
+
public function is_available() {
|
1036 |
+
if ( ! did_action( 'wp_loaded' ) ) {
|
1037 |
+
return false;
|
1038 |
+
}
|
1039 |
+
global $woocommerce;
|
1040 |
+
$w_cart = $woocommerce->cart;
|
1041 |
+
$_mp_public_key = get_option( '_mp_public_key' );
|
1042 |
+
$_mp_access_token = get_option( '_mp_access_token' );
|
1043 |
+
$_site_id_v1 = get_option( '_site_id_v1' );
|
1044 |
+
// If we do not have SSL in production environment, we are not allowed to process.
|
1045 |
+
$_mp_debug_mode = get_option( '_mp_debug_mode', '' );
|
1046 |
+
if ( empty( $_SERVER['HTTPS'] ) || $_SERVER['HTTPS'] == 'off' ) {
|
1047 |
+
if ( empty ( $_mp_debug_mode ) ) {
|
1048 |
+
return false;
|
1049 |
+
}
|
1050 |
+
}
|
1051 |
+
// Check for recurrent product checkout.
|
1052 |
+
if ( isset( $w_cart ) ) {
|
1053 |
+
if ( WC_Woo_Mercado_Pago_Module::is_subscription( $w_cart->get_cart() ) ) {
|
1054 |
+
return false;
|
1055 |
+
}
|
1056 |
+
}
|
1057 |
+
// Check if this gateway is enabled and well configured.
|
1058 |
+
$available = ( 'yes' == $this->settings['enabled'] ) &&
|
1059 |
+
! empty( $_mp_public_key ) &&
|
1060 |
+
! empty( $_mp_access_token ) &&
|
1061 |
+
! empty( $_site_id_v1 );
|
1062 |
+
return $available;
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
/*
|
1066 |
+
* ========================================================================
|
1067 |
+
* IPN MECHANICS (SERVER SIDE)
|
1068 |
+
* ========================================================================
|
1069 |
+
*/
|
1070 |
+
|
1071 |
+
/**
|
1072 |
+
* Summary: This call checks any incoming notifications from Mercado Pago server.
|
1073 |
+
* Description: This call checks any incoming notifications from Mercado Pago server.
|
1074 |
+
*/
|
1075 |
+
public function check_ipn_response() {
|
1076 |
+
@ob_clean();
|
1077 |
+
$this->write_log(
|
1078 |
+
__FUNCTION__,
|
1079 |
+
'received _get content: ' .
|
1080 |
+
json_encode( $_GET, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE )
|
1081 |
+
);
|
1082 |
+
// Setup sandbox mode.
|
1083 |
+
$this->mp->sandbox_mode( $this->sandbox );
|
1084 |
+
// Over here, $_GET should come with this JSON structure:
|
1085 |
+
// {
|
1086 |
+
// "topic": <string>,
|
1087 |
+
// "id": <string>
|
1088 |
+
// }
|
1089 |
+
// If not, the IPN is corrupted in some way.
|
1090 |
+
$data = $_GET;
|
1091 |
+
if ( isset( $data['coupon_id'] ) && ! empty( $data['coupon_id'] ) ) {
|
1092 |
+
// Process coupon evaluations.
|
1093 |
+
if ( isset( $data['payer'] ) && ! empty( $data['payer'] ) ) {
|
1094 |
+
$response = $this->mp->check_discount_campaigns( $data['amount'], $data['payer'], $data['coupon_id'] );
|
1095 |
+
header( 'HTTP/1.1 200 OK' );
|
1096 |
+
header( 'Content-Type: application/json' );
|
1097 |
+
echo json_encode( $response );
|
1098 |
+
} else {
|
1099 |
+
$obj = new stdClass();
|
1100 |
+
$obj->status = 404;
|
1101 |
+
$obj->response = array(
|
1102 |
+
'message' => __( 'Please, inform your email in billing address to use this feature', 'woocommerce-mercadopago' ),
|
1103 |
+
'error' => 'payer_not_found',
|
1104 |
+
'status' => 404,
|
1105 |
+
'cause' => array()
|
1106 |
+
);
|
1107 |
+
header( 'HTTP/1.1 200 OK' );
|
1108 |
+
header( 'Content-Type: application/json' );
|
1109 |
+
echo json_encode( $obj );
|
1110 |
+
}
|
1111 |
+
exit( 0 );
|
1112 |
+
} else if ( ! isset( $data['data_id'] ) || ! isset( $data['type'] ) ) {
|
1113 |
+
// Received IPN call from v0.
|
1114 |
+
$this->write_log(
|
1115 |
+
__FUNCTION__,
|
1116 |
+
'data_id or type not set: ' .
|
1117 |
+
json_encode( $data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE )
|
1118 |
+
);
|
1119 |
+
if ( ! isset( $data['id'] ) || ! isset( $data['topic'] ) ) {
|
1120 |
+
$this->write_log(
|
1121 |
+
__FUNCTION__,
|
1122 |
+
'Mercado Pago Request failure: ' .
|
1123 |
+
json_encode( $data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE )
|
1124 |
+
);
|
1125 |
+
wp_die( __( 'Mercado Pago Request Failure', 'woocommerce-mercadopago' ) );
|
1126 |
+
} else {
|
1127 |
+
// At least, check if its a v0 ipn.
|
1128 |
+
header( 'HTTP/1.1 200 OK' );
|
1129 |
+
}
|
1130 |
+
} else {
|
1131 |
+
// Needed informations are present, so start process then.
|
1132 |
+
try {
|
1133 |
+
if ( $data['type'] == 'payment' ) {
|
1134 |
+
$access_token = array( 'access_token' => $this->mp->get_access_token() );
|
1135 |
+
$payment_info = $this->mp->get( '/v1/payments/' . $data['data_id'], $access_token, false );
|
1136 |
+
if ( ! is_wp_error( $payment_info ) && ( $payment_info['status'] == 200 || $payment_info['status'] == 201 ) ) {
|
1137 |
+
if ( $payment_info['response'] ) {
|
1138 |
+
header( 'HTTP/1.1 200 OK' );
|
1139 |
+
do_action( 'valid_mercadopago_pse_ipn_request', $payment_info['response'] );
|
1140 |
+
}
|
1141 |
+
} else {
|
1142 |
+
$this->write_log(
|
1143 |
+
__FUNCTION__,
|
1144 |
+
'error when processing received data: ' .
|
1145 |
+
json_encode( $payment_info, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE )
|
1146 |
+
);
|
1147 |
+
}
|
1148 |
+
}
|
1149 |
+
} catch ( MercadoPagoException $ex ) {
|
1150 |
+
$this->write_log(
|
1151 |
+
__FUNCTION__,
|
1152 |
+
'MercadoPagoException: ' .
|
1153 |
+
json_encode( $ex, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE )
|
1154 |
+
);
|
1155 |
+
}
|
1156 |
+
}
|
1157 |
+
}
|
1158 |
+
|
1159 |
+
/**
|
1160 |
+
* Summary: Properly handles each case of notification, based in payment status.
|
1161 |
+
* Description: Properly handles each case of notification, based in payment status.
|
1162 |
+
*/
|
1163 |
+
public function successful_request( $data ) {
|
1164 |
+
$this->write_log( __FUNCTION__, 'starting to process ipn update...' );
|
1165 |
+
// Get the order and check its presence.
|
1166 |
+
$order_key = $data['external_reference'];
|
1167 |
+
if ( empty( $order_key ) ) {
|
1168 |
+
return;
|
1169 |
+
}
|
1170 |
+
$invoice_prefix = get_option( '_mp_store_identificator', 'WC-' );
|
1171 |
+
$id = (int) str_replace( $invoice_prefix, '', $order_key );
|
1172 |
+
$order = wc_get_order( $id );
|
1173 |
+
// Check if order exists.
|
1174 |
+
if ( ! $order ) {
|
1175 |
+
return;
|
1176 |
+
}
|
1177 |
+
// WooCommerce 3.0 or later.
|
1178 |
+
$order_id = ( method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id );
|
1179 |
+
// Check if we have the correct order.
|
1180 |
+
if ( $order_id !== $id ) {
|
1181 |
+
return;
|
1182 |
+
}
|
1183 |
+
$this->write_log(
|
1184 |
+
__FUNCTION__,
|
1185 |
+
'updating metadata and status with data: ' .
|
1186 |
+
json_encode( $data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE )
|
1187 |
+
);
|
1188 |
+
// Here, we process the status... this is the business rules!
|
1189 |
+
// Reference: https://www.mercadopago.com.br/developers/en/api-docs/basic-checkout/ipn/payment-status/
|
1190 |
+
$status = isset( $data['status'] ) ? $data['status'] : 'pending';
|
1191 |
+
$total_paid = isset( $data['transaction_details']['total_paid_amount'] ) ? $data['transaction_details']['total_paid_amount'] : 0.00;
|
1192 |
+
$total_refund = isset( $data['transaction_amount_refunded'] ) ? $data['transaction_amount_refunded'] : 0.00;
|
1193 |
+
// WooCommerce 3.0 or later.
|
1194 |
+
if ( method_exists( $order, 'update_meta_data' ) ) {
|
1195 |
+
// Updates the type of gateway.
|
1196 |
+
$order->update_meta_data( '_used_gateway', 'WC_WooMercadoPago_PESGateway' );
|
1197 |
+
if ( ! empty( $data['payer']['email'] ) ) {
|
1198 |
+
$order->update_meta_data( __( 'Payer email', 'woocommerce-mercadopago' ), $data['payer']['email'] );
|
1199 |
+
}
|
1200 |
+
if ( ! empty( $data['payment_type_id'] ) ) {
|
1201 |
+
$order->update_meta_data( __( 'Payment type', 'woocommerce-mercadopago' ), $data['payment_type_id'] );
|
1202 |
+
}
|
1203 |
+
$order->update_meta_data(
|
1204 |
+
'Mercado Pago - Payment ' . $data['id'],
|
1205 |
+
'[Date ' . date( 'Y-m-d H:i:s', strtotime( $data['date_created'] ) ) .
|
1206 |
+
']/[Amount ' . $data['transaction_amount'] .
|
1207 |
+
']/[Paid ' . $total_paid .
|
1208 |
+
']/[Refund ' . $total_refund . ']'
|
1209 |
+
);
|
1210 |
+
$order->update_meta_data( '_Mercado_Pago_Payment_IDs', $data['id'] );
|
1211 |
+
$order->save();
|
1212 |
+
} else {
|
1213 |
+
// Updates the type of gateway.
|
1214 |
+
update_post_meta( $order_id, '_used_gateway', 'WC_WooMercadoPago_PSEGateway' );
|
1215 |
+
if ( ! empty( $data['payer']['email'] ) ) {
|
1216 |
+
update_post_meta( $order_id, __( 'Payer email', 'woocommerce-mercadopago' ), $data['payer']['email'] );
|
1217 |
+
}
|
1218 |
+
if ( ! empty( $data['payment_type_id'] ) ) {
|
1219 |
+
update_post_meta( $order_id, __( 'Payment type', 'woocommerce-mercadopago' ), $data['payment_type_id'] );
|
1220 |
+
}
|
1221 |
+
update_post_meta(
|
1222 |
+
$order_id,
|
1223 |
+
'Mercado Pago - Payment ' . $data['id'],
|
1224 |
+
'[Date ' . date( 'Y-m-d H:i:s', strtotime( $data['date_created'] ) ) .
|
1225 |
+
']/[Amount ' . $data['transaction_amount'] .
|
1226 |
+
']/[Paid ' . $total_paid .
|
1227 |
+
']/[Refund ' . $total_refund . ']'
|
1228 |
+
);
|
1229 |
+
update_post_meta( $order_id, '_Mercado_Pago_Payment_IDs', $data['id'] );
|
1230 |
+
}
|
1231 |
+
// Switch the status and update in WooCommerce.
|
1232 |
+
$this->write_log(
|
1233 |
+
__FUNCTION__,
|
1234 |
+
'Changing order status to: ' .
|
1235 |
+
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( str_replace( '_', '', $status ) )
|
1236 |
+
);
|
1237 |
+
switch ( $status ) {
|
1238 |
+
case 'approved':
|
1239 |
+
$order->add_order_note(
|
1240 |
+
'Mercado Pago: ' . __( 'Payment approved.', 'woocommerce-mercadopago' )
|
1241 |
+
);
|
1242 |
+
if ( $this->stock_reduce_mode == 'no' ) {
|
1243 |
+
$order->payment_complete();
|
1244 |
+
}
|
1245 |
+
$order->update_status(
|
1246 |
+
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( 'approved' )
|
1247 |
+
);
|
1248 |
+
break;
|
1249 |
+
case 'pending':
|
1250 |
+
$order->update_status(
|
1251 |
+
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( 'pending' )
|
1252 |
+
);
|
1253 |
+
// decrease stock if not yet decreased and order not exists.
|
1254 |
+
$notes = $order->get_customer_order_notes();
|
1255 |
+
$has_note = false;
|
1256 |
+
if ( sizeof( $notes ) > 1 ) {
|
1257 |
+
$has_note = true;
|
1258 |
+
break;
|
1259 |
+
}
|
1260 |
+
if ( ! $has_note ) {
|
1261 |
+
$order->add_order_note(
|
1262 |
+
'Mercado Pago: ' . __( 'Waiting for the bank transfer.', 'woocommerce-mercadopago' ),
|
1263 |
+
1, false
|
1264 |
+
);
|
1265 |
+
}
|
1266 |
+
break;
|
1267 |
+
case 'in_process':
|
1268 |
+
$order->update_status(
|
1269 |
+
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( 'on-hold' ),
|
1270 |
+
'Mercado Pago: ' . __( 'Payment under review.', 'woocommerce-mercadopago' )
|
1271 |
+
);
|
1272 |
+
break;
|
1273 |
+
case 'rejected':
|
1274 |
+
$order->update_status(
|
1275 |
+
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( 'rejected' ),
|
1276 |
+
'Mercado Pago: ' . __( 'The payment was refused. The customer can try again.', 'woocommerce-mercadopago' )
|
1277 |
+
);
|
1278 |
+
break;
|
1279 |
+
case 'refunded':
|
1280 |
+
$order->update_status(
|
1281 |
+
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( 'refunded' ),
|
1282 |
+
'Mercado Pago: ' . __( 'The payment was refunded to the customer.', 'woocommerce-mercadopago' )
|
1283 |
+
);
|
1284 |
+
break;
|
1285 |
+
case 'cancelled':
|
1286 |
+
$this->process_cancel_order_meta_box_actions( $order );
|
1287 |
+
$order->update_status(
|
1288 |
+
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( 'cancelled' ),
|
1289 |
+
'Mercado Pago: ' . __( 'The payment was cancelled.', 'woocommerce-mercadopago' )
|
1290 |
+
);
|
1291 |
+
break;
|
1292 |
+
case 'in_mediation':
|
1293 |
+
$order->update_status(
|
1294 |
+
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( 'inmediation' )
|
1295 |
+
);
|
1296 |
+
$order->add_order_note(
|
1297 |
+
'Mercado Pago: ' . __( 'The payment is under mediation or it was charged-back.', 'woocommerce-mercadopago' )
|
1298 |
+
);
|
1299 |
+
break;
|
1300 |
+
case 'charged-back':
|
1301 |
+
$order->update_status(
|
1302 |
+
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( 'chargedback' )
|
1303 |
+
);
|
1304 |
+
$order->add_order_note(
|
1305 |
+
'Mercado Pago: ' . __( 'The payment is under mediation or it was charged-back.', 'woocommerce-mercadopago' )
|
1306 |
+
);
|
1307 |
+
break;
|
1308 |
+
default:
|
1309 |
+
break;
|
1310 |
+
}
|
1311 |
+
}
|
1312 |
+
|
1313 |
+
}
|
1314 |
+
|
1315 |
+
new WC_WooMercadoPago_PSEGateway( true );
|
includes/WC_WooMercadoPago_SubscriptionGateway.php
CHANGED
@@ -1118,7 +1118,7 @@ class WC_WooMercadoPago_SubscriptionGateway extends WC_Payment_Gateway {
|
|
1118 |
break;
|
1119 |
case 'rejected':
|
1120 |
$order->update_status(
|
1121 |
-
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( '
|
1122 |
'Mercado Pago: ' . __( 'The payment was refused. The customer can try again.', 'woocommerce-mercadopago' )
|
1123 |
);
|
1124 |
break;
|
1118 |
break;
|
1119 |
case 'rejected':
|
1120 |
$order->update_status(
|
1121 |
+
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( 'rejected' ),
|
1122 |
'Mercado Pago: ' . __( 'The payment was refused. The customer can try again.', 'woocommerce-mercadopago' )
|
1123 |
);
|
1124 |
break;
|
includes/WC_WooMercadoPago_TicketGateway.php
CHANGED
@@ -1296,7 +1296,7 @@ class WC_WooMercadoPago_TicketGateway extends WC_Payment_Gateway {
|
|
1296 |
break;
|
1297 |
case 'rejected':
|
1298 |
$order->update_status(
|
1299 |
-
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( '
|
1300 |
'Mercado Pago: ' . __( 'The payment was refused. The customer can try again.', 'woocommerce-mercadopago' )
|
1301 |
);
|
1302 |
break;
|
1296 |
break;
|
1297 |
case 'rejected':
|
1298 |
$order->update_status(
|
1299 |
+
WC_Woo_Mercado_Pago_Module::get_wc_status_for_mp_status( 'rejected' ),
|
1300 |
'Mercado Pago: ' . __( 'The payment was refused. The customer can try again.', 'woocommerce-mercadopago' )
|
1301 |
);
|
1302 |
break;
|
includes/class-wc-product-mp_recurrent.php
CHANGED
File without changes
|
includes/sdk/lib/mercadopago.php
CHANGED
@@ -12,7 +12,7 @@ $GLOBALS['LIB_LOCATION'] = dirname( __FILE__ );
|
|
12 |
|
13 |
class MP {
|
14 |
|
15 |
-
private $version = '3.0.
|
16 |
private $client_id;
|
17 |
private $client_secret;
|
18 |
private $ll_access_token;
|
@@ -620,6 +620,19 @@ class MP {
|
|
620 |
return $response;
|
621 |
|
622 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
623 |
|
624 |
//=== GENERIC RESOURCE CALL METHODS ===
|
625 |
|
12 |
|
13 |
class MP {
|
14 |
|
15 |
+
private $version = '3.0.16';
|
16 |
private $client_id;
|
17 |
private $client_secret;
|
18 |
private $ll_access_token;
|
620 |
return $response;
|
621 |
|
622 |
}
|
623 |
+
|
624 |
+
public function get_payment_methods() {
|
625 |
+
$request = array(
|
626 |
+
'uri' => '/v1/payment_methods',
|
627 |
+
'params' => array(
|
628 |
+
'access_token' => $this->get_access_token()
|
629 |
+
)
|
630 |
+
);
|
631 |
+
|
632 |
+
$response = MPRestClient::get( $request, $this->version );
|
633 |
+
|
634 |
+
return $response;
|
635 |
+
}
|
636 |
|
637 |
//=== GENERIC RESOURCE CALL METHODS ===
|
638 |
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== WooCommerce MercadoPago ===
|
2 |
Contributors: mercadopago, mercadolivre, claudiosanches, marcelohama
|
3 |
Tags: ecommerce, mercadopago, woocommerce
|
4 |
-
Requires at least: 4.
|
5 |
-
Tested up to: 4.
|
6 |
Requires PHP: 5.6
|
7 |
-
Stable tag: 3.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -215,6 +215,12 @@ Features: LatAm Basic Checkout support. Great for merchants who want to get goin
|
|
215 |
|
216 |
== Changelog ==
|
217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
= v3.0.15 (15/03/2018) =
|
219 |
* Improvements
|
220 |
- Allowing customization by merchants, in ticket fields (credits to https://github.com/fernandoacosta)
|
1 |
=== WooCommerce MercadoPago ===
|
2 |
Contributors: mercadopago, mercadolivre, claudiosanches, marcelohama
|
3 |
Tags: ecommerce, mercadopago, woocommerce
|
4 |
+
Requires at least: 4.9.7
|
5 |
+
Tested up to: 4.9.7
|
6 |
Requires PHP: 5.6
|
7 |
+
Stable tag: 3.0.16
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
215 |
|
216 |
== Changelog ==
|
217 |
|
218 |
+
= v3.0.16 (20/07/2018) =
|
219 |
+
* Feature MCO
|
220 |
+
- Adding PSE gateway for Colombia
|
221 |
+
* Improvements
|
222 |
+
- Some code improvements
|
223 |
+
|
224 |
= v3.0.15 (15/03/2018) =
|
225 |
* Improvements
|
226 |
- Allowing customization by merchants, in ticket fields (credits to https://github.com/fernandoacosta)
|
templates/credit-card/payment-form.php
CHANGED
File without changes
|
templates/mp_main_settings.php
CHANGED
@@ -61,7 +61,7 @@
|
|
61 |
<tr>
|
62 |
<th scope="row"><label>Client Secret</label></th>
|
63 |
<td>
|
64 |
-
<input name="client_secret" type="
|
65 |
<p class="description" id="tagline-description">
|
66 |
<?php echo esc_html( __( 'Insert your Mercado Pago Client_secret.', 'woocommerce-mercadopago' ) ); ?>
|
67 |
</p>
|
@@ -104,7 +104,7 @@
|
|
104 |
<tr>
|
105 |
<th scope="row"><label>Access Token</label></th>
|
106 |
<td>
|
107 |
-
<input name="access_token" type="
|
108 |
<p class="description" id="tagline-description">
|
109 |
<?php echo esc_html( __( 'Insert your Mercado Pago Access token.', 'woocommerce-mercadopago' ) ); ?>
|
110 |
</p>
|
@@ -353,6 +353,10 @@
|
|
353 |
'woo-mercado-pago-ticket',
|
354 |
__( 'Tickets', 'woocommerce-mercadopago' )
|
355 |
),
|
|
|
|
|
|
|
|
|
356 |
WC_Woo_Mercado_Pago_Module::build_log_path_string(
|
357 |
'woo-mercado-pago-subscription',
|
358 |
__( 'Subscription', 'woocommerce-mercadopago' )
|
61 |
<tr>
|
62 |
<th scope="row"><label>Client Secret</label></th>
|
63 |
<td>
|
64 |
+
<input name="client_secret" type="text" id="client_secret" aria-describedby="tagline-description" value="<?php form_option('_mp_client_secret'); ?>" class="regular-text" />
|
65 |
<p class="description" id="tagline-description">
|
66 |
<?php echo esc_html( __( 'Insert your Mercado Pago Client_secret.', 'woocommerce-mercadopago' ) ); ?>
|
67 |
</p>
|
104 |
<tr>
|
105 |
<th scope="row"><label>Access Token</label></th>
|
106 |
<td>
|
107 |
+
<input name="access_token" type="text" id="access_token" aria-describedby="tagline-description" value="<?php form_option('_mp_access_token'); ?>" class="regular-text" />
|
108 |
<p class="description" id="tagline-description">
|
109 |
<?php echo esc_html( __( 'Insert your Mercado Pago Access token.', 'woocommerce-mercadopago' ) ); ?>
|
110 |
</p>
|
353 |
'woo-mercado-pago-ticket',
|
354 |
__( 'Tickets', 'woocommerce-mercadopago' )
|
355 |
),
|
356 |
+
WC_Woo_Mercado_Pago_Module::build_log_path_string(
|
357 |
+
'woo-mercado-pago-pse',
|
358 |
+
__( 'PSE', 'woocommerce-mercadopago' )
|
359 |
+
),
|
360 |
WC_Woo_Mercado_Pago_Module::build_log_path_string(
|
361 |
'woo-mercado-pago-subscription',
|
362 |
__( 'Subscription', 'woocommerce-mercadopago' )
|
templates/pse/pse-form.php
ADDED
@@ -0,0 +1,508 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Part of Woo Mercado Pago Module
|
5 |
+
* Author - Mercado Pago
|
6 |
+
* Developer - Marcelo Mita / marcelo.mita@mercadolivre.com
|
7 |
+
* Copyright - Copyright(c) MercadoPago [https://www.mercadopago.com]
|
8 |
+
* License - https://www.gnu.org/licenses/gpl.html GPL version 2 or higher
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
}
|
14 |
+
|
15 |
+
?>
|
16 |
+
|
17 |
+
<div class="mp-box-inputs mp-line" >
|
18 |
+
<label>
|
19 |
+
<span class="mensagem-ticket">
|
20 |
+
<div class="tooltip">
|
21 |
+
<?php echo esc_html__( 'Note: Confirmation under payment approval.', 'woocommerce-mercadopago' ); ?>
|
22 |
+
<span class="tooltiptext">
|
23 |
+
<?php
|
24 |
+
echo esc_html__( 'Click [Place order] button. The bank transfer will be setup and you will be redirected to pay it.', 'woocommerce-mercadopago' );
|
25 |
+
echo ' ';
|
26 |
+
echo esc_html__( 'Important: The order will be confirmed only after the payment approval.', 'woocommerce-mercadopago' );
|
27 |
+
?>
|
28 |
+
</span>
|
29 |
+
</div>
|
30 |
+
</span>
|
31 |
+
</label>
|
32 |
+
</div>
|
33 |
+
|
34 |
+
<fieldset id="pse_checkout_fieldset" style="margin:-1px; background:white; display: none;">
|
35 |
+
|
36 |
+
<!-- coupom -->
|
37 |
+
<!-- <div class="mp-box-inputs mp-line form-row" id="mercadopago-form-coupon-pse" >
|
38 |
+
<div class="form-col-8">
|
39 |
+
<label for="couponCodeLabel"><?php echo esc_html__( 'Discount Coupon', 'woocommerce-mercadopago' ); ?></label>
|
40 |
+
<input type="text" id="couponCodePSE" name="mercadopago_pse[coupon_code]"
|
41 |
+
autocomplete="off" maxlength="24" style="margin-bottom: 8px;"/>
|
42 |
+
<span class="mp-discount" id="mpCouponApplyedPSE" ></span>
|
43 |
+
<span class="mp-error" id="mpCouponErrorPSE" ></span>
|
44 |
+
</div>
|
45 |
+
<div class="form-col-4">
|
46 |
+
<label > </label>
|
47 |
+
<input type="button" class="button" id="applyCouponPSE" value="<?php echo esc_html__( 'Apply', 'woocommerce-mercadopago' ); ?>">
|
48 |
+
</div>
|
49 |
+
</div> -->
|
50 |
+
|
51 |
+
<!-- payment method -->
|
52 |
+
<div id="mercadopago-form-pse" class="mp-box-inputs mp-line" >
|
53 |
+
<div id="form-pse">
|
54 |
+
<div class="form-row">
|
55 |
+
<div class="form-col-6">
|
56 |
+
<label for="docType"><?php echo esc_html__( 'DOCUMENT TYPE', 'woocommerce-mercadopago' ); ?><em class="obrigatorio"> *</em></label>
|
57 |
+
<select name="mercadopago_pse[docType]" id="pse-doc-type" class="form-control-mine" style="width: 100%">
|
58 |
+
<option value="CC">C.C.</option>
|
59 |
+
<option value="CE">C.E.</option>
|
60 |
+
<option value="NIT">NIT</option>
|
61 |
+
<option value="Otro">Otro</option>
|
62 |
+
</select>
|
63 |
+
<span class="erro_pse" data-main="#pse-doc-type" id="error-docType"><?php echo esc_html__( 'You must inform your DOCUMENT TYPE', 'woocommerce-mercadopago' ); ?></span>
|
64 |
+
</div>
|
65 |
+
<div class="form-col-6">
|
66 |
+
<label for="docNumber"><?php echo esc_html__( 'DOCUMENT', 'woocommerce-mercadopago' ); ?><em class="obrigatorio"> *</em></label>
|
67 |
+
<input type="text" value="<?php echo $pse_data['docNumber']; ?>" id="pse-doc-number" class="form-control-mine" name="mercadopago_pse[docNumber]" style="width: 100%">
|
68 |
+
<span class="erro_pse" data-main="#pse-doc-number" id="error-docNumber"><?php echo esc_html__( 'You must inform your DOCUMENT', 'woocommerce-mercadopago' ); ?></span>
|
69 |
+
</div>
|
70 |
+
</div>
|
71 |
+
|
72 |
+
<div class="form-row">
|
73 |
+
<div class="form-col-6">
|
74 |
+
<label for="bank"><?php echo esc_html__( 'BANK', 'woocommerce-mercadopago' ); ?><em class="obrigatorio"> *</em></label>
|
75 |
+
<select name="mercadopago_pse[bank]" id="pse-bank" class="form-control-mine" style="width: 100%">
|
76 |
+
<?php foreach($financial_institutions as $bank) : ?>
|
77 |
+
<option value="<?php echo $bank["id"] ?>"><?php echo $bank["description"] ?></option>
|
78 |
+
<?php endforeach ?>
|
79 |
+
</select>
|
80 |
+
<span class="erro_pse" data-main="#pse-bank" id="error-bank"><?php echo esc_html__( 'You must inform the FINANCIAL INSTITUTION', 'woocommerce-mercadopago' ); ?></span>
|
81 |
+
</div>
|
82 |
+
<div class="form-col-6">
|
83 |
+
<label for="personType"><?php echo esc_html__( 'PERSON TYPE', 'woocommerce-mercadopago' ); ?><em class="obrigatorio"> *</em></label>
|
84 |
+
<select id="pse-person-type" class="form-control-mine" name="mercadopago_pse[personType]" style="width: 100%">
|
85 |
+
<option value="individual">Individual</option>
|
86 |
+
<option value="association">Association</option>
|
87 |
+
</select>
|
88 |
+
<span class="erro_pse" data-main="#pse-person-type" id="error-person-type"><?php echo esc_html__( 'You must inform your PERSON TYPE', 'woocommerce-mercadopago' ); ?></span>
|
89 |
+
</div>
|
90 |
+
</div>
|
91 |
+
|
92 |
+
<!-- utilities -->
|
93 |
+
<div class="mp-box-inputs mp-col-100" id="mercadopago-utilities">
|
94 |
+
<input type="hidden" id="site_id" value="<?php echo $site_id; ?>" name="mercadopago_pse[site_id]"/>
|
95 |
+
<input type="hidden" id="amountPSE" value="<?php echo $amount; ?>" name="mercadopago_pse[amount]"/>
|
96 |
+
<input type="hidden" id="currency_ratioPSE" value="<?php echo $currency_ratio; ?>" name="mercadopago_pse[currency_ratio]"/>
|
97 |
+
<input type="hidden" id="campaign_idPSE" name="mercadopago_pse[campaign_id]"/>
|
98 |
+
<input type="hidden" id="campaignPSE" name="mercadopago_pse[campaign]"/>
|
99 |
+
<input type="hidden" id="discountPSE" name="mercadopago_pse[discount]"/>
|
100 |
+
<input type="hidden" id="paymentMethodIdPSE" value="pse" name="mercadopago_pse[paymentMethodId]"/>
|
101 |
+
</div>
|
102 |
+
|
103 |
+
</div>
|
104 |
+
</div>
|
105 |
+
</fieldset>
|
106 |
+
|
107 |
+
<script type="text/javascript">
|
108 |
+
( function() {
|
109 |
+
|
110 |
+
var MPv1PSE = {
|
111 |
+
site_id: "",
|
112 |
+
// coupon_of_discounts: {
|
113 |
+
// discount_action_url: "",
|
114 |
+
// payer_email: "",
|
115 |
+
// default: true,
|
116 |
+
// status: false
|
117 |
+
// },
|
118 |
+
// inputs_to_create_discount: [
|
119 |
+
// "couponCodePSE",
|
120 |
+
// "applyCouponPSE"
|
121 |
+
// ],
|
122 |
+
inputs_to_validate_pse: [
|
123 |
+
"personType",
|
124 |
+
"docType",
|
125 |
+
"docNumber",
|
126 |
+
"bank"
|
127 |
+
],
|
128 |
+
selectors: {
|
129 |
+
// currency
|
130 |
+
currency_ratio: "#currency_ratioPSE",
|
131 |
+
// coupom
|
132 |
+
// couponCode: "#couponCodePSE",
|
133 |
+
// applyCoupon: "#applyCouponPSE",
|
134 |
+
mpCouponApplyed: "#mpCouponApplyedPSE",
|
135 |
+
mpCouponError: "#mpCouponErrorPSE",
|
136 |
+
campaign_id: "#campaign_idPSE",
|
137 |
+
campaign: "#campaignPSE",
|
138 |
+
discount: "#discountPSE",
|
139 |
+
// payment method and checkout
|
140 |
+
paymentMethodId: "#paymentMethodIdPSE",
|
141 |
+
amount: "#amountPSE",
|
142 |
+
// pse fields
|
143 |
+
personType: "#pse-person-type",
|
144 |
+
docType: "#pse-doc-type",
|
145 |
+
docNumber: "#pse-doc-number",
|
146 |
+
bank: "#pse-bank",
|
147 |
+
// form
|
148 |
+
formCoupon: "#mercadopago-form-coupon-pse",
|
149 |
+
formPSE: "#form-pse",
|
150 |
+
box_loading: "#mp-box-loading",
|
151 |
+
submit: "#btnSubmit",
|
152 |
+
form: "#mercadopago-form-pse"
|
153 |
+
},
|
154 |
+
text: {
|
155 |
+
discount_info1: "You will save",
|
156 |
+
discount_info2: "with discount from",
|
157 |
+
discount_info3: "Total of your purchase:",
|
158 |
+
discount_info4: "Total of your purchase with discount:",
|
159 |
+
discount_info5: "*Uppon payment approval",
|
160 |
+
discount_info6: "Terms and Conditions of Use",
|
161 |
+
coupon_empty: "Please, inform your coupon code",
|
162 |
+
apply: "Apply",
|
163 |
+
remove: "Remove"
|
164 |
+
},
|
165 |
+
paths: {
|
166 |
+
loading: "images/loading.gif",
|
167 |
+
check: "images/check.png",
|
168 |
+
error: "images/error.png"
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
// === Coupon of Discounts
|
173 |
+
|
174 |
+
MPv1PSE.currencyIdToCurrency = function ( currency_id ) {
|
175 |
+
if ( currency_id == "ARS" ) {
|
176 |
+
return "$";
|
177 |
+
} else if ( currency_id == "BRL" ) {
|
178 |
+
return "R$";
|
179 |
+
} else if ( currency_id == "COP" ) {
|
180 |
+
return "$";
|
181 |
+
} else if ( currency_id == "CLP" ) {
|
182 |
+
return "$";
|
183 |
+
} else if ( currency_id == "MXN" ) {
|
184 |
+
return "$";
|
185 |
+
} else if ( currency_id == "VEF" ) {
|
186 |
+
return "Bs";
|
187 |
+
} else if ( currency_id == "PEN" ) {
|
188 |
+
return "S/";
|
189 |
+
} else if ( currency_id == "UYU" ) {
|
190 |
+
return "$U";
|
191 |
+
} else {
|
192 |
+
return "$";
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
MPv1PSE.checkCouponEligibility = function () {
|
197 |
+
if ( document.querySelector( MPv1PSE.selectors.couponCode ).value == "" ) {
|
198 |
+
// Coupon code is empty.
|
199 |
+
document.querySelector( MPv1PSE.selectors.mpCouponApplyed ).style.display = "none";
|
200 |
+
document.querySelector( MPv1PSE.selectors.mpCouponError ).style.display = "block";
|
201 |
+
document.querySelector( MPv1PSE.selectors.mpCouponError ).innerHTML = MPv1PSE.text.coupon_empty;
|
202 |
+
MPv1PSE.coupon_of_discounts.status = false;
|
203 |
+
document.querySelector( MPv1PSE.selectors.couponCode ).style.background = null;
|
204 |
+
document.querySelector( MPv1PSE.selectors.applyCoupon ).value = MPv1PSE.text.apply;
|
205 |
+
document.querySelector( MPv1PSE.selectors.discount ).value = 0;
|
206 |
+
// --- No cards handler ---
|
207 |
+
} else if ( MPv1PSE.coupon_of_discounts.status ) {
|
208 |
+
// We already have a coupon set, so we remove it.
|
209 |
+
document.querySelector( MPv1PSE.selectors.mpCouponApplyed ).style.display = "none";
|
210 |
+
document.querySelector( MPv1PSE.selectors.mpCouponError ).style.display = "none";
|
211 |
+
MPv1PSE.coupon_of_discounts.status = false;
|
212 |
+
document.querySelector( MPv1PSE.selectors.applyCoupon ).style.background = null;
|
213 |
+
document.querySelector( MPv1PSE.selectors.applyCoupon ).value = MPv1PSE.text.apply;
|
214 |
+
document.querySelector( MPv1PSE.selectors.couponCode ).value = "";
|
215 |
+
document.querySelector( MPv1PSE.selectors.couponCode ).style.background = null;
|
216 |
+
document.querySelector( MPv1PSE.selectors.discount ).value = 0;
|
217 |
+
// --- No cards handler ---
|
218 |
+
} else {
|
219 |
+
// Set loading.
|
220 |
+
document.querySelector( MPv1PSE.selectors.mpCouponApplyed ).style.display = "none";
|
221 |
+
document.querySelector( MPv1PSE.selectors.mpCouponError ).style.display = "none";
|
222 |
+
document.querySelector( MPv1PSE.selectors.couponCode ).style.background = "url(" + MPv1PSE.paths.loading + ") 98% 50% no-repeat #fff";
|
223 |
+
document.querySelector( MPv1PSE.selectors.applyCoupon ).disabled = true;
|
224 |
+
|
225 |
+
// Check if there are params in the url.
|
226 |
+
var url = MPv1PSE.coupon_of_discounts.discount_action_url;
|
227 |
+
var sp = "?";
|
228 |
+
if ( url.indexOf( "?" ) >= 0 ) {
|
229 |
+
sp = "&";
|
230 |
+
}
|
231 |
+
url += sp + "site_id=" + MPv1PSE.site_id;
|
232 |
+
url += "&coupon_id=" + document.querySelector( MPv1PSE.selectors.couponCode ).value;
|
233 |
+
url += "&amount=" + document.querySelector( MPv1PSE.selectors.amount ).value;
|
234 |
+
url += "&payer=" + MPv1PSE.coupon_of_discounts.payer_email;
|
235 |
+
|
236 |
+
MPv1PSE.AJAX({
|
237 |
+
url: url,
|
238 |
+
method : "GET",
|
239 |
+
timeout : 5000,
|
240 |
+
error: function() {
|
241 |
+
// Request failed.
|
242 |
+
document.querySelector( MPv1PSE.selectors.mpCouponApplyed ).style.display = "none";
|
243 |
+
document.querySelector( MPv1PSE.selectors.mpCouponError ).style.display = "none";
|
244 |
+
MPv1PSE.coupon_of_discounts.status = false;
|
245 |
+
document.querySelector( MPv1PSE.selectors.applyCoupon ).style.background = null;
|
246 |
+
document.querySelector( MPv1PSE.selectors.applyCoupon ).value = MPv1PSE.text.apply;
|
247 |
+
document.querySelector( MPv1PSE.selectors.couponCode ).value = "";
|
248 |
+
document.querySelector( MPv1PSE.selectors.couponCode ).style.background = null;
|
249 |
+
document.querySelector( MPv1PSE.selectors.discount ).value = 0;
|
250 |
+
// --- No cards handler ---
|
251 |
+
},
|
252 |
+
success : function ( status, response ) {
|
253 |
+
if ( response.status == 200 ) {
|
254 |
+
document.querySelector( MPv1PSE.selectors.mpCouponApplyed ).style.display =
|
255 |
+
"block";
|
256 |
+
document.querySelector( MPv1PSE.selectors.discount ).value =
|
257 |
+
response.response.coupon_amount;
|
258 |
+
document.querySelector( MPv1PSE.selectors.mpCouponApplyed ).innerHTML =
|
259 |
+
MPv1PSE.text.discount_info1 + " <strong>" +
|
260 |
+
MPv1PSE.currencyIdToCurrency( response.response.currency_id ) + " " +
|
261 |
+
Math.round( response.response.coupon_amount * 100 ) / 100 +
|
262 |
+
"</strong> " + MPv1PSE.text.discount_info2 + " " +
|
263 |
+
response.response.name + ".<br>" + MPv1PSE.text.discount_info3 + " <strong>" +
|
264 |
+
MPv1PSE.currencyIdToCurrency( response.response.currency_id ) + " " +
|
265 |
+
Math.round( MPv1PSE.getAmountWithoutDiscount() * 100 ) / 100 +
|
266 |
+
"</strong><br>" + MPv1PSE.text.discount_info4 + " <strong>" +
|
267 |
+
MPv1PSE.currencyIdToCurrency( response.response.currency_id ) + " " +
|
268 |
+
Math.round( MPv1PSE.getAmount() * 100 ) / 100 + "*</strong><br>" +
|
269 |
+
"<i>" + MPv1PSE.text.discount_info5 + "</i><br>" +
|
270 |
+
"<a href='https://api.mercadolibre.com/campaigns/" +
|
271 |
+
response.response.id +
|
272 |
+
"/terms_and_conditions?format_type=html' target='_blank'>" +
|
273 |
+
MPv1PSE.text.discount_info6 + "</a>";
|
274 |
+
document.querySelector( MPv1PSE.selectors.mpCouponError ).style.display =
|
275 |
+
"none";
|
276 |
+
MPv1PSE.coupon_of_discounts.status = true;
|
277 |
+
document.querySelector( MPv1PSE.selectors.couponCode ).style.background =
|
278 |
+
null;
|
279 |
+
document.querySelector( MPv1PSE.selectors.couponCode ).style.background =
|
280 |
+
"url(" + MPv1PSE.paths.check + ") 98% 50% no-repeat #fff";
|
281 |
+
document.querySelector( MPv1PSE.selectors.applyCoupon ).value =
|
282 |
+
MPv1PSE.text.remove;
|
283 |
+
// --- No cards handler ---
|
284 |
+
document.querySelector( MPv1PSE.selectors.campaign_id ).value =
|
285 |
+
response.response.id;
|
286 |
+
document.querySelector( MPv1PSE.selectors.campaign ).value =
|
287 |
+
response.response.name;
|
288 |
+
} else {
|
289 |
+
document.querySelector( MPv1PSE.selectors.mpCouponApplyed ).style.display = "none";
|
290 |
+
document.querySelector( MPv1PSE.selectors.mpCouponError ).style.display = "block";
|
291 |
+
document.querySelector( MPv1PSE.selectors.mpCouponError ).innerHTML = response.response.message;
|
292 |
+
MPv1PSE.coupon_of_discounts.status = false;
|
293 |
+
document.querySelector(MPv1PSE.selectors.couponCode).style.background = null;
|
294 |
+
document.querySelector( MPv1PSE.selectors.couponCode ).style.background = "url(" + MPv1PSE.paths.error + ") 98% 50% no-repeat #fff";
|
295 |
+
document.querySelector( MPv1PSE.selectors.applyCoupon ).value = MPv1PSE.text.apply;
|
296 |
+
document.querySelector( MPv1PSE.selectors.discount ).value = 0;
|
297 |
+
// --- No cards handler ---
|
298 |
+
}
|
299 |
+
document.querySelector( MPv1PSE.selectors.applyCoupon ).disabled = false;
|
300 |
+
}
|
301 |
+
});
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
// === Initialization function
|
306 |
+
|
307 |
+
MPv1PSE.addListenerEvent = function( el, eventName, handler ) {
|
308 |
+
if ( el.addEventListener ) {
|
309 |
+
el.addEventListener( eventName, handler );
|
310 |
+
} else {
|
311 |
+
el.attachEvent( "on" + eventName, function() {
|
312 |
+
handler.call( el );
|
313 |
+
} );
|
314 |
+
}
|
315 |
+
};
|
316 |
+
|
317 |
+
MPv1PSE.referer = (function () {
|
318 |
+
var referer = window.location.protocol + "//" +
|
319 |
+
window.location.hostname + ( window.location.port ? ":" + window.location.port: "" );
|
320 |
+
return referer;
|
321 |
+
})();
|
322 |
+
|
323 |
+
MPv1PSE.AJAX = function( options ) {
|
324 |
+
var useXDomain = !!window.XDomainRequest;
|
325 |
+
var req = useXDomain ? new XDomainRequest() : new XMLHttpRequest()
|
326 |
+
var data;
|
327 |
+
options.url += ( options.url.indexOf( "?" ) >= 0 ? "&" : "?" ) + "referer=" + escape( MPv1PSE.referer );
|
328 |
+
options.requestedMethod = options.method;
|
329 |
+
if ( useXDomain && options.method == "PUT" ) {
|
330 |
+
options.method = "POST";
|
331 |
+
options.url += "&_method=PUT";
|
332 |
+
}
|
333 |
+
req.open( options.method, options.url, true );
|
334 |
+
req.timeout = options.timeout || 1000;
|
335 |
+
if ( window.XDomainRequest ) {
|
336 |
+
req.onload = function() {
|
337 |
+
data = JSON.parse( req.responseText );
|
338 |
+
if ( typeof options.success === "function" ) {
|
339 |
+
options.success( options.requestedMethod === "POST" ? 201 : 200, data );
|
340 |
+
}
|
341 |
+
};
|
342 |
+
req.onerror = req.ontimeout = function() {
|
343 |
+
if ( typeof options.error === "function" ) {
|
344 |
+
options.error( 400, {
|
345 |
+
user_agent:window.navigator.userAgent, error : "bad_request", cause:[]
|
346 |
+
});
|
347 |
+
}
|
348 |
+
};
|
349 |
+
req.onprogress = function() {};
|
350 |
+
} else {
|
351 |
+
req.setRequestHeader( "Accept", "application/json" );
|
352 |
+
if ( options.contentType ) {
|
353 |
+
req.setRequestHeader( "Content-Type", options.contentType );
|
354 |
+
} else {
|
355 |
+
req.setRequestHeader( "Content-Type", "application/json" );
|
356 |
+
}
|
357 |
+
req.onreadystatechange = function() {
|
358 |
+
if ( this.readyState === 4 ) {
|
359 |
+
try {
|
360 |
+
if ( this.status >= 200 && this.status < 400 ) {
|
361 |
+
// Success!
|
362 |
+
data = JSON.parse( this.responseText );
|
363 |
+
if ( typeof options.success === "function" ) {
|
364 |
+
options.success( this.status, data );
|
365 |
+
}
|
366 |
+
} else if ( this.status >= 400 ) {
|
367 |
+
data = JSON.parse( this.responseText );
|
368 |
+
if ( typeof options.error === "function" ) {
|
369 |
+
options.error( this.status, data );
|
370 |
+
}
|
371 |
+
} else if ( typeof options.error === "function" ) {
|
372 |
+
options.error( 503, {} );
|
373 |
+
}
|
374 |
+
} catch (e) {
|
375 |
+
options.error( 503, {} );
|
376 |
+
}
|
377 |
+
}
|
378 |
+
};
|
379 |
+
}
|
380 |
+
if ( options.method === "GET" || options.data == null || options.data == undefined ) {
|
381 |
+
req.send();
|
382 |
+
} else {
|
383 |
+
req.send( JSON.stringify( options.data ) );
|
384 |
+
}
|
385 |
+
}
|
386 |
+
|
387 |
+
// Form validation
|
388 |
+
|
389 |
+
var doSubmitPSE = false;
|
390 |
+
|
391 |
+
MPv1PSE.doPay = function() {
|
392 |
+
if(!doSubmitPSE){
|
393 |
+
doSubmitPSE=true;
|
394 |
+
document.querySelector(MPv1PSE.selectors.box_loading).style.background = "url("+MPv1PSE.paths.loading+") 0 50% no-repeat #fff";
|
395 |
+
btn = document.querySelector(MPv1PSE.selectors.form);
|
396 |
+
btn.submit();
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
MPv1PSE.validateInputsPSE = function(event) {
|
401 |
+
event.preventDefault();
|
402 |
+
MPv1PSE.hideErrors();
|
403 |
+
var valid_to_pse = true;
|
404 |
+
var $inputs = MPv1PSE.getForm().querySelectorAll("[data-checkout]");
|
405 |
+
var $inputs_to_validate_pse = MPv1PSE.inputs_to_validate_pse;
|
406 |
+
var arr = [];
|
407 |
+
for (var x = 0; x < $inputs.length; x++) {
|
408 |
+
var element = $inputs[x];
|
409 |
+
if($inputs_to_validate_pse.indexOf(element.getAttribute("data-checkout")) > -1){
|
410 |
+
if (element.value == -1 || element.value == "") {
|
411 |
+
arr.push(element.id);
|
412 |
+
valid_to_pse = false;
|
413 |
+
}
|
414 |
+
}
|
415 |
+
}
|
416 |
+
if (!valid_to_pse) {
|
417 |
+
MPv1PSE.showErrors(arr);
|
418 |
+
}
|
419 |
+
}
|
420 |
+
|
421 |
+
MPv1PSE.getForm = function(){
|
422 |
+
return document.querySelector(MPv1PSE.selectors.form);
|
423 |
+
}
|
424 |
+
|
425 |
+
// Show/hide errors.
|
426 |
+
|
427 |
+
MPv1PSE.showErrors = function(fields){
|
428 |
+
var $form = MPv1PSE.getForm();
|
429 |
+
for(var x = 0; x < fields.length; x++){
|
430 |
+
var f = fields[x];
|
431 |
+
var $span = $form.querySelector("#error-" + f);
|
432 |
+
var $input = $form.querySelector($span.getAttribute("data-main"));
|
433 |
+
$span.style.display = "inline-block";
|
434 |
+
$input.classList.add("mp-error-input");
|
435 |
+
}
|
436 |
+
return;
|
437 |
+
}
|
438 |
+
|
439 |
+
MPv1PSE.hideErrors = function(){
|
440 |
+
for(var x = 0; x < document.querySelectorAll("[data-checkout]").length; x++){
|
441 |
+
var $field = document.querySelectorAll("[data-checkout]")[x];
|
442 |
+
$field.classList.remove("mp-error-input");
|
443 |
+
} //end for
|
444 |
+
for(var x = 0; x < document.querySelectorAll(".erro_pse").length; x++){
|
445 |
+
var $span = document.querySelectorAll(".erro_pse")[x];
|
446 |
+
$span.style.display = "none";
|
447 |
+
}
|
448 |
+
return;
|
449 |
+
}
|
450 |
+
|
451 |
+
MPv1PSE.Initialize = function( site_id, coupon_mode, discount_action_url, payer_email ) {
|
452 |
+
|
453 |
+
// Sets.
|
454 |
+
MPv1PSE.site_id = site_id;
|
455 |
+
// MPv1PSE.coupon_of_discounts.default = coupon_mode;
|
456 |
+
// MPv1PSE.coupon_of_discounts.discount_action_url = discount_action_url;
|
457 |
+
// MPv1PSE.coupon_of_discounts.payer_email = payer_email;
|
458 |
+
|
459 |
+
// Flow coupon of discounts.
|
460 |
+
// if ( MPv1PSE.coupon_of_discounts.default ) {
|
461 |
+
// MPv1PSE.addListenerEvent(
|
462 |
+
// document.querySelector( MPv1PSE.selectors.applyCoupon ),
|
463 |
+
// "click",
|
464 |
+
// MPv1PSE.checkCouponEligibility
|
465 |
+
// );
|
466 |
+
// } else {
|
467 |
+
// document.querySelector( MPv1PSE.selectors.formCoupon ).style.display = "none";
|
468 |
+
// }
|
469 |
+
|
470 |
+
MPv1PSE.hideErrors();
|
471 |
+
return;
|
472 |
+
}
|
473 |
+
|
474 |
+
this.MPv1PSE = MPv1PSE;
|
475 |
+
|
476 |
+
MPv1PSE.getAmount = function() {
|
477 |
+
return document.querySelector( MPv1PSE.selectors.amount )
|
478 |
+
.value - document.querySelector( MPv1PSE.selectors.discount ).value;
|
479 |
+
}
|
480 |
+
|
481 |
+
MPv1PSE.getAmountWithoutDiscount = function() {
|
482 |
+
return document.querySelector( MPv1PSE.selectors.amount ).value;
|
483 |
+
}
|
484 |
+
|
485 |
+
MPv1PSE.text.apply = "<?php echo __( 'Apply', 'woocommerce-mercadopago' ); ?>";
|
486 |
+
MPv1PSE.text.remove = "<?php echo __( 'Remove', 'woocommerce-mercadopago' ); ?>";
|
487 |
+
MPv1PSE.text.coupon_empty = "<?php echo __( 'Please, inform your coupon code', 'woocommerce-mercadopago' ); ?>";
|
488 |
+
MPv1PSE.text.discount_info1 = "<?php echo __( 'You will save', 'woocommerce-mercadopago' ); ?>";
|
489 |
+
MPv1PSE.text.discount_info2 = "<?php echo __( 'with discount from', 'woocommerce-mercadopago' ); ?>";
|
490 |
+
MPv1PSE.text.discount_info3 = "<?php echo __( 'Total of your purchase:', 'woocommerce-mercadopago' ); ?>";
|
491 |
+
MPv1PSE.text.discount_info4 = "<?php echo __( 'Total of your purchase with discount:', 'woocommerce-mercadopago' ); ?>";
|
492 |
+
MPv1PSE.text.discount_info5 = "<?php echo __( '*Uppon payment approval', 'woocommerce-mercadopago' ); ?>";
|
493 |
+
MPv1PSE.text.discount_info6 = "<?php echo __( 'Terms and Conditions of Use', 'woocommerce-mercadopago' ); ?>";
|
494 |
+
|
495 |
+
MPv1PSE.paths.loading = "<?php echo ( $images_path . 'loading.gif' ); ?>";
|
496 |
+
MPv1PSE.paths.check = "<?php echo ( $images_path . 'check.png' ); ?>";
|
497 |
+
MPv1PSE.paths.error = "<?php echo ( $images_path . 'error.png' ); ?>";
|
498 |
+
|
499 |
+
MPv1PSE.Initialize(
|
500 |
+
"<?php echo $site_id; ?>",
|
501 |
+
"<?php echo $coupon_mode; ?>" == "no",
|
502 |
+
"<?php echo $discount_action_url; ?>",
|
503 |
+
"<?php echo $payer_email; ?>"
|
504 |
+
);
|
505 |
+
} ).call();
|
506 |
+
|
507 |
+
document.querySelector( "#pse_checkout_fieldset" ).style.display = "block";
|
508 |
+
</script>
|
templates/ticket/ticket-form.php
CHANGED
File without changes
|
woocommerce-mercadopago.php
CHANGED
@@ -3,13 +3,13 @@
|
|
3 |
* Plugin Name: WooCommerce MercadoPago
|
4 |
* Plugin URI: https://github.com/mercadopago/cart-woocommerce
|
5 |
* Description: This is the <strong>oficial</strong> module of Mercado Pago for WooCommerce plugin. This module enables WooCommerce to use Mercado Pago as a payment Gateway for purchases made in your e-commerce store.
|
6 |
-
* Version: 3.0.
|
7 |
* Author: Mercado Pago
|
8 |
* Author URI: https://www.mercadopago.com.br/developers/
|
9 |
* Text Domain: woocommerce-mercadopago
|
10 |
* Domain Path: /i18n/languages/
|
11 |
* WC requires at least: 3.0.0
|
12 |
-
* WC tested up to: 3.
|
13 |
*
|
14 |
* @package MercadoPago
|
15 |
* @category Core
|
@@ -106,7 +106,7 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
|
|
106 |
// ============================================================
|
107 |
|
108 |
// General constants.
|
109 |
-
const VERSION = '3.0.
|
110 |
const MIN_PHP = 5.6;
|
111 |
|
112 |
// Arrays to hold configurations for LatAm environment.
|
@@ -195,6 +195,7 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
|
|
195 |
include_once dirname( __FILE__ ) . '/includes/WC_WooMercadoPago_BasicGateway.php';
|
196 |
include_once dirname( __FILE__ ) . '/includes/WC_WooMercadoPago_CustomGateway.php';
|
197 |
include_once dirname( __FILE__ ) . '/includes/WC_WooMercadoPago_TicketGateway.php';
|
|
|
198 |
include_once dirname( __FILE__ ) . '/includes/WC_WooMercadoPago_SubscriptionGateway.php';
|
199 |
include_once dirname( __FILE__ ) . '/includes/class-wc-product-mp_recurrent.php';
|
200 |
add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateway' ) );
|
@@ -238,6 +239,7 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
|
|
238 |
$methods[] = 'WC_WooMercadoPago_BasicGateway';
|
239 |
$methods[] = 'WC_WooMercadoPago_CustomGateway';
|
240 |
$methods[] = 'WC_WooMercadoPago_TicketGateway';
|
|
|
241 |
$methods[] = 'WC_WooMercadoPago_SubscriptionGateway';
|
242 |
return $methods;
|
243 |
}
|
@@ -410,7 +412,8 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
|
|
410 |
if ( $payment['payment_type_id'] != 'account_money' &&
|
411 |
$payment['payment_type_id'] != 'credit_card' &&
|
412 |
$payment['payment_type_id'] != 'debit_card' &&
|
413 |
-
$payment['payment_type_id'] != 'prepaid_card'
|
|
|
414 |
$obj = new stdClass();
|
415 |
$obj->id = $payment['id'];
|
416 |
$obj->name = $payment['name'];
|
@@ -692,42 +695,33 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
|
|
692 |
return str_replace( '_', '-', $status );
|
693 |
}
|
694 |
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
__( "Update WooCommerce order to ", "woocommerce-mercadopago" ) . 'CANCELLED
|
723 |
-
</option>
|
724 |
-
<option value="refunded"' . ( $selection == 'refunded' ? 'selected="selected"' : '' ) . '>' .
|
725 |
-
__( "Update WooCommerce order to ", "woocommerce-mercadopago" ) . 'REFUNDED
|
726 |
-
</option>
|
727 |
-
<option value="failed"' . ( $selection == 'failed' ? 'selected="selected"' : '' ) . '>' .
|
728 |
-
__( "Update WooCommerce order to ", "woocommerce-mercadopago" ) . 'FAILED
|
729 |
-
</option>';
|
730 |
-
}
|
731 |
|
732 |
public static function generate_refund_cancel_subscription( $domain, $success_msg, $fail_msg, $options, $str1, $str2, $str3, $str4 ) {
|
733 |
$subscription_js = '<script type="text/javascript">
|
@@ -925,86 +919,22 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
|
|
925 |
|
926 |
// Check for submits.
|
927 |
if ( isset( $_POST['submit'] ) ) {
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
update_option( '_mp_access_token', $_POST['access_token'], true );
|
945 |
-
} else {
|
946 |
-
update_option( '_mp_access_token', '', true );
|
947 |
-
}
|
948 |
-
if ( isset( $_POST['success_url'] ) ) {
|
949 |
-
update_option( '_mp_success_url', $_POST['success_url'], true );
|
950 |
-
} else {
|
951 |
-
update_option( '_mp_success_url', '', true );
|
952 |
-
}
|
953 |
-
if ( isset( $_POST['fail_url'] ) ) {
|
954 |
-
update_option( '_mp_fail_url', $_POST['fail_url'], true );
|
955 |
-
} else {
|
956 |
-
update_option( '_mp_fail_url', '', true );
|
957 |
-
}
|
958 |
-
if ( isset( $_POST['pending_url'] ) ) {
|
959 |
-
update_option( '_mp_pending_url', $_POST['pending_url'], true );
|
960 |
-
} else {
|
961 |
-
update_option( '_mp_pending_url', '', true );
|
962 |
-
}
|
963 |
-
if ( isset( $_POST['order_status_pending_map'] ) ) {
|
964 |
-
update_option( '_mp_order_status_pending_map', $_POST['order_status_pending_map'], true );
|
965 |
-
} else {
|
966 |
-
update_option( '_mp_order_status_pending_map', '', true );
|
967 |
-
}
|
968 |
-
if ( isset( $_POST['order_status_approved_map'] ) ) {
|
969 |
-
update_option( '_mp_order_status_approved_map', $_POST['order_status_approved_map'], true );
|
970 |
-
} else {
|
971 |
-
update_option( '_mp_order_status_approved_map', '', true );
|
972 |
-
}
|
973 |
-
if ( isset( $_POST['order_status_inprocess_map'] ) ) {
|
974 |
-
update_option( '_mp_order_status_inprocess_map', $_POST['order_status_inprocess_map'], true );
|
975 |
-
} else {
|
976 |
-
update_option( '_mp_order_status_inprocess_map', '', true );
|
977 |
-
}
|
978 |
-
if ( isset( $_POST['order_status_inmediation_map'] ) ) {
|
979 |
-
update_option( '_mp_order_status_inmediation_map', $_POST['order_status_inmediation_map'], true );
|
980 |
-
} else {
|
981 |
-
update_option( '_mp_order_status_inmediation_map', '', true );
|
982 |
-
}
|
983 |
-
if ( isset( $_POST['order_status_rejected_map'] ) ) {
|
984 |
-
update_option( '_mp_order_status_rejected_map', $_POST['order_status_rejected_map'], true );
|
985 |
-
} else {
|
986 |
-
update_option( '_mp_order_status_rejected_map', '', true );
|
987 |
-
}
|
988 |
-
if ( isset( $_POST['order_status_cancelled_map'] ) ) {
|
989 |
-
update_option( '_mp_order_status_cancelled_map', $_POST['order_status_cancelled_map'], true );
|
990 |
-
} else {
|
991 |
-
update_option( '_mp_order_status_cancelled_map', '', true );
|
992 |
-
}
|
993 |
-
if ( isset( $_POST['order_status_refunded_map'] ) ) {
|
994 |
-
update_option( '_mp_order_status_refunded_map', $_POST['order_status_refunded_map'], true );
|
995 |
-
} else {
|
996 |
-
update_option( '_mp_order_status_refunded_map', '', true );
|
997 |
-
}
|
998 |
-
if ( isset( $_POST['order_status_chargedback_map'] ) ) {
|
999 |
-
update_option( '_mp_order_status_chargedback_map', $_POST['order_status_chargedback_map'], true );
|
1000 |
-
} else {
|
1001 |
-
update_option( '_mp_order_status_chargedback_map', '', true );
|
1002 |
-
}
|
1003 |
-
if ( isset( $_POST['statement_descriptor'] ) ) {
|
1004 |
-
update_option( '_mp_statement_descriptor', $_POST['statement_descriptor'], true );
|
1005 |
-
} else {
|
1006 |
-
update_option( '_mp_statement_descriptor', '', true );
|
1007 |
-
}
|
1008 |
if ( isset( $_POST['category_id'] ) ) {
|
1009 |
update_option( '_mp_category_id', $_POST['category_id'], true );
|
1010 |
$categories_data = WC_Woo_Mercado_Pago_Module::$categories;
|
@@ -1013,41 +943,13 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
|
|
1013 |
update_option( '_mp_category_id', '', true );
|
1014 |
update_option( '_mp_category_name', 'others', true );
|
1015 |
}
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
} else {
|
1024 |
-
update_option( '_mp_custom_banner', '', true );
|
1025 |
-
}
|
1026 |
-
if ( isset( $_POST['custom_domain'] ) ) {
|
1027 |
-
update_option( '_mp_custom_domain', $_POST['custom_domain'], true );
|
1028 |
-
} else {
|
1029 |
-
update_option( '_mp_custom_domain', '', true );
|
1030 |
-
}
|
1031 |
-
if ( isset( $_POST['currency_conversion_v0'] ) ) {
|
1032 |
-
update_option( '_mp_currency_conversion_v0', $_POST['currency_conversion_v0'], true );
|
1033 |
-
} else {
|
1034 |
-
update_option( '_mp_currency_conversion_v0', '', true );
|
1035 |
-
}
|
1036 |
-
if ( isset( $_POST['currency_conversion_v1'] ) ) {
|
1037 |
-
update_option( '_mp_currency_conversion_v1', $_POST['currency_conversion_v1'], true );
|
1038 |
-
} else {
|
1039 |
-
update_option( '_mp_currency_conversion_v1', '', true );
|
1040 |
-
}
|
1041 |
-
if ( isset( $_POST['debug_mode'] ) ) {
|
1042 |
-
update_option( '_mp_debug_mode', $_POST['debug_mode'], true );
|
1043 |
-
} else {
|
1044 |
-
update_option( '_mp_debug_mode', '', true );
|
1045 |
-
}
|
1046 |
-
if ( isset( $_POST['sandbox_mode'] ) ) {
|
1047 |
-
update_option( '_mp_sandbox_mode', $_POST['sandbox_mode'], true );
|
1048 |
-
} else {
|
1049 |
-
update_option( '_mp_sandbox_mode', '', true );
|
1050 |
-
}
|
1051 |
}
|
1052 |
|
1053 |
// Mercado Pago logo.
|
@@ -1102,8 +1004,13 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
|
|
1102 |
'">' . __( 'Ticket', 'woocommerce-mercadopago' ) . '</a>' . ' ' .
|
1103 |
'<a class="button button-primary" href="' . esc_url( admin_url(
|
1104 |
'admin.php?page=wc-settings&tab=checkout§ion=woo-mercado-pago-subscription' ) ) .
|
1105 |
-
'">' . __( 'Subscription', 'woocommerce-mercadopago' ) . '</a>'
|
1106 |
-
|
|
|
|
|
|
|
|
|
|
|
1107 |
// Statement descriptor.
|
1108 |
$statement_descriptor = get_option( '_mp_statement_descriptor', 'Mercado Pago' );
|
1109 |
// Get categories.
|
@@ -1281,53 +1188,6 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
|
|
1281 |
);
|
1282 |
});
|
1283 |
|
1284 |
-
// ==========================================================================================
|
1285 |
-
|
1286 |
-
// add custom field for checkout
|
1287 |
-
/*add_filter( 'woocommerce_checkout_fields', 'custom_override_checkout_fields', 10, 2 );
|
1288 |
-
// check for specific countries to add specific custom fields
|
1289 |
-
function custom_override_checkout_fields( $fields ) {
|
1290 |
-
$fields['billing']['billing_payer_doc_type']['type'] = 'select';
|
1291 |
-
$fields['billing']['billing_payer_doc_type']['options'] = array(
|
1292 |
-
'option_1' => 'CPF',
|
1293 |
-
'option_2' => 'CNPJ'
|
1294 |
-
);
|
1295 |
-
$fields['billing']['billing_payer_doc_type']['label'] = esc_html__( 'Document Type', 'woocommerce-mercadopago' );
|
1296 |
-
$fields['billing']['billing_payer_doc_type']['class'] = array(
|
1297 |
-
'form-row-first'
|
1298 |
-
);
|
1299 |
-
$fields['billing']['billing_payer_doc']['type'] = 'text';
|
1300 |
-
$fields['billing']['billing_payer_doc']['label'] = esc_html__( 'Document number', 'woocommerce-mercadopago' );
|
1301 |
-
$fields['billing']['billing_payer_doc']['required'] = true;
|
1302 |
-
$fields['billing']['billing_payer_doc']['class'] = array(
|
1303 |
-
'form-row-last'
|
1304 |
-
);
|
1305 |
-
$fields['billing']['billing_address_number']['type'] = 'text';
|
1306 |
-
$fields['billing']['billing_address_number']['label'] = esc_html__( 'Address Number', 'woocommerce-mercadopago' );
|
1307 |
-
$fields['billing']['billing_address_number']['class'] = array(
|
1308 |
-
'form-row-first'
|
1309 |
-
);
|
1310 |
-
$fields['billing']['billing_address_2']['class'] = array(
|
1311 |
-
'form-row-last'
|
1312 |
-
);
|
1313 |
-
$fields['billing']['billing_address_2']['label'] = esc_html__( 'Address Additional Info', 'woocommerce-mercadopago' );'Complemento';
|
1314 |
-
$order = array(
|
1315 |
-
'billing_first_name', 'billing_last_name',
|
1316 |
-
'billing_payer_doc_type', 'billing_payer_doc',
|
1317 |
-
'billing_company',
|
1318 |
-
'billing_address_1',
|
1319 |
-
'billing_address_number', 'billing_address_2',
|
1320 |
-
'billing_postcode',
|
1321 |
-
'billing_country',
|
1322 |
-
'billing_email', 'billing_phone'
|
1323 |
-
);
|
1324 |
-
foreach( $order as $field ) {
|
1325 |
-
$ordered_fields[$field] = $fields['billing'][$field];
|
1326 |
-
}
|
1327 |
-
$fields['billing'] = $ordered_fields;
|
1328 |
-
return $fields;
|
1329 |
-
}*/
|
1330 |
-
|
1331 |
// add our own item to the order actions meta box
|
1332 |
add_action( 'woocommerce_order_actions', 'add_mp_order_meta_box_actions' );
|
1333 |
// define the item in the meta box by adding an item to the $actions array
|
3 |
* Plugin Name: WooCommerce MercadoPago
|
4 |
* Plugin URI: https://github.com/mercadopago/cart-woocommerce
|
5 |
* Description: This is the <strong>oficial</strong> module of Mercado Pago for WooCommerce plugin. This module enables WooCommerce to use Mercado Pago as a payment Gateway for purchases made in your e-commerce store.
|
6 |
+
* Version: 3.0.16
|
7 |
* Author: Mercado Pago
|
8 |
* Author URI: https://www.mercadopago.com.br/developers/
|
9 |
* Text Domain: woocommerce-mercadopago
|
10 |
* Domain Path: /i18n/languages/
|
11 |
* WC requires at least: 3.0.0
|
12 |
+
* WC tested up to: 3.4.3
|
13 |
*
|
14 |
* @package MercadoPago
|
15 |
* @category Core
|
106 |
// ============================================================
|
107 |
|
108 |
// General constants.
|
109 |
+
const VERSION = '3.0.16';
|
110 |
const MIN_PHP = 5.6;
|
111 |
|
112 |
// Arrays to hold configurations for LatAm environment.
|
195 |
include_once dirname( __FILE__ ) . '/includes/WC_WooMercadoPago_BasicGateway.php';
|
196 |
include_once dirname( __FILE__ ) . '/includes/WC_WooMercadoPago_CustomGateway.php';
|
197 |
include_once dirname( __FILE__ ) . '/includes/WC_WooMercadoPago_TicketGateway.php';
|
198 |
+
include_once dirname( __FILE__ ) . '/includes/WC_WooMercadoPago_PSEGateway.php';
|
199 |
include_once dirname( __FILE__ ) . '/includes/WC_WooMercadoPago_SubscriptionGateway.php';
|
200 |
include_once dirname( __FILE__ ) . '/includes/class-wc-product-mp_recurrent.php';
|
201 |
add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateway' ) );
|
239 |
$methods[] = 'WC_WooMercadoPago_BasicGateway';
|
240 |
$methods[] = 'WC_WooMercadoPago_CustomGateway';
|
241 |
$methods[] = 'WC_WooMercadoPago_TicketGateway';
|
242 |
+
$methods[] = 'WC_WooMercadoPago_PSEGateway';
|
243 |
$methods[] = 'WC_WooMercadoPago_SubscriptionGateway';
|
244 |
return $methods;
|
245 |
}
|
412 |
if ( $payment['payment_type_id'] != 'account_money' &&
|
413 |
$payment['payment_type_id'] != 'credit_card' &&
|
414 |
$payment['payment_type_id'] != 'debit_card' &&
|
415 |
+
$payment['payment_type_id'] != 'prepaid_card' &&
|
416 |
+
$payment['id'] != 'pse') {
|
417 |
$obj = new stdClass();
|
418 |
$obj->id = $payment['id'];
|
419 |
$obj->name = $payment['name'];
|
695 |
return str_replace( '_', '-', $status );
|
696 |
}
|
697 |
|
698 |
+
public static function get_map( $selector_id ) {
|
699 |
+
$arr = explode( '_', $selector_id );
|
700 |
+
$defaults = array(
|
701 |
+
'pending' => 'pending',
|
702 |
+
'approved' => 'processing',
|
703 |
+
'inprocess' => 'on_hold',
|
704 |
+
'inmediation' => 'on_hold',
|
705 |
+
'rejected' => 'failed',
|
706 |
+
'cancelled' => 'cancelled',
|
707 |
+
'refunded' => 'refunded',
|
708 |
+
'chargedback' => 'refunded'
|
709 |
+
);
|
710 |
+
$selection = get_option( '_mp_' . $selector_id, $defaults[$arr[2]] );
|
711 |
+
|
712 |
+
foreach ( wc_get_order_statuses() as $slug => $status ) {
|
713 |
+
$slug = str_replace( array( 'wc-', '-' ), array( '', '_' ), $slug );
|
714 |
+
$html .= sprintf(
|
715 |
+
'<option value="%s"%s>%s %s</option>',
|
716 |
+
$slug,
|
717 |
+
selected( $selection, $slug, false ),
|
718 |
+
__( 'Update WooCommerce order to ', 'woocommerce-mercadopago' ),
|
719 |
+
$status
|
720 |
+
);
|
721 |
+
}
|
722 |
+
|
723 |
+
return $html;
|
724 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
725 |
|
726 |
public static function generate_refund_cancel_subscription( $domain, $success_msg, $fail_msg, $options, $str1, $str2, $str3, $str4 ) {
|
727 |
$subscription_js = '<script type="text/javascript">
|
919 |
|
920 |
// Check for submits.
|
921 |
if ( isset( $_POST['submit'] ) ) {
|
922 |
+
update_option( '_mp_client_id', isset( $_POST['client_id'] ) ? $_POST['client_id'] : '', true );
|
923 |
+
update_option( '_mp_client_secret', isset( $_POST['client_secret'] ) ? $_POST['client_secret'] : '', true );
|
924 |
+
update_option( '_mp_public_key', isset( $_POST['public_key'] ) ? $_POST['public_key'] : '', true );
|
925 |
+
update_option( '_mp_access_token', isset( $_POST['access_token'] ) ? $_POST['access_token'] : '', true );
|
926 |
+
update_option( '_mp_success_url', isset( $_POST['success_url'] ) ? $_POST['success_url'] : '', true );
|
927 |
+
update_option( '_mp_fail_url', isset( $_POST['fail_url'] ) ? $_POST['fail_url'] : '', true );
|
928 |
+
update_option( '_mp_pending_url', isset( $_POST['pending_url'] ) ? $_POST['pending_url'] : '', true );
|
929 |
+
update_option( '_mp_order_status_pending_map', isset( $_POST['order_status_pending_map'] ) ? $_POST['order_status_pending_map'] : '', true );
|
930 |
+
update_option( '_mp_order_status_approved_map', isset( $_POST['order_status_approved_map'] ) ? $_POST['order_status_approved_map'] : '', true );
|
931 |
+
update_option( '_mp_order_status_inprocess_map', isset( $_POST['order_status_inprocess_map'] ) ? $_POST['order_status_inprocess_map'] : '', true );
|
932 |
+
update_option( '_mp_order_status_inmediation_map', isset( $_POST['order_status_inmediation_map'] ) ? $_POST['order_status_inmediation_map'] : '', true );
|
933 |
+
update_option( '_mp_order_status_rejected_map', isset( $_POST['order_status_rejected_map'] ) ? $_POST['order_status_rejected_map'] : '', true );
|
934 |
+
update_option( '_mp_order_status_cancelled_map', isset( $_POST['order_status_cancelled_map'] ) ? $_POST['order_status_cancelled_map'] : '', true );
|
935 |
+
update_option( '_mp_order_status_refunded_map', isset( $_POST['order_status_refunded_map'] ) ? $_POST['order_status_refunded_map'] : '', true );
|
936 |
+
update_option( '_mp_order_status_chargedback_map', isset( $_POST['order_status_chargedback_map'] ) ? $_POST['order_status_chargedback_map'] : '', true );
|
937 |
+
update_option( '_mp_statement_descriptor', isset( $_POST['statement_descriptor'] ) ? $_POST['statement_descriptor'] : '', true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
938 |
if ( isset( $_POST['category_id'] ) ) {
|
939 |
update_option( '_mp_category_id', $_POST['category_id'], true );
|
940 |
$categories_data = WC_Woo_Mercado_Pago_Module::$categories;
|
943 |
update_option( '_mp_category_id', '', true );
|
944 |
update_option( '_mp_category_name', 'others', true );
|
945 |
}
|
946 |
+
update_option( '_mp_store_identificator', isset( $_POST['store_identificator'] ) ? $_POST['store_identificator'] : '', true );
|
947 |
+
update_option( '_mp_custom_banner', isset( $_POST['custom_banner'] ) ? $_POST['custom_banner'] : '', true );
|
948 |
+
update_option( '_mp_custom_domain', isset( $_POST['custom_domain'] ) ? $_POST['custom_domain'] : '', true );
|
949 |
+
update_option( '_mp_currency_conversion_v0', isset( $_POST['currency_conversion_v0'] ) ? $_POST['currency_conversion_v0'] : '', true );
|
950 |
+
update_option( '_mp_currency_conversion_v1', isset( $_POST['currency_conversion_v1'] ) ? $_POST['currency_conversion_v1'] : '', true );
|
951 |
+
update_option( '_mp_debug_mode', isset( $_POST['debug_mode'] ) ? $_POST['debug_mode'] : '', true );
|
952 |
+
update_option( '_mp_sandbox_mode', isset( $_POST['sandbox_mode'] ) ? $_POST['sandbox_mode'] : '', true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
953 |
}
|
954 |
|
955 |
// Mercado Pago logo.
|
1004 |
'">' . __( 'Ticket', 'woocommerce-mercadopago' ) . '</a>' . ' ' .
|
1005 |
'<a class="button button-primary" href="' . esc_url( admin_url(
|
1006 |
'admin.php?page=wc-settings&tab=checkout§ion=woo-mercado-pago-subscription' ) ) .
|
1007 |
+
'">' . __( 'Subscription', 'woocommerce-mercadopago' ) . '</a>';
|
1008 |
+
if ( get_option('_site_id_v1', '') == 'MCO' ) {
|
1009 |
+
$gateway_buttons .= ' <a class="button button-primary" href="' . esc_url( admin_url(
|
1010 |
+
'admin.php?page=wc-settings&tab=checkout§ion=woo-mercado-pago-pse' ) ) .
|
1011 |
+
'">' . __( 'PSE', 'woocommerce-mercadopago' ) . '</a>';
|
1012 |
+
}
|
1013 |
+
$gateway_buttons .= '</strong>';
|
1014 |
// Statement descriptor.
|
1015 |
$statement_descriptor = get_option( '_mp_statement_descriptor', 'Mercado Pago' );
|
1016 |
// Get categories.
|
1188 |
);
|
1189 |
});
|
1190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1191 |
// add our own item to the order actions meta box
|
1192 |
add_action( 'woocommerce_order_actions', 'add_mp_order_meta_box_actions' );
|
1193 |
// define the item in the meta box by adding an item to the $actions array
|