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

WooPaymentsRestController::reset_onboardingprotectedWC 1.0

Handle the onboarding reset 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->reset_onboarding( $request );
$request(WP_REST_Request) (required)
The request object.

WooPaymentsRestController::reset_onboarding() code WC 10.7.0

protected function reset_onboarding( WP_REST_Request $request ) {
	$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 {
		$this->woopayments->reset_onboarding( $location, $request->get_param( 'from' ) ?? '', $request->get_param( 'source' ) ?? '' );
	} catch ( ApiException $e ) {
		return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
	}

	return rest_ensure_response(
		array(
			'success' => true,
		)
	);
}