From da0aa1740d6f1a63f922e934e2e5ea41141782f3 Mon Sep 17 00:00:00 2001 From: Filip Bekic Date: Sun, 22 Sep 2024 20:12:44 +0200 Subject: [PATCH] Fix Stripe env vars --- .../Features/Stripe/ChangePlan/ChangePlanFeature.cs | 4 ++-- .../Stripe/CreateSubscription/CreateSubscriptionFeature.cs | 4 ++-- backend/ResQueue/ResQueue/Settings.cs | 3 +++ backend/ResQueue/ResQueue/appsettings.Development.json | 6 ++++-- frontend/.env.debug | 3 ++- frontend/.env.prod | 4 ++-- frontend/env.d.ts | 1 + frontend/src/composables/stripeComposable.ts | 4 +--- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/backend/ResQueue/ResQueue/Features/Stripe/ChangePlan/ChangePlanFeature.cs b/backend/ResQueue/ResQueue/Features/Stripe/ChangePlan/ChangePlanFeature.cs index ef896c5..f33fb6a 100644 --- a/backend/ResQueue/ResQueue/Features/Stripe/ChangePlan/ChangePlanFeature.cs +++ b/backend/ResQueue/ResQueue/Features/Stripe/ChangePlan/ChangePlanFeature.cs @@ -29,8 +29,8 @@ public async Task> ExecuteAsync(ChangePlanRe var dc = new Dictionary { - { StripePlans.ESSENTIALS, "price_1PpyCoKE6sxW2owa2SY4jGXp" }, - { StripePlans.ULTIMATE, "price_1PpyDFKE6sxW2owaWndg9Wxc" } + { StripePlans.ESSENTIALS, settings.Value.StripeEssentialsPriceId }, + { StripePlans.ULTIMATE, settings.Value.StripeUltimatePriceId } }; // Get user diff --git a/backend/ResQueue/ResQueue/Features/Stripe/CreateSubscription/CreateSubscriptionFeature.cs b/backend/ResQueue/ResQueue/Features/Stripe/CreateSubscription/CreateSubscriptionFeature.cs index 77dc218..5557bbf 100644 --- a/backend/ResQueue/ResQueue/Features/Stripe/CreateSubscription/CreateSubscriptionFeature.cs +++ b/backend/ResQueue/ResQueue/Features/Stripe/CreateSubscription/CreateSubscriptionFeature.cs @@ -31,8 +31,8 @@ public async Task> ExecuteAsync(Crea var dc = new Dictionary { - { StripePlans.ESSENTIALS, "price_1PpyCoKE6sxW2owa2SY4jGXp" }, - { StripePlans.ULTIMATE, "price_1PpyDFKE6sxW2owaWndg9Wxc" } + { StripePlans.ESSENTIALS, settings.Value.StripeEssentialsPriceId }, + { StripePlans.ULTIMATE, settings.Value.StripeUltimatePriceId } }; if (!dc.TryGetValue(request.Dto.Plan.ToLower(), out var priceId)) diff --git a/backend/ResQueue/ResQueue/Settings.cs b/backend/ResQueue/ResQueue/Settings.cs index ad74adc..d862f11 100644 --- a/backend/ResQueue/ResQueue/Settings.cs +++ b/backend/ResQueue/ResQueue/Settings.cs @@ -12,4 +12,7 @@ public class Settings public string StripeSecret { get; set; } = null!; public string StripeSecretWebhook { get; set; } = null!; public string WebsiteUrl { get; set; } = null!; + + public string StripeEssentialsPriceId { get; set; } = null!; + public string StripeUltimatePriceId { get; set; } = null!; } \ No newline at end of file diff --git a/backend/ResQueue/ResQueue/appsettings.Development.json b/backend/ResQueue/ResQueue/appsettings.Development.json index 8b69187..50e5559 100644 --- a/backend/ResQueue/ResQueue/appsettings.Development.json +++ b/backend/ResQueue/ResQueue/appsettings.Development.json @@ -12,7 +12,9 @@ "SmtpPort": "25", "SmtpUsername": "0446e7630b990d", "SmtpPassword": "cf4a06720b6dd1", - "StripeSecret": "sk_test_51PpxV4KE6sxW2owadyGKDtUF7cDjpCEtD83stbkfbzd7FqPfleW0pWKEmJR6BGr7oLnwIjRAQPCFxQsnMDYOr79h00cKaT8nO1", - "StripeSecretWebhook": "whsec_R3uUedvZktGW61aqe1d5Rrv5mXiMvLen" + "StripeSecret": "sk_test_51Q1suB0313W5fRAAja6UVcEzQ02JyZK3KBkXIdh0VPRZiixYOqkZdNXXRsC9DSXiemxSO2RHIL3ATvZZdsKf3cHi005qp3XCGR", + "StripeSecretWebhook": "whsec_R3uUedvZktGW61aqe1d5Rrv5mXiMvLen", + "StripeEssentialsPriceId": "price_1Q1uCh0313W5fRAACe4u6FGJ", + "StripeUltimatePriceId": "price_1Q1uDh0313W5fRAA9MyIlum8" } } diff --git a/frontend/.env.debug b/frontend/.env.debug index 6288e4f..885c8c3 100644 --- a/frontend/.env.debug +++ b/frontend/.env.debug @@ -1 +1,2 @@ -VITE_API_URL=http://localhost:5004/api +VITE_STRIPE_PUBLIC_KEY=pk_test_51Q1suB0313W5fRAAfBXGN7WrQIzTG0uzbGUcJH8eDaaw2DxkC3U0WCZh9W5l8IJmJPmcsUP1Zj9Ezc2VwwDYoW0p00dTk7ZQUk +VITE_API_URL=http://localhost:5004/api \ No newline at end of file diff --git a/frontend/.env.prod b/frontend/.env.prod index b0740fd..83e7c7a 100644 --- a/frontend/.env.prod +++ b/frontend/.env.prod @@ -1,2 +1,2 @@ - -# No VITE_API_URL since it is deployed on the same server +VITE_STRIPE_PUBLIC_KEY=pk_live_51Q1suB0313W5fRAAxrIQ4gDCLkGKf8zojJm3Vgu79hemGsxVSH4E0mrrR70flcaaYKbTBNDfUhJKBdLB7mXS1U8w00OXSmmuPU +#VITE_API_URL=No URL since it is deployed on the same server diff --git a/frontend/env.d.ts b/frontend/env.d.ts index 10617ac..480e854 100644 --- a/frontend/env.d.ts +++ b/frontend/env.d.ts @@ -5,4 +5,5 @@ interface ImportMeta { interface ImportMetaEnv { readonly VITE_API_URL?: string + readonly VITE_STRIPE_PUBLIC_KEY: string } diff --git a/frontend/src/composables/stripeComposable.ts b/frontend/src/composables/stripeComposable.ts index 77b5bda..617d088 100644 --- a/frontend/src/composables/stripeComposable.ts +++ b/frontend/src/composables/stripeComposable.ts @@ -11,9 +11,7 @@ const loadStripeAsync = async () => { isLoading.value = true try { - stripe.value = await loadStripe( - 'pk_test_51PpxV4KE6sxW2owau69f5U6Fzf5uMnUIgo9gB8WxnCkaix9pcxn9yGr1erlTZjPt2ec7I8X42eKKmNpCgNoaDxw300PVRqNQUe' - ) + stripe.value = await loadStripe(import.meta.env.VITE_STRIPE_PUBLIC_KEY) if (!stripe.value) { console.error('Failed method loadStripeAsync')