Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders\WooPayments

WooPaymentsRestController::handle_onboarding_step_checkprotectedWC 1.0

Handle the onboarding step check action.

Method of the class: WooPaymentsRestController{}

No Hooks.

Returns

WP_Error|WP_REST_Response. The response or error.

Usage

// protected - for code of main (parent) or child class
$result = $this->handle_onboarding_step_check( $request );
$request(WP_REST_Request) (required)
The request object.

WooPaymentsRestController::handle_onboarding_step_check() code WC 10.7.0

protected function handle_onboarding_step_check( WP_REST_Request $request ) {
	$step_id = $request->get_param( 'step' ) ?? '';

	$location = $request->get_param( 'location' );
	if ( empty( $location ) ) {
		// Fall back to the providers country if no location is provided.
		$location = $this->payments->get_country();
	}

	try {
		$result = $this->woopayments->onboarding_step_check( $step_id, $location );
	} catch ( ApiException $e ) {
		return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
	}

	// Merge the result with the success flag.
	$response = array_merge( array( 'success' => true ), $result );

	return rest_ensure_response( $response );
}