@fleetless/contracts 9.2.0-next.1 → 10.1.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 +24 -0
  2. package/artifacts/openapi.json +18609 -10341
  3. package/artifacts/routes.json +96 -16
  4. package/artifacts/schema/billing-change-response.schema.json +1527 -1727
  5. package/artifacts/schema/billing-decision-amounts.schema.json +244 -0
  6. package/artifacts/schema/billing-decision-display-request.schema.json +24 -0
  7. package/artifacts/schema/billing-decision-display-response.schema.json +3130 -0
  8. package/artifacts/schema/billing-decision-period.schema.json +550 -0
  9. package/artifacts/schema/billing-decision-snapshot.schema.json +3103 -0
  10. package/artifacts/schema/checkout-request.schema.json +3 -4
  11. package/artifacts/schema/checkout-response.schema.json +492 -402
  12. package/artifacts/schema/confirmation-proof.schema.json +6 -0
  13. package/artifacts/schema/plan-change-decision-lookup-query.schema.json +16 -0
  14. package/artifacts/schema/plan-change-decision-status-response.schema.json +543 -0
  15. package/artifacts/schema/plan-change-prepare-request.schema.json +84 -0
  16. package/artifacts/schema/plan-change-prepare-response.schema.json +3162 -0
  17. package/artifacts/schema/plan-change-request.schema.json +177 -65
  18. package/artifacts/schema/purchase-conflict-details.schema.json +94 -0
  19. package/artifacts/schema/purchase-intent-accepted-without-payment.schema.json +95 -0
  20. package/artifacts/schema/purchase-intent-confirm-request.schema.json +146 -33
  21. package/artifacts/schema/purchase-intent-draft.schema.json +449 -0
  22. package/artifacts/schema/purchase-intent-payment-started.schema.json +184 -0
  23. package/artifacts/schema/purchase-intent-response.schema.json +1235 -168
  24. package/dist/billing.d.ts +5665 -210
  25. package/dist/billing.js +224 -29
  26. package/dist/confirmation-proof.d.ts +5 -0
  27. package/dist/confirmation-proof.js +6 -0
  28. package/dist/iana-time-zones.d.ts +2 -0
  29. package/dist/iana-time-zones.js +426 -0
  30. package/dist/index.d.ts +5 -4
  31. package/dist/index.js +3 -2
  32. package/dist/plans.d.ts +125 -1
  33. package/dist/plans.js +19 -1
  34. package/dist/purchase-operation-key.d.ts +4 -0
  35. package/dist/purchase-operation-key.js +4 -0
  36. package/dist/routes.js +42 -21
  37. package/package.json +3 -1
@@ -354,99 +354,190 @@
354
354
  "rule"
355
355
  ],
356
356
  "additionalProperties": false
357
- },
357
+ }
358
+ ],
359
+ "allOf": [
358
360
  {
359
- "type": "object",
360
- "properties": {
361
- "intent_id": {
362
- "type": "string",
363
- "format": "uuid",
364
- "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)$",
365
- "description": "Opaque persisted purchase intent identity."
366
- },
367
- "operation_key": {
368
- "type": "string",
369
- "format": "uuid",
370
- "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)$",
371
- "description": "Client-generated UUID persisted before the start request. Unique per org and reused only for identical input."
361
+ "if": {
362
+ "properties": {
363
+ "operation": {
364
+ "enum": [
365
+ "invoice_payment",
366
+ "payment_method_invoice"
367
+ ]
368
+ }
372
369
  },
373
- "operation": {
374
- "type": "string",
375
- "enum": [
376
- "checkout",
377
- "paid_change",
378
- "invoice_payment",
379
- "payment_method_invoice"
380
- ]
370
+ "required": [
371
+ "operation"
372
+ ]
373
+ },
374
+ "then": {
375
+ "required": [
376
+ "invoice_id"
377
+ ]
378
+ }
379
+ },
380
+ {
381
+ "if": {
382
+ "properties": {
383
+ "operation": {
384
+ "const": "mandate_setup"
385
+ }
381
386
  },
382
- "invoice_id": {
383
- "description": "The due charge or issued invoice, for invoice-paying operations.",
384
- "type": "string",
385
- "format": "uuid",
386
- "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)$"
387
+ "required": [
388
+ "operation"
389
+ ]
390
+ },
391
+ "then": {
392
+ "properties": {
393
+ "state": {
394
+ "const": "held"
395
+ },
396
+ "reason": {
397
+ "const": "mandate_policy_unresolved"
398
+ }
387
399
  },
388
- "state": {
389
- "type": "string",
390
- "const": "payment_started"
400
+ "required": [
401
+ "reason"
402
+ ]
403
+ }
404
+ },
405
+ {
406
+ "if": {
407
+ "properties": {
408
+ "reason": {
409
+ "const": "mandate_policy_unresolved"
410
+ }
391
411
  },
392
- "payment_id": {
393
- "type": "string",
394
- "format": "uuid",
395
- "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)$"
412
+ "required": [
413
+ "reason"
414
+ ]
415
+ },
416
+ "then": {
417
+ "properties": {
418
+ "operation": {
419
+ "const": "mandate_setup"
420
+ }
421
+ }
422
+ }
423
+ },
424
+ {
425
+ "if": {
426
+ "properties": {
427
+ "payment": {
428
+ "properties": {
429
+ "kind": {
430
+ "const": "mandate"
431
+ }
432
+ },
433
+ "required": [
434
+ "kind"
435
+ ]
436
+ }
396
437
  },
397
- "payment": {
398
- "oneOf": [
399
- {
400
- "type": "object",
401
- "properties": {
402
- "kind": {
403
- "type": "string",
404
- "const": "hosted"
405
- },
406
- "checkout_id": {
407
- "type": "string",
408
- "format": "uuid",
409
- "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)$"
410
- },
411
- "checkout_url": {
412
- "type": "string",
413
- "format": "uri"
414
- }
415
- },
416
- "required": [
417
- "kind",
418
- "checkout_id",
419
- "checkout_url"
420
- ],
421
- "additionalProperties": false
438
+ "required": [
439
+ "payment"
440
+ ]
441
+ },
442
+ "then": {
443
+ "properties": {
444
+ "operation": {
445
+ "const": "paid_change"
446
+ }
447
+ }
448
+ }
449
+ }
450
+ ]
451
+ },
452
+ {
453
+ "type": "object",
454
+ "properties": {
455
+ "intent_id": {
456
+ "type": "string",
457
+ "format": "uuid",
458
+ "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)$",
459
+ "description": "Opaque persisted purchase intent identity."
460
+ },
461
+ "operation_key": {
462
+ "type": "string",
463
+ "format": "uuid",
464
+ "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)$",
465
+ "description": "Client-generated UUID persisted before the start request. Unique per org and reused only for identical input."
466
+ },
467
+ "operation": {
468
+ "type": "string",
469
+ "enum": [
470
+ "checkout",
471
+ "invoice_payment",
472
+ "payment_method_invoice"
473
+ ]
474
+ },
475
+ "invoice_id": {
476
+ "description": "The due charge or issued invoice, for invoice-paying operations.",
477
+ "type": "string",
478
+ "format": "uuid",
479
+ "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)$"
480
+ },
481
+ "state": {
482
+ "type": "string",
483
+ "const": "payment_started"
484
+ },
485
+ "payment_id": {
486
+ "type": "string",
487
+ "format": "uuid",
488
+ "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)$"
489
+ },
490
+ "payment": {
491
+ "oneOf": [
492
+ {
493
+ "type": "object",
494
+ "properties": {
495
+ "kind": {
496
+ "type": "string",
497
+ "const": "hosted"
422
498
  },
423
- {
424
- "type": "object",
425
- "properties": {
426
- "kind": {
427
- "type": "string",
428
- "const": "mandate"
429
- }
430
- },
431
- "required": [
432
- "kind"
433
- ],
434
- "additionalProperties": false
499
+ "checkout_id": {
500
+ "type": "string",
501
+ "format": "uuid",
502
+ "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)$"
503
+ },
504
+ "checkout_url": {
505
+ "type": "string",
506
+ "format": "uri"
435
507
  }
436
- ]
508
+ },
509
+ "required": [
510
+ "kind",
511
+ "checkout_id",
512
+ "checkout_url"
513
+ ],
514
+ "additionalProperties": false
515
+ },
516
+ {
517
+ "type": "object",
518
+ "properties": {
519
+ "kind": {
520
+ "type": "string",
521
+ "const": "mandate"
522
+ }
523
+ },
524
+ "required": [
525
+ "kind"
526
+ ],
527
+ "additionalProperties": false
437
528
  }
438
- },
439
- "required": [
440
- "intent_id",
441
- "operation_key",
442
- "operation",
443
- "state",
444
- "payment_id",
445
- "payment"
446
- ],
447
- "additionalProperties": false
529
+ ]
448
530
  }
531
+ },
532
+ "required": [
533
+ "intent_id",
534
+ "operation_key",
535
+ "operation",
536
+ "state",
537
+ "payment_id",
538
+ "payment"
449
539
  ],
540
+ "additionalProperties": false,
450
541
  "allOf": [
451
542
  {
452
543
  "if": {
@@ -1609,12 +1700,7 @@
1609
1700
  },
1610
1701
  "operation": {
1611
1702
  "type": "string",
1612
- "enum": [
1613
- "checkout",
1614
- "paid_change",
1615
- "invoice_payment",
1616
- "payment_method_invoice"
1617
- ]
1703
+ "const": "paid_change"
1618
1704
  },
1619
1705
  "invoice_id": {
1620
1706
  "description": "The due charge or issued invoice, for invoice-paying operations.",
@@ -1681,99 +1767,1080 @@
1681
1767
  "payment_id",
1682
1768
  "payment"
1683
1769
  ],
1684
- "additionalProperties": false,
1685
- "allOf": [
1686
- {
1687
- "if": {
1688
- "properties": {
1689
- "operation": {
1690
- "enum": [
1691
- "invoice_payment",
1692
- "payment_method_invoice"
1693
- ]
1694
- }
1695
- },
1696
- "required": [
1697
- "operation"
1698
- ]
1699
- },
1700
- "then": {
1701
- "required": [
1702
- "invoice_id"
1703
- ]
1704
- }
1770
+ "additionalProperties": false
1771
+ }
1772
+ },
1773
+ "required": [
1774
+ "billing",
1775
+ "charged",
1776
+ "intent"
1777
+ ],
1778
+ "additionalProperties": false
1779
+ },
1780
+ {
1781
+ "type": "object",
1782
+ "properties": {
1783
+ "billing": {
1784
+ "type": "object",
1785
+ "properties": {
1786
+ "available": {
1787
+ "type": "boolean",
1788
+ "description": "Whether this cloud takes payments at all — `false` when no Mollie key is configured."
1705
1789
  },
1706
- {
1707
- "if": {
1708
- "properties": {
1709
- "operation": {
1710
- "const": "mandate_setup"
1711
- }
1712
- },
1713
- "required": [
1714
- "operation"
1715
- ]
1716
- },
1717
- "then": {
1718
- "properties": {
1719
- "state": {
1720
- "const": "held"
1721
- },
1722
- "reason": {
1723
- "const": "mandate_policy_unresolved"
1724
- }
1725
- },
1726
- "required": [
1727
- "reason"
1728
- ]
1729
- }
1790
+ "account": {
1791
+ "anyOf": [
1792
+ {
1793
+ "type": "object",
1794
+ "properties": {
1795
+ "payer": {
1796
+ "oneOf": [
1797
+ {
1798
+ "type": "object",
1799
+ "properties": {
1800
+ "kind": {
1801
+ "type": "string",
1802
+ "const": "company",
1803
+ "description": "Billed as a company."
1804
+ },
1805
+ "company_name": {
1806
+ "type": "string",
1807
+ "minLength": 1,
1808
+ "maxLength": 200,
1809
+ "description": "The company's legal name, printed on the invoice."
1810
+ },
1811
+ "vat_id": {
1812
+ "anyOf": [
1813
+ {
1814
+ "type": "string",
1815
+ "maxLength": 20
1816
+ },
1817
+ {
1818
+ "type": "null"
1819
+ }
1820
+ ],
1821
+ "description": "The company's VAT ID, or `null` for none. Required for a new purchase in another EU country; direct VIES must confirm it with an identifier."
1822
+ },
1823
+ "tax_id": {
1824
+ "description": "Free-text Tax ID. Required for a new non-EU purchase; historical records may omit it.",
1825
+ "anyOf": [
1826
+ {
1827
+ "type": "string",
1828
+ "maxLength": 100
1829
+ },
1830
+ {
1831
+ "type": "null"
1832
+ }
1833
+ ]
1834
+ },
1835
+ "address": {
1836
+ "type": "object",
1837
+ "properties": {
1838
+ "line1": {
1839
+ "type": "string",
1840
+ "minLength": 1,
1841
+ "maxLength": 200,
1842
+ "description": "Street and number, or the first address line."
1843
+ },
1844
+ "line2": {
1845
+ "anyOf": [
1846
+ {
1847
+ "type": "string",
1848
+ "maxLength": 200
1849
+ },
1850
+ {
1851
+ "type": "null"
1852
+ }
1853
+ ],
1854
+ "description": "A second address line, or `null` when there is none."
1855
+ },
1856
+ "postal_code": {
1857
+ "type": "string",
1858
+ "minLength": 1,
1859
+ "maxLength": 20,
1860
+ "description": "Postal or ZIP code."
1861
+ },
1862
+ "city": {
1863
+ "type": "string",
1864
+ "minLength": 1,
1865
+ "maxLength": 100,
1866
+ "description": "City or town."
1867
+ },
1868
+ "country": {
1869
+ "type": "string",
1870
+ "pattern": "^[A-Z]{2}$",
1871
+ "description": "The billing country, used for purchase eligibility and VAT."
1872
+ },
1873
+ "state": {
1874
+ "description": "State or region. A new US purchase requires a two-letter state code; historical addresses may omit it.",
1875
+ "type": "string",
1876
+ "minLength": 1,
1877
+ "maxLength": 100
1878
+ }
1879
+ },
1880
+ "required": [
1881
+ "line1",
1882
+ "line2",
1883
+ "postal_code",
1884
+ "city",
1885
+ "country"
1886
+ ],
1887
+ "additionalProperties": false,
1888
+ "description": "The billing address."
1889
+ },
1890
+ "invoice_email": {
1891
+ "type": "string",
1892
+ "format": "email",
1893
+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
1894
+ "description": "Where invoices and billing mail are sent."
1895
+ }
1896
+ },
1897
+ "required": [
1898
+ "kind",
1899
+ "company_name",
1900
+ "vat_id",
1901
+ "address",
1902
+ "invoice_email"
1903
+ ],
1904
+ "additionalProperties": false,
1905
+ "description": "A company: name and an optional VAT ID, never 'full name'."
1906
+ },
1907
+ {
1908
+ "type": "object",
1909
+ "properties": {
1910
+ "kind": {
1911
+ "type": "string",
1912
+ "const": "person",
1913
+ "description": "Billed as a person."
1914
+ },
1915
+ "full_name": {
1916
+ "type": "string",
1917
+ "minLength": 1,
1918
+ "maxLength": 200,
1919
+ "description": "The person's full name, printed on the invoice."
1920
+ },
1921
+ "address": {
1922
+ "type": "object",
1923
+ "properties": {
1924
+ "line1": {
1925
+ "type": "string",
1926
+ "minLength": 1,
1927
+ "maxLength": 200,
1928
+ "description": "Street and number, or the first address line."
1929
+ },
1930
+ "line2": {
1931
+ "anyOf": [
1932
+ {
1933
+ "type": "string",
1934
+ "maxLength": 200
1935
+ },
1936
+ {
1937
+ "type": "null"
1938
+ }
1939
+ ],
1940
+ "description": "A second address line, or `null` when there is none."
1941
+ },
1942
+ "postal_code": {
1943
+ "type": "string",
1944
+ "minLength": 1,
1945
+ "maxLength": 20,
1946
+ "description": "Postal or ZIP code."
1947
+ },
1948
+ "city": {
1949
+ "type": "string",
1950
+ "minLength": 1,
1951
+ "maxLength": 100,
1952
+ "description": "City or town."
1953
+ },
1954
+ "country": {
1955
+ "type": "string",
1956
+ "pattern": "^[A-Z]{2}$",
1957
+ "description": "The billing country, used for purchase eligibility and VAT."
1958
+ },
1959
+ "state": {
1960
+ "description": "State or region. A new US purchase requires a two-letter state code; historical addresses may omit it.",
1961
+ "type": "string",
1962
+ "minLength": 1,
1963
+ "maxLength": 100
1964
+ }
1965
+ },
1966
+ "required": [
1967
+ "line1",
1968
+ "line2",
1969
+ "postal_code",
1970
+ "city",
1971
+ "country"
1972
+ ],
1973
+ "additionalProperties": false,
1974
+ "description": "The billing address."
1975
+ },
1976
+ "invoice_email": {
1977
+ "type": "string",
1978
+ "format": "email",
1979
+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
1980
+ "description": "Where invoices and billing mail are sent."
1981
+ }
1982
+ },
1983
+ "required": [
1984
+ "kind",
1985
+ "full_name",
1986
+ "address",
1987
+ "invoice_email"
1988
+ ],
1989
+ "additionalProperties": false,
1990
+ "description": "A person: a full name, never a VAT ID — only a company can be VAT-registered."
1991
+ }
1992
+ ],
1993
+ "description": "Who is paying, and the invoice address and email."
1994
+ },
1995
+ "vat_id_status": {
1996
+ "anyOf": [
1997
+ {
1998
+ "type": "string",
1999
+ "enum": [
2000
+ "valid",
2001
+ "unverified",
2002
+ "invalid",
2003
+ "unavailable"
2004
+ ]
2005
+ },
2006
+ {
2007
+ "type": "null"
2008
+ }
2009
+ ],
2010
+ "description": "The payer's VAT ID check, or `null` when no VAT ID was given."
2011
+ },
2012
+ "vat": {
2013
+ "anyOf": [
2014
+ {
2015
+ "type": "object",
2016
+ "properties": {
2017
+ "treatment": {
2018
+ "type": "string",
2019
+ "enum": [
2020
+ "de_standard",
2021
+ "reverse_charge",
2022
+ "outside_eu"
2023
+ ],
2024
+ "description": "How the account is taxed."
2025
+ },
2026
+ "rate_percent": {
2027
+ "type": "integer",
2028
+ "minimum": -9007199254740991,
2029
+ "maximum": 9007199254740991,
2030
+ "description": "The VAT rate, in whole percent."
2031
+ }
2032
+ },
2033
+ "required": [
2034
+ "treatment",
2035
+ "rate_percent"
2036
+ ],
2037
+ "additionalProperties": false
2038
+ },
2039
+ {
2040
+ "type": "null"
2041
+ }
2042
+ ],
2043
+ "description": "Recorded VAT treatment; null while the current buyer has no eligible decision. Never infer zero rating from a pending account."
2044
+ },
2045
+ "currency": {
2046
+ "type": "string",
2047
+ "enum": [
2048
+ "eur",
2049
+ "usd"
2050
+ ],
2051
+ "description": "The org's billing currency, fixed at the first payment."
2052
+ },
2053
+ "cycle": {
2054
+ "type": "string",
2055
+ "enum": [
2056
+ "monthly",
2057
+ "yearly"
2058
+ ],
2059
+ "description": "The current billing cycle."
2060
+ },
2061
+ "status": {
2062
+ "type": "string",
2063
+ "enum": [
2064
+ "pending",
2065
+ "active",
2066
+ "past_due",
2067
+ "canceled"
2068
+ ],
2069
+ "description": "The account's own status."
2070
+ },
2071
+ "period_starts_at": {
2072
+ "anyOf": [
2073
+ {
2074
+ "type": "string",
2075
+ "format": "date-time",
2076
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
2077
+ },
2078
+ {
2079
+ "type": "null"
2080
+ }
2081
+ ],
2082
+ "description": "The current period's start. `null` before the first payment."
2083
+ },
2084
+ "period_ends_at": {
2085
+ "anyOf": [
2086
+ {
2087
+ "type": "string",
2088
+ "format": "date-time",
2089
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
2090
+ },
2091
+ {
2092
+ "type": "null"
2093
+ }
2094
+ ],
2095
+ "description": "The current period's end. `null` before the first payment."
2096
+ },
2097
+ "next_charge": {
2098
+ "anyOf": [
2099
+ {
2100
+ "type": "object",
2101
+ "properties": {
2102
+ "at": {
2103
+ "type": "string",
2104
+ "format": "date-time",
2105
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
2106
+ "description": "When the next charge is due."
2107
+ },
2108
+ "net_cents": {
2109
+ "type": "integer",
2110
+ "minimum": -9007199254740991,
2111
+ "maximum": 9007199254740991,
2112
+ "description": "The next charge, excluding VAT, in integer cents."
2113
+ },
2114
+ "vat_cents": {
2115
+ "type": "integer",
2116
+ "minimum": -9007199254740991,
2117
+ "maximum": 9007199254740991,
2118
+ "description": "VAT on the next charge, in integer cents."
2119
+ },
2120
+ "gross_cents": {
2121
+ "type": "integer",
2122
+ "minimum": -9007199254740991,
2123
+ "maximum": 9007199254740991,
2124
+ "description": "The next charge including VAT, in integer cents."
2125
+ }
2126
+ },
2127
+ "required": [
2128
+ "at",
2129
+ "net_cents",
2130
+ "vat_cents",
2131
+ "gross_cents"
2132
+ ],
2133
+ "additionalProperties": false
2134
+ },
2135
+ {
2136
+ "type": "null"
2137
+ }
2138
+ ],
2139
+ "description": "`null` while a cancel is pending or nothing else renews."
2140
+ },
2141
+ "scheduled": {
2142
+ "type": "object",
2143
+ "properties": {
2144
+ "cycle": {
2145
+ "anyOf": [
2146
+ {
2147
+ "type": "string",
2148
+ "enum": [
2149
+ "monthly",
2150
+ "yearly"
2151
+ ]
2152
+ },
2153
+ {
2154
+ "type": "null"
2155
+ }
2156
+ ],
2157
+ "description": "A cycle change queued for the period's end, or `null`."
2158
+ },
2159
+ "addons": {
2160
+ "anyOf": [
2161
+ {
2162
+ "type": "object",
2163
+ "properties": {
2164
+ "seats": {
2165
+ "type": "integer",
2166
+ "minimum": 0,
2167
+ "maximum": 9007199254740991,
2168
+ "description": "Extra developer seats, one each."
2169
+ },
2170
+ "robots": {
2171
+ "type": "integer",
2172
+ "minimum": 0,
2173
+ "maximum": 9007199254740991,
2174
+ "description": "Extra robots, one each."
2175
+ },
2176
+ "apps": {
2177
+ "type": "integer",
2178
+ "minimum": 0,
2179
+ "maximum": 9007199254740991,
2180
+ "description": "Extra apps, one each."
2181
+ },
2182
+ "app_user_packs": {
2183
+ "type": "integer",
2184
+ "minimum": 0,
2185
+ "maximum": 9007199254740991,
2186
+ "description": "Packs of five extra app users."
2187
+ },
2188
+ "live_video_packs": {
2189
+ "type": "integer",
2190
+ "minimum": 0,
2191
+ "maximum": 9007199254740991,
2192
+ "description": "Packs of 250 extra hours of app-user live video per month."
2193
+ }
2194
+ },
2195
+ "required": [
2196
+ "seats",
2197
+ "robots",
2198
+ "apps",
2199
+ "app_user_packs",
2200
+ "live_video_packs"
2201
+ ],
2202
+ "additionalProperties": false
2203
+ },
2204
+ {
2205
+ "type": "null"
2206
+ }
2207
+ ],
2208
+ "description": "Add-on counts queued for the period's end, or `null`."
2209
+ }
2210
+ },
2211
+ "required": [
2212
+ "cycle",
2213
+ "addons"
2214
+ ],
2215
+ "additionalProperties": false,
2216
+ "description": "What takes effect at the period's end."
2217
+ },
2218
+ "dunning": {
2219
+ "anyOf": [
2220
+ {
2221
+ "type": "object",
2222
+ "properties": {
2223
+ "invoice_id": {
2224
+ "type": "string",
2225
+ "format": "uuid",
2226
+ "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)$",
2227
+ "description": "What dunning is chasing: a historical open `FL-…` invoice, or a due charge. Before the issuer cutover a due charge appears here only while the payer's VAT ID is unsettled; it has no number yet, is not in `invoices`, and `POST /api/billing/invoices/:id/pay` takes either. After the cutover this is always a due charge (in `charges`): pay it with `POST /api/billing/charges/:id/pay`."
2228
+ },
2229
+ "gross_cents": {
2230
+ "type": "integer",
2231
+ "minimum": -9007199254740991,
2232
+ "maximum": 9007199254740991,
2233
+ "description": "The amount owed, in integer cents — after a partial chargeback only the charged-back part."
2234
+ },
2235
+ "due_at": {
2236
+ "type": "string",
2237
+ "format": "date-time",
2238
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
2239
+ "description": "The charge's due date; retries and the lock count from here."
2240
+ },
2241
+ "next_retry_at": {
2242
+ "anyOf": [
2243
+ {
2244
+ "type": "string",
2245
+ "format": "date-time",
2246
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
2247
+ },
2248
+ {
2249
+ "type": "null"
2250
+ }
2251
+ ],
2252
+ "description": "The next automatic retry, or `null` once retries are exhausted. Always `null` after a chargeback: a charged-back payment is never charged again automatically."
2253
+ },
2254
+ "lock_at": {
2255
+ "type": "string",
2256
+ "format": "date-time",
2257
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
2258
+ "description": "When the org is locked if still unpaid (`BILLING_LOCK_DAY`)."
2259
+ },
2260
+ "failure": {
2261
+ "anyOf": [
2262
+ {
2263
+ "type": "string"
2264
+ },
2265
+ {
2266
+ "type": "null"
2267
+ }
2268
+ ],
2269
+ "description": "Mollie's own reason, e.g. 'card_expired'; 'vat_id_invalid' while a renewal is held because VIES does not confirm the VAT ID; 'charged_back' after a chargeback or a lost PayPal dispute."
2270
+ }
2271
+ },
2272
+ "required": [
2273
+ "invoice_id",
2274
+ "gross_cents",
2275
+ "due_at",
2276
+ "next_retry_at",
2277
+ "lock_at",
2278
+ "failure"
2279
+ ],
2280
+ "additionalProperties": false
2281
+ },
2282
+ {
2283
+ "type": "null"
2284
+ }
2285
+ ],
2286
+ "description": "`null` while nothing is overdue. During a VAT-ID hold the charge is due but not yet invoiced."
2287
+ }
2288
+ },
2289
+ "required": [
2290
+ "payer",
2291
+ "vat_id_status",
2292
+ "vat",
2293
+ "currency",
2294
+ "cycle",
2295
+ "status",
2296
+ "period_starts_at",
2297
+ "period_ends_at",
2298
+ "next_charge",
2299
+ "scheduled",
2300
+ "dunning"
2301
+ ],
2302
+ "additionalProperties": false
2303
+ },
2304
+ {
2305
+ "type": "null"
2306
+ }
2307
+ ],
2308
+ "description": "`null` before the org has ever checked out."
2309
+ },
2310
+ "payment_method": {
2311
+ "anyOf": [
2312
+ {
2313
+ "oneOf": [
2314
+ {
2315
+ "type": "object",
2316
+ "properties": {
2317
+ "kind": {
2318
+ "type": "string",
2319
+ "const": "card",
2320
+ "description": "A card mandate."
2321
+ },
2322
+ "brand": {
2323
+ "type": "string",
2324
+ "description": "The card network, as Mollie's mandate reports it, e.g. 'Visa'."
2325
+ },
2326
+ "last4": {
2327
+ "type": "string",
2328
+ "pattern": "^\\d{4}$",
2329
+ "description": "The last four digits of the card."
2330
+ },
2331
+ "expires": {
2332
+ "type": "string",
2333
+ "pattern": "^\\d{2}\\/\\d{2}$",
2334
+ "description": "Expiry as Mollie's mandate shows it, 'MM/YY'."
2335
+ }
2336
+ },
2337
+ "required": [
2338
+ "kind",
2339
+ "brand",
2340
+ "last4",
2341
+ "expires"
2342
+ ],
2343
+ "additionalProperties": false
2344
+ },
2345
+ {
2346
+ "type": "object",
2347
+ "properties": {
2348
+ "kind": {
2349
+ "type": "string",
2350
+ "const": "applepay",
2351
+ "description": "A card mandate from an Apple Pay first payment — Mollie stores it as `creditcard`; Fleetless labels it Apple Pay."
2352
+ },
2353
+ "brand": {
2354
+ "type": "string",
2355
+ "description": "The card network, as Mollie's mandate reports it, e.g. 'Mastercard'."
2356
+ },
2357
+ "last4": {
2358
+ "type": "string",
2359
+ "pattern": "^\\d{4}$",
2360
+ "description": "The last four digits of the card behind Apple Pay."
2361
+ },
2362
+ "expires": {
2363
+ "type": "string",
2364
+ "pattern": "^\\d{2}\\/\\d{2}$",
2365
+ "description": "Expiry as Mollie's mandate shows it, 'MM/YY'."
2366
+ }
2367
+ },
2368
+ "required": [
2369
+ "kind",
2370
+ "brand",
2371
+ "last4",
2372
+ "expires"
2373
+ ],
2374
+ "additionalProperties": false
2375
+ },
2376
+ {
2377
+ "type": "object",
2378
+ "properties": {
2379
+ "kind": {
2380
+ "type": "string",
2381
+ "const": "paypal",
2382
+ "description": "A PayPal mandate."
2383
+ },
2384
+ "account": {
2385
+ "type": "string",
2386
+ "description": "The PayPal account Mollie's mandate names."
2387
+ }
2388
+ },
2389
+ "required": [
2390
+ "kind",
2391
+ "account"
2392
+ ],
2393
+ "additionalProperties": false
2394
+ }
2395
+ ]
2396
+ },
2397
+ {
2398
+ "type": "null"
2399
+ }
2400
+ ],
2401
+ "description": "The payment method on file, or `null`."
1730
2402
  },
1731
- {
1732
- "if": {
2403
+ "payment_method_options": {
2404
+ "type": "array",
2405
+ "items": {
2406
+ "type": "object",
2407
+ "properties": {
2408
+ "method": {
2409
+ "type": "string",
2410
+ "enum": [
2411
+ "card",
2412
+ "paypal",
2413
+ "applepay"
2414
+ ],
2415
+ "description": "A method `POST /api/billing/payment-method` accepts now."
2416
+ },
2417
+ "pays_invoice": {
2418
+ "type": "boolean",
2419
+ "description": "Whether changing to it also pays the open invoice — `true` only for `applepay` when a zero-amount Apple Pay payment is not available."
2420
+ }
2421
+ },
2422
+ "required": [
2423
+ "method",
2424
+ "pays_invoice"
2425
+ ],
2426
+ "additionalProperties": false
2427
+ },
2428
+ "description": "What a payment-method change may offer right now, so a client offers exactly what the cloud accepts. `applepay` is absent when it needs an open invoice and none is open; `[]` when the org has no billing account."
2429
+ },
2430
+ "issuer": {
2431
+ "type": "string",
2432
+ "enum": [
2433
+ "cloud",
2434
+ "lexware"
2435
+ ],
2436
+ "description": "Which system issues this org's charges: `cloud` before the issuer cutover, or `lexware` after it."
2437
+ },
2438
+ "invoices": {
2439
+ "type": "array",
2440
+ "items": {
2441
+ "type": "object",
2442
+ "properties": {
2443
+ "id": {
2444
+ "type": "string",
2445
+ "format": "uuid",
2446
+ "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)$",
2447
+ "description": "The invoice's id."
2448
+ },
2449
+ "number": {
2450
+ "type": "string",
2451
+ "pattern": "^FL-\\d{4}-\\d{4,}$",
2452
+ "description": "The invoice number: `FL-<year>-<seq>`, `seq` zero-padded to four digits, gapless per calendar year in `Europe/Berlin`."
2453
+ },
2454
+ "issued_at": {
2455
+ "type": "string",
2456
+ "format": "date-time",
2457
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
2458
+ "description": "When the invoice was issued."
2459
+ },
2460
+ "status": {
2461
+ "type": "string",
2462
+ "enum": [
2463
+ "open",
2464
+ "paid",
2465
+ "uncollectible"
2466
+ ],
2467
+ "description": "This invoice's own status."
2468
+ },
2469
+ "currency": {
2470
+ "type": "string",
2471
+ "enum": [
2472
+ "eur",
2473
+ "usd"
2474
+ ],
2475
+ "description": "The org's billing currency."
2476
+ },
2477
+ "net_cents": {
2478
+ "type": "integer",
2479
+ "minimum": 0,
2480
+ "maximum": 9007199254740991,
2481
+ "description": "The charge, excluding VAT, in integer cents."
2482
+ },
2483
+ "vat_rate_percent": {
2484
+ "type": "integer",
2485
+ "minimum": 0,
2486
+ "maximum": 100,
2487
+ "description": "The VAT rate applied, in whole percent."
2488
+ },
2489
+ "vat_cents": {
2490
+ "type": "integer",
2491
+ "minimum": 0,
2492
+ "maximum": 9007199254740991,
2493
+ "description": "VAT, in integer cents (`vatCents`)."
2494
+ },
2495
+ "gross_cents": {
2496
+ "type": "integer",
2497
+ "minimum": 0,
2498
+ "maximum": 9007199254740991,
2499
+ "description": "Net plus VAT, in integer cents."
2500
+ }
2501
+ },
2502
+ "required": [
2503
+ "id",
2504
+ "number",
2505
+ "issued_at",
2506
+ "status",
2507
+ "currency",
2508
+ "net_cents",
2509
+ "vat_rate_percent",
2510
+ "vat_cents",
2511
+ "gross_cents"
2512
+ ],
2513
+ "additionalProperties": false
2514
+ },
2515
+ "description": "Cloud-issued invoices from before the issuer cutover; read-only, never grows after it. Newest first, at most 24."
2516
+ },
2517
+ "charges": {
2518
+ "type": "array",
2519
+ "items": {
2520
+ "type": "object",
1733
2521
  "properties": {
1734
- "reason": {
1735
- "const": "mandate_policy_unresolved"
2522
+ "id": {
2523
+ "type": "string",
2524
+ "format": "uuid",
2525
+ "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)$",
2526
+ "description": "The due charge's id — never a Cloud invoice number. Pay it with `POST /api/billing/charges/:id/pay`."
2527
+ },
2528
+ "kind": {
2529
+ "type": "string",
2530
+ "enum": [
2531
+ "first",
2532
+ "renewal",
2533
+ "change"
2534
+ ],
2535
+ "description": "What caused the charge: the first charge after checkout, a scheduled renewal, or a mid-period plan change."
2536
+ },
2537
+ "status": {
2538
+ "type": "string",
2539
+ "enum": [
2540
+ "due",
2541
+ "paid",
2542
+ "uncollectible",
2543
+ "cancelled"
2544
+ ],
2545
+ "description": "The charge's own status. A charged back or manually refunded charge stays `paid` — refunds and chargebacks are handled in Mollie or Lexware by hand; this status and the invoice it names are unchanged, and the resulting Lexware credit note appears under `GET /api/billing/documents` instead."
2546
+ },
2547
+ "currency": {
2548
+ "type": "string",
2549
+ "const": "eur",
2550
+ "description": "Every charge billed through Lexware is EUR."
2551
+ },
2552
+ "net_cents": {
2553
+ "type": "integer",
2554
+ "minimum": 0,
2555
+ "maximum": 9007199254740991,
2556
+ "description": "The charge, excluding VAT, in integer cents."
2557
+ },
2558
+ "vat_rate_percent": {
2559
+ "type": "integer",
2560
+ "minimum": 0,
2561
+ "maximum": 100,
2562
+ "description": "The VAT rate applied, in whole percent."
2563
+ },
2564
+ "vat_cents": {
2565
+ "type": "integer",
2566
+ "minimum": 0,
2567
+ "maximum": 9007199254740991,
2568
+ "description": "VAT, in integer cents (`vatCents`)."
2569
+ },
2570
+ "gross_cents": {
2571
+ "type": "integer",
2572
+ "minimum": 0,
2573
+ "maximum": 9007199254740991,
2574
+ "description": "Net plus VAT, in integer cents."
2575
+ },
2576
+ "period_start": {
2577
+ "type": "string",
2578
+ "format": "date-time",
2579
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
2580
+ "description": "The covered period's start."
2581
+ },
2582
+ "period_end": {
2583
+ "type": "string",
2584
+ "format": "date-time",
2585
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
2586
+ "description": "The covered period's end."
2587
+ },
2588
+ "due_at": {
2589
+ "type": "string",
2590
+ "format": "date-time",
2591
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
2592
+ "description": "When this charge is due."
2593
+ },
2594
+ "paid_at": {
2595
+ "anyOf": [
2596
+ {
2597
+ "type": "string",
2598
+ "format": "date-time",
2599
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
2600
+ },
2601
+ {
2602
+ "type": "null"
2603
+ }
2604
+ ],
2605
+ "description": "When this charge was paid, or `null` while unpaid."
2606
+ },
2607
+ "invoice": {
2608
+ "oneOf": [
2609
+ {
2610
+ "type": "object",
2611
+ "properties": {
2612
+ "state": {
2613
+ "type": "string",
2614
+ "const": "not_issued",
2615
+ "description": "Not collected (due, a failed retry, or uncollectible): no invoice exists."
2616
+ }
2617
+ },
2618
+ "required": [
2619
+ "state"
2620
+ ],
2621
+ "additionalProperties": false
2622
+ },
2623
+ {
2624
+ "type": "object",
2625
+ "properties": {
2626
+ "state": {
2627
+ "type": "string",
2628
+ "const": "pending",
2629
+ "description": "Collected; the Lexware invoice is not yet confirmed."
2630
+ }
2631
+ },
2632
+ "required": [
2633
+ "state"
2634
+ ],
2635
+ "additionalProperties": false
2636
+ },
2637
+ {
2638
+ "type": "object",
2639
+ "properties": {
2640
+ "state": {
2641
+ "type": "string",
2642
+ "const": "issued",
2643
+ "description": "Lexware has confirmed the invoice."
2644
+ },
2645
+ "document_id": {
2646
+ "type": "string",
2647
+ "format": "uuid",
2648
+ "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)$",
2649
+ "description": "The Lexware document's id — read it with `GET /api/billing/documents/:id`."
2650
+ }
2651
+ },
2652
+ "required": [
2653
+ "state",
2654
+ "document_id"
2655
+ ],
2656
+ "additionalProperties": false
2657
+ }
2658
+ ],
2659
+ "description": "Whether a Lexware invoice exists for this charge yet, and which document it names once it does."
1736
2660
  }
1737
2661
  },
1738
2662
  "required": [
1739
- "reason"
1740
- ]
1741
- },
1742
- "then": {
1743
- "properties": {
1744
- "operation": {
1745
- "const": "mandate_setup"
1746
- }
1747
- }
1748
- }
1749
- },
1750
- {
1751
- "if": {
1752
- "properties": {
1753
- "payment": {
1754
- "properties": {
1755
- "kind": {
1756
- "const": "mandate"
2663
+ "id",
2664
+ "kind",
2665
+ "status",
2666
+ "currency",
2667
+ "net_cents",
2668
+ "vat_rate_percent",
2669
+ "vat_cents",
2670
+ "gross_cents",
2671
+ "period_start",
2672
+ "period_end",
2673
+ "due_at",
2674
+ "paid_at",
2675
+ "invoice"
2676
+ ],
2677
+ "additionalProperties": false,
2678
+ "allOf": [
2679
+ {
2680
+ "if": {
2681
+ "properties": {
2682
+ "status": {
2683
+ "const": "paid"
2684
+ }
2685
+ },
2686
+ "required": [
2687
+ "status"
2688
+ ]
2689
+ },
2690
+ "then": {
2691
+ "properties": {
2692
+ "invoice": {
2693
+ "properties": {
2694
+ "state": {
2695
+ "enum": [
2696
+ "pending",
2697
+ "issued"
2698
+ ]
2699
+ }
2700
+ }
2701
+ }
1757
2702
  }
2703
+ }
2704
+ },
2705
+ {
2706
+ "if": {
2707
+ "properties": {
2708
+ "status": {
2709
+ "enum": [
2710
+ "due",
2711
+ "uncollectible",
2712
+ "cancelled"
2713
+ ]
2714
+ }
2715
+ },
2716
+ "required": [
2717
+ "status"
2718
+ ]
1758
2719
  },
1759
- "required": [
1760
- "kind"
1761
- ]
2720
+ "then": {
2721
+ "properties": {
2722
+ "invoice": {
2723
+ "properties": {
2724
+ "state": {
2725
+ "const": "not_issued"
2726
+ }
2727
+ }
2728
+ }
2729
+ }
2730
+ }
1762
2731
  }
1763
- },
1764
- "required": [
1765
- "payment"
1766
2732
  ]
1767
2733
  },
1768
- "then": {
1769
- "properties": {
1770
- "operation": {
1771
- "const": "paid_change"
1772
- }
2734
+ "description": "Newest first, at most 24. Lists only due charges with issuer `lexware` — never a pre-cutover charge, a legacy payment (legacy_issued/legacy_held/legacy_person/legacy_usd) or a late USD collection: none of those carry a Lexware intent, and they stay in `invoices` or nowhere. `[]` while `issuer` is `cloud`."
2735
+ }
2736
+ },
2737
+ "required": [
2738
+ "available",
2739
+ "account",
2740
+ "payment_method",
2741
+ "payment_method_options",
2742
+ "issuer",
2743
+ "invoices",
2744
+ "charges"
2745
+ ],
2746
+ "additionalProperties": false
2747
+ },
2748
+ "charged": {
2749
+ "type": "null"
2750
+ },
2751
+ "intent": {
2752
+ "type": "object",
2753
+ "properties": {
2754
+ "intent_id": {
2755
+ "type": "string",
2756
+ "format": "uuid",
2757
+ "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)$"
2758
+ },
2759
+ "operation_key": {
2760
+ "type": "string",
2761
+ "format": "uuid",
2762
+ "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)$",
2763
+ "description": "Client-generated UUID persisted before the start request. Unique per org and reused only for identical input."
2764
+ },
2765
+ "operation": {
2766
+ "type": "string",
2767
+ "const": "paid_change"
2768
+ },
2769
+ "state": {
2770
+ "type": "string",
2771
+ "const": "accepted_no_payment"
2772
+ },
2773
+ "quote_revision": {
2774
+ "type": "string",
2775
+ "minLength": 1,
2776
+ "maxLength": 200,
2777
+ "description": "Opaque revision of the displayed quote; echo it when confirming."
2778
+ },
2779
+ "buyer_fingerprint": {
2780
+ "type": "string",
2781
+ "minLength": 1,
2782
+ "maxLength": 200,
2783
+ "description": "Opaque revision of buyer details and email policy; never full VIES evidence."
2784
+ },
2785
+ "quote": {
2786
+ "type": "object",
2787
+ "properties": {
2788
+ "currency": {
2789
+ "type": "string",
2790
+ "const": "eur",
2791
+ "description": "Every new quote is in EUR."
2792
+ },
2793
+ "net_cents": {
2794
+ "type": "number",
2795
+ "const": 0
2796
+ },
2797
+ "vat_cents": {
2798
+ "type": "number",
2799
+ "const": 0
2800
+ },
2801
+ "gross_cents": {
2802
+ "type": "number",
2803
+ "const": 0
2804
+ },
2805
+ "rate_percent": {
2806
+ "type": "integer",
2807
+ "minimum": 0,
2808
+ "maximum": 100,
2809
+ "description": "VAT rate in whole percent."
1773
2810
  }
1774
- }
2811
+ },
2812
+ "required": [
2813
+ "currency",
2814
+ "net_cents",
2815
+ "vat_cents",
2816
+ "gross_cents",
2817
+ "rate_percent"
2818
+ ],
2819
+ "additionalProperties": false
2820
+ },
2821
+ "accepted_at": {
2822
+ "type": "string",
2823
+ "allOf": [
2824
+ {
2825
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
2826
+ },
2827
+ {
2828
+ "pattern": "Z$"
2829
+ }
2830
+ ]
1775
2831
  }
1776
- ]
2832
+ },
2833
+ "required": [
2834
+ "intent_id",
2835
+ "operation_key",
2836
+ "operation",
2837
+ "state",
2838
+ "quote_revision",
2839
+ "buyer_fingerprint",
2840
+ "quote",
2841
+ "accepted_at"
2842
+ ],
2843
+ "additionalProperties": false
1777
2844
  }
1778
2845
  },
1779
2846
  "required": [