Skip to content

Commit

Permalink
Merge pull request #1128 from jamesmckenzie/add-custom-base-urls
Browse files Browse the repository at this point in the history
Custom Url configuration
  • Loading branch information
ob-stripe authored Mar 13, 2018
2 parents 38c33dc + 59ec275 commit 7cb8daa
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
45 changes: 45 additions & 0 deletions src/Stripe.net/Infrastructure/Public/StripeConfiguration.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public static class StripeConfiguration
public static TimeSpan? HttpTimeSpan { get; set; }

private static string _apiKey;
private static string _apiBase;
private static string _uploadsBase;
private static string _connectBase;

static StripeConfiguration()
{
Expand All @@ -40,5 +43,47 @@ public static void SetApiKey(string newApiKey)
{
_apiKey = newApiKey;
}

internal static string GetApiBase()
{
if (string.IsNullOrEmpty(_apiBase))
{
_apiBase = Urls.DefaultBaseUrl;
}
return _apiBase;
}

public static void SetApiBase(string baseUrl)
{
_apiBase = baseUrl;
}

internal static string GetUploadsBase()
{
if (string.IsNullOrEmpty(_uploadsBase))
{
_uploadsBase = Urls.DefaultBaseUploadsUrl;
}
return _uploadsBase;
}

public static void SetUploadsBase(string baseUrl)
{
_uploadsBase = baseUrl;
}

internal static string GetConnectBase()
{
if (string.IsNullOrEmpty(_connectBase))
{
_connectBase = Urls.DefaultBaseConnectUrl;
}
return _connectBase;
}

public static void SetConnectBase(string baseUrl)
{
_connectBase = baseUrl;
}
}
}
12 changes: 9 additions & 3 deletions src/Stripe.net/Infrastructure/Urls.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
{
internal static class Urls
{
internal static string BaseUrl => "https://api.stripe.com/v1";
internal static string DefaultBaseUrl => "https://api.stripe.com/v1";

internal static string BaseUrl => StripeConfiguration.GetApiBase();

public static string Invoices => BaseUrl + "/invoices";

Expand Down Expand Up @@ -46,9 +48,13 @@ internal static class Urls

public static string OAuthDeauthorize => BaseConnectUrl + "/oauth/deauthorize";

private static string BaseConnectUrl => "https://connect.stripe.com";
internal static string DefaultBaseConnectUrl => "https://connect.stripe.com";

private static string BaseConnectUrl => StripeConfiguration.GetConnectBase();

internal static string DefaultBaseUploadsUrl => "https://uploads.stripe.com/v1";

private static string BaseUploadsUrl => "https://uploads.stripe.com/v1";
private static string BaseUploadsUrl => StripeConfiguration.GetUploadsBase();

public static string FileUploads => BaseUploadsUrl + "/files";
}
Expand Down

0 comments on commit 7cb8daa

Please sign in to comment.