Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders\WooPayments
WooPaymentsService::onboarding_preload
Preload the onboarding process.
This method is used to run the heavier logic required for onboarding ahead of time, so that we can be quicker to respond to the user when they start the onboarding process.
Method of the class: WooPaymentsService{}
No Hooks.
Returns
Array. An array containing the success status and any errors encountered during the preload. 'success' => true if the preload was successful, false otherwise. 'errors' => An array of error messages if any errors occurred, empty if no errors.
Usage
$WooPaymentsService = new WooPaymentsService(); $WooPaymentsService->onboarding_preload(): array;
WooPaymentsService::onboarding_preload() WooPaymentsService::onboarding preload code WC 10.8.1
public function onboarding_preload(): array {
// If the onboarding is locked, we shouldn't do anything.
if ( $this->is_onboarding_locked() ) {
throw new ApiException(
'woocommerce_woopayments_onboarding_locked',
esc_html__( 'Another onboarding action is already in progress. Please wait for it to finish.', 'woocommerce' ),
(int) WP_Http::CONFLICT
);
}
$result = true;
// Register the site to WPCOM if it is not already registered.
// This sets up the site for connection. For new sites, this tends to take a while.
// It is a prerequisite to generating the WPCOM/Jetpack authorization URL.
if ( ! $this->wpcom_connection_manager->is_connected() ) {
$result = $this->wpcom_connection_manager->try_registration();
if ( is_wp_error( $result ) ) {
throw new ApiException(
'woocommerce_woopayments_onboarding_action_error',
esc_html( $result->get_error_message() ),
(int) WP_Http::INTERNAL_SERVER_ERROR,
map_deep( (array) $result->get_error_data(), 'esc_html' )
);
}
}
return array(
'success' => $result,
);
}