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

WooPaymentsRestController::get_onboarding_detailsprotectedWC 1.0

Get the onboarding details for the given location.

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->get_onboarding_details( $request );
$request(WP_REST_Request) (required)
The request object.

WooPaymentsRestController::get_onboarding_details() code WC 10.7.0

protected function get_onboarding_details( 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();
	}

	$source = $request->get_param( 'source' );

	try {
		$onboarding_details = $this->woopayments->get_onboarding_details( $location, $this->get_rest_url_path( 'onboarding' ), $source );
	} catch ( ApiException $e ) {
		return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
	} catch ( Exception $e ) {
		return new WP_Error( 'woocommerce_rest_woopayments_onboarding_error', $e->getMessage(), array( 'status' => WP_Http::INTERNAL_SERVER_ERROR ) );
	}

	return rest_ensure_response( $this->prepare_onboarding_details_response( $onboarding_details ) );
}