From f0be2154ac6af95a8a651edb7abc2b834224408a Mon Sep 17 00:00:00 2001 From: Joshua Flowers Date: Tue, 25 May 2021 12:38:06 -0400 Subject: [PATCH 1/3] Add payment gateway setup help text --- ...class-wc-woomercadopago-custom-gateway.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/includes/payments/class-wc-woomercadopago-custom-gateway.php b/includes/payments/class-wc-woomercadopago-custom-gateway.php index afc6a3e6e..23761e58b 100755 --- a/includes/payments/class-wc-woomercadopago-custom-gateway.php +++ b/includes/payments/class-wc-woomercadopago-custom-gateway.php @@ -593,4 +593,32 @@ public function get_or_create_customer() { public static function get_id() { return self::ID; } + + /** + * Get the Mercado Pago registration URL. + * + * @return string URL. + */ + public function get_registration_url() { + $url = 'https://www.mercadopago.com'; + $country_code = WC_Countries::get_base_country(); + + if ( in_array( $country_code, array( 'AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY' ) ) ) { + $country_code = strtolower( $country_code ); + return "${url}.${country_code}/registration-company?confirmation_url=${url}.${country_code}%2Fcomo-cobrar"; + } + + return $url; + } + + /** + * Get help text to display during quick setup. + */ + public function get_setup_help_text() { + return sprintf( + __( 'Mercado Pago can be configured under your store settings. Create your Mercado Pago account here.', 'wc_mercado' ), + $this->get_registration_url(), + admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . strtolower( $this->id ) ) + ); + } } From 841255b0c53e258214a90919b481cdcfe7642928 Mon Sep 17 00:00:00 2001 From: Joshua Flowers Date: Tue, 1 Jun 2021 16:49:45 -0400 Subject: [PATCH 2/3] Add needs_setup check --- .../payments/class-wc-woomercadopago-custom-gateway.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/includes/payments/class-wc-woomercadopago-custom-gateway.php b/includes/payments/class-wc-woomercadopago-custom-gateway.php index 23761e58b..77df58e4d 100755 --- a/includes/payments/class-wc-woomercadopago-custom-gateway.php +++ b/includes/payments/class-wc-woomercadopago-custom-gateway.php @@ -621,4 +621,13 @@ public function get_setup_help_text() { admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . strtolower( $this->id ) ) ); } + + /** + * Check if the gateway still required further setup. + * + * @return bool + */ + public function needs_setup() { + return empty( $this->get_access_token() ) || empty( $this->get_public_key() ); + } } From 9f8ed0c31117522dcd5aaf649a15f39d72ed95a1 Mon Sep 17 00:00:00 2001 From: Joshua Flowers Date: Tue, 1 Jun 2021 17:31:12 -0400 Subject: [PATCH 3/3] Fix get base country call --- includes/payments/class-wc-woomercadopago-custom-gateway.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/payments/class-wc-woomercadopago-custom-gateway.php b/includes/payments/class-wc-woomercadopago-custom-gateway.php index 77df58e4d..c69e91c89 100755 --- a/includes/payments/class-wc-woomercadopago-custom-gateway.php +++ b/includes/payments/class-wc-woomercadopago-custom-gateway.php @@ -601,7 +601,7 @@ public static function get_id() { */ public function get_registration_url() { $url = 'https://www.mercadopago.com'; - $country_code = WC_Countries::get_base_country(); + $country_code = WC()->countries->get_base_country(); if ( in_array( $country_code, array( 'AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY' ) ) ) { $country_code = strtolower( $country_code );