@fleetless/contracts 15.6.0 → 16.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/billing.js CHANGED
@@ -302,7 +302,7 @@ export const purchaseBillingDetails = billingDetails.options[0].superRefine((pay
302
302
  ctx.addIssue({ code: 'custom', path: ['address', 'state'], message: 'us_state_required' });
303
303
  }
304
304
  }).meta({ description: 'New company purchase. Other EU countries require VAT ID; non-EU requires Tax ID; US requires two-letter state. Cloud additionally checks the versioned public-email policy and current VIES evidence.' });
305
- /** Generate before POST, persist across reloads; unique within the authenticated org. */
305
+ /** Generate before POST; unique within the authenticated org. A checkout or paid change takes a fresh key per press. */
306
306
  export const purchaseOperation = z.enum(['checkout', 'paid_change', 'invoice_payment', 'payment_method_invoice', 'mandate_setup']);
307
307
  const chargeOperation = purchaseOperation.exclude(['mandate_setup']);
308
308
  /** Starting a checkout records an intent; only confirming its current quote may create a payment. */
@@ -420,15 +420,132 @@ const firstPaymentPeriod = z.discriminatedUnion('cycle', [
420
420
  }),
421
421
  ]);
422
422
  export const billingDecisionPeriod = z.union([existingBillingPeriod, firstPaymentPeriod]);
423
- const declaration = z.object({
424
- text_id: z.literal('DR-1374-draft-3-C.4'),
425
- text: z.string().min(1),
426
- terms: legalDocumentReference,
427
- dpa: legalDocumentReference,
428
- }).strict().superRefine((value, ctx) => {
423
+ /*
424
+ * ---------------------------------------------------------------------------
425
+ * The C.4 declaration: one consent sentence and one button label per action
426
+ * (2026-11-18, fleetless/fleetless#1168).
427
+ *
428
+ * A decision display names what the button above it does. The sentence and
429
+ * the label are built here from the snapshot's own amounts, plan, cycle and
430
+ * organization, so the cloud that issues a display and every client that
431
+ * renders one write the same words, and a snapshot whose words do not match
432
+ * its decision does not parse.
433
+ * ---------------------------------------------------------------------------
434
+ */
435
+ /**
436
+ * Euro cents the way the console writes money: `de-DE` digits, whole euros
437
+ * without `,00`, a plain space before the sign — `34,51 €`, `29 €`,
438
+ * `1.234,56 €`. Throws for anything but a safe integer.
439
+ */
440
+ export function formatEur(cents) {
441
+ if (!Number.isSafeInteger(cents))
442
+ throw new Error(`formatEur: ${cents} is not a whole number of cents`);
443
+ const abs = Math.abs(cents);
444
+ const euros = String(Math.floor(abs / 100)).replace(/\B(?=(\d{3})+(?!\d))/g, '.');
445
+ const rest = abs % 100;
446
+ return `${cents < 0 ? '-' : ''}${euros}${rest === 0 ? '' : `,${String(rest).padStart(2, '0')}`} €`;
447
+ }
448
+ /**
449
+ * What the owner's one click does: buy a first plan, pay now and switch,
450
+ * switch at no charge, switch from yearly to monthly at the period end,
451
+ * schedule a lower plan (or fewer add-ons), or cancel to Basic.
452
+ */
453
+ export const C4_ACTIONS = ['checkout', 'pay_and_switch', 'switch', 'schedule_switch', 'schedule_downgrade', 'cancel'];
454
+ /** The approved sentence of each action, by id, in the order of `C4_ACTIONS`. */
455
+ export const C4_TEXT_IDS = [
456
+ 'C4-1168-checkout', 'C4-1168-pay-and-switch', 'C4-1168-switch', 'C4-1168-schedule-switch', 'C4-1168-schedule-downgrade', 'C4-1168-cancel',
457
+ ];
458
+ /** The single sentence and button of the displays issued before one existed per action. Readable in stored snapshots only. */
459
+ const LEGACY_C4_TEXT_ID = 'DR-1374-draft-3-C.4';
460
+ const legacyC4Text = (org) => `By selecting “Order and pay”, you agree to the Terms of Service and the Data Processing Agreement for ${org}.`;
461
+ /** The consent sentence, the button label and the text id of `action`. Money is `formatEur`. */
462
+ export function c4Declaration(action, v) {
463
+ const plan = PLANS[v.plan].name;
464
+ const due = formatEur(v.dueCents);
465
+ const gross = formatEur(v.periodGrossCents);
466
+ const period = v.cycle === 'monthly' ? 'month' : 'year';
467
+ const legal = 'agree to the Terms of Service and the Data Processing Agreement';
468
+ const [label, rest] = (() => {
469
+ switch (action) {
470
+ case 'checkout':
471
+ return [`Pay ${due} with Mollie`, `you order ${plan} for ${v.org} as a business, ${legal}, and authorise Fleetless to charge ${gross} every ${period} until you cancel.`];
472
+ case 'pay_and_switch':
473
+ return [`Pay ${due} and switch`, `you order ${plan} for ${v.org} as a business from today, ${legal}, and authorise Fleetless to charge ${due} now and ${gross} every ${period} after that until you cancel.`];
474
+ case 'switch':
475
+ return [`Switch to ${plan}`, `you order ${plan} for ${v.org} as a business from today, ${legal}, and authorise Fleetless to charge ${gross} every ${period} from the next renewal until you cancel.`];
476
+ case 'schedule_switch':
477
+ return ['Switch to monthly at period end', `you order ${plan} monthly for ${v.org} as a business from the end of the current period, ${legal}, and authorise Fleetless to charge ${gross} every month from then until you cancel.`];
478
+ case 'schedule_downgrade':
479
+ return [`Schedule downgrade to ${plan}`, `you order ${plan} for ${v.org} as a business from the end of the current period, ${legal}, and authorise Fleetless to charge ${gross} every ${period} from then until you cancel.`];
480
+ case 'cancel':
481
+ return ['Cancel at period end', `you cancel ${plan} for ${v.org} at the end of the current period; ${v.org} then stays on Basic under the Terms of Service and the Data Processing Agreement, and nothing more is charged.`];
482
+ }
483
+ })();
484
+ return { text_id: C4_TEXT_IDS[C4_ACTIONS.indexOf(action)], text: `By selecting “${label}”, ${rest}`, action_label: label };
485
+ }
486
+ /**
487
+ * The action of a decision. `checkout` for a first purchase; a paid change
488
+ * charging now is `pay_and_switch`, one taking effect now at no charge
489
+ * `switch`; a plan change to Basic is `cancel`, to another plan
490
+ * `schedule_downgrade`. A scheduled paid change is `schedule_downgrade` for a
491
+ * lower plan or fewer add-ons and `schedule_switch` for yearly to monthly on
492
+ * the same plan: that needs `from` when the target is monthly, and throws
493
+ * without it.
494
+ */
495
+ export function c4ActionOf(s, from) {
496
+ if (s.decision_kind === 'checkout')
497
+ return 'checkout';
498
+ if (s.decision_kind === 'plan_change')
499
+ return s.selection.plan === 'basic' ? 'cancel' : 'schedule_downgrade';
500
+ if (s.amounts.due_today_gross_cents > 0)
501
+ return 'pay_and_switch';
502
+ if (s.period.anchor !== 'existing_period' || s.period.effective.mode === 'on_confirmation')
503
+ return 'switch';
504
+ if (s.selection.cycle === 'yearly')
505
+ return 'schedule_downgrade';
506
+ if (from === undefined)
507
+ throw new Error('c4ActionOf: a scheduled monthly paid change needs the current plan to tell a downgrade from a cycle switch');
508
+ const current = typeof from === 'string' ? { plan: from } : from;
509
+ if (PLAN_ORDER.indexOf(s.selection.plan) < PLAN_ORDER.indexOf(current.plan))
510
+ return 'schedule_downgrade';
511
+ return current.cycle === 'monthly' ? 'schedule_downgrade' : 'schedule_switch';
512
+ }
513
+ /** Every action a snapshot can carry when the plan it starts from is not known. */
514
+ function c4ActionsOf(s) {
515
+ if (s.decision_kind !== 'paid_change' || s.amounts.due_today_gross_cents > 0
516
+ || s.period.anchor !== 'existing_period' || s.period.effective.mode === 'on_confirmation')
517
+ return [c4ActionOf(s)];
518
+ return s.selection.cycle === 'monthly' ? ['schedule_switch', 'schedule_downgrade'] : ['schedule_downgrade'];
519
+ }
520
+ const separateLegalLinks = (value, ctx) => {
429
521
  if (value.terms.url === value.dpa.url)
430
522
  ctx.addIssue({ code: 'custom', path: ['dpa'], message: 'Terms and DPA require separate version URLs.' });
523
+ };
524
+ const legalLinks = { terms: legalDocumentReference, dpa: legalDocumentReference };
525
+ const labelRules = {
526
+ 'C4-1168-checkout': { pattern: '^Pay \\S.* with Mollie$' },
527
+ 'C4-1168-pay-and-switch': { pattern: '^Pay \\S.* and switch$' },
528
+ 'C4-1168-switch': { pattern: '^Switch to \\S.*$' },
529
+ 'C4-1168-schedule-switch': { const: 'Switch to monthly at period end' },
530
+ 'C4-1168-schedule-downgrade': { pattern: '^Schedule downgrade to \\S.*$' },
531
+ 'C4-1168-cancel': { const: 'Cancel at period end' },
532
+ };
533
+ const declaration = z.object({
534
+ text_id: z.enum(C4_TEXT_IDS).meta({ description: 'The approved sentence this display shows, one per action.' }),
535
+ text: z.string().min(1).regex(/^By selecting “/).meta({ description: 'The consent sentence shown directly above the button, naming the button.' }),
536
+ action_label: z.string().min(1).meta({ description: 'The label of the one button that confirms this decision.' }),
537
+ ...legalLinks,
538
+ }).strict().superRefine(separateLegalLinks).meta({
539
+ allOf: C4_TEXT_IDS.map(textId => ({
540
+ if: { properties: { text_id: { const: textId } }, required: ['text_id'] },
541
+ then: { properties: { action_label: labelRules[textId] } },
542
+ })),
431
543
  });
544
+ const legacyDeclaration = z.object({
545
+ text_id: z.literal(LEGACY_C4_TEXT_ID),
546
+ text: z.string().min(1),
547
+ ...legalLinks,
548
+ }).strict().superRefine(separateLegalLinks);
432
549
  const snapshotBase = z.object({
433
550
  snapshot_id: z.uuid(),
434
551
  decision_id: z.uuid(),
@@ -443,17 +560,46 @@ const snapshotBase = z.object({
443
560
  declaration,
444
561
  expires_at: utcInstant,
445
562
  }).strict();
446
- export const billingDecisionSnapshot = z.discriminatedUnion('decision_kind', [
563
+ const snapshotVariants = [
447
564
  snapshotBase.extend({ decision_kind: z.literal('checkout'), selection: purchaseSelection }).strict(),
448
565
  snapshotBase.extend({ decision_kind: z.literal('paid_change'), selection: purchaseSelection, period: existingBillingPeriod }).strict(),
449
566
  snapshotBase.extend({ decision_kind: z.literal('plan_change'), selection: planChangeSelection, period: existingBillingPeriod }).strict(),
450
- ]).superRefine((value, ctx) => {
567
+ ];
568
+ const storedDeclaration = z.union([declaration, legacyDeclaration]);
569
+ const storedSnapshotVariants = z.discriminatedUnion('decision_kind', [
570
+ snapshotVariants[0].extend({ declaration: storedDeclaration }).strict(),
571
+ snapshotVariants[1].extend({ declaration: storedDeclaration }).strict(),
572
+ snapshotVariants[2].extend({ declaration: storedDeclaration }).strict(),
573
+ ]);
574
+ /** The declaration must be the one its decision, amounts, plan and organization write; a legacy one only its own sentence. */
575
+ function checkDeclaration(value, ctx) {
576
+ const declared = value.declaration;
577
+ if (declared.text_id === LEGACY_C4_TEXT_ID) {
578
+ if (declared.text !== legacyC4Text(value.organization_name))
579
+ ctx.addIssue({ code: 'custom', path: ['declaration', 'text'], message: 'Declaration must match the approved C.4 sentence and organization.' });
580
+ return;
581
+ }
582
+ const action = C4_ACTIONS[C4_TEXT_IDS.indexOf(declared.text_id)];
583
+ if (!c4ActionsOf(value).includes(action)) {
584
+ ctx.addIssue({ code: 'custom', path: ['declaration', 'text_id'], message: 'Declaration must be the sentence of the action this decision is.' });
585
+ return;
586
+ }
587
+ const plans = action === 'cancel' ? ['plus', 'pro'] : [value.selection.plan];
588
+ const matches = plans.some(plan => {
589
+ const expected = c4Declaration(action, {
590
+ org: value.organization_name, plan, cycle: value.selection.cycle,
591
+ dueCents: value.amounts.due_today_gross_cents, periodGrossCents: value.amounts.period_gross_cents,
592
+ });
593
+ return expected.text === declared.text && expected.action_label === declared.action_label;
594
+ });
595
+ if (!matches)
596
+ ctx.addIssue({ code: 'custom', path: ['declaration', 'text'], message: 'Declaration must match the approved sentence and button of its action, amounts, plan and organization.' });
597
+ }
598
+ function refineSnapshot(value, ctx) {
451
599
  if (value.period.anchor === 'on_first_successful_payment' && value.period.cycle !== value.selection.cycle) {
452
600
  ctx.addIssue({ code: 'custom', path: ['period', 'cycle'], message: 'First-payment period must match the selected cycle.' });
453
601
  }
454
- const expected = `By selecting “Order and pay”, you agree to the Terms of Service and the Data Processing Agreement for ${value.organization_name}.`;
455
- if (value.declaration.text !== expected)
456
- ctx.addIssue({ code: 'custom', path: ['declaration', 'text'], message: 'Declaration must match the approved C.4 sentence and organization.' });
602
+ checkDeclaration(value, ctx);
457
603
  if (value.amounts.vat_treatment === 'de_standard') {
458
604
  const euro = (cents) => new Intl.NumberFormat('en-US', { style: 'currency', currency: 'EUR' }).format(cents / 100);
459
605
  const period = value.selection.cycle === 'monthly' ? 'month' : 'year';
@@ -465,10 +611,19 @@ export const billingDecisionSnapshot = z.discriminatedUnion('decision_kind', [
465
611
  const expectedAddons = addonKey.options.filter((key) => value.selection.addons[key] > 0);
466
612
  if (lines.length !== expectedAddons.length || lines.some((line, i) => line.addon !== expectedAddons[i] || line.quantity !== value.selection.addons[line.addon]))
467
613
  ctx.addIssue({ code: 'custom', path: ['amounts', 'addon_lines'], message: 'Add-on lines must match absolute selection in catalogue order.' });
468
- }).meta({ allOf: ['monthly', 'yearly'].map(cycle => ({
614
+ }
615
+ const snapshotRules = { allOf: ['monthly', 'yearly'].map(cycle => ({
469
616
  if: { properties: { period: { properties: { anchor: { const: 'on_first_successful_payment' }, cycle: { const: cycle } }, required: ['anchor', 'cycle'] } }, required: ['period'] },
470
617
  then: { properties: { selection: { properties: { cycle: { const: cycle } }, required: ['cycle'] } }, required: ['selection'] },
471
- })) });
618
+ })) };
619
+ /** What a C.4 display shows the owner. The declaration is the sentence and button of the decision's own action. */
620
+ export const billingDecisionSnapshot = z.discriminatedUnion('decision_kind', snapshotVariants).superRefine(refineSnapshot).meta(snapshotRules);
621
+ /**
622
+ * A snapshot as the cloud stored it: also a display issued before each action
623
+ * had its own sentence, with the single legacy declaration and no button label.
624
+ * Never issued anew; for reading and replaying stored decisions only.
625
+ */
626
+ export const storedBillingDecisionSnapshot = storedSnapshotVariants.superRefine(refineSnapshot).meta(snapshotRules);
472
627
  export const billingDecisionDisplayResponse = z.object({
473
628
  confirmation_proof: confirmationProof,
474
629
  expires_at: utcInstant,
@@ -497,12 +652,13 @@ const intentIdentity = {
497
652
  '(`charged` is `null`), it identifies the matching billing.charges[].id. Absent on a paid_change in any other state.',
498
653
  }),
499
654
  };
655
+ /**
656
+ * Why an intent is held. Lexware never holds a purchase: its contact and
657
+ * invoice follow the payment. A checkout or paid change is held only while an
658
+ * issuer cutover runs (`issuer_cutover_in_progress`, minutes, then try again).
659
+ */
500
660
  export const purchaseHoldReason = z.enum([
501
- 'legacy_usd_invoice', 'legacy_payer_unresolved', 'mandate_policy_unresolved',
502
- // The Lexware issuer cutover (2026-10-19, fleetless/fleetless#327): holds
503
- // during and after the move from Cloud-issued invoices to charges billed
504
- // through Lexware.
505
- 'lexware_contact_pending', 'lexware_contact_changed', 'issuer_cutover_in_progress', 'lexware_issuance_paused',
661
+ 'legacy_usd_invoice', 'legacy_payer_unresolved', 'mandate_policy_unresolved', 'issuer_cutover_in_progress',
506
662
  ]);
507
663
  export const purchaseRefusalRule = z.enum(['company_required', 'vat_id_required', 'vat_id_invalid', 'tax_id_required', 'us_state_required', 'public_email_domain', 'invoice_not_open']);
508
664
  // Cross-field invariants also travel in JSON Schema so non-TypeScript callers
@@ -558,7 +714,7 @@ export const purchaseIntentAcceptedWithoutPayment = z.object({
558
714
  export const purchaseIntent = z.discriminatedUnion('state', [
559
715
  ...draftVariants, paymentStartedVariant, purchaseIntentAcceptedWithoutPayment,
560
716
  ]).superRefine(validateIntent).meta({ allOf: intentRules });
561
- /** Shared by checkout, invoice payment and method change. Paid changes use their own response. */
717
+ /** Shared by invoice payment and method change. A checkout start answers `checkoutStartResponse`, a paid change its own response. */
562
718
  const nonChangeOperation = purchaseOperation.exclude(['paid_change']);
563
719
  const nonChangeChargeOperation = chargeOperation.exclude(['paid_change']);
564
720
  const nonChangeDraft = z.discriminatedUnion('state', [
@@ -572,14 +728,99 @@ const nonChangePaymentStarted = paymentStartedVariant
572
728
  .safeExtend({ operation: nonChangeChargeOperation })
573
729
  .superRefine(validateIntent).meta({ allOf: intentRules });
574
730
  const paidChangeOperation = z.literal('paid_change');
731
+ // A paid change is decided in its request: it never waits for VIES.
575
732
  const paidChangeDraft = z.discriminatedUnion('state', [
576
- draftVariants[0].safeExtend({ operation: paidChangeOperation }),
577
733
  draftVariants[1].safeExtend({ operation: paidChangeOperation }),
578
734
  draftVariants[2].safeExtend({ operation: paidChangeOperation }),
579
735
  draftVariants[3].safeExtend({ operation: paidChangeOperation }),
580
736
  draftVariants[4].safeExtend({ operation: paidChangeOperation }),
581
737
  ]).superRefine(validateIntent).meta({ allOf: intentRules });
582
738
  export const checkoutResponse = z.union([nonChangeDraft, nonChangePaymentStarted]);
739
+ const checkoutIntentIdentity = {
740
+ intent_id: z.uuid().meta({ description: 'The persisted checkout intent; confirm it with `POST /api/billing/intents/:id/confirm`.' }),
741
+ operation_key: purchaseOperationKey,
742
+ operation: z.literal('checkout'),
743
+ };
744
+ const vatIdField = z.literal('billing.vat_id');
745
+ /**
746
+ * `POST /api/billing/checkout`'s answer. The start decides in the request:
747
+ * `eligible` carries the frozen quote and its C.4 display, whose proof the
748
+ * one click on `display.snapshot.declaration.action_label` consumes;
749
+ * `vies_unavailable`, `invalid_vat_id` and `refused` store nothing but the
750
+ * checkout draft; `held` only while an issuer cutover runs; `payment_started`
751
+ * replays a key already confirmed.
752
+ */
753
+ export const checkoutStartResponse = z.discriminatedUnion('state', [
754
+ z.object({
755
+ ...checkoutIntentIdentity, state: z.literal('eligible'), ...quoteIdentity, quote: purchaseQuote,
756
+ display: billingDecisionDisplayResponse,
757
+ }).strict().meta({ description: 'Eligible: the price is frozen and the display shown; one click on its button confirms.' }),
758
+ z.object({ state: z.literal('vies_unavailable'), field: vatIdField, reason: viesPendingReason }).strict()
759
+ .meta({ description: 'VIES did not confirm the VAT ID within its retries. Nothing is stored; check again.' }),
760
+ z.object({ state: z.literal('invalid_vat_id'), field: vatIdField, rule: z.literal('vat_id_invalid') }).strict()
761
+ .meta({ description: 'VIES says the VAT ID is invalid. Nothing is stored.' }),
762
+ z.object({ state: z.literal('refused'), field: z.string().min(1), rule: purchaseRefusalRule }).strict()
763
+ .meta({ description: 'A field the purchase cannot accept. Nothing is stored.' }),
764
+ z.object({ ...checkoutIntentIdentity, state: z.literal('held'), reason: z.literal('issuer_cutover_in_progress') }).strict()
765
+ .meta({ description: 'An issuer cutover is running; try again in a few minutes.' }),
766
+ z.object({
767
+ ...checkoutIntentIdentity, state: z.literal('payment_started'), payment_id: z.uuid(),
768
+ payment: z.object({ kind: z.literal('hosted'), checkout_id: z.uuid(), checkout_url: z.url() }).strict(),
769
+ }).strict().meta({ description: 'The key was already confirmed: the hosted payment it started.' }),
770
+ ]).superRefine((value, ctx) => {
771
+ if (value.state !== 'eligible')
772
+ return;
773
+ const snapshot = value.display.snapshot;
774
+ const invalid = (path, message) => ctx.addIssue({ code: 'custom', path, message });
775
+ if (snapshot.decision_kind !== 'checkout')
776
+ invalid(['display', 'snapshot', 'decision_kind'], 'A checkout start displays a checkout decision.');
777
+ if (snapshot.decision_id !== value.intent_id)
778
+ invalid(['display', 'snapshot', 'decision_id'], 'The display must refer to this intent.');
779
+ if (snapshot.operation_key !== value.operation_key)
780
+ invalid(['display', 'snapshot', 'operation_key'], 'The display must carry this operation key.');
781
+ if (snapshot.quote_revision !== value.quote_revision || snapshot.buyer_fingerprint !== value.buyer_fingerprint) {
782
+ invalid(['display', 'snapshot', 'quote_revision'], 'The display must show this quote revision and buyer.');
783
+ }
784
+ const quote = snapshot.amounts.quote;
785
+ if (Object.keys(value.quote).some(key => quote[key] !== value.quote[key])) {
786
+ invalid(['quote'], 'The quote must be the one the display shows.');
787
+ }
788
+ }).meta({ allOf: [{
789
+ if: { properties: { state: { const: 'eligible' } }, required: ['state'] },
790
+ then: { properties: { display: { properties: { snapshot: { properties: { decision_kind: { const: 'checkout' } } } } } } },
791
+ }] });
792
+ const checkoutDraft = z.object({
793
+ plan: z.enum(['plus', 'pro']).meta({ description: 'The plan last chosen on the checkout page.' }),
794
+ cycle: billingCycle.meta({ description: 'The cycle last chosen.' }),
795
+ billing: purchaseBillingDetails.meta({ description: 'The company details last sent to the checkout start.' }),
796
+ updated_at: z.iso.datetime().meta({ description: 'When the draft was last saved.' }),
797
+ }).strict();
798
+ /**
799
+ * `GET /api/billing/checkout-draft`'s answer: the details the checkout page
800
+ * fills its form from. `draft` is what the last checkout start received,
801
+ * whatever it decided; without one, `prefill` is the org's earlier billing
802
+ * details; both `null` for a first purchase. Never both.
803
+ */
804
+ export const checkoutDraftResponse = z.object({
805
+ draft: checkoutDraft.nullable().meta({ description: 'The saved checkout draft, or `null`. Deleted once the checkout is paid.' }),
806
+ prefill: billingDetails.nullable().meta({ description: "The org's earlier billing details when there is no draft, else `null`." }),
807
+ }).strict().superRefine((value, ctx) => {
808
+ if (value.draft !== null && value.prefill !== null)
809
+ ctx.addIssue({ code: 'custom', path: ['prefill'], message: 'A draft answers alone; prefill is null beside it.' });
810
+ }).meta({ not: { properties: { draft: { type: 'object' }, prefill: { type: 'object' } }, required: ['draft', 'prefill'] } });
811
+ /** `409 target_state_conflict` details while a first payment of the org is still open: continue it at `checkout_url`. */
812
+ export const checkoutOpenDetails = z.object({
813
+ field: z.literal('billing'),
814
+ rule: z.literal('checkout_open'),
815
+ expires_at: z.iso.datetime().nullable().meta({ description: 'When the open payment expires at the provider, or `null` when unknown.' }),
816
+ checkout_url: z.url().nullable().meta({ description: 'Where the open payment continues, or `null` when the provider no longer offers it.' }),
817
+ }).strict();
818
+ /** `409 target_state_conflict` details when a paid change needs VIES and VIES did not answer. Nothing is stored. */
819
+ export const viesUnavailableDetails = z.object({
820
+ field: vatIdField,
821
+ rule: z.literal('vies_unavailable'),
822
+ reason: viesPendingReason,
823
+ }).strict();
583
824
  /** Lookup needs one identity, plus the expected operation; a mismatch discloses nothing. */
584
825
  export const purchaseIntentLookupQuery = z.object({
585
826
  operation_key: purchaseOperationKey.optional().meta({ description: 'The client operation key; supply this or intent_id, never both.' }),
@@ -605,6 +846,8 @@ export const purchaseIntentConfirmRequest = z.discriminatedUnion('operation', [
605
846
  /** `409 target_state_conflict` details. Stale confirmation returns the new owner-visible intent. */
606
847
  export const purchaseConflictDetails = z.discriminatedUnion('rule', [
607
848
  z.object({ field: z.literal('operation_key'), rule: z.literal('operation_key_reused') }).strict(),
849
+ z.object({ field: z.literal('confirmation_proof'), rule: z.literal('display_stale') }).strict()
850
+ .meta({ description: 'The display was spent, expired or no longer matches: fetch a fresh one and press again.' }),
608
851
  z.object({ field: z.literal('intent'), rule: z.enum(['stale_quote', 'buyer_changed', 'not_eligible', 'invoice_not_open']), current_intent: purchaseIntent }).strict(),
609
852
  ]);
610
853
  export const invoicePayRequest = z.object({ operation_key: purchaseOperationKey }).strict();
package/dist/index.d.ts CHANGED
@@ -91,8 +91,8 @@ export { countryCode, EU_COUNTRIES, SELLER_COUNTRY, DE_VAT_RATE_PERCENT, isEuCou
91
91
  export type { PayerKind, BillingCycle, VatTreatment, PayerRefusalRule, VatDecision, ChargeAmounts, BillingState, QuoteLine, CheckoutQuote, BillingAddress, BillingDetails, CheckoutRequest, CheckoutResponse, CheckoutStatus, VatIdStatus, VatIdCheckRequest, VatIdCheckResponse, BillingChangeRequest, BillingCancelRequest, BillingDetailsUpdate, PaymentMethodKind, PaymentMethodChangeRequest, BillingAccountStatus, PaymentMethod, InvoiceStatus, BillingInvoice, BillingInvoicePdfQuery, BillingAccount, BillingView, BillingChangeResponse, BillingDocumentKind, BillingDocumentStatus, BillingDocumentProfile, BillingDocumentFormat, BillingDocument, BillingDocumentList, BillingDocumentFileRole, BillingDocumentDetail, BillingDocumentFileQuery, BillingIssuer, BillingChargeInvoice, BillingCharge, ChargePayRequest, } from './billing.js';
92
92
  export { controllerRegisterAddress, controllerRegisterPrivacyContact, controllerRegisterRepresentative, controllerRegisterWrite, controllerRegisterOrgRecord, controllerRegisterOrgResponse } from './controller-register.js';
93
93
  export type { ControllerRegisterWrite, ControllerRegisterOrgResponse } from './controller-register.js';
94
- export { purchaseBillingDetails, purchaseOperationKey, purchaseOperation, purchaseQuote, billingDecisionDisplayRequest, confirmationProof, billingDecisionAmounts, billingDecisionPeriod, billingDecisionSnapshot, billingDecisionDisplayResponse, planChangePrepareResponse, purchaseHoldReason, purchaseRefusalRule, purchaseIntent, purchaseIntentLookupQuery, purchaseIntentDraft, purchaseIntentPaymentStarted, purchaseIntentAcceptedWithoutPayment, purchaseIntentConfirmRequest, purchaseConflictDetails, invoicePayRequest, purchaseIntentResponse, vatDecision, viesPendingReason, } from './billing.js';
95
- export type { PurchaseBillingDetails, PurchaseOperation, PurchaseQuote, PurchaseIntent, PurchaseIntentDraft, PurchaseIntentPaymentStarted, PurchaseIntentAcceptedWithoutPayment, BillingDecisionDisplayRequest, ConfirmationProof, BillingDecisionAmounts, BillingDecisionPeriod, BillingDecisionSnapshot, BillingDecisionDisplayResponse, PlanChangePrepareResponse, PurchaseIntentLookupQuery, PurchaseIntentConfirmRequest, PurchaseConflictDetails, InvoicePayRequest, PurchaseIntentResponse, ViesVerdict, ViesPendingReason, } from './billing.js';
94
+ export { purchaseBillingDetails, purchaseOperationKey, purchaseOperation, purchaseQuote, billingDecisionDisplayRequest, confirmationProof, billingDecisionAmounts, billingDecisionPeriod, billingDecisionSnapshot, billingDecisionDisplayResponse, planChangePrepareResponse, purchaseHoldReason, purchaseRefusalRule, purchaseIntent, purchaseIntentLookupQuery, purchaseIntentDraft, purchaseIntentPaymentStarted, purchaseIntentAcceptedWithoutPayment, purchaseIntentConfirmRequest, purchaseConflictDetails, invoicePayRequest, purchaseIntentResponse, vatDecision, viesPendingReason, formatEur, C4_ACTIONS, C4_TEXT_IDS, c4ActionOf, c4Declaration, storedBillingDecisionSnapshot, checkoutStartResponse, checkoutDraftResponse, checkoutOpenDetails, viesUnavailableDetails, } from './billing.js';
95
+ export type { PurchaseBillingDetails, PurchaseOperation, PurchaseQuote, PurchaseIntent, PurchaseIntentDraft, PurchaseIntentPaymentStarted, PurchaseIntentAcceptedWithoutPayment, BillingDecisionDisplayRequest, ConfirmationProof, BillingDecisionAmounts, BillingDecisionPeriod, BillingDecisionSnapshot, BillingDecisionDisplayResponse, PlanChangePrepareResponse, PurchaseIntentLookupQuery, PurchaseIntentConfirmRequest, PurchaseConflictDetails, InvoicePayRequest, PurchaseIntentResponse, ViesVerdict, ViesPendingReason, C4Action, C4TextId, C4DeclarationText, C4DeclarationValues, C4Decision, C4From, StoredBillingDecisionSnapshot, CheckoutStartResponse, CheckoutDraftResponse, CheckoutOpenDetails, ViesUnavailableDetails, } from './billing.js';
96
96
  export { COLLECTIONS_FORMAT_VERSION, COLLECTION_RESERVED_KEYS, COLLECTION_LIMITS, collectionKey, collectionBinding, collectionFieldType, collectionField, collectionAccessValue, collectionAccess, collectionDefinition, collectionsDocument, } from './collections.js';
97
97
  export type { CollectionKey, CollectionBinding, CollectionFieldType, CollectionField, CollectionAccessValue, CollectionAccess, CollectionDefinition, CollectionsDocument, } from './collections.js';
98
98
  export { roleCollectionRights } from './collections-rights.js';
package/dist/index.js CHANGED
@@ -102,7 +102,7 @@ billingDocumentKind, billingDocumentStatus, billingDocumentProfile, billingDocum
102
102
  // 2026-10-19 — the Lexware issuer cutover (fleetless/fleetless#327).
103
103
  billingIssuer, billingChargeInvoice, billingCharge, chargePayRequest, } from './billing.js';
104
104
  export { controllerRegisterAddress, controllerRegisterPrivacyContact, controllerRegisterRepresentative, controllerRegisterWrite, controllerRegisterOrgRecord, controllerRegisterOrgResponse } from './controller-register.js';
105
- export { purchaseBillingDetails, purchaseOperationKey, purchaseOperation, purchaseQuote, billingDecisionDisplayRequest, confirmationProof, billingDecisionAmounts, billingDecisionPeriod, billingDecisionSnapshot, billingDecisionDisplayResponse, planChangePrepareResponse, purchaseHoldReason, purchaseRefusalRule, purchaseIntent, purchaseIntentLookupQuery, purchaseIntentDraft, purchaseIntentPaymentStarted, purchaseIntentAcceptedWithoutPayment, purchaseIntentConfirmRequest, purchaseConflictDetails, invoicePayRequest, purchaseIntentResponse, vatDecision, viesPendingReason, } from './billing.js';
105
+ export { purchaseBillingDetails, purchaseOperationKey, purchaseOperation, purchaseQuote, billingDecisionDisplayRequest, confirmationProof, billingDecisionAmounts, billingDecisionPeriod, billingDecisionSnapshot, billingDecisionDisplayResponse, planChangePrepareResponse, purchaseHoldReason, purchaseRefusalRule, purchaseIntent, purchaseIntentLookupQuery, purchaseIntentDraft, purchaseIntentPaymentStarted, purchaseIntentAcceptedWithoutPayment, purchaseIntentConfirmRequest, purchaseConflictDetails, invoicePayRequest, purchaseIntentResponse, vatDecision, viesPendingReason, formatEur, C4_ACTIONS, C4_TEXT_IDS, c4ActionOf, c4Declaration, storedBillingDecisionSnapshot, checkoutStartResponse, checkoutDraftResponse, checkoutOpenDetails, viesUnavailableDetails, } from './billing.js';
106
106
  export { COLLECTIONS_FORMAT_VERSION, COLLECTION_RESERVED_KEYS, COLLECTION_LIMITS, collectionKey, collectionBinding, collectionFieldType, collectionField, collectionAccessValue, collectionAccess, collectionDefinition, collectionsDocument, } from './collections.js';
107
107
  export { roleCollectionRights } from './collections-rights.js';
108
108
  export { collectionJsonTemplateName, COLLECTION_JSON_TEMPLATES, parseDisplayTemplate } from './collections-templates.js';
@@ -23,8 +23,8 @@ export declare const referencePlace: z.ZodObject<{
23
23
  app_id: z.ZodNullable<z.ZodUUID>;
24
24
  user_id: z.ZodNullable<z.ZodUUID>;
25
25
  document: z.ZodNullable<z.ZodEnum<{
26
- published: "published";
27
26
  draft: "draft";
27
+ published: "published";
28
28
  }>>;
29
29
  new_version: z.ZodNullable<z.ZodNumber>;
30
30
  }, z.core.$strip>;
@@ -59,8 +59,8 @@ export declare const danglingReference: z.ZodObject<{
59
59
  app_id: z.ZodNullable<z.ZodUUID>;
60
60
  user_id: z.ZodNullable<z.ZodUUID>;
61
61
  document: z.ZodNullable<z.ZodEnum<{
62
- published: "published";
63
62
  draft: "draft";
63
+ published: "published";
64
64
  }>>;
65
65
  new_version: z.ZodNullable<z.ZodNumber>;
66
66
  }, z.core.$strip>>;
@@ -95,8 +95,8 @@ export declare const orgRoleListResponse: z.ZodObject<{
95
95
  app_id: z.ZodNullable<z.ZodUUID>;
96
96
  user_id: z.ZodNullable<z.ZodUUID>;
97
97
  document: z.ZodNullable<z.ZodEnum<{
98
- published: "published";
99
98
  draft: "draft";
99
+ published: "published";
100
100
  }>>;
101
101
  new_version: z.ZodNullable<z.ZodNumber>;
102
102
  }, z.core.$strip>>;
@@ -153,8 +153,8 @@ export declare const roleRenamePreview: z.ZodObject<{
153
153
  app_id: z.ZodNullable<z.ZodUUID>;
154
154
  user_id: z.ZodNullable<z.ZodUUID>;
155
155
  document: z.ZodNullable<z.ZodEnum<{
156
- published: "published";
157
156
  draft: "draft";
157
+ published: "published";
158
158
  }>>;
159
159
  new_version: z.ZodNullable<z.ZodNumber>;
160
160
  }, z.core.$strip>>;
package/dist/routes.js CHANGED
@@ -20,7 +20,7 @@ import { MCP_APP_PATHS, mcpRobotDatasheet } from './mcp.js';
20
20
  import { authorizationServerMetadata, dynamicClientRegistrationRequest, dynamicClientRegistrationResponse, oauthAuthorizeQuery, oauthRedirectResponse, oauthTokenRequest, oauthTokenResponse, protectedResourceMetadata, } from './oauth.js';
21
21
  import { adminPlanChangeRequest, orgPlan, planChangeRequest, planChangePrepareRequest, planChangeDecisionLookupQuery, planChangeDecisionStatusResponse } from './plans.js';
22
22
  import { supportRenewFailRequest, supportTokenRequest, supportTokenResponse } from './support.js';
23
- import { purchaseIntentLookupQuery, purchaseIntentConfirmRequest, billingDecisionDisplayRequest, billingDecisionDisplayResponse, planChangePrepareResponse, purchaseIntentResponse, invoicePayRequest, billingCancelRequest, billingChangeRequest, billingChangeResponse, billingDetailsUpdate, billingInvoicePdfQuery, billingDocumentDetail, billingDocumentFileQuery, billingDocumentList, billingView, chargePayRequest, checkoutRequest, checkoutResponse, checkoutStatus, paymentMethodChangeRequest, vatIdCheckRequest, vatIdCheckResponse, } from './billing.js';
23
+ import { purchaseIntentLookupQuery, purchaseIntentConfirmRequest, billingDecisionDisplayRequest, billingDecisionDisplayResponse, planChangePrepareResponse, purchaseIntentResponse, invoicePayRequest, billingCancelRequest, billingChangeRequest, billingChangeResponse, billingDetailsUpdate, billingInvoicePdfQuery, billingDocumentDetail, billingDocumentFileQuery, billingDocumentList, billingView, chargePayRequest, checkoutRequest, checkoutResponse, checkoutStartResponse, checkoutDraftResponse, checkoutStatus, paymentMethodChangeRequest, vatIdCheckRequest, vatIdCheckResponse, } from './billing.js';
24
24
  import { cameraListResponse, cancelRequest, recoverHeldJobRequest, recoverHeldJobResponse, configDraftResponse, configVersionResponse, configVersionsResponse, createRobotRequest, createRobotResponse, datapointListResponse, datapointValue, exposureListResponse, fetchTypesRequest, fetchTypesResponse, historyQuery, historyResponse, introspectionResponse, invokeOrServiceResponse, invokeRequest, jobResponse, liveSessionResponse, orgHealthQuery, orgLatencyQuery, orgLatencyResponse, orgQuotaUsage, orgUsageQuery, orgUsageResponse, patchRobotRequest, patchRobotResponse, publishConfigResponse, publishRequest, putConfigDraftRequest, robotTokenRotateResponse, jointStatePutRequest, jointStatePutResponse, releaseLiveQuery, renameSlugRequest, renameSlugResponse, robotDeleteQuery, resourceHealthListResponse, robotDeletionSummary, robotDetailResponse, robotJobsResponse, robotListResponse, slugUsageResponse, snapshotMetaResponse, typesResponse, } from './rest.js';
25
25
  export const ROUTE_SECTIONS = [
26
26
  { id: 'health', title: 'Health' },
@@ -3198,12 +3198,34 @@ export const ROUTES = [
3198
3198
  },
3199
3199
  {
3200
3200
  method: 'POST', path: '/api/billing/checkout', section: 'billing',
3201
- summary: "Records a company purchase intent for the first paid plan.",
3201
+ summary: "Decides a company's first paid plan and returns its order summary to confirm.",
3202
3202
  audience: 'developer', auth: 'developer', rateLimited: true, ownerTier: true, status: 201,
3203
- params: [], query: null, request: checkoutRequest, response: checkoutResponse,
3203
+ params: [], query: null, request: checkoutRequest, response: checkoutStartResponse,
3204
3204
  errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'plan_limit', 'target_state_conflict', 'rate_limited', 'plan_purchase_closed', ...BILLING_OFF, ...MOLLIE],
3205
3205
  transport: 'http',
3206
- notes: "Basic stays free for every payer. This start creates only a nonbinding draft; accept_terms is deprecated and cannot confirm an order. Current company, buyer, VIES and EUR quote checks still apply. Persist operation_key before POST; the same key and input return 200 with the existing intent (and its hosted checkout when payment_started), without another Mollie payment; changed input conflicts. A different operation_key while a first payment is open returns 409 target_state_conflict with rule checkout_open and details expires_at: null. An eligible Owner obtains a no-store C.4 display, then explicitly confirms with its proof. No payment or acceptance occurs at start. Hosted payment later offers card, PayPal or Apple Pay; its return is <console>/settings/billing?checkout=<checkout_id>. An active/past_due account uses billing/change.",
3206
+ notes: 'Basic stays free for every payer. The start decides in this request, VIES included: a busy VIES is retried for up to 15 seconds ' +
3207
+ "before the answer. The body is first saved as the org's checkout draft (`GET /api/billing/checkout-draft`), whatever the answer. " +
3208
+ '`eligible` (201) records the pending billing account and a checkout intent, freezes the EUR quote and carries its C.4 display, ' +
3209
+ 'Cache-Control: no-store: show `display.snapshot.declaration.text` directly above one button labelled `action_label`; that one ' +
3210
+ 'click is `POST /api/billing/intents/:id/confirm` with the display\'s `confirmation_proof`. `vies_unavailable`, `invalid_vat_id` ' +
3211
+ 'and `refused` answer 200 and nothing is stored but the draft: no intent, no account, no retry in the background; check again. ' +
3212
+ '`held` (`issuer_cutover_in_progress`) only while an issuer cutover runs, for minutes; try again. Lexware never holds a checkout: ' +
3213
+ 'its contact and invoice follow the payment. Use a fresh operation_key per press; the same key and input answer 200 with the same ' +
3214
+ 'intent (`payment_started` with its hosted checkout once confirmed), without another Mollie payment; changed input conflicts. ' +
3215
+ 'While another first payment of the org is open, 409 target_state_conflict with `checkoutOpenDetails` (rule `checkout_open`): ' +
3216
+ 'continue it at `checkout_url`. No payment or acceptance occurs at start, and the deprecated `accept_terms` confirms nothing. ' +
3217
+ 'Hosted payment offers card, PayPal or Apple Pay; its return is <console>/settings/billing?checkout=<checkout_id>. Rate limited ' +
3218
+ 'on billing.checkout_start. An active/past_due account uses billing/change.',
3219
+ },
3220
+ {
3221
+ method: 'GET', path: '/api/billing/checkout-draft', section: 'billing',
3222
+ summary: "Reads the checkout draft, or the org's earlier billing details, to fill the checkout page.",
3223
+ audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
3224
+ params: [], query: null, request: null, response: checkoutDraftResponse,
3225
+ errors: [...DEVELOPER_GUARD, 'tier_required'], transport: 'http',
3226
+ notes: '`draft` is what the last `POST /api/billing/checkout` received, saved whatever it decided, and deleted once the checkout is ' +
3227
+ "paid. Without one, `prefill` carries the org's earlier billing details; both are `null` for a first purchase, never both set. " +
3228
+ 'A reload, a new tab or a return from Mollie fills the form from here. Reading changes nothing.',
3207
3229
  },
3208
3230
  {
3209
3231
  method: 'GET', path: '/api/billing/intents', section: 'billing',
@@ -3220,7 +3242,12 @@ export const ROUTES = [
3220
3242
  params: [{ name: 'id', description: 'The eligible intent ID returned by checkout or billing change.' }],
3221
3243
  query: null, request: billingDecisionDisplayRequest, response: billingDecisionDisplayResponse,
3222
3244
  errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'not_found', 'target_state_conflict', 'plan_purchase_closed'], transport: 'http',
3223
- notes: 'Owner only, Cache-Control: no-store. Cloud persists the snapshot and proof hash for an eligible current checkout or paid-change intent of this Owner and org. Pending, held, refused or accepted intents cannot mint a new proof. The proof never appears in lookup, billing views or logs.',
3245
+ notes: 'Owner only, Cache-Control: no-store. Cloud persists the snapshot and proof hash for an eligible current checkout or paid-change ' +
3246
+ 'intent of this Owner and org. A checkout start already returns its display; this route issues one for a paid change, and a fresh ' +
3247
+ 'one for an intent that is still eligible. `snapshot.declaration` carries the approved sentence of the decision\'s action ' +
3248
+ '(`text_id`, `text`) and the label of its one button (`action_label`): `Pay 34,51 € with Mollie`, `Pay 95 € and switch`, ' +
3249
+ '`Switch to Pro`, `Switch to monthly at period end`, `Schedule downgrade to Plus` or `Cancel at period end`. Render both as sent. ' +
3250
+ 'Pending, held, refused or accepted intents cannot mint a new proof. The proof never appears in lookup, billing views or logs.',
3224
3251
  },
3225
3252
  {
3226
3253
  method: 'POST', path: '/api/billing/intents/:id/confirm', section: 'billing',
@@ -3229,13 +3256,22 @@ export const ROUTES = [
3229
3256
  params: [{ name: 'id', description: 'The intent ID returned by the start or lookup response.' }],
3230
3257
  query: null, request: purchaseIntentConfirmRequest, response: purchaseIntentResponse,
3231
3258
  errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'not_found', 'target_state_conflict', 'plan_limit', 'rate_limited', 'plan_purchase_closed', ...BILLING_OFF, ...MOLLIE], transport: 'http',
3232
- notes: 'Checkout and paid-change decisions require confirmation_proof along with the operation key, quote revision and buyer fingerprint shown in the persisted C.4 display. Cloud rechecks buyer, quote, selection, legal references, period and current state under the org lock; stale or spent proof conflicts without effect. One decision and one legal acceptance commit together. An exact same-key replay returns the original result without another payment or acceptance. A paid change can return 409 target_state_conflict with field billing and rule charge_in_progress while an earlier charge is unresolved; it does not start another charge. Foreign ownership answers 404 without disclosure; pending or held cannot charge.',
3259
+ notes: 'Checkout and paid-change decisions require confirmation_proof along with the operation key, quote revision and buyer fingerprint ' +
3260
+ 'shown in the persisted C.4 display. Cloud rechecks buyer, quote, selection, legal references, period and current state under the ' +
3261
+ 'org lock. A spent, expired or stale proof answers 409 target_state_conflict with `{ field: confirmation_proof, rule: display_stale }` ' +
3262
+ 'and changes nothing: fetch a fresh display (for a checkout, a new start with a new key) and press again; never resend the click. ' +
3263
+ 'One decision, one legal acceptance and, for a charge, the hosted payment commit in this one request. An exact same-key replay ' +
3264
+ 'returns the original result without another payment or acceptance. After 502 payment_provider_unavailable the same key and proof ' +
3265
+ 'may be sent again: the payment is created with the same idempotency key, so at most one exists. While another first payment of ' +
3266
+ 'the org is open, a checkout answers 409 target_state_conflict with `checkoutOpenDetails` (rule `checkout_open`): continue it at ' +
3267
+ '`checkout_url`. A paid change can return 409 target_state_conflict with field billing and rule charge_in_progress while an ' +
3268
+ 'earlier charge is unresolved; it does not start another charge. Foreign ownership answers 404 without disclosure; held cannot charge.',
3233
3269
  },
3234
3270
  {
3235
3271
  method: 'GET', path: '/api/billing/checkout/:id', section: 'billing',
3236
3272
  summary: "Reads a checkout's status, for the return page's poll.",
3237
3273
  audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
3238
- params: [{ name: 'id', description: 'The checkout id from `checkoutResponse.checkout_id`, carried on the return URL.' }],
3274
+ params: [{ name: 'id', description: 'The checkout id from a started payment\'s `payment.checkout_id`, carried on the return URL.' }],
3239
3275
  query: null, request: null, response: checkoutStatus,
3240
3276
  errors: [...DEVELOPER_GUARD, 'tier_required', 'not_found'], transport: 'http',
3241
3277
  notes: 'Calls the same `reconcilePayment(deps, molliePaymentId)` the webhook calls, so a return page that lands before the ' +
@@ -3266,7 +3302,18 @@ export const ROUTES = [
3266
3302
  params: [], query: null, request: billingChangeRequest, response: billingChangeResponse,
3267
3303
  errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'plan_limit', 'target_state_conflict', 'plan_purchase_closed', ...BILLING_OFF, ...MOLLIE],
3268
3304
  transport: 'http',
3269
- notes: "The request names an absolute plan/cycle/add-on target and a stable operation_key. Start is nonbinding for every change, including zero-charge, scheduled and formerly immediate decreases: it neither changes the plan nor writes legal acceptance. An eligible Owner obtains a C.4 display and explicitly confirms with its proof. Confirmation may return accepted_no_payment with charged: null and no provider payment or redirect, or payment_started for a charged change. Exact-key lookup recovers the accepted result. Existing no_account, past_due, no_valid_mandate and plan_limit conflicts remain. A later paid-change confirmation can return 409 target_state_conflict with field billing and rule charge_in_progress while an earlier charge is unresolved; no second charge starts.",
3305
+ notes: 'The request names an absolute plan/cycle/add-on target and a fresh operation_key per selection. Start is nonbinding for every ' +
3306
+ 'change, including zero-charge, scheduled and formerly immediate decreases: it neither changes the plan nor writes legal ' +
3307
+ 'acceptance. The change is decided in the request and never waits: no `awaiting_vies`, and Lexware never holds it; `held` ' +
3308
+ '(`issuer_cutover_in_progress`) only while an issuer cutover runs. VIES runs only when the billing details changed since the last ' +
3309
+ 'decision or the recorded VAT treatment is blocked, and a change that charges nothing never calls it. When VIES does not answer: ' +
3310
+ '409 target_state_conflict with `viesUnavailableDetails` (`field: billing.vat_id`, `rule: vies_unavailable`), nothing stored. A ' +
3311
+ 'change charging nothing while the recorded VAT treatment is unresolved: 409 target_state_conflict with `{ field: billing.vat_id, ' +
3312
+ 'rule: purchase_eligibility_pending }`. An eligible Owner obtains a C.4 display (`POST /api/billing/intents/:id/display`) and ' +
3313
+ 'confirms with one click on its `action_label`. Confirmation may return accepted_no_payment with charged: null and no provider ' +
3314
+ 'payment or redirect, or payment_started for a charged change. Exact-key lookup recovers the accepted result. Existing ' +
3315
+ 'no_account, past_due, no_valid_mandate and plan_limit conflicts remain. A later paid-change confirmation can return 409 ' +
3316
+ 'target_state_conflict with field billing and rule charge_in_progress while an earlier charge is unresolved; no second charge starts.',
3270
3317
  },
3271
3318
  {
3272
3319
  method: 'POST', path: '/api/billing/payment-method', section: 'billing',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetless/contracts",
3
- "version": "15.6.0",
3
+ "version": "16.0.0-next.1",
4
4
  "description": "Fleetless wire contracts: the bridge-cloud protocol, the REST API schemas and the error codes, as zod schemas with generated JSON Schema and OpenAPI artifacts.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Dehne Robotik GmbH",