Automattic\WooCommerce\Admin\API

Plugins::connect_wcpay()publicWC 1.0

Returns a URL that can be used to point the merchant to the WooPayments onboarding flow.

Method of the class: Plugins{}

No Hooks.

Return

\WP_Error|Array. Connect URL.

Usage

$Plugins = new Plugins();
$Plugins->connect_wcpay();

Plugins::connect_wcpay() code WC 9.6.0

public function connect_wcpay() {
	if ( ! class_exists( 'WC_Payments' ) ) {
		return new \WP_Error( 'woocommerce_rest_helper_connect', __( 'There was an error communicating with the WooPayments plugin.', 'woocommerce' ), 500 );
	}

	// Use a WooPayments connect link to let the WooPayments plugin handle the connection flow.
	return array(
		'connectUrl' => add_query_arg(
			array(
				'wcpay-connect' => '1',
				'from'          => 'WCADMIN_PAYMENT_TASK',
				'_wpnonce'      => wp_create_nonce( 'wcpay-connect' ),
			),
			admin_url( 'admin.php' )
		),
	);
}