diff --git a/packages/billing/core/src/create-billing-schema.ts b/packages/billing/core/src/create-billing-schema.ts index 34ba4805f..bdc9c05ff 100644 --- a/packages/billing/core/src/create-billing-schema.ts +++ b/packages/billing/core/src/create-billing-schema.ts @@ -215,13 +215,13 @@ const BillingSchema = z for (const product of schema.products) { for (const plan of product.plans) { if (plan.lineItems.length > 1) { - return true; + return false; } } } - - return true; } + + return true; }, { message: 'Lemon Squeezy only supports one line item per plan', diff --git a/packages/billing/gateway/src/components/plan-picker.tsx b/packages/billing/gateway/src/components/plan-picker.tsx index e16921b35..3c3c8a7f3 100644 --- a/packages/billing/gateway/src/components/plan-picker.tsx +++ b/packages/billing/gateway/src/components/plan-picker.tsx @@ -15,6 +15,7 @@ import { getPrimaryLineItem, getProductPlanPair, } from '@kit/billing'; +import config from '@kit/prettier-config/index.mjs'; import { formatCurrency } from '@kit/shared/utils'; import { Badge } from '@kit/ui/badge'; import { Button } from '@kit/ui/button'; @@ -153,13 +154,15 @@ export function PlanPicker( id={interval} value={interval} onClick={() => { - form.setValue('planId', '', { - shouldValidate: true, - }); + if (selectedProduct) { + const plan = selectedProduct.plans.find( + (item) => item.interval === interval, + ); - form.setValue('productId', '', { - shouldValidate: true, - }); + form.setValue('planId', plan?.id ?? '', { + shouldValidate: true, + }); + } form.setValue('interval', interval, { shouldValidate: true,