Changeset 2785289
- Timestamp:
- 09/15/2022 11:37:02 AM (3 years ago)
- Location:
- omise
- Files:
-
- 10 edited
- 1 copied
-
tags/4.24.1 (copied) (copied from omise/trunk)
-
tags/4.24.1/CHANGELOG.md (modified) (1 diff)
-
tags/4.24.1/includes/class-omise-capabilities.php (modified) (3 diffs)
-
tags/4.24.1/omise-woocommerce.php (modified) (2 diffs)
-
tags/4.24.1/readme.txt (modified) (2 diffs)
-
tags/4.24.1/tests/unit/includes/class-omise-money-test.php (modified) (1 diff)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/includes/class-omise-capabilities.php (modified) (3 diffs)
-
trunk/omise-woocommerce.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/tests/unit/includes/class-omise-money-test.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
omise/tags/4.24.1/CHANGELOG.md
r2783685 r2785289 1 1 # CHANGELOG 2 3 ### [v4.24.1 _(Sep 15, 2022)_](https://github.com/omise/omise-woocommerce/releases/tag/v4.24.1) 4 - Fix the issue of user unable to set new keys when their old keys are expired. (PR [#311](https://github.com/omise/omise-woocommerce/pull/311)) 2 5 3 6 ### [v4.24.0 _(Sep 7, 2022)_](https://github.com/omise/omise-woocommerce/releases/tag/v4.24.0) -
omise/tags/4.24.1/includes/class-omise-capabilities.php
r2783685 r2785289 40 40 $secretKey = !$sKey ? $settings->secret_key() : $sKey; 41 41 42 $keys = self::getKeys($pKey, $sKey); 43 42 44 // Do not call capabilities API if keys are not present 43 if(empty($ publicKey) || empty($secretKey)) {45 if(empty($keys['public']) || empty($keys['secret'])) { 44 46 return null; 45 47 } 46 48 47 49 if(self::$instance) { 48 $keysNotChanged = self::$instance->publicKey === $ publicKey && self::$instance->secretKey === $secretKey;50 $keysNotChanged = self::$instance->publicKey === $keys['public'] && self::$instance->secretKey === $keys['secret']; 49 51 50 52 // if keys are same then we return the previous instance without calling … … 57 59 58 60 try { 59 $capabilities = OmiseCapabilities::retrieve( $ publicKey , $secretKey);61 $capabilities = OmiseCapabilities::retrieve( $keys['public'] , $keys['secret'] ); 60 62 } catch(\Exception $e) { 61 63 // logging the error and suppressing error on the admin dashboard … … 66 68 self::$instance = new self(); 67 69 self::$instance->capabilities = $capabilities; 68 self::$instance->publicKey = $ publicKey;69 self::$instance->secretKey = $ secretKey;70 self::$instance->publicKey = $keys['public']; 71 self::$instance->secretKey = $keys['secret']; 70 72 return self::$instance; 73 } 74 75 /** 76 * @param string|null $pKey 77 * @param string|null $sKey 78 */ 79 private static function getKeys($pKey = null, $sKey = null) 80 { 81 $settings = Omise_Setting::instance(); 82 83 // Check if user has submitted a form 84 if ( ! empty( $_POST ) && isset($_POST['sandbox']) && isset($_POST['test_public_key']) ) { 85 return self::getUserEnteredKeys(); 86 } 87 88 return [ 89 'public' => !$pKey ? $settings->public_key() : $pKey, 90 'secret' => !$sKey ? $settings->secret_key() : $sKey 91 ]; 92 } 93 94 /** 95 * We have many classes that calls capabilities API before the user entered keys are saved. 96 * This means they will use the old saved keys instead of new user entered keys. This will 97 * cause issues like: 98 * - 401 unauthorized access 99 * - Expired keys 100 * - Others 101 * 102 * To avoid such issue we first get the user entered keys from $_POST so that other classes calls the 103 * capabilities API from the user entered keys. 104 */ 105 private static function getUserEnteredKeys() 106 { 107 if ( 108 ! isset( $_POST['omise_setting_page_nonce'] ) || 109 ! wp_verify_nonce( $_POST['omise_setting_page_nonce'], 'omise-setting' ) 110 ) { 111 wp_die( __( 'You are not allowed to modify the settings from a suspicious source.', 'omise' ) ); 112 } 113 114 return [ 115 'public' => isset( $_POST['sandbox'] ) ? 116 sanitize_text_field($_POST['test_public_key']) : 117 sanitize_text_field($_POST['live_public_key']), 118 'secret' => isset( $_POST['sandbox'] ) ? 119 sanitize_text_field($_POST['test_private_key']) : 120 sanitize_text_field($_POST['live_private_key']) 121 ]; 71 122 } 72 123 -
omise/tags/4.24.1/omise-woocommerce.php
r2783685 r2785289 4 4 * Plugin URI: https://www.omise.co/woocommerce 5 5 * Description: Omise WooCommerce Gateway Plugin is a WordPress plugin designed specifically for WooCommerce. The plugin adds support for Omise Payment Gateway payment method to WooCommerce. 6 * Version: 4.24. 06 * Version: 4.24.1 7 7 * Author: Omise and contributors 8 8 * Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors … … 21 21 * @var string 22 22 */ 23 public $version = '4.24. 0';23 public $version = '4.24.1'; 24 24 25 25 /** -
omise/tags/4.24.1/readme.txt
r2783685 r2785289 4 4 Requires at least: 4.3.1 5 5 Tested up to: 6.0.2 6 Stable tag: 4.24. 06 Stable tag: 4.24.1 7 7 License: MIT 8 8 License URI: https://opensource.org/licenses/MIT … … 33 33 34 34 == Changelog == 35 36 = 4.24.1 = 37 38 #### 👾 Bug Fixes 39 - Fix the issue of user unable to set new keys when their old keys are expired. (PR [#311](https://github.com/omise/omise-woocommerce/pull/311)) 35 40 36 41 = 4.24.0 = -
omise/tags/4.24.1/tests/unit/includes/class-omise-money-test.php
r2501457 r2785289 32 32 */ 33 33 public function convert_amount_with_4_decimal_points() { 34 $amount = 4780.040 9;35 $currency = 'thb'; 36 37 $this->assertEquals( 478004.09, Omise_Money::to_subunit( $amount, $currency ));34 $amount = 4780.0405; 35 $currency = 'thb'; 36 37 $this->assertEquals(478004.05, Omise_Money::to_subunit( $amount, $currency )); 38 38 } 39 39 -
omise/trunk/CHANGELOG.md
r2783685 r2785289 1 1 # CHANGELOG 2 3 ### [v4.24.1 _(Sep 15, 2022)_](https://github.com/omise/omise-woocommerce/releases/tag/v4.24.1) 4 - Fix the issue of user unable to set new keys when their old keys are expired. (PR [#311](https://github.com/omise/omise-woocommerce/pull/311)) 2 5 3 6 ### [v4.24.0 _(Sep 7, 2022)_](https://github.com/omise/omise-woocommerce/releases/tag/v4.24.0) -
omise/trunk/includes/class-omise-capabilities.php
r2783685 r2785289 40 40 $secretKey = !$sKey ? $settings->secret_key() : $sKey; 41 41 42 $keys = self::getKeys($pKey, $sKey); 43 42 44 // Do not call capabilities API if keys are not present 43 if(empty($ publicKey) || empty($secretKey)) {45 if(empty($keys['public']) || empty($keys['secret'])) { 44 46 return null; 45 47 } 46 48 47 49 if(self::$instance) { 48 $keysNotChanged = self::$instance->publicKey === $ publicKey && self::$instance->secretKey === $secretKey;50 $keysNotChanged = self::$instance->publicKey === $keys['public'] && self::$instance->secretKey === $keys['secret']; 49 51 50 52 // if keys are same then we return the previous instance without calling … … 57 59 58 60 try { 59 $capabilities = OmiseCapabilities::retrieve( $ publicKey , $secretKey);61 $capabilities = OmiseCapabilities::retrieve( $keys['public'] , $keys['secret'] ); 60 62 } catch(\Exception $e) { 61 63 // logging the error and suppressing error on the admin dashboard … … 66 68 self::$instance = new self(); 67 69 self::$instance->capabilities = $capabilities; 68 self::$instance->publicKey = $ publicKey;69 self::$instance->secretKey = $ secretKey;70 self::$instance->publicKey = $keys['public']; 71 self::$instance->secretKey = $keys['secret']; 70 72 return self::$instance; 73 } 74 75 /** 76 * @param string|null $pKey 77 * @param string|null $sKey 78 */ 79 private static function getKeys($pKey = null, $sKey = null) 80 { 81 $settings = Omise_Setting::instance(); 82 83 // Check if user has submitted a form 84 if ( ! empty( $_POST ) && isset($_POST['sandbox']) && isset($_POST['test_public_key']) ) { 85 return self::getUserEnteredKeys(); 86 } 87 88 return [ 89 'public' => !$pKey ? $settings->public_key() : $pKey, 90 'secret' => !$sKey ? $settings->secret_key() : $sKey 91 ]; 92 } 93 94 /** 95 * We have many classes that calls capabilities API before the user entered keys are saved. 96 * This means they will use the old saved keys instead of new user entered keys. This will 97 * cause issues like: 98 * - 401 unauthorized access 99 * - Expired keys 100 * - Others 101 * 102 * To avoid such issue we first get the user entered keys from $_POST so that other classes calls the 103 * capabilities API from the user entered keys. 104 */ 105 private static function getUserEnteredKeys() 106 { 107 if ( 108 ! isset( $_POST['omise_setting_page_nonce'] ) || 109 ! wp_verify_nonce( $_POST['omise_setting_page_nonce'], 'omise-setting' ) 110 ) { 111 wp_die( __( 'You are not allowed to modify the settings from a suspicious source.', 'omise' ) ); 112 } 113 114 return [ 115 'public' => isset( $_POST['sandbox'] ) ? 116 sanitize_text_field($_POST['test_public_key']) : 117 sanitize_text_field($_POST['live_public_key']), 118 'secret' => isset( $_POST['sandbox'] ) ? 119 sanitize_text_field($_POST['test_private_key']) : 120 sanitize_text_field($_POST['live_private_key']) 121 ]; 71 122 } 72 123 -
omise/trunk/omise-woocommerce.php
r2783685 r2785289 4 4 * Plugin URI: https://www.omise.co/woocommerce 5 5 * Description: Omise WooCommerce Gateway Plugin is a WordPress plugin designed specifically for WooCommerce. The plugin adds support for Omise Payment Gateway payment method to WooCommerce. 6 * Version: 4.24. 06 * Version: 4.24.1 7 7 * Author: Omise and contributors 8 8 * Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors … … 21 21 * @var string 22 22 */ 23 public $version = '4.24. 0';23 public $version = '4.24.1'; 24 24 25 25 /** -
omise/trunk/readme.txt
r2783685 r2785289 4 4 Requires at least: 4.3.1 5 5 Tested up to: 6.0.2 6 Stable tag: 4.24. 06 Stable tag: 4.24.1 7 7 License: MIT 8 8 License URI: https://opensource.org/licenses/MIT … … 33 33 34 34 == Changelog == 35 36 = 4.24.1 = 37 38 #### 👾 Bug Fixes 39 - Fix the issue of user unable to set new keys when their old keys are expired. (PR [#311](https://github.com/omise/omise-woocommerce/pull/311)) 35 40 36 41 = 4.24.0 = -
omise/trunk/tests/unit/includes/class-omise-money-test.php
r2501457 r2785289 32 32 */ 33 33 public function convert_amount_with_4_decimal_points() { 34 $amount = 4780.040 9;35 $currency = 'thb'; 36 37 $this->assertEquals( 478004.09, Omise_Money::to_subunit( $amount, $currency ));34 $amount = 4780.0405; 35 $currency = 'thb'; 36 37 $this->assertEquals(478004.05, Omise_Money::to_subunit( $amount, $currency )); 38 38 } 39 39
Note: See TracChangeset
for help on using the changeset viewer.