Plugin Directory

Changeset 2785289


Ignore:
Timestamp:
09/15/2022 11:37:02 AM (3 years ago)
Author:
omise
Message:

Update to version 4.24.1 from GitHub

Location:
omise
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • omise/tags/4.24.1/CHANGELOG.md

    r2783685 r2785289  
    11# 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))
    25
    36### [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  
    4040        $secretKey = !$sKey ? $settings->secret_key() : $sKey;
    4141
     42        $keys = self::getKeys($pKey, $sKey);
     43
    4244        // Do not call capabilities API if keys are not present
    43         if(empty($publicKey) || empty($secretKey)) {
     45        if(empty($keys['public']) || empty($keys['secret'])) {
    4446            return null;
    4547        }
    4648
    4749        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'];
    4951
    5052            // if keys are same then we return the previous instance without calling
     
    5759
    5860        try {
    59             $capabilities = OmiseCapabilities::retrieve( $publicKey , $secretKey );
     61            $capabilities = OmiseCapabilities::retrieve( $keys['public'] , $keys['secret'] );
    6062        } catch(\Exception $e) {
    6163            // logging the error and suppressing error on the admin dashboard
     
    6668        self::$instance = new self();
    6769        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'];
    7072        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        ];
    71122    }
    72123   
  • omise/tags/4.24.1/omise-woocommerce.php

    r2783685 r2785289  
    44 * Plugin URI:  https://www.omise.co/woocommerce
    55 * 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.0
     6 * Version:     4.24.1
    77 * Author:      Omise and contributors
    88 * Author URI:  https://github.com/omise/omise-woocommerce/graphs/contributors
     
    2121     * @var string
    2222     */
    23     public $version = '4.24.0';
     23    public $version = '4.24.1';
    2424
    2525    /**
  • omise/tags/4.24.1/readme.txt

    r2783685 r2785289  
    44Requires at least: 4.3.1
    55Tested up to: 6.0.2
    6 Stable tag: 4.24.0
     6Stable tag: 4.24.1
    77License: MIT
    88License URI: https://opensource.org/licenses/MIT
     
    3333
    3434== 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))
    3540
    3641= 4.24.0 =
  • omise/tags/4.24.1/tests/unit/includes/class-omise-money-test.php

    r2501457 r2785289  
    3232     */
    3333    public function convert_amount_with_4_decimal_points() {
    34         $amount   = 4780.0409;
    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 ));
    3838    }
    3939
  • omise/trunk/CHANGELOG.md

    r2783685 r2785289  
    11# 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))
    25
    36### [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  
    4040        $secretKey = !$sKey ? $settings->secret_key() : $sKey;
    4141
     42        $keys = self::getKeys($pKey, $sKey);
     43
    4244        // Do not call capabilities API if keys are not present
    43         if(empty($publicKey) || empty($secretKey)) {
     45        if(empty($keys['public']) || empty($keys['secret'])) {
    4446            return null;
    4547        }
    4648
    4749        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'];
    4951
    5052            // if keys are same then we return the previous instance without calling
     
    5759
    5860        try {
    59             $capabilities = OmiseCapabilities::retrieve( $publicKey , $secretKey );
     61            $capabilities = OmiseCapabilities::retrieve( $keys['public'] , $keys['secret'] );
    6062        } catch(\Exception $e) {
    6163            // logging the error and suppressing error on the admin dashboard
     
    6668        self::$instance = new self();
    6769        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'];
    7072        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        ];
    71122    }
    72123   
  • omise/trunk/omise-woocommerce.php

    r2783685 r2785289  
    44 * Plugin URI:  https://www.omise.co/woocommerce
    55 * 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.0
     6 * Version:     4.24.1
    77 * Author:      Omise and contributors
    88 * Author URI:  https://github.com/omise/omise-woocommerce/graphs/contributors
     
    2121     * @var string
    2222     */
    23     public $version = '4.24.0';
     23    public $version = '4.24.1';
    2424
    2525    /**
  • omise/trunk/readme.txt

    r2783685 r2785289  
    44Requires at least: 4.3.1
    55Tested up to: 6.0.2
    6 Stable tag: 4.24.0
     6Stable tag: 4.24.1
    77License: MIT
    88License URI: https://opensource.org/licenses/MIT
     
    3333
    3434== 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))
    3540
    3641= 4.24.0 =
  • omise/trunk/tests/unit/includes/class-omise-money-test.php

    r2501457 r2785289  
    3232     */
    3333    public function convert_amount_with_4_decimal_points() {
    34         $amount   = 4780.0409;
    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 ));
    3838    }
    3939
Note: See TracChangeset for help on using the changeset viewer.