Changeset 2925811
- Timestamp:
- 06/14/2023 10:18:29 AM (3 years ago)
- Location:
- triplea-cryptocurrency-payment-gateway-for-woocommerce
- Files:
-
- 6 edited
- 1 copied
-
tags/2.0.6 (copied) (copied from triplea-cryptocurrency-payment-gateway-for-woocommerce/trunk)
-
tags/2.0.6/includes/WooCommerce/TripleA_Payment_Gateway.php (modified) (2 diffs)
-
tags/2.0.6/readme.txt (modified) (3 diffs)
-
tags/2.0.6/triplea-cryptocurrency-payment-gateway-for-woocommerce.php (modified) (2 diffs)
-
trunk/includes/WooCommerce/TripleA_Payment_Gateway.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/triplea-cryptocurrency-payment-gateway-for-woocommerce.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
triplea-cryptocurrency-payment-gateway-for-woocommerce/tags/2.0.6/includes/WooCommerce/TripleA_Payment_Gateway.php
r2919181 r2925811 591 591 } 592 592 } 593 /** 594 * Generate new OAuth token if validity expired 595 */ 593 596 private function refreshOauthTokensForForms($refresh_for_api_id = FALSE) { 594 597 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 } 623 654 } 624 655 private function getOauthToken( $client_id, $client_secret ) { … … 671 702 $self = new TripleA_Payment_Gateway(); 672 703 673 // Refresh oauth tokens, Actually generating new tokens704 // validity checking oauth tokens, if validity expires, create new token. 674 705 $oauth_token = $self->refreshOauthTokensForForms(); 675 706 707 //if token is null or false, aboirt the request 676 708 if (empty($oauth_token)) { 677 709 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 7 7 Requires at least: 5.5 8 8 Tested up to: 6.1.1 9 Stable tag: 2.0. 59 Stable tag: 2.0.6 10 10 Requires PHP: 7.0 11 11 License: GPLv2 or later … … 109 109 == Changelog == 110 110 111 = 2.0.6 = 112 Fixed: Multiple oAuth token generation request issue while calling the payment form issue fixed 113 111 114 = 2.0.5 = 112 115 Fixed: Payment form loading after clicking "Pay with Cryptocurrency" issue fixed … … 264 267 == Upgrade Notice == 265 268 269 = 2.0.6 = 270 Simply install the update. No further action is needed. 271 266 272 = 2.0.5 = 267 273 Simply 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 17 17 * Plugin URI: https://wordpress.org/plugins/triplea-cryptocurrency-payment-gateway-for-woocommerce/ 18 18 * 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. 519 * Version: 2.0.6 20 20 * Author: TripleA Team 21 21 * Author URI: https://triple-a.io … … 45 45 * $var string 46 46 */ 47 const version = '2.0. 5';47 const version = '2.0.6'; 48 48 49 49 /* -
triplea-cryptocurrency-payment-gateway-for-woocommerce/trunk/includes/WooCommerce/TripleA_Payment_Gateway.php
r2919181 r2925811 591 591 } 592 592 } 593 /** 594 * Generate new OAuth token if validity expired 595 */ 593 596 private function refreshOauthTokensForForms($refresh_for_api_id = FALSE) { 594 597 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 } 623 654 } 624 655 private function getOauthToken( $client_id, $client_secret ) { … … 671 702 $self = new TripleA_Payment_Gateway(); 672 703 673 // Refresh oauth tokens, Actually generating new tokens704 // validity checking oauth tokens, if validity expires, create new token. 674 705 $oauth_token = $self->refreshOauthTokensForForms(); 675 706 707 //if token is null or false, aboirt the request 676 708 if (empty($oauth_token)) { 677 709 wp_die('Missing oauth token for cryptocurrency payments with local currency settlement.'); -
triplea-cryptocurrency-payment-gateway-for-woocommerce/trunk/readme.txt
r2919181 r2925811 7 7 Requires at least: 5.5 8 8 Tested up to: 6.1.1 9 Stable tag: 2.0. 59 Stable tag: 2.0.6 10 10 Requires PHP: 7.0 11 11 License: GPLv2 or later … … 109 109 == Changelog == 110 110 111 = 2.0.6 = 112 Fixed: Multiple oAuth token generation request issue while calling the payment form issue fixed 113 111 114 = 2.0.5 = 112 115 Fixed: Payment form loading after clicking "Pay with Cryptocurrency" issue fixed … … 264 267 == Upgrade Notice == 265 268 269 = 2.0.6 = 270 Simply install the update. No further action is needed. 271 266 272 = 2.0.5 = 267 273 Simply install the update. No further action is needed. -
triplea-cryptocurrency-payment-gateway-for-woocommerce/trunk/triplea-cryptocurrency-payment-gateway-for-woocommerce.php
r2919181 r2925811 17 17 * Plugin URI: https://wordpress.org/plugins/triplea-cryptocurrency-payment-gateway-for-woocommerce/ 18 18 * 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. 519 * Version: 2.0.6 20 20 * Author: TripleA Team 21 21 * Author URI: https://triple-a.io … … 45 45 * $var string 46 46 */ 47 const version = '2.0. 5';47 const version = '2.0.6'; 48 48 49 49 /*
Note: See TracChangeset
for help on using the changeset viewer.