diff --git a/changelog.txt b/changelog.txt index 3a7f9291530..dfd9b3c8971 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ *** WooPayments Changelog *** += 9.2.1 - 2025-04-23 = +* Update - Update account session creation route definition to use POST rather than GET. + = 9.2.0 - 2025-04-09 = * Add - Add back button for tertiary+ level pages in WooPayments settings. * Fix - fix: cancel GooglePay/ApplePay dialog on product page if add-to-cart product validation fails diff --git a/client/embedded-components/hooks.tsx b/client/embedded-components/hooks.tsx index c9c725fbff5..4e9f0cb9a5a 100644 --- a/client/embedded-components/hooks.tsx +++ b/client/embedded-components/hooks.tsx @@ -33,12 +33,14 @@ export const createKycAccountSession = async ( isPoEligible: boolean ): Promise< AccountSession > => { const urlParams = new URLSearchParams( window.location.search ); + return await apiFetch< AccountSession >( { - path: addQueryArgs( `${ NAMESPACE }/onboarding/kyc/session`, { + path: `${ NAMESPACE }/onboarding/kyc/session`, + method: 'POST', + data: { self_assessment: fromDotNotation( data ), capabilities: urlParams.get( 'capabilities' ) || '', progressive: isPoEligible, - } ), - method: 'GET', + }, } ); }; diff --git a/includes/admin/class-wc-rest-payments-onboarding-controller.php b/includes/admin/class-wc-rest-payments-onboarding-controller.php index 9d5fd2138da..6a1849903b7 100644 --- a/includes/admin/class-wc-rest-payments-onboarding-controller.php +++ b/includes/admin/class-wc-rest-payments-onboarding-controller.php @@ -52,8 +52,8 @@ public function register_routes() { $this->namespace, '/' . $this->rest_base . '/kyc/session', [ - 'methods' => WP_REST_Server::READABLE, - 'callback' => [ $this, 'get_embedded_kyc_session' ], + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => [ $this, 'create_embedded_kyc_session' ], 'permission_callback' => [ $this, 'check_permission' ], 'args' => [ 'progressive' => [ @@ -71,32 +71,26 @@ public function register_routes() { 'country' => [ 'type' => 'string', 'description' => 'The country code where the company is legally registered.', - 'required' => true, ], 'business_type' => [ 'type' => 'string', 'description' => 'The company incorporation type.', - 'required' => true, ], 'mcc' => [ 'type' => 'string', 'description' => 'The merchant category code. This can either be a true MCC or an MCCs tree item id from the onboarding form.', - 'required' => true, ], 'annual_revenue' => [ 'type' => 'string', 'description' => 'The estimated annual revenue bucket id.', - 'required' => true, ], 'go_live_timeframe' => [ 'type' => 'string', 'description' => 'The timeframe bucket for the estimated first live transaction.', - 'required' => true, ], 'site' => [ 'type' => 'string', 'description' => 'The URL of the site.', - 'required' => true, ], ], ], @@ -226,9 +220,9 @@ public function register_routes() { * * @param WP_REST_Request $request Request object. * - * @return WP_Error|WP_REST_Response + * @return WP_Error|WP_REST_Response Response object containing the account session, or an error if session creation failed. */ - public function get_embedded_kyc_session( WP_REST_Request $request ) { + public function create_embedded_kyc_session( WP_REST_Request $request ) { $self_assessment_data = ! empty( $request->get_param( 'self_assessment' ) ) ? wc_clean( wp_unslash( $request->get_param( 'self_assessment' ) ) ) : []; $progressive = ! empty( $request->get_param( 'progressive' ) ) && filter_var( $request->get_param( 'progressive' ), FILTER_VALIDATE_BOOLEAN ); diff --git a/package-lock.json b/package-lock.json index 773c34dbc6d..d0fa1fbaf31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "woocommerce-payments", - "version": "9.2.0", + "version": "9.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "woocommerce-payments", - "version": "9.2.0", + "version": "9.2.1", "hasInstallScript": true, "license": "GPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index bd7b7a57b34..37d3ce41afe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "woocommerce-payments", - "version": "9.2.0", + "version": "9.2.1", "main": "webpack.config.js", "author": "Automattic", "license": "GPL-3.0-or-later", diff --git a/readme.txt b/readme.txt index 4e7577793f3..8ba0e755ac7 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: woocommerce payments, apple pay, credit card, google pay, payment, payment Requires at least: 6.0 Tested up to: 6.7 Requires PHP: 7.3 -Stable tag: 9.2.0 +Stable tag: 9.2.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -87,6 +87,10 @@ You can read our Terms of Service and other policies [here](https://woocommerce. == Changelog == += 9.2.1 - 2025-04-23 = +* Update - Update account session creation route definition to use POST rather than GET. + + = 9.2.0 - 2025-04-09 = * Add - Add back button for tertiary+ level pages in WooPayments settings. * Fix - fix: cancel GooglePay/ApplePay dialog on product page if add-to-cart product validation fails diff --git a/tests/unit/admin/test-class-wc-rest-payments-onboarding-controller.php b/tests/unit/admin/test-class-wc-rest-payments-onboarding-controller.php index 0e0b125c4ff..5823b494cde 100644 --- a/tests/unit/admin/test-class-wc-rest-payments-onboarding-controller.php +++ b/tests/unit/admin/test-class-wc-rest-payments-onboarding-controller.php @@ -141,7 +141,7 @@ public function test_get_progressive_onboarding_not_eligible() { ); } - public function test_get_embedded_kyc_session() { + public function test_create_embedded_kyc_session() { $kyc_session = [ 'clientSecret' => 'accs_secret__XXX', 'expiresAt' => time() + 120, @@ -158,15 +158,15 @@ public function test_get_embedded_kyc_session() { $kyc_session ); - $request = new WP_REST_Request( 'GET' ); - $request->set_query_params( + $request = new WP_REST_Request( 'POST' ); + $request->set_body_params( [ 'progressive' => true, 'create_live_account' => true, ] ); - $response = $this->controller->get_embedded_kyc_session( $request ); + $response = $this->controller->create_embedded_kyc_session( $request ); $this->assertSame( 200, $response->status ); $this->assertSame( array_merge( diff --git a/woocommerce-payments.php b/woocommerce-payments.php index a65895983cc..d283b533be2 100644 --- a/woocommerce-payments.php +++ b/woocommerce-payments.php @@ -11,7 +11,7 @@ * WC tested up to: 9.7.1 * Requires at least: 6.0 * Requires PHP: 7.3 - * Version: 9.2.0 + * Version: 9.2.1 * Requires Plugins: woocommerce * * @package WooCommerce\Payments