/// <summary> /// Checks that stripe-mock is running and that it's a recent enough version. /// </summary> private static object InitStripeMock() { port = Environment.GetEnvironmentVariable("STRIPE_MOCK_PORT") ?? "12111"; string url = $"http://localhost:{port}"; using (HttpClient client = new HttpClient()) { HttpResponseMessage response; try { response = client.GetAsync(url).Result; } catch (Exception) { throw new Exception( $"Couldn't reach stripe-mock at `localhost:{port}`. " + "Is it running? Please see README for setup instructions."); } string version = response.Headers.GetValues("Stripe-Mock-Version").FirstOrDefault(); if (!version.Equals("master") && (CompareVersions(version, MockMinimumVersion) > 0)) { throw new Exception( $"Your version of stripe-mock ({version}) is too old. The minimum " + $"version to run this test suite is {MockMinimumVersion}. Please see its " + "repository for upgrade instructions."); } } StripeConfiguration.SetApiBase($"http://localhost:{port}/v1"); StripeConfiguration.SetUploadsBase($"http://localhost:{port}/v1"); StripeConfiguration.SetApiKey("sk_test_123"); return(null); }