Version Description
Download this release
Release Info
Developer | mercadopago |
Plugin | WooCommerce MercadoPago |
Version | 5.7.3 |
Comparing to | |
See all releases |
Code changes from version 5.7.2 to 5.7.3
- assets/js/mercadopago-settings/mercadopago_settings.js +12 -14
- assets/js/mercadopago-settings/mercadopago_settings.min.js +1 -1
- includes/admin/hooks/class-wc-woomercadopago-hook-order-details.php +1 -1
- includes/module/class-wc-woomercadopago-credentials.php +1 -1
- includes/module/class-wc-woomercadopago-init.php +1 -0
- includes/module/class-wc-woomercadopago-module.php +376 -313
- includes/module/config/class-wc-woomercadopago-constants.php +1 -1
- includes/payments/class-wc-woomercadopago-basic-gateway.php +2 -2
- includes/payments/class-wc-woomercadopago-custom-gateway.php +1 -1
- includes/payments/class-wc-woomercadopago-pix-gateway.php +1 -1
- includes/payments/class-wc-woomercadopago-ticket-gateway.php +4 -4
- readme.txt +8 -1
- woocommerce-mercadopago.php +1 -1
assets/js/mercadopago-settings/mercadopago_settings.js
CHANGED
@@ -52,9 +52,9 @@ function mp_validate_credentials() {
|
|
52 |
var self = this;
|
53 |
|
54 |
jQuery.post(ajaxurl, { access_token: this.value, is_test: false, action: "mp_validate_credentials"}, function(data) {
|
55 |
-
|
56 |
}).done(function (response) {
|
57 |
-
if (response.
|
58 |
self.classList.add("mp-credential-feedback-positive");
|
59 |
self.classList.remove("mp-credential-feedback-negative");
|
60 |
} else {
|
@@ -74,9 +74,9 @@ function mp_validate_credentials() {
|
|
74 |
var self = this;
|
75 |
|
76 |
jQuery.post(ajaxurl, { access_token: this.value, is_test: true, action: "mp_validate_credentials"}, function(data) {
|
77 |
-
|
78 |
}).done(function (response) {
|
79 |
-
if (response.
|
80 |
self.classList.add( "mp-credential-feedback-positive" );
|
81 |
self.classList.remove( "mp-credential-feedback-negative" );
|
82 |
} else {
|
@@ -95,10 +95,9 @@ function mp_validate_credentials() {
|
|
95 |
var self = this;
|
96 |
|
97 |
jQuery.post(ajaxurl, { public_key: this.value, is_test: true, action: "mp_validate_credentials"}, function(data) {
|
98 |
-
console.log('validated');
|
99 |
})
|
100 |
.done(function (response) {
|
101 |
-
if (response.
|
102 |
self.classList.add( "mp-credential-feedback-positive" );
|
103 |
self.classList.remove( "mp-credential-feedback-negative" );
|
104 |
} else {
|
@@ -118,10 +117,9 @@ function mp_validate_credentials() {
|
|
118 |
var self = this;
|
119 |
|
120 |
jQuery.post(ajaxurl, { public_key: this.value, is_test: false, action: "mp_validate_credentials"}, function(data) {
|
121 |
-
console.log('validated');
|
122 |
})
|
123 |
.done(function (response) {
|
124 |
-
if (response.
|
125 |
self.classList.add( "mp-credential-feedback-positive" );
|
126 |
self.classList.remove( "mp-credential-feedback-negative" );
|
127 |
} else {
|
@@ -162,11 +160,11 @@ function mp_update_option_credentials() {
|
|
162 |
);
|
163 |
}, 3000);
|
164 |
} else {
|
165 |
-
mp_show_message(
|
166 |
}
|
167 |
})
|
168 |
.fail(function (error) {
|
169 |
-
mp_show_message(
|
170 |
});
|
171 |
});
|
172 |
}
|
@@ -200,11 +198,11 @@ function mp_update_store_information() {
|
|
200 |
);
|
201 |
}, 3000 );
|
202 |
} else {
|
203 |
-
mp_show_message(
|
204 |
}
|
205 |
})
|
206 |
.fail(function (error) {
|
207 |
-
mp_show_message(
|
208 |
});
|
209 |
});
|
210 |
}
|
@@ -292,11 +290,11 @@ function mp_set_mode() {
|
|
292 |
mp_show_message( response.data, "success", "test_mode" );
|
293 |
}
|
294 |
} else {
|
295 |
-
mp_show_message(
|
296 |
}
|
297 |
})
|
298 |
.fail(function (error) {
|
299 |
-
mp_show_message(error, "error", "test_mode");
|
300 |
});
|
301 |
});
|
302 |
}
|
52 |
var self = this;
|
53 |
|
54 |
jQuery.post(ajaxurl, { access_token: this.value, is_test: false, action: "mp_validate_credentials"}, function(data) {
|
55 |
+
|
56 |
}).done(function (response) {
|
57 |
+
if (response.success) {
|
58 |
self.classList.add("mp-credential-feedback-positive");
|
59 |
self.classList.remove("mp-credential-feedback-negative");
|
60 |
} else {
|
74 |
var self = this;
|
75 |
|
76 |
jQuery.post(ajaxurl, { access_token: this.value, is_test: true, action: "mp_validate_credentials"}, function(data) {
|
77 |
+
|
78 |
}).done(function (response) {
|
79 |
+
if (response.success) {
|
80 |
self.classList.add( "mp-credential-feedback-positive" );
|
81 |
self.classList.remove( "mp-credential-feedback-negative" );
|
82 |
} else {
|
95 |
var self = this;
|
96 |
|
97 |
jQuery.post(ajaxurl, { public_key: this.value, is_test: true, action: "mp_validate_credentials"}, function(data) {
|
|
|
98 |
})
|
99 |
.done(function (response) {
|
100 |
+
if (response.success) {
|
101 |
self.classList.add( "mp-credential-feedback-positive" );
|
102 |
self.classList.remove( "mp-credential-feedback-negative" );
|
103 |
} else {
|
117 |
var self = this;
|
118 |
|
119 |
jQuery.post(ajaxurl, { public_key: this.value, is_test: false, action: "mp_validate_credentials"}, function(data) {
|
|
|
120 |
})
|
121 |
.done(function (response) {
|
122 |
+
if (response.success) {
|
123 |
self.classList.add( "mp-credential-feedback-positive" );
|
124 |
self.classList.remove( "mp-credential-feedback-negative" );
|
125 |
} else {
|
160 |
);
|
161 |
}, 3000);
|
162 |
} else {
|
163 |
+
mp_show_message(response.data, "error", "credentials");
|
164 |
}
|
165 |
})
|
166 |
.fail(function (error) {
|
167 |
+
mp_show_message(error?.data, "error", "credentials");
|
168 |
});
|
169 |
});
|
170 |
}
|
198 |
);
|
199 |
}, 3000 );
|
200 |
} else {
|
201 |
+
mp_show_message(response.data, "error", "store");
|
202 |
}
|
203 |
})
|
204 |
.fail(function (error) {
|
205 |
+
mp_show_message(error?.data, "error", "store");
|
206 |
});
|
207 |
});
|
208 |
}
|
290 |
mp_show_message( response.data, "success", "test_mode" );
|
291 |
}
|
292 |
} else {
|
293 |
+
mp_show_message(response.data, "error", "test_mode");
|
294 |
}
|
295 |
})
|
296 |
.fail(function (error) {
|
297 |
+
mp_show_message(error.data, "error", "test_mode");
|
298 |
});
|
299 |
});
|
300 |
}
|
assets/js/mercadopago-settings/mercadopago_settings.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function mp_settings_accordion_start(){var e,t=document.getElementsByClassName("mp-settings-title-align");for(e=0;e<t.length;e++)t[e].addEventListener("click",(function(){this.classList.toggle("active");for(var e=null,t=0;t<this.childNodes.length;t++)if(this.childNodes[t]?.classList?.contains("mp-settings-margin-left")){e=this.childNodes[t];break}e.childNodes[1].classList.toggle("mp-arrow-up");var s=this.nextElementSibling;"block"===s.style.display?s.style.display="none":s.style.display="block"}))}function mp_get_requirements(){jQuery.post(ajaxurl,{action:"mp_get_requirements"},(function(e){const t={ssl:document.getElementById("mp-req-ssl"),gd_ext:document.getElementById("mp-req-gd"),curl_ext:document.getElementById("mp-req-curl")};for(let s in t){let n=t[s];n.style="",e.data[s]||(n.classList.remove("mp-settings-icon-success"),n.classList.add("mp-settings-icon-warning"))}}))}function mp_validate_credentials(){document.getElementById("mp-access-token-prod").addEventListener("change",(function(){var e=this;jQuery.post(ajaxurl,{access_token:this.value,is_test:!1,action:"mp_validate_credentials"},(function(e){console.log("validated")})).done((function(t){t.data.success?(e.classList.add("mp-credential-feedback-positive"),e.classList.remove("mp-credential-feedback-negative")):(e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative"))})).fail((function(t){e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative")}))})),document.getElementById("mp-access-token-test").addEventListener("change",(function(){var e=this;jQuery.post(ajaxurl,{access_token:this.value,is_test:!0,action:"mp_validate_credentials"},(function(e){console.log("validated")})).done((function(t){t.data.success?(e.classList.add("mp-credential-feedback-positive"),e.classList.remove("mp-credential-feedback-negative")):(e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative"))})).fail((function(t){e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative")}))})),document.getElementById("mp-public-key-test").addEventListener("change",(function(){var e=this;jQuery.post(ajaxurl,{public_key:this.value,is_test:!0,action:"mp_validate_credentials"},(function(e){console.log("validated")})).done((function(t){t.data.success?(e.classList.add("mp-credential-feedback-positive"),e.classList.remove("mp-credential-feedback-negative")):(e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative"))})).fail((function(t){e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative")}))})),document.getElementById("mp-public-key-prod").addEventListener("change",(function(){var e=this;jQuery.post(ajaxurl,{public_key:this.value,is_test:!1,action:"mp_validate_credentials"},(function(e){console.log("validated")})).done((function(t){t.data.success?(e.classList.add("mp-credential-feedback-positive"),e.classList.remove("mp-credential-feedback-negative")):(e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative"))})).fail((function(t){e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative")}))}))}function mp_update_option_credentials(){document.getElementById("mp-btn-credentials").addEventListener("click",(function(){jQuery.post(ajaxurl,{access_token_prod:document.getElementById("mp-access-token-prod").value,access_token_test:document.getElementById("mp-access-token-test").value,public_key_prod:document.getElementById("mp-public-key-prod").value,public_key_test:document.getElementById("mp-public-key-test").value,action:"mp_update_option_credentials"},(function(e){})).done((function(e){e.success?(mp_show_message(e.data,"success","credentials"),mp_validate_credentials_tips(),setTimeout((()=>{mp_go_to_next_step("mp-step-1","mp-step-2","mp-credentials-arrow-up","mp-store-info-arrow-up")}),3e3)):mp_show_message(error,"error","credentials")})).fail((function(e){mp_show_message("error","error","credentials")}))}))}function mp_update_store_information(){button=document.getElementById("mp-store-info-save"),button.addEventListener("click",(function(){jQuery.post(ajaxurl,{store_identificator:document.getElementById("mp-store-identificator").value,store_category_id:document.getElementById("mp-store-category-id").value,store_categories:document.getElementById("mp-store-categories").value,store_url_ipn:document.querySelector("#mp-store-url-ipn").value,store_integrator_id:document.getElementById("mp-store-integrator-id").value,store_debug_mode:document.querySelector("#mp-store-debug-mode:checked")?.value,action:"mp_update_store_information"},(function(e){})).done((function(e){e.success?(mp_validate_store_tips(),mp_show_message(e.data,"success","store"),setTimeout((()=>{mp_go_to_next_step("mp-step-2","mp-step-3","mp-store-info-arrow-up","mp-payments-arrow-up")}),3e3)):mp_show_message("error","error","store")})).fail((function(e){mp_show_message("error","error","store")}))}))}function mp_settings_accordion_options(){var e=document.getElementById("options"),t=document.getElementById("block-two");e.addEventListener("click",(function(){this.classList.toggle("active");var s=this.nextElementSibling;"block"===s.style.display?s.style.display="none":s.style.display="block",e.classList.contains("active")||t.classList.contains("mp-settings-flex-start")?(e.textContent="Ocultar opções avançadas",t.classList.remove("mp-settings-flex-start")):(t.classList.toggle("mp-settings-flex-start"),e.textContent="Ver opções avançadas")}))}function mp_set_mode(){document.getElementById("mp-store-mode-save").addEventListener("click",(function(){var e=document.querySelector('input[name="mp-test-prod"]:checked').value;jQuery.post(ajaxurl,{input_mode_value:e,action:"mp_store_mode"},(function(e){})).done((function(t){if(t.data){var s=document.getElementById("mp-mode-badge"),n=document.getElementById("mp-orange-badge"),a=document.getElementById("mp-icon-badge"),i=document.getElementById("mp-text-badge"),o=document.getElementById("mp-helper-test"),c=document.getElementById("mp-helper-prod");i.textContent=t.data,"yes"===e?(s.classList.remove("mp-settings-prod-mode-alert"),s.classList.add("mp-settings-test-mode-alert"),n.classList.remove("mp-settings-alert-payment-methods-green"),n.classList.add("mp-settings-alert-payment-methods-orange"),a.classList.remove("mp-settings-icon-success"),a.classList.add("mp-settings-icon-warning"),s.textContent="Loja em modo teste",o.style.display="block",c.style.display="none",mp_show_message(t.data,"success","test_mode")):(s.classList.remove("mp-settings-test-mode-alert"),s.classList.add("mp-settings-prod-mode-alert"),s.textContent="Loja em modo vendas (Produção)",n.classList.remove("mp-settings-alert-payment-methods-orange"),n.classList.add("mp-settings-alert-payment-methods-green"),a.classList.remove("mp-settings-icon-warning"),a.classList.add("mp-settings-icon-success"),o.style.display="none",c.style.display="block",mp_show_message(t.data,"success","test_mode"))}else mp_show_message(error,"error","test_mode")})).fail((function(e){mp_show_message(e,"error","test_mode")}))}))}function mp_get_payment_properties(){jQuery.post(ajaxurl,{action:"mp_get_payment_properties"},(function(e){})).done((function(e){const t=document.getElementById("mp-payment");e.data.reverse().forEach((e=>{t.insertAdjacentHTML("afterend",mp_payment_properties(e)),mp_payment_properties(e)}))})).fail((function(e){}))}function mp_payment_properties(e){var t="yes"==e.enabled?"mp-settings-badge-active":"mp-settings-badge-inactive",s="yes"==e.enabled?e.badge_translator.yes:e.badge_translator.no;return' <a href="'+e.link+'" class="mp-settings-link mp-settings-font-color"><div class="mp-block mp-block-flex mp-settings-payment-block mp-settings-margin-right mp-settings-align-div"> <div class="mp-settings-align-div"> <div class="mp-settings-icon '+e.icon+'"></div> <span class="mp-settings-subtitle-font-size mp-settings-margin-title-payment"> <b>'+e.title+"</b> - "+e.description+' </span> <span class="'+t+'" > '+s+'</span> </div> <div class="mp-settings-title-align"> <span class="mp-settings-text-payment">Configurar</span> <img class="mp-settings-icon-config"> </div> </div></a>'}function mp_validate_credentials_tips(){var e=document.getElementById("mp-settings-icon-credentials");jQuery.post(ajaxurl,{action:"mp_validate_credentials_tips"},(function(e){})).done((function(t){t.success?(e.classList.remove("mp-settings-icon-credentials"),e.classList.add("mp-settings-icon-success")):e.classList.remove("mp-settings-icon-success")})).fail((function(t){e.classList.remove("mp-settings-icon-success")}))}function mp_validate_store_tips(){var e=document.getElementById("mp-settings-icon-store");jQuery.post(ajaxurl,{action:"mp_validate_store_tips"},(function(e){})).done((function(t){t.success?(e.classList.remove("mp-settings-icon-store"),e.classList.add("mp-settings-icon-success")):e.classList.remove("mp-settings-icon-success")})).fail((function(t){e.classList.remove("mp-settings-icon-success")}))}function mp_validate_payment_tips(){var e=document.getElementById("mp-settings-icon-payment");jQuery.post(ajaxurl,{action:"mp_validate_payment_tips"},(function(e){})).done((function(t){t.success?(e.classList.remove("mp-settings-icon-payment"),e.classList.add("mp-settings-icon-success")):e.classList.remove("mp-settings-icon-success")})).fail((function(t){e.classList.remove("mp-settings-icon-success")}))}function mp_show_message(e,t,s){const n=document.createElement("div");var a="",i="";switch(s){case"credentials":a=document.querySelector(".mp-message-credentials"),i=document.querySelector(".mp-heading-credentials");break;case"store":a=document.querySelector(".mp-message-store"),i=document.querySelector(".mp-heading-store");break;case"payment":a=document.querySelector(".mp-message-payment"),i=document.querySelector(".mp-heading-payment");break;case"test_mode":a=document.querySelector(".mp-message-test-mode"),i=document.querySelector(".mp-heading-test-mode");break;default:a="",i=""}n.className="error"===t?"mp-alert mp-alert-danger mp-text-center mp-card-body":"mp-alert mp-alert-success mp-text-center mp-card-body",n.appendChild(document.createTextNode(e)),a.insertBefore(n,i),setTimeout(clearMessage,3e3)}function clearMessage(){document.querySelector(".mp-alert").remove()}function mp_go_to_next_step(e,t,s,n){var a=document.getElementById(e),i=document.getElementById(t),o=document.getElementById(s),c=document.getElementById(n);a.style.display="none",i.style.display="block",o.classList.remove("mp-arrow-up"),c.classList.add("mp-arrow-up")}function mp_continue_to_next_step(){document.getElementById("mp-payment-method-continue").addEventListener("click",(function(){mp_go_to_next_step("mp-step-3","mp-step-4","mp-payments-arrow-up","mp-modes-arrow-up")}))}function mp_settings_screen_load(){mp_settings_accordion_start(),mp_settings_accordion_options(),mp_get_requirements(),mp_validate_credentials(),mp_update_option_credentials(),mp_update_store_information(),mp_set_mode(),mp_get_payment_properties(),mp_validate_credentials_tips(),mp_validate_store_tips(),mp_validate_payment_tips(),mp_continue_to_next_step()}
|
1 |
+
function mp_settings_accordion_start(){var e,t=document.getElementsByClassName("mp-settings-title-align");for(e=0;e<t.length;e++)t[e].addEventListener("click",(function(){this.classList.toggle("active");for(var e=null,t=0;t<this.childNodes.length;t++)if(this.childNodes[t]?.classList?.contains("mp-settings-margin-left")){e=this.childNodes[t];break}e.childNodes[1].classList.toggle("mp-arrow-up");var s=this.nextElementSibling;"block"===s.style.display?s.style.display="none":s.style.display="block"}))}function mp_get_requirements(){jQuery.post(ajaxurl,{action:"mp_get_requirements"},(function(e){const t={ssl:document.getElementById("mp-req-ssl"),gd_ext:document.getElementById("mp-req-gd"),curl_ext:document.getElementById("mp-req-curl")};for(let s in t){let n=t[s];n.style="",e.data[s]||(n.classList.remove("mp-settings-icon-success"),n.classList.add("mp-settings-icon-warning"))}}))}function mp_validate_credentials(){document.getElementById("mp-access-token-prod").addEventListener("change",(function(){var e=this;jQuery.post(ajaxurl,{access_token:this.value,is_test:!1,action:"mp_validate_credentials"},(function(e){})).done((function(t){t.success?(e.classList.add("mp-credential-feedback-positive"),e.classList.remove("mp-credential-feedback-negative")):(e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative"))})).fail((function(t){e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative")}))})),document.getElementById("mp-access-token-test").addEventListener("change",(function(){var e=this;jQuery.post(ajaxurl,{access_token:this.value,is_test:!0,action:"mp_validate_credentials"},(function(e){})).done((function(t){t.success?(e.classList.add("mp-credential-feedback-positive"),e.classList.remove("mp-credential-feedback-negative")):(e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative"))})).fail((function(t){e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative")}))})),document.getElementById("mp-public-key-test").addEventListener("change",(function(){var e=this;jQuery.post(ajaxurl,{public_key:this.value,is_test:!0,action:"mp_validate_credentials"},(function(e){})).done((function(t){t.success?(e.classList.add("mp-credential-feedback-positive"),e.classList.remove("mp-credential-feedback-negative")):(e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative"))})).fail((function(t){e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative")}))})),document.getElementById("mp-public-key-prod").addEventListener("change",(function(){var e=this;jQuery.post(ajaxurl,{public_key:this.value,is_test:!1,action:"mp_validate_credentials"},(function(e){})).done((function(t){t.success?(e.classList.add("mp-credential-feedback-positive"),e.classList.remove("mp-credential-feedback-negative")):(e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative"))})).fail((function(t){e.classList.remove("mp-credential-feedback-positive"),e.classList.add("mp-credential-feedback-negative")}))}))}function mp_update_option_credentials(){document.getElementById("mp-btn-credentials").addEventListener("click",(function(){jQuery.post(ajaxurl,{access_token_prod:document.getElementById("mp-access-token-prod").value,access_token_test:document.getElementById("mp-access-token-test").value,public_key_prod:document.getElementById("mp-public-key-prod").value,public_key_test:document.getElementById("mp-public-key-test").value,action:"mp_update_option_credentials"},(function(e){})).done((function(e){e.success?(mp_show_message(e.data,"success","credentials"),mp_validate_credentials_tips(),setTimeout((()=>{mp_go_to_next_step("mp-step-1","mp-step-2","mp-credentials-arrow-up","mp-store-info-arrow-up")}),3e3)):mp_show_message(e.data,"error","credentials")})).fail((function(e){mp_show_message(e?.data,"error","credentials")}))}))}function mp_update_store_information(){button=document.getElementById("mp-store-info-save"),button.addEventListener("click",(function(){jQuery.post(ajaxurl,{store_identificator:document.getElementById("mp-store-identificator").value,store_category_id:document.getElementById("mp-store-category-id").value,store_categories:document.getElementById("mp-store-categories").value,store_url_ipn:document.querySelector("#mp-store-url-ipn").value,store_integrator_id:document.getElementById("mp-store-integrator-id").value,store_debug_mode:document.querySelector("#mp-store-debug-mode:checked")?.value,action:"mp_update_store_information"},(function(e){})).done((function(e){e.success?(mp_validate_store_tips(),mp_show_message(e.data,"success","store"),setTimeout((()=>{mp_go_to_next_step("mp-step-2","mp-step-3","mp-store-info-arrow-up","mp-payments-arrow-up")}),3e3)):mp_show_message(e.data,"error","store")})).fail((function(e){mp_show_message(e?.data,"error","store")}))}))}function mp_settings_accordion_options(){var e=document.getElementById("options"),t=document.getElementById("block-two");e.addEventListener("click",(function(){this.classList.toggle("active");var s=this.nextElementSibling;"block"===s.style.display?s.style.display="none":s.style.display="block",e.classList.contains("active")||t.classList.contains("mp-settings-flex-start")?(e.textContent="Ocultar opções avançadas",t.classList.remove("mp-settings-flex-start")):(t.classList.toggle("mp-settings-flex-start"),e.textContent="Ver opções avançadas")}))}function mp_set_mode(){document.getElementById("mp-store-mode-save").addEventListener("click",(function(){var e=document.querySelector('input[name="mp-test-prod"]:checked').value;jQuery.post(ajaxurl,{input_mode_value:e,action:"mp_store_mode"},(function(e){})).done((function(t){if(t.data){var s=document.getElementById("mp-mode-badge"),n=document.getElementById("mp-orange-badge"),a=document.getElementById("mp-icon-badge"),i=document.getElementById("mp-text-badge"),c=document.getElementById("mp-helper-test"),o=document.getElementById("mp-helper-prod");i.textContent=t.data,"yes"===e?(s.classList.remove("mp-settings-prod-mode-alert"),s.classList.add("mp-settings-test-mode-alert"),n.classList.remove("mp-settings-alert-payment-methods-green"),n.classList.add("mp-settings-alert-payment-methods-orange"),a.classList.remove("mp-settings-icon-success"),a.classList.add("mp-settings-icon-warning"),s.textContent="Loja em modo teste",c.style.display="block",o.style.display="none",mp_show_message(t.data,"success","test_mode")):(s.classList.remove("mp-settings-test-mode-alert"),s.classList.add("mp-settings-prod-mode-alert"),s.textContent="Loja em modo vendas (Produção)",n.classList.remove("mp-settings-alert-payment-methods-orange"),n.classList.add("mp-settings-alert-payment-methods-green"),a.classList.remove("mp-settings-icon-warning"),a.classList.add("mp-settings-icon-success"),c.style.display="none",o.style.display="block",mp_show_message(t.data,"success","test_mode"))}else mp_show_message(t.data,"error","test_mode")})).fail((function(e){mp_show_message(e.data,"error","test_mode")}))}))}function mp_get_payment_properties(){jQuery.post(ajaxurl,{action:"mp_get_payment_properties"},(function(e){})).done((function(e){const t=document.getElementById("mp-payment");e.data.reverse().forEach((e=>{t.insertAdjacentHTML("afterend",mp_payment_properties(e)),mp_payment_properties(e)}))})).fail((function(e){}))}function mp_payment_properties(e){var t="yes"==e.enabled?"mp-settings-badge-active":"mp-settings-badge-inactive",s="yes"==e.enabled?e.badge_translator.yes:e.badge_translator.no;return' <a href="'+e.link+'" class="mp-settings-link mp-settings-font-color"><div class="mp-block mp-block-flex mp-settings-payment-block mp-settings-margin-right mp-settings-align-div"> <div class="mp-settings-align-div"> <div class="mp-settings-icon '+e.icon+'"></div> <span class="mp-settings-subtitle-font-size mp-settings-margin-title-payment"> <b>'+e.title+"</b> - "+e.description+' </span> <span class="'+t+'" > '+s+'</span> </div> <div class="mp-settings-title-align"> <span class="mp-settings-text-payment">Configurar</span> <img class="mp-settings-icon-config"> </div> </div></a>'}function mp_validate_credentials_tips(){var e=document.getElementById("mp-settings-icon-credentials");jQuery.post(ajaxurl,{action:"mp_validate_credentials_tips"},(function(e){})).done((function(t){t.success?(e.classList.remove("mp-settings-icon-credentials"),e.classList.add("mp-settings-icon-success")):e.classList.remove("mp-settings-icon-success")})).fail((function(t){e.classList.remove("mp-settings-icon-success")}))}function mp_validate_store_tips(){var e=document.getElementById("mp-settings-icon-store");jQuery.post(ajaxurl,{action:"mp_validate_store_tips"},(function(e){})).done((function(t){t.success?(e.classList.remove("mp-settings-icon-store"),e.classList.add("mp-settings-icon-success")):e.classList.remove("mp-settings-icon-success")})).fail((function(t){e.classList.remove("mp-settings-icon-success")}))}function mp_validate_payment_tips(){var e=document.getElementById("mp-settings-icon-payment");jQuery.post(ajaxurl,{action:"mp_validate_payment_tips"},(function(e){})).done((function(t){t.success?(e.classList.remove("mp-settings-icon-payment"),e.classList.add("mp-settings-icon-success")):e.classList.remove("mp-settings-icon-success")})).fail((function(t){e.classList.remove("mp-settings-icon-success")}))}function mp_show_message(e,t,s){const n=document.createElement("div");var a="",i="";switch(s){case"credentials":a=document.querySelector(".mp-message-credentials"),i=document.querySelector(".mp-heading-credentials");break;case"store":a=document.querySelector(".mp-message-store"),i=document.querySelector(".mp-heading-store");break;case"payment":a=document.querySelector(".mp-message-payment"),i=document.querySelector(".mp-heading-payment");break;case"test_mode":a=document.querySelector(".mp-message-test-mode"),i=document.querySelector(".mp-heading-test-mode");break;default:a="",i=""}n.className="error"===t?"mp-alert mp-alert-danger mp-text-center mp-card-body":"mp-alert mp-alert-success mp-text-center mp-card-body",n.appendChild(document.createTextNode(e)),a.insertBefore(n,i),setTimeout(clearMessage,3e3)}function clearMessage(){document.querySelector(".mp-alert").remove()}function mp_go_to_next_step(e,t,s,n){var a=document.getElementById(e),i=document.getElementById(t),c=document.getElementById(s),o=document.getElementById(n);a.style.display="none",i.style.display="block",c.classList.remove("mp-arrow-up"),o.classList.add("mp-arrow-up")}function mp_continue_to_next_step(){document.getElementById("mp-payment-method-continue").addEventListener("click",(function(){mp_go_to_next_step("mp-step-3","mp-step-4","mp-payments-arrow-up","mp-modes-arrow-up")}))}function mp_settings_screen_load(){mp_settings_accordion_start(),mp_settings_accordion_options(),mp_get_requirements(),mp_validate_credentials(),mp_update_option_credentials(),mp_update_store_information(),mp_set_mode(),mp_get_payment_properties(),mp_validate_credentials_tips(),mp_validate_store_tips(),mp_validate_payment_tips(),mp_continue_to_next_step()}
|
includes/admin/hooks/class-wc-woomercadopago-hook-order-details.php
CHANGED
@@ -377,7 +377,7 @@ class WC_WooMercadoPago_Hook_Order_Details {
|
|
377 |
public function payment_status_metabox_script() {
|
378 |
$suffix = $this->get_suffix();
|
379 |
|
380 |
-
if ( is_admin()
|
381 |
wp_enqueue_script(
|
382 |
'mp_payment_status_metabox',
|
383 |
plugins_url( '../../assets/js/payment_status_metabox' . $suffix . '.js', plugin_dir_path( __FILE__ ) ),
|
377 |
public function payment_status_metabox_script() {
|
378 |
$suffix = $this->get_suffix();
|
379 |
|
380 |
+
if ( is_admin() ) {
|
381 |
wp_enqueue_script(
|
382 |
'mp_payment_status_metabox',
|
383 |
plugins_url( '../../assets/js/payment_status_metabox' . $suffix . '.js', plugin_dir_path( __FILE__ ) ),
|
includes/module/class-wc-woomercadopago-credentials.php
CHANGED
@@ -332,7 +332,7 @@ class WC_WooMercadoPago_Credentials {
|
|
332 |
|
333 |
$arr = array();
|
334 |
$cho = array();
|
335 |
-
$excluded = array( 'consumer_credits', 'paypal' );
|
336 |
|
337 |
foreach ( $payments_response as $payment ) {
|
338 |
if ( in_array( $payment['id'], $excluded, true ) ) {
|
332 |
|
333 |
$arr = array();
|
334 |
$cho = array();
|
335 |
+
$excluded = array( 'consumer_credits', 'paypal', 'account_money' );
|
336 |
|
337 |
foreach ( $payments_response as $payment ) {
|
338 |
if ( in_array( $payment['id'], $excluded, true ) ) {
|
includes/module/class-wc-woomercadopago-init.php
CHANGED
@@ -145,6 +145,7 @@ class WC_WooMercadoPago_Init {
|
|
145 |
$old_version = get_option( '_mp_version', '0' );
|
146 |
if ( version_compare( WC_WooMercadoPago_Constants::VERSION, $old_version, '>' ) ) {
|
147 |
do_action( 'mercadopago_plugin_updated' );
|
|
|
148 |
update_option( '_mp_version', WC_WooMercadoPago_Constants::VERSION, true );
|
149 |
}
|
150 |
}
|
145 |
$old_version = get_option( '_mp_version', '0' );
|
146 |
if ( version_compare( WC_WooMercadoPago_Constants::VERSION, $old_version, '>' ) ) {
|
147 |
do_action( 'mercadopago_plugin_updated' );
|
148 |
+
do_action( 'mercadopago_test_mode_update' );
|
149 |
update_option( '_mp_version', WC_WooMercadoPago_Constants::VERSION, true );
|
150 |
}
|
151 |
}
|
includes/module/class-wc-woomercadopago-module.php
CHANGED
@@ -95,9 +95,16 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
95 |
add_action( 'wp_enqueue_scripts', array( $this, 'load_global_css' ) );
|
96 |
|
97 |
add_filter( 'woocommerce_available_payment_gateways', array( $this, 'filter_payment_method_by_shipping' ) );
|
98 |
-
add_filter( 'plugin_action_links_' . WC_MERCADOPAGO_BASENAME, array(
|
|
|
|
|
|
|
99 |
add_filter( 'plugin_row_meta', array( $this, 'mp_plugin_row_meta' ), 10, 2 );
|
100 |
-
add_action( 'mercadopago_plugin_updated', array(
|
|
|
|
|
|
|
|
|
101 |
|
102 |
if ( is_admin() ) {
|
103 |
// validate credentials.
|
@@ -115,103 +122,61 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
115 |
}
|
116 |
|
117 |
/**
|
|
|
118 |
*
|
119 |
-
*
|
120 |
-
*
|
121 |
-
* @param object $payment payment.
|
122 |
-
* @return MP MP.
|
123 |
-
* @throws WC_WooMercadoPago_Exception Error.
|
124 |
*/
|
125 |
-
public
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
$mp->set_payment_class( $payment );
|
131 |
-
}
|
132 |
-
if ( WC_WooMercadoPago_Credentials::TYPE_ACCESS_CLIENT === $validate_credentials_type ) {
|
133 |
-
$mp = new MP( $credentials->client_id, $credentials->client_secret );
|
134 |
-
$mp->set_payment_class( $payment );
|
135 |
-
if ( ! empty( $payment ) ) {
|
136 |
-
$payment->sandbox = false;
|
137 |
-
}
|
138 |
-
}
|
139 |
-
|
140 |
-
if ( ! isset( $mp ) ) {
|
141 |
-
return false;
|
142 |
-
}
|
143 |
-
|
144 |
-
$email = ( 0 !== wp_get_current_user()->ID ) ? wp_get_current_user()->user_email : null;
|
145 |
-
$mp->set_email( $email );
|
146 |
-
|
147 |
-
$locale = get_locale();
|
148 |
-
$locale = false !== ( strpos( $locale, '_' ) && 5 === strlen( $locale ) ) ? explode( '_', $locale ) : array( '', '' );
|
149 |
-
$mp->set_locale( $locale[1] );
|
150 |
-
|
151 |
-
return $mp;
|
152 |
}
|
153 |
|
154 |
/**
|
155 |
*
|
156 |
-
*
|
157 |
*
|
158 |
-
* @
|
159 |
-
* @return MP|null
|
160 |
-
* @throws WC_WooMercadoPago_Exception Error.
|
161 |
*/
|
162 |
-
public
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
$mp = self::$mp_instance_ayment[ $class ];
|
169 |
-
if ( ! empty( $mp ) ) {
|
170 |
-
return $mp;
|
171 |
-
}
|
172 |
-
}
|
173 |
-
}
|
174 |
-
|
175 |
-
if ( null === self::$mp_instance || empty( $mp ) ) {
|
176 |
-
self::$mp_instance = self::get_mp_instance();
|
177 |
-
}
|
178 |
-
|
179 |
-
return self::$mp_instance;
|
180 |
}
|
181 |
|
182 |
/**
|
|
|
|
|
183 |
*
|
184 |
-
*
|
185 |
-
*
|
186 |
-
* @return WC_WooMercadoPago_Module|null
|
187 |
-
* Singleton
|
188 |
*/
|
189 |
-
public static function
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
192 |
}
|
193 |
-
return self::$instance;
|
194 |
}
|
195 |
|
196 |
/**
|
197 |
*
|
198 |
-
* Load
|
199 |
*
|
200 |
* @return void
|
201 |
*/
|
202 |
-
public function
|
203 |
-
|
204 |
-
$configs = new parent();
|
205 |
-
self::$categories = $configs->get_categories();
|
206 |
-
self::$site_data = self::get_site_data();
|
207 |
-
self::$payments_name = self::set_payment_gateway();
|
208 |
}
|
209 |
|
210 |
/**
|
211 |
*
|
212 |
* Load Hooks
|
213 |
*
|
214 |
-
*
|
215 |
*/
|
216 |
public function load_hooks() {
|
217 |
include_once dirname( __FILE__ ) . '/../payments/hooks/class-wc-woomercadopago-hook-abstract.php';
|
@@ -221,18 +186,6 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
221 |
include_once dirname( __FILE__ ) . '/../payments/hooks/class-wc-woomercadopago-hook-pix.php';
|
222 |
}
|
223 |
|
224 |
-
/**
|
225 |
-
* Load Helpers
|
226 |
-
*
|
227 |
-
* @return void
|
228 |
-
*/
|
229 |
-
public function load_helpers() {
|
230 |
-
include_once dirname( __FILE__ ) . '/../helpers/class-wc-woomercadopago-helper-current-url.php';
|
231 |
-
include_once dirname( __FILE__ ) . '/../helpers/class-wc-woomercadopago-helpers-currencyconverter.php';
|
232 |
-
include_once dirname( __FILE__ ) . '/../helpers/class-wc-woomercadopago-composite-id-helper.php';
|
233 |
-
include_once dirname( __FILE__ ) . '/../helpers/class-wc-woomercadopago-helper-links.php';
|
234 |
-
}
|
235 |
-
|
236 |
/**
|
237 |
* Load Preferences Classes
|
238 |
*
|
@@ -251,7 +204,7 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
251 |
/**
|
252 |
* Load Payment Classes
|
253 |
*
|
254 |
-
*
|
255 |
*/
|
256 |
public function load_payments() {
|
257 |
include_once dirname( __FILE__ ) . '/../payments/class-wc-woomercadopago-payment-abstract.php';
|
@@ -274,66 +227,6 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
274 |
include_once dirname( __FILE__ ) . '/../notification/class-wc-woomercadopago-notification-webhook.php';
|
275 |
}
|
276 |
|
277 |
-
/**
|
278 |
-
*
|
279 |
-
* Load log
|
280 |
-
*
|
281 |
-
* @return void
|
282 |
-
*/
|
283 |
-
public function load_log() {
|
284 |
-
include_once dirname( __FILE__ ) . '/log/class-wc-woomercadopago-log.php';
|
285 |
-
}
|
286 |
-
|
287 |
-
/**
|
288 |
-
* Get Suffix to get minify files
|
289 |
-
*
|
290 |
-
* @return String
|
291 |
-
*/
|
292 |
-
private function get_suffix() {
|
293 |
-
return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
294 |
-
}
|
295 |
-
|
296 |
-
/**
|
297 |
-
* Load Admin Css
|
298 |
-
*
|
299 |
-
* @return void
|
300 |
-
*/
|
301 |
-
public function load_admin_css() {
|
302 |
-
if ( is_admin() && ( WC_WooMercadoPago_Helper_Current_Url::validate_page('mercadopago-settings') || WC_WooMercadoPago_Helper_Current_Url::validate_section('woo-mercado-pago') ) ) {
|
303 |
-
$suffix = $this->get_suffix();
|
304 |
-
|
305 |
-
wp_enqueue_style(
|
306 |
-
'woocommerce-mercadopago-basic-config-styles',
|
307 |
-
plugins_url( '../assets/css/config_mercadopago' . $suffix . '.css', plugin_dir_path( __FILE__ ) ),
|
308 |
-
array(),
|
309 |
-
WC_WooMercadoPago_Constants::VERSION
|
310 |
-
);
|
311 |
-
|
312 |
-
wp_enqueue_style(
|
313 |
-
'woocommerce-mercadopago-components',
|
314 |
-
plugins_url( '../assets/css/components_mercadopago' . $suffix . '.css', plugin_dir_path( __FILE__ ) ),
|
315 |
-
array(),
|
316 |
-
WC_WooMercadoPago_Constants::VERSION
|
317 |
-
);
|
318 |
-
}
|
319 |
-
}
|
320 |
-
|
321 |
-
/**
|
322 |
-
* Load global CSS
|
323 |
-
*
|
324 |
-
* @return void
|
325 |
-
*/
|
326 |
-
public function load_global_css() {
|
327 |
-
$suffix = $this->get_suffix();
|
328 |
-
|
329 |
-
wp_enqueue_style(
|
330 |
-
'woocommerce-mercadopago-global-css',
|
331 |
-
plugins_url( '../assets/css/global' . $suffix . '.css', plugin_dir_path( __FILE__ ) ),
|
332 |
-
array(),
|
333 |
-
WC_WooMercadoPago_Constants::VERSION
|
334 |
-
);
|
335 |
-
}
|
336 |
-
|
337 |
/**
|
338 |
*
|
339 |
* Load Stock Manager
|
@@ -346,184 +239,112 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
346 |
|
347 |
/**
|
348 |
*
|
349 |
-
*
|
350 |
-
*
|
351 |
-
* @param array $methods methods.
|
352 |
-
* @return array
|
353 |
-
*/
|
354 |
-
public function filter_payment_method_by_shipping( $methods ) {
|
355 |
-
return $methods;
|
356 |
-
}
|
357 |
-
|
358 |
-
/**
|
359 |
-
*
|
360 |
-
* Enable Payment Notice
|
361 |
-
*
|
362 |
-
* @return void
|
363 |
-
*/
|
364 |
-
public function enable_payment_notice() {
|
365 |
-
$type = 'notice-warning';
|
366 |
-
$message = __( 'Fill in your credentials to enable payment methods.', 'woocommerce-mercadopago' );
|
367 |
-
WC_WooMercadoPago_Notices::get_alert_frame( $message, $type );
|
368 |
-
}
|
369 |
-
|
370 |
-
/**
|
371 |
-
*
|
372 |
-
* Woomercadopago Settings Link add settings link on plugin page.
|
373 |
-
* Enable Payment Notice
|
374 |
-
*
|
375 |
-
* @param array $links links.
|
376 |
-
* @return array
|
377 |
-
*/
|
378 |
-
public function woomercadopago_settings_link( $links ) {
|
379 |
-
$links_mp = self::define_link_country();
|
380 |
-
$plugin_links = array();
|
381 |
-
$plugin_links[] = '<a href="' . admin_url( 'admin.php?page=mercadopago-settings' ) . '">' . __( 'Set plugin', 'woocommerce-mercadopago' ) . '</a>';
|
382 |
-
$plugin_links[] = '<a target="_blank" href="' . admin_url( 'admin.php?page=wc-settings&tab=checkout' ) . '">' . __( 'Payment methods', 'woocommerce-mercadopago' ) . '</a>';
|
383 |
-
$plugin_links[] = '<br><a target="_blank" href="https://www.mercadopago.' . $links_mp['sufix_url'] . 'developers/' . $links_mp['translate'] . '/guides/plugins/woocommerce/introduction/">' . __( 'Plugin manual', 'woocommerce-mercadopago' ) . '</a>';
|
384 |
-
return array_merge( $plugin_links, $links );
|
385 |
-
}
|
386 |
-
|
387 |
-
/**
|
388 |
*
|
389 |
-
*
|
390 |
*
|
391 |
-
* @return
|
|
|
392 |
*/
|
393 |
-
public static function
|
394 |
-
$
|
395 |
-
$
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
'help' => 'ajuda',
|
406 |
-
'sufix_url' => 'com.br/',
|
407 |
-
'translate' => 'pt',
|
408 |
-
'term_conditition' => '/termos-e-politicas_194',
|
409 |
-
'site_id_mp' => 'mlb',
|
410 |
-
),
|
411 |
-
'CL' => array( // Chile.
|
412 |
-
'help' => 'ayuda',
|
413 |
-
'sufix_url' => 'cl/',
|
414 |
-
'translate' => 'es',
|
415 |
-
'term_conditition' => '/terminos-y-politicas_194',
|
416 |
-
'site_id_mp' => 'mlc',
|
417 |
-
),
|
418 |
-
'CO' => array( // Colombia.
|
419 |
-
'help' => 'ayuda',
|
420 |
-
'sufix_url' => 'com.co/',
|
421 |
-
'translate' => 'es',
|
422 |
-
'term_conditition' => '/terminos-y-politicas_194',
|
423 |
-
'site_id_mp' => 'mco',
|
424 |
-
),
|
425 |
-
'MX' => array( // Mexico.
|
426 |
-
'help' => 'ayuda',
|
427 |
-
'sufix_url' => 'com.mx/',
|
428 |
-
'translate' => 'es',
|
429 |
-
'term_conditition' => '/terminos-y-politicas_194',
|
430 |
-
'site_id_mp' => 'mlm',
|
431 |
-
),
|
432 |
-
'PE' => array( // Peru.
|
433 |
-
'help' => 'ayuda',
|
434 |
-
'sufix_url' => 'com.pe/',
|
435 |
-
'translate' => 'es',
|
436 |
-
'term_conditition' => '/terminos-y-politicas_194',
|
437 |
-
'site_id_mp' => 'mpe',
|
438 |
-
),
|
439 |
-
'UY' => array( // Uruguay.
|
440 |
-
'help' => 'ayuda',
|
441 |
-
'sufix_url' => 'com.uy/',
|
442 |
-
'translate' => 'es',
|
443 |
-
'term_conditition' => '/terminos-y-politicas_194',
|
444 |
-
'site_id_mp' => 'mlu',
|
445 |
-
),
|
446 |
-
);
|
447 |
|
448 |
-
|
449 |
-
|
|
|
450 |
|
451 |
-
return
|
452 |
}
|
453 |
|
454 |
/**
|
455 |
*
|
456 |
-
* Get
|
457 |
*
|
458 |
-
* @
|
|
|
|
|
|
|
459 |
*/
|
460 |
-
public static function
|
461 |
-
$
|
462 |
-
|
463 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
464 |
}
|
465 |
|
466 |
-
|
467 |
-
|
|
|
468 |
|
469 |
-
|
470 |
-
|
471 |
-
* Define terms and conditions link
|
472 |
-
*
|
473 |
-
* @return string
|
474 |
-
*/
|
475 |
-
public static function mp_define_terms_and_conditions() {
|
476 |
-
$links_mp = self::define_link_country();
|
477 |
-
$link_prefix_mp = 'https://www.mercadopago.';
|
478 |
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
|
|
484 |
|
|
|
485 |
}
|
486 |
|
487 |
-
/**
|
488 |
-
*
|
489 |
-
*
|
490 |
-
*
|
491 |
-
* @
|
492 |
-
*
|
493 |
-
*/
|
494 |
-
public function
|
495 |
-
if (
|
496 |
-
|
497 |
-
$new_link[] = $links[0];
|
498 |
-
$new_link[] = esc_html__( 'By Mercado Pago', 'woocommerce-mercadopago' );
|
499 |
-
|
500 |
-
return $new_link;
|
501 |
}
|
502 |
|
503 |
-
return
|
504 |
}
|
505 |
|
506 |
/**
|
507 |
*
|
508 |
-
*
|
509 |
-
* Summary: Check if we have valid credentials for v1.
|
510 |
-
* Description: Check if we have valid credentials.
|
511 |
*
|
512 |
-
* @return
|
513 |
*/
|
514 |
-
public static function
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
|
|
|
|
|
|
521 |
}
|
522 |
|
523 |
/**
|
524 |
* Get Common Error Messages function
|
525 |
*
|
526 |
* @param string $key Key.
|
|
|
527 |
* @return string
|
528 |
*/
|
529 |
public static function get_common_error_messages( $key ) {
|
@@ -531,17 +352,15 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
531 |
return __( 'The payment method is not valid or not available.', 'woocommerce-mercadopago' );
|
532 |
}
|
533 |
if ( 'Invalid transaction_amount' === $key ) {
|
534 |
-
return __( 'The transaction amount cannot be processed by Mercado Pago.', 'woocommerce-mercadopago' ) . ' ' .
|
535 |
-
__( 'Possible causes: Currency not supported; Amounts below the minimum or above the maximum allowed.', 'woocommerce-mercadopago' );
|
536 |
}
|
537 |
if ( 'Invalid users involved' === $key ) {
|
538 |
-
return __( 'The users are not valid.', 'woocommerce-mercadopago' ) . ' ' .
|
539 |
-
__( 'Possible causes: Buyer and seller have the same account in Mercado Pago; The transaction involving production and test users.', 'woocommerce-mercadopago' );
|
540 |
}
|
541 |
if ( 'Unauthorized use of live credentials' === $key ) {
|
542 |
-
return __( 'Unauthorized use of production credentials.', 'woocommerce-mercadopago' ) . ' ' .
|
543 |
-
__( 'Possible causes: Use permission in use for the credential of the seller.', 'woocommerce-mercadopago' );
|
544 |
}
|
|
|
545 |
return $key;
|
546 |
}
|
547 |
|
@@ -550,6 +369,7 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
550 |
* Description: The currencies are the one used in WooCommerce and the one used in $site_id.
|
551 |
*
|
552 |
* @param string $used_currency Used currency.
|
|
|
553 |
* @return float float that is the rate of conversion.
|
554 |
*/
|
555 |
public static function get_conversion_rate( $used_currency ) {
|
@@ -574,9 +394,28 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
574 |
'code_version' => phpversion(),
|
575 |
'so_server' => PHP_OS,
|
576 |
);
|
|
|
577 |
return $infra_data;
|
578 |
}
|
579 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
580 |
/**
|
581 |
* Summary: Get Sponsor ID to preferences.
|
582 |
* Description: This function verifies, if the sponsor ID was configured,
|
@@ -587,22 +426,8 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
587 |
*/
|
588 |
public static function get_sponsor_id() {
|
589 |
$site_data = self::get_site_data();
|
590 |
-
return $site_data['sponsor_id'];
|
591 |
-
}
|
592 |
|
593 |
-
|
594 |
-
* Summary: Get information about the used Mercado Pago account based in its site.
|
595 |
-
* Description: Get information about the used Mercado Pago account based in its site.
|
596 |
-
*
|
597 |
-
* @return array with the information.
|
598 |
-
*/
|
599 |
-
public static function get_site_data() {
|
600 |
-
$site_id = strtolower(get_option( '_site_id_v1', '' ));
|
601 |
-
if ( isset( $site_id ) && ! empty( $site_id ) ) {
|
602 |
-
return self::$country_configs[ $site_id ];
|
603 |
-
} else {
|
604 |
-
return null;
|
605 |
-
}
|
606 |
}
|
607 |
|
608 |
/**
|
@@ -611,6 +436,7 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
611 |
* Fix to URL Problem : #038; replaces & and breaks the navigation.
|
612 |
*
|
613 |
* @param string $link Link.
|
|
|
614 |
* @return string
|
615 |
*/
|
616 |
public static function fix_url_ampersand( $link ) {
|
@@ -632,6 +458,7 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
632 |
* Check if an order is recurrent.
|
633 |
*
|
634 |
* @param object $items items.
|
|
|
635 |
* @return boolean
|
636 |
*/
|
637 |
public static function is_subscription( $items ) {
|
@@ -645,6 +472,7 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
645 |
}
|
646 |
}
|
647 |
}
|
|
|
648 |
return $is_subscription;
|
649 |
}
|
650 |
|
@@ -652,6 +480,7 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
652 |
* Get Country Name function
|
653 |
*
|
654 |
* @param string $site_id Site id.
|
|
|
655 |
* @return string
|
656 |
*/
|
657 |
public static function get_country_name( $site_id ) {
|
@@ -673,6 +502,7 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
673 |
case 'mpe':
|
674 |
return __( 'Peru', 'woocommerce-mercadopago' );
|
675 |
}
|
|
|
676 |
return '';
|
677 |
}
|
678 |
|
@@ -680,6 +510,7 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
680 |
* Get Map function
|
681 |
*
|
682 |
* @param array $selector_id Selector id.
|
|
|
683 |
* @return array
|
684 |
*/
|
685 |
public static function get_map( $selector_id ) {
|
@@ -722,6 +553,7 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
722 |
if ( $woo_commerce_version <= '4.0.0' ) {
|
723 |
return false;
|
724 |
}
|
|
|
725 |
return true;
|
726 |
}
|
727 |
|
@@ -738,6 +570,7 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
738 |
if ( preg_match( '/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i', $user_agent ) || preg_match( '/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr( $user_agent, 0, 4 ) ) ) {
|
739 |
$mobile = true;
|
740 |
}
|
|
|
741 |
return $mobile;
|
742 |
}
|
743 |
|
@@ -752,7 +585,237 @@ class WC_WooMercadoPago_Module extends WC_WooMercadoPago_Configs {
|
|
752 |
$types['WC_WooMercadoPago_Custom_Gateway'] = 'webhooks';
|
753 |
$types['WC_WooMercadoPago_Pix_Gateway'] = 'webhooks';
|
754 |
$types['WC_WooMercadoPago_Ticket_Gateway'] = 'webhooks';
|
755 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
756 |
}
|
757 |
|
758 |
}
|
95 |
add_action( 'wp_enqueue_scripts', array( $this, 'load_global_css' ) );
|
96 |
|
97 |
add_filter( 'woocommerce_available_payment_gateways', array( $this, 'filter_payment_method_by_shipping' ) );
|
98 |
+
add_filter( 'plugin_action_links_' . WC_MERCADOPAGO_BASENAME, array(
|
99 |
+
$this,
|
100 |
+
'woomercadopago_settings_link'
|
101 |
+
) );
|
102 |
add_filter( 'plugin_row_meta', array( $this, 'mp_plugin_row_meta' ), 10, 2 );
|
103 |
+
add_action( 'mercadopago_plugin_updated', array(
|
104 |
+
'WC_WooMercadoPago_Credentials',
|
105 |
+
'mercadopago_payment_update'
|
106 |
+
) );
|
107 |
+
add_action( 'mercadopago_test_mode_update', array( $this, 'update_credential_production' ) );
|
108 |
|
109 |
if ( is_admin() ) {
|
110 |
// validate credentials.
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
+
* Load Helpers
|
126 |
*
|
127 |
+
* @return void
|
|
|
|
|
|
|
|
|
128 |
*/
|
129 |
+
public function load_helpers() {
|
130 |
+
include_once dirname( __FILE__ ) . '/../helpers/class-wc-woomercadopago-helper-current-url.php';
|
131 |
+
include_once dirname( __FILE__ ) . '/../helpers/class-wc-woomercadopago-helpers-currencyconverter.php';
|
132 |
+
include_once dirname( __FILE__ ) . '/../helpers/class-wc-woomercadopago-composite-id-helper.php';
|
133 |
+
include_once dirname( __FILE__ ) . '/../helpers/class-wc-woomercadopago-helper-links.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
|
136 |
/**
|
137 |
*
|
138 |
+
* Load Config / Categories
|
139 |
*
|
140 |
+
* @return void
|
|
|
|
|
141 |
*/
|
142 |
+
public function load_configs() {
|
143 |
+
self::$country_configs = self::get_country_configs();
|
144 |
+
$configs = new parent();
|
145 |
+
self::$categories = $configs->get_categories();
|
146 |
+
self::$site_data = self::get_site_data();
|
147 |
+
self::$payments_name = self::set_payment_gateway();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
}
|
149 |
|
150 |
/**
|
151 |
+
* Summary: Get information about the used Mercado Pago account based in its site.
|
152 |
+
* Description: Get information about the used Mercado Pago account based in its site.
|
153 |
*
|
154 |
+
* @return array with the information.
|
|
|
|
|
|
|
155 |
*/
|
156 |
+
public static function get_site_data() {
|
157 |
+
$site_id = strtolower( get_option( '_site_id_v1', '' ) );
|
158 |
+
if ( isset( $site_id ) && ! empty( $site_id ) ) {
|
159 |
+
return self::$country_configs[ $site_id ];
|
160 |
+
} else {
|
161 |
+
return null;
|
162 |
}
|
|
|
163 |
}
|
164 |
|
165 |
/**
|
166 |
*
|
167 |
+
* Load log
|
168 |
*
|
169 |
* @return void
|
170 |
*/
|
171 |
+
public function load_log() {
|
172 |
+
include_once dirname( __FILE__ ) . '/log/class-wc-woomercadopago-log.php';
|
|
|
|
|
|
|
|
|
173 |
}
|
174 |
|
175 |
/**
|
176 |
*
|
177 |
* Load Hooks
|
178 |
*
|
179 |
+
* @return void
|
180 |
*/
|
181 |
public function load_hooks() {
|
182 |
include_once dirname( __FILE__ ) . '/../payments/hooks/class-wc-woomercadopago-hook-abstract.php';
|
186 |
include_once dirname( __FILE__ ) . '/../payments/hooks/class-wc-woomercadopago-hook-pix.php';
|
187 |
}
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
/**
|
190 |
* Load Preferences Classes
|
191 |
*
|
204 |
/**
|
205 |
* Load Payment Classes
|
206 |
*
|
207 |
+
* @return void
|
208 |
*/
|
209 |
public function load_payments() {
|
210 |
include_once dirname( __FILE__ ) . '/../payments/class-wc-woomercadopago-payment-abstract.php';
|
227 |
include_once dirname( __FILE__ ) . '/../notification/class-wc-woomercadopago-notification-webhook.php';
|
228 |
}
|
229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
/**
|
231 |
*
|
232 |
* Load Stock Manager
|
239 |
|
240 |
/**
|
241 |
*
|
242 |
+
* Get Mp InstanceSingleton
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
*
|
244 |
+
* @param null|object $payment payment.
|
245 |
*
|
246 |
+
* @return MP|null
|
247 |
+
* @throws WC_WooMercadoPago_Exception Error.
|
248 |
*/
|
249 |
+
public static function get_mp_instance_singleton( $payment = null ) {
|
250 |
+
$mp = null;
|
251 |
+
if ( ! empty( $payment ) ) {
|
252 |
+
$class = get_class( $payment );
|
253 |
+
if ( ! isset( self::$mp_instance_ayment[ $class ] ) ) {
|
254 |
+
self::$mp_instance_ayment[ $class ] = self::get_mp_instance( $payment );
|
255 |
+
$mp = self::$mp_instance_ayment[ $class ];
|
256 |
+
if ( ! empty( $mp ) ) {
|
257 |
+
return $mp;
|
258 |
+
}
|
259 |
+
}
|
260 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
|
262 |
+
if ( null === self::$mp_instance || empty( $mp ) ) {
|
263 |
+
self::$mp_instance = self::get_mp_instance();
|
264 |
+
}
|
265 |
|
266 |
+
return self::$mp_instance;
|
267 |
}
|
268 |
|
269 |
/**
|
270 |
*
|
271 |
+
* Get Mp Instance
|
272 |
*
|
273 |
+
* @param object $payment payment.
|
274 |
+
*
|
275 |
+
* @return MP MP.
|
276 |
+
* @throws WC_WooMercadoPago_Exception Error.
|
277 |
*/
|
278 |
+
public static function get_mp_instance( $payment = null ) {
|
279 |
+
$credentials = new WC_WooMercadoPago_Credentials( $payment );
|
280 |
+
$validate_credentials_type = $credentials->validate_credentials_type();
|
281 |
+
if ( WC_WooMercadoPago_Credentials::TYPE_ACCESS_TOKEN === $validate_credentials_type ) {
|
282 |
+
$mp = new MP( $credentials->access_token );
|
283 |
+
$mp->set_payment_class( $payment );
|
284 |
+
}
|
285 |
+
if ( WC_WooMercadoPago_Credentials::TYPE_ACCESS_CLIENT === $validate_credentials_type ) {
|
286 |
+
$mp = new MP( $credentials->client_id, $credentials->client_secret );
|
287 |
+
$mp->set_payment_class( $payment );
|
288 |
+
if ( ! empty( $payment ) ) {
|
289 |
+
$payment->sandbox = false;
|
290 |
+
}
|
291 |
}
|
292 |
|
293 |
+
if ( ! isset( $mp ) ) {
|
294 |
+
return false;
|
295 |
+
}
|
296 |
|
297 |
+
$email = ( 0 !== wp_get_current_user()->ID ) ? wp_get_current_user()->user_email : null;
|
298 |
+
$mp->set_email( $email );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
|
300 |
+
$locale = get_locale();
|
301 |
+
$locale = false !== ( strpos( $locale, '_' ) && 5 === strlen( $locale ) ) ? explode( '_', $locale ) : array(
|
302 |
+
'',
|
303 |
+
''
|
304 |
+
);
|
305 |
+
$mp->set_locale( $locale[1] );
|
306 |
|
307 |
+
return $mp;
|
308 |
}
|
309 |
|
310 |
+
/**
|
311 |
+
*
|
312 |
+
* Init Mercado Pago Class
|
313 |
+
*
|
314 |
+
* @return WC_WooMercadoPago_Module|null
|
315 |
+
* Singleton
|
316 |
+
*/
|
317 |
+
public static function init_mercado_pago_class() {
|
318 |
+
if ( null === self::$instance ) {
|
319 |
+
self::$instance = new self();
|
|
|
|
|
|
|
|
|
320 |
}
|
321 |
|
322 |
+
return self::$instance;
|
323 |
}
|
324 |
|
325 |
/**
|
326 |
*
|
327 |
+
* Define terms and conditions link
|
|
|
|
|
328 |
*
|
329 |
+
* @return string
|
330 |
*/
|
331 |
+
public static function mp_define_terms_and_conditions() {
|
332 |
+
$links_mp = self::define_link_country();
|
333 |
+
$link_prefix_mp = 'https://www.mercadopago.';
|
334 |
+
|
335 |
+
return array(
|
336 |
+
'text_prefix' => __( 'By continuing, you agree to our ', 'woocommerce-mercadopago' ),
|
337 |
+
'link_terms_and_conditions' => $link_prefix_mp . $links_mp['sufix_url'] . $links_mp['help'] . $links_mp['term_conditition'],
|
338 |
+
'text_suffix' => __( 'Terms and Conditions', 'woocommerce-mercadopago' ),
|
339 |
+
);
|
340 |
+
|
341 |
}
|
342 |
|
343 |
/**
|
344 |
* Get Common Error Messages function
|
345 |
*
|
346 |
* @param string $key Key.
|
347 |
+
*
|
348 |
* @return string
|
349 |
*/
|
350 |
public static function get_common_error_messages( $key ) {
|
352 |
return __( 'The payment method is not valid or not available.', 'woocommerce-mercadopago' );
|
353 |
}
|
354 |
if ( 'Invalid transaction_amount' === $key ) {
|
355 |
+
return __( 'The transaction amount cannot be processed by Mercado Pago.', 'woocommerce-mercadopago' ) . ' ' . __( 'Possible causes: Currency not supported; Amounts below the minimum or above the maximum allowed.', 'woocommerce-mercadopago' );
|
|
|
356 |
}
|
357 |
if ( 'Invalid users involved' === $key ) {
|
358 |
+
return __( 'The users are not valid.', 'woocommerce-mercadopago' ) . ' ' . __( 'Possible causes: Buyer and seller have the same account in Mercado Pago; The transaction involving production and test users.', 'woocommerce-mercadopago' );
|
|
|
359 |
}
|
360 |
if ( 'Unauthorized use of live credentials' === $key ) {
|
361 |
+
return __( 'Unauthorized use of production credentials.', 'woocommerce-mercadopago' ) . ' ' . __( 'Possible causes: Use permission in use for the credential of the seller.', 'woocommerce-mercadopago' );
|
|
|
362 |
}
|
363 |
+
|
364 |
return $key;
|
365 |
}
|
366 |
|
369 |
* Description: The currencies are the one used in WooCommerce and the one used in $site_id.
|
370 |
*
|
371 |
* @param string $used_currency Used currency.
|
372 |
+
*
|
373 |
* @return float float that is the rate of conversion.
|
374 |
*/
|
375 |
public static function get_conversion_rate( $used_currency ) {
|
394 |
'code_version' => phpversion(),
|
395 |
'so_server' => PHP_OS,
|
396 |
);
|
397 |
+
|
398 |
return $infra_data;
|
399 |
}
|
400 |
|
401 |
+
/**
|
402 |
+
*
|
403 |
+
* Get WooCommerce instance
|
404 |
+
* Summary: Check if we have valid credentials for v1.
|
405 |
+
* Description: Check if we have valid credentials.
|
406 |
+
*
|
407 |
+
* @return boolean true/false depending on the validation result.
|
408 |
+
*/
|
409 |
+
public static function woocommerce_instance() {
|
410 |
+
if ( function_exists( 'WC' ) ) {
|
411 |
+
return WC();
|
412 |
+
} else {
|
413 |
+
global $woocommerce;
|
414 |
+
|
415 |
+
return $woocommerce;
|
416 |
+
}
|
417 |
+
}
|
418 |
+
|
419 |
/**
|
420 |
* Summary: Get Sponsor ID to preferences.
|
421 |
* Description: This function verifies, if the sponsor ID was configured,
|
426 |
*/
|
427 |
public static function get_sponsor_id() {
|
428 |
$site_data = self::get_site_data();
|
|
|
|
|
429 |
|
430 |
+
return $site_data['sponsor_id'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
}
|
432 |
|
433 |
/**
|
436 |
* Fix to URL Problem : #038; replaces & and breaks the navigation.
|
437 |
*
|
438 |
* @param string $link Link.
|
439 |
+
*
|
440 |
* @return string
|
441 |
*/
|
442 |
public static function fix_url_ampersand( $link ) {
|
458 |
* Check if an order is recurrent.
|
459 |
*
|
460 |
* @param object $items items.
|
461 |
+
*
|
462 |
* @return boolean
|
463 |
*/
|
464 |
public static function is_subscription( $items ) {
|
472 |
}
|
473 |
}
|
474 |
}
|
475 |
+
|
476 |
return $is_subscription;
|
477 |
}
|
478 |
|
480 |
* Get Country Name function
|
481 |
*
|
482 |
* @param string $site_id Site id.
|
483 |
+
*
|
484 |
* @return string
|
485 |
*/
|
486 |
public static function get_country_name( $site_id ) {
|
502 |
case 'mpe':
|
503 |
return __( 'Peru', 'woocommerce-mercadopago' );
|
504 |
}
|
505 |
+
|
506 |
return '';
|
507 |
}
|
508 |
|
510 |
* Get Map function
|
511 |
*
|
512 |
* @param array $selector_id Selector id.
|
513 |
+
*
|
514 |
* @return array
|
515 |
*/
|
516 |
public static function get_map( $selector_id ) {
|
553 |
if ( $woo_commerce_version <= '4.0.0' ) {
|
554 |
return false;
|
555 |
}
|
556 |
+
|
557 |
return true;
|
558 |
}
|
559 |
|
570 |
if ( preg_match( '/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i', $user_agent ) || preg_match( '/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr( $user_agent, 0, 4 ) ) ) {
|
571 |
$mobile = true;
|
572 |
}
|
573 |
+
|
574 |
return $mobile;
|
575 |
}
|
576 |
|
585 |
$types['WC_WooMercadoPago_Custom_Gateway'] = 'webhooks';
|
586 |
$types['WC_WooMercadoPago_Pix_Gateway'] = 'webhooks';
|
587 |
$types['WC_WooMercadoPago_Ticket_Gateway'] = 'webhooks';
|
588 |
+
|
589 |
+
return $types[ $notification_type ];
|
590 |
+
}
|
591 |
+
|
592 |
+
/**
|
593 |
+
* Load Admin Css
|
594 |
+
*
|
595 |
+
* @return void
|
596 |
+
*/
|
597 |
+
public function load_admin_css() {
|
598 |
+
if ( is_admin() && ( WC_WooMercadoPago_Helper_Current_Url::validate_page( 'mercadopago-settings' ) || WC_WooMercadoPago_Helper_Current_Url::validate_section( 'woo-mercado-pago' ) ) ) {
|
599 |
+
$suffix = $this->get_suffix();
|
600 |
+
|
601 |
+
wp_enqueue_style(
|
602 |
+
'woocommerce-mercadopago-basic-config-styles',
|
603 |
+
plugins_url( '../assets/css/config_mercadopago' . $suffix . '.css', plugin_dir_path( __FILE__ ) ),
|
604 |
+
array(),
|
605 |
+
WC_WooMercadoPago_Constants::VERSION
|
606 |
+
);
|
607 |
+
|
608 |
+
wp_enqueue_style(
|
609 |
+
'woocommerce-mercadopago-components',
|
610 |
+
plugins_url( '../assets/css/components_mercadopago' . $suffix . '.css', plugin_dir_path( __FILE__ ) ),
|
611 |
+
array(),
|
612 |
+
WC_WooMercadoPago_Constants::VERSION
|
613 |
+
);
|
614 |
+
}
|
615 |
+
}
|
616 |
+
|
617 |
+
/**
|
618 |
+
* Get Suffix to get minify files
|
619 |
+
*
|
620 |
+
* @return String
|
621 |
+
*/
|
622 |
+
private function get_suffix() {
|
623 |
+
return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
624 |
+
}
|
625 |
+
|
626 |
+
/**
|
627 |
+
* Load global CSS
|
628 |
+
*
|
629 |
+
* @return void
|
630 |
+
*/
|
631 |
+
public function load_global_css() {
|
632 |
+
$suffix = $this->get_suffix();
|
633 |
+
|
634 |
+
wp_enqueue_style(
|
635 |
+
'woocommerce-mercadopago-global-css',
|
636 |
+
plugins_url( '../assets/css/global' . $suffix . '.css', plugin_dir_path( __FILE__ ) ),
|
637 |
+
array(),
|
638 |
+
WC_WooMercadoPago_Constants::VERSION
|
639 |
+
);
|
640 |
+
}
|
641 |
+
|
642 |
+
/**
|
643 |
+
*
|
644 |
+
* Filter Payment Method by Shipping
|
645 |
+
*
|
646 |
+
* @param array $methods methods.
|
647 |
+
*
|
648 |
+
* @return array
|
649 |
+
*/
|
650 |
+
public function filter_payment_method_by_shipping( $methods ) {
|
651 |
+
return $methods;
|
652 |
+
}
|
653 |
+
|
654 |
+
/**
|
655 |
+
*
|
656 |
+
* Enable Payment Notice
|
657 |
+
*
|
658 |
+
* @return void
|
659 |
+
*/
|
660 |
+
public function enable_payment_notice() {
|
661 |
+
$type = 'notice-warning';
|
662 |
+
$message = __( 'Fill in your credentials to enable payment methods.', 'woocommerce-mercadopago' );
|
663 |
+
WC_WooMercadoPago_Notices::get_alert_frame( $message, $type );
|
664 |
+
}
|
665 |
+
|
666 |
+
/**
|
667 |
+
*
|
668 |
+
* Woomercadopago Settings Link add settings link on plugin page.
|
669 |
+
* Enable Payment Notice
|
670 |
+
*
|
671 |
+
* @param array $links links.
|
672 |
+
*
|
673 |
+
* @return array
|
674 |
+
*/
|
675 |
+
public function woomercadopago_settings_link( $links ) {
|
676 |
+
$links_mp = self::define_link_country();
|
677 |
+
$plugin_links = array();
|
678 |
+
$plugin_links[] = '<a href="' . admin_url( 'admin.php?page=mercadopago-settings' ) . '">' . __( 'Set plugin', 'woocommerce-mercadopago' ) . '</a>';
|
679 |
+
$plugin_links[] = '<a target="_blank" href="' . admin_url( 'admin.php?page=wc-settings&tab=checkout' ) . '">' . __( 'Payment methods', 'woocommerce-mercadopago' ) . '</a>';
|
680 |
+
$plugin_links[] = '<br><a target="_blank" href="https://www.mercadopago.' . $links_mp['sufix_url'] . 'developers/' . $links_mp['translate'] . '/guides/plugins/woocommerce/introduction/">' . __( 'Plugin manual', 'woocommerce-mercadopago' ) . '</a>';
|
681 |
+
|
682 |
+
return array_merge( $plugin_links, $links );
|
683 |
+
}
|
684 |
+
|
685 |
+
/**
|
686 |
+
*
|
687 |
+
* Define link country
|
688 |
+
*
|
689 |
+
* @return array
|
690 |
+
*/
|
691 |
+
public static function define_link_country() {
|
692 |
+
$sufix_country = 'AR';
|
693 |
+
$country = array(
|
694 |
+
'AR' => array( // Argentinian.
|
695 |
+
'help' => 'ayuda',
|
696 |
+
'sufix_url' => 'com.ar/',
|
697 |
+
'translate' => 'es',
|
698 |
+
'term_conditition' => '/terminos-y-politicas_194',
|
699 |
+
'site_id_mp' => 'mla',
|
700 |
+
|
701 |
+
),
|
702 |
+
'BR' => array( // Brazil.
|
703 |
+
'help' => 'ajuda',
|
704 |
+
'sufix_url' => 'com.br/',
|
705 |
+
'translate' => 'pt',
|
706 |
+
'term_conditition' => '/termos-e-politicas_194',
|
707 |
+
'site_id_mp' => 'mlb',
|
708 |
+
),
|
709 |
+
'CL' => array( // Chile.
|
710 |
+
'help' => 'ayuda',
|
711 |
+
'sufix_url' => 'cl/',
|
712 |
+
'translate' => 'es',
|
713 |
+
'term_conditition' => '/terminos-y-politicas_194',
|
714 |
+
'site_id_mp' => 'mlc',
|
715 |
+
),
|
716 |
+
'CO' => array( // Colombia.
|
717 |
+
'help' => 'ayuda',
|
718 |
+
'sufix_url' => 'com.co/',
|
719 |
+
'translate' => 'es',
|
720 |
+
'term_conditition' => '/terminos-y-politicas_194',
|
721 |
+
'site_id_mp' => 'mco',
|
722 |
+
),
|
723 |
+
'MX' => array( // Mexico.
|
724 |
+
'help' => 'ayuda',
|
725 |
+
'sufix_url' => 'com.mx/',
|
726 |
+
'translate' => 'es',
|
727 |
+
'term_conditition' => '/terminos-y-politicas_194',
|
728 |
+
'site_id_mp' => 'mlm',
|
729 |
+
),
|
730 |
+
'PE' => array( // Peru.
|
731 |
+
'help' => 'ayuda',
|
732 |
+
'sufix_url' => 'com.pe/',
|
733 |
+
'translate' => 'es',
|
734 |
+
'term_conditition' => '/terminos-y-politicas_194',
|
735 |
+
'site_id_mp' => 'mpe',
|
736 |
+
),
|
737 |
+
'UY' => array( // Uruguay.
|
738 |
+
'help' => 'ayuda',
|
739 |
+
'sufix_url' => 'com.uy/',
|
740 |
+
'translate' => 'es',
|
741 |
+
'term_conditition' => '/terminos-y-politicas_194',
|
742 |
+
'site_id_mp' => 'mlu',
|
743 |
+
),
|
744 |
+
);
|
745 |
+
|
746 |
+
$sufix_country = strtoupper( self::get_woocommerce_default_country() );
|
747 |
+
$links_country = array_key_exists( $sufix_country, $country ) ? $country[ $sufix_country ] : $country['AR'];
|
748 |
+
|
749 |
+
return $links_country;
|
750 |
+
}
|
751 |
+
|
752 |
+
/**
|
753 |
+
*
|
754 |
+
* Get Woocommerce default country configured
|
755 |
+
*
|
756 |
+
* @return string
|
757 |
+
*/
|
758 |
+
public static function get_woocommerce_default_country() {
|
759 |
+
$wc_country = get_option( 'woocommerce_default_country', '' );
|
760 |
+
if ( '' !== $wc_country ) {
|
761 |
+
$wc_country = strlen( $wc_country ) > 2 ? substr( $wc_country, 0, 2 ) : $wc_country;
|
762 |
+
}
|
763 |
+
|
764 |
+
return $wc_country;
|
765 |
+
}
|
766 |
+
|
767 |
+
/**
|
768 |
+
* Show row meta on the plugin screen.
|
769 |
+
*
|
770 |
+
* @param mixed $links Plugin Row Meta.
|
771 |
+
* @param mixed $file Plugin Base file.
|
772 |
+
*
|
773 |
+
* @return array
|
774 |
+
*/
|
775 |
+
public function mp_plugin_row_meta( $links, $file ) {
|
776 |
+
if ( WC_MERCADOPAGO_BASENAME === $file ) {
|
777 |
+
$new_link = array();
|
778 |
+
$new_link[] = $links[0];
|
779 |
+
$new_link[] = esc_html__( 'By Mercado Pago', 'woocommerce-mercadopago' );
|
780 |
+
|
781 |
+
return $new_link;
|
782 |
+
}
|
783 |
+
|
784 |
+
return (array) $links;
|
785 |
+
}
|
786 |
+
|
787 |
+
/**
|
788 |
+
* Update Credentials for production
|
789 |
+
*/
|
790 |
+
public function update_credential_production() {
|
791 |
+
if ( get_option( 'checkbox_checkout_test_mode' ) ) {
|
792 |
+
return;
|
793 |
+
}
|
794 |
+
|
795 |
+
$has_a_gateway_in_production = false;
|
796 |
+
|
797 |
+
foreach ( WC_WooMercadoPago_Constants::PAYMENT_GATEWAYS as $gateway ) {
|
798 |
+
$key = 'woocommerce_' . $gateway::get_id() . '_settings';
|
799 |
+
$options = get_option( $key );
|
800 |
+
if ( ! empty( $options ) ) {
|
801 |
+
$old_credential_is_prod = array_key_exists( 'checkout_credential_prod', $options ) && isset( $options['checkout_credential_prod'] ) ? $options['checkout_credential_prod'] : 'no';
|
802 |
+
$has_new_key = array_key_exists( 'checkbox_checkout_test_mode', $options ) && isset( $options['checkbox_checkout_test_mode'] );
|
803 |
+
$options['checkbox_checkout_test_mode'] = $has_new_key && 'deprecated' === $old_credential_is_prod
|
804 |
+
? $options['checkbox_checkout_test_mode']
|
805 |
+
: ( 'yes' === $old_credential_is_prod ? 'no' : 'yes' );
|
806 |
+
$options['checkout_credential_prod'] = 'deprecated';
|
807 |
+
|
808 |
+
if ( 'no' === $options['checkbox_checkout_test_mode'] ) {
|
809 |
+
$has_a_gateway_in_production = true;
|
810 |
+
}
|
811 |
+
|
812 |
+
update_option( $key, apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $gateway::get_id(), $options ) );
|
813 |
+
}
|
814 |
+
}
|
815 |
+
|
816 |
+
$test_mode_value = $has_a_gateway_in_production ? 'no' : 'yes';
|
817 |
+
|
818 |
+
update_option( 'checkbox_checkout_test_mode', $test_mode_value, true );
|
819 |
}
|
820 |
|
821 |
}
|
includes/module/config/class-wc-woomercadopago-constants.php
CHANGED
@@ -21,7 +21,7 @@ class WC_WooMercadoPago_Constants {
|
|
21 |
const PRODUCT_ID_DESKTOP = 'BT7OF5FEOO6G01NJK3QG';
|
22 |
const PRODUCT_ID_MOBILE = 'BT7OFH09QS3001K5A0H0';
|
23 |
const PLATAFORM_ID = 'bo2hnr2ic4p001kbgpt0';
|
24 |
-
const VERSION = '5.7.
|
25 |
const MIN_PHP = 5.6;
|
26 |
const API_MP_BASE_URL = 'https://api.mercadopago.com';
|
27 |
const PAYMENT_GATEWAYS = array(
|
21 |
const PRODUCT_ID_DESKTOP = 'BT7OF5FEOO6G01NJK3QG';
|
22 |
const PRODUCT_ID_MOBILE = 'BT7OFH09QS3001K5A0H0';
|
23 |
const PLATAFORM_ID = 'bo2hnr2ic4p001kbgpt0';
|
24 |
+
const VERSION = '5.7.3';
|
25 |
const MIN_PHP = 5.6;
|
26 |
const API_MP_BASE_URL = 'https://api.mercadopago.com';
|
27 |
const PAYMENT_GATEWAYS = array(
|
includes/payments/class-wc-woomercadopago-basic-gateway.php
CHANGED
@@ -220,7 +220,7 @@ class WC_WooMercadoPago_Basic_Gateway extends WC_WooMercadoPago_Payment_Abstract
|
|
220 |
*/
|
221 |
private function get_ex_payments() {
|
222 |
$ex_payments = array();
|
223 |
-
$get_ex_payment_options =
|
224 |
if ( ! empty( $get_ex_payment_options ) ) {
|
225 |
$options = explode( ',', $get_ex_payment_options );
|
226 |
foreach ( $options as $option ) {
|
@@ -518,7 +518,7 @@ class WC_WooMercadoPago_Basic_Gateway extends WC_WooMercadoPago_Payment_Abstract
|
|
518 |
$amount = $this->get_order_total();
|
519 |
|
520 |
if ( method_exists( $order, 'update_meta_data' ) ) {
|
521 |
-
$order->update_meta_data( 'is_production_mode',
|
522 |
$order->update_meta_data( '_used_gateway', get_class( $this ) );
|
523 |
|
524 |
if ( ! empty( $this->gateway_discount ) ) {
|
220 |
*/
|
221 |
private function get_ex_payments() {
|
222 |
$ex_payments = array();
|
223 |
+
$get_ex_payment_options = get_option( '_all_payment_methods_v0', '' );
|
224 |
if ( ! empty( $get_ex_payment_options ) ) {
|
225 |
$options = explode( ',', $get_ex_payment_options );
|
226 |
foreach ( $options as $option ) {
|
518 |
$amount = $this->get_order_total();
|
519 |
|
520 |
if ( method_exists( $order, 'update_meta_data' ) ) {
|
521 |
+
$order->update_meta_data( 'is_production_mode', 'no' === $this->mp_options->get_checkbox_checkout_test_mode() ? 'yes' : 'no' );
|
522 |
$order->update_meta_data( '_used_gateway', get_class( $this ) );
|
523 |
|
524 |
if ( ! empty( $this->gateway_discount ) ) {
|
includes/payments/class-wc-woomercadopago-custom-gateway.php
CHANGED
@@ -536,7 +536,7 @@ class WC_WooMercadoPago_Custom_Gateway extends WC_WooMercadoPago_Payment_Abstrac
|
|
536 |
protected function process_discount_and_commission( $order_id, $order ) {
|
537 |
$amount = $this->get_order_total();
|
538 |
if ( method_exists( $order, 'update_meta_data' ) ) {
|
539 |
-
$order->update_meta_data( 'is_production_mode',
|
540 |
$order->update_meta_data( '_used_gateway', get_class( $this ) );
|
541 |
|
542 |
if ( ! empty( $this->gateway_discount ) ) {
|
536 |
protected function process_discount_and_commission( $order_id, $order ) {
|
537 |
$amount = $this->get_order_total();
|
538 |
if ( method_exists( $order, 'update_meta_data' ) ) {
|
539 |
+
$order->update_meta_data( 'is_production_mode', 'no' === $this->mp_options->get_checkbox_checkout_test_mode() ? 'yes' : 'no' );
|
540 |
$order->update_meta_data( '_used_gateway', get_class( $this ) );
|
541 |
|
542 |
if ( ! empty( $this->gateway_discount ) ) {
|
includes/payments/class-wc-woomercadopago-pix-gateway.php
CHANGED
@@ -401,7 +401,7 @@ class WC_WooMercadoPago_Pix_Gateway extends WC_WooMercadoPago_Payment_Abstract {
|
|
401 |
|
402 |
$amount = $this->get_order_total();
|
403 |
if ( method_exists( $order, 'update_meta_data' ) ) {
|
404 |
-
$order->update_meta_data( 'is_production_mode',
|
405 |
$order->update_meta_data( '_used_gateway', get_class( $this ) );
|
406 |
|
407 |
if ( ! empty( $this->gateway_discount ) ) {
|
401 |
|
402 |
$amount = $this->get_order_total();
|
403 |
if ( method_exists( $order, 'update_meta_data' ) ) {
|
404 |
+
$order->update_meta_data( 'is_production_mode', 'no' === $this->mp_options->get_checkbox_checkout_test_mode() ? 'yes' : 'no' );
|
405 |
$order->update_meta_data( '_used_gateway', get_class( $this ) );
|
406 |
|
407 |
if ( ! empty( $this->gateway_discount ) ) {
|
includes/payments/class-wc-woomercadopago-ticket-gateway.php
CHANGED
@@ -154,8 +154,8 @@ class WC_WooMercadoPago_Ticket_Gateway extends WC_WooMercadoPago_Payment_Abstrac
|
|
154 |
}
|
155 |
|
156 |
foreach ( $get_payment_methods_ticket as $payment_methods_ticket ) {
|
157 |
-
if ( ! isset( $saved_options[
|
158 |
-
|| 'yes' === $saved_options[
|
159 |
array_push( $activated_payment, $payment_methods_ticket );
|
160 |
sort($activated_payment);
|
161 |
}
|
@@ -382,7 +382,7 @@ class WC_WooMercadoPago_Ticket_Gateway extends WC_WooMercadoPago_Payment_Abstrac
|
|
382 |
$order = wc_get_order( $order_id );
|
383 |
$amount = $this->get_order_total();
|
384 |
if ( method_exists( $order, 'update_meta_data' ) ) {
|
385 |
-
$order->update_meta_data( 'is_production_mode',
|
386 |
$order->update_meta_data( '_used_gateway', get_class( $this ) );
|
387 |
|
388 |
if ( ! empty( $this->gateway_discount ) ) {
|
@@ -589,7 +589,7 @@ class WC_WooMercadoPago_Ticket_Gateway extends WC_WooMercadoPago_Payment_Abstrac
|
|
589 |
}
|
590 |
|
591 |
$last_element = array_pop( $payments );
|
592 |
-
$paycash_payments = implode
|
593 |
|
594 |
return implode( __(' and ', 'woocommerce-mercadopago') , array( $paycash_payments, $last_element ));
|
595 |
}
|
154 |
}
|
155 |
|
156 |
foreach ( $get_payment_methods_ticket as $payment_methods_ticket ) {
|
157 |
+
if ( ! isset( $saved_options[ $payment_methods_ticket['id'] ] )
|
158 |
+
|| 'yes' === $saved_options[ $payment_methods_ticket['id'] ] ) {
|
159 |
array_push( $activated_payment, $payment_methods_ticket );
|
160 |
sort($activated_payment);
|
161 |
}
|
382 |
$order = wc_get_order( $order_id );
|
383 |
$amount = $this->get_order_total();
|
384 |
if ( method_exists( $order, 'update_meta_data' ) ) {
|
385 |
+
$order->update_meta_data( 'is_production_mode', 'no' === $this->mp_options->get_checkbox_checkout_test_mode() ? 'yes' : 'no' );
|
386 |
$order->update_meta_data( '_used_gateway', get_class( $this ) );
|
387 |
|
388 |
if ( ! empty( $this->gateway_discount ) ) {
|
589 |
}
|
590 |
|
591 |
$last_element = array_pop( $payments );
|
592 |
+
$paycash_payments = implode(', ', $payments);
|
593 |
|
594 |
return implode( __(' and ', 'woocommerce-mercadopago') , array( $paycash_payments, $last_element ));
|
595 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: ecommerce, mercadopago, woocommerce
|
|
4 |
Requires at least: 4.9.10
|
5 |
Tested up to: 5.9
|
6 |
Requires PHP: 5.6
|
7 |
-
Stable tag: 5.7.
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -133,6 +133,13 @@ Set up both the plugin and the checkouts you want to activate on your payment av
|
|
133 |
Check out our <a href="https://www.mercadopago.com.br/developers/pt/plugins_sdks/plugins/official/woo-commerce/">official documentation</a> for more information on the specific fields to configure.
|
134 |
|
135 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
= v5.7.2 (14/02/2022) =
|
137 |
* Bug fixes
|
138 |
- Using Jquery from wp.ajax
|
4 |
Requires at least: 4.9.10
|
5 |
Tested up to: 5.9
|
6 |
Requires PHP: 5.6
|
7 |
+
Stable tag: 5.7.3
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
133 |
Check out our <a href="https://www.mercadopago.com.br/developers/pt/plugins_sdks/plugins/official/woo-commerce/">official documentation</a> for more information on the specific fields to configure.
|
134 |
|
135 |
== Changelog ==
|
136 |
+
= v5.7.3 (16/02/2022) =
|
137 |
+
* Bug fixes
|
138 |
+
- fixed cho pro excluded payments
|
139 |
+
- fixed cho ticket excluded payments
|
140 |
+
- validate if has a checkout prod set all to prod
|
141 |
+
- fixed mp order screen
|
142 |
+
|
143 |
= v5.7.2 (14/02/2022) =
|
144 |
* Bug fixes
|
145 |
- Using Jquery from wp.ajax
|
woocommerce-mercadopago.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Mercado Pago payments for WooCommerce
|
4 |
* Plugin URI: https://github.com/mercadopago/cart-woocommerce
|
5 |
* Description: Configure the payment options and accept payments with cards, ticket and money of Mercado Pago account.
|
6 |
-
* Version: 5.7.
|
7 |
* Author: Mercado Pago
|
8 |
* Author URI: https://developers.mercadopago.com/
|
9 |
* Text Domain: woocommerce-mercadopago
|
3 |
* Plugin Name: Mercado Pago payments for WooCommerce
|
4 |
* Plugin URI: https://github.com/mercadopago/cart-woocommerce
|
5 |
* Description: Configure the payment options and accept payments with cards, ticket and money of Mercado Pago account.
|
6 |
+
* Version: 5.7.3
|
7 |
* Author: Mercado Pago
|
8 |
* Author URI: https://developers.mercadopago.com/
|
9 |
* Text Domain: woocommerce-mercadopago
|