Merge pull request #707 from ente-io/manage-non-stripe-subscription
mail to manage paypal and bitpay subscription
This commit is contained in:
commit
c69b6ff1a9
|
@ -9,7 +9,6 @@ import {
|
|||
isOnFreePlan,
|
||||
planForSubscription,
|
||||
hasMobileSubscription,
|
||||
hasPaypalSubscription,
|
||||
getLocalUserSubscription,
|
||||
hasPaidSubscription,
|
||||
getTotalFamilyUsage,
|
||||
|
@ -105,23 +104,20 @@ function PlanSelectorCard(props: Props) {
|
|||
|
||||
async function onPlanSelect(plan: Plan) {
|
||||
if (
|
||||
hasMobileSubscription(subscription) &&
|
||||
!isSubscriptionCancelled(subscription)
|
||||
!hasPaidSubscription(subscription) ||
|
||||
isSubscriptionCancelled(subscription)
|
||||
) {
|
||||
try {
|
||||
props.setLoading(true);
|
||||
await billingService.buySubscription(plan.stripeID);
|
||||
} catch (e) {
|
||||
props.setLoading(false);
|
||||
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(),
|
||||
content: constants.SUBSCRIPTION_PURCHASE_FAILED,
|
||||
close: { variant: 'danger' },
|
||||
});
|
||||
}
|
||||
} else if (hasStripeSubscription(subscription)) {
|
||||
appContext.setDialogMessage({
|
||||
title: `${constants.CONFIRM} ${reverseString(
|
||||
|
@ -141,18 +137,18 @@ function PlanSelectorCard(props: Props) {
|
|||
},
|
||||
close: { text: constants.CANCEL },
|
||||
});
|
||||
} else {
|
||||
try {
|
||||
props.setLoading(true);
|
||||
await billingService.buySubscription(plan.stripeID);
|
||||
} catch (e) {
|
||||
props.setLoading(false);
|
||||
} else if (hasMobileSubscription(subscription)) {
|
||||
appContext.setDialogMessage({
|
||||
title: constants.ERROR,
|
||||
content: constants.SUBSCRIPTION_PURCHASE_FAILED,
|
||||
close: { variant: 'danger' },
|
||||
title: constants.CANCEL_SUBSCRIPTION_ON_MOBILE,
|
||||
content: constants.CANCEL_SUBSCRIPTION_ON_MOBILE_MESSAGE,
|
||||
close: { variant: 'secondary' },
|
||||
});
|
||||
} else {
|
||||
appContext.setDialogMessage({
|
||||
title: constants.MANAGE_PLAN,
|
||||
content: constants.MAIL_TO_MANAGE_SUBSCRIPTION,
|
||||
close: { variant: 'secondary' },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import { openLink } from 'utils/common';
|
|||
const PAYMENT_PROVIDER_STRIPE = 'stripe';
|
||||
const PAYMENT_PROVIDER_APPSTORE = 'appstore';
|
||||
const PAYMENT_PROVIDER_PLAYSTORE = 'playstore';
|
||||
const PAYMENT_PROVIDER_PAYPAL = 'paypal';
|
||||
const FREE_PLAN = 'free';
|
||||
|
||||
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) {
|
||||
if (isPartOfFamily(userDetails.familyData)) {
|
||||
const usage = getTotalFamilyUsage(userDetails.familyData);
|
||||
|
|
|
@ -338,16 +338,16 @@ const englishConstants = {
|
|||
SUBSCRIPTION_ACTIVATE_FAILED: 'Failed to reactivate subscription renewals',
|
||||
|
||||
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',
|
||||
PAYPAL_MANAGE_NOT_SUPPORTED_MESSAGE: () => (
|
||||
MAIL_TO_MANAGE_SUBSCRIPTION: (
|
||||
<>
|
||||
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_COLLECTION: 'Rename album',
|
||||
DELETE_COLLECTION_TITLE: 'Delete album?',
|
||||
|
|
Loading…
Reference in a new issue