Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders

Stripe::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: Stripe{}

No Hooks.

Returns

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

Usage

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

Stripe::is_in_test_mode() code WC 10.7.0

public function is_in_test_mode( WC_Payment_Gateway $payment_gateway ): bool {
	try {
		if ( class_exists( '\WC_Stripe_Mode' ) &&
			is_callable( '\WC_Stripe_Mode::is_test' ) ) {

			return wc_string_to_bool( \WC_Stripe_Mode::is_test() );
		}
	} 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 );
}