Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add payment gateway setup help text #281

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions includes/payments/class-wc-woomercadopago-custom-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,4 +593,41 @@ 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 <a href="%s">store settings.</a> Create your Mercado Pago account <a href="%s">here.</a>', 'wc_mercado' ),
$this->get_registration_url(),
admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . 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() );
}
}