Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders

Helcim::is_helcim_in_sandbox_mode │ private │ WC 1.0

Check if the Helcim payment gateway is in sandbox mode.

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

Хуков нет.

Возвращает

?bool. True if the payment gateway is in sandbox mode, false otherwise. Null if the environment could not be determined.

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

// private - только в коде основоного (родительского) класса
$result = $this->is_helcim_in_sandbox_mode( $payment_gateway ): ?bool;
$payment_gateway(WC_Payment_Gateway) (обязательный)
The payment gateway object.

Код Helcim::is_helcim_in_sandbox_mode() WC 11.2.2

private function is_helcim_in_sandbox_mode( WC_Payment_Gateway $payment_gateway ): ?bool {
	try {
		// Helcim stores the active environment ('sandbox'|'live') as a gateway option,
		// read through the gateway's own get_option() so we follow whatever option key
		// and precedence the extension uses internally.
		$environment = $payment_gateway->get_option( 'environment' );
		if ( ! is_string( $environment ) ) {
			return null;
		}

		$environment = strtolower( trim( $environment ) );
		if ( 'sandbox' === $environment ) {
			return true;
		}
		if ( 'live' === $environment ) {
			return false;
		}

		return null;
	} catch ( Throwable $e ) {
		// Do nothing but log so we can investigate.
		SafeGlobalFunctionProxy::wc_get_logger()->debug(
			'Failed to determine if gateway is in sandbox mode: ' . $e->getMessage(),
			array(
				'gateway'   => $payment_gateway->id,
				'source'    => 'settings-payments',
				'exception' => $e,
			)
		);
	}

	// Let the caller know that we couldn't determine the environment.
	return null;
}