1
0
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:
Laurent Cozic 2023-10-06 21:19:57 +01:00
parent b1461d699f
commit 1b740a76cf
4 changed files with 11 additions and 11 deletions

View File

@ -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',

View File

@ -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;

View File

@ -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,
});

View File

@ -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[] = [];