Browse Source

Patch few Stripe related issues (#1156)

Vishnu Mohandas 1 year ago
parent
commit
8101fe1495

+ 5 - 1
mobile/lib/services/billing_service.dart

@@ -16,7 +16,11 @@ import 'package:photos/services/user_service.dart';
 import 'package:photos/ui/common/web_page.dart';
 import 'package:photos/ui/common/web_page.dart';
 import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/dialog_util.dart';
 
 
-const kWebPaymentRedirectUrl = "https://payments.ente.io/frameRedirect";
+const kWebPaymentRedirectUrl = String.fromEnvironment(
+  "web-payment-redirect",
+  defaultValue: "https://payments.ente.io/frameRedirect",
+);
+
 const kWebPaymentBaseEndpoint = String.fromEnvironment(
 const kWebPaymentBaseEndpoint = String.fromEnvironment(
   "web-payment",
   "web-payment",
   defaultValue: "https://payments.ente.io",
   defaultValue: "https://payments.ente.io",

+ 1 - 1
mobile/lib/ui/payment/stripe_subscription_page.dart

@@ -331,6 +331,7 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
     await _dialog.show();
     await _dialog.show();
     try {
     try {
       final String url = await _billingService.getStripeCustomerPortalUrl();
       final String url = await _billingService.getStripeCustomerPortalUrl();
+      await _dialog.hide();
       await Navigator.of(context).push(
       await Navigator.of(context).push(
         MaterialPageRoute(
         MaterialPageRoute(
           builder: (BuildContext context) {
           builder: (BuildContext context) {
@@ -342,7 +343,6 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
       await _dialog.hide();
       await _dialog.hide();
       await showGenericErrorDialog(context: context, error: e);
       await showGenericErrorDialog(context: context, error: e);
     }
     }
-    await _dialog.hide();
   }
   }
 
 
   Widget _stripeRenewOrCancelButton() {
   Widget _stripeRenewOrCancelButton() {

+ 5 - 0
server/pkg/controller/stripe.go

@@ -296,6 +296,11 @@ func (c *StripeController) handleCustomerSubscriptionDeleted(event stripe.Event)
 		return ente.StripeEventLog{}, stacktrace.Propagate(err, "")
 		return ente.StripeEventLog{}, stacktrace.Propagate(err, "")
 	}
 	}
 
 
+	err = c.BillingRepo.UpdateSubscriptionCancellationStatus(userID, true)
+	if err != nil {
+		return ente.StripeEventLog{}, stacktrace.Propagate(err, "")
+	}
+
 	skipMail := stripeSubscription.Metadata[SkipMailKey]
 	skipMail := stripeSubscription.Metadata[SkipMailKey]
 	// Send a cancellation notification email for folks who are either on
 	// Send a cancellation notification email for folks who are either on
 	// individual plan or admin of a family plan.
 	// individual plan or admin of a family plan.