Version Description
- 2019.11.18 =
- Fix - No longer automatically disconnect on unexpected authorization errors
- Fix - Bump compatibility for WooCommerce 3.8 and WordPress 5.3
- Fix - Correct cents rounding that was causing invalid value errors
- Fix - Fix encrypted token handling
- Fix - No longer call revoke when disconnecting - just disconnect the site
Download this release
Release Info
| Developer | automattic |
| Plugin | |
| Version | 2.0.7 |
| Comparing to | |
| See all releases | |
Code changes from version 2.0.6 to 2.0.7
- i18n/languages/woocommerce-square.pot +1 -1
- includes/API.php +1 -1
- includes/Handlers/Connection.php +1 -44
- includes/Plugin.php +1 -1
- includes/Settings.php +6 -2
- includes/Utilities/Money_Utility.php +4 -2
- readme.txt +9 -2
- woocommerce-square.php +2 -2
i18n/languages/woocommerce-square.pot
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
# This file is distributed under the GNU General Public License v3.0.
|
| 3 |
msgid ""
|
| 4 |
msgstr ""
|
| 5 |
-
"Project-Id-Version: WooCommerce Square 2.0.
|
| 6 |
"Report-Msgid-Bugs-To: "
|
| 7 |
"https://github.com/woocommerce/woocommerce-square/issues\n"
|
| 8 |
"POT-Creation-Date: 2019-08-19 13:09:58+00:00\n"
|
| 2 |
# This file is distributed under the GNU General Public License v3.0.
|
| 3 |
msgid ""
|
| 4 |
msgstr ""
|
| 5 |
+
"Project-Id-Version: WooCommerce Square 2.0.7\n"
|
| 6 |
"Report-Msgid-Bugs-To: "
|
| 7 |
"https://github.com/woocommerce/woocommerce-square/issues\n"
|
| 8 |
"POT-Creation-Date: 2019-08-19 13:09:58+00:00\n"
|
includes/API.php
CHANGED
|
@@ -821,7 +821,7 @@ class API extends Framework\SV_WC_API_Base {
|
|
| 821 |
}
|
| 822 |
|
| 823 |
// if the error indicates that access token is bad, disconnect the plugin to prevent further attempts
|
| 824 |
-
if ( in_array( $error->code, [ '
|
| 825 |
$this->get_plugin()->get_connection_handler()->disconnect();
|
| 826 |
$this->get_plugin()->log( 'Disconnected due to invalid authorization. Please try connecting again.' );
|
| 827 |
}
|
| 821 |
}
|
| 822 |
|
| 823 |
// if the error indicates that access token is bad, disconnect the plugin to prevent further attempts
|
| 824 |
+
if ( in_array( $error->code, [ 'ACCESS_TOKEN_EXPIRED', 'ACCESS_TOKEN_REVOKED' ], true ) ) {
|
| 825 |
$this->get_plugin()->get_connection_handler()->disconnect();
|
| 826 |
$this->get_plugin()->log( 'Disconnected due to invalid authorization. Please try connecting again.' );
|
| 827 |
}
|
includes/Handlers/Connection.php
CHANGED
|
@@ -49,13 +49,6 @@ class Connection {
|
|
| 49 |
/** @var string sandbox refresh URL */
|
| 50 |
const REFRESH_URL_SANDBOX = 'https://connect.woocommerce.com/renew/squaresandbox';
|
| 51 |
|
| 52 |
-
/** @var string production revoke URL */
|
| 53 |
-
const REVOKE_URL_PRODUCTION = 'https://connect.woocommerce.com/revoke/square';
|
| 54 |
-
|
| 55 |
-
/** @var string sandbox revoke URL */
|
| 56 |
-
const REVOKE_URL_SANDBOX = 'https://connect.woocommerce.com/revoke/squaresandbox';
|
| 57 |
-
|
| 58 |
-
|
| 59 |
/** @var Square\Plugin plugin instance */
|
| 60 |
protected $plugin;
|
| 61 |
|
|
@@ -175,29 +168,7 @@ class Connection {
|
|
| 175 |
wp_die( __( 'Sorry, you do not have permission to manage the Square connection.', 'woocommerce-square' ) );
|
| 176 |
}
|
| 177 |
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
// make the request
|
| 181 |
-
$response = wp_remote_post( $this->get_revoke_url(), [
|
| 182 |
-
'body' => [
|
| 183 |
-
'token' => $this->get_plugin()->get_settings_handler()->get_access_token(),
|
| 184 |
-
'url' => admin_url(),
|
| 185 |
-
],
|
| 186 |
-
'timeout' => 45,
|
| 187 |
-
] );
|
| 188 |
-
|
| 189 |
-
// handle HTTP errors
|
| 190 |
-
if ( is_wp_error( $response ) ) {
|
| 191 |
-
throw new Framework\SV_WC_Plugin_Exception( $response->get_error_message() );
|
| 192 |
-
}
|
| 193 |
-
|
| 194 |
-
} catch ( Framework\SV_WC_Plugin_Exception $exception ) {
|
| 195 |
-
|
| 196 |
-
// log the failure, but still disconnect below
|
| 197 |
-
$this->get_plugin()->log( 'Could not revoke token remotely. ' . $exception->getMessage() );
|
| 198 |
-
}
|
| 199 |
-
|
| 200 |
-
// fully disconnect by clearing tokens, unscheduling syncs, etc...
|
| 201 |
$this->disconnect();
|
| 202 |
|
| 203 |
$this->get_plugin()->log( 'Manually disconnected' );
|
|
@@ -498,20 +469,6 @@ class Connection {
|
|
| 498 |
return $this->get_plugin()->get_settings_handler()->is_sandbox() ? self::REFRESH_URL_SANDBOX : self::REFRESH_URL_PRODUCTION;
|
| 499 |
}
|
| 500 |
|
| 501 |
-
|
| 502 |
-
/**
|
| 503 |
-
* Gets the token revoke URL.
|
| 504 |
-
*
|
| 505 |
-
* @since 2.0.0
|
| 506 |
-
*
|
| 507 |
-
* @return string
|
| 508 |
-
*/
|
| 509 |
-
protected function get_revoke_url() {
|
| 510 |
-
|
| 511 |
-
return $this->get_plugin()->get_settings_handler()->is_sandbox() ? self::REVOKE_URL_SANDBOX : self::REVOKE_URL_PRODUCTION;
|
| 512 |
-
}
|
| 513 |
-
|
| 514 |
-
|
| 515 |
/**
|
| 516 |
* Gets the connection scopes.
|
| 517 |
*
|
| 49 |
/** @var string sandbox refresh URL */
|
| 50 |
const REFRESH_URL_SANDBOX = 'https://connect.woocommerce.com/renew/squaresandbox';
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
/** @var Square\Plugin plugin instance */
|
| 53 |
protected $plugin;
|
| 54 |
|
| 168 |
wp_die( __( 'Sorry, you do not have permission to manage the Square connection.', 'woocommerce-square' ) );
|
| 169 |
}
|
| 170 |
|
| 171 |
+
// disconnect by clearing tokens, unscheduling syncs, etc...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
$this->disconnect();
|
| 173 |
|
| 174 |
$this->get_plugin()->log( 'Manually disconnected' );
|
| 469 |
return $this->get_plugin()->get_settings_handler()->is_sandbox() ? self::REFRESH_URL_SANDBOX : self::REFRESH_URL_PRODUCTION;
|
| 470 |
}
|
| 471 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 472 |
/**
|
| 473 |
* Gets the connection scopes.
|
| 474 |
*
|
includes/Plugin.php
CHANGED
|
@@ -41,7 +41,7 @@ class Plugin extends Framework\SV_WC_Payment_Gateway_Plugin {
|
|
| 41 |
|
| 42 |
|
| 43 |
/** plugin version number */
|
| 44 |
-
const VERSION = '2.0.
|
| 45 |
|
| 46 |
/** plugin ID */
|
| 47 |
const PLUGIN_ID = 'square';
|
| 41 |
|
| 42 |
|
| 43 |
/** plugin version number */
|
| 44 |
+
const VERSION = '2.0.7';
|
| 45 |
|
| 46 |
/** plugin ID */
|
| 47 |
const PLUGIN_ID = 'square';
|
includes/Settings.php
CHANGED
|
@@ -342,6 +342,8 @@ class Settings extends \WC_Settings_API {
|
|
| 342 |
|
| 343 |
if ( ! empty( $token ) ) {
|
| 344 |
|
|
|
|
|
|
|
| 345 |
if ( Utilities\Encryption_Utility::is_encryption_supported() ) {
|
| 346 |
|
| 347 |
$encryption = new Utilities\Encryption_Utility();
|
|
@@ -357,7 +359,7 @@ class Settings extends \WC_Settings_API {
|
|
| 357 |
}
|
| 358 |
}
|
| 359 |
|
| 360 |
-
$refresh_tokens[ $environment ] = $
|
| 361 |
}
|
| 362 |
|
| 363 |
update_option( 'wc_square_refresh_tokens', $refresh_tokens );
|
|
@@ -378,6 +380,8 @@ class Settings extends \WC_Settings_API {
|
|
| 378 |
|
| 379 |
if ( ! empty( $token ) ) {
|
| 380 |
|
|
|
|
|
|
|
| 381 |
if ( Utilities\Encryption_Utility::is_encryption_supported() ) {
|
| 382 |
|
| 383 |
$encryption = new Utilities\Encryption_Utility();
|
|
@@ -393,7 +397,7 @@ class Settings extends \WC_Settings_API {
|
|
| 393 |
}
|
| 394 |
}
|
| 395 |
|
| 396 |
-
$access_tokens[ $environment ] = $
|
| 397 |
}
|
| 398 |
|
| 399 |
update_option( 'wc_square_access_tokens', $access_tokens );
|
| 342 |
|
| 343 |
if ( ! empty( $token ) ) {
|
| 344 |
|
| 345 |
+
$this->refresh_token = $token;
|
| 346 |
+
|
| 347 |
if ( Utilities\Encryption_Utility::is_encryption_supported() ) {
|
| 348 |
|
| 349 |
$encryption = new Utilities\Encryption_Utility();
|
| 359 |
}
|
| 360 |
}
|
| 361 |
|
| 362 |
+
$refresh_tokens[ $environment ] = $token;
|
| 363 |
}
|
| 364 |
|
| 365 |
update_option( 'wc_square_refresh_tokens', $refresh_tokens );
|
| 380 |
|
| 381 |
if ( ! empty( $token ) ) {
|
| 382 |
|
| 383 |
+
$this->access_token = $token;
|
| 384 |
+
|
| 385 |
if ( Utilities\Encryption_Utility::is_encryption_supported() ) {
|
| 386 |
|
| 387 |
$encryption = new Utilities\Encryption_Utility();
|
| 397 |
}
|
| 398 |
}
|
| 399 |
|
| 400 |
+
$access_tokens[ $environment ] = $token;
|
| 401 |
}
|
| 402 |
|
| 403 |
update_option( 'wc_square_access_tokens', $access_tokens );
|
includes/Utilities/Money_Utility.php
CHANGED
|
@@ -71,7 +71,8 @@ class Money_Utility {
|
|
| 71 |
$currency = get_woocommerce_currency();
|
| 72 |
}
|
| 73 |
|
| 74 |
-
|
|
|
|
| 75 |
}
|
| 76 |
|
| 77 |
|
|
@@ -90,7 +91,8 @@ class Money_Utility {
|
|
| 90 |
$currency = get_woocommerce_currency();
|
| 91 |
}
|
| 92 |
|
| 93 |
-
|
|
|
|
| 94 |
}
|
| 95 |
|
| 96 |
|
| 71 |
$currency = get_woocommerce_currency();
|
| 72 |
}
|
| 73 |
|
| 74 |
+
$cents_factor = 10 ** self::get_currency_decimals( $currency );
|
| 75 |
+
return (int) ( round( $cents_factor * $amount ) );
|
| 76 |
}
|
| 77 |
|
| 78 |
|
| 91 |
$currency = get_woocommerce_currency();
|
| 92 |
}
|
| 93 |
|
| 94 |
+
$cents_factor = 10 ** self::get_currency_decimals( $currency );
|
| 95 |
+
return (float) ( $cents / $cents_factor );
|
| 96 |
}
|
| 97 |
|
| 98 |
|
readme.txt
CHANGED
|
@@ -2,9 +2,9 @@
|
|
| 2 |
Contributors: automattic, royho, woothemes, bor0
|
| 3 |
Tags: credit card, square, woocommerce, inventory sync
|
| 4 |
Requires at least: 4.6
|
| 5 |
-
Tested up to: 5.
|
| 6 |
Requires PHP: 5.6
|
| 7 |
-
Stable tag: 2.0.
|
| 8 |
License: GPLv3
|
| 9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
| 10 |
|
|
@@ -72,6 +72,13 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
|
|
| 72 |
|
| 73 |
== Changelog ==
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
= 2.0.6 - 2019.11.07 =
|
| 76 |
* Fix - Access token renewal schedule action duplication.
|
| 77 |
|
| 2 |
Contributors: automattic, royho, woothemes, bor0
|
| 3 |
Tags: credit card, square, woocommerce, inventory sync
|
| 4 |
Requires at least: 4.6
|
| 5 |
+
Tested up to: 5.3
|
| 6 |
Requires PHP: 5.6
|
| 7 |
+
Stable tag: 2.0.7
|
| 8 |
License: GPLv3
|
| 9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
| 10 |
|
| 72 |
|
| 73 |
== Changelog ==
|
| 74 |
|
| 75 |
+
= 2.0.7 - 2019.11.18 =
|
| 76 |
+
* Fix - No longer automatically disconnect on unexpected authorization errors
|
| 77 |
+
* Fix - Bump compatibility for WooCommerce 3.8 and WordPress 5.3
|
| 78 |
+
* Fix - Correct cents rounding that was causing invalid value errors
|
| 79 |
+
* Fix - Fix encrypted token handling
|
| 80 |
+
* Fix - No longer call revoke when disconnecting - just disconnect the site
|
| 81 |
+
|
| 82 |
= 2.0.6 - 2019.11.07 =
|
| 83 |
* Fix - Access token renewal schedule action duplication.
|
| 84 |
|
woocommerce-square.php
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Plugin Name: WooCommerce Square
|
| 4 |
-
* Version: 2.0.
|
| 5 |
* Plugin URI: https://woocommerce.com/products/square/
|
| 6 |
* Description: Adds ability to sync inventory between WooCommerce and Square POS. In addition, you can also make purchases through the Square payment gateway.
|
| 7 |
* Author: WooCommerce
|
|
@@ -19,7 +19,7 @@
|
|
| 19 |
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
|
| 20 |
*
|
| 21 |
* WC requires at least: 3.0
|
| 22 |
-
* WC tested up to: 3.
|
| 23 |
*/
|
| 24 |
|
| 25 |
defined( 'ABSPATH' ) or exit;
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Plugin Name: WooCommerce Square
|
| 4 |
+
* Version: 2.0.7
|
| 5 |
* Plugin URI: https://woocommerce.com/products/square/
|
| 6 |
* Description: Adds ability to sync inventory between WooCommerce and Square POS. In addition, you can also make purchases through the Square payment gateway.
|
| 7 |
* Author: WooCommerce
|
| 19 |
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
|
| 20 |
*
|
| 21 |
* WC requires at least: 3.0
|
| 22 |
+
* WC tested up to: 3.8.0
|
| 23 |
*/
|
| 24 |
|
| 25 |
defined( 'ABSPATH' ) or exit;
|
