Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders

Paystack::needs_setuppublicWC 1.0

Check if the payment gateway needs setup.

Method of the class: Paystack{}

No Hooks.

Returns

true|false. True if the payment gateway needs setup, false otherwise.

Usage

$Paystack = new Paystack();
$Paystack->needs_setup( $payment_gateway ): bool;
$payment_gateway(WC_Payment_Gateway) (required)
The payment gateway object.

Paystack::needs_setup() code WC 10.9.4

public function needs_setup( WC_Payment_Gateway $payment_gateway ): bool {
	try {
		$is_valid_for_use = true;
		if ( is_callable( array( $payment_gateway, 'is_valid_for_use' ) ) ) {
			$is_valid_for_use = wc_string_to_bool( $payment_gateway->is_valid_for_use() );
		}

		return ! $is_valid_for_use || ! $this->is_account_connected( $payment_gateway );
	} catch ( Throwable $e ) {
		// Do nothing but log so we can investigate.
		SafeGlobalFunctionProxy::wc_get_logger()->debug(
			'Failed to determine if gateway needs setup: ' . $e->getMessage(),
			array(
				'gateway'   => $payment_gateway->id,
				'source'    => 'settings-payments',
				'exception' => $e,
			)
		);
	}

	return parent::needs_setup( $payment_gateway );
}