Changeset 2936473
- Timestamp:
- 07/10/2023 10:18:02 AM (3 years ago)
- Location:
- triplea-cryptocurrency-payment-gateway-for-woocommerce
- Files:
-
- 6 edited
- 1 copied
-
tags/2.0.7 (copied) (copied from triplea-cryptocurrency-payment-gateway-for-woocommerce/trunk)
-
tags/2.0.7/includes/WooCommerce/TripleA_Payment_Gateway.php (modified) (7 diffs)
-
tags/2.0.7/readme.txt (modified) (3 diffs)
-
tags/2.0.7/triplea-cryptocurrency-payment-gateway-for-woocommerce.php (modified) (2 diffs)
-
trunk/includes/WooCommerce/TripleA_Payment_Gateway.php (modified) (7 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.7/includes/WooCommerce/TripleA_Payment_Gateway.php
r2925811 r2936473 72 72 ]); 73 73 74 // Refresh oauth tokens 75 $this->refreshOauthTokens(); 76 74 75 //will be called only for checkout page 76 if ( is_checkout() ) { 77 78 79 $this->logger->write_log( 'refreshOauthToken() will be called now from checkout page', $this->debugLog ); 80 81 $this->refreshOauthTokens(); 82 } 83 add_filter('http_headers_useragent', [ $this, 'custom_user_agent' ],10,2 ); 77 84 add_filter('woocommerce_available_payment_gateways', [$this, 'triplea_exclude_if_subscription_product']); 78 85 } … … 552 559 ); 553 560 } 554 561 /** 562 * @return boolean true if the token is expired or invalid or null 563 * @return boolean false if the token is valid. 564 */ 565 private function isOauthTokenInvalid(){ 566 567 $date_now = (new DateTime())->getTimestamp(); 568 $buffer_time = 600; // 10 min buffer time, so new token will generated after 50 min 569 $current_token_expiry = $this->get_option('oauth_token_expiry'); 570 $current_token = $this->get_option('oauth_token'); 571 572 if (isset($this->clientID) && !empty($this->clientID) 573 && isset($this->clientSecret) && !empty($this->clientSecret) 574 && (!isset($current_token) || empty($current_token) || 575 $date_now >= ( $current_token_expiry - $buffer_time )) 576 ) 577 { 578 //time to gernerate new token 579 return true; 580 } 581 else{ 582 //current token is valid 583 return false; 584 } 585 586 587 } 588 /** 589 * Store new token into database if token validity expired 590 */ 555 591 private function refreshOauthTokens($refresh_for_api_id = FALSE) { 556 592 557 $date_now = (new DateTime())->getTimestamp();558 $ date_expiry_limit = $date_now - 600; // 10 minutes before expiry token559 560 if (isset($this->clientID) && !empty($this->clientID)561 && isset($this->clientSecret) && !empty($this->clientSecret) 562 && (!isset($this->oauthToken) || empty($this->oauthToken) || $this->oauthTokenExpiry <= $date_expiry_limit)563 ){564 if ($ this->oauthTokenExpiry <= $date_expiry_limit) {593 $date_now = (new DateTime())->getTimestamp(); 594 $buffer_time = 600; // 10 min buffer time, so new token will generated after 50 min 595 $current_token_expiry = $this->get_option('oauth_token_expiry'); 596 $current_token = $this->get_option('oauth_token'); 597 598 if($this->isOauthTokenInvalid()) 599 { 600 if ($date_now >= ( $current_token_expiry - $buffer_time)) { 565 601 $this->logger->write_log( 'refreshOauthToken() OAuth token (for local currency settlement) expires in less than 10 minutes. Requesting a new oauth token.', $this->debugLog ); 566 602 } … … 568 604 $this->logger->write_log( 'refreshOauthToken() OAuth token (for local currency settlement) is missing. Requesting a new oauth token.', $this->debugLog ); 569 605 } 606 570 607 571 608 $new_token_data = $this->getOauthToken($this->clientID, $this->clientSecret); … … 590 627 } 591 628 } 592 } 629 else{ 630 if (!isset($this->clientID) || empty($this->clientID)) { 631 $this->logger->write_log( 'refreshOauthToken() Client ID is not set ', $this->debugLog ); 632 } 633 if(!isset($this->clientSecret) || empty($this->clientSecret)){ 634 $this->logger->write_log( 'refreshOauthToken() Client Secret ID is not set ', $this->debugLog ); 635 } 636 if($date_now < ( $current_token_expiry - $buffer_time )){ 637 638 $this->logger->write_log( 'refreshOauthToken() OAuth token (for local currency settlement) is still valid, so not requesting for a new one.', $this->debugLog ); 639 } 640 641 } 642 } 643 593 644 /** 594 645 * Generate new OAuth token if validity expired 595 646 */ 596 647 private function refreshOauthTokensForForms($refresh_for_api_id = FALSE) { 597 598 648 $date_now = (new DateTime())->getTimestamp(); 599 649 $buffer_time = 600; // 10 min buffer time, so new token will generated after 50 min … … 601 651 $current_token = $this->get_option('oauth_token'); 602 652 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 ) 653 if($this->isOauthTokenInvalid()) 608 654 { 609 655 if ($date_now >= ( $current_token_expiry - $buffer_time)) { … … 662 708 ]; 663 709 664 $this->logger->write_log( 'Making an oauth token request with body: \n' . wc_print_r($body, TRUE), $this->debugLog ); 710 // $this->logger->write_log( 'Making an oauth token request with body: \n' . wc_print_r($body, TRUE), $this->debugLog ); 711 $this->logger->write_log( 'Making an oauth token request with clinet id: \n' . wc_print_r($client_id, TRUE), $this->debugLog ); 665 712 666 713 $result = wp_remote_post($post_url, [ … … 682 729 return json_decode($result['body']); 683 730 } 684 731 public static function custom_user_agent($user_agent, $url) { 732 733 734 if (strpos($url, '/oauth/token') !== false || strpos($url, 'v2/payment') !== false ) { 735 // Modify the user agent to your desired value 736 $version = get_option('wc_triplea_crypto_payment_version'); 737 $user_agent = $user_agent."; wc_triplea_crypto_payment:".$version; 738 739 } 740 return $user_agent; 741 } 685 742 /** 686 743 * -
triplea-cryptocurrency-payment-gateway-for-woocommerce/tags/2.0.7/readme.txt
r2925811 r2936473 6 6 Tags: altcoin woocommerce, bitcoin payments, bitcoin, crypto payment gateway, crypto payments 7 7 Requires at least: 5.5 8 Tested up to: 6. 1.19 Stable tag: 2.0. 68 Tested up to: 6.2.2 9 Stable tag: 2.0.7 10 10 Requires PHP: 7.0 11 11 License: GPLv2 or later … … 109 109 == Changelog == 110 110 111 = 2.0.7 = 112 Fixed: Unusual token request from elementor or javascript from frontend 113 Fixed: Prevent printing confedential information into logs 114 Fixed: Add triple-a plugin version to user-agent 115 111 116 = 2.0.6 = 112 117 Fixed: Multiple oAuth token generation request issue while calling the payment form issue fixed … … 267 272 == Upgrade Notice == 268 273 274 = 2.0.7 = 275 Simply install the update. No further action is needed. 276 269 277 = 2.0.6 = 270 278 Simply install the update. No further action is needed. -
triplea-cryptocurrency-payment-gateway-for-woocommerce/tags/2.0.7/triplea-cryptocurrency-payment-gateway-for-woocommerce.php
r2925811 r2936473 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. 619 * Version: 2.0.7 20 20 * Author: TripleA Team 21 21 * Author URI: https://triple-a.io … … 45 45 * $var string 46 46 */ 47 const version = '2.0. 6';47 const version = '2.0.7'; 48 48 49 49 /* -
triplea-cryptocurrency-payment-gateway-for-woocommerce/trunk/includes/WooCommerce/TripleA_Payment_Gateway.php
r2925811 r2936473 72 72 ]); 73 73 74 // Refresh oauth tokens 75 $this->refreshOauthTokens(); 76 74 75 //will be called only for checkout page 76 if ( is_checkout() ) { 77 78 79 $this->logger->write_log( 'refreshOauthToken() will be called now from checkout page', $this->debugLog ); 80 81 $this->refreshOauthTokens(); 82 } 83 add_filter('http_headers_useragent', [ $this, 'custom_user_agent' ],10,2 ); 77 84 add_filter('woocommerce_available_payment_gateways', [$this, 'triplea_exclude_if_subscription_product']); 78 85 } … … 552 559 ); 553 560 } 554 561 /** 562 * @return boolean true if the token is expired or invalid or null 563 * @return boolean false if the token is valid. 564 */ 565 private function isOauthTokenInvalid(){ 566 567 $date_now = (new DateTime())->getTimestamp(); 568 $buffer_time = 600; // 10 min buffer time, so new token will generated after 50 min 569 $current_token_expiry = $this->get_option('oauth_token_expiry'); 570 $current_token = $this->get_option('oauth_token'); 571 572 if (isset($this->clientID) && !empty($this->clientID) 573 && isset($this->clientSecret) && !empty($this->clientSecret) 574 && (!isset($current_token) || empty($current_token) || 575 $date_now >= ( $current_token_expiry - $buffer_time )) 576 ) 577 { 578 //time to gernerate new token 579 return true; 580 } 581 else{ 582 //current token is valid 583 return false; 584 } 585 586 587 } 588 /** 589 * Store new token into database if token validity expired 590 */ 555 591 private function refreshOauthTokens($refresh_for_api_id = FALSE) { 556 592 557 $date_now = (new DateTime())->getTimestamp();558 $ date_expiry_limit = $date_now - 600; // 10 minutes before expiry token559 560 if (isset($this->clientID) && !empty($this->clientID)561 && isset($this->clientSecret) && !empty($this->clientSecret) 562 && (!isset($this->oauthToken) || empty($this->oauthToken) || $this->oauthTokenExpiry <= $date_expiry_limit)563 ){564 if ($ this->oauthTokenExpiry <= $date_expiry_limit) {593 $date_now = (new DateTime())->getTimestamp(); 594 $buffer_time = 600; // 10 min buffer time, so new token will generated after 50 min 595 $current_token_expiry = $this->get_option('oauth_token_expiry'); 596 $current_token = $this->get_option('oauth_token'); 597 598 if($this->isOauthTokenInvalid()) 599 { 600 if ($date_now >= ( $current_token_expiry - $buffer_time)) { 565 601 $this->logger->write_log( 'refreshOauthToken() OAuth token (for local currency settlement) expires in less than 10 minutes. Requesting a new oauth token.', $this->debugLog ); 566 602 } … … 568 604 $this->logger->write_log( 'refreshOauthToken() OAuth token (for local currency settlement) is missing. Requesting a new oauth token.', $this->debugLog ); 569 605 } 606 570 607 571 608 $new_token_data = $this->getOauthToken($this->clientID, $this->clientSecret); … … 590 627 } 591 628 } 592 } 629 else{ 630 if (!isset($this->clientID) || empty($this->clientID)) { 631 $this->logger->write_log( 'refreshOauthToken() Client ID is not set ', $this->debugLog ); 632 } 633 if(!isset($this->clientSecret) || empty($this->clientSecret)){ 634 $this->logger->write_log( 'refreshOauthToken() Client Secret ID is not set ', $this->debugLog ); 635 } 636 if($date_now < ( $current_token_expiry - $buffer_time )){ 637 638 $this->logger->write_log( 'refreshOauthToken() OAuth token (for local currency settlement) is still valid, so not requesting for a new one.', $this->debugLog ); 639 } 640 641 } 642 } 643 593 644 /** 594 645 * Generate new OAuth token if validity expired 595 646 */ 596 647 private function refreshOauthTokensForForms($refresh_for_api_id = FALSE) { 597 598 648 $date_now = (new DateTime())->getTimestamp(); 599 649 $buffer_time = 600; // 10 min buffer time, so new token will generated after 50 min … … 601 651 $current_token = $this->get_option('oauth_token'); 602 652 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 ) 653 if($this->isOauthTokenInvalid()) 608 654 { 609 655 if ($date_now >= ( $current_token_expiry - $buffer_time)) { … … 662 708 ]; 663 709 664 $this->logger->write_log( 'Making an oauth token request with body: \n' . wc_print_r($body, TRUE), $this->debugLog ); 710 // $this->logger->write_log( 'Making an oauth token request with body: \n' . wc_print_r($body, TRUE), $this->debugLog ); 711 $this->logger->write_log( 'Making an oauth token request with clinet id: \n' . wc_print_r($client_id, TRUE), $this->debugLog ); 665 712 666 713 $result = wp_remote_post($post_url, [ … … 682 729 return json_decode($result['body']); 683 730 } 684 731 public static function custom_user_agent($user_agent, $url) { 732 733 734 if (strpos($url, '/oauth/token') !== false || strpos($url, 'v2/payment') !== false ) { 735 // Modify the user agent to your desired value 736 $version = get_option('wc_triplea_crypto_payment_version'); 737 $user_agent = $user_agent."; wc_triplea_crypto_payment:".$version; 738 739 } 740 return $user_agent; 741 } 685 742 /** 686 743 * -
triplea-cryptocurrency-payment-gateway-for-woocommerce/trunk/readme.txt
r2925811 r2936473 6 6 Tags: altcoin woocommerce, bitcoin payments, bitcoin, crypto payment gateway, crypto payments 7 7 Requires at least: 5.5 8 Tested up to: 6. 1.19 Stable tag: 2.0. 68 Tested up to: 6.2.2 9 Stable tag: 2.0.7 10 10 Requires PHP: 7.0 11 11 License: GPLv2 or later … … 109 109 == Changelog == 110 110 111 = 2.0.7 = 112 Fixed: Unusual token request from elementor or javascript from frontend 113 Fixed: Prevent printing confedential information into logs 114 Fixed: Add triple-a plugin version to user-agent 115 111 116 = 2.0.6 = 112 117 Fixed: Multiple oAuth token generation request issue while calling the payment form issue fixed … … 267 272 == Upgrade Notice == 268 273 274 = 2.0.7 = 275 Simply install the update. No further action is needed. 276 269 277 = 2.0.6 = 270 278 Simply install the update. No further action is needed. -
triplea-cryptocurrency-payment-gateway-for-woocommerce/trunk/triplea-cryptocurrency-payment-gateway-for-woocommerce.php
r2925811 r2936473 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. 619 * Version: 2.0.7 20 20 * Author: TripleA Team 21 21 * Author URI: https://triple-a.io … … 45 45 * $var string 46 46 */ 47 const version = '2.0. 6';47 const version = '2.0.7'; 48 48 49 49 /*
Note: See TracChangeset
for help on using the changeset viewer.