Plugin Directory

Changeset 2925811


Ignore:
Timestamp:
06/14/2023 10:18:29 AM (3 years ago)
Author:
tripleatechnology
Message:

Updating my plugin to 2.0.6 version

Location:
triplea-cryptocurrency-payment-gateway-for-woocommerce
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • triplea-cryptocurrency-payment-gateway-for-woocommerce/tags/2.0.6/includes/WooCommerce/TripleA_Payment_Gateway.php

    r2919181 r2925811  
    591591        }
    592592    }
     593    /**
     594     * Generate new OAuth token if validity expired
     595     */
    593596    private function refreshOauthTokensForForms($refresh_for_api_id = FALSE) {
    594597
    595         $date_now          = (new DateTime())->getTimestamp();
    596         $date_expiry_limit = $date_now - 600;   // 10 minutes before expiry token
    597 
    598         $new_token_data = $this->getOauthToken($this->clientID, $this->clientSecret);
    599         $this->logger->write_log( 'refreshOauthTokensForForms() OAuth token data received : ' . wc_print_r(json_encode($new_token_data), TRUE), $this->debugLog );
    600 
    601         if ($new_token_data !== FALSE
    602             && isset($new_token_data->access_token)
    603             && !empty($new_token_data->access_token)
    604             && isset($new_token_data->expires_in)
    605             && !empty($new_token_data->expires_in)) {
    606             $this->oauthToken       = $new_token_data->access_token;
    607             $this->oauthTokenExpiry = $date_now + $new_token_data->expires_in;
    608             $this->update_option('oauth_token', $this->oauthToken);
    609             $this->update_option('oauth_token_expiry', $this->oauthTokenExpiry);
    610             $this->logger->write_log( 'refreshOauthTokensForForms() Obtained and saved a new oauth token.', $this->debugLog );
    611 
    612             return $new_token_data->access_token;
    613         } else {
    614             $this->logger->write_log( 'refreshOauthTokensForForms() A problem happened, could not get a new oauth token. \n' . wc_print_r(json_encode($new_token_data), TRUE), $this->debugLog );
    615             $this->oauthToken       = NULL;
    616             $this->oauthTokenExpiry = NULL;
    617             $this->update_option('oauth_token', $this->oauthToken);
    618             $this->update_option('oauth_token_expiry', $this->oauthTokenExpiry);
    619 
    620             return false;
    621         }
    622 
     598        $date_now       = (new DateTime())->getTimestamp();
     599        $buffer_time     = 600; // 10 min buffer time, so new token will generated after 50 min
     600        $current_token_expiry   = $this->get_option('oauth_token_expiry');
     601        $current_token   = $this->get_option('oauth_token');
     602
     603        if (isset($this->clientID) && !empty($this->clientID)
     604        && isset($this->clientSecret) && !empty($this->clientSecret)
     605        && (!isset($current_token) || empty($current_token) ||
     606            $date_now >= ( $current_token_expiry - $buffer_time ))
     607        )
     608        {
     609            if ($date_now >= ( $current_token_expiry - $buffer_time)) {
     610                $this->logger->write_log( 'refreshOauthTokensForForms() OAuth token (for local currency settlement) expires in less than 10 minutes. Requesting a new oauth token.', $this->debugLog );
     611            }
     612            else {
     613                $this->logger->write_log( 'refreshOauthTokensForForms() OAuth token (for local currency settlement) is missing. Requesting a new oauth token.', $this->debugLog );
     614            }
     615
     616            $new_token_data = $this->getOauthToken($this->clientID, $this->clientSecret);
     617            $this->logger->write_log( 'refreshOauthTokensForForms() OAuth token data received : ' . wc_print_r(json_encode($new_token_data), TRUE), $this->debugLog );
     618
     619            if ($new_token_data !== FALSE
     620                && isset($new_token_data->access_token)
     621                && !empty($new_token_data->access_token)
     622                && isset($new_token_data->expires_in)
     623                && !empty($new_token_data->expires_in)) {
     624                $this->oauthToken       = $new_token_data->access_token;
     625                $this->oauthTokenExpiry = $date_now + $new_token_data->expires_in;
     626                $this->update_option('oauth_token', $this->oauthToken);
     627                $this->update_option('oauth_token_expiry', $this->oauthTokenExpiry);
     628
     629                $this->logger->write_log( 'refreshOauthTokensForForms() Obtained and saved a new oauth token.', $this->debugLog );
     630
     631                return $new_token_data->access_token;
     632            } else {
     633                $this->logger->write_log( 'refreshOauthTokensForForms() A problem happened, could not get a new oauth token. \n' . wc_print_r(json_encode($new_token_data), TRUE), $this->debugLog );
     634                $this->oauthToken       = NULL;
     635                $this->oauthTokenExpiry = NULL;
     636                $this->update_option('oauth_token', $this->oauthToken);
     637                $this->update_option('oauth_token_expiry', $this->oauthTokenExpiry);
     638
     639                return false;
     640            }
     641        }
     642        else{
     643            if (!isset($this->clientID) || empty($this->clientID)) {
     644                $this->logger->write_log( 'refreshOauthTokensForForms() Client ID is not set ', $this->debugLog );
     645            }
     646            if(!isset($this->clientSecret) ||  empty($this->clientSecret)){
     647                $this->logger->write_log( 'refreshOauthTokensForForms() Client Secret ID is not set ', $this->debugLog );
     648            }
     649            if($date_now < ( $current_token_expiry - $buffer_time )){
     650                $this->logger->write_log( 'refreshOauthTokensForForms() OAuth token (for local currency settlement) is still valid, so not requesting for a new one.', $this->debugLog );
     651            }
     652            return $current_token;
     653        }
    623654    }
    624655    private function getOauthToken( $client_id, $client_secret ) {
     
    671702        $self = new TripleA_Payment_Gateway();
    672703
    673         // Refresh oauth tokens, Actually generating new tokens
     704        // validity checking oauth tokens, if validity expires, create new token.
    674705        $oauth_token = $self->refreshOauthTokensForForms();
    675706
     707        //if token is null or false, aboirt the request
    676708        if (empty($oauth_token)) {
    677709            wp_die('Missing oauth token for cryptocurrency payments with local currency settlement.');
  • triplea-cryptocurrency-payment-gateway-for-woocommerce/tags/2.0.6/readme.txt

    r2919181 r2925811  
    77Requires at least: 5.5
    88Tested up to: 6.1.1
    9 Stable tag: 2.0.5
     9Stable tag: 2.0.6
    1010Requires PHP: 7.0
    1111License: GPLv2 or later
     
    109109== Changelog ==
    110110
     111= 2.0.6 =
     112Fixed: Multiple oAuth token generation request issue while calling the payment form issue fixed
     113
    111114= 2.0.5 =
    112115Fixed: Payment form loading after clicking "Pay with Cryptocurrency" issue fixed
     
    264267== Upgrade Notice ==
    265268
     269= 2.0.6 =
     270Simply install the update. No further action is needed.
     271
    266272= 2.0.5 =
    267273Simply install the update. No further action is needed.
  • triplea-cryptocurrency-payment-gateway-for-woocommerce/tags/2.0.6/triplea-cryptocurrency-payment-gateway-for-woocommerce.php

    r2919181 r2925811  
    1717 * Plugin URI:        https://wordpress.org/plugins/triplea-cryptocurrency-payment-gateway-for-woocommerce/
    1818 * Description:       Offer cryptocurrency as a payment option on your website and get access to even more clients. Receive payments in cryptocurrency or in your local currency, directly in your bank account. Enjoy an easy setup, no cryptocurrency expertise required. Powered by TripleA.
    19  * Version:           2.0.5
     19 * Version:           2.0.6
    2020 * Author:            TripleA Team
    2121 * Author URI:        https://triple-a.io
     
    4545     * $var string
    4646     */
    47     const version = '2.0.5';
     47    const version = '2.0.6';
    4848
    4949    /*
  • triplea-cryptocurrency-payment-gateway-for-woocommerce/trunk/includes/WooCommerce/TripleA_Payment_Gateway.php

    r2919181 r2925811  
    591591        }
    592592    }
     593    /**
     594     * Generate new OAuth token if validity expired
     595     */
    593596    private function refreshOauthTokensForForms($refresh_for_api_id = FALSE) {
    594597
    595         $date_now          = (new DateTime())->getTimestamp();
    596         $date_expiry_limit = $date_now - 600;   // 10 minutes before expiry token
    597 
    598         $new_token_data = $this->getOauthToken($this->clientID, $this->clientSecret);
    599         $this->logger->write_log( 'refreshOauthTokensForForms() OAuth token data received : ' . wc_print_r(json_encode($new_token_data), TRUE), $this->debugLog );
    600 
    601         if ($new_token_data !== FALSE
    602             && isset($new_token_data->access_token)
    603             && !empty($new_token_data->access_token)
    604             && isset($new_token_data->expires_in)
    605             && !empty($new_token_data->expires_in)) {
    606             $this->oauthToken       = $new_token_data->access_token;
    607             $this->oauthTokenExpiry = $date_now + $new_token_data->expires_in;
    608             $this->update_option('oauth_token', $this->oauthToken);
    609             $this->update_option('oauth_token_expiry', $this->oauthTokenExpiry);
    610             $this->logger->write_log( 'refreshOauthTokensForForms() Obtained and saved a new oauth token.', $this->debugLog );
    611 
    612             return $new_token_data->access_token;
    613         } else {
    614             $this->logger->write_log( 'refreshOauthTokensForForms() A problem happened, could not get a new oauth token. \n' . wc_print_r(json_encode($new_token_data), TRUE), $this->debugLog );
    615             $this->oauthToken       = NULL;
    616             $this->oauthTokenExpiry = NULL;
    617             $this->update_option('oauth_token', $this->oauthToken);
    618             $this->update_option('oauth_token_expiry', $this->oauthTokenExpiry);
    619 
    620             return false;
    621         }
    622 
     598        $date_now       = (new DateTime())->getTimestamp();
     599        $buffer_time     = 600; // 10 min buffer time, so new token will generated after 50 min
     600        $current_token_expiry   = $this->get_option('oauth_token_expiry');
     601        $current_token   = $this->get_option('oauth_token');
     602
     603        if (isset($this->clientID) && !empty($this->clientID)
     604        && isset($this->clientSecret) && !empty($this->clientSecret)
     605        && (!isset($current_token) || empty($current_token) ||
     606            $date_now >= ( $current_token_expiry - $buffer_time ))
     607        )
     608        {
     609            if ($date_now >= ( $current_token_expiry - $buffer_time)) {
     610                $this->logger->write_log( 'refreshOauthTokensForForms() OAuth token (for local currency settlement) expires in less than 10 minutes. Requesting a new oauth token.', $this->debugLog );
     611            }
     612            else {
     613                $this->logger->write_log( 'refreshOauthTokensForForms() OAuth token (for local currency settlement) is missing. Requesting a new oauth token.', $this->debugLog );
     614            }
     615
     616            $new_token_data = $this->getOauthToken($this->clientID, $this->clientSecret);
     617            $this->logger->write_log( 'refreshOauthTokensForForms() OAuth token data received : ' . wc_print_r(json_encode($new_token_data), TRUE), $this->debugLog );
     618
     619            if ($new_token_data !== FALSE
     620                && isset($new_token_data->access_token)
     621                && !empty($new_token_data->access_token)
     622                && isset($new_token_data->expires_in)
     623                && !empty($new_token_data->expires_in)) {
     624                $this->oauthToken       = $new_token_data->access_token;
     625                $this->oauthTokenExpiry = $date_now + $new_token_data->expires_in;
     626                $this->update_option('oauth_token', $this->oauthToken);
     627                $this->update_option('oauth_token_expiry', $this->oauthTokenExpiry);
     628
     629                $this->logger->write_log( 'refreshOauthTokensForForms() Obtained and saved a new oauth token.', $this->debugLog );
     630
     631                return $new_token_data->access_token;
     632            } else {
     633                $this->logger->write_log( 'refreshOauthTokensForForms() A problem happened, could not get a new oauth token. \n' . wc_print_r(json_encode($new_token_data), TRUE), $this->debugLog );
     634                $this->oauthToken       = NULL;
     635                $this->oauthTokenExpiry = NULL;
     636                $this->update_option('oauth_token', $this->oauthToken);
     637                $this->update_option('oauth_token_expiry', $this->oauthTokenExpiry);
     638
     639                return false;
     640            }
     641        }
     642        else{
     643            if (!isset($this->clientID) || empty($this->clientID)) {
     644                $this->logger->write_log( 'refreshOauthTokensForForms() Client ID is not set ', $this->debugLog );
     645            }
     646            if(!isset($this->clientSecret) ||  empty($this->clientSecret)){
     647                $this->logger->write_log( 'refreshOauthTokensForForms() Client Secret ID is not set ', $this->debugLog );
     648            }
     649            if($date_now < ( $current_token_expiry - $buffer_time )){
     650                $this->logger->write_log( 'refreshOauthTokensForForms() OAuth token (for local currency settlement) is still valid, so not requesting for a new one.', $this->debugLog );
     651            }
     652            return $current_token;
     653        }
    623654    }
    624655    private function getOauthToken( $client_id, $client_secret ) {
     
    671702        $self = new TripleA_Payment_Gateway();
    672703
    673         // Refresh oauth tokens, Actually generating new tokens
     704        // validity checking oauth tokens, if validity expires, create new token.
    674705        $oauth_token = $self->refreshOauthTokensForForms();
    675706
     707        //if token is null or false, aboirt the request
    676708        if (empty($oauth_token)) {
    677709            wp_die('Missing oauth token for cryptocurrency payments with local currency settlement.');
  • triplea-cryptocurrency-payment-gateway-for-woocommerce/trunk/readme.txt

    r2919181 r2925811  
    77Requires at least: 5.5
    88Tested up to: 6.1.1
    9 Stable tag: 2.0.5
     9Stable tag: 2.0.6
    1010Requires PHP: 7.0
    1111License: GPLv2 or later
     
    109109== Changelog ==
    110110
     111= 2.0.6 =
     112Fixed: Multiple oAuth token generation request issue while calling the payment form issue fixed
     113
    111114= 2.0.5 =
    112115Fixed: Payment form loading after clicking "Pay with Cryptocurrency" issue fixed
     
    264267== Upgrade Notice ==
    265268
     269= 2.0.6 =
     270Simply install the update. No further action is needed.
     271
    266272= 2.0.5 =
    267273Simply install the update. No further action is needed.
  • triplea-cryptocurrency-payment-gateway-for-woocommerce/trunk/triplea-cryptocurrency-payment-gateway-for-woocommerce.php

    r2919181 r2925811  
    1717 * Plugin URI:        https://wordpress.org/plugins/triplea-cryptocurrency-payment-gateway-for-woocommerce/
    1818 * Description:       Offer cryptocurrency as a payment option on your website and get access to even more clients. Receive payments in cryptocurrency or in your local currency, directly in your bank account. Enjoy an easy setup, no cryptocurrency expertise required. Powered by TripleA.
    19  * Version:           2.0.5
     19 * Version:           2.0.6
    2020 * Author:            TripleA Team
    2121 * Author URI:        https://triple-a.io
     
    4545     * $var string
    4646     */
    47     const version = '2.0.5';
     47    const version = '2.0.6';
    4848
    4949    /*
Note: See TracChangeset for help on using the changeset viewer.