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.

Method of the class: Helcim{}

No Hooks.

Returns

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

Usage

// private - for code of main (parent) class only
$result = $this->is_helcim_in_sandbox_mode( $payment_gateway ): ?bool;
$payment_gateway(WC_Payment_Gateway) (required)
The payment gateway object.

Helcim::is_helcim_in_sandbox_mode() code WC 11.1.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;
}