From 7463098824ec909cad329da111c0159c7ee10259 Mon Sep 17 00:00:00 2001 From: Aashish Date: Wed, 1 Nov 2023 15:00:45 +0700 Subject: [PATCH 01/19] Added fields to enter custom font name and URL --- assets/javascripts/card-form-customization.js | 26 +++++++++++++++++++ assets/javascripts/omise-embedded-card.js | 9 ++++++- ...ass-omise-page-card-form-customization.php | 5 ++++ .../omise-page-card-form-customization.php | 19 +++++++++++++- 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/card-form-customization.js b/assets/javascripts/card-form-customization.js index b87123e4..6e293822 100644 --- a/assets/javascripts/card-form-customization.js +++ b/assets/javascripts/card-form-customization.js @@ -58,6 +58,31 @@ function getDesignFormValues() { return formValues; } +function handleFontChange() { + const fontName = document.getElementById('custom_sf_font_name'); + + if (fontName.value == 'Others') { + document.getElementById('custom_sf_custom_font_name').style.display = null + document.getElementById('custom_sf_custom_font_url').style.display = null + } + + fontName.addEventListener('change', (event) => { + console.log(event.target.value) + if (event.target.value == 'Others') { + document.getElementById('custom_sf_custom_font_name').style.display = null + document.getElementById('custom_sf_custom_font_url').style.display = null + } else { + const customFontName = document.getElementById('custom_sf_custom_font_name'); + customFontName.value = ""; + customFontName.style.display = "none"; + + const customFontUrl = document.getElementById('custom_sf_custom_font_url'); + customFontUrl.value = ""; + customFontUrl.style.display = "none" + } + }); +} + function initOmiseCardForm() { const customCardFormTheme = CARD_FORM_THEME ?? 'light'; document.querySelector('.omise-modal .content').style.background = @@ -91,3 +116,4 @@ document.getElementById('omise-modal').addEventListener('click', (event) => { setDesignFormValues(); handleColorInputChanges(); +handleFontChange(); \ No newline at end of file diff --git a/assets/javascripts/omise-embedded-card.js b/assets/javascripts/omise-embedded-card.js index af0c676c..08b0370a 100644 --- a/assets/javascripts/omise-embedded-card.js +++ b/assets/javascripts/omise-embedded-card.js @@ -25,6 +25,12 @@ function showOmiseEmbeddedCardForm({ } element.style.height = iframeElementHeight + 'px' + const fontName = font.name + + if (font.custom_name.trim() != "") { + fontName = font.custom_name.trim() + } + OmiseCard.configure({ publicKey: publicKey, element, @@ -34,7 +40,8 @@ function showOmiseEmbeddedCardForm({ customCardFormHideRememberCard: hideRememberCard ?? false, customCardFormBrandIcons: brandIcons ?? null, style: { - fontFamily: font.name, + fontFamily: fontName, + fontUrl: font.custom_url, fontSize: font.size, input: { height: input.height, diff --git a/includes/admin/class-omise-page-card-form-customization.php b/includes/admin/class-omise-page-card-form-customization.php index ce325705..db5e6f11 100644 --- a/includes/admin/class-omise-page-card-form-customization.php +++ b/includes/admin/class-omise-page-card-form-customization.php @@ -27,6 +27,8 @@ private function get_light_theme() 'font' => [ 'name' => 'Poppins', 'size' => 16, + 'custom_name' => '', + 'custom_url' => '' ], 'input' => [ 'height' => '44px', @@ -51,6 +53,8 @@ private function get_dark_theme() 'font' => [ 'name' => 'Poppins', 'size' => 16, + 'custom_name' => '', + 'custom_url' => '' ], 'input' => [ 'height' => '44px', @@ -110,6 +114,7 @@ protected function save($data) $options[$componentKey][$key] = sanitize_text_field($data[$componentKey][$key]); } } + error_log(print_r($options, true)); update_option(self::PAGE_NAME, $options); $this->add_message('message', "Update has been saved!"); } diff --git a/includes/admin/views/omise-page-card-form-customization.php b/includes/admin/views/omise-page-card-form-customization.php index d12e44d6..2db05135 100644 --- a/includes/admin/views/omise-page-card-form-customization.php +++ b/includes/admin/views/omise-page-card-form-customization.php @@ -24,14 +24,31 @@ Font Name - +
Match font used in form with your selected font
+ + + + +
Match font used in form with your selected font
+ + + + + + + +
Enter if you have a custom font URL. Leave it empty if you
are using Google fonts
+ + + Font Size From a6cd09615c4a3698d0ad7bdc6ce7d059ee9cc8de Mon Sep 17 00:00:00 2001 From: Aashish Date: Thu, 9 Nov 2023 14:19:41 +0700 Subject: [PATCH 02/19] Removed code related to custom URL --- assets/javascripts/card-form-customization.js | 7 ------- assets/javascripts/omise-embedded-card.js | 5 ++--- .../admin/class-omise-page-card-form-customization.php | 6 ++---- .../admin/views/omise-page-card-form-customization.php | 8 -------- 4 files changed, 4 insertions(+), 22 deletions(-) diff --git a/assets/javascripts/card-form-customization.js b/assets/javascripts/card-form-customization.js index 6e293822..a0c6ec2f 100644 --- a/assets/javascripts/card-form-customization.js +++ b/assets/javascripts/card-form-customization.js @@ -63,22 +63,15 @@ function handleFontChange() { if (fontName.value == 'Others') { document.getElementById('custom_sf_custom_font_name').style.display = null - document.getElementById('custom_sf_custom_font_url').style.display = null } fontName.addEventListener('change', (event) => { - console.log(event.target.value) if (event.target.value == 'Others') { document.getElementById('custom_sf_custom_font_name').style.display = null - document.getElementById('custom_sf_custom_font_url').style.display = null } else { const customFontName = document.getElementById('custom_sf_custom_font_name'); customFontName.value = ""; customFontName.style.display = "none"; - - const customFontUrl = document.getElementById('custom_sf_custom_font_url'); - customFontUrl.value = ""; - customFontUrl.style.display = "none" } }); } diff --git a/assets/javascripts/omise-embedded-card.js b/assets/javascripts/omise-embedded-card.js index 08b0370a..9d010110 100644 --- a/assets/javascripts/omise-embedded-card.js +++ b/assets/javascripts/omise-embedded-card.js @@ -25,9 +25,9 @@ function showOmiseEmbeddedCardForm({ } element.style.height = iframeElementHeight + 'px' - const fontName = font.name + let fontName = font.name - if (font.custom_name.trim() != "") { + if (font.name.trim() === "Others" && font.custom_name.trim() != "") { fontName = font.custom_name.trim() } @@ -41,7 +41,6 @@ function showOmiseEmbeddedCardForm({ customCardFormBrandIcons: brandIcons ?? null, style: { fontFamily: fontName, - fontUrl: font.custom_url, fontSize: font.size, input: { height: input.height, diff --git a/includes/admin/class-omise-page-card-form-customization.php b/includes/admin/class-omise-page-card-form-customization.php index db5e6f11..d76785d0 100644 --- a/includes/admin/class-omise-page-card-form-customization.php +++ b/includes/admin/class-omise-page-card-form-customization.php @@ -27,8 +27,7 @@ private function get_light_theme() 'font' => [ 'name' => 'Poppins', 'size' => 16, - 'custom_name' => '', - 'custom_url' => '' + 'custom_name' => '' ], 'input' => [ 'height' => '44px', @@ -53,8 +52,7 @@ private function get_dark_theme() 'font' => [ 'name' => 'Poppins', 'size' => 16, - 'custom_name' => '', - 'custom_url' => '' + 'custom_name' => '' ], 'input' => [ 'height' => '44px', diff --git a/includes/admin/views/omise-page-card-form-customization.php b/includes/admin/views/omise-page-card-form-customization.php index 2db05135..665a06e0 100644 --- a/includes/admin/views/omise-page-card-form-customization.php +++ b/includes/admin/views/omise-page-card-form-customization.php @@ -41,14 +41,6 @@ - - - - -
Enter if you have a custom font URL. Leave it empty if you
are using Google fonts
- - - Font Size From ecb4279f3e29e9c1bc25a7f31a37f99566ffad15 Mon Sep 17 00:00:00 2001 From: Aashish Date: Thu, 9 Nov 2023 18:06:13 +0700 Subject: [PATCH 03/19] Removed error_log --- assets/javascripts/card-form-customization.js | 2 +- includes/admin/class-omise-page-card-form-customization.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/assets/javascripts/card-form-customization.js b/assets/javascripts/card-form-customization.js index a0c6ec2f..c2c9ced9 100644 --- a/assets/javascripts/card-form-customization.js +++ b/assets/javascripts/card-form-customization.js @@ -109,4 +109,4 @@ document.getElementById('omise-modal').addEventListener('click', (event) => { setDesignFormValues(); handleColorInputChanges(); -handleFontChange(); \ No newline at end of file +handleFontChange(); diff --git a/includes/admin/class-omise-page-card-form-customization.php b/includes/admin/class-omise-page-card-form-customization.php index d76785d0..7b6ba36e 100644 --- a/includes/admin/class-omise-page-card-form-customization.php +++ b/includes/admin/class-omise-page-card-form-customization.php @@ -112,7 +112,6 @@ protected function save($data) $options[$componentKey][$key] = sanitize_text_field($data[$componentKey][$key]); } } - error_log(print_r($options, true)); update_option(self::PAGE_NAME, $options); $this->add_message('message', "Update has been saved!"); } From 34b0d3df3bca68bacf6ddad73a1494ccb8ba77db Mon Sep 17 00:00:00 2001 From: Aashish Date: Fri, 10 Nov 2023 11:11:57 +0700 Subject: [PATCH 04/19] Updated message under custom font name field. --- includes/admin/views/omise-page-card-form-customization.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/views/omise-page-card-form-customization.php b/includes/admin/views/omise-page-card-form-customization.php index 665a06e0..86c63920 100644 --- a/includes/admin/views/omise-page-card-form-customization.php +++ b/includes/admin/views/omise-page-card-form-customization.php @@ -37,7 +37,7 @@ -
Match font used in form with your selected font
+
Enter a Google font name that matches your theme
From c0b3bd5152eebb85a0639e40038305cdd44f9e83 Mon Sep 17 00:00:00 2001 From: Aashish Date: Fri, 10 Nov 2023 15:51:15 +0700 Subject: [PATCH 05/19] Update custom font name message under input field. --- includes/admin/views/omise-page-card-form-customization.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/views/omise-page-card-form-customization.php b/includes/admin/views/omise-page-card-form-customization.php index 86c63920..cb635e69 100644 --- a/includes/admin/views/omise-page-card-form-customization.php +++ b/includes/admin/views/omise-page-card-form-customization.php @@ -37,7 +37,7 @@ -
Enter a Google font name that matches your theme
+
Specify the Google font to use
From 5c416fc8134e1a751546439b4d8d1cb50a473283 Mon Sep 17 00:00:00 2001 From: Aashish Date: Mon, 13 Nov 2023 09:04:58 +0700 Subject: [PATCH 06/19] Added unit tests. --- ...mise-page-card-form-customization-test.php | 113 ++++++++++++++++++ .../abstract-omise-payment-base-card-test.php | 9 ++ .../abstract-omise-payment-offline-test.php | 9 ++ .../includes/gateway/bootstrap-test-setup.php | 16 +-- .../class-omise-payment-atome-test.php | 9 ++ ...ass-omise-payment-internetbanking-test.php | 1 - .../class-omise-payment-konbini-test.php | 9 ++ .../class-omise-payment-promptpay-test.php | 9 ++ .../traits/charge-request-builder-test.php | 1 + 9 files changed, 167 insertions(+), 9 deletions(-) create mode 100644 tests/unit/includes/admin/class-omise-page-card-form-customization-test.php diff --git a/tests/unit/includes/admin/class-omise-page-card-form-customization-test.php b/tests/unit/includes/admin/class-omise-page-card-form-customization-test.php new file mode 100644 index 00000000..34439778 --- /dev/null +++ b/tests/unit/includes/admin/class-omise-page-card-form-customization-test.php @@ -0,0 +1,113 @@ + [ + 'name' => 'Poppins', + 'size' => 16, + 'custom_name' => '' + ], + 'input' => [ + 'height' => '44px', + 'border_radius' => '4px', + 'border_color' => '#ced3de', + 'active_border_color' => '#1451cc', + 'background_color' => '#ffffff', + 'label_color' => '#212121', + 'text_color' => '#212121', + 'placeholder_color' => '#98a1b2', + ], + 'checkbox' => [ + 'text_color' => '#1c2433', + 'theme_color' => '#1451cc', + ] + ]; + + $obj = Omise_Page_Card_From_Customization::get_instance(); + + // calling private method + $themeValues = $this->invokeMethod($obj, 'get_light_theme', []); + + $this->assertEqualsCanonicalizing($expected, $themeValues); + } + + /** + * @test + */ + public function testGetDarkTheme() + { + $expected = [ + 'font' => [ + 'name' => 'Poppins', + 'size' => 16, + 'custom_name' => '' + ], + 'input' => [ + 'height' => '44px', + 'border_radius' => '4px', + 'border_color' => '#475266', + 'active_border_color' => '#475266', + 'background_color' => '#131926', + 'label_color' => '#E6EAF2', + 'text_color' => '#ffffff', + 'placeholder_color' => '#DBDBDB', + ], + 'checkbox' => [ + 'text_color' => '#E6EAF2', + 'theme_color' => '#1451CC', + ] + ]; + + $obj = Omise_Page_Card_From_Customization::get_instance(); + + // calling private method + $themeValues = $this->invokeMethod($obj, 'get_dark_theme', []); + + $this->assertEqualsCanonicalizing($expected, $themeValues); + } + + /** + * Call protected/private method of a class. + * + * @param object $object Instantiated object that we will run method on. + * @param string $methodName Method name to call + * @param array $parameters Array of parameters to pass into method. + * + * @return mixed Method return. + */ + public function invokeMethod($object, $methodName, array $parameters = []) + { + $reflection = new \ReflectionClass(get_class($object)); + $method = $reflection->getMethod($methodName); + $method->setAccessible(true); + + return $method->invokeArgs($object, $parameters); + } +} \ No newline at end of file diff --git a/tests/unit/includes/gateway/abstract-omise-payment-base-card-test.php b/tests/unit/includes/gateway/abstract-omise-payment-base-card-test.php index 8f4fb28b..e60a487b 100644 --- a/tests/unit/includes/gateway/abstract-omise-payment-base-card-test.php +++ b/tests/unit/includes/gateway/abstract-omise-payment-base-card-test.php @@ -42,6 +42,15 @@ public function returnThis() }; } + + /** + * close mockery after tests are done + */ + public function tearDown(): void + { + Mockery::close(); + } + public function getOrderMock($expectedAmount, $expectedCurrency) { // Create a mock of the $order object diff --git a/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php b/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php index dcb1ed52..9d52eca3 100644 --- a/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php +++ b/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php @@ -10,4 +10,13 @@ public function setUp(): void Mockery::mock('alias:Omise_Payment')->makePartial(); require_once __DIR__ . '/../../../../includes/gateway/abstract-omise-payment-offline.php'; } + + + /** + * close mockery after tests are done + */ + public function tearDown(): void + { + Mockery::close(); + } } diff --git a/tests/unit/includes/gateway/bootstrap-test-setup.php b/tests/unit/includes/gateway/bootstrap-test-setup.php index 8ee06aa4..a1da9206 100644 --- a/tests/unit/includes/gateway/bootstrap-test-setup.php +++ b/tests/unit/includes/gateway/bootstrap-test-setup.php @@ -18,6 +18,14 @@ function add_action() {} } } + /** + * close mockery after tests are done + */ + public function tearDown(): void + { + Mockery::close(); + } + public function getOrderMock($expectedAmount, $expectedCurrency) { // Create a mock of the $order object @@ -52,14 +60,6 @@ public function getOrderMock($expectedAmount, $expectedCurrency) return $orderMock; } - /** - * close mockery after tests are done - */ - public function tearDown(): void - { - Mockery::close(); - } - /** * @runInSeparateProcess */ diff --git a/tests/unit/includes/gateway/class-omise-payment-atome-test.php b/tests/unit/includes/gateway/class-omise-payment-atome-test.php index 497313a1..952bf29d 100644 --- a/tests/unit/includes/gateway/class-omise-payment-atome-test.php +++ b/tests/unit/includes/gateway/class-omise-payment-atome-test.php @@ -24,6 +24,15 @@ function plugins_url() {} } } + + /** + * close mockery after tests are done + */ + public function tearDown(): void + { + Mockery::close(); + } + public function testGetChargeRequest() { $expectedAmount = 999999; diff --git a/tests/unit/includes/gateway/class-omise-payment-internetbanking-test.php b/tests/unit/includes/gateway/class-omise-payment-internetbanking-test.php index 56e54e9b..37e44b68 100644 --- a/tests/unit/includes/gateway/class-omise-payment-internetbanking-test.php +++ b/tests/unit/includes/gateway/class-omise-payment-internetbanking-test.php @@ -8,7 +8,6 @@ public function setUp(): void { $this->sourceType = 'fpx'; parent::setUp(); - // require_once __DIR__ . '/../../../../includes/backends/class-omise-backend-fpx.php'; require_once __DIR__ . '/../../../../includes/gateway/class-omise-payment-internetbanking.php'; } diff --git a/tests/unit/includes/gateway/class-omise-payment-konbini-test.php b/tests/unit/includes/gateway/class-omise-payment-konbini-test.php index 1c11d67f..02558568 100644 --- a/tests/unit/includes/gateway/class-omise-payment-konbini-test.php +++ b/tests/unit/includes/gateway/class-omise-payment-konbini-test.php @@ -28,6 +28,15 @@ function sanitize_text_field() { } } + + /** + * close mockery after tests are done + */ + public function tearDown(): void + { + Mockery::close(); + } + public function testGetChargeRequest() { $obj = new Omise_Payment_Konbini(); diff --git a/tests/unit/includes/gateway/class-omise-payment-promptpay-test.php b/tests/unit/includes/gateway/class-omise-payment-promptpay-test.php index bda6a6a2..7991fb47 100644 --- a/tests/unit/includes/gateway/class-omise-payment-promptpay-test.php +++ b/tests/unit/includes/gateway/class-omise-payment-promptpay-test.php @@ -29,6 +29,15 @@ function admin_url() {} require_once __DIR__ . '/../../../../includes/gateway/class-omise-payment-promptpay.php'; } + + /** + * close mockery after tests are done + */ + public function tearDown(): void + { + Mockery::close(); + } + /** * @test */ diff --git a/tests/unit/includes/gateway/traits/charge-request-builder-test.php b/tests/unit/includes/gateway/traits/charge-request-builder-test.php index 3ffe5cc4..e0bbdc0c 100644 --- a/tests/unit/includes/gateway/traits/charge-request-builder-test.php +++ b/tests/unit/includes/gateway/traits/charge-request-builder-test.php @@ -15,6 +15,7 @@ function get_rest_url() { } } + /** * close mockery after tests are done */ From 359a46c4197433cf05d267bf29d21bce4c8f0619 Mon Sep 17 00:00:00 2001 From: Aashish Date: Mon, 13 Nov 2023 09:07:25 +0700 Subject: [PATCH 07/19] Removed extra empty line. --- .../admin/class-omise-page-card-form-customization-test.php | 2 +- .../includes/gateway/abstract-omise-payment-base-card-test.php | 1 - .../includes/gateway/abstract-omise-payment-offline-test.php | 1 - tests/unit/includes/gateway/class-omise-payment-atome-test.php | 1 - .../unit/includes/gateway/class-omise-payment-konbini-test.php | 1 - .../includes/gateway/class-omise-payment-promptpay-test.php | 1 - .../includes/gateway/traits/charge-request-builder-test.php | 1 - 7 files changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/unit/includes/admin/class-omise-page-card-form-customization-test.php b/tests/unit/includes/admin/class-omise-page-card-form-customization-test.php index 34439778..898b22db 100644 --- a/tests/unit/includes/admin/class-omise-page-card-form-customization-test.php +++ b/tests/unit/includes/admin/class-omise-page-card-form-customization-test.php @@ -110,4 +110,4 @@ public function invokeMethod($object, $methodName, array $parameters = []) return $method->invokeArgs($object, $parameters); } -} \ No newline at end of file +} diff --git a/tests/unit/includes/gateway/abstract-omise-payment-base-card-test.php b/tests/unit/includes/gateway/abstract-omise-payment-base-card-test.php index e60a487b..cff4a717 100644 --- a/tests/unit/includes/gateway/abstract-omise-payment-base-card-test.php +++ b/tests/unit/includes/gateway/abstract-omise-payment-base-card-test.php @@ -42,7 +42,6 @@ public function returnThis() }; } - /** * close mockery after tests are done */ diff --git a/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php b/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php index 9d52eca3..67bf7138 100644 --- a/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php +++ b/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php @@ -11,7 +11,6 @@ public function setUp(): void require_once __DIR__ . '/../../../../includes/gateway/abstract-omise-payment-offline.php'; } - /** * close mockery after tests are done */ diff --git a/tests/unit/includes/gateway/class-omise-payment-atome-test.php b/tests/unit/includes/gateway/class-omise-payment-atome-test.php index 952bf29d..9b276a92 100644 --- a/tests/unit/includes/gateway/class-omise-payment-atome-test.php +++ b/tests/unit/includes/gateway/class-omise-payment-atome-test.php @@ -24,7 +24,6 @@ function plugins_url() {} } } - /** * close mockery after tests are done */ diff --git a/tests/unit/includes/gateway/class-omise-payment-konbini-test.php b/tests/unit/includes/gateway/class-omise-payment-konbini-test.php index 02558568..02ae8f73 100644 --- a/tests/unit/includes/gateway/class-omise-payment-konbini-test.php +++ b/tests/unit/includes/gateway/class-omise-payment-konbini-test.php @@ -28,7 +28,6 @@ function sanitize_text_field() { } } - /** * close mockery after tests are done */ diff --git a/tests/unit/includes/gateway/class-omise-payment-promptpay-test.php b/tests/unit/includes/gateway/class-omise-payment-promptpay-test.php index 7991fb47..1d5e964d 100644 --- a/tests/unit/includes/gateway/class-omise-payment-promptpay-test.php +++ b/tests/unit/includes/gateway/class-omise-payment-promptpay-test.php @@ -29,7 +29,6 @@ function admin_url() {} require_once __DIR__ . '/../../../../includes/gateway/class-omise-payment-promptpay.php'; } - /** * close mockery after tests are done */ diff --git a/tests/unit/includes/gateway/traits/charge-request-builder-test.php b/tests/unit/includes/gateway/traits/charge-request-builder-test.php index e0bbdc0c..3ffe5cc4 100644 --- a/tests/unit/includes/gateway/traits/charge-request-builder-test.php +++ b/tests/unit/includes/gateway/traits/charge-request-builder-test.php @@ -15,7 +15,6 @@ function get_rest_url() { } } - /** * close mockery after tests are done */ From 38eafbfbcb30125f5845e6038015d2efbab30e3d Mon Sep 17 00:00:00 2001 From: Aashish Date: Mon, 13 Nov 2023 10:37:31 +0700 Subject: [PATCH 08/19] Defined a constant for Other and improve code consistency. --- assets/javascripts/card-form-customization.js | 8 ++++---- assets/javascripts/omise-embedded-card.js | 2 +- .../admin/views/omise-page-card-form-customization.php | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/assets/javascripts/card-form-customization.js b/assets/javascripts/card-form-customization.js index c2c9ced9..dac90147 100644 --- a/assets/javascripts/card-form-customization.js +++ b/assets/javascripts/card-form-customization.js @@ -61,17 +61,17 @@ function getDesignFormValues() { function handleFontChange() { const fontName = document.getElementById('custom_sf_font_name'); - if (fontName.value == 'Others') { + if (fontName.value === OMISE_CUSTOM_FONT_OTHER) { document.getElementById('custom_sf_custom_font_name').style.display = null } fontName.addEventListener('change', (event) => { - if (event.target.value == 'Others') { + if (event.target.value === OMISE_CUSTOM_FONT_OTHER) { document.getElementById('custom_sf_custom_font_name').style.display = null } else { const customFontName = document.getElementById('custom_sf_custom_font_name'); - customFontName.value = ""; - customFontName.style.display = "none"; + customFontName.value = ''; + customFontName.style.display = 'none'; } }); } diff --git a/assets/javascripts/omise-embedded-card.js b/assets/javascripts/omise-embedded-card.js index 9d010110..f2a2cb0b 100644 --- a/assets/javascripts/omise-embedded-card.js +++ b/assets/javascripts/omise-embedded-card.js @@ -27,7 +27,7 @@ function showOmiseEmbeddedCardForm({ let fontName = font.name - if (font.name.trim() === "Others" && font.custom_name.trim() != "") { + if (font.name.trim() === OMISE_CUSTOM_FONT_OTHER && font.custom_name.trim() !== '') { fontName = font.custom_name.trim() } diff --git a/includes/admin/views/omise-page-card-form-customization.php b/includes/admin/views/omise-page-card-form-customization.php index cb635e69..fa9f3a16 100644 --- a/includes/admin/views/omise-page-card-form-customization.php +++ b/includes/admin/views/omise-page-card-form-customization.php @@ -4,6 +4,7 @@ $cardFormTheme = $omiseCardGateway->get_option('card_form_theme'); $cardIcons = $omiseCardGateway->get_card_icons(); $publicKey = Omise()->settings()->public_key(); + $customFontOther = 'Other'; ?> @@ -26,8 +27,8 @@
Match font used in form with your selected font
@@ -198,6 +199,7 @@ window.DEFAULT_FORM_DESIGN = JSON.parse(``); window.CARD_BRAND_ICONS = JSON.parse(``); window.LOCALE = ``; + window.OMISE_CUSTOM_FONT_OTHER = ``; From 3e9f826c9b8c113ed260de3023a9c69f36e70c64 Mon Sep 17 00:00:00 2001 From: Aashish Date: Mon, 13 Nov 2023 10:55:08 +0700 Subject: [PATCH 09/19] Removed the message under font name --- includes/admin/views/omise-page-card-form-customization.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/admin/views/omise-page-card-form-customization.php b/includes/admin/views/omise-page-card-form-customization.php index fa9f3a16..6058907a 100644 --- a/includes/admin/views/omise-page-card-form-customization.php +++ b/includes/admin/views/omise-page-card-form-customization.php @@ -30,7 +30,6 @@ -
Match font used in form with your selected font
From a07434cf8aa4028a568134059c2251698719d331 Mon Sep 17 00:00:00 2001 From: Aashish Date: Mon, 13 Nov 2023 11:02:18 +0700 Subject: [PATCH 10/19] change the message under custom font name. --- includes/admin/views/omise-page-card-form-customization.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/views/omise-page-card-form-customization.php b/includes/admin/views/omise-page-card-form-customization.php index 6058907a..458a1dd7 100644 --- a/includes/admin/views/omise-page-card-form-customization.php +++ b/includes/admin/views/omise-page-card-form-customization.php @@ -37,7 +37,7 @@ -
Specify the Google font to use
+
Specify other font name (note: only Google Fonts supported)
From 804aa542e0bfe2a9faac6fc9c1d6b17e180b6e82 Mon Sep 17 00:00:00 2001 From: Aashish Date: Mon, 13 Nov 2023 13:31:31 +0700 Subject: [PATCH 11/19] Added OMISE_CUSTOM_FONT_OTHER in form.php and my-card.php --- assets/javascripts/omise-embedded-card.js | 4 +++- templates/myaccount/my-card.php | 1 + templates/payment/form.php | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/omise-embedded-card.js b/assets/javascripts/omise-embedded-card.js index f2a2cb0b..973ffabb 100644 --- a/assets/javascripts/omise-embedded-card.js +++ b/assets/javascripts/omise-embedded-card.js @@ -26,8 +26,10 @@ function showOmiseEmbeddedCardForm({ element.style.height = iframeElementHeight + 'px' let fontName = font.name + const isCustomFontSet = font.name.toLowerCase().trim() === OMISE_CUSTOM_FONT_OTHER.toLowerCase() + const isCustomFontEmpty = font.custom_name.trim() === '' - if (font.name.trim() === OMISE_CUSTOM_FONT_OTHER && font.custom_name.trim() !== '') { + if (isCustomFontSet && !isCustomFontEmpty) { fontName = font.custom_name.trim() } diff --git a/templates/myaccount/my-card.php b/templates/myaccount/my-card.php index 34ca2546..40049982 100644 --- a/templates/myaccount/my-card.php +++ b/templates/myaccount/my-card.php @@ -56,5 +56,6 @@ class='button delete_card' window.FORM_DESIGN = JSON.parse(``); window.CARD_BRAND_ICONS = JSON.parse(``); window.LOCALE = ``; + window.OMISE_CUSTOM_FONT_OTHER = 'Other'; diff --git a/templates/payment/form.php b/templates/payment/form.php index 67057da1..4c2e4e95 100644 --- a/templates/payment/form.php +++ b/templates/payment/form.php @@ -60,5 +60,6 @@ window.FORM_DESIGN = JSON.parse(``); window.LOCALE = ``; window.HIDE_REMEMBER_CARD = `` == 'yes' ? true : false; + window.OMISE_CUSTOM_FONT_OTHER = 'Other'; From 043e037436288d081fc8a836aeea3a6dbbe00f99 Mon Sep 17 00:00:00 2001 From: Aashish Date: Mon, 13 Nov 2023 15:21:14 +0700 Subject: [PATCH 12/19] Added requried attribute if other is selected. --- assets/javascripts/card-form-customization.js | 10 +++++++--- .../admin/class-omise-page-card-form-customization.php | 1 + includes/admin/views/omise-page-settings.php | 2 +- includes/gateway/class-omise-payment-creditcard.php | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/assets/javascripts/card-form-customization.js b/assets/javascripts/card-form-customization.js index dac90147..8b16c8d1 100644 --- a/assets/javascripts/card-form-customization.js +++ b/assets/javascripts/card-form-customization.js @@ -66,12 +66,16 @@ function handleFontChange() { } fontName.addEventListener('change', (event) => { + const customFontName = document.getElementById('custom_sf_custom_font_name'); + const inputCustomFont = customFontName.querySelector('input') + if (event.target.value === OMISE_CUSTOM_FONT_OTHER) { - document.getElementById('custom_sf_custom_font_name').style.display = null + customFontName.style.display = null; + inputCustomFont.required = true; } else { - const customFontName = document.getElementById('custom_sf_custom_font_name'); - customFontName.value = ''; customFontName.style.display = 'none'; + inputCustomFont.value = ''; + inputCustomFont.required = false; } }); } diff --git a/includes/admin/class-omise-page-card-form-customization.php b/includes/admin/class-omise-page-card-form-customization.php index 7b6ba36e..8a446482 100644 --- a/includes/admin/class-omise-page-card-form-customization.php +++ b/includes/admin/class-omise-page-card-form-customization.php @@ -112,6 +112,7 @@ protected function save($data) $options[$componentKey][$key] = sanitize_text_field($data[$componentKey][$key]); } } + update_option(self::PAGE_NAME, $options); $this->add_message('message', "Update has been saved!"); } diff --git a/includes/admin/views/omise-page-settings.php b/includes/admin/views/omise-page-settings.php index b0975c60..285ea3c1 100644 --- a/includes/admin/views/omise-page-settings.php +++ b/includes/admin/views/omise-page-settings.php @@ -139,7 +139,7 @@ Opn Payments dashboard (HTTPS only).', 'omise' ), + __( 'Unless dynamic webhooks are enabled, you must add the URL above as a new endpoint on your Opn Payments dashboard (HTTPS only).', 'omise' ), [ 'a' => ['href' => []], ], diff --git a/includes/gateway/class-omise-payment-creditcard.php b/includes/gateway/class-omise-payment-creditcard.php index bf78ccbb..b1af2fa4 100644 --- a/includes/gateway/class-omise-payment-creditcard.php +++ b/includes/gateway/class-omise-payment-creditcard.php @@ -148,7 +148,7 @@ function init_form_fields() { 'css' => Omise_Card_Image::get_css(), 'default' => Omise_Card_Image::get_amex_default_display(), 'description' => wp_kses( - __( 'This only controls the icons displayed on the checkout page.
It is not related to card processing on Omise payment gateway.', 'omise' ), + __( 'This only controls the icons displayed on the checkout page.
It is not related to card processing on OPN payment gateway.', 'omise' ), array( 'br' => array() ) ) ) From e18187491d42a5fb5b31e54e78edd4b5ed6ab7b1 Mon Sep 17 00:00:00 2001 From: Aashish Date: Mon, 13 Nov 2023 15:35:29 +0700 Subject: [PATCH 13/19] Removed circular --- includes/admin/views/omise-page-card-form-customization.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/admin/views/omise-page-card-form-customization.php b/includes/admin/views/omise-page-card-form-customization.php index 458a1dd7..4c95b414 100644 --- a/includes/admin/views/omise-page-card-form-customization.php +++ b/includes/admin/views/omise-page-card-form-customization.php @@ -27,7 +27,6 @@ From 871c976ea5a9a2ddfb3011232224039342e88fff Mon Sep 17 00:00:00 2001 From: Aashish Date: Mon, 13 Nov 2023 16:02:39 +0700 Subject: [PATCH 14/19] Removed unnecessary Mockery:close from child classes. --- .../gateway/abstract-omise-payment-offline-test.php | 9 --------- .../includes/gateway/class-omise-offsite-test.php | 9 --------- .../gateway/class-omise-payment-atome-test.php | 8 -------- .../gateway/class-omise-payment-konbini-test.php | 9 +-------- .../gateway/class-omise-payment-promptpay-test.php | 11 +---------- 5 files changed, 2 insertions(+), 44 deletions(-) diff --git a/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php b/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php index 67bf7138..c2a7355e 100644 --- a/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php +++ b/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php @@ -8,14 +8,5 @@ public function setUp(): void { parent::setUp(); Mockery::mock('alias:Omise_Payment')->makePartial(); - require_once __DIR__ . '/../../../../includes/gateway/abstract-omise-payment-offline.php'; - } - - /** - * close mockery after tests are done - */ - public function tearDown(): void - { - Mockery::close(); } } diff --git a/tests/unit/includes/gateway/class-omise-offsite-test.php b/tests/unit/includes/gateway/class-omise-offsite-test.php index 79f06b59..f6918934 100644 --- a/tests/unit/includes/gateway/class-omise-offsite-test.php +++ b/tests/unit/includes/gateway/class-omise-offsite-test.php @@ -24,15 +24,6 @@ public function setUp(): void unset($offsite); } - /** - * close mockery after tests are done - */ - public function tearDown(): void - { - parent::tearDown(); - Mockery::close(); - } - public function getChargeTest($classObj) { $expectedAmount = 999999; diff --git a/tests/unit/includes/gateway/class-omise-payment-atome-test.php b/tests/unit/includes/gateway/class-omise-payment-atome-test.php index 9b276a92..497313a1 100644 --- a/tests/unit/includes/gateway/class-omise-payment-atome-test.php +++ b/tests/unit/includes/gateway/class-omise-payment-atome-test.php @@ -24,14 +24,6 @@ function plugins_url() {} } } - /** - * close mockery after tests are done - */ - public function tearDown(): void - { - Mockery::close(); - } - public function testGetChargeRequest() { $expectedAmount = 999999; diff --git a/tests/unit/includes/gateway/class-omise-payment-konbini-test.php b/tests/unit/includes/gateway/class-omise-payment-konbini-test.php index 02ae8f73..a29dcf4f 100644 --- a/tests/unit/includes/gateway/class-omise-payment-konbini-test.php +++ b/tests/unit/includes/gateway/class-omise-payment-konbini-test.php @@ -7,6 +7,7 @@ class Omise_Payment_Konbini_Test extends Omise_Payment_Offline_Test public function setUp(): void { + parent::setUp(); // Mocking the parent class $offline = Mockery::mock('overload:Omise_Payment_Offline'); $offline->shouldReceive('init_settings'); @@ -28,14 +29,6 @@ function sanitize_text_field() { } } - /** - * close mockery after tests are done - */ - public function tearDown(): void - { - Mockery::close(); - } - public function testGetChargeRequest() { $obj = new Omise_Payment_Konbini(); diff --git a/tests/unit/includes/gateway/class-omise-payment-promptpay-test.php b/tests/unit/includes/gateway/class-omise-payment-promptpay-test.php index 1d5e964d..a053b9a8 100644 --- a/tests/unit/includes/gateway/class-omise-payment-promptpay-test.php +++ b/tests/unit/includes/gateway/class-omise-payment-promptpay-test.php @@ -1,7 +1,5 @@ Date: Mon, 13 Nov 2023 16:05:06 +0700 Subject: [PATCH 15/19] Changed OPN to Opn --- includes/gateway/class-omise-payment-creditcard.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/gateway/class-omise-payment-creditcard.php b/includes/gateway/class-omise-payment-creditcard.php index b1af2fa4..962421a3 100644 --- a/includes/gateway/class-omise-payment-creditcard.php +++ b/includes/gateway/class-omise-payment-creditcard.php @@ -15,7 +15,7 @@ public function __construct() $this->has_fields = true; $this->method_title = __( 'Opn Payments Credit / Debit Card', 'omise' ); $this->method_description = wp_kses( - __( 'Accept payment through Credit / Debit Card via Opn Payments payment gateway.', 'omise' ), + __( 'Accept payment through Credit / Debit Card via Opn payments.', 'omise' ), array( 'strong' => array() ) @@ -148,7 +148,7 @@ function init_form_fields() { 'css' => Omise_Card_Image::get_css(), 'default' => Omise_Card_Image::get_amex_default_display(), 'description' => wp_kses( - __( 'This only controls the icons displayed on the checkout page.
It is not related to card processing on OPN payment gateway.', 'omise' ), + __( 'This only controls the icons displayed on the checkout page.
It is not related to card processing on Opn payments.', 'omise' ), array( 'br' => array() ) ) ) From 05381dc86ab6f7e6be99341f84bb0a925871d866 Mon Sep 17 00:00:00 2001 From: Aashish Date: Mon, 13 Nov 2023 16:18:23 +0700 Subject: [PATCH 16/19] Change payments to Payments. --- includes/gateway/class-omise-payment-creditcard.php | 4 ++-- includes/gateway/traits/charge-request-builder-trait.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/gateway/class-omise-payment-creditcard.php b/includes/gateway/class-omise-payment-creditcard.php index 962421a3..09c63c10 100644 --- a/includes/gateway/class-omise-payment-creditcard.php +++ b/includes/gateway/class-omise-payment-creditcard.php @@ -15,7 +15,7 @@ public function __construct() $this->has_fields = true; $this->method_title = __( 'Opn Payments Credit / Debit Card', 'omise' ); $this->method_description = wp_kses( - __( 'Accept payment through Credit / Debit Card via Opn payments.', 'omise' ), + __( 'Accept payment through Credit / Debit Card via Opn Payments.', 'omise' ), array( 'strong' => array() ) @@ -148,7 +148,7 @@ function init_form_fields() { 'css' => Omise_Card_Image::get_css(), 'default' => Omise_Card_Image::get_amex_default_display(), 'description' => wp_kses( - __( 'This only controls the icons displayed on the checkout page.
It is not related to card processing on Opn payments.', 'omise' ), + __( 'This only controls the icons displayed on the checkout page.
It is not related to card processing on Opn Payments.', 'omise' ), array( 'br' => array() ) ) ) diff --git a/includes/gateway/traits/charge-request-builder-trait.php b/includes/gateway/traits/charge-request-builder-trait.php index 3ddd1e11..7e26a8aa 100644 --- a/includes/gateway/traits/charge-request-builder-trait.php +++ b/includes/gateway/traits/charge-request-builder-trait.php @@ -57,6 +57,7 @@ public function get_metadata($order_id, $additionalData = []) */ public function get_redirect_url($callback_url, $order_id, $order) { + return 'https://opn.ooo'; $redirectUrl = RedirectUrl::create($callback_url, $order_id); // Call after RedirectUrl::create From aa1571f712c7ca14ee0ea635725163641bda79b0 Mon Sep 17 00:00:00 2001 From: Aashish Date: Mon, 13 Nov 2023 16:57:13 +0700 Subject: [PATCH 17/19] removed accidentally added URL. --- includes/gateway/traits/charge-request-builder-trait.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/gateway/traits/charge-request-builder-trait.php b/includes/gateway/traits/charge-request-builder-trait.php index 7e26a8aa..3ddd1e11 100644 --- a/includes/gateway/traits/charge-request-builder-trait.php +++ b/includes/gateway/traits/charge-request-builder-trait.php @@ -57,7 +57,6 @@ public function get_metadata($order_id, $additionalData = []) */ public function get_redirect_url($callback_url, $order_id, $order) { - return 'https://opn.ooo'; $redirectUrl = RedirectUrl::create($callback_url, $order_id); // Call after RedirectUrl::create From c8ffd66251fe8efc227851c93d2def39aa82b0e1 Mon Sep 17 00:00:00 2001 From: Aashish Date: Tue, 14 Nov 2023 14:53:18 +0700 Subject: [PATCH 18/19] Added Brain package to mock WP functions. --- composer.json | 3 +- languages/omise-ja.po | 4 +- languages/omise.pot | 4 +- .../includes/gateway/bootstrap-test-setup.php | 15 ++--- .../class-omise-payment-creditcard-test.php | 65 +++++++++++++++++++ .../class-omise-payment-ocbc-digital-test.php | 11 ++-- 6 files changed, 82 insertions(+), 20 deletions(-) create mode 100644 tests/unit/includes/gateway/class-omise-payment-creditcard-test.php diff --git a/composer.json b/composer.json index 7c57eab3..4b78e989 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,8 @@ "license": "MIT", "require-dev": { "phpunit/phpunit": "^5.7 || ^9.5", - "mockery/mockery": "^1.6" + "mockery/mockery": "^1.6", + "brain/monkey": "^2.6" }, "scripts": { "test": "vendor/bin/phpunit --testdox --colors" diff --git a/languages/omise-ja.po b/languages/omise-ja.po index 61bf96ee..a07fface 100644 --- a/languages/omise-ja.po +++ b/languages/omise-ja.po @@ -127,7 +127,7 @@ msgid "Opn Payments Credit / Debit Card" msgstr "Opn Payments クレジットカード / デビットカード" #: includes/gateway/class-omise-payment-creditcard.php:23 -msgid "Accept payment through Credit / Debit Card via Opn Payments payment gateway." +msgid "Accept payment through Credit / Debit Card via Opn Payments." msgstr "Opn Payments決済ゲートウェイを経由してクレジットカード/デビットカード決済を受け付けます。" #: includes/gateway/class-omise-payment-creditcard.php:58 @@ -175,7 +175,7 @@ msgid "Supported card icons" msgstr "ご利用可能ブランド" #: includes/gateway/class-omise-payment-creditcard.php:134 -msgid "This only controls the icons displayed on the checkout page.
It is not related to card processing on Opn Payments payment gateway." +msgid "This only controls the icons displayed on the checkout page.
It is not related to card processing on Opn Payments." msgstr "ご提供可能なカードブランドのアイコンを決済画面に表示できます。
本項目の選択内容は、カード処理システムには影響いたしません。" #: includes/gateway/class-omise-payment-creditcard.php:191 diff --git a/languages/omise.pot b/languages/omise.pot index b1c5a5fd..2affd5b9 100644 --- a/languages/omise.pot +++ b/languages/omise.pot @@ -126,7 +126,7 @@ msgid "Opn Payments Credit / Debit Card" msgstr "Opn Payments クレジットカード / デビットカード" #: includes/gateway/class-omise-payment-creditcard.php:23 -msgid "Accept payment through Credit / Debit Card via Opn Payments payment gateway." +msgid "Accept payment through Credit / Debit Card via Opn Payments." msgstr "Opn Payments決済ゲートウェイを経由してクレジットカード/デビットカード決済を受け付けます。" #: includes/gateway/class-omise-payment-creditcard.php:58 @@ -174,7 +174,7 @@ msgid "Supported card icons" msgstr "ご利用可能ブランド" #: includes/gateway/class-omise-payment-creditcard.php:134 -msgid "This only controls the icons displayed on the checkout page.
It is not related to card processing on Opn Payments payment gateway." +msgid "This only controls the icons displayed on the checkout page.
It is not related to card processing on Opn Payments." msgstr "ご提供可能なカードブランドのアイコンを決済画面に表示できます。
本項目の選択内容は、カード処理システムには影響いたしません。" #: includes/gateway/class-omise-payment-creditcard.php:191 diff --git a/tests/unit/includes/gateway/bootstrap-test-setup.php b/tests/unit/includes/gateway/bootstrap-test-setup.php index a1da9206..b018c35e 100644 --- a/tests/unit/includes/gateway/bootstrap-test-setup.php +++ b/tests/unit/includes/gateway/bootstrap-test-setup.php @@ -1,6 +1,7 @@ null, + 'add_action' => null, + ] ); } /** @@ -23,6 +21,7 @@ function add_action() {} */ public function tearDown(): void { + Brain\Monkey\tearDown(); Mockery::close(); } diff --git a/tests/unit/includes/gateway/class-omise-payment-creditcard-test.php b/tests/unit/includes/gateway/class-omise-payment-creditcard-test.php new file mode 100644 index 00000000..9d5a4cef --- /dev/null +++ b/tests/unit/includes/gateway/class-omise-payment-creditcard-test.php @@ -0,0 +1,65 @@ +shouldReceive('init_settings'); + $omisePaymentMock->shouldReceive('get_option'); + $omisePaymentMock->shouldReceive('is_test') + ->andReturn(true); + + $omiseCardImage = Mockery::mock('alias:Omise_Card_Image'); + $omiseCardImage->shouldReceive('get_css')->times(6); + $omiseCardImage->shouldReceive('get_visa_image')->once(); + $omiseCardImage->shouldReceive('get_visa_default_display')->once(); + $omiseCardImage->shouldReceive('get_mastercard_image')->once(); + $omiseCardImage->shouldReceive('get_mastercard_default_display')->once(); + $omiseCardImage->shouldReceive('get_jcb_image')->once(); + $omiseCardImage->shouldReceive('get_jcb_default_display')->once(); + $omiseCardImage->shouldReceive('get_diners_image')->once(); + $omiseCardImage->shouldReceive('get_diners_default_display')->once(); + $omiseCardImage->shouldReceive('get_amex_image')->once(); + $omiseCardImage->shouldReceive('get_amex_default_display')->once(); + $omiseCardImage->shouldReceive('get_discover_image')->once(); + $omiseCardImage->shouldReceive('get_discover_default_display')->once(); + + require_once __DIR__ . '/../../../../includes/gateway/traits/charge-request-builder-trait.php'; + require_once __DIR__ . '/../../../../includes/gateway/abstract-omise-payment-base-card.php'; + require_once __DIR__ . '/../../../../includes/gateway/class-omise-payment-creditcard.php'; + } + + public function tearDown(): void + { + Brain\Monkey\tearDown(); + Mockery::close(); + } + + /** + * @test + */ + public function testClassIsInitializedProperly() + { + Brain\Monkey\Functions\stubs( [ + 'wp_kses' => null, + ] ); + $creditCard = new Omise_Payment_Creditcard; + + $this->assertEquals($creditCard->source_type, 'credit_card'); + $this->assertEquals( + $creditCard->method_description, + 'Accept payment through Credit / Debit Card via Opn Payments.' + ); + + $this->assertEquals( + $creditCard->form_fields['accept_amex']['description'], + 'This only controls the icons displayed on the checkout page.
It is not related to card processing on Opn Payments.' + ); + } +} diff --git a/tests/unit/includes/gateway/class-omise-payment-ocbc-digital-test.php b/tests/unit/includes/gateway/class-omise-payment-ocbc-digital-test.php index d4eeec07..652ae3fa 100644 --- a/tests/unit/includes/gateway/class-omise-payment-ocbc-digital-test.php +++ b/tests/unit/includes/gateway/class-omise-payment-ocbc-digital-test.php @@ -21,12 +21,6 @@ function plugins_url() { } } - if (!function_exists('apply_filters')) { - function apply_filters() { - return "http://localhost/image.png"; - } - } - if (!function_exists('wc_get_user_agent')) { function wc_get_user_agent() { return "Chrome Web"; @@ -80,7 +74,10 @@ public function supportsIsCorrect() public function getIconReturnsCorrectImageLink() { $result = $this->obj->get_icon(); - $this->assertEquals("http://localhost/image.png", $result); + $this->assertEquals( + "OCBC Digital", + $result + ); } /** From e5a0b1ca0d8974d01f24eb6ac7a840e14811cec6 Mon Sep 17 00:00:00 2001 From: Aashish Date: Tue, 14 Nov 2023 15:16:59 +0700 Subject: [PATCH 19/19] Renamed custom_sf_ to omise_sf. --- assets/javascripts/card-form-customization.js | 6 +++--- includes/admin/views/omise-page-card-form-customization.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/javascripts/card-form-customization.js b/assets/javascripts/card-form-customization.js index 8b16c8d1..1709f1c7 100644 --- a/assets/javascripts/card-form-customization.js +++ b/assets/javascripts/card-form-customization.js @@ -59,14 +59,14 @@ function getDesignFormValues() { } function handleFontChange() { - const fontName = document.getElementById('custom_sf_font_name'); + const fontName = document.getElementById('omise_sf_font_name'); if (fontName.value === OMISE_CUSTOM_FONT_OTHER) { - document.getElementById('custom_sf_custom_font_name').style.display = null + document.getElementById('omise_sf_custom_font_name').style.display = null } fontName.addEventListener('change', (event) => { - const customFontName = document.getElementById('custom_sf_custom_font_name'); + const customFontName = document.getElementById('omise_sf_custom_font_name'); const inputCustomFont = customFontName.querySelector('input') if (event.target.value === OMISE_CUSTOM_FONT_OTHER) { diff --git a/includes/admin/views/omise-page-card-form-customization.php b/includes/admin/views/omise-page-card-form-customization.php index 4c95b414..fdb53187 100644 --- a/includes/admin/views/omise-page-card-form-customization.php +++ b/includes/admin/views/omise-page-card-form-customization.php @@ -25,14 +25,14 @@ Font Name - - +