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

WooPaymentsService::get_onboarding_detailspublicWC 1.0

Get the onboarding details for the Payments settings page.

Method of the class: WooPaymentsService{}

No Hooks.

Returns

Array. The onboarding details.

Usage

$WooPaymentsService = new WooPaymentsService();
$WooPaymentsService->get_onboarding_details( $location, $rest_path, ?string $source ): array;
$location(string) (required)
The location for which we are onboarding. This is an ISO 3166-1 alpha-2 country code.
$rest_path(string) (required)
The REST API path to use for constructing REST API URLs.
?string $source
.
Default: null

WooPaymentsService::get_onboarding_details() code WC 10.8.1

public function get_onboarding_details( string $location, string $rest_path, ?string $source = null ): array {
	// Since getting the onboarding details is not idempotent, we will check it as an action.
	$this->check_if_onboarding_action_is_acceptable();

	$source = $this->validate_onboarding_source( $source );

	$gateway = $this->get_payment_gateway();

	$onboarding_supported = $this->provider->is_onboarding_supported( $gateway, $location ) ?? true;
	$onboarding_started   = $this->provider->is_onboarding_started( $gateway );
	if ( ! $onboarding_started && ! empty( $this->get_nox_profile_onboarding( $location ) ) ) {
		// If the onboarding profile is stored, we consider the onboarding started.
		$onboarding_started = true;
	}

	return array(
		// This state is high-level data, independent of the type of onboarding flow.
		'state'    => array(
			'supported' => $onboarding_supported,
			'started'   => $onboarding_started,
			'completed' => $this->provider->is_onboarding_completed( $gateway ),
			'test_mode' => $this->provider->is_in_test_mode_onboarding( $gateway ),
			'dev_mode'  => $this->provider->is_in_dev_mode( $gateway ),
		),
		'messages' => array(
			'not_supported' => ! $onboarding_supported ? $this->provider->get_onboarding_not_supported_message( $gateway, $location ) : null,
		),
		'steps'    => $this->get_onboarding_steps( $location, trailingslashit( $rest_path ) . 'step', $source ),
		'context'  => array(
			'urls' => array(
				'overview_page' => $this->get_overview_page_url(),
			),
		),
	);
}