From 156c30f809990e75d5785b4605fb6b929108fa51 Mon Sep 17 00:00:00 2001 From: Aashish Date: Mon, 29 Apr 2024 12:48:13 +0700 Subject: [PATCH] Remove OCBC PAO. --- 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); - } -}