Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CU-868a7khdq Changing how stripeCustomerId empty are handled #160

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading