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

WooPaymentsService::get_onboarding_kyc_fieldsprivateWC 1.0

Get the onboarding fields data for the KYC business verification.

Method of the class: WooPaymentsService{}

No Hooks.

Returns

Array. The onboarding fields data.

Usage

// private - for code of main (parent) class only
$result = $this->get_onboarding_kyc_fields( $location ): array;
$location(string) (required)
The location for which we are onboarding. This is an ISO 3166-1 alpha-2 country code.

WooPaymentsService::get_onboarding_kyc_fields() code WC 10.7.0

private function get_onboarding_kyc_fields( string $location ): array {
	// Call the WooPayments API to get the onboarding fields.
	$response = $this->proxy->call_static( Utils::class, 'rest_endpoint_get_request', '/wc/v3/payments/onboarding/fields' );

	if ( is_wp_error( $response ) ) {
		throw new Exception( esc_html( $response->get_error_message() ) );
	}

	if ( ! is_array( $response ) || ! isset( $response['data'] ) ) {
		throw new Exception( esc_html__( 'Failed to get onboarding fields data.', 'woocommerce' ) );
	}

	$fields = $response['data'];

	// If there is no available_countries entry, add it.
	if ( ! isset( $fields['available_countries'] ) &&
		class_exists( '\WC_Payments_Utils' ) &&
		$this->proxy->call_function( 'is_callable', '\WC_Payments_Utils::supported_countries' ) ) {

		$fields['available_countries'] = $this->proxy->call_static( '\WC_Payments_Utils', 'supported_countries' );
	}

	$fields['location'] = $location;

	return $fields;
}