Skip to content

Commit

Permalink
Merge pull request #432 from omise/release-v5.7.0
Browse files Browse the repository at this point in the history
Release v5.7.0
  • Loading branch information
aashishgurung authored Jan 15, 2024
2 parents a2bb592 + b459f06 commit 9f88a51
Show file tree
Hide file tree
Showing 17 changed files with 276 additions and 131 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS

This file was deleted.

52 changes: 0 additions & 52 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## [v5.7.0 _(Jan 11, 2024)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.7.0)
- Added TrueMoney jumpapp. (PR [#431](https://github.com/omise/omise-woocommerce/pull/431))
- Updated README.md. (PR [#429](https://github.com/omise/omise-woocommerce/pull/429))

## [v5.6.2 _(Dec 7, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.6.2)
- Update OCBC digital logo. (PR [#422](https://github.com/omise/omise-woocommerce/pull/422))
- Update installment interest rates. (PR [#423](https://github.com/omise/omise-woocommerce/pull/423))
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<!--- KEEP START --->
[![Omise](https://cdn.omise.co/assets/omise.png)](https://www.omise.co/developers)
[![Opn Payments](https://www.opn.ooo/assets/svg/logo-opn-full.svg)](https://www.opn.ooo)

[Omise](https://www.omise.co/) is a payment service provider operating in Thailand, Japan, and Singapore.
Omise provides a set of APIs that help merchants of any size accept payments online.
[Opn Payments](https://www.opn.ooo) is a payment service provider operating in Thailand, Japan, and Singapore.
Opn Payments provides a set of APIs that help merchants of any size accept payments online.
<!--- KEEP END --->

**Omise WooCommerce** is our official plugin providing support for processing payments on WooCommerce through Omise.

![PHP Composer](https://github.com/omise/omise-woocommerce/workflows/PHP%20Composer/badge.svg)
**Omise WooCommerce** is our official plugin providing support for processing payments on WooCommerce through Opn Payments.

## Usage

See our [official docs](https://www.omise.co/woocommerce-plugin) for details on installation and configuration.
See our [official docs](https://docs.opn.ooo/woocommerce-plugin) for details on installation and configuration.

## Contributing

Expand Down
16 changes: 16 additions & 0 deletions includes/class-omise-capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,20 @@ public function getInstallmentMinLimit()
{
return $this->capabilities['limits']['installment_amount']['min'];
}

/**
* Retrieves details of TrueMoney from capabilities.
*
* @param string $source_type
*/
public function get_truemoney_backend($source_type)
{
$truemoney_source_types = [Omise_Payment_Truemoney::WALLET, Omise_Payment_Truemoney::JUMPAPP];

if (!in_array($source_type, $truemoney_source_types)) {
return null;
}

return $this->getBackendByType($source_type);
}
}
72 changes: 55 additions & 17 deletions includes/gateway/class-omise-payment-truemoney.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@
*/
class Omise_Payment_Truemoney extends Omise_Payment_Offsite
{
/**
* Backends identifier
* @var string
*/
const WALLET = 'truemoney';
const JUMPAPP = 'truemoney_jumpapp';

public function __construct()
{
parent::__construct();

$this->id = 'omise_truemoney';
$this->has_fields = true;
$this->method_title = __( 'Opn Payments TrueMoney Wallet', 'omise' );
$this->method_title = __( 'Opn Payments TrueMoney', 'omise' );
$this->method_description = wp_kses(
__( 'Accept payments through <strong>TrueMoney Wallet</strong> via Opn Payments payment gateway (only available in Thailand).', 'omise' ),
__( 'Accept payments through <strong>TrueMoney</strong> via Opn Payments payment gateway (only available in Thailand).', 'omise' ),
array( 'strong' => array() )
);

Expand All @@ -26,7 +33,7 @@ public function __construct()
$this->title = $this->get_option( 'title' );
$this->description = $this->get_option( 'description' );
$this->restricted_countries = array( 'TH' );
$this->source_type = 'truemoney';
$this->source_type = $this->get_source();

add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
add_action( 'woocommerce_api_' . $this->id . '_callback', 'Omise_Callback::execute' );
Expand All @@ -43,15 +50,15 @@ public function init_form_fields()
'enabled' => array(
'title' => __( 'Enable/Disable', 'omise' ),
'type' => 'checkbox',
'label' => __( 'Enable Opn Payments TrueMoney Wallet Payment', 'omise' ),
'label' => __( 'Enable Opn Payments TrueMoney Payment', 'omise' ),
'default' => 'no'
),

'title' => array(
'title' => __( 'Title', 'omise' ),
'type' => 'text',
'description' => __( 'This controls the title the user sees during checkout.', 'omise' ),
'default' => __( 'TrueMoney Wallet', 'omise' ),
'default' => __( 'TrueMoney', 'omise' ),
),

'description' => array(
Expand All @@ -68,7 +75,9 @@ public function init_form_fields()
public function payment_fields()
{
parent::payment_fields();
Omise_Util::render_view( 'templates/payment/form-truemoney.php', array() );
if (self::WALLET === $this->source_type) {
Omise_Util::render_view( 'templates/payment/form-truemoney.php', [] );
}
}

/**
Expand All @@ -82,22 +91,51 @@ public function charge($order_id, $order)

public function get_charge_request($order_id, $order)
{
$phoneOption = $_POST['omise_phone_number_default'];
$isPhoneOptionChecked = isset($phoneOption) && 1 == $phoneOption;
$phone_number = $isPhoneOptionChecked ?
$order->get_billing_phone() :
sanitize_text_field( $_POST['omise_phone_number'] );

$requestData = $this->build_charge_request(
$request_data = $this->build_charge_request(
$order_id,
$order,
$this->source_type,
$this->id . '_callback'
);
$requestData['source'] = array_merge($requestData['source'], [
'phone_number' => $phone_number
]);

return $requestData;
if (self::WALLET === $this->source_type) {
$phone_option = $_POST['omise_phone_number_default'];
$is_phone_option_checked = isset($phone_option) && 1 == $phone_option;
$phone_number = $is_phone_option_checked ?
$order->get_billing_phone() :
sanitize_text_field( $_POST['omise_phone_number'] );

$request_data['source'] = array_merge($request_data['source'], [
'phone_number' => $phone_number
]);
}

return $request_data;
}

/**
* Return the right ShopeePay backend depending on the platform and availability of
* the backend in the capability
*/
public function get_source()
{
$capabilities = Omise_Capabilities::retrieve();

if (!$capabilities) {
return self::JUMPAPP;
}

$is_jumpapp_enabled = $capabilities->get_truemoney_backend(self::JUMPAPP);
$is_wallet_enabled = $capabilities->get_truemoney_backend(self::WALLET);

if (!empty($is_wallet_enabled) && empty($is_jumpapp_enabled)) {
return self::WALLET;
}

// Return JUMP APP for the following cases:
// Case 1: Both jumpapp and wallet are enabled
// Case 2: jumpapp is enabled and wallet is disabled
// Case 3: Both are disabled.
return self::JUMPAPP;
}
}
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.6.2
* Version: 5.7.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.6.2';
public $version = '5.7.0';

/**
* The Omise Instance.
Expand Down
9 changes: 7 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
=== Opn Payments ===
Contributors: Opn Payments
Tags: opn payments, payment, payment gateway, woocommerce plugin, omise, opn, installment, internet banking, alipay, paynow, truemoney wallet, woocommerce payment
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.6.2
Stable tag: 5.7.0
License: MIT
License URI: https://opensource.org/licenses/MIT

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

== Changelog ==

= 5.7.0 =

- Added TrueMoney jumpapp. (PR [#431](https://github.com/omise/omise-woocommerce/pull/431))
- Updated README.md. (PR [#429](https://github.com/omise/omise-woocommerce/pull/429))

= 5.6.2 =

- Update OCBC digital logo. (PR [#422](https://github.com/omise/omise-woocommerce/pull/422))
Expand Down
Loading

0 comments on commit 9f88a51

Please sign in to comment.