diff --git a/globalpayments-gateway-provider-for-woocommerce.php b/globalpayments-gateway-provider-for-woocommerce.php index be854d0..a47fb17 100644 --- a/globalpayments-gateway-provider-for-woocommerce.php +++ b/globalpayments-gateway-provider-for-woocommerce.php @@ -23,31 +23,3 @@ include_once $autoloader; add_action( 'plugins_loaded', array( \GlobalPayments\WooCommercePaymentGatewayProvider\Plugin::class, 'init' ) ); } - -function globalpayments_gpapi_upgrader_process_complete( WP_Upgrader $wp_upgrader, $hook_extra ) { - if ( 'plugin' !== $hook_extra[ 'type' ] || plugin_basename( __FILE__ ) == $hook_extra[ 'plugins' ] ) { - return; - } - if ( 'update' === $hook_extra[ 'action' ] || 'install' === $hook_extra[ 'action' ] ) { - $current_plugin_version = get_option( 'woocommerce_globalpayments_version' ); - if ( ! empty( $current_plugin_version ) ) { - if ( version_compare( \GlobalPayments\WooCommercePaymentGatewayProvider\Plugin::VERSION, $current_plugin_version, '>') ) { - delete_option( 'woocommerce_globalpayments_version' ); - update_option( 'woocommerce_globalpayments_version', \GlobalPayments\WooCommercePaymentGatewayProvider\Plugin::VERSION ); - } - return; - } - if ( empty( $settings['app_id'] ) && empty( $settings['app_key'] ) ) { - return; - } - if ( ! wc_string_to_bool( $settings['is_production'] ) ) { - $settings['sandbox_app_id'] = $settings['app_id']; - $settings['sandbox_app_key'] = $settings['app_key']; - $settings['app_id'] = ''; - $settings['app_key'] = ''; - update_option( 'woocommerce_globalpayments_gpapi_settings', $settings ); - } - update_option( 'woocommerce_globalpayments_version', \GlobalPayments\WooCommercePaymentGatewayProvider\Plugin::VERSION ); - } -} -add_action( 'upgrader_process_complete', 'globalpayments_gpapi_upgrader_process_complete', 10, 2 ); diff --git a/readme.txt b/readme.txt index b0399dc..c451ddf 100644 --- a/readme.txt +++ b/readme.txt @@ -1,6 +1,6 @@ === GlobalPayments WooCommerce === Contributors: globalpayments -Tags: unified, commerce, platform, global, payments, ucp, heartland, payment, systems, tsys, genius, 3DS, gateway, token, tokenize, save cards +Tags: woocommerce, woo, unified, commerce, platform, global, payments, ucp, heartland, payment, systems, tsys, genius, 3DS, gateway, token, tokenize, save cards Requires at least: 5.4 Tested up to: 5.7 Stable tag: 1.1.0 @@ -49,8 +49,6 @@ Access to our Unified Commerce Platform (UCP) requires sandbox credentials which * Renamed GP-API to Unified Commerce Platform (UCP) * Update PHP-SDK to v2.3.7 * Update UCP 3DS -* Add UCP Sandbox indicator at checkout -* Add UCP separate credentials config for Live and Sandbox = 1.0.2 = * Update PHP-SDK to v2.3.6 diff --git a/src/Gateways/GpApiGateway.php b/src/Gateways/GpApiGateway.php index 3c0ae14..43a05c4 100644 --- a/src/Gateways/GpApiGateway.php +++ b/src/Gateways/GpApiGateway.php @@ -25,29 +25,14 @@ class GpApiGateway extends AbstractGateway { public $gateway_provider = GatewayProvider::GP_API; /** - * Sandbox App ID - * - * @var string - */ - public $sandbox_app_id; - - /** - * Sandbox App Key - * - * - * @var string - */ - public $sandbox_app_key; - - /** - * Production App ID + * App ID * * @var string */ public $app_id; /** - * Production App Key + * App Key * * * @var string @@ -87,57 +72,35 @@ public function get_first_line_support_email() { public function get_gateway_form_fields() { return array( - 'section_sandbox' => array( - 'title' => __( 'Sandbox Credentials', 'globalpayments-gateway-provider-for-woocommerce' ), - 'type' => 'title', + 'app_id' => array( + 'title' => __( 'App Id', 'globalpayments-gateway-provider-for-woocommerce' ), + 'type' => 'text', 'description' => __( 'Get your App Id and App Key from your Global Payments Developer Account. ' . 'Please follow the instuctions provided in the plugin description.', 'globalpayments-gateway-provider-for-woocommerce' ), - ), - 'sandbox_app_id' => array( - 'title' => __( 'Sandbox App Id', 'globalpayments-gateway-provider-for-woocommerce' ), - 'type' => 'text', - 'description' => '', 'default' => '', ), - 'sandbox_app_key' => array( - 'title' => __( 'Sandbox App Key', 'globalpayments-gateway-provider-for-woocommerce' ), + 'app_key' => array( + 'title' => __( 'App Key', 'globalpayments-gateway-provider-for-woocommerce' ), 'type' => 'password', - 'description' => '', + 'description' => __( + 'Get your App Id and App Key from your Global Payments Developer Account. ' . + 'Please follow the instuctions provided in the plugin description.', + 'globalpayments-gateway-provider-for-woocommerce' + ), 'default' => '', ), - 'section_live' => array( - 'title' => __( 'Live Credentials', 'globalpayments-gateway-provider-for-woocommerce' ), - 'type' => 'title', + 'is_production' => array( + 'title' => __( 'Live Mode', 'globalpayments-gateway-provider-for-woocommerce' ), + 'type' => 'checkbox', 'description' => sprintf( /* translators: %s: Email address of support team */ __( 'When you are ready for Live, please contact support to get you live credentials.', 'globalpayments-gateway-provider-for-woocommerce' ), $this->get_first_line_support_email() ), - ), - 'app_id' => array( - 'title' => __( 'Live App Id', 'globalpayments-gateway-provider-for-woocommerce' ), - 'type' => 'text', - 'description' => '', - 'default' => '', - ), - 'app_key' => array( - 'title' => __( 'Live App Key', 'globalpayments-gateway-provider-for-woocommerce' ), - 'type' => 'password', - 'description' => '', - 'default' => '', - ), - 'is_production' => array( - 'title' => __( 'Live Mode', 'globalpayments-gateway-provider-for-woocommerce' ), - 'type' => 'checkbox', - 'desc_tip' => true, - 'description' => __( - 'Allows you to switch between the Live and Sandbox version of your Global Payments account.', - 'globalpayments-gateway-provider-for-woocommerce' - ), 'default' => 'no', ), 'section_general' => array( @@ -159,10 +122,7 @@ public function needs_setup() { if ( empty( $this->merchant_contact_url ) ) { return true; } - if ( wc_string_to_bool( $this->is_production ) ) { - return ( empty( $this->app_id ) || empty( $this->app_key ) ); - } - return ( empty( $this->sandbox_app_id ) || empty( $this->sandbox_app_key ) ); + return ( empty( $this->app_id ) || empty( $this->app_key ) ); } public function get_frontend_gateway_options() { @@ -175,8 +135,8 @@ public function get_frontend_gateway_options() { public function get_backend_gateway_options() { return array( - 'appId' => $this->get_app_id(), - 'appKey' => $this->get_app_key(), + 'appId' => $this->app_id, + 'appKey' => $this->app_key, 'channel' => Channels::CardNotPresent, 'country' => wc_get_base_location()['country'], 'developerId' => '', @@ -194,18 +154,9 @@ protected function get_access_token() { return $response->token; } - protected function get_app_id() { - return $this->is_production ? $this->app_id : $this->sandbox_app_id; - } - - protected function get_app_key() { - return $this->is_production ? $this->app_key : $this->sandbox_app_key; - } - protected function add_hooks() { parent::add_hooks(); - add_filter( 'woocommerce_gateway_title', array( $this, 'gateway_title' ), 10, 2 ); add_filter( 'pre_update_option_woocommerce_globalpayments_gpapi_settings', array( $this, 'woocommerce_globalpayments_gpapi_settings' ) ); add_action( 'woocommerce_after_checkout_validation', array( $this, 'after_checkout_validation' ), 10, 2 ); @@ -219,22 +170,6 @@ protected function add_hooks() { add_action( 'woocommerce_api_globalpayments_threedsecure_challengenotification', array( $this, 'process_threeDSecure_challengeNotification' ) ); } - public function gateway_title( $gateway_title, $gateway_id ) { - if ( self::GATEWAY_ID !== $gateway_id ) { - return $gateway_title; - } - if ( ! wc_string_to_bool( $this->enabled ) ) { - return $gateway_title; - } - if ( $this->is_production ) { - return $gateway_title; - } - if ( ! is_checkout() && ! is_add_payment_method_page() ) { - return $gateway_title; - } - return $gateway_title . __( ' [SANDBOX_MODE]' ); - } - public function woocommerce_globalpayments_gpapi_settings( $settings ) { if ( ! wc_string_to_bool( $settings['enabled'] ) ) { return $settings; @@ -245,18 +180,9 @@ public function woocommerce_globalpayments_gpapi_settings( $settings ) { }); $settings['enabled'] = 'no'; } - if ( wc_string_to_bool( $settings['is_production'] ) ) { - if ( empty( $settings['app_id'] ) || empty( $settings['app_key'] ) ) { - add_action( 'admin_notices', function() { - echo '
' . __( 'Please provide Live Credentials. Gateway not enabled.' ) . '
' . __( 'Please provide Sandbox Credentials. Gateway not enabled.' ) . '
' . __( 'Please provide App Credentials. Gateway not enabled.' ) . '