Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders\WooPayments
WooPaymentsService::onboarding_step_save
Save the data for an onboarding step.
Method of the class: WooPaymentsService{}
No Hooks.
Returns
true|false. Whether the onboarding step data was saved.
Usage
$WooPaymentsService = new WooPaymentsService(); $WooPaymentsService->onboarding_step_save( $step_id, $location, $request_data ): bool;
- $step_id(string) (required)
- The ID of the onboarding step.
- $location(string) (required)
- The location for which we are onboarding. This is an ISO 3166-1 alpha-2 country code.
- $request_data(array) (required)
- The entire data received in the request.
WooPaymentsService::onboarding_step_save() WooPaymentsService::onboarding step save code WC 10.8.1
public function onboarding_step_save( string $step_id, string $location, array $request_data ): bool {
$this->check_if_onboarding_step_action_is_acceptable( $step_id, $location );
// Validate the received step data.
// If we didn't receive any known data for the step, we consider it an invalid save operation.
if ( ! $this->is_valid_onboarding_step_data( $step_id, $request_data ) ) {
throw new ApiArgumentException(
'woocommerce_woopayments_onboarding_invalid_step_data',
esc_html__( 'Invalid onboarding step data.', 'woocommerce' ),
(int) WP_Http::BAD_REQUEST
);
}
$step_details = $this->get_nox_profile_onboarding_step( $step_id, $location );
if ( empty( $step_details['data'] ) ) {
$step_details['data'] = array();
}
// Extract the data for the step.
switch ( $step_id ) {
case self::ONBOARDING_STEP_PAYMENT_METHODS:
if ( isset( $request_data['payment_methods'] ) ) {
$step_details['data']['payment_methods'] = $request_data['payment_methods'];
}
break;
case self::ONBOARDING_STEP_BUSINESS_VERIFICATION:
if ( isset( $request_data['self_assessment'] ) ) {
$step_details['data']['self_assessment'] = $request_data['self_assessment'];
}
if ( isset( $request_data['sub_steps'] ) ) {
$step_details['data']['sub_steps'] = $request_data['sub_steps'];
}
break;
default:
throw new ApiException(
'woocommerce_woopayments_onboarding_step_action_not_supported',
esc_html__( 'Save action not supported for the onboarding step ID.', 'woocommerce' ),
(int) WP_Http::NOT_ACCEPTABLE
);
}
// Store the updated step data.
return $this->save_nox_profile_onboarding_step( $step_id, $location, $step_details );
}