From d7ee1650ee9709abc8ec6f0c67f48f522dc5098a Mon Sep 17 00:00:00 2001 From: Aashish Gurung <101558497+aashishgurung@users.noreply.github.com> Date: Tue, 7 May 2024 09:05:26 +0700 Subject: [PATCH 1/2] Remove OCBC PAO. (#449) Co-authored-by: Aashish --- includes/class-omise-payment-factory.php | 1 - .../class-omise-rest-webhooks-controller.php | 27 ------- .../class-omise-payment-mobilebanking.php | 3 +- .../gateway/class-omise-payment-ocbc-pao.php | 81 ------------------- .../omise-plugin/helpers/request.php | 2 +- omise-woocommerce.php | 1 - .../class-omise-payment-ocbc-pao-test.php | 34 -------- 7 files changed, 2 insertions(+), 147 deletions(-) delete mode 100644 includes/gateway/class-omise-payment-ocbc-pao.php delete mode 100644 tests/unit/includes/gateway/class-omise-payment-ocbc-pao-test.php diff --git a/includes/class-omise-payment-factory.php b/includes/class-omise-payment-factory.php index d4ec0930..60d4d0ba 100644 --- a/includes/class-omise-payment-factory.php +++ b/includes/class-omise-payment-factory.php @@ -31,7 +31,6 @@ class Omise_Payment_Factory { 'Omise_Payment_Kakaopay', 'Omise_Payment_TouchNGo', 'Omise_Payment_RabbitLinePay', - 'Omise_Payment_OCBC_PAO', 'Omise_Payment_OCBC_Digital', 'Omise_Payment_GrabPay', 'Omise_Payment_GooglePay', diff --git a/includes/class-omise-rest-webhooks-controller.php b/includes/class-omise-rest-webhooks-controller.php index 928d4b4e..ac215b20 100644 --- a/includes/class-omise-rest-webhooks-controller.php +++ b/includes/class-omise-rest-webhooks-controller.php @@ -23,11 +23,6 @@ class Omise_Rest_Webhooks_Controller { */ const PAYNOW_CHARGE_STATUS_ENDPOINT = 'paynow-payment-status'; - /** - * @var string - */ - const OCBC_PAO_CALLBACK_ENDPOINT = 'ocbc-pao-callback'; - /** * @var string */ @@ -56,16 +51,6 @@ public function register_routes() { 'permission_callback' => self::RETURN_TRUE ) ); - - register_rest_route( - self::ENDPOINT_NAMESPACE, - '/' . self::OCBC_PAO_CALLBACK_ENDPOINT . '/(?P\d+)', - array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'callback_ocbc_pao_callback' ), - 'permission_callback' => self::RETURN_TRUE - ) - ); } /** @@ -106,16 +91,4 @@ public function callback_paynow_payment_status($request) { } return rest_ensure_response( $data ); } - - /** - * @param WP_REST_Request $request - * - * @return WP_Error|WP_REST_Response - */ - public function callback_ocbc_pao_callback($request) { - $order_id = $request->get_param('order_id'); - $url = add_query_arg('order_id', $order_id, home_url('wc-api/omise_ocbc_pao_callback')); - wp_redirect($url); - exit(); - } } diff --git a/includes/gateway/class-omise-payment-mobilebanking.php b/includes/gateway/class-omise-payment-mobilebanking.php index e35bfcaf..decd34bf 100644 --- a/includes/gateway/class-omise-payment-mobilebanking.php +++ b/includes/gateway/class-omise-payment-mobilebanking.php @@ -98,7 +98,6 @@ public function charge($order_id, $order) * @return array|false */ public function is_capability_support( $available_payment_methods ) { - //filter ocbc pao out bc is no longer mobile banking payments - return preg_grep('/^mobile_banking_(?!ocbc_pao)/', $available_payment_methods); + return preg_grep('/^mobile_banking_/', $available_payment_methods); } } diff --git a/includes/gateway/class-omise-payment-ocbc-pao.php b/includes/gateway/class-omise-payment-ocbc-pao.php deleted file mode 100644 index 2de6010e..00000000 --- a/includes/gateway/class-omise-payment-ocbc-pao.php +++ /dev/null @@ -1,81 +0,0 @@ -id = 'omise_ocbc_pao'; - $this->has_fields = false; - $this->method_title = __( 'Opn Payments OCBC Pay Anyone', 'omise' ); - $this->method_description = __( 'Accept payment through OCBC Pay Anyone via Opn Payments payment gateway.', 'omise' ); - $this->supports = array( 'products', 'refunds' ); - - $this->init_form_fields(); - $this->init_settings(); - - $this->title = $this->get_option( 'title' ); - $this->description = $this->get_option( 'description' ); - $this->restricted_countries = array( 'SG' ); - $this->source_type = 'mobile_banking_ocbc_pao'; - - add_action( 'woocommerce_api_' . $this->id . '_callback', 'Omise_Callback::execute' ); - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); - add_action( 'woocommerce_order_action_' . $this->id . '_sync_payment', array( $this, 'sync_payment' ) ); - } - - /** - * @see WC_Settings_API::init_form_fields() - * @see woocommerce/includes/abstracts/abstract-wc-settings-api.php - */ - public function init_form_fields() { - $this->form_fields = array( - 'enabled' => array( - 'title' => __( 'Enable/Disable', 'omise' ), - 'type' => 'checkbox', - 'label' => __( 'Enable Opn Payments OCBC Pay Anyone Payment', 'omise' ), - 'default' => 'no' - ), - - 'title' => array( - 'title' => __( 'Title', 'omise' ), - 'type' => 'text', - 'description' => __( 'This controls the title the user sees during checkout.', 'omise' ), - 'default' => __( 'OCBC Pay Anyone', 'omise' ), - ), - - 'description' => array( - 'title' => __( 'Description', 'omise' ), - 'type' => 'textarea', - 'description' => __( 'This controls the description the user sees during checkout.', 'omise' ) - ), - ); - } - - /** - * @inheritdoc - */ - public function charge($order_id, $order) - { - $requestData = $this->build_charge_request( - $order_id, $order, $this->source_type, $this->id . '_callback' - ); - $requestData['source'] = array_merge($requestData['source'], [ - 'platform_type' => Omise_Util::get_platform_type(wc_get_user_agent()) - ]); - return OmiseCharge::create($requestData); - } - - /** - * Get icons - * - * @see WC_Payment_Gateway::get_icon() - */ - public function get_icon() { - $icon = Omise_Image::get_image([ - 'file' => 'ocbc-pao.png', - 'alternate_text' => 'OCBC Pay Anyone', - ]); - return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id ); - } -} diff --git a/includes/libraries/omise-plugin/helpers/request.php b/includes/libraries/omise-plugin/helpers/request.php index 976d1851..5344fdc1 100644 --- a/includes/libraries/omise-plugin/helpers/request.php +++ b/includes/libraries/omise-plugin/helpers/request.php @@ -24,7 +24,7 @@ public static function validate_request($order_token = null) { $token = isset($_GET['token']) ? sanitize_text_field($_GET['token']) : null; - // For all payment except offline and OCBC PAO. + // For all payment except offline if ($token) { return $token === $order_token; } diff --git a/omise-woocommerce.php b/omise-woocommerce.php index 28e5ffd7..42479767 100644 --- a/omise-woocommerce.php +++ b/omise-woocommerce.php @@ -213,7 +213,6 @@ private function include_classes() require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/class-omise-payment-rabbit-linepay.php'; require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/class-omise-payment-googlepay.php'; require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/class-omise-payment-grabpay.php'; - require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/class-omise-payment-ocbc-pao.php'; require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/class-omise-payment-ocbc-digital.php'; require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/class-omise-payment-boost.php'; require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/class-omise-payment-duitnow-obw.php'; diff --git a/tests/unit/includes/gateway/class-omise-payment-ocbc-pao-test.php b/tests/unit/includes/gateway/class-omise-payment-ocbc-pao-test.php deleted file mode 100644 index 5d1f6de2..00000000 --- a/tests/unit/includes/gateway/class-omise-payment-ocbc-pao-test.php +++ /dev/null @@ -1,34 +0,0 @@ -sourceType = 'mobile_banking_ocbc'; - parent::setUp(); - require_once __DIR__ . '/../../../../includes/gateway/class-omise-payment-ocbc-pao.php'; - $this->obj = new Omise_Payment_OCBC_PAO(); - } - - public function tearDown(): void - { - parent::tearDown(); - // destroy object and clear memory - unset($this->obj); - } - - /** - * @test - */ - public function testCharge() - { - Brain\Monkey\Functions\expect('wc_get_user_agent') - ->with('123') - ->andReturn('Chrome Web'); - $this->getChargeTest($this->obj); - } -} From c38c758f1a7e3dcb13e849ff2d12f1b0e30ee79b Mon Sep 17 00:00:00 2001 From: Aashish Date: Wed, 8 May 2024 11:39:56 +0700 Subject: [PATCH 2/2] Updated metadata for v5.8.3 release. --- CHANGELOG.md | 3 +++ omise-woocommerce.php | 4 ++-- readme.txt | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3edd0ab7..faa93a44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## [v5.8.3 _(May 8, 2024)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.8.3) +- Remove OCBC PAO (PR: [#449](https://github.com/omise/omise-woocommerce/pull/449)) + ## [v5.8.2 _(Apr 9, 2024)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.8.2) - Resolve PHP warnings. (PR [#443](https://github.com/omise/omise-woocommerce/pull/443)) - Remove white box appearing under WeChat Pay. (PR [#444](https://github.com/omise/omise-woocommerce/pull/444)) diff --git a/omise-woocommerce.php b/omise-woocommerce.php index 42479767..e786b422 100644 --- a/omise-woocommerce.php +++ b/omise-woocommerce.php @@ -4,7 +4,7 @@ * Plugin Name: Opn Payments * Plugin URI: https://www.omise.co/woocommerce * Description: Opn Payments is a WordPress plugin designed specifically for WooCommerce. The plugin adds support for Opn Payments Payment Gateway's payment methods to WooCommerce. - * Version: 5.8.2 + * Version: 5.8.3 * Author: Opn Payments and contributors * Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors * Text Domain: omise @@ -22,7 +22,7 @@ class Omise * * @var string */ - public $version = '5.8.2'; + public $version = '5.8.3'; /** * The Omise Instance. diff --git a/readme.txt b/readme.txt index 6236fd81..267c5646 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: Opn Payments Tags: opn payments, payment, payment gateway, woocommerce plugin, omise, opn, installment, internet banking, alipay, paynow, truemoney, woocommerce payment Requires at least: 4.3.1 Tested up to: 6.4.2 -Stable tag: 5.8.2 +Stable tag: 5.8.3 License: MIT License URI: https://opensource.org/licenses/MIT @@ -34,6 +34,10 @@ From there: == Changelog == += 5.8.3 = + +- Remove OCBC PAO (PR: [#449](https://github.com/omise/omise-woocommerce/pull/449)) + = 5.8.2 = - Resolve PHP warnings. (PR [#443](https://github.com/omise/omise-woocommerce/pull/443))