@fleetless/contracts 6.5.0 → 7.0.0

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/artifacts/openapi.json +5805 -1805
  3. package/artifacts/routes.json +75 -13
  4. package/artifacts/schema/addon-catalogue-entry.schema.json +1 -15
  5. package/artifacts/schema/billing-address.schema.json +7 -1
  6. package/artifacts/schema/billing-change-request.schema.json +9 -0
  7. package/artifacts/schema/billing-change-response.schema.json +2219 -625
  8. package/artifacts/schema/billing-details-update.schema.json +70 -0
  9. package/artifacts/schema/billing-details.schema.json +27 -3
  10. package/artifacts/schema/billing-view.schema.json +56 -24
  11. package/artifacts/schema/checkout-request.schema.json +90 -154
  12. package/artifacts/schema/checkout-response.schema.json +531 -17
  13. package/artifacts/schema/invoice-pay-request.schema.json +16 -0
  14. package/artifacts/schema/payment-method-change-request.schema.json +7 -0
  15. package/artifacts/schema/plan-catalogue-entry.schema.json +1 -15
  16. package/artifacts/schema/plan-prices.schema.json +1 -15
  17. package/artifacts/schema/purchase-billing-details.schema.json +111 -0
  18. package/artifacts/schema/purchase-conflict-details.schema.json +582 -0
  19. package/artifacts/schema/purchase-hold-reason.schema.json +9 -0
  20. package/artifacts/schema/purchase-intent-confirm-request.schema.json +40 -0
  21. package/artifacts/schema/purchase-intent-lookup-query.schema.json +56 -0
  22. package/artifacts/schema/purchase-intent-response.schema.json +1554 -0
  23. package/artifacts/schema/purchase-operation-key.schema.json +7 -0
  24. package/artifacts/schema/purchase-operation.schema.json +11 -0
  25. package/artifacts/schema/purchase-quote.schema.json +43 -0
  26. package/artifacts/schema/purchase-refusal-rule.schema.json +13 -0
  27. package/artifacts/schema/vat-decision.schema.json +77 -0
  28. package/artifacts/schema/vat-id-check-response.schema.json +111 -25
  29. package/artifacts/schema/vies-pending-reason.schema.json +9 -0
  30. package/dist/billing.d.ts +1128 -75
  31. package/dist/billing.js +174 -66
  32. package/dist/index.d.ts +2 -0
  33. package/dist/index.js +1 -0
  34. package/dist/plans.d.ts +4 -9
  35. package/dist/plans.js +4 -7
  36. package/dist/routes.js +33 -60
  37. package/package.json +1 -1
@@ -6527,7 +6527,7 @@
6527
6527
  "method": "POST",
6528
6528
  "path": "/api/billing/checkout",
6529
6529
  "section": "billing",
6530
- "summary": "Starts a Mollie checkout for a plan, or an upgrade paid at once.",
6530
+ "summary": "Records a company purchase intent for the first paid plan.",
6531
6531
  "audience": "developer",
6532
6532
  "auth": "developer",
6533
6533
  "rateLimited": true,
@@ -6550,7 +6550,67 @@
6550
6550
  "payment_provider_unavailable"
6551
6551
  ],
6552
6552
  "transport": "http",
6553
- "notes": "Rate limited on the `billing.checkout` bucket, same as `POST /api/billing/payment-method` and `POST /api/billing/invoices/:id/pay` — the three routes that mint a Mollie checkout. `400 validation_error` names who may not pay with these rules: `{ field: 'billing.address.country', rule: 'eu_person' }` for a person in another EU country, `{ field: 'billing.vat_id', rule: 'vat_id_required' }` for a company there with no VAT ID, `{ field: 'billing.vat_id', rule: 'vat_id_invalid' }` once VIES has said so, and `{ field: 'accept_withdrawal', rule: 'required' }` for a person who did not confirm it. `409 target_state_conflict` names `plan` with rule `already_billed` when the org already has an `active` or `past_due` billing account — checkout is for the first payment only, every later change is `POST /api/billing/change`. `checkout_url` is Mollie's hosted page, where the payer chooses card, PayPal or Apple Pay; the return lands on `<console>/settings/billing?checkout=<checkout_id>`, which polls `GET /api/billing/checkout/:id` until the webhook — or the poll itself — has reconciled the payment. `409 plan_limit` is the org's own usage against the plan being bought."
6553
+ "notes": "Basic stays free for every payer. New paid checkout requires a company, terms, current buyer eligibility and an EUR quote. Other EU countries require direct VIES valid with an identifier; unavailable/unverified or missing identifier returns awaiting_vies without payment or redirect. Cloud checks the non-EU Tax ID and versioned public-email policy, and US state. Persist operation_key before POST; the same org/key/input returns the same intent, different input is 409 target_state_conflict with purchaseConflictDetails rule operation_key_reused. Owner lookup recovers a lost response. Only explicit confirmation of the current quote may create a payment; a worker cannot start it. payment_started.payment.checkout_url exists only for a hosted payment, where the buyer chooses card, PayPal or Apple Pay. Its return is <console>/settings/billing?checkout=<checkout_id>; GET /api/billing/checkout/:id reconciles the recorded payment. An active/past_due account uses billing/change; already_billed and plan_limit retain their existing meanings."
6554
+ },
6555
+ {
6556
+ "method": "GET",
6557
+ "path": "/api/billing/intents",
6558
+ "section": "billing",
6559
+ "summary": "Recovers a purchase intent by operation key or intent ID.",
6560
+ "audience": "developer",
6561
+ "auth": "developer",
6562
+ "rateLimited": false,
6563
+ "ownerTier": true,
6564
+ "status": 200,
6565
+ "params": [],
6566
+ "query": "purchase-intent-lookup-query",
6567
+ "request": null,
6568
+ "response": "purchase-intent-response",
6569
+ "errors": [
6570
+ "unauthorized",
6571
+ "token_expired",
6572
+ "token_revoked",
6573
+ "tier_required",
6574
+ "validation_error",
6575
+ "not_found"
6576
+ ],
6577
+ "transport": "http",
6578
+ "notes": "Supply exactly one of operation_key or intent_id and the expected operation. Scope lookup to the authenticated owner and org; unknown, foreign-org or mismatched-operation intents return 404 without disclosure. Repeating a lookup after restart or lost response returns the same intent/payment identity and, for a paid change, its billing result. Awaiting VIES and eligible states never start payment; Console polls at a bounded interval and asks for fresh confirmation of the displayed quote."
6579
+ },
6580
+ {
6581
+ "method": "POST",
6582
+ "path": "/api/billing/intents/:id/confirm",
6583
+ "section": "billing",
6584
+ "summary": "Confirms the current purchase quote exactly once.",
6585
+ "audience": "developer",
6586
+ "auth": "developer",
6587
+ "rateLimited": true,
6588
+ "ownerTier": true,
6589
+ "status": 200,
6590
+ "params": [
6591
+ {
6592
+ "name": "id",
6593
+ "description": "The intent ID returned by the start or lookup response."
6594
+ }
6595
+ ],
6596
+ "query": null,
6597
+ "request": "purchase-intent-confirm-request",
6598
+ "response": "purchase-intent-response",
6599
+ "errors": [
6600
+ "unauthorized",
6601
+ "token_expired",
6602
+ "token_revoked",
6603
+ "tier_required",
6604
+ "validation_error",
6605
+ "not_found",
6606
+ "target_state_conflict",
6607
+ "plan_limit",
6608
+ "rate_limited",
6609
+ "billing_unavailable",
6610
+ "payment_provider_unavailable"
6611
+ ],
6612
+ "transport": "http",
6613
+ "notes": "Require the same operation_key and operation plus the displayed quote_revision and buyer_fingerprint. Under the org lock compare current buyer, country, VAT ID, Tax ID, invoice email/policy version, US state, EUR quote, invoice status/amount/currency and integration holds. A stale revision is 409 target_state_conflict with purchaseConflictDetails/current_intent; the owner must confirm again. Foreign or mismatched operation is 404 without disclosure. Pending or held cannot charge. Persist one payment row before the provider call and use its ID as the provider idempotency key. Repeated confirmations and lost responses recover that payment/result; never create another. Look up/adopt a possibly-created payment before resending after a timeout; ambiguity is not permission to charge again."
6554
6614
  },
6555
6615
  {
6556
6616
  "method": "GET",
@@ -6585,7 +6645,7 @@
6585
6645
  "method": "POST",
6586
6646
  "path": "/api/billing/vat-id/check",
6587
6647
  "section": "billing",
6588
- "summary": "Checks a VAT ID against VIES, for the checkout form and the details page.",
6648
+ "summary": "Checks a VAT ID using requester-aware direct VIES.",
6589
6649
  "audience": "developer",
6590
6650
  "auth": "developer",
6591
6651
  "rateLimited": true,
@@ -6604,13 +6664,13 @@
6604
6664
  "rate_limited"
6605
6665
  ],
6606
6666
  "transport": "http",
6607
- "notes": "Rate limited on its own `billing.vat_check` bucket, sized for a form checked on blur rather than for a checkout. Never refuses for an `unverified` VIES answer — the checkout itself accepts `unverified` and the hourly sweep re-checks it — this route only reports what VIES currently says, in a different place for the same ID, entered either at checkout or on `PATCH /api/billing/details`."
6667
+ "notes": "Reports status and optional display name only; full evidence stays in protected Finance storage. valid with a missing identifier remains pending/vies_identifier_missing. unverified or unavailable remains pending without zero rating or payment. A form check never authorizes a later charge; Cloud binds current evidence to the buyer and quote at confirmation. Rate limited on billing.vat_check."
6608
6668
  },
6609
6669
  {
6610
6670
  "method": "PATCH",
6611
6671
  "path": "/api/billing/details",
6612
6672
  "section": "billing",
6613
- "summary": "Edits the billing account's invoice email or VAT ID.",
6673
+ "summary": "Edits company billing details for revalidation before the next charge.",
6614
6674
  "audience": "developer",
6615
6675
  "auth": "developer",
6616
6676
  "rateLimited": false,
@@ -6629,13 +6689,13 @@
6629
6689
  "not_found"
6630
6690
  ],
6631
6691
  "transport": "http",
6632
- "notes": "`404 not_found` when the org has no billing account yet — there is nothing here to edit before the first checkout. A new `vat_id` is re-checked through VIES the same way `POST /api/billing/vat-id/check` does; a valid ID entered here lifts the block a definitive `invalid` answer placed on the next renewal."
6692
+ "notes": "404 not_found when no billing account exists. Edits may change company name, full address/state, Tax ID, VAT ID and invoice email. Validate the merged buyer before a later charge; edits invalidate old evidence and quote revisions. Revalidate the email policy and country requirements. An edit does not create a payment, activate a plan, pay an invoice, clear dunning or lift a lock."
6633
6693
  },
6634
6694
  {
6635
6695
  "method": "POST",
6636
6696
  "path": "/api/billing/change",
6637
6697
  "section": "billing",
6638
- "summary": "Moves the org's plan, cycle or add-ons, charging increases at once.",
6698
+ "summary": "Records a paid-change intent or schedules a decrease.",
6639
6699
  "audience": "developer",
6640
6700
  "auth": "developer",
6641
6701
  "rateLimited": false,
@@ -6657,13 +6717,13 @@
6657
6717
  "payment_provider_unavailable"
6658
6718
  ],
6659
6719
  "transport": "http",
6660
- "notes": "The body names the **absolute** target — plan, cycle and add-ons — never a delta: the route compares it with the org's current state and splits the difference. The increasing part is charged now, through the same proration `changeNetCents` computes, and takes effect the moment Mollie accepts the `recurring` payment with anything but `failed`, `canceled` or `expired` — card mandates, Apple Pay's included, usually answer `paid` within seconds, a PayPal one may stay `pending` for a while; if it fails later, its open invoice enters dunning like a failed renewal. If Mollie refuses or does not answer, nothing is applied and this answers `502 payment_provider_unavailable` instead. The decreasing part — a lower plan, yearly → monthly, fewer add-ons — is stored as a pending change and applied at the period's end, same as `PUT /api/org/plan/change`; a lower plan over the target's limits answers `409 plan_limit` and the console opens its choose-what-stays page. Any increase first withdraws a pending downgrade or cancel, exactly as the admin route does. `409 target_state_conflict` names `billing` with rule `no_account` (no checkout yet — use `POST /api/billing/checkout`), `past_due` (an open invoice has to be paid first) or `no_valid_mandate` (the payment method needs renewing first, `POST /api/billing/payment-method`). `charged` in the response is the invoice from the part charged now, or `null` when the whole request was a decrease."
6720
+ "notes": "The request names an absolute plan/cycle/add-on target and a stable operation_key. Increases need a current company/EUR decision and explicit owner confirmation even after a worker resolves VIES. billingChangeResponse carries intent while awaiting_vies, eligible, refused or held; the old plan stays in effect. Confirm under the org lock, comparing buyer/policy fingerprint and quote revision; use one persisted payment row for provider idempotency. A started paid change returns billing, charged and intent with payment_started. An immediate accepted decrease retains the billing/charged branch (charged null); decreases are scheduled for period end. Existing no_account, past_due, no_valid_mandate and plan_limit conflicts remain. Do not advance periods, cancel existing choices or begin dunning merely because an intent is pending."
6661
6721
  },
6662
6722
  {
6663
6723
  "method": "POST",
6664
6724
  "path": "/api/billing/payment-method",
6665
6725
  "section": "billing",
6666
- "summary": "Starts a Mollie checkout for a new payment method.",
6726
+ "summary": "Records an invoice-paying method intent or a held mandate setup.",
6667
6727
  "audience": "developer",
6668
6728
  "auth": "developer",
6669
6729
  "rateLimited": true,
@@ -6674,6 +6734,7 @@
6674
6734
  "request": "payment-method-change-request",
6675
6735
  "response": "checkout-response",
6676
6736
  "errors": [
6737
+ "target_state_conflict",
6677
6738
  "unauthorized",
6678
6739
  "token_expired",
6679
6740
  "token_revoked",
@@ -6685,7 +6746,7 @@
6685
6746
  "payment_provider_unavailable"
6686
6747
  ],
6687
6748
  "transport": "http",
6688
- "notes": "Rate limited on the `billing.checkout` bucket, same as `POST /api/billing/checkout`. Creates a hosted `first` payment on the existing Mollie customer, restricted to the chosen method (`card` → Mollie's `creditcard`, `paypal`, `applepay`). For `card` and `paypal` it is a payment of `0.00` in the org's currency that pays no open invoice: the invoice stays open, the next dunning retry charges the new mandate — except for an invoice that was charged back, which is never charged again automatically; pay it with `POST /api/billing/invoices/:id/pay` — and that route still pays any open invoice at once. `applepay` behaves the same where Mollie accepts a zero-amount Apple Pay payment; where it does not, a change to Apple Pay is only offered together with paying an open invoice — the payment is then that invoice's amount and pays it — and without one this answers `400 validation_error` with `{ field: 'method', rule: 'applepay_needs_open_invoice' }`. A client offers what `payment_method_options` in `GET /api/billing` lists. `404 not_found` when the org has no billing account yet. When the new mandate turns `valid` it becomes the account's — an Apple Pay one is a card mandate, shown as `applepay` — and every other mandate of the customer is revoked."
6749
+ "notes": "Use a stable operation_key and owner intent lookup after reload/timeout. Offer payment_method_options. Apple Pay with zero-amount changes disabled pays an open invoice through operation payment_method_invoice; without one, 400 validation_error has field method and rule applepay_needs_open_invoice. Apply the same buyer/VIES gate, current-amount reconfirmation and USD legacy hold as invoices/:id/pay. Pending, eligible and held contain no checkout URL; redirect only on payment_started.payment.kind hosted. A 0.00 mandate-only setup uses operation mandate_setup and held/mandate_policy_unresolved until the integration decision settles eligibility and currency. It pays no invoice and clears no dunning or lock. An invoice charged back is never retried automatically. 404 not_found when no account exists. Same key with changed input is a typed operation_key_reused conflict."
6689
6750
  },
6690
6751
  {
6691
6752
  "method": "POST",
@@ -6772,7 +6833,7 @@
6772
6833
  "method": "POST",
6773
6834
  "path": "/api/billing/invoices/:id/pay",
6774
6835
  "section": "billing",
6775
- "summary": "Pays one open invoice, through a new Mollie payment.",
6836
+ "summary": "Records an owner-confirmed payment intent for an open invoice or due charge.",
6776
6837
  "audience": "developer",
6777
6838
  "auth": "developer",
6778
6839
  "rateLimited": true,
@@ -6785,9 +6846,10 @@
6785
6846
  }
6786
6847
  ],
6787
6848
  "query": null,
6788
- "request": null,
6849
+ "request": "invoice-pay-request",
6789
6850
  "response": "checkout-response",
6790
6851
  "errors": [
6852
+ "validation_error",
6791
6853
  "unauthorized",
6792
6854
  "token_expired",
6793
6855
  "token_revoked",
@@ -6799,7 +6861,7 @@
6799
6861
  "payment_provider_unavailable"
6800
6862
  ],
6801
6863
  "transport": "http",
6802
- "notes": "Rate limited on the `billing.checkout` bucket, same as `POST /api/billing/checkout`. `409 target_state_conflict` names `invoice` with rule `not_open` when the invoice is already `paid` or `uncollectible` — there is nothing left to pay. Paying the open invoice of a locked org unlocks it and keeps the plan running to the period's end, the same as a renewal that succeeds on a retry. `:id` may also be a due charge's id from `dunning.invoice_id` in `GET /api/billing`: while the payer's VAT ID is unsettled a held renewal is a due charge that has no number yet, and it is numbered and issued as an invoice once this payment is paid. The payment charges the amount owed (`dunning.gross_cents`). While that due charge is held by the VAT ID this answers `409 target_state_conflict` with `{ field: 'billing', rule: 'vat_id_invalid' }`. `404 not_found` for an unknown id or one from another org."
6864
+ "notes": "The required operation_key binds the org, invoice and request; reuse with changed input is 409 target_state_conflict (purchaseConflictDetails). :id may be an issued invoice or a due charge with no number. Recheck current buyer eligibility, VIES, invoice status, owed amount and original currency before every new provider call. Invalid VAT is state invalid_vat_id with rule vat_id_invalid, without a payment. Pending/eligible/held has no redirect; after VIES recovers, the owner must confirm the current quote. An issued USD invoice remains held/legacy_usd_invoice: never convert it or call the provider anew until the integration decision resolves the conflict. Already-created payments retain recorded currency/amount and are looked up/reconciled, never replaced. Under the org lock, confirmation checks the current owed amount and returns the same payment identity on retries. invoice_not_open is a typed conflict; 404 not_found for unknown/foreign invoice. Pending itself never pays an invoice, lifts a lock or resets dunning."
6803
6865
  },
6804
6866
  {
6805
6867
  "method": "POST",
@@ -42,30 +42,16 @@
42
42
  "maximum": 9007199254740991,
43
43
  "description": "Per month in euro cents, excluding VAT."
44
44
  },
45
- "usd_month": {
46
- "type": "integer",
47
- "minimum": 0,
48
- "maximum": 9007199254740991,
49
- "description": "Per month in US dollar cents, excluding VAT: the euro price × 1.15, rounded up to a whole dollar."
50
- },
51
45
  "eur_year": {
52
46
  "type": "integer",
53
47
  "minimum": 0,
54
48
  "maximum": 9007199254740991,
55
49
  "description": "Per year in euro cents, excluding VAT: twelve months less 15 %."
56
- },
57
- "usd_year": {
58
- "type": "integer",
59
- "minimum": 0,
60
- "maximum": 9007199254740991,
61
- "description": "Per year in US dollar cents, excluding VAT: the yearly euro price × 1.15, rounded up to a whole dollar."
62
50
  }
63
51
  },
64
52
  "required": [
65
53
  "eur_month",
66
- "usd_month",
67
- "eur_year",
68
- "usd_year"
54
+ "eur_year"
69
55
  ],
70
56
  "additionalProperties": false,
71
57
  "description": "The price of one unit."
@@ -35,7 +35,13 @@
35
35
  "country": {
36
36
  "type": "string",
37
37
  "pattern": "^[A-Z]{2}$",
38
- "description": "The billing country. Decides VAT (`vatFor`) and currency (`currencyForCountry`)."
38
+ "description": "The billing country, used for purchase eligibility and VAT."
39
+ },
40
+ "state": {
41
+ "description": "State or region. A new US purchase requires a two-letter state code; historical addresses may omit it.",
42
+ "type": "string",
43
+ "minLength": 1,
44
+ "maxLength": 100
39
45
  }
40
46
  },
41
47
  "required": [
@@ -2,6 +2,12 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "type": "object",
4
4
  "properties": {
5
+ "operation_key": {
6
+ "type": "string",
7
+ "format": "uuid",
8
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
9
+ "description": "Client-generated UUID persisted before the start request. Unique per org and reused only for identical input."
10
+ },
5
11
  "plan": {
6
12
  "description": "The target plan. Omitted leaves the plan as it is.",
7
13
  "type": "string",
@@ -56,5 +62,8 @@
56
62
  "additionalProperties": false
57
63
  }
58
64
  },
65
+ "required": [
66
+ "operation_key"
67
+ ],
59
68
  "additionalProperties": false
60
69
  }