Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders\WooPayments
WooPaymentsRestController::handle_onboarding_step_save
Handle the onboarding step save action.
Method of the class: WooPaymentsRestController{}
No Hooks.
Returns
WP_Error|WP_REST_Response. The response.
Usage
// protected - for code of main (parent) or child class $result = $this->handle_onboarding_step_save( $request );
- $request(WP_REST_Request) (required)
- The request object.
WooPaymentsRestController::handle_onboarding_step_save() WooPaymentsRestController::handle onboarding step save code WC 10.7.0
protected function handle_onboarding_step_save( 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();
}
$source = $request->get_param( 'source' );
try {
$this->woopayments->onboarding_step_save( $step_id, $location, $request->get_params() );
// If some step data was saved, we also ensure that the step is marked as started, if not already.
// This way we maintain onboarding state consistency if the frontend does not call the start endpoint.
$this->woopayments->mark_onboarding_step_started( $step_id, $location, false, $source );
} catch ( ApiException $e ) {
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
}
return rest_ensure_response( array( 'success' => true ) );
}