Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders\WooPayments
WooPaymentsRestController::handle_onboarding_step_finish
Handle the onboarding step finish 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_finish( $request );
- $request(WP_REST_Request) (required)
- The request object.
WooPaymentsRestController::handle_onboarding_step_finish() WooPaymentsRestController::handle onboarding step finish code WC 10.7.0
protected function handle_onboarding_step_finish( 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 {
$previous_status = $this->woopayments->get_onboarding_step_status( $step_id, $location );
$this->woopayments->mark_onboarding_step_completed( $step_id, $location, false, $source );
$response = array(
'success' => true,
'previous_status' => $previous_status,
'current_status' => $this->woopayments->get_onboarding_step_status( $step_id, $location ),
);
} catch ( ApiException $e ) {
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
}
return rest_ensure_response( $response );
}