Skip to content

Commit

Permalink
Merge pull request #325 from PluginAndPartners/fix/get-payment-refused
Browse files Browse the repository at this point in the history
Correções - Release 5.4.0
SalehKhalilMP authored Sep 22, 2021
2 parents c225c12 + 60baa4b commit eb4c9df
Showing 5 changed files with 29 additions and 31 deletions.
10 changes: 5 additions & 5 deletions i18n/languages/woocommerce-mercadopago.pot
Original file line number Diff line number Diff line change
@@ -974,19 +974,19 @@ msgstr ""
msgid "%s"
msgstr ""

#: ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1876, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1876, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1876
#: ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1877, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1877, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1877
msgid "All Mercado Pago payment methods are in Production Mode"
msgstr ""

#: ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1877, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1877, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1877
#: ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1878, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1878, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1878
msgid "All Mercado Pago payment methods are in Test Mode"
msgstr ""

#: ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1879, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1879, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1879
#: ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1880, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1880, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1880
msgid "Your store is ready to receive payments from customers."
msgstr ""

#: ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1880, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1880, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1880
#: ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1881, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1881, ../../includes/payments/class-wc-woomercadopago-payment-abstract.php:1881
msgid "Your customers will not be able to make purchases while in Test Mode."
msgstr ""

@@ -1639,7 +1639,7 @@ msgstr ""
msgid "Copy code"
msgstr ""

#: ../../includes/module/sdk/lib/class-mp.php:601, ../../includes/module/sdk/lib/class-mp.php:645, ../../includes/module/sdk/lib/class-mp.php:601, ../../includes/module/sdk/lib/class-mp.php:645, ../../includes/module/sdk/lib/class-mp.php:601, ../../includes/module/sdk/lib/class-mp.php:645
#: ../../includes/module/sdk/lib/class-mp.php:599, ../../includes/module/sdk/lib/class-mp.php:643, ../../includes/module/sdk/lib/class-mp.php:599, ../../includes/module/sdk/lib/class-mp.php:643, ../../includes/module/sdk/lib/class-mp.php:599, ../../includes/module/sdk/lib/class-mp.php:643
msgid "Response from cache"
msgstr ""

Original file line number Diff line number Diff line change
@@ -363,11 +363,11 @@ public function payment_status_metabox_content( $post ) {

$last_payment_id = end($payment_ids);
$is_production_mode = $order->get_meta( 'is_production_mode' );
$access_token = 'no' === $is_production_mode
$access_token = 'no' === $is_production_mode || ! $is_production_mode
? get_option( '_mp_access_token_test' )
: get_option( '_mp_access_token_prod' );
$mp = new MP($access_token);
$payment = $mp->search_payment_v1(trim($last_payment_id));
$payment = $mp->search_payment_v1(trim($last_payment_id), $access_token);

if ( ! $payment || ! $payment['status'] || 200 !== $payment['status'] ) {
return;
@@ -473,13 +473,13 @@ public function get_mp_home_link( $country ) {
*/
public function get_mp_devsite_link( $country ) {
$country_links = [
'mla' => 'https://rebrand.ly/l5bt0p3',
'mlb' => 'https://rebrand.ly/g20teif',
'mlc' => 'https://rebrand.ly/6drvoof',
'mco' => 'https://rebrand.ly/o5av2xn',
'mlm' => 'https://rebrand.ly/ajrdsp3',
'mpe' => 'https://rebrand.ly/m16d4v4',
'mlu' => 'https://rebrand.ly/0a2ngts',
'mla' => 'https://www.mercadopago.com.ar/developers/es/guides/plugins/woocommerce/sales-processing#bookmark_motivos_de_las_recusas',
'mlb' => 'https://www.mercadopago.com.br/developers/pt/guides/plugins/woocommerce/sales-processing#bookmark_motivos_de_recusas',
'mlc' => 'https://www.mercadopago.cl/developers/es/guides/plugins/woocommerce/sales-processing#bookmark_motivos_de_las_recusas',
'mco' => 'https://www.mercadopago.com.co/developers/es/guides/plugins/woocommerce/sales-processing#bookmark_motivos_de_las_recusas',
'mlm' => 'https://www.mercadopago.com.mx/developers/es/guides/plugins/woocommerce/sales-processing#bookmark_motivos_de_las_recusas',
'mpe' => 'https://www.mercadopago.com.pe/developers/es/guides/plugins/woocommerce/sales-processing#bookmark_motivos_de_las_recusas',
'mlu' => 'https://www.mercadopago.com.uy/developers/es/guides/plugins/woocommerce/sales-processing#bookmark_motivos_de_las_recusas',
];
$link = array_key_exists($country, $country_links) ? $country_links[$country] : $country_links['mla'];

6 changes: 2 additions & 4 deletions includes/module/sdk/lib/class-mp.php
Original file line number Diff line number Diff line change
@@ -128,7 +128,6 @@ public function sandbox_mode( $enable = null ) {
* @throws WC_WooMercadoPago_Exception Get Access Token Exception.
*/
public function get_access_token() {

if ( isset( $this->ll_access_token ) && ! is_null( $this->ll_access_token ) ) {
return $this->ll_access_token;
}
@@ -170,12 +169,11 @@ public function get_access_token() {
* @return array|null
* @throws WC_WooMercadoPago_Exception Search Payment V1 Exception.
*/
public function search_payment_v1( $id ) {

public function search_payment_v1( $id, $token = null ) {
$request = array(
'uri' => '/v1/payments/' . $id,
'headers' => array(
'Authorization' => 'Bearer ' . $this->get_access_token(),
'Authorization' => 'Bearer ' . ( is_null($token) ? $this->get_access_token() : $token ),
)
);

24 changes: 12 additions & 12 deletions includes/payments/class-wc-woomercadopago-payment-abstract.php
Original file line number Diff line number Diff line change
@@ -1854,13 +1854,13 @@ public function update_credential_production() {
$key = 'woocommerce_' . $gateway::get_id() . '_settings';
$options = get_option( $key );
if ( ! empty( $options ) ) {
if ( ! isset( $options['checkbox_checkout_test_mode'] ) || empty( $options['checkbox_checkout_test_mode'] ) ) {
continue;
}

$old_credential_is_prod = array_key_exists('checkout_credential_prod', $options) && isset($options['checkout_credential_prod']) ? $options['checkout_credential_prod'] : 'no';
$has_new_key = array_key_exists('checkbox_checkout_test_mode', $options) && isset($options['checkbox_checkout_test_mode']);
$options['checkbox_checkout_test_mode'] = $has_new_key ? $options['checkbox_checkout_test_mode'] : ( 'yes' === $old_credential_is_prod ? 'no' : 'yes' );
$options['checkbox_checkout_test_mode'] = $has_new_key && 'deprecated' === $old_credential_is_prod
? $options['checkbox_checkout_test_mode']
: ( 'yes' === $old_credential_is_prod ? 'no' : 'yes' );
$options['checkout_credential_prod'] = 'deprecated';

update_option( $key, apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $gateway::get_id(), $options ) );
}
}
@@ -1954,13 +1954,13 @@ public function get_country_domain_by_meli_acronym( $meliAcronym ) {
*/
public function get_mp_devsite_link( $country ) {
$country_links = [
'mla' => 'https://rebrand.ly/test-woo-ar',
'mlb' => 'https://rebrand.ly/test-woo-br',
'mlc' => 'https://rebrand.ly/test-woo-cl',
'mco' => 'https://rebrand.ly/test-woo-co',
'mlm' => 'https://rebrand.ly/test-woo-mx',
'mpe' => 'https://rebrand.ly/test-woo-pe',
'mlu' => 'https://rebrand.ly/test-woo-uy',
'mla' => 'https://www.mercadopago.com.ar/developers/es/guides/plugins/woocommerce/testing',
'mlb' => 'https://www.mercadopago.com.br/developers/pt/guides/plugins/woocommerce/testing',
'mlc' => 'https://www.mercadopago.cl/developers/es/guides/plugins/woocommerce/testing',
'mco' => 'https://www.mercadopago.com.co/developers/es/guides/plugins/woocommerce/testing',
'mlm' => 'https://www.mercadopago.com.mx/developers/es/guides/plugins/woocommerce/testing',
'mpe' => 'https://www.mercadopago.com.pe/developers/es/guides/plugins/woocommerce/testing',
'mlu' => 'https://www.mercadopago.com.uy/developers/es/guides/plugins/woocommerce/testing',
];
$link = array_key_exists($country, $country_links) ? $country_links[$country] : $country_links['mla'];

2 changes: 1 addition & 1 deletion woocommerce-mercadopago.php
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
* Text Domain: woocommerce-mercadopago
* Domain Path: /i18n/languages/
* WC requires at least: 3.0.0
* WC tested up to: 5.5.2
* WC tested up to: 5.7
*
* @package MercadoPago
*/

0 comments on commit eb4c9df

Please sign in to comment.