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

WooPaymentsService::is_valid_onboarding_step_dataprivateWC 1.0

Check if the given onboarding step data is valid.

If we didn't receive any known data for the step, we consider it invalid.

Method of the class: WooPaymentsService{}

No Hooks.

Returns

true|false. Whether the given onboarding step data is valid.

Usage

// private - for code of main (parent) class only
$result = $this->is_valid_onboarding_step_data( $step_id, $request_data ): bool;
$step_id(string) (required)
The ID of the onboarding step.
$request_data(array) (required)
The entire data received in the request.

WooPaymentsService::is_valid_onboarding_step_data() code WC 10.7.0

private function is_valid_onboarding_step_data( string $step_id, array $request_data ): bool {
	switch ( $step_id ) {
		case self::ONBOARDING_STEP_PAYMENT_METHODS:
			// Check that we have at least one piece of data.
			if ( ! isset( $request_data['payment_methods'] ) ) {
				return false;
			}

			// Check that the data is in the expected format.
			if ( ! is_array( $request_data['payment_methods'] ) ) {
				return false;
			}
			break;
		case self::ONBOARDING_STEP_BUSINESS_VERIFICATION:
			// Check that we have at least one piece of data.
			if ( ! isset( $request_data['self_assessment'] ) &&
				! isset( $request_data['sub_steps'] ) ) {
				return false;
			}

			// Check that the data is in the expected format.
			if ( isset( $request_data['self_assessment'] ) && ! is_array( $request_data['self_assessment'] ) ) {
				return false;
			}
			if ( isset( $request_data['sub_steps'] ) && ! is_array( $request_data['sub_steps'] ) ) {
				return false;
			}
			break;
		default:
			// If we don't know how to validate the data, we assume it is valid.
			return true;
	}

	return true;
}