feat(api)!: always use localized pricing where it is offered (#2646)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-10 21:22:32 +02:00
1 parent 905af5dd5a
commit f708586c59
62 files changed
+3148 -11917

No files matched your search

@@ -1,6 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {PricingModeEnum} from '@fluxer/schema/src/domains/premium/PremiumSchemas';
import {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas';
import {createStringType} from '@fluxer/schema/src/primitives/SchemaPrimitives';
import {z} from 'zod';
@@ -11,7 +10,11 @@ export type CheckoutPaymentMethod = z.infer<typeof CheckoutPaymentMethodEnum>;
export const CreateCheckoutSessionRequest = z.object({
price_id: createStringType().describe('The Stripe price ID for the subscription plan'),
country_code: createStringType(2, 2).optional().describe('Two-letter country code used for regional pricing'),
country_code: createStringType(2, 2)
.optional()
.describe(
'Two-letter country code used for regional pricing. Only used when the server cannot geolocate the request; otherwise the request GeoIP country wins.',
),
client_geoip_country_code: createStringType(2, 2)
.optional()
.describe('Two-letter country code observed by the client GeoIP store before checkout'),
@@ -19,7 +22,6 @@ export const CreateCheckoutSessionRequest = z.object({
.boolean()
.optional()
.describe('Whether the EU/EEA digital content withdrawal waiver was expressly accepted before checkout'),
pricing_mode: PricingModeEnum.optional().describe('Whether to use localized or standard USD/EUR pricing rules'),
payment_method: CheckoutPaymentMethodEnum.optional().describe(
'Preferred payment method. card (default) uses the account Payment Method Configuration. pix requires a BRL recurring price and enables Pix Automático. upi requires an INR recurring price and enables RBI-compliant UPI mandates.',
),
@@ -4,10 +4,6 @@ import {createStringType} from '@fluxer/schema/src/primitives/SchemaPrimitives';
import {UserPremiumTypesSchema} from '@fluxer/schema/src/primitives/UserSettingsValidators';
import {z} from 'zod';
export const PricingModeEnum = z.enum(['localized', 'base']);
export type PricingMode = z.infer<typeof PricingModeEnum>;
export const WebhookReceivedResponse = z.object({
received: z.boolean().describe('Whether the webhook was successfully received'),
});
@@ -40,8 +36,11 @@ export const PriceIdsResponse = z.object({
export type PriceIdsResponse = z.infer<typeof PriceIdsResponse>;
export const PriceIdsQueryRequest = z.object({
country_code: createStringType(2, 2).optional().describe('Two-letter country code for regional pricing'),
pricing_mode: PricingModeEnum.optional().describe('Whether to resolve localized or standard USD/EUR pricing'),
country_code: createStringType(2, 2)
.optional()
.describe(
'Two-letter country code for regional pricing. Only used when the server cannot geolocate the request; otherwise the request GeoIP country wins.',
),
});
export type PriceIdsQueryRequest = z.infer<typeof PriceIdsQueryRequest>;
@@ -358,7 +357,6 @@ const PremiumBillingState = z.object({
export const PremiumPricingState = z.object({
country_code: createStringType(2, 2).nullable().describe('Country code used to resolve localized prices'),
localized: PriceIdsResponse.nullable().describe('Localized checkout prices resolved from mirrored billing data'),
base: PriceIdsResponse.nullable().describe('Standard USD/EUR checkout prices resolved from mirrored billing data'),
});
export type PremiumPricingState = z.infer<typeof PremiumPricingState>;
@@ -373,7 +371,11 @@ export const PremiumStateResponse = z.object({
export type PremiumStateResponse = z.infer<typeof PremiumStateResponse>;
export const PremiumStateQueryRequest = z.object({
country_code: createStringType(2, 2).optional().describe('Two-letter country code for regional pricing'),
country_code: createStringType(2, 2)
.optional()
.describe(
'Two-letter country code for regional pricing. Only used when the server cannot geolocate the request; otherwise the request GeoIP country wins.',
),
});
export type PremiumStateQueryRequest = z.infer<typeof PremiumStateQueryRequest>;