Skip to content

Commit

Permalink
Merge pull request #417 from omise/bump_v5.6.0
Browse files Browse the repository at this point in the history
Bump to v5.6.0
  • Loading branch information
aashishgurung committed Nov 15, 2023
2 parents 1e39ddd + cca00a0 commit 6dc2dd7
Show file tree
Hide file tree
Showing 24 changed files with 275 additions and 51 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

### [v5.6.0 _(Nov 15, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.6.0)
- Support Google fonts other than Poppins. (PR [#416](https://github.com/omise/omise-woocommerce/pull/416))

### [v5.5.1 _(Nov 2, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.5.1)
- Fix mobile banking issue. (PR [#413](https://github.com/omise/omise-woocommerce/pull/413))

Expand Down
23 changes: 23 additions & 0 deletions assets/javascripts/card-form-customization.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ function getDesignFormValues() {
return formValues;
}

function handleFontChange() {
const fontName = document.getElementById('omise_sf_font_name');

if (fontName.value === OMISE_CUSTOM_FONT_OTHER) {
document.getElementById('omise_sf_custom_font_name').style.display = null
}

fontName.addEventListener('change', (event) => {
const customFontName = document.getElementById('omise_sf_custom_font_name');
const inputCustomFont = customFontName.querySelector('input')

if (event.target.value === OMISE_CUSTOM_FONT_OTHER) {
customFontName.style.display = null;
inputCustomFont.required = true;
} else {
customFontName.style.display = 'none';
inputCustomFont.value = '';
inputCustomFont.required = false;
}
});
}

function initOmiseCardForm() {
const customCardFormTheme = CARD_FORM_THEME ?? 'light';
document.querySelector('.omise-modal .content').style.background =
Expand Down Expand Up @@ -91,3 +113,4 @@ document.getElementById('omise-modal').addEventListener('click', (event) => {

setDesignFormValues();
handleColorInputChanges();
handleFontChange();
10 changes: 9 additions & 1 deletion assets/javascripts/omise-embedded-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ 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 (isCustomFontSet && !isCustomFontEmpty) {
fontName = font.custom_name.trim()
}

OmiseCard.configure({
publicKey: publicKey,
element,
Expand All @@ -34,7 +42,7 @@ function showOmiseEmbeddedCardForm({
customCardFormHideRememberCard: hideRememberCard ?? false,
customCardFormBrandIcons: brandIcons ?? null,
style: {
fontFamily: font.name,
fontFamily: fontName,
fontSize: font.size,
input: {
height: input.height,
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions includes/admin/class-omise-page-card-form-customization.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ private function get_light_theme()
'font' => [
'name' => 'Poppins',
'size' => 16,
'custom_name' => ''
],
'input' => [
'height' => '44px',
Expand All @@ -51,6 +52,7 @@ private function get_dark_theme()
'font' => [
'name' => 'Poppins',
'size' => 16,
'custom_name' => ''
],
'input' => [
'height' => '44px',
Expand Down Expand Up @@ -110,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!");
}
Expand Down
15 changes: 12 additions & 3 deletions includes/admin/views/omise-page-card-form-customization.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$cardFormTheme = $omiseCardGateway->get_option('card_form_theme');
$cardIcons = $omiseCardGateway->get_card_icons();
$publicKey = Omise()->settings()->public_key();
$customFontOther = 'Other';
?>

<link rel="stylesheet" href="<?php echo $assetUrl . '/css/card-form-customization.css'; ?>">
Expand All @@ -24,11 +25,18 @@
<tr>
<td class="text-bold" style="width: 250px;">Font Name</td>
<td>
<select class="select-input" name="font[name]">
<select id="omise_sf_font_name" class="select-input" name="font[name]">
<option value="Poppins">Poppins</option>
<option value="Circular" selected>Circular</option>
<option value="<?php echo $customFontOther ?>"><?php echo $customFontOther ?></option>
</select>
<div class="description">Match font used in form with your selected font</div>
</td>
</tr>

<tr id="omise_sf_custom_font_name" style="display: none;">
<td class="text-bold" style="width: 250px;"></td>
<td>
<input type="text" class="select-input" placeholder="Font Name" name="font[custom_name]" />
<div class="description">Specify other font name (note: only Google Fonts supported)</div>
</td>
</tr>

Expand Down Expand Up @@ -189,6 +197,7 @@
window.DEFAULT_FORM_DESIGN = JSON.parse(`<?php echo json_encode($formDesign) ?>`);
window.CARD_BRAND_ICONS = JSON.parse(`<?php echo json_encode($cardIcons) ?>`);
window.LOCALE = `<?php echo get_locale(); ?>`;
window.OMISE_CUSTOM_FONT_OTHER = `<?php echo $customFontOther ?>`;
</script>
<script src="<?php echo $assetUrl . '/javascripts/omise-embedded-card.js'; ?>"></script>
<script src="<?php echo $assetUrl . '/javascripts/card-form-customization.js'; ?>"></script>
2 changes: 1 addition & 1 deletion includes/admin/views/omise-page-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<?php
echo sprintf(
wp_kses(
__( 'Unless dynamic webhooks are enabled, you must add the URL below as a new endpoint on your <a href="%s">Opn Payments dashboard</a> (HTTPS only).', 'omise' ),
__( 'Unless dynamic webhooks are enabled, you must add the URL above as a new endpoint on your <a href="%s">Opn Payments dashboard</a> (HTTPS only).', 'omise' ),
[
'a' => ['href' => []],
],
Expand Down
4 changes: 2 additions & 2 deletions includes/gateway/class-omise-payment-creditcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <strong>Credit / Debit Card</strong> via Opn Payments payment gateway.', 'omise' ),
__( 'Accept payment through <strong>Credit / Debit Card</strong> via Opn Payments.', 'omise' ),
array(
'strong' => array()
)
Expand Down Expand Up @@ -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.<br />It is not related to card processing on Omise payment gateway.', 'omise' ),
__( 'This only controls the icons displayed on the checkout page.<br />It is not related to card processing on Opn Payments.', 'omise' ),
array( 'br' => array() )
)
)
Expand Down
4 changes: 2 additions & 2 deletions languages/omise-ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <strong>Credit / Debit Card</strong> via Opn Payments payment gateway."
msgid "Accept payment through <strong>Credit / Debit Card</strong> via Opn Payments."
msgstr "Opn Payments決済ゲートウェイを経由して<strong>クレジットカード/デビットカード</strong>決済を受け付けます。"

#: includes/gateway/class-omise-payment-creditcard.php:58
Expand Down Expand Up @@ -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.<br />It is not related to card processing on Opn Payments payment gateway."
msgid "This only controls the icons displayed on the checkout page.<br />It is not related to card processing on Opn Payments."
msgstr "ご提供可能なカードブランドのアイコンを決済画面に表示できます。<br/>本項目の選択内容は、カード処理システムには影響いたしません。"

#: includes/gateway/class-omise-payment-creditcard.php:191
Expand Down
4 changes: 2 additions & 2 deletions languages/omise.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 <strong>Credit / Debit Card</strong> via Opn Payments payment gateway."
msgid "Accept payment through <strong>Credit / Debit Card</strong> via Opn Payments."
msgstr "Opn Payments決済ゲートウェイを経由して<strong>クレジットカード/デビットカード</strong>決済を受け付けます。"

#: includes/gateway/class-omise-payment-creditcard.php:58
Expand Down Expand Up @@ -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.<br />It is not related to card processing on Opn Payments payment gateway."
msgid "This only controls the icons displayed on the checkout page.<br />It is not related to card processing on Opn Payments."
msgstr "ご提供可能なカードブランドのアイコンを決済画面に表示できます。<br/>本項目の選択内容は、カード処理システムには影響いたしません。"

#: includes/gateway/class-omise-payment-creditcard.php:191
Expand Down
4 changes: 2 additions & 2 deletions omise-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.1
* Version: 5.6.0
* Author: Opn Payments and contributors
* Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors
* Text Domain: omise
Expand All @@ -22,7 +22,7 @@ class Omise
*
* @var string
*/
public $version = '5.5.1';
public $version = '5.6.0';

/**
* The Omise Instance.
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: Opn Payments
Tags: opn payments, payment, payment gateway, woocommerce plugin, omise, opn, installment, internet banking, alipay, paynow, truemoney wallet, woocommerce payment
Requires at least: 4.3.1
Tested up to: 6.3.2
Stable tag: 5.5.1
Tested up to: 6.4.0
Stable tag: 5.6.0
License: MIT
License URI: https://opensource.org/licenses/MIT

Expand Down Expand Up @@ -34,6 +34,10 @@ From there:

== Changelog ==

= 5.6.0 =

- Support Google fonts other than Poppins. (PR [#416](https://github.com/omise/omise-woocommerce/pull/416))

= 5.5.1 =

- Fix mobile banking issue. (PR [#413](https://github.com/omise/omise-woocommerce/pull/413))
Expand Down
1 change: 1 addition & 0 deletions templates/myaccount/my-card.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ class='button delete_card'
window.FORM_DESIGN = JSON.parse(`<?php echo json_encode($viewData['formDesign']) ?>`);
window.CARD_BRAND_ICONS = JSON.parse(`<?php echo json_encode($viewData['cardIcons']) ?>`);
window.LOCALE = `<?php echo get_locale(); ?>`;
window.OMISE_CUSTOM_FONT_OTHER = 'Other';
</script>
<?php endif; ?>
1 change: 1 addition & 0 deletions templates/payment/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
window.FORM_DESIGN = JSON.parse(`<?php echo json_encode($viewData['form_design']) ?>`);
window.LOCALE = `<?php echo get_locale(); ?>`;
window.HIDE_REMEMBER_CARD = `<?php echo $hideRememberCard ?>` == 'yes' ? true : false;
window.OMISE_CUSTOM_FONT_OTHER = 'Other';
</script>
<?php endif; ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

use PHPUnit\Framework\TestCase;

/**
* @runTestsInSeparateProcesses
*/
class Omise_Page_Card_From_Customization_Test extends TestCase
{
public function setUp(): void
{
// mocking WP built-in functions
if (!function_exists('get_option')) {
function get_option() {}
}

Mockery::mock('alias:Omise_Admin_Page');
require_once __DIR__ . '/../../../../includes/admin/class-omise-page-card-form-customization.php';
}

public function tearDown(): void
{
Mockery::close();
}

/**
* @test
*/
public function testGetLightTheme()
{
$expected = [
'font' => [
'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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ public function setUp(): void
{
parent::setUp();
Mockery::mock('alias:Omise_Payment')->makePartial();
require_once __DIR__ . '/../../../../includes/gateway/abstract-omise-payment-offline.php';
}
}
Loading

0 comments on commit 6dc2dd7

Please sign in to comment.