Skip to content

Commit

Permalink
Merge pull request #160 from Resgrid/develop
Browse files Browse the repository at this point in the history
CU-868a7khdq Changing how stripeCustomerId empty are handled
  • Loading branch information
ucswift authored Oct 12, 2024
2 parents de7ac44 + 4add78c commit b1c15a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Core/Resgrid.Services/DepartmentSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public async Task<string> GetStripeCustomerIdForDepartmentAsync(int departmentId
if (settingValue != null)
return settingValue.Setting;

return null;
return String.Empty;
}

public async Task<int?> GetDepartmentIdForStripeCustomerIdAsync(string stripeCustomerId, bool bypassCache = false)
Expand Down
17 changes: 9 additions & 8 deletions Core/Resgrid.Services/SubscriptionsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using MongoDB.Driver;
using Resgrid.Model;
using Resgrid.Model.Billing.Api;
Expand Down Expand Up @@ -995,7 +996,7 @@ public async Task<CreateStripeSessionForUpdateData> CreateStripeSessionForUpdate
request.AddHeader("X-API-Key", Config.ApiConfig.BackendInternalApikey);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("departmentId", departmentId, ParameterType.QueryString);
request.AddParameter("stripeCustomerId", stripeCustomerId, ParameterType.QueryString);
request.AddParameter("stripeCustomerId", Uri.EscapeDataString(stripeCustomerId), ParameterType.QueryString);
request.AddParameter("email", email, ParameterType.QueryString, true);
request.AddParameter("departmentName", departmentName, ParameterType.QueryString, true);

Expand All @@ -1021,7 +1022,7 @@ public async Task<GetCanceledPlanFromStripeData> GetActiveStripeSubscriptionAsyn
var request = new RestRequest($"/api/Billing/GetActiveStripeSubscription", Method.Get);
request.AddHeader("X-API-Key", Config.ApiConfig.BackendInternalApikey);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("stripeCustomerId", stripeCustomerId, ParameterType.QueryString);
request.AddParameter("stripeCustomerId", Uri.EscapeDataString(stripeCustomerId), ParameterType.QueryString);

var response = await client.ExecuteAsync<GetCanceledPlanFromStripeResult>(request);

Expand All @@ -1045,7 +1046,7 @@ public async Task<GetCanceledPlanFromStripeData> GetActivePTTStripeSubscriptionA
var request = new RestRequest($"/api/Billing/GetActivePTTStripeSubscription", Method.Get);
request.AddHeader("X-API-Key", Config.ApiConfig.BackendInternalApikey);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("stripeCustomerId", stripeCustomerId, ParameterType.QueryString);
request.AddParameter("stripeCustomerId", Uri.EscapeDataString(stripeCustomerId), ParameterType.QueryString);

var response = await client.ExecuteAsync<GetCanceledPlanFromStripeResult>(request);

Expand All @@ -1069,7 +1070,7 @@ public async Task<bool> ModifyPTTAddonSubscriptionAsync(string stripeCustomerId,
var request = new RestRequest($"/api/Billing/ModifyPTTAddonSubscription", Method.Get);
request.AddHeader("X-API-Key", Config.ApiConfig.BackendInternalApikey);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("stripeCustomerId", stripeCustomerId, ParameterType.QueryString);
request.AddParameter("stripeCustomerId", Uri.EscapeDataString(stripeCustomerId), ParameterType.QueryString);
request.AddParameter("quantity", quantity, ParameterType.QueryString);
request.AddParameter("planAddonId", planAddon.PlanAddonId, ParameterType.QueryString);

Expand All @@ -1095,7 +1096,7 @@ public async Task<bool> CancelSubscriptionAsync(string stripeCustomerId)
var request = new RestRequest($"/api/Billing/CancelSubscription", Method.Get);
request.AddHeader("X-API-Key", Config.ApiConfig.BackendInternalApikey);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("stripeCustomerId", stripeCustomerId, ParameterType.QueryString);
request.AddParameter("stripeCustomerId", Uri.EscapeDataString(stripeCustomerId), ParameterType.QueryString);

var response = await client.ExecuteAsync<GetHasActiveSubForDepartmentFromStripeResult>(request);

Expand All @@ -1119,7 +1120,7 @@ public async Task<CreateStripeBillingPortalSessionData> CreateStripeSessionForCu
var request = new RestRequest($"/api/Billing/CreateStripeSessionForCustomerPortal", Method.Get);
request.AddHeader("X-API-Key", Config.ApiConfig.BackendInternalApikey);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("stripeCustomerId", stripeCustomerId, ParameterType.QueryString);
request.AddParameter("stripeCustomerId", Uri.EscapeDataString(stripeCustomerId), ParameterType.QueryString);
request.AddParameter("departmentId", departmentId, ParameterType.QueryString);

if (!String.IsNullOrWhiteSpace(customerConfigId))
Expand Down Expand Up @@ -1155,7 +1156,7 @@ public async Task<CreateStripeSessionForUpdateData> CreateStripeSessionForSub(in
var request = new RestRequest($"/api/Billing/CreateStripeSessionForSubscriptionCheckout", Method.Get);
request.AddHeader("X-API-Key", Config.ApiConfig.BackendInternalApikey);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("stripeCustomerId", stripeCustomerId, ParameterType.QueryString);
request.AddParameter("stripeCustomerId", Uri.EscapeDataString(stripeCustomerId), ParameterType.QueryString);
request.AddParameter("departmentId", departmentId, ParameterType.QueryString);
request.AddParameter("stripePlanId", stripePlanId, ParameterType.QueryString);
request.AddParameter("planId", planId, ParameterType.QueryString);
Expand Down Expand Up @@ -1185,7 +1186,7 @@ public async Task<ChangeActiveSubscriptionData> ChangeActiveSubscriptionAsync(st
var request = new RestRequest($"/api/Billing/ChangeActiveSubscription", Method.Get);
request.AddHeader("X-API-Key", Config.ApiConfig.BackendInternalApikey);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("stripeCustomerId", stripeCustomerId, ParameterType.QueryString);
request.AddParameter("stripeCustomerId", Uri.EscapeDataString(stripeCustomerId), ParameterType.QueryString);
request.AddParameter("stripePlanId", stripePlanId, ParameterType.QueryString);

var response = await client.ExecuteAsync<ChangeActiveSubscriptionResult>(request);
Expand Down

0 comments on commit b1c15a4

Please sign in to comment.