| @@ -555,19 +555,26 @@ | ||
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | /** |
| 558 | 558 | * Check $_POST for live or test mode value as it can be updated in real time from Square Settings and can be configured before the update is saved. |
| 559 | + * The connect request sends a 'mode' string, and the disconnect request sends a 'testMode' flag, so check for both. | |
| 559 | 560 | * |
| 560 | 561 | * @return string 'test' or 'live' |
| 561 | 562 | */ |
| 562 | 563 | private static function get_mode_value_from_post() { |
| 563 | 564 | // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 564 | - if ( empty( $_POST ) || ! array_key_exists( 'testMode', $_POST ) ) { | |
| 565 | - return FrmSquareLiteAppHelper::active_mode(); | |
| 565 | + if ( array_key_exists( 'mode', $_POST ) ) { | |
| 566 | + $mode = FrmAppHelper::get_post_param( 'mode', '', 'sanitize_text_field' ); | |
| 567 | + return 'test' === $mode ? 'test' : 'live'; | |
| 566 | 568 | } |
| 567 | 569 | |
| 568 | - $test_mode = FrmAppHelper::get_param( 'testMode', '', 'post', 'absint' ); | |
| 569 | - return $test_mode ? 'test' : 'live'; | |
| 570 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 571 | + if ( array_key_exists( 'testMode', $_POST ) ) { | |
| 572 | + $test_mode = FrmAppHelper::get_post_param( 'testMode', '', 'absint' ); | |
| 573 | + return $test_mode ? 'test' : 'live'; | |
| 574 | + } | |
| 575 | + | |
| 576 | + return FrmSquareLiteAppHelper::active_mode(); | |
| 570 | 577 | } |
| 571 | 578 | |
| 572 | 579 | /** |
| 573 | 580 | * Get the standard body with account id, mode, and passwords to send to the connect server. |