is_in_test_mode( $payment_gateway ) ) { return property_exists( $payment_gateway, 'test_client_id' ) && ! empty( $payment_gateway->test_client_id ) && property_exists( $payment_gateway, 'test_client_secret' ) && ! empty( $payment_gateway->test_client_secret ) && property_exists( $payment_gateway, 'test_source_code' ) && ! empty( $payment_gateway->test_source_code ); } else { return property_exists( $payment_gateway, 'client_id' ) && ! empty( $payment_gateway->client_id ) && property_exists( $payment_gateway, 'client_secret' ) && ! empty( $payment_gateway->client_secret ) && property_exists( $payment_gateway, 'source_code' ) && ! empty( $payment_gateway->source_code ); } } catch ( Throwable $e ) { // Do nothing but log so we can investigate. SafeGlobalFunctionProxy::wc_get_logger()->debug( 'Failed to determine if gateway has an account connected: ' . $e->getMessage(), array( 'gateway' => $payment_gateway->id, 'source' => 'settings-payments', 'exception' => $e, ) ); } return parent::is_account_connected( $payment_gateway ); } /** * 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. * * @param WC_Payment_Gateway $payment_gateway The payment gateway object. * * @return bool True if the payment gateway is in test mode onboarding, false otherwise. */ public function is_in_test_mode_onboarding( WC_Payment_Gateway $payment_gateway ): bool { // Test mode is actually sandbox mode for Viva.com, affecting the used API keys. return $this->is_in_test_mode( $payment_gateway ); } }