Jelajahi Sumber

Merge pull request #707 from ente-io/manage-non-stripe-subscription

mail to manage paypal and bitpay subscription
Abhinav Kumar 2 tahun lalu
induk
melakukan
c69b6ff1a9

+ 24 - 28
src/components/pages/gallery/PlanSelector/card/index.tsx

@@ -9,7 +9,6 @@ import {
     isOnFreePlan,
     isOnFreePlan,
     planForSubscription,
     planForSubscription,
     hasMobileSubscription,
     hasMobileSubscription,
-    hasPaypalSubscription,
     getLocalUserSubscription,
     getLocalUserSubscription,
     hasPaidSubscription,
     hasPaidSubscription,
     getTotalFamilyUsage,
     getTotalFamilyUsage,
@@ -105,23 +104,20 @@ function PlanSelectorCard(props: Props) {
 
 
     async function onPlanSelect(plan: Plan) {
     async function onPlanSelect(plan: Plan) {
         if (
         if (
-            hasMobileSubscription(subscription) &&
-            !isSubscriptionCancelled(subscription)
+            !hasPaidSubscription(subscription) ||
+            isSubscriptionCancelled(subscription)
         ) {
         ) {
-            appContext.setDialogMessage({
-                title: constants.ERROR,
-                content: constants.CANCEL_SUBSCRIPTION_ON_MOBILE,
-                close: { variant: 'danger' },
-            });
-        } else if (
-            hasPaypalSubscription(subscription) &&
-            !isSubscriptionCancelled(subscription)
-        ) {
-            appContext.setDialogMessage({
-                title: constants.MANAGE_PLAN,
-                content: constants.PAYPAL_MANAGE_NOT_SUPPORTED_MESSAGE(),
-                close: { variant: 'danger' },
-            });
+            try {
+                props.setLoading(true);
+                await billingService.buySubscription(plan.stripeID);
+            } catch (e) {
+                props.setLoading(false);
+                appContext.setDialogMessage({
+                    title: constants.ERROR,
+                    content: constants.SUBSCRIPTION_PURCHASE_FAILED,
+                    close: { variant: 'danger' },
+                });
+            }
         } else if (hasStripeSubscription(subscription)) {
         } else if (hasStripeSubscription(subscription)) {
             appContext.setDialogMessage({
             appContext.setDialogMessage({
                 title: `${constants.CONFIRM} ${reverseString(
                 title: `${constants.CONFIRM} ${reverseString(
@@ -141,18 +137,18 @@ function PlanSelectorCard(props: Props) {
                 },
                 },
                 close: { text: constants.CANCEL },
                 close: { text: constants.CANCEL },
             });
             });
+        } else if (hasMobileSubscription(subscription)) {
+            appContext.setDialogMessage({
+                title: constants.CANCEL_SUBSCRIPTION_ON_MOBILE,
+                content: constants.CANCEL_SUBSCRIPTION_ON_MOBILE_MESSAGE,
+                close: { variant: 'secondary' },
+            });
         } else {
         } else {
-            try {
-                props.setLoading(true);
-                await billingService.buySubscription(plan.stripeID);
-            } catch (e) {
-                props.setLoading(false);
-                appContext.setDialogMessage({
-                    title: constants.ERROR,
-                    content: constants.SUBSCRIPTION_PURCHASE_FAILED,
-                    close: { variant: 'danger' },
-                });
-            }
+            appContext.setDialogMessage({
+                title: constants.MANAGE_PLAN,
+                content: constants.MAIL_TO_MANAGE_SUBSCRIPTION,
+                close: { variant: 'secondary' },
+            });
         }
         }
     }
     }
 
 

+ 0 - 9
src/utils/billing/index.ts

@@ -14,7 +14,6 @@ import { openLink } from 'utils/common';
 const PAYMENT_PROVIDER_STRIPE = 'stripe';
 const PAYMENT_PROVIDER_STRIPE = 'stripe';
 const PAYMENT_PROVIDER_APPSTORE = 'appstore';
 const PAYMENT_PROVIDER_APPSTORE = 'appstore';
 const PAYMENT_PROVIDER_PLAYSTORE = 'playstore';
 const PAYMENT_PROVIDER_PLAYSTORE = 'playstore';
-const PAYMENT_PROVIDER_PAYPAL = 'paypal';
 const FREE_PLAN = 'free';
 const FREE_PLAN = 'free';
 
 
 enum FAILURE_REASON {
 enum FAILURE_REASON {
@@ -169,14 +168,6 @@ export function hasMobileSubscription(subscription: Subscription) {
     );
     );
 }
 }
 
 
-export function hasPaypalSubscription(subscription: Subscription) {
-    return (
-        hasPaidSubscription(subscription) &&
-        subscription.paymentProvider.length > 0 &&
-        subscription.paymentProvider === PAYMENT_PROVIDER_PAYPAL
-    );
-}
-
 export function hasExceededStorageQuota(userDetails: UserDetails) {
 export function hasExceededStorageQuota(userDetails: UserDetails) {
     if (isPartOfFamily(userDetails.familyData)) {
     if (isPartOfFamily(userDetails.familyData)) {
         const usage = getTotalFamilyUsage(userDetails.familyData);
         const usage = getTotalFamilyUsage(userDetails.familyData);

+ 5 - 5
src/utils/strings/englishConstants.tsx

@@ -338,16 +338,16 @@ const englishConstants = {
     SUBSCRIPTION_ACTIVATE_FAILED: 'Failed to reactivate subscription renewals',
     SUBSCRIPTION_ACTIVATE_FAILED: 'Failed to reactivate subscription renewals',
 
 
     SUBSCRIPTION_PURCHASE_SUCCESS_TITLE: 'Thank you',
     SUBSCRIPTION_PURCHASE_SUCCESS_TITLE: 'Thank you',
-    CANCEL_SUBSCRIPTION_ON_MOBILE:
+    CANCEL_SUBSCRIPTION_ON_MOBILE: 'Cancel mobile subscription',
+    CANCEL_SUBSCRIPTION_ON_MOBILE_MESSAGE:
         'Please cancel your subscription from the mobile app to activate a subscription here',
         'Please cancel your subscription from the mobile app to activate a subscription here',
-    PAYPAL_MANAGE_NOT_SUPPORTED_MESSAGE: () => (
+    MAIL_TO_MANAGE_SUBSCRIPTION: (
         <>
         <>
             Please contact us at{' '}
             Please contact us at{' '}
-            <a href="mailto:paypal@ente.io">paypal@ente.io</a> to manage your
-            subscription
+            <Link href={`mailto:support@ente.io`}>support@ente.io</Link> to
+            manage your subscription
         </>
         </>
     ),
     ),
-    PAYPAL_MANAGE_NOT_SUPPORTED: 'Manage paypal plan',
     RENAME: 'Rename',
     RENAME: 'Rename',
     RENAME_COLLECTION: 'Rename album',
     RENAME_COLLECTION: 'Rename album',
     DELETE_COLLECTION_TITLE: 'Delete album?',
     DELETE_COLLECTION_TITLE: 'Delete album?',