Automattic\WooCommerce\Internal\Admin\Settings\PaymentProviders
WooPayments::needs_setup
Check if the payment gateway needs setup.
Method of the class: WooPayments{}
No Hooks.
Returns
true|false
. True if the payment gateway needs setup, false otherwise.
Usage
$WooPayments = new WooPayments(); $WooPayments->needs_setup( $payment_gateway ): bool;
- $payment_gateway(WC_Payment_Gateway) (required)
- The payment gateway object.
WooPayments::needs_setup() WooPayments::needs setup code WC 9.9.3
public function needs_setup( WC_Payment_Gateway $payment_gateway ): bool { // No account means we need setup. if ( ! $this->is_account_connected( $payment_gateway ) ) { return true; } if ( function_exists( '\wcpay_get_container' ) && class_exists( '\WC_Payments_Account' ) ) { $account = \wcpay_get_container()->get( \WC_Payments_Account::class ); if ( is_callable( array( $account, 'get_account_status_data' ) ) ) { // Test-drive accounts don't need setup. $account_status = $account->get_account_status_data(); if ( ! empty( $account_status['testDrive'] ) ) { return false; } } } return parent::needs_setup( $payment_gateway ); }