mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-24 08:12:24 +02:00
fix ts errors
This commit is contained in:
parent
b1461d699f
commit
1b740a76cf
@ -65,7 +65,7 @@ async function createUserViaSubscription(ctx: AppContext, options: WebhookOption
|
||||
};
|
||||
|
||||
const stripeSessionId = 'sess_123';
|
||||
const stripePrice = findPrice(stripeConfig().prices, { accountType: 2, period: PricePeriod.Monthly });
|
||||
const stripePrice = findPrice(stripeConfig(), { accountType: 2, period: PricePeriod.Monthly });
|
||||
await models().keyValue().setValue(`stripeSessionToPriceId::${stripeSessionId}`, stripePrice.id);
|
||||
|
||||
await simulateWebhook(ctx, 'customer.subscription.created', {
|
||||
@ -254,7 +254,7 @@ describe('index/stripe', () => {
|
||||
});
|
||||
await simulateWebhook(ctx, 'customer.subscription.deleted', { id: 'sub_1' });
|
||||
|
||||
const stripePrice = findPrice(stripeConfig().prices, { accountType: 1, period: PricePeriod.Monthly });
|
||||
const stripePrice = findPrice(stripeConfig(), { accountType: 1, period: PricePeriod.Monthly });
|
||||
|
||||
await simulateWebhook(ctx, 'customer.subscription.created', {
|
||||
id: 'sub_new',
|
||||
@ -295,7 +295,7 @@ describe('index/stripe', () => {
|
||||
userEmail: 'toto@example.com',
|
||||
});
|
||||
|
||||
const stripePrice = findPrice(stripeConfig().prices, { accountType: 1, period: PricePeriod.Monthly });
|
||||
const stripePrice = findPrice(stripeConfig(), { accountType: 1, period: PricePeriod.Monthly });
|
||||
|
||||
await simulateWebhook(ctx, 'customer.subscription.created', {
|
||||
id: 'sub_1',
|
||||
|
@ -455,8 +455,8 @@ const getHandlers: Record<string, StripeRouteHandler> = {
|
||||
checkoutTest: async (_stripe: Stripe, _path: SubPath, ctx: AppContext) => {
|
||||
if (globalConfig().env === Env.Prod) throw new ErrorForbidden();
|
||||
|
||||
const basicPrice = findPrice(stripeConfig().prices, { accountType: 1, period: PricePeriod.Monthly });
|
||||
const proPrice = findPrice(stripeConfig().prices, { accountType: 2, period: PricePeriod.Monthly });
|
||||
const basicPrice = findPrice(stripeConfig(), { accountType: 1, period: PricePeriod.Monthly });
|
||||
const proPrice = findPrice(stripeConfig(), { accountType: 2, period: PricePeriod.Monthly });
|
||||
|
||||
const customPriceId = ctx.request.query.price_id;
|
||||
|
||||
|
@ -49,8 +49,8 @@ router.get('upgrade', async (_path: SubPath, ctx: AppContext) => {
|
||||
}
|
||||
|
||||
const priceId = await stripePriceIdByUserId(ctx.joplin.models, ctx.joplin.owner.id);
|
||||
const currentPrice = findPrice(stripeConfig().prices, { priceId });
|
||||
const upgradePrice = findPrice(stripeConfig().prices, {
|
||||
const currentPrice = findPrice(stripeConfig(), { priceId });
|
||||
const upgradePrice = findPrice(stripeConfig(), {
|
||||
accountType: AccountType.Pro,
|
||||
period: currentPrice.period,
|
||||
});
|
||||
|
@ -22,12 +22,12 @@ export function initStripe(): Stripe {
|
||||
}
|
||||
|
||||
export function priceIdToAccountType(priceId: string): AccountType {
|
||||
const price = findPrice(stripeConfig().prices, { priceId });
|
||||
const price = findPrice(stripeConfig(), { priceId });
|
||||
return price.accountType;
|
||||
}
|
||||
|
||||
export function accountTypeToPriceId(accountType: AccountType): string {
|
||||
const price = findPrice(stripeConfig().prices, { accountType, period: PricePeriod.Monthly });
|
||||
const price = findPrice(stripeConfig(), { accountType, period: PricePeriod.Monthly });
|
||||
return price.id;
|
||||
}
|
||||
|
||||
@ -68,8 +68,8 @@ export async function updateSubscriptionType(models: Models, userId: Uuid, newAc
|
||||
|
||||
const { sub, stripeSub } = await subscriptionInfoByUserId(models, userId);
|
||||
|
||||
const currentPrice = findPrice(stripeConfig().prices, { priceId: stripePriceIdByStripeSub(stripeSub) });
|
||||
const upgradePrice = findPrice(stripeConfig().prices, { accountType: newAccountType, period: currentPrice.period });
|
||||
const currentPrice = findPrice(stripeConfig(), { priceId: stripePriceIdByStripeSub(stripeSub) });
|
||||
const upgradePrice = findPrice(stripeConfig(), { accountType: newAccountType, period: currentPrice.period });
|
||||
|
||||
const items: Stripe.SubscriptionUpdateParams.Item[] = [];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user