Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders

Stripe::is_in_test_mode_onboardingpublicWC 1.0

Try to determine if the payment gateway is in test mode onboarding (aka sandbox or test-drive).

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 onboarding, false otherwise.

Usage

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

Stripe::is_in_test_mode_onboarding() code WC 10.7.0

public function is_in_test_mode_onboarding( WC_Payment_Gateway $payment_gateway ): bool {
	try {
		if ( class_exists( '\WC_Stripe' ) && is_callable( '\WC_Stripe::get_instance' ) ) {
			$stripe = \WC_Stripe::get_instance();
			if ( is_object( $stripe ) && isset( $stripe->connect ) &&
				class_exists( '\WC_Stripe_Connect' ) &&
				$stripe->connect instanceof \WC_Stripe_Connect &&
				is_callable( array( $stripe->connect, 'is_connected' ) ) ) {

				return $stripe->connect->is_connected( 'test' )
					&& ! $stripe->connect->is_connected( 'live' );
			}
		}
	} 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 onboarding: ' . $e->getMessage(),
			array(
				'gateway'   => $payment_gateway->id,
				'source'    => 'settings-payments',
				'exception' => $e,
			)
		);
	}

	return parent::is_in_test_mode_onboarding( $payment_gateway );
}