Changeset 3021743
- Timestamp:
- 01/15/2024 07:46:52 AM (2 years ago)
- Location:
- omise
- Files:
-
- 30 edited
- 1 copied
-
tags/5.7.0 (copied) (copied from omise/trunk)
-
tags/5.7.0/CHANGELOG.md (modified) (1 diff)
-
tags/5.7.0/README.md (modified) (1 diff)
-
tags/5.7.0/includes/class-omise-capabilities.php (modified) (1 diff)
-
tags/5.7.0/includes/gateway/class-omise-payment-truemoney.php (modified) (8 diffs)
-
tags/5.7.0/omise-woocommerce.php (modified) (2 diffs)
-
tags/5.7.0/readme.txt (modified) (2 diffs)
-
tags/5.7.0/tests/unit/includes/class-omise-capabilities-test.php (modified) (5 diffs)
-
tags/5.7.0/tests/unit/includes/gateway/bootstrap-test-setup.php (modified) (1 diff)
-
tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-alipayplus-hk-test.php (modified) (1 diff)
-
tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-alipayplus-kakaopay-test.php (modified) (1 diff)
-
tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-creditcard-test.php (modified) (1 diff)
-
tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-mobilebanking-test.php (modified) (1 diff)
-
tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-ocbc-digital-test.php (modified) (2 diffs)
-
tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-ocbc-pao-test.php (modified) (1 diff)
-
tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-truemoney-test.php (modified) (1 diff)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/README.md (modified) (1 diff)
-
trunk/includes/class-omise-capabilities.php (modified) (1 diff)
-
trunk/includes/gateway/class-omise-payment-truemoney.php (modified) (8 diffs)
-
trunk/omise-woocommerce.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/tests/unit/includes/class-omise-capabilities-test.php (modified) (5 diffs)
-
trunk/tests/unit/includes/gateway/bootstrap-test-setup.php (modified) (1 diff)
-
trunk/tests/unit/includes/gateway/class-omise-payment-alipayplus-hk-test.php (modified) (1 diff)
-
trunk/tests/unit/includes/gateway/class-omise-payment-alipayplus-kakaopay-test.php (modified) (1 diff)
-
trunk/tests/unit/includes/gateway/class-omise-payment-creditcard-test.php (modified) (1 diff)
-
trunk/tests/unit/includes/gateway/class-omise-payment-mobilebanking-test.php (modified) (1 diff)
-
trunk/tests/unit/includes/gateway/class-omise-payment-ocbc-digital-test.php (modified) (2 diffs)
-
trunk/tests/unit/includes/gateway/class-omise-payment-ocbc-pao-test.php (modified) (1 diff)
-
trunk/tests/unit/includes/gateway/class-omise-payment-truemoney-test.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
omise/tags/5.7.0/CHANGELOG.md
r3006639 r3021743 1 1 # CHANGELOG 2 3 ## [v5.7.0 _(Jan 11, 2024)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.7.0) 4 - Added TrueMoney jumpapp. (PR [#431](https://github.com/omise/omise-woocommerce/pull/431)) 5 - Updated README.md. (PR [#429](https://github.com/omise/omise-woocommerce/pull/429)) 2 6 3 7 ## [v5.6.2 _(Dec 7, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.6.2) -
omise/tags/5.7.0/README.md
r2501457 r3021743 1 1 <!--- KEEP START ---> 2 [](https://www.omise.co/developers)2 [](https://www.opn.ooo) 3 3 4 [O mise](https://www.omise.co/) is a payment service provider operating in Thailand, Japan, and Singapore.5 O miseprovides a set of APIs that help merchants of any size accept payments online.4 [Opn Payments](https://www.opn.ooo) is a payment service provider operating in Thailand, Japan, and Singapore. 5 Opn Payments provides a set of APIs that help merchants of any size accept payments online. 6 6 <!--- KEEP END ---> 7 7 8 **Omise WooCommerce** is our official plugin providing support for processing payments on WooCommerce through Omise. 9 10  8 **Omise WooCommerce** is our official plugin providing support for processing payments on WooCommerce through Opn Payments. 11 9 12 10 ## Usage 13 11 14 See our [official docs](https:// www.omise.co/woocommerce-plugin) for details on installation and configuration.12 See our [official docs](https://docs.opn.ooo/woocommerce-plugin) for details on installation and configuration. 15 13 16 14 ## Contributing -
omise/tags/5.7.0/includes/class-omise-capabilities.php
r2962817 r3021743 252 252 return $this->capabilities['limits']['installment_amount']['min']; 253 253 } 254 255 /** 256 * Retrieves details of TrueMoney from capabilities. 257 * 258 * @param string $source_type 259 */ 260 public function get_truemoney_backend($source_type) 261 { 262 $truemoney_source_types = [Omise_Payment_Truemoney::WALLET, Omise_Payment_Truemoney::JUMPAPP]; 263 264 if (!in_array($source_type, $truemoney_source_types)) { 265 return null; 266 } 267 268 return $this->getBackendByType($source_type); 269 } 254 270 } -
omise/tags/5.7.0/includes/gateway/class-omise-payment-truemoney.php
r2979883 r3021743 7 7 class Omise_Payment_Truemoney extends Omise_Payment_Offsite 8 8 { 9 /** 10 * Backends identifier 11 * @var string 12 */ 13 const WALLET = 'truemoney'; 14 const JUMPAPP = 'truemoney_jumpapp'; 15 9 16 public function __construct() 10 17 { … … 13 20 $this->id = 'omise_truemoney'; 14 21 $this->has_fields = true; 15 $this->method_title = __( 'Opn Payments TrueMoney Wallet', 'omise' );22 $this->method_title = __( 'Opn Payments TrueMoney', 'omise' ); 16 23 $this->method_description = wp_kses( 17 __( 'Accept payments through <strong>TrueMoney Wallet</strong> via Opn Payments payment gateway (only available in Thailand).', 'omise' ),24 __( 'Accept payments through <strong>TrueMoney</strong> via Opn Payments payment gateway (only available in Thailand).', 'omise' ), 18 25 array( 'strong' => array() ) 19 26 ); … … 27 34 $this->description = $this->get_option( 'description' ); 28 35 $this->restricted_countries = array( 'TH' ); 29 $this->source_type = 'truemoney';36 $this->source_type = $this->get_source(); 30 37 31 38 add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); … … 44 51 'title' => __( 'Enable/Disable', 'omise' ), 45 52 'type' => 'checkbox', 46 'label' => __( 'Enable Opn Payments TrueMoney WalletPayment', 'omise' ),53 'label' => __( 'Enable Opn Payments TrueMoney Payment', 'omise' ), 47 54 'default' => 'no' 48 55 ), … … 52 59 'type' => 'text', 53 60 'description' => __( 'This controls the title the user sees during checkout.', 'omise' ), 54 'default' => __( 'TrueMoney Wallet', 'omise' ),61 'default' => __( 'TrueMoney', 'omise' ), 55 62 ), 56 63 … … 69 76 { 70 77 parent::payment_fields(); 71 Omise_Util::render_view( 'templates/payment/form-truemoney.php', array() ); 78 if (self::WALLET === $this->source_type) { 79 Omise_Util::render_view( 'templates/payment/form-truemoney.php', [] ); 80 } 72 81 } 73 82 … … 83 92 public function get_charge_request($order_id, $order) 84 93 { 85 $phoneOption = $_POST['omise_phone_number_default']; 86 $isPhoneOptionChecked = isset($phoneOption) && 1 == $phoneOption; 87 $phone_number = $isPhoneOptionChecked ? 88 $order->get_billing_phone() : 89 sanitize_text_field( $_POST['omise_phone_number'] ); 90 91 $requestData = $this->build_charge_request( 94 $request_data = $this->build_charge_request( 92 95 $order_id, 93 96 $order, … … 95 98 $this->id . '_callback' 96 99 ); 97 $requestData['source'] = array_merge($requestData['source'], [98 'phone_number' => $phone_number99 ]);100 100 101 return $requestData; 101 if (self::WALLET === $this->source_type) { 102 $phone_option = $_POST['omise_phone_number_default']; 103 $is_phone_option_checked = isset($phone_option) && 1 == $phone_option; 104 $phone_number = $is_phone_option_checked ? 105 $order->get_billing_phone() : 106 sanitize_text_field( $_POST['omise_phone_number'] ); 107 108 $request_data['source'] = array_merge($request_data['source'], [ 109 'phone_number' => $phone_number 110 ]); 111 } 112 113 return $request_data; 114 } 115 116 /** 117 * Return the right ShopeePay backend depending on the platform and availability of 118 * the backend in the capability 119 */ 120 public function get_source() 121 { 122 $capabilities = Omise_Capabilities::retrieve(); 123 124 if (!$capabilities) { 125 return self::JUMPAPP; 126 } 127 128 $is_jumpapp_enabled = $capabilities->get_truemoney_backend(self::JUMPAPP); 129 $is_wallet_enabled = $capabilities->get_truemoney_backend(self::WALLET); 130 131 if (!empty($is_wallet_enabled) && empty($is_jumpapp_enabled)) { 132 return self::WALLET; 133 } 134 135 // Return JUMP APP for the following cases: 136 // Case 1: Both jumpapp and wallet are enabled 137 // Case 2: jumpapp is enabled and wallet is disabled 138 // Case 3: Both are disabled. 139 return self::JUMPAPP; 102 140 } 103 141 } -
omise/tags/5.7.0/omise-woocommerce.php
r3006639 r3021743 5 5 * Plugin URI: https://www.omise.co/woocommerce 6 6 * 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. 7 * Version: 5. 6.27 * Version: 5.7.0 8 8 * Author: Opn Payments and contributors 9 9 * Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors … … 23 23 * @var string 24 24 */ 25 public $version = '5. 6.2';25 public $version = '5.7.0'; 26 26 27 27 /** -
omise/tags/5.7.0/readme.txt
r3006639 r3021743 1 1 === Opn Payments === 2 2 Contributors: Opn Payments 3 Tags: opn payments, payment, payment gateway, woocommerce plugin, omise, opn, installment, internet banking, alipay, paynow, truemoney wallet, woocommerce payment3 Tags: opn payments, payment, payment gateway, woocommerce plugin, omise, opn, installment, internet banking, alipay, paynow, truemoney, woocommerce payment 4 4 Requires at least: 4.3.1 5 5 Tested up to: 6.4.2 6 Stable tag: 5. 6.26 Stable tag: 5.7.0 7 7 License: MIT 8 8 License URI: https://opensource.org/licenses/MIT … … 34 34 35 35 == Changelog == 36 37 = 5.7.0 = 38 39 - Added TrueMoney jumpapp. (PR [#431](https://github.com/omise/omise-woocommerce/pull/431)) 40 - Updated README.md. (PR [#429](https://github.com/omise/omise-woocommerce/pull/429)) 36 41 37 42 = 5.6.2 = -
omise/tags/5.7.0/tests/unit/includes/class-omise-capabilities-test.php
r2962817 r3021743 1 1 <?php 2 2 3 use PHPUnit\Framework\TestCase;3 require_once __DIR__ . '/gateway/bootstrap-test-setup.php'; 4 4 5 class Omise_Capabilities_Test extends TestCase 5 /** 6 * @runTestsInSeparateProcesses 7 */ 8 class Omise_Capabilities_Test extends Bootstrap_Test_Setup 6 9 { 7 10 private $omiseSettingMock; … … 14 17 public function setUp(): void 15 18 { 19 parent::setUp(); 20 21 Mockery::mock('Omise_Payment_Offsite'); 16 22 require_once __DIR__ . '/../../../includes/class-omise-capabilities.php'; 23 require_once __DIR__ . '/../../../includes/gateway/class-omise-payment-truemoney.php'; 17 24 $this->omiseSettingMock = Mockery::mock('alias:Omise_Setting'); 18 25 $this->omiseCapabilitiesMock = Mockery::mock('alias:OmiseCapabilities'); … … 20 27 21 28 /** 22 * close mockery after test cases are done23 */24 public function tearDown(): void25 {26 Mockery::close();27 }28 29 /**30 29 * @dataProvider retrieve_data_provider 31 * @runInSeparateProcess32 30 * @covers Omise_Capabilities 33 31 */ 34 32 public function test_retrieve_should_return_value_when_it_should_call_api($isCheckout, $isThankYouPage, $isAdmin, $adminPageName, $expected) 35 { 33 { 36 34 // assigning to global variable, so that we can use in child functions 37 35 $GLOBALS['isCheckout'] = $isCheckout; … … 42 40 $_GET['page'] = $adminPageName; 43 41 44 function is_checkout() { return $GLOBALS['isCheckout']; } 45 function is_wc_endpoint_url($page) { return $GLOBALS['isThankYouPage']; } 46 function is_admin() { return $GLOBALS['isAdmin']; } 42 Brain\Monkey\Functions\expect('is_admin') 43 ->with('123') 44 ->andReturn($GLOBALS['isAdmin']); 45 Brain\Monkey\Functions\expect('is_checkout') 46 ->with('123') 47 ->andReturn($GLOBALS['isCheckout']); 48 Brain\Monkey\Functions\expect('is_wc_endpoint_url') 49 ->with('123') 50 ->andReturn($GLOBALS['isThankYouPage']); 47 51 48 52 if ($expected) { … … 67 71 // checkout page and not thank you page 68 72 [true, false, false, '', true], 69 // //checkout page and also thank you page73 // checkout page and also thank you page 70 74 [true, true, false, '', false], 71 // //omise setting page75 // omise setting page 72 76 [true, true, true, 'omise', true], 73 // //other admin page77 // other admin page 74 78 [true, true, true, 'other-page', false], 75 // //non checkout page and also no-admin page79 // non checkout page and also no-admin page 76 80 [false, false, false, 'other-page', false], 77 // //non checkout page, non admin page81 // non checkout page, non admin page 78 82 [false, false, false, '', false], 79 83 ]; 80 84 } 85 86 /** 87 * @test 88 */ 89 public function test_get_truemoney_backend_returns_null_when_invalid_payment_is_passed() 90 { 91 Brain\Monkey\Functions\expect('is_admin') 92 ->with('123') 93 ->andReturn(true); 94 95 Brain\Monkey\Functions\expect('is_checkout') 96 ->with('123') 97 ->andReturn(true); 98 99 Brain\Monkey\Functions\expect('is_wc_endpoint_url') 100 ->with('123') 101 ->andReturn(false); 102 103 $capabilities = new Omise_Capabilities; 104 $is_enabled = $capabilities->get_truemoney_backend('abc'); 105 $this->assertNull($is_enabled); 106 } 107 108 public function truemoney_source_provider() 109 { 110 return [ ['abc', false], ['truemoney', true], ['truemoney_jumpapp', true] ]; 111 } 81 112 } 113 114 class Omise_Payment_Truemoney_Stub 115 { 116 /** 117 * Backends identifier 118 * @var string 119 */ 120 const WALLET = 'truemoney'; 121 const JUMPAPP = 'truemoney_jumpapp'; 122 } -
omise/tags/5.7.0/tests/unit/includes/gateway/bootstrap-test-setup.php
r2996251 r3021743 2 2 3 3 use PHPUnit\Framework\TestCase; 4 use Brain; 4 5 5 6 6 abstract class Bootstrap_Test_Setup extends TestCase -
omise/tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-alipayplus-hk-test.php
r2979883 r3021743 3 3 require_once __DIR__ . '/class-omise-offsite-test.php'; 4 4 5 /** 6 * @runTestsInSeparateProcesses 7 */ 5 8 class Omise_Payment_Alipay_Hk_Test extends Omise_Offsite_Test 6 9 { -
omise/tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-alipayplus-kakaopay-test.php
r2979883 r3021743 3 3 require_once __DIR__ . '/class-omise-offsite-test.php'; 4 4 5 /** 6 * @runTestsInSeparateProcesses 7 */ 5 8 class Omise_Payment_Kakaopay_Test extends Omise_Offsite_Test 6 9 { -
omise/tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-creditcard-test.php
r2996251 r3021743 2 2 3 3 use PHPUnit\Framework\TestCase; 4 use Brain;5 4 6 5 class Omise_Payment_CreditCard_Test extends TestCase -
omise/tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-mobilebanking-test.php
r2979883 r3021743 14 14 public function testCharge() 15 15 { 16 Brain\Monkey\Functions\expect('wc_get_user_agent') 17 ->with('123') 18 ->andReturn('Chrome Web'); 16 19 $_POST['omise-offsite'] = 'mobile_banking_bbl'; 17 20 $obj = new Omise_Payment_Mobilebanking(); -
omise/tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-ocbc-digital-test.php
r3006639 r3021743 19 19 function plugins_url() { 20 20 return "http://localhost"; 21 }22 }23 24 if (!function_exists('wc_get_user_agent')) {25 function wc_get_user_agent() {26 return "Chrome Web";27 21 } 28 22 } … … 86 80 public function testCharge() 87 81 { 82 Brain\Monkey\Functions\expect('wc_get_user_agent') 83 ->with('123') 84 ->andReturn('Chrome Web'); 88 85 $this->getChargeTest($this->obj); 89 86 } -
omise/tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-ocbc-pao-test.php
r2979883 r3021743 27 27 public function testCharge() 28 28 { 29 Brain\Monkey\Functions\expect('wc_get_user_agent') 30 ->with('123') 31 ->andReturn('Chrome Web'); 29 32 $this->getChargeTest($this->obj); 30 33 } -
omise/tags/5.7.0/tests/unit/includes/gateway/class-omise-payment-truemoney-test.php
r2979883 r3021743 5 5 class Omise_Payment_Truemoney_Test extends Omise_Offsite_Test 6 6 { 7 private $omise_capability_mock; 8 7 9 public function setUp(): void 8 10 { 9 11 $this->sourceType = 'truemoney'; 10 12 parent::setUp(); 13 Brain\Monkey\Functions\expect('is_admin') 14 ->with('123') 15 ->andReturn(true); 16 Brain\Monkey\Functions\expect('is_checkout') 17 ->with('123') 18 ->andReturn(true); 19 Brain\Monkey\Functions\expect('is_wc_endpoint_url') 20 ->with('123') 21 ->andReturn(true); 11 22 require_once __DIR__ . '/../../../../includes/gateway/class-omise-payment-truemoney.php'; 23 $this->omise_capability_mock = Mockery::mock('alias:Omise_Capabilities'); 12 24 } 13 25 14 public function test GetChargeRequest()26 public function test_get_charge_request() 15 27 { 28 $this->omise_capability_mock->shouldReceive('retrieve')->once(); 29 // set source type to truemoney wallet 16 30 $obj = new Omise_Payment_Truemoney(); 17 18 $order Id = 'order_123';19 $expected Amount = 999999;20 $expected Currency = 'thb';21 $order Mock = $this->getOrderMock($expectedAmount, $expectedCurrency);31 $obj->source_type = 'truemoney'; 32 $order_id = 'order_123'; 33 $expected_amount = 999999; 34 $expected_currency = 'thb'; 35 $order_mock = $this->getOrderMock($expected_amount, $expected_currency); 22 36 23 37 $_POST['omise_phone_number_default'] = true; 24 $result = $obj->get_charge_request($order Id, $orderMock);38 $result = $obj->get_charge_request($order_id, $order_mock); 25 39 26 $this->assertEquals($orderMock->get_billing_phone(), $result['source']['phone_number']); 27 28 unset($_POST['omise_phone_number_default']); 29 unset($obj); 40 $this->assertEquals($order_mock->get_billing_phone(), $result['source']['phone_number']); 30 41 } 31 42 32 public function test GetChargeRequestWhenCustomerOverridesDefaultPhone()43 public function test_get_charge_request_when_customer_overrides_default_phone() 33 44 { 45 $this->omise_capability_mock->shouldReceive('retrieve')->once(); 46 $order_id = 'order_123'; 47 $expected_amount = 999999; 48 $expected_currency = 'thb'; 49 $order_mock = $this->getOrderMock($expected_amount, $expected_currency); 50 51 $_POST['omise_phone_number'] = '1234567890'; 52 34 53 $obj = new Omise_Payment_Truemoney(); 35 36 $orderId = 'order_123'; 37 $expectedAmount = 999999; 38 $expectedCurrency = 'thb'; 39 $orderMock = $this->getOrderMock($expectedAmount, $expectedCurrency); 40 41 $_POST['omise_phone_number_default'] = false; 42 $_POST['omise_phone_number'] = '1234567890'; 43 44 $result = $obj->get_charge_request($orderId, $orderMock); 54 $result = $obj->get_charge_request($order_id, $order_mock); 45 55 46 56 $this->assertEquals($this->sourceType, $result['source']['type']); 47 57 } 48 58 49 public function test Charge()59 public function test_charge() 50 60 { 61 $this->omise_capability_mock->shouldReceive('retrieve')->once(); 51 62 $_POST['omise_phone_number_default'] = true; 52 63 $obj = new Omise_Payment_Truemoney(); 53 64 $this->getChargeTest($obj); 54 65 } 66 67 public function test_get_source_returns_jumpapp() 68 { 69 $this->omise_capability_mock->shouldReceive('retrieve'); 70 $obj = new Omise_Payment_Truemoney(); 71 $source_type = $obj->get_source(); 72 $this->assertEquals('truemoney_jumpapp', $source_type); 73 } 74 75 public function test_get_source_returns_wallet() 76 { 77 $this->omise_capability_mock->shouldReceive('retrieve') 78 ->andReturn(new class() { 79 public function get_truemoney_backend($source_type) { 80 if ('truemoney' === $source_type) { 81 return (object)[ 82 'truemoney' => [ 83 'type' => 'truemoney', 84 'currencies' => [ 85 'thb' 86 ], 87 'amount' => [ 88 'min' => 2000, 89 'max' => 500000000000 90 ] 91 ] 92 ]; 93 } 94 95 return null; 96 } 97 }); 98 99 $obj = new Omise_Payment_Truemoney(); 100 $source_type = $obj->get_source(); 101 $this->assertEquals('truemoney', $source_type); 102 } 103 104 public function test_get_source_returns_jumpapp_when_both_are_enabled() 105 { 106 $this->omise_capability_mock->shouldReceive('retrieve') 107 ->andReturn(new class() { 108 public function get_truemoney_backend($source_type) { 109 if ('truemoney' === $source_type) { 110 return (object)[ 111 'truemoney' => [ 112 'type' => 'truemoney', 113 'currencies' => [ 114 'thb' 115 ], 116 'amount' => [ 117 'min' => 2000, 118 'max' => 500000000000 119 ] 120 ] 121 ]; 122 } 123 124 return (object)[ 125 'truemoney_jumpapp' => [ 126 'type' => 'truemoney_jumpapp', 127 'currencies' => [ 128 'thb' 129 ], 130 'amount' => [ 131 'min' => 2000, 132 'max' => 500000000000 133 ] 134 ] 135 ]; 136 } 137 }); 138 139 $obj = new Omise_Payment_Truemoney(); 140 $source_type = $obj->get_source(); 141 $this->assertEquals('truemoney_jumpapp', $source_type); 142 } 55 143 } -
omise/trunk/CHANGELOG.md
r3006639 r3021743 1 1 # CHANGELOG 2 3 ## [v5.7.0 _(Jan 11, 2024)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.7.0) 4 - Added TrueMoney jumpapp. (PR [#431](https://github.com/omise/omise-woocommerce/pull/431)) 5 - Updated README.md. (PR [#429](https://github.com/omise/omise-woocommerce/pull/429)) 2 6 3 7 ## [v5.6.2 _(Dec 7, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.6.2) -
omise/trunk/README.md
r2501457 r3021743 1 1 <!--- KEEP START ---> 2 [](https://www.omise.co/developers)2 [](https://www.opn.ooo) 3 3 4 [O mise](https://www.omise.co/) is a payment service provider operating in Thailand, Japan, and Singapore.5 O miseprovides a set of APIs that help merchants of any size accept payments online.4 [Opn Payments](https://www.opn.ooo) is a payment service provider operating in Thailand, Japan, and Singapore. 5 Opn Payments provides a set of APIs that help merchants of any size accept payments online. 6 6 <!--- KEEP END ---> 7 7 8 **Omise WooCommerce** is our official plugin providing support for processing payments on WooCommerce through Omise. 9 10  8 **Omise WooCommerce** is our official plugin providing support for processing payments on WooCommerce through Opn Payments. 11 9 12 10 ## Usage 13 11 14 See our [official docs](https:// www.omise.co/woocommerce-plugin) for details on installation and configuration.12 See our [official docs](https://docs.opn.ooo/woocommerce-plugin) for details on installation and configuration. 15 13 16 14 ## Contributing -
omise/trunk/includes/class-omise-capabilities.php
r2962817 r3021743 252 252 return $this->capabilities['limits']['installment_amount']['min']; 253 253 } 254 255 /** 256 * Retrieves details of TrueMoney from capabilities. 257 * 258 * @param string $source_type 259 */ 260 public function get_truemoney_backend($source_type) 261 { 262 $truemoney_source_types = [Omise_Payment_Truemoney::WALLET, Omise_Payment_Truemoney::JUMPAPP]; 263 264 if (!in_array($source_type, $truemoney_source_types)) { 265 return null; 266 } 267 268 return $this->getBackendByType($source_type); 269 } 254 270 } -
omise/trunk/includes/gateway/class-omise-payment-truemoney.php
r2979883 r3021743 7 7 class Omise_Payment_Truemoney extends Omise_Payment_Offsite 8 8 { 9 /** 10 * Backends identifier 11 * @var string 12 */ 13 const WALLET = 'truemoney'; 14 const JUMPAPP = 'truemoney_jumpapp'; 15 9 16 public function __construct() 10 17 { … … 13 20 $this->id = 'omise_truemoney'; 14 21 $this->has_fields = true; 15 $this->method_title = __( 'Opn Payments TrueMoney Wallet', 'omise' );22 $this->method_title = __( 'Opn Payments TrueMoney', 'omise' ); 16 23 $this->method_description = wp_kses( 17 __( 'Accept payments through <strong>TrueMoney Wallet</strong> via Opn Payments payment gateway (only available in Thailand).', 'omise' ),24 __( 'Accept payments through <strong>TrueMoney</strong> via Opn Payments payment gateway (only available in Thailand).', 'omise' ), 18 25 array( 'strong' => array() ) 19 26 ); … … 27 34 $this->description = $this->get_option( 'description' ); 28 35 $this->restricted_countries = array( 'TH' ); 29 $this->source_type = 'truemoney';36 $this->source_type = $this->get_source(); 30 37 31 38 add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); … … 44 51 'title' => __( 'Enable/Disable', 'omise' ), 45 52 'type' => 'checkbox', 46 'label' => __( 'Enable Opn Payments TrueMoney WalletPayment', 'omise' ),53 'label' => __( 'Enable Opn Payments TrueMoney Payment', 'omise' ), 47 54 'default' => 'no' 48 55 ), … … 52 59 'type' => 'text', 53 60 'description' => __( 'This controls the title the user sees during checkout.', 'omise' ), 54 'default' => __( 'TrueMoney Wallet', 'omise' ),61 'default' => __( 'TrueMoney', 'omise' ), 55 62 ), 56 63 … … 69 76 { 70 77 parent::payment_fields(); 71 Omise_Util::render_view( 'templates/payment/form-truemoney.php', array() ); 78 if (self::WALLET === $this->source_type) { 79 Omise_Util::render_view( 'templates/payment/form-truemoney.php', [] ); 80 } 72 81 } 73 82 … … 83 92 public function get_charge_request($order_id, $order) 84 93 { 85 $phoneOption = $_POST['omise_phone_number_default']; 86 $isPhoneOptionChecked = isset($phoneOption) && 1 == $phoneOption; 87 $phone_number = $isPhoneOptionChecked ? 88 $order->get_billing_phone() : 89 sanitize_text_field( $_POST['omise_phone_number'] ); 90 91 $requestData = $this->build_charge_request( 94 $request_data = $this->build_charge_request( 92 95 $order_id, 93 96 $order, … … 95 98 $this->id . '_callback' 96 99 ); 97 $requestData['source'] = array_merge($requestData['source'], [98 'phone_number' => $phone_number99 ]);100 100 101 return $requestData; 101 if (self::WALLET === $this->source_type) { 102 $phone_option = $_POST['omise_phone_number_default']; 103 $is_phone_option_checked = isset($phone_option) && 1 == $phone_option; 104 $phone_number = $is_phone_option_checked ? 105 $order->get_billing_phone() : 106 sanitize_text_field( $_POST['omise_phone_number'] ); 107 108 $request_data['source'] = array_merge($request_data['source'], [ 109 'phone_number' => $phone_number 110 ]); 111 } 112 113 return $request_data; 114 } 115 116 /** 117 * Return the right ShopeePay backend depending on the platform and availability of 118 * the backend in the capability 119 */ 120 public function get_source() 121 { 122 $capabilities = Omise_Capabilities::retrieve(); 123 124 if (!$capabilities) { 125 return self::JUMPAPP; 126 } 127 128 $is_jumpapp_enabled = $capabilities->get_truemoney_backend(self::JUMPAPP); 129 $is_wallet_enabled = $capabilities->get_truemoney_backend(self::WALLET); 130 131 if (!empty($is_wallet_enabled) && empty($is_jumpapp_enabled)) { 132 return self::WALLET; 133 } 134 135 // Return JUMP APP for the following cases: 136 // Case 1: Both jumpapp and wallet are enabled 137 // Case 2: jumpapp is enabled and wallet is disabled 138 // Case 3: Both are disabled. 139 return self::JUMPAPP; 102 140 } 103 141 } -
omise/trunk/omise-woocommerce.php
r3006639 r3021743 5 5 * Plugin URI: https://www.omise.co/woocommerce 6 6 * 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. 7 * Version: 5. 6.27 * Version: 5.7.0 8 8 * Author: Opn Payments and contributors 9 9 * Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors … … 23 23 * @var string 24 24 */ 25 public $version = '5. 6.2';25 public $version = '5.7.0'; 26 26 27 27 /** -
omise/trunk/readme.txt
r3006639 r3021743 1 1 === Opn Payments === 2 2 Contributors: Opn Payments 3 Tags: opn payments, payment, payment gateway, woocommerce plugin, omise, opn, installment, internet banking, alipay, paynow, truemoney wallet, woocommerce payment3 Tags: opn payments, payment, payment gateway, woocommerce plugin, omise, opn, installment, internet banking, alipay, paynow, truemoney, woocommerce payment 4 4 Requires at least: 4.3.1 5 5 Tested up to: 6.4.2 6 Stable tag: 5. 6.26 Stable tag: 5.7.0 7 7 License: MIT 8 8 License URI: https://opensource.org/licenses/MIT … … 34 34 35 35 == Changelog == 36 37 = 5.7.0 = 38 39 - Added TrueMoney jumpapp. (PR [#431](https://github.com/omise/omise-woocommerce/pull/431)) 40 - Updated README.md. (PR [#429](https://github.com/omise/omise-woocommerce/pull/429)) 36 41 37 42 = 5.6.2 = -
omise/trunk/tests/unit/includes/class-omise-capabilities-test.php
r2962817 r3021743 1 1 <?php 2 2 3 use PHPUnit\Framework\TestCase;3 require_once __DIR__ . '/gateway/bootstrap-test-setup.php'; 4 4 5 class Omise_Capabilities_Test extends TestCase 5 /** 6 * @runTestsInSeparateProcesses 7 */ 8 class Omise_Capabilities_Test extends Bootstrap_Test_Setup 6 9 { 7 10 private $omiseSettingMock; … … 14 17 public function setUp(): void 15 18 { 19 parent::setUp(); 20 21 Mockery::mock('Omise_Payment_Offsite'); 16 22 require_once __DIR__ . '/../../../includes/class-omise-capabilities.php'; 23 require_once __DIR__ . '/../../../includes/gateway/class-omise-payment-truemoney.php'; 17 24 $this->omiseSettingMock = Mockery::mock('alias:Omise_Setting'); 18 25 $this->omiseCapabilitiesMock = Mockery::mock('alias:OmiseCapabilities'); … … 20 27 21 28 /** 22 * close mockery after test cases are done23 */24 public function tearDown(): void25 {26 Mockery::close();27 }28 29 /**30 29 * @dataProvider retrieve_data_provider 31 * @runInSeparateProcess32 30 * @covers Omise_Capabilities 33 31 */ 34 32 public function test_retrieve_should_return_value_when_it_should_call_api($isCheckout, $isThankYouPage, $isAdmin, $adminPageName, $expected) 35 { 33 { 36 34 // assigning to global variable, so that we can use in child functions 37 35 $GLOBALS['isCheckout'] = $isCheckout; … … 42 40 $_GET['page'] = $adminPageName; 43 41 44 function is_checkout() { return $GLOBALS['isCheckout']; } 45 function is_wc_endpoint_url($page) { return $GLOBALS['isThankYouPage']; } 46 function is_admin() { return $GLOBALS['isAdmin']; } 42 Brain\Monkey\Functions\expect('is_admin') 43 ->with('123') 44 ->andReturn($GLOBALS['isAdmin']); 45 Brain\Monkey\Functions\expect('is_checkout') 46 ->with('123') 47 ->andReturn($GLOBALS['isCheckout']); 48 Brain\Monkey\Functions\expect('is_wc_endpoint_url') 49 ->with('123') 50 ->andReturn($GLOBALS['isThankYouPage']); 47 51 48 52 if ($expected) { … … 67 71 // checkout page and not thank you page 68 72 [true, false, false, '', true], 69 // //checkout page and also thank you page73 // checkout page and also thank you page 70 74 [true, true, false, '', false], 71 // //omise setting page75 // omise setting page 72 76 [true, true, true, 'omise', true], 73 // //other admin page77 // other admin page 74 78 [true, true, true, 'other-page', false], 75 // //non checkout page and also no-admin page79 // non checkout page and also no-admin page 76 80 [false, false, false, 'other-page', false], 77 // //non checkout page, non admin page81 // non checkout page, non admin page 78 82 [false, false, false, '', false], 79 83 ]; 80 84 } 85 86 /** 87 * @test 88 */ 89 public function test_get_truemoney_backend_returns_null_when_invalid_payment_is_passed() 90 { 91 Brain\Monkey\Functions\expect('is_admin') 92 ->with('123') 93 ->andReturn(true); 94 95 Brain\Monkey\Functions\expect('is_checkout') 96 ->with('123') 97 ->andReturn(true); 98 99 Brain\Monkey\Functions\expect('is_wc_endpoint_url') 100 ->with('123') 101 ->andReturn(false); 102 103 $capabilities = new Omise_Capabilities; 104 $is_enabled = $capabilities->get_truemoney_backend('abc'); 105 $this->assertNull($is_enabled); 106 } 107 108 public function truemoney_source_provider() 109 { 110 return [ ['abc', false], ['truemoney', true], ['truemoney_jumpapp', true] ]; 111 } 81 112 } 113 114 class Omise_Payment_Truemoney_Stub 115 { 116 /** 117 * Backends identifier 118 * @var string 119 */ 120 const WALLET = 'truemoney'; 121 const JUMPAPP = 'truemoney_jumpapp'; 122 } -
omise/trunk/tests/unit/includes/gateway/bootstrap-test-setup.php
r2996251 r3021743 2 2 3 3 use PHPUnit\Framework\TestCase; 4 use Brain; 4 5 5 6 6 abstract class Bootstrap_Test_Setup extends TestCase -
omise/trunk/tests/unit/includes/gateway/class-omise-payment-alipayplus-hk-test.php
r2979883 r3021743 3 3 require_once __DIR__ . '/class-omise-offsite-test.php'; 4 4 5 /** 6 * @runTestsInSeparateProcesses 7 */ 5 8 class Omise_Payment_Alipay_Hk_Test extends Omise_Offsite_Test 6 9 { -
omise/trunk/tests/unit/includes/gateway/class-omise-payment-alipayplus-kakaopay-test.php
r2979883 r3021743 3 3 require_once __DIR__ . '/class-omise-offsite-test.php'; 4 4 5 /** 6 * @runTestsInSeparateProcesses 7 */ 5 8 class Omise_Payment_Kakaopay_Test extends Omise_Offsite_Test 6 9 { -
omise/trunk/tests/unit/includes/gateway/class-omise-payment-creditcard-test.php
r2996251 r3021743 2 2 3 3 use PHPUnit\Framework\TestCase; 4 use Brain;5 4 6 5 class Omise_Payment_CreditCard_Test extends TestCase -
omise/trunk/tests/unit/includes/gateway/class-omise-payment-mobilebanking-test.php
r2979883 r3021743 14 14 public function testCharge() 15 15 { 16 Brain\Monkey\Functions\expect('wc_get_user_agent') 17 ->with('123') 18 ->andReturn('Chrome Web'); 16 19 $_POST['omise-offsite'] = 'mobile_banking_bbl'; 17 20 $obj = new Omise_Payment_Mobilebanking(); -
omise/trunk/tests/unit/includes/gateway/class-omise-payment-ocbc-digital-test.php
r3006639 r3021743 19 19 function plugins_url() { 20 20 return "http://localhost"; 21 }22 }23 24 if (!function_exists('wc_get_user_agent')) {25 function wc_get_user_agent() {26 return "Chrome Web";27 21 } 28 22 } … … 86 80 public function testCharge() 87 81 { 82 Brain\Monkey\Functions\expect('wc_get_user_agent') 83 ->with('123') 84 ->andReturn('Chrome Web'); 88 85 $this->getChargeTest($this->obj); 89 86 } -
omise/trunk/tests/unit/includes/gateway/class-omise-payment-ocbc-pao-test.php
r2979883 r3021743 27 27 public function testCharge() 28 28 { 29 Brain\Monkey\Functions\expect('wc_get_user_agent') 30 ->with('123') 31 ->andReturn('Chrome Web'); 29 32 $this->getChargeTest($this->obj); 30 33 } -
omise/trunk/tests/unit/includes/gateway/class-omise-payment-truemoney-test.php
r2979883 r3021743 5 5 class Omise_Payment_Truemoney_Test extends Omise_Offsite_Test 6 6 { 7 private $omise_capability_mock; 8 7 9 public function setUp(): void 8 10 { 9 11 $this->sourceType = 'truemoney'; 10 12 parent::setUp(); 13 Brain\Monkey\Functions\expect('is_admin') 14 ->with('123') 15 ->andReturn(true); 16 Brain\Monkey\Functions\expect('is_checkout') 17 ->with('123') 18 ->andReturn(true); 19 Brain\Monkey\Functions\expect('is_wc_endpoint_url') 20 ->with('123') 21 ->andReturn(true); 11 22 require_once __DIR__ . '/../../../../includes/gateway/class-omise-payment-truemoney.php'; 23 $this->omise_capability_mock = Mockery::mock('alias:Omise_Capabilities'); 12 24 } 13 25 14 public function test GetChargeRequest()26 public function test_get_charge_request() 15 27 { 28 $this->omise_capability_mock->shouldReceive('retrieve')->once(); 29 // set source type to truemoney wallet 16 30 $obj = new Omise_Payment_Truemoney(); 17 18 $order Id = 'order_123';19 $expected Amount = 999999;20 $expected Currency = 'thb';21 $order Mock = $this->getOrderMock($expectedAmount, $expectedCurrency);31 $obj->source_type = 'truemoney'; 32 $order_id = 'order_123'; 33 $expected_amount = 999999; 34 $expected_currency = 'thb'; 35 $order_mock = $this->getOrderMock($expected_amount, $expected_currency); 22 36 23 37 $_POST['omise_phone_number_default'] = true; 24 $result = $obj->get_charge_request($order Id, $orderMock);38 $result = $obj->get_charge_request($order_id, $order_mock); 25 39 26 $this->assertEquals($orderMock->get_billing_phone(), $result['source']['phone_number']); 27 28 unset($_POST['omise_phone_number_default']); 29 unset($obj); 40 $this->assertEquals($order_mock->get_billing_phone(), $result['source']['phone_number']); 30 41 } 31 42 32 public function test GetChargeRequestWhenCustomerOverridesDefaultPhone()43 public function test_get_charge_request_when_customer_overrides_default_phone() 33 44 { 45 $this->omise_capability_mock->shouldReceive('retrieve')->once(); 46 $order_id = 'order_123'; 47 $expected_amount = 999999; 48 $expected_currency = 'thb'; 49 $order_mock = $this->getOrderMock($expected_amount, $expected_currency); 50 51 $_POST['omise_phone_number'] = '1234567890'; 52 34 53 $obj = new Omise_Payment_Truemoney(); 35 36 $orderId = 'order_123'; 37 $expectedAmount = 999999; 38 $expectedCurrency = 'thb'; 39 $orderMock = $this->getOrderMock($expectedAmount, $expectedCurrency); 40 41 $_POST['omise_phone_number_default'] = false; 42 $_POST['omise_phone_number'] = '1234567890'; 43 44 $result = $obj->get_charge_request($orderId, $orderMock); 54 $result = $obj->get_charge_request($order_id, $order_mock); 45 55 46 56 $this->assertEquals($this->sourceType, $result['source']['type']); 47 57 } 48 58 49 public function test Charge()59 public function test_charge() 50 60 { 61 $this->omise_capability_mock->shouldReceive('retrieve')->once(); 51 62 $_POST['omise_phone_number_default'] = true; 52 63 $obj = new Omise_Payment_Truemoney(); 53 64 $this->getChargeTest($obj); 54 65 } 66 67 public function test_get_source_returns_jumpapp() 68 { 69 $this->omise_capability_mock->shouldReceive('retrieve'); 70 $obj = new Omise_Payment_Truemoney(); 71 $source_type = $obj->get_source(); 72 $this->assertEquals('truemoney_jumpapp', $source_type); 73 } 74 75 public function test_get_source_returns_wallet() 76 { 77 $this->omise_capability_mock->shouldReceive('retrieve') 78 ->andReturn(new class() { 79 public function get_truemoney_backend($source_type) { 80 if ('truemoney' === $source_type) { 81 return (object)[ 82 'truemoney' => [ 83 'type' => 'truemoney', 84 'currencies' => [ 85 'thb' 86 ], 87 'amount' => [ 88 'min' => 2000, 89 'max' => 500000000000 90 ] 91 ] 92 ]; 93 } 94 95 return null; 96 } 97 }); 98 99 $obj = new Omise_Payment_Truemoney(); 100 $source_type = $obj->get_source(); 101 $this->assertEquals('truemoney', $source_type); 102 } 103 104 public function test_get_source_returns_jumpapp_when_both_are_enabled() 105 { 106 $this->omise_capability_mock->shouldReceive('retrieve') 107 ->andReturn(new class() { 108 public function get_truemoney_backend($source_type) { 109 if ('truemoney' === $source_type) { 110 return (object)[ 111 'truemoney' => [ 112 'type' => 'truemoney', 113 'currencies' => [ 114 'thb' 115 ], 116 'amount' => [ 117 'min' => 2000, 118 'max' => 500000000000 119 ] 120 ] 121 ]; 122 } 123 124 return (object)[ 125 'truemoney_jumpapp' => [ 126 'type' => 'truemoney_jumpapp', 127 'currencies' => [ 128 'thb' 129 ], 130 'amount' => [ 131 'min' => 2000, 132 'max' => 500000000000 133 ] 134 ] 135 ]; 136 } 137 }); 138 139 $obj = new Omise_Payment_Truemoney(); 140 $source_type = $obj->get_source(); 141 $this->assertEquals('truemoney_jumpapp', $source_type); 142 } 55 143 }
Note: See TracChangeset
for help on using the changeset viewer.