Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders
WooPayments::get_onboarding_url
Get the onboarding URL for the payment gateway.
This URL should start or continue the onboarding process.
Метод класса: WooPayments{}
Хуков нет.
Возвращает
Строку. The onboarding URL for the payment gateway.
Использование
$WooPayments = new WooPayments(); $WooPayments->get_onboarding_url( $payment_gateway, $return_url ): string;
- $payment_gateway(WC_Payment_Gateway) (обязательный)
- The payment gateway object.
- $return_url(строка)
- The URL to return to after onboarding. This will likely get attached to the onboarding URL.
По умолчанию: ''
Код WooPayments::get_onboarding_url() WooPayments::get onboarding url WC 10.4.3
public function get_onboarding_url( WC_Payment_Gateway $payment_gateway, string $return_url = '' ): string {
if ( $this->proxy->call_function( 'class_exists', 'WC_Payments_Account' ) &&
$this->proxy->call_function( 'is_callable', 'WC_Payments_Account::get_connect_url' ) ) {
$connect_url = $this->proxy->call_static( 'WC_Payments_Account', 'get_connect_url' );
} else {
$connect_url = parent::get_onboarding_url( $payment_gateway, $return_url );
}
// Default URL params to set, regardless if they exist.
$params = array(
'from' => Constants::is_defined( 'WC_Payments_Onboarding_Service::FROM_WCADMIN_PAYMENTS_SETTINGS' ) ? (string) Constants::get_constant( 'WC_Payments_Onboarding_Service::FROM_WCADMIN_PAYMENTS_SETTINGS' ) : 'WCADMIN_PAYMENT_SETTINGS',
'source' => Constants::is_defined( 'WC_Payments_Onboarding_Service::SOURCE_WCADMIN_SETTINGS_PAGE' ) ? (string) Constants::get_constant( 'WC_Payments_Onboarding_Service::SOURCE_WCADMIN_SETTINGS_PAGE' ) : 'wcadmin-settings-page',
'redirect_to_settings_page' => 'true',
);
// First, sanity check to handle existing accounts.
// Such accounts should keep their current onboarding mode.
// Do not force things either way.
if ( $this->is_account_connected( $payment_gateway ) ) {
return add_query_arg( $params, $connect_url );
}
// We don't have an account yet, so the onboarding link is used to kickstart the process.
// Default to test-account-first onboarding.
$live_onboarding = false;
/*
* Apply our routing logic to determine if we should do a live onboarding/account.
*
* For new stores (not yet launched aka in Coming Soon mode),
* based on the answers provided in the onboarding profile, we will do live onboarding if:
* - Merchant selected “I’m already selling” AND answered either:
* - Yes, I’m selling online.
* - I’m selling both online and offline.
*
* For launched stores, we will only consider live onboarding if all are true:
* - Store is at least 90 days old.
* - Store has an active payments gateway (other than WooPayments).
* - Store has processed a live electronic payment in the past 90 days (any gateway).
*
* @see plugins/woocommerce/client/admin/client/core-profiler/pages/UserProfile.tsx for the values.
*/
if ( filter_var( get_option( 'woocommerce_coming_soon' ), FILTER_VALIDATE_BOOLEAN ) ) {
$onboarding_profile = get_option( OnboardingProfile::DATA_OPTION, array() );
if (
isset( $onboarding_profile['business_choice'] ) && 'im_already_selling' === $onboarding_profile['business_choice'] &&
isset( $onboarding_profile['selling_online_answer'] ) && (
'yes_im_selling_online' === $onboarding_profile['selling_online_answer'] ||
'im_selling_both_online_and_offline' === $onboarding_profile['selling_online_answer']
)
) {
$live_onboarding = true;
}
} elseif (
WCAdminHelper::is_wc_admin_active_for( 90 * DAY_IN_SECONDS ) &&
$this->has_enabled_other_ecommerce_gateways() &&
$this->has_orders()
) {
$live_onboarding = true;
}
// If we are doing live onboarding, we don't need to add more to the URL.
// But for test-drive/sandbox mode, we have work to do.
if ( ! $live_onboarding ) {
$params['test_drive'] = 'true';
$params['auto_start_test_drive_onboarding'] = 'true';
}
return add_query_arg( $params, $connect_url );
}