Skip to content

Commit

Permalink
Enable payment only if store base country is US.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Jan 26, 2024
1 parent 9bb3a09 commit 4355ddd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions includes/Gateway/Cash_App_Pay_Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ public function add_admin_notices() {
$base_location = wc_get_base_location();
$is_plugin_settings = $this->get_plugin()->is_payment_gateway_configuration_page( $this->get_id() );
$is_connected = $this->get_plugin()->get_settings_handler()->is_connected() && $this->get_plugin()->get_settings_handler()->get_location_id();
$is_enabled = $this->is_enabled() && $is_connected;

// Add a notice for cash app pay if the base location is not the US.
if ( ( $this->is_configured() || $is_plugin_settings ) && isset( $base_location['country'] ) && 'US' !== $base_location['country'] ) {
if ( ( $is_enabled || $is_plugin_settings ) && isset( $base_location['country'] ) && 'US' !== $base_location['country'] ) {

$this->get_plugin()->get_admin_notice_handler()->add_admin_notice(
sprintf(
Expand Down Expand Up @@ -369,7 +370,11 @@ public function is_available() {
* @return boolean true if the gateway is properly configured
*/
public function is_configured() {
return $this->is_enabled() && $this->get_plugin()->get_settings_handler()->is_connected() && $this->get_plugin()->get_settings_handler()->get_location_id();
// Only available in the US
$base_location = wc_get_base_location();
$us_only = isset( $base_location['country'] ) && 'US' === $base_location['country'];

return $this->is_enabled() && $us_only && $this->get_plugin()->get_settings_handler()->is_connected() && $this->get_plugin()->get_settings_handler()->get_location_id();
}

/** Getter methods ************************************************************************************************/
Expand Down

0 comments on commit 4355ddd

Please sign in to comment.