commit
073880de50
|
@ -16,6 +16,8 @@ import {
|
|||
hasPaidSubscription,
|
||||
isOnFreePlan,
|
||||
planForSubscription,
|
||||
hasMobileSubscription,
|
||||
hasPaypalSubscription,
|
||||
} from 'utils/billing';
|
||||
import { reverseString } from 'utils/common';
|
||||
import { SetDialogMessage } from 'components/MessageDialog';
|
||||
|
@ -143,8 +145,7 @@ function PlanSelector(props: Props) {
|
|||
|
||||
async function onPlanSelect(plan: Plan) {
|
||||
if (
|
||||
hasPaidSubscription(subscription) &&
|
||||
!hasStripeSubscription(subscription) &&
|
||||
hasMobileSubscription(subscription) &&
|
||||
!isSubscriptionCancelled(subscription)
|
||||
) {
|
||||
props.setDialogMessage({
|
||||
|
@ -152,6 +153,15 @@ function PlanSelector(props: Props) {
|
|||
content: constants.CANCEL_SUBSCRIPTION_ON_MOBILE,
|
||||
close: { variant: 'danger' },
|
||||
});
|
||||
} else if (
|
||||
hasPaypalSubscription(subscription) &&
|
||||
!isSubscriptionCancelled(subscription)
|
||||
) {
|
||||
props.setDialogMessage({
|
||||
title: constants.MANAGE_PLAN,
|
||||
content: constants.PAYPAL_MANAGE_NOT_SUPPORTED_MESSAGE(),
|
||||
close: { variant: 'danger' },
|
||||
});
|
||||
} else if (hasStripeSubscription(subscription)) {
|
||||
props.setDialogMessage({
|
||||
title: `${constants.CONFIRM} ${reverseString(
|
||||
|
|
|
@ -9,6 +9,9 @@ import { CustomError } from '../error';
|
|||
import { logError } from '../sentry';
|
||||
|
||||
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 {
|
||||
|
@ -96,6 +99,23 @@ export function hasStripeSubscription(subscription: Subscription) {
|
|||
);
|
||||
}
|
||||
|
||||
export function hasMobileSubscription(subscription: Subscription) {
|
||||
return (
|
||||
hasPaidSubscription(subscription) &&
|
||||
subscription.paymentProvider.length > 0 &&
|
||||
(subscription.paymentProvider === PAYMENT_PROVIDER_APPSTORE ||
|
||||
subscription.paymentProvider === PAYMENT_PROVIDER_PLAYSTORE)
|
||||
);
|
||||
}
|
||||
|
||||
export function hasPaypalSubscription(subscription: Subscription) {
|
||||
return (
|
||||
hasPaidSubscription(subscription) &&
|
||||
subscription.paymentProvider.length > 0 &&
|
||||
subscription.paymentProvider === PAYMENT_PROVIDER_PAYPAL
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateSubscription(
|
||||
plan: Plan,
|
||||
setDialogMessage: SetDialogMessage,
|
||||
|
|
|
@ -332,6 +332,14 @@ const englishConstants = {
|
|||
SUBSCRIPTION_PURCHASE_SUCCESS_TITLE: 'thank you',
|
||||
CANCEL_SUBSCRIPTION_ON_MOBILE:
|
||||
'please cancel your subscription from the mobile app to activate a subscription here',
|
||||
PAYPAL_MANAGE_NOT_SUPPORTED_MESSAGE: () => (
|
||||
<>
|
||||
please contact us at{' '}
|
||||
<a href="mailto:paypal@ente.io">paypal@ente.io</a> to manage your
|
||||
subscription
|
||||
</>
|
||||
),
|
||||
PAYPAL_MANAGE_NOT_SUPPORTED: 'manage paypal plan',
|
||||
RENAME: 'rename',
|
||||
RENAME_COLLECTION: 'rename album',
|
||||
CONFIRM_DELETE_COLLECTION: 'confirm album deletion',
|
||||
|
|
Loading…
Reference in a new issue