Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders

PaymentGateway::is_account_connectedpublicWC 1.0

Check if the payment gateway has a payments processor account connected.

Note: Be extra careful if you override this method and rely on needs_setup() since it could lead to an infinite loop.

Метод класса: PaymentGateway{}

Хуков нет.

Возвращает

true|false. True if the payment gateway account is connected, false otherwise. If the payment gateway does not provide the information, it will return true.

Использование

$PaymentGateway = new PaymentGateway();
$PaymentGateway->is_account_connected( $payment_gateway ): bool;
$payment_gateway(WC_Payment_Gateway) (обязательный)
The payment gateway object.

Код PaymentGateway::is_account_connected() WC 10.7.0

public function is_account_connected( WC_Payment_Gateway $payment_gateway ): bool {
	try {
		if ( method_exists( $payment_gateway, 'is_account_connected' ) && is_callable( array( $payment_gateway, 'is_account_connected' ) ) ) {
			return wc_string_to_bool( $payment_gateway->is_account_connected() );
		}

		if ( method_exists( $payment_gateway, 'is_connected' ) && is_callable( array( $payment_gateway, 'is_connected' ) ) ) {
			return wc_string_to_bool( $payment_gateway->is_connected() );
		}
	} catch ( Throwable $e ) {
		// Do nothing but log so we can investigate.
		SafeGlobalFunctionProxy::wc_get_logger()->debug(
			'Failed to determine if gateway account is connected: ' . $e->getMessage(),
			array(
				'gateway'   => $payment_gateway->id,
				'source'    => 'settings-payments',
				'exception' => $e,
			)
		);
	}

	// Fall back to assuming that it is connected. This is the safest option.
	return true;
}