Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders

Paytrail::is_in_test_modepublicWC 1.0

Try to determine if the payment gateway is in test mode.

This is a best-effort attempt, as there is no standard way to determine this. Trust the true value, but don't consider a false value as definitive.

Method of the class: Paytrail{}

No Hooks.

Returns

true|false. True if the payment gateway is in test mode, false otherwise.

Usage

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

Paytrail::is_in_test_mode() code WC 10.8.1

public function is_in_test_mode( WC_Payment_Gateway $payment_gateway ): bool {
	try {
		return wc_string_to_bool( $payment_gateway->get_option( 'enable_test_mode', 'no' ) );
	} catch ( Throwable $e ) {
		// Do nothing but log so we can investigate.
		SafeGlobalFunctionProxy::wc_get_logger()->debug(
			'Failed to determine if gateway is in test mode: ' . $e->getMessage(),
			array(
				'gateway'   => $payment_gateway->id,
				'source'    => 'settings-payments',
				'exception' => $e,
			)
		);
	}

	return parent::is_in_test_mode( $payment_gateway );
}