@fleetless/contracts 6.3.0-next.1 → 6.3.0-next.3
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/CHANGELOG.md +10 -2
- package/artifacts/openapi.json +92 -24
- package/artifacts/routes.json +8 -6
- package/artifacts/schema/billing-change-response.schema.json +43 -9
- package/artifacts/schema/billing-view.schema.json +43 -9
- package/artifacts/schema/payment-method-change-request.schema.json +2 -2
- package/artifacts/schema/payment-method.schema.json +15 -9
- package/dist/billing.d.ts +44 -10
- package/dist/billing.js +27 -6
- package/dist/errors.js +4 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/routes.js +26 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -20,14 +20,22 @@ version.
|
|
|
20
20
|
`prorateCents`, `changeNetCents`, `chargeAmounts`, `checkoutQuote`); and
|
|
21
21
|
the dunning schedule `BILLING_RETRY_DAYS` and `BILLING_LOCK_DAY`.
|
|
22
22
|
- **The billing read model and requests.** `billingView` (the account, the
|
|
23
|
-
payment method on file, the
|
|
24
|
-
`
|
|
23
|
+
payment method on file, the `payment_method_options` a change may offer
|
|
24
|
+
now, the last 24 invoices), `billingAccount`, `billingInvoice`,
|
|
25
|
+
`paymentMethod`, `billingDetails` and `billingAddress`;
|
|
25
26
|
the requests `checkoutRequest`, `vatIdCheckRequest`,
|
|
26
27
|
`billingChangeRequest` (absolute counts, not deltas),
|
|
27
28
|
`billingCancelRequest`, `billingDetailsUpdate` and
|
|
28
29
|
`paymentMethodChangeRequest`; the answers `checkoutResponse`,
|
|
29
30
|
`checkoutStatus`, `vatIdCheckResponse` and `billingChangeResponse`. Each
|
|
30
31
|
has a JSON Schema in `artifacts/schema/`.
|
|
32
|
+
- **Card, PayPal and Apple Pay.** `paymentMethodKind`
|
|
33
|
+
(`card | paypal | applepay`) is what `paymentMethodChangeRequest` names
|
|
34
|
+
and what `paymentMethod` shows: `applepay` carries the card fields,
|
|
35
|
+
because Mollie stores an Apple Pay mandate as a card mandate. A change
|
|
36
|
+
to Apple Pay may be refused with `400 validation_error`, rule
|
|
37
|
+
`applepay_needs_open_invoice`, where it can only be made while paying an
|
|
38
|
+
open invoice; `payment_method_options` says which applies.
|
|
31
39
|
- **The `billing` route section**, twelve routes: `GET /api/billing`, the
|
|
32
40
|
checkout and its status, the VAT-ID check, billing details, changes,
|
|
33
41
|
the payment method, cancel and resume, an invoice's PDF and paying an
|
package/artifacts/openapi.json
CHANGED
|
@@ -9605,7 +9605,7 @@
|
|
|
9605
9605
|
}
|
|
9606
9606
|
}
|
|
9607
9607
|
},
|
|
9608
|
-
"description": "`available: false` when `MOLLIE_API_KEY` is not configured — this cloud takes no payments, and every
|
|
9608
|
+
"description": "`available: false` when `MOLLIE_API_KEY` is not configured — this cloud takes no payments, and every billing route that charges or opens a Mollie checkout answers `503 billing_unavailable` instead of acting; cancel, resume, the details and the VAT-ID check need no Mollie and answer normally. `account` is `null` before the org has ever checked out; the plan and its limits still come from `GET /api/org/plan` (#103) and are not repeated here."
|
|
9609
9609
|
}
|
|
9610
9610
|
},
|
|
9611
9611
|
"/api/billing/checkout": {
|
|
@@ -9643,7 +9643,7 @@
|
|
|
9643
9643
|
}
|
|
9644
9644
|
}
|
|
9645
9645
|
},
|
|
9646
|
-
"description": "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; 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.",
|
|
9646
|
+
"description": "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.",
|
|
9647
9647
|
"requestBody": {
|
|
9648
9648
|
"required": true,
|
|
9649
9649
|
"content": {
|
|
@@ -9835,7 +9835,7 @@
|
|
|
9835
9835
|
}
|
|
9836
9836
|
}
|
|
9837
9837
|
},
|
|
9838
|
-
"description": "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` —
|
|
9838
|
+
"description": "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 #103's 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.",
|
|
9839
9839
|
"requestBody": {
|
|
9840
9840
|
"required": true,
|
|
9841
9841
|
"content": {
|
|
@@ -9883,7 +9883,7 @@
|
|
|
9883
9883
|
}
|
|
9884
9884
|
}
|
|
9885
9885
|
},
|
|
9886
|
-
"description": "Rate limited on the `billing.checkout` bucket, same as `POST /api/billing/checkout`. Creates a `first` payment on the existing Mollie customer
|
|
9886
|
+
"description": "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, and `POST /api/billing/invoices/:id/pay` still pays it 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.",
|
|
9887
9887
|
"requestBody": {
|
|
9888
9888
|
"required": true,
|
|
9889
9889
|
"content": {
|
|
@@ -12936,23 +12936,29 @@
|
|
|
12936
12936
|
"properties": {
|
|
12937
12937
|
"kind": {
|
|
12938
12938
|
"type": "string",
|
|
12939
|
-
"const": "
|
|
12940
|
-
"description": "A
|
|
12939
|
+
"const": "applepay",
|
|
12940
|
+
"description": "A card mandate from an Apple Pay first payment — Mollie stores it as `creditcard`; Fleetless labels it Apple Pay."
|
|
12941
12941
|
},
|
|
12942
|
-
"
|
|
12942
|
+
"brand": {
|
|
12943
12943
|
"type": "string",
|
|
12944
|
-
"description": "The
|
|
12944
|
+
"description": "The card network, as Mollie's mandate reports it, e.g. 'Mastercard'."
|
|
12945
12945
|
},
|
|
12946
|
-
"
|
|
12946
|
+
"last4": {
|
|
12947
12947
|
"type": "string",
|
|
12948
|
-
"pattern": "
|
|
12949
|
-
"description": "The last four
|
|
12948
|
+
"pattern": "^\\d{4}$",
|
|
12949
|
+
"description": "The last four digits of the card behind Apple Pay."
|
|
12950
|
+
},
|
|
12951
|
+
"expires": {
|
|
12952
|
+
"type": "string",
|
|
12953
|
+
"pattern": "^\\d{2}\\/\\d{2}$",
|
|
12954
|
+
"description": "Expiry as Mollie's mandate shows it, 'MM/YY'."
|
|
12950
12955
|
}
|
|
12951
12956
|
},
|
|
12952
12957
|
"required": [
|
|
12953
12958
|
"kind",
|
|
12954
|
-
"
|
|
12955
|
-
"
|
|
12959
|
+
"brand",
|
|
12960
|
+
"last4",
|
|
12961
|
+
"expires"
|
|
12956
12962
|
],
|
|
12957
12963
|
"additionalProperties": false
|
|
12958
12964
|
},
|
|
@@ -12983,6 +12989,33 @@
|
|
|
12983
12989
|
],
|
|
12984
12990
|
"description": "The payment method on file, or `null`."
|
|
12985
12991
|
},
|
|
12992
|
+
"payment_method_options": {
|
|
12993
|
+
"type": "array",
|
|
12994
|
+
"items": {
|
|
12995
|
+
"type": "object",
|
|
12996
|
+
"properties": {
|
|
12997
|
+
"method": {
|
|
12998
|
+
"type": "string",
|
|
12999
|
+
"enum": [
|
|
13000
|
+
"card",
|
|
13001
|
+
"paypal",
|
|
13002
|
+
"applepay"
|
|
13003
|
+
],
|
|
13004
|
+
"description": "A method `POST /api/billing/payment-method` accepts now."
|
|
13005
|
+
},
|
|
13006
|
+
"pays_invoice": {
|
|
13007
|
+
"type": "boolean",
|
|
13008
|
+
"description": "Whether changing to it also pays the open invoice — `true` only for `applepay` when a zero-amount Apple Pay payment is not available."
|
|
13009
|
+
}
|
|
13010
|
+
},
|
|
13011
|
+
"required": [
|
|
13012
|
+
"method",
|
|
13013
|
+
"pays_invoice"
|
|
13014
|
+
],
|
|
13015
|
+
"additionalProperties": false
|
|
13016
|
+
},
|
|
13017
|
+
"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."
|
|
13018
|
+
},
|
|
12986
13019
|
"invoices": {
|
|
12987
13020
|
"type": "array",
|
|
12988
13021
|
"items": {
|
|
@@ -13067,6 +13100,7 @@
|
|
|
13067
13100
|
"available",
|
|
13068
13101
|
"account",
|
|
13069
13102
|
"payment_method",
|
|
13103
|
+
"payment_method_options",
|
|
13070
13104
|
"invoices"
|
|
13071
13105
|
],
|
|
13072
13106
|
"additionalProperties": false,
|
|
@@ -13721,23 +13755,29 @@
|
|
|
13721
13755
|
"properties": {
|
|
13722
13756
|
"kind": {
|
|
13723
13757
|
"type": "string",
|
|
13724
|
-
"const": "
|
|
13725
|
-
"description": "A
|
|
13758
|
+
"const": "applepay",
|
|
13759
|
+
"description": "A card mandate from an Apple Pay first payment — Mollie stores it as `creditcard`; Fleetless labels it Apple Pay."
|
|
13726
13760
|
},
|
|
13727
|
-
"
|
|
13761
|
+
"brand": {
|
|
13728
13762
|
"type": "string",
|
|
13729
|
-
"description": "The
|
|
13763
|
+
"description": "The card network, as Mollie's mandate reports it, e.g. 'Mastercard'."
|
|
13730
13764
|
},
|
|
13731
|
-
"
|
|
13765
|
+
"last4": {
|
|
13732
13766
|
"type": "string",
|
|
13733
|
-
"pattern": "
|
|
13734
|
-
"description": "The last four
|
|
13767
|
+
"pattern": "^\\d{4}$",
|
|
13768
|
+
"description": "The last four digits of the card behind Apple Pay."
|
|
13769
|
+
},
|
|
13770
|
+
"expires": {
|
|
13771
|
+
"type": "string",
|
|
13772
|
+
"pattern": "^\\d{2}\\/\\d{2}$",
|
|
13773
|
+
"description": "Expiry as Mollie's mandate shows it, 'MM/YY'."
|
|
13735
13774
|
}
|
|
13736
13775
|
},
|
|
13737
13776
|
"required": [
|
|
13738
13777
|
"kind",
|
|
13739
|
-
"
|
|
13740
|
-
"
|
|
13778
|
+
"brand",
|
|
13779
|
+
"last4",
|
|
13780
|
+
"expires"
|
|
13741
13781
|
],
|
|
13742
13782
|
"additionalProperties": false
|
|
13743
13783
|
},
|
|
@@ -13768,6 +13808,33 @@
|
|
|
13768
13808
|
],
|
|
13769
13809
|
"description": "The payment method on file, or `null`."
|
|
13770
13810
|
},
|
|
13811
|
+
"payment_method_options": {
|
|
13812
|
+
"type": "array",
|
|
13813
|
+
"items": {
|
|
13814
|
+
"type": "object",
|
|
13815
|
+
"properties": {
|
|
13816
|
+
"method": {
|
|
13817
|
+
"type": "string",
|
|
13818
|
+
"enum": [
|
|
13819
|
+
"card",
|
|
13820
|
+
"paypal",
|
|
13821
|
+
"applepay"
|
|
13822
|
+
],
|
|
13823
|
+
"description": "A method `POST /api/billing/payment-method` accepts now."
|
|
13824
|
+
},
|
|
13825
|
+
"pays_invoice": {
|
|
13826
|
+
"type": "boolean",
|
|
13827
|
+
"description": "Whether changing to it also pays the open invoice — `true` only for `applepay` when a zero-amount Apple Pay payment is not available."
|
|
13828
|
+
}
|
|
13829
|
+
},
|
|
13830
|
+
"required": [
|
|
13831
|
+
"method",
|
|
13832
|
+
"pays_invoice"
|
|
13833
|
+
],
|
|
13834
|
+
"additionalProperties": false
|
|
13835
|
+
},
|
|
13836
|
+
"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."
|
|
13837
|
+
},
|
|
13771
13838
|
"invoices": {
|
|
13772
13839
|
"type": "array",
|
|
13773
13840
|
"items": {
|
|
@@ -13852,6 +13919,7 @@
|
|
|
13852
13919
|
"available",
|
|
13853
13920
|
"account",
|
|
13854
13921
|
"payment_method",
|
|
13922
|
+
"payment_method_options",
|
|
13855
13923
|
"invoices"
|
|
13856
13924
|
],
|
|
13857
13925
|
"additionalProperties": false
|
|
@@ -21242,9 +21310,9 @@
|
|
|
21242
21310
|
"enum": [
|
|
21243
21311
|
"card",
|
|
21244
21312
|
"paypal",
|
|
21245
|
-
"
|
|
21313
|
+
"applepay"
|
|
21246
21314
|
],
|
|
21247
|
-
"description": "The new mandate's method. `
|
|
21315
|
+
"description": "The new mandate's method. Offer what `billingView.payment_method_options` lists: `applepay` may be refused with `400 validation_error` `{ field: 'method', rule: 'applepay_needs_open_invoice' }` unless an invoice is open."
|
|
21248
21316
|
}
|
|
21249
21317
|
},
|
|
21250
21318
|
"required": [
|
package/artifacts/routes.json
CHANGED
|
@@ -6495,7 +6495,7 @@
|
|
|
6495
6495
|
"tier_required"
|
|
6496
6496
|
],
|
|
6497
6497
|
"transport": "http",
|
|
6498
|
-
"notes": "`available: false` when `MOLLIE_API_KEY` is not configured — this cloud takes no payments, and every
|
|
6498
|
+
"notes": "`available: false` when `MOLLIE_API_KEY` is not configured — this cloud takes no payments, and every billing route that charges or opens a Mollie checkout answers `503 billing_unavailable` instead of acting; cancel, resume, the details and the VAT-ID check need no Mollie and answer normally. `account` is `null` before the org has ever checked out; the plan and its limits still come from `GET /api/org/plan` (#103) and are not repeated here."
|
|
6499
6499
|
},
|
|
6500
6500
|
{
|
|
6501
6501
|
"method": "POST",
|
|
@@ -6524,7 +6524,7 @@
|
|
|
6524
6524
|
"payment_provider_unavailable"
|
|
6525
6525
|
],
|
|
6526
6526
|
"transport": "http",
|
|
6527
|
-
"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; 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."
|
|
6527
|
+
"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."
|
|
6528
6528
|
},
|
|
6529
6529
|
{
|
|
6530
6530
|
"method": "GET",
|
|
@@ -6631,7 +6631,7 @@
|
|
|
6631
6631
|
"payment_provider_unavailable"
|
|
6632
6632
|
],
|
|
6633
6633
|
"transport": "http",
|
|
6634
|
-
"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` —
|
|
6634
|
+
"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 #103's 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."
|
|
6635
6635
|
},
|
|
6636
6636
|
{
|
|
6637
6637
|
"method": "POST",
|
|
@@ -6659,7 +6659,7 @@
|
|
|
6659
6659
|
"payment_provider_unavailable"
|
|
6660
6660
|
],
|
|
6661
6661
|
"transport": "http",
|
|
6662
|
-
"notes": "Rate limited on the `billing.checkout` bucket, same as `POST /api/billing/checkout`. Creates a `first` payment on the existing Mollie customer
|
|
6662
|
+
"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, and `POST /api/billing/invoices/:id/pay` still pays it 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."
|
|
6663
6663
|
},
|
|
6664
6664
|
{
|
|
6665
6665
|
"method": "POST",
|
|
@@ -6789,9 +6789,11 @@
|
|
|
6789
6789
|
"query": null,
|
|
6790
6790
|
"request": null,
|
|
6791
6791
|
"response": null,
|
|
6792
|
-
"errors": [
|
|
6792
|
+
"errors": [
|
|
6793
|
+
"rate_limited"
|
|
6794
|
+
],
|
|
6793
6795
|
"transport": "http",
|
|
6794
|
-
"notes": "**The body is never trusted**: it names only a payment id (`id=tr_…`, form-encoded, Mollie's own shape), and this route does nothing with it but call `reconcilePayment(deps, molliePaymentId)` — the same function `GET /api/billing/checkout/:id` and the hourly sweep call — which fetches the payment from Mollie itself and applies what Mollie says, idempotently. Rate limited on the `billing.webhook` bucket, per ip, 600/min — generous, because this is Mollie's own infrastructure calling, not a browser. **Every answer is `200`**, including an id this cloud does not recognise, which is logged and otherwise ignored, **except a processing fault, which is `500`** so Mollie retries the notification rather than this cloud losing it. `auth: 'none'` because Mollie signs nothing Fleetless checks here — the payment is only ever trusted once fetched back from Mollie's own API with the configured key."
|
|
6796
|
+
"notes": "**The body is never trusted**: it names only a payment id (`id=tr_…`, form-encoded, Mollie's own shape), and this route does nothing with it but call `reconcilePayment(deps, molliePaymentId)` — the same function `GET /api/billing/checkout/:id` and the hourly sweep call — which fetches the payment from Mollie itself and applies what Mollie says, idempotently. Rate limited on the `billing.webhook` bucket, per ip, 600/min — generous, because this is Mollie's own infrastructure calling, not a browser; over it the answer is `429 rate_limited`, and Mollie retries the notification later. **Every other answer is `200`**, including an id this cloud does not recognise, which is logged and otherwise ignored, **except a processing fault, which is `500`** so Mollie retries the notification rather than this cloud losing it. `auth: 'none'` because Mollie signs nothing Fleetless checks here — the payment is only ever trusted once fetched back from Mollie's own API with the configured key."
|
|
6795
6797
|
},
|
|
6796
6798
|
{
|
|
6797
6799
|
"method": "POST",
|
|
@@ -537,23 +537,29 @@
|
|
|
537
537
|
"properties": {
|
|
538
538
|
"kind": {
|
|
539
539
|
"type": "string",
|
|
540
|
-
"const": "
|
|
541
|
-
"description": "A
|
|
540
|
+
"const": "applepay",
|
|
541
|
+
"description": "A card mandate from an Apple Pay first payment — Mollie stores it as `creditcard`; Fleetless labels it Apple Pay."
|
|
542
542
|
},
|
|
543
|
-
"
|
|
543
|
+
"brand": {
|
|
544
544
|
"type": "string",
|
|
545
|
-
"description": "The
|
|
545
|
+
"description": "The card network, as Mollie's mandate reports it, e.g. 'Mastercard'."
|
|
546
546
|
},
|
|
547
|
-
"
|
|
547
|
+
"last4": {
|
|
548
548
|
"type": "string",
|
|
549
|
-
"pattern": "
|
|
550
|
-
"description": "The last four
|
|
549
|
+
"pattern": "^\\d{4}$",
|
|
550
|
+
"description": "The last four digits of the card behind Apple Pay."
|
|
551
|
+
},
|
|
552
|
+
"expires": {
|
|
553
|
+
"type": "string",
|
|
554
|
+
"pattern": "^\\d{2}\\/\\d{2}$",
|
|
555
|
+
"description": "Expiry as Mollie's mandate shows it, 'MM/YY'."
|
|
551
556
|
}
|
|
552
557
|
},
|
|
553
558
|
"required": [
|
|
554
559
|
"kind",
|
|
555
|
-
"
|
|
556
|
-
"
|
|
560
|
+
"brand",
|
|
561
|
+
"last4",
|
|
562
|
+
"expires"
|
|
557
563
|
],
|
|
558
564
|
"additionalProperties": false
|
|
559
565
|
},
|
|
@@ -584,6 +590,33 @@
|
|
|
584
590
|
],
|
|
585
591
|
"description": "The payment method on file, or `null`."
|
|
586
592
|
},
|
|
593
|
+
"payment_method_options": {
|
|
594
|
+
"type": "array",
|
|
595
|
+
"items": {
|
|
596
|
+
"type": "object",
|
|
597
|
+
"properties": {
|
|
598
|
+
"method": {
|
|
599
|
+
"type": "string",
|
|
600
|
+
"enum": [
|
|
601
|
+
"card",
|
|
602
|
+
"paypal",
|
|
603
|
+
"applepay"
|
|
604
|
+
],
|
|
605
|
+
"description": "A method `POST /api/billing/payment-method` accepts now."
|
|
606
|
+
},
|
|
607
|
+
"pays_invoice": {
|
|
608
|
+
"type": "boolean",
|
|
609
|
+
"description": "Whether changing to it also pays the open invoice — `true` only for `applepay` when a zero-amount Apple Pay payment is not available."
|
|
610
|
+
}
|
|
611
|
+
},
|
|
612
|
+
"required": [
|
|
613
|
+
"method",
|
|
614
|
+
"pays_invoice"
|
|
615
|
+
],
|
|
616
|
+
"additionalProperties": false
|
|
617
|
+
},
|
|
618
|
+
"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."
|
|
619
|
+
},
|
|
587
620
|
"invoices": {
|
|
588
621
|
"type": "array",
|
|
589
622
|
"items": {
|
|
@@ -668,6 +701,7 @@
|
|
|
668
701
|
"available",
|
|
669
702
|
"account",
|
|
670
703
|
"payment_method",
|
|
704
|
+
"payment_method_options",
|
|
671
705
|
"invoices"
|
|
672
706
|
],
|
|
673
707
|
"additionalProperties": false,
|
|
@@ -534,23 +534,29 @@
|
|
|
534
534
|
"properties": {
|
|
535
535
|
"kind": {
|
|
536
536
|
"type": "string",
|
|
537
|
-
"const": "
|
|
538
|
-
"description": "A
|
|
537
|
+
"const": "applepay",
|
|
538
|
+
"description": "A card mandate from an Apple Pay first payment — Mollie stores it as `creditcard`; Fleetless labels it Apple Pay."
|
|
539
539
|
},
|
|
540
|
-
"
|
|
540
|
+
"brand": {
|
|
541
541
|
"type": "string",
|
|
542
|
-
"description": "The
|
|
542
|
+
"description": "The card network, as Mollie's mandate reports it, e.g. 'Mastercard'."
|
|
543
543
|
},
|
|
544
|
-
"
|
|
544
|
+
"last4": {
|
|
545
545
|
"type": "string",
|
|
546
|
-
"pattern": "
|
|
547
|
-
"description": "The last four
|
|
546
|
+
"pattern": "^\\d{4}$",
|
|
547
|
+
"description": "The last four digits of the card behind Apple Pay."
|
|
548
|
+
},
|
|
549
|
+
"expires": {
|
|
550
|
+
"type": "string",
|
|
551
|
+
"pattern": "^\\d{2}\\/\\d{2}$",
|
|
552
|
+
"description": "Expiry as Mollie's mandate shows it, 'MM/YY'."
|
|
548
553
|
}
|
|
549
554
|
},
|
|
550
555
|
"required": [
|
|
551
556
|
"kind",
|
|
552
|
-
"
|
|
553
|
-
"
|
|
557
|
+
"brand",
|
|
558
|
+
"last4",
|
|
559
|
+
"expires"
|
|
554
560
|
],
|
|
555
561
|
"additionalProperties": false
|
|
556
562
|
},
|
|
@@ -581,6 +587,33 @@
|
|
|
581
587
|
],
|
|
582
588
|
"description": "The payment method on file, or `null`."
|
|
583
589
|
},
|
|
590
|
+
"payment_method_options": {
|
|
591
|
+
"type": "array",
|
|
592
|
+
"items": {
|
|
593
|
+
"type": "object",
|
|
594
|
+
"properties": {
|
|
595
|
+
"method": {
|
|
596
|
+
"type": "string",
|
|
597
|
+
"enum": [
|
|
598
|
+
"card",
|
|
599
|
+
"paypal",
|
|
600
|
+
"applepay"
|
|
601
|
+
],
|
|
602
|
+
"description": "A method `POST /api/billing/payment-method` accepts now."
|
|
603
|
+
},
|
|
604
|
+
"pays_invoice": {
|
|
605
|
+
"type": "boolean",
|
|
606
|
+
"description": "Whether changing to it also pays the open invoice — `true` only for `applepay` when a zero-amount Apple Pay payment is not available."
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
"required": [
|
|
610
|
+
"method",
|
|
611
|
+
"pays_invoice"
|
|
612
|
+
],
|
|
613
|
+
"additionalProperties": false
|
|
614
|
+
},
|
|
615
|
+
"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."
|
|
616
|
+
},
|
|
584
617
|
"invoices": {
|
|
585
618
|
"type": "array",
|
|
586
619
|
"items": {
|
|
@@ -665,6 +698,7 @@
|
|
|
665
698
|
"available",
|
|
666
699
|
"account",
|
|
667
700
|
"payment_method",
|
|
701
|
+
"payment_method_options",
|
|
668
702
|
"invoices"
|
|
669
703
|
],
|
|
670
704
|
"additionalProperties": false
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
"enum": [
|
|
8
8
|
"card",
|
|
9
9
|
"paypal",
|
|
10
|
-
"
|
|
10
|
+
"applepay"
|
|
11
11
|
],
|
|
12
|
-
"description": "The new mandate's method. `
|
|
12
|
+
"description": "The new mandate's method. Offer what `billingView.payment_method_options` lists: `applepay` may be refused with `400 validation_error` `{ field: 'method', rule: 'applepay_needs_open_invoice' }` unless an invoice is open."
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"required": [
|
|
@@ -37,23 +37,29 @@
|
|
|
37
37
|
"properties": {
|
|
38
38
|
"kind": {
|
|
39
39
|
"type": "string",
|
|
40
|
-
"const": "
|
|
41
|
-
"description": "A
|
|
40
|
+
"const": "applepay",
|
|
41
|
+
"description": "A card mandate from an Apple Pay first payment — Mollie stores it as `creditcard`; Fleetless labels it Apple Pay."
|
|
42
42
|
},
|
|
43
|
-
"
|
|
43
|
+
"brand": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "The card network, as Mollie's mandate reports it, e.g. 'Mastercard'."
|
|
46
|
+
},
|
|
47
|
+
"last4": {
|
|
44
48
|
"type": "string",
|
|
45
|
-
"
|
|
49
|
+
"pattern": "^\\d{4}$",
|
|
50
|
+
"description": "The last four digits of the card behind Apple Pay."
|
|
46
51
|
},
|
|
47
|
-
"
|
|
52
|
+
"expires": {
|
|
48
53
|
"type": "string",
|
|
49
|
-
"pattern": "
|
|
50
|
-
"description": "
|
|
54
|
+
"pattern": "^\\d{2}\\/\\d{2}$",
|
|
55
|
+
"description": "Expiry as Mollie's mandate shows it, 'MM/YY'."
|
|
51
56
|
}
|
|
52
57
|
},
|
|
53
58
|
"required": [
|
|
54
59
|
"kind",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
60
|
+
"brand",
|
|
61
|
+
"last4",
|
|
62
|
+
"expires"
|
|
57
63
|
],
|
|
58
64
|
"additionalProperties": false
|
|
59
65
|
},
|
package/dist/billing.d.ts
CHANGED
|
@@ -174,6 +174,11 @@ export interface CheckoutQuote extends ChargeAmounts {
|
|
|
174
174
|
* The first charge of a checkout: one full period of `plan` + `addons`.
|
|
175
175
|
* One line for the plan, then one line per add-on actually bought
|
|
176
176
|
* (quantity 0 is omitted, not a zero-amount line).
|
|
177
|
+
*
|
|
178
|
+
* The VAT is rounded once, over the whole net amount, because that is what
|
|
179
|
+
* is charged. Rounding it per line can land a cent off that total, so the
|
|
180
|
+
* plan line absorbs the difference: the gross lines always add up to
|
|
181
|
+
* `gross_cents`, and the amount a person sees is the amount charged.
|
|
177
182
|
*/
|
|
178
183
|
export declare function checkoutQuote(input: {
|
|
179
184
|
plan: 'plus' | 'pro';
|
|
@@ -371,12 +376,22 @@ export declare const billingDetailsUpdate: z.ZodObject<{
|
|
|
371
376
|
vat_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
372
377
|
}, z.core.$strict>;
|
|
373
378
|
export type BillingDetailsUpdate = z.infer<typeof billingDetailsUpdate>;
|
|
379
|
+
/**
|
|
380
|
+
* The payment methods Fleetless takes: card, PayPal and Apple Pay, in EUR and USD, and no others (André, 2026-10-04).
|
|
381
|
+
* Apple Pay is a Mollie method of its own at checkout and for a change, but the mandate it leaves is a card mandate.
|
|
382
|
+
*/
|
|
383
|
+
export declare const paymentMethodKind: z.ZodEnum<{
|
|
384
|
+
card: "card";
|
|
385
|
+
paypal: "paypal";
|
|
386
|
+
applepay: "applepay";
|
|
387
|
+
}>;
|
|
388
|
+
export type PaymentMethodKind = z.infer<typeof paymentMethodKind>;
|
|
374
389
|
/** `POST /api/billing/payment-method`'s body. */
|
|
375
390
|
export declare const paymentMethodChangeRequest: z.ZodObject<{
|
|
376
391
|
method: z.ZodEnum<{
|
|
377
392
|
card: "card";
|
|
378
393
|
paypal: "paypal";
|
|
379
|
-
|
|
394
|
+
applepay: "applepay";
|
|
380
395
|
}>;
|
|
381
396
|
}, z.core.$strict>;
|
|
382
397
|
export type PaymentMethodChangeRequest = z.infer<typeof paymentMethodChangeRequest>;
|
|
@@ -395,9 +410,10 @@ export declare const paymentMethod: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
395
410
|
last4: z.ZodString;
|
|
396
411
|
expires: z.ZodString;
|
|
397
412
|
}, z.core.$strip>, z.ZodObject<{
|
|
398
|
-
kind: z.ZodLiteral<"
|
|
399
|
-
|
|
400
|
-
|
|
413
|
+
kind: z.ZodLiteral<"applepay">;
|
|
414
|
+
brand: z.ZodString;
|
|
415
|
+
last4: z.ZodString;
|
|
416
|
+
expires: z.ZodString;
|
|
401
417
|
}, z.core.$strip>, z.ZodObject<{
|
|
402
418
|
kind: z.ZodLiteral<"paypal">;
|
|
403
419
|
account: z.ZodString;
|
|
@@ -611,13 +627,22 @@ export declare const billingView: z.ZodObject<{
|
|
|
611
627
|
last4: z.ZodString;
|
|
612
628
|
expires: z.ZodString;
|
|
613
629
|
}, z.core.$strip>, z.ZodObject<{
|
|
614
|
-
kind: z.ZodLiteral<"
|
|
615
|
-
|
|
616
|
-
|
|
630
|
+
kind: z.ZodLiteral<"applepay">;
|
|
631
|
+
brand: z.ZodString;
|
|
632
|
+
last4: z.ZodString;
|
|
633
|
+
expires: z.ZodString;
|
|
617
634
|
}, z.core.$strip>, z.ZodObject<{
|
|
618
635
|
kind: z.ZodLiteral<"paypal">;
|
|
619
636
|
account: z.ZodString;
|
|
620
637
|
}, z.core.$strip>], "kind">>;
|
|
638
|
+
payment_method_options: z.ZodArray<z.ZodObject<{
|
|
639
|
+
method: z.ZodEnum<{
|
|
640
|
+
card: "card";
|
|
641
|
+
paypal: "paypal";
|
|
642
|
+
applepay: "applepay";
|
|
643
|
+
}>;
|
|
644
|
+
pays_invoice: z.ZodBoolean;
|
|
645
|
+
}, z.core.$strip>>;
|
|
621
646
|
invoices: z.ZodArray<z.ZodObject<{
|
|
622
647
|
id: z.ZodUUID;
|
|
623
648
|
number: z.ZodString;
|
|
@@ -730,13 +755,22 @@ export declare const billingChangeResponse: z.ZodObject<{
|
|
|
730
755
|
last4: z.ZodString;
|
|
731
756
|
expires: z.ZodString;
|
|
732
757
|
}, z.core.$strip>, z.ZodObject<{
|
|
733
|
-
kind: z.ZodLiteral<"
|
|
734
|
-
|
|
735
|
-
|
|
758
|
+
kind: z.ZodLiteral<"applepay">;
|
|
759
|
+
brand: z.ZodString;
|
|
760
|
+
last4: z.ZodString;
|
|
761
|
+
expires: z.ZodString;
|
|
736
762
|
}, z.core.$strip>, z.ZodObject<{
|
|
737
763
|
kind: z.ZodLiteral<"paypal">;
|
|
738
764
|
account: z.ZodString;
|
|
739
765
|
}, z.core.$strip>], "kind">>;
|
|
766
|
+
payment_method_options: z.ZodArray<z.ZodObject<{
|
|
767
|
+
method: z.ZodEnum<{
|
|
768
|
+
card: "card";
|
|
769
|
+
paypal: "paypal";
|
|
770
|
+
applepay: "applepay";
|
|
771
|
+
}>;
|
|
772
|
+
pays_invoice: z.ZodBoolean;
|
|
773
|
+
}, z.core.$strip>>;
|
|
740
774
|
invoices: z.ZodArray<z.ZodObject<{
|
|
741
775
|
id: z.ZodUUID;
|
|
742
776
|
number: z.ZodString;
|
package/dist/billing.js
CHANGED
|
@@ -201,6 +201,11 @@ export function changeNetCents(input) {
|
|
|
201
201
|
* The first charge of a checkout: one full period of `plan` + `addons`.
|
|
202
202
|
* One line for the plan, then one line per add-on actually bought
|
|
203
203
|
* (quantity 0 is omitted, not a zero-amount line).
|
|
204
|
+
*
|
|
205
|
+
* The VAT is rounded once, over the whole net amount, because that is what
|
|
206
|
+
* is charged. Rounding it per line can land a cent off that total, so the
|
|
207
|
+
* plan line absorbs the difference: the gross lines always add up to
|
|
208
|
+
* `gross_cents`, and the amount a person sees is the amount charged.
|
|
204
209
|
*/
|
|
205
210
|
export function checkoutQuote(input) {
|
|
206
211
|
const { plan, addons, cycle, currency, rate_percent } = input;
|
|
@@ -218,7 +223,9 @@ export function checkoutQuote(input) {
|
|
|
218
223
|
}
|
|
219
224
|
}
|
|
220
225
|
const netCents = lines.reduce((sum, line) => sum + line.net_cents, 0);
|
|
221
|
-
|
|
226
|
+
const total = chargeAmounts(netCents, rate_percent);
|
|
227
|
+
lines[0].gross_cents += total.gross_cents - lines.reduce((sum, line) => sum + line.gross_cents, 0);
|
|
228
|
+
return { ...total, lines, rate_percent, currency, cycle };
|
|
222
229
|
}
|
|
223
230
|
/** Dunning after a failed renewal: retries on these days after the charge's due date. */
|
|
224
231
|
export const BILLING_RETRY_DAYS = [3, 7];
|
|
@@ -345,10 +352,16 @@ export const billingDetailsUpdate = z.object({
|
|
|
345
352
|
description: 'Replaces the VAT ID; `null` clears it. Omitted leaves it as it is. A new ID is re-checked through VIES.',
|
|
346
353
|
}),
|
|
347
354
|
}).strict();
|
|
355
|
+
/**
|
|
356
|
+
* The payment methods Fleetless takes: card, PayPal and Apple Pay, in EUR and USD, and no others (André, 2026-10-04).
|
|
357
|
+
* Apple Pay is a Mollie method of its own at checkout and for a change, but the mandate it leaves is a card mandate.
|
|
358
|
+
*/
|
|
359
|
+
export const paymentMethodKind = z.enum(['card', 'paypal', 'applepay']);
|
|
348
360
|
/** `POST /api/billing/payment-method`'s body. */
|
|
349
361
|
export const paymentMethodChangeRequest = z.object({
|
|
350
|
-
method:
|
|
351
|
-
description: "The new mandate's method. `
|
|
362
|
+
method: paymentMethodKind.meta({
|
|
363
|
+
description: "The new mandate's method. Offer what `billingView.payment_method_options` lists: `applepay` may be refused with " +
|
|
364
|
+
"`400 validation_error` `{ field: 'method', rule: 'applepay_needs_open_invoice' }` unless an invoice is open.",
|
|
352
365
|
}),
|
|
353
366
|
}).strict();
|
|
354
367
|
/** The billing account's own status, distinct from the org's plan: `billing_accounts` holds no plan, currency or period of its own. */
|
|
@@ -362,9 +375,10 @@ export const paymentMethod = z.discriminatedUnion('kind', [
|
|
|
362
375
|
expires: z.string().regex(/^\d{2}\/\d{2}$/).meta({ description: "Expiry as Mollie's mandate shows it, 'MM/YY'." }),
|
|
363
376
|
}),
|
|
364
377
|
z.object({
|
|
365
|
-
kind: z.literal('
|
|
366
|
-
|
|
367
|
-
|
|
378
|
+
kind: z.literal('applepay').meta({ description: "A card mandate from an Apple Pay first payment — Mollie stores it as `creditcard`; Fleetless labels it Apple Pay." }),
|
|
379
|
+
brand: z.string().meta({ description: "The card network, as Mollie's mandate reports it, e.g. 'Mastercard'." }),
|
|
380
|
+
last4: z.string().regex(/^\d{4}$/).meta({ description: 'The last four digits of the card behind Apple Pay.' }),
|
|
381
|
+
expires: z.string().regex(/^\d{2}\/\d{2}$/).meta({ description: "Expiry as Mollie's mandate shows it, 'MM/YY'." }),
|
|
368
382
|
}),
|
|
369
383
|
z.object({
|
|
370
384
|
kind: z.literal('paypal').meta({ description: 'A PayPal mandate.' }),
|
|
@@ -432,6 +446,13 @@ export const billingView = z.object({
|
|
|
432
446
|
available: z.boolean().meta({ description: 'Whether this cloud takes payments at all — `false` when no Mollie key is configured.' }),
|
|
433
447
|
account: billingAccount.nullable().meta({ description: '`null` before the org has ever checked out.' }),
|
|
434
448
|
payment_method: paymentMethod.nullable().meta({ description: 'The payment method on file, or `null`.' }),
|
|
449
|
+
payment_method_options: z.array(z.object({
|
|
450
|
+
method: paymentMethodKind.meta({ description: 'A method `POST /api/billing/payment-method` accepts now.' }),
|
|
451
|
+
pays_invoice: z.boolean().meta({ description: 'Whether changing to it also pays the open invoice — `true` only for `applepay` when a zero-amount Apple Pay payment is not available.' }),
|
|
452
|
+
})).meta({
|
|
453
|
+
description: 'What a payment-method change may offer right now, so a client offers exactly what the cloud accepts. `applepay` is absent when ' +
|
|
454
|
+
'it needs an open invoice and none is open; `[]` when the org has no billing account.',
|
|
455
|
+
}),
|
|
435
456
|
invoices: z.array(billingInvoice).meta({ description: 'Newest first, at most 24.' }),
|
|
436
457
|
});
|
|
437
458
|
/** `POST /api/billing/change`'s answer: the billing view afterwards, and what was charged right now, if anything. */
|
package/dist/errors.js
CHANGED
|
@@ -1042,8 +1042,10 @@ export const ERROR_CODES = [
|
|
|
1042
1042
|
// 2026-10-04 — billing through Mollie (#104).
|
|
1043
1043
|
/**
|
|
1044
1044
|
* `503`: this cloud takes no payments, because no payment provider is
|
|
1045
|
-
* configured — `MOLLIE_API_KEY` is unset. Every
|
|
1046
|
-
*
|
|
1045
|
+
* configured — `MOLLIE_API_KEY` is unset. Every billing route that
|
|
1046
|
+
* charges or opens a Mollie checkout answers it; the routes that need no
|
|
1047
|
+
* Mollie (cancel, resume, the details, the VAT-ID check) answer normally,
|
|
1048
|
+
* and `GET /api/billing` answers `200` with
|
|
1047
1049
|
* `available: false` instead, so a caller can render "billing is off"
|
|
1048
1050
|
* without parsing an error. An upgrade or an add-on is a request to
|
|
1049
1051
|
* Fleetless instead, exactly as it is today (#103's Feedback request).
|
package/dist/index.d.ts
CHANGED
|
@@ -57,5 +57,5 @@ export { planId, PLAN_ORDER, planLimitKey, planLimits, planFeature, planFeatures
|
|
|
57
57
|
export type { PlanId, PlanLimitKey, PlanLimits, PlanFeature, PlanFeatures, PlanPrices, PlanSupport, PlanCatalogueEntry, AddonKey, AddonCatalogueEntry, } from './plans.js';
|
|
58
58
|
export { planCurrency, orgAddons, orgPlanUsage, planChangeKeep, planChangeReason, pendingPlanChange, orgLock, orgPlan, planChangeRequest, planOverrides, adminPlanChangeRequest, } from './plans.js';
|
|
59
59
|
export type { PlanCurrency, OrgAddons, OrgPlanUsage, PlanChangeKeep, PlanChangeReason, PendingPlanChange, OrgLock, OrgPlan, PlanChangeRequest, PlanOverrides, AdminPlanChangeRequest, } from './plans.js';
|
|
60
|
-
export { countryCode, EU_COUNTRIES, SELLER_COUNTRY, DE_VAT_RATE_PERCENT, isEuCountry, currencyForCountry, payerKind, billingCycle, vatTreatment, payerRefusalRule, vatFor, viesCountry, normalizeVatId, periodNetCents, prorateCents, vatCents, chargeAmounts, DAY_MS, periodDays, remainingDays, changeNetCents, checkoutQuote, BILLING_RETRY_DAYS, BILLING_LOCK_DAY, billingAddress, billingDetails, checkoutRequest, checkoutResponse, checkoutStatus, vatIdStatus, vatIdCheckRequest, vatIdCheckResponse, billingChangeRequest, billingCancelRequest, billingDetailsUpdate, paymentMethodChangeRequest, billingAccountStatus, paymentMethod, invoiceStatus, billingInvoice, billingAccount, billingView, billingChangeResponse, } from './billing.js';
|
|
61
|
-
export type { PayerKind, BillingCycle, VatTreatment, PayerRefusalRule, VatDecision, ChargeAmounts, BillingState, QuoteLine, CheckoutQuote, BillingAddress, BillingDetails, CheckoutRequest, CheckoutResponse, CheckoutStatus, VatIdStatus, VatIdCheckRequest, VatIdCheckResponse, BillingChangeRequest, BillingCancelRequest, BillingDetailsUpdate, PaymentMethodChangeRequest, BillingAccountStatus, PaymentMethod, InvoiceStatus, BillingInvoice, BillingAccount, BillingView, BillingChangeResponse, } from './billing.js';
|
|
60
|
+
export { countryCode, EU_COUNTRIES, SELLER_COUNTRY, DE_VAT_RATE_PERCENT, isEuCountry, currencyForCountry, payerKind, billingCycle, vatTreatment, payerRefusalRule, vatFor, viesCountry, normalizeVatId, periodNetCents, prorateCents, vatCents, chargeAmounts, DAY_MS, periodDays, remainingDays, changeNetCents, checkoutQuote, BILLING_RETRY_DAYS, BILLING_LOCK_DAY, billingAddress, billingDetails, checkoutRequest, checkoutResponse, checkoutStatus, vatIdStatus, vatIdCheckRequest, vatIdCheckResponse, billingChangeRequest, billingCancelRequest, billingDetailsUpdate, paymentMethodKind, paymentMethodChangeRequest, billingAccountStatus, paymentMethod, invoiceStatus, billingInvoice, billingAccount, billingView, billingChangeResponse, } from './billing.js';
|
|
61
|
+
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, BillingAccount, BillingView, BillingChangeResponse, } from './billing.js';
|
package/dist/index.js
CHANGED
|
@@ -70,4 +70,4 @@ export { planId, PLAN_ORDER, planLimitKey, planLimits, planFeature, planFeatures
|
|
|
70
70
|
// admin request (I-2).
|
|
71
71
|
export { planCurrency, orgAddons, orgPlanUsage, planChangeKeep, planChangeReason, pendingPlanChange, orgLock, orgPlan, planChangeRequest, planOverrides, adminPlanChangeRequest, } from './plans.js';
|
|
72
72
|
// 2026-10-04 — billing through Mollie (#104).
|
|
73
|
-
export { countryCode, EU_COUNTRIES, SELLER_COUNTRY, DE_VAT_RATE_PERCENT, isEuCountry, currencyForCountry, payerKind, billingCycle, vatTreatment, payerRefusalRule, vatFor, viesCountry, normalizeVatId, periodNetCents, prorateCents, vatCents, chargeAmounts, DAY_MS, periodDays, remainingDays, changeNetCents, checkoutQuote, BILLING_RETRY_DAYS, BILLING_LOCK_DAY, billingAddress, billingDetails, checkoutRequest, checkoutResponse, checkoutStatus, vatIdStatus, vatIdCheckRequest, vatIdCheckResponse, billingChangeRequest, billingCancelRequest, billingDetailsUpdate, paymentMethodChangeRequest, billingAccountStatus, paymentMethod, invoiceStatus, billingInvoice, billingAccount, billingView, billingChangeResponse, } from './billing.js';
|
|
73
|
+
export { countryCode, EU_COUNTRIES, SELLER_COUNTRY, DE_VAT_RATE_PERCENT, isEuCountry, currencyForCountry, payerKind, billingCycle, vatTreatment, payerRefusalRule, vatFor, viesCountry, normalizeVatId, periodNetCents, prorateCents, vatCents, chargeAmounts, DAY_MS, periodDays, remainingDays, changeNetCents, checkoutQuote, BILLING_RETRY_DAYS, BILLING_LOCK_DAY, billingAddress, billingDetails, checkoutRequest, checkoutResponse, checkoutStatus, vatIdStatus, vatIdCheckRequest, vatIdCheckResponse, billingChangeRequest, billingCancelRequest, billingDetailsUpdate, paymentMethodKind, paymentMethodChangeRequest, billingAccountStatus, paymentMethod, invoiceStatus, billingInvoice, billingAccount, billingView, billingChangeResponse, } from './billing.js';
|
package/dist/routes.js
CHANGED
|
@@ -99,8 +99,9 @@ const DEVELOPER_GUARD = ['unauthorized', 'token_expired', 'token_revoked'];
|
|
|
99
99
|
* billing's own infrastructure rather than from what the caller sent
|
|
100
100
|
* (2026-10-04, fleetless/fleetless#104): `BILLING_OFF` is no payment
|
|
101
101
|
* provider configured at all, `MOLLIE` is Mollie itself not
|
|
102
|
-
* answering. Every
|
|
103
|
-
* lists both; a route that only reads or edits local state lists neither
|
|
102
|
+
* answering. Every billing route that charges or opens a Mollie checkout
|
|
103
|
+
* lists both; a route that only reads or edits local state lists neither,
|
|
104
|
+
* and answers normally without a key.
|
|
104
105
|
*/
|
|
105
106
|
const BILLING_OFF = ['billing_unavailable'];
|
|
106
107
|
const MOLLIE = ['payment_provider_unavailable'];
|
|
@@ -2868,9 +2869,9 @@ export const ROUTES = [
|
|
|
2868
2869
|
* developer answers `403 tier_required` and `GET /api/billing`
|
|
2869
2870
|
* is no exception — a developer reads #103's plan cards from
|
|
2870
2871
|
* `GET /api/org/plan` instead, without the payer, payment method or
|
|
2871
|
-
* invoices
|
|
2872
|
-
* `payment_provider_unavailable`
|
|
2873
|
-
*
|
|
2872
|
+
* invoices. The routes that list `billing_unavailable` and
|
|
2873
|
+
* `payment_provider_unavailable` spread them from the `BILLING_OFF` and
|
|
2874
|
+
* `MOLLIE` constants near the top of this file.
|
|
2874
2875
|
*/
|
|
2875
2876
|
{
|
|
2876
2877
|
method: 'GET', path: '/api/billing', section: 'billing',
|
|
@@ -2878,8 +2879,9 @@ export const ROUTES = [
|
|
|
2878
2879
|
audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
|
|
2879
2880
|
params: [], query: null, request: null, response: billingView,
|
|
2880
2881
|
errors: [...DEVELOPER_GUARD, 'tier_required'], transport: 'http',
|
|
2881
|
-
notes: '`available: false` when `MOLLIE_API_KEY` is not configured — this cloud takes no payments, and every
|
|
2882
|
-
'
|
|
2882
|
+
notes: '`available: false` when `MOLLIE_API_KEY` is not configured — this cloud takes no payments, and every billing route that ' +
|
|
2883
|
+
'charges or opens a Mollie checkout answers `503 billing_unavailable` instead of acting; cancel, resume, the details and the ' +
|
|
2884
|
+
'VAT-ID check need no Mollie and answer normally. `account` is `null` before the org has ever checked out; the plan ' +
|
|
2883
2885
|
'and its limits still come from `GET /api/org/plan` (#103) and are not repeated here.',
|
|
2884
2886
|
},
|
|
2885
2887
|
{
|
|
@@ -2896,7 +2898,8 @@ export const ROUTES = [
|
|
|
2896
2898
|
'`{ field: \'billing.vat_id\', rule: \'vat_id_invalid\' }` once VIES has said so, and ' +
|
|
2897
2899
|
'`{ field: \'accept_withdrawal\', rule: \'required\' }` for a person who did not confirm it. `409 target_state_conflict` names ' +
|
|
2898
2900
|
'`plan` with rule `already_billed` when the org already has an `active` or `past_due` billing account — checkout is for the first ' +
|
|
2899
|
-
'payment only, every later change is `POST /api/billing/change`. `checkout_url` is Mollie\'s hosted page
|
|
2901
|
+
'payment only, every later change is `POST /api/billing/change`. `checkout_url` is Mollie\'s hosted page, where the payer ' +
|
|
2902
|
+
'chooses card, PayPal or Apple Pay; the return lands on ' +
|
|
2900
2903
|
'`<console>/settings/billing?checkout=<checkout_id>`, which polls `GET /api/billing/checkout/:id` until the webhook — or the poll ' +
|
|
2901
2904
|
'itself — has reconciled the payment. `409 plan_limit` is the org\'s own usage against the plan being bought.',
|
|
2902
2905
|
},
|
|
@@ -2943,7 +2946,8 @@ export const ROUTES = [
|
|
|
2943
2946
|
notes: 'The body names the **absolute** target — plan, cycle and add-ons — never a delta: the route compares it with the ' +
|
|
2944
2947
|
'org\'s current state and splits the difference. The increasing part is charged now, through the same proration `changeNetCents` ' +
|
|
2945
2948
|
'computes, and takes effect the moment Mollie accepts the `recurring` payment with anything but `failed`, `canceled` or `expired` ' +
|
|
2946
|
-
'—
|
|
2949
|
+
'— card mandates, Apple Pay\'s included, usually answer `paid` within seconds, a PayPal one may stay `pending` for a while; if it ' +
|
|
2950
|
+
'fails later, its open invoice enters dunning like a failed renewal. If Mollie refuses or does not answer, nothing is applied ' +
|
|
2947
2951
|
'and this answers `502 payment_provider_unavailable` instead. The decreasing part — a lower plan, yearly → monthly, fewer add-ons — ' +
|
|
2948
2952
|
'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 ' +
|
|
2949
2953
|
'limits answers `409 plan_limit` and the console opens #103\'s choose-what-stays page. Any increase first withdraws a pending ' +
|
|
@@ -2959,12 +2963,16 @@ export const ROUTES = [
|
|
|
2959
2963
|
params: [], query: null, request: paymentMethodChangeRequest, response: checkoutResponse,
|
|
2960
2964
|
errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'not_found', 'rate_limited', ...BILLING_OFF, ...MOLLIE],
|
|
2961
2965
|
transport: 'http',
|
|
2962
|
-
notes: 'Rate limited on the `billing.checkout` bucket, same as `POST /api/billing/checkout`. Creates a `first` payment on the
|
|
2963
|
-
'Mollie customer
|
|
2964
|
-
'
|
|
2965
|
-
'
|
|
2966
|
-
'
|
|
2967
|
-
'
|
|
2966
|
+
notes: 'Rate limited on the `billing.checkout` bucket, same as `POST /api/billing/checkout`. Creates a hosted `first` payment on the ' +
|
|
2967
|
+
'existing Mollie customer, restricted to the chosen method (`card` → Mollie\'s `creditcard`, `paypal`, `applepay`). For `card` ' +
|
|
2968
|
+
'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 ' +
|
|
2969
|
+
'dunning retry charges the new mandate, and `POST /api/billing/invoices/:id/pay` still pays it at once. `applepay` behaves the ' +
|
|
2970
|
+
'same where Mollie accepts a zero-amount Apple Pay payment; where it does not, a change to Apple Pay is only offered together ' +
|
|
2971
|
+
'with paying an open invoice — the payment is then that invoice\'s amount and pays it — and without one this answers ' +
|
|
2972
|
+
'`400 validation_error` with `{ field: \'method\', rule: \'applepay_needs_open_invoice\' }`. A client offers what ' +
|
|
2973
|
+
'`payment_method_options` in `GET /api/billing` lists. `404 not_found` when the org has no billing account yet. When the new ' +
|
|
2974
|
+
'mandate turns `valid` it becomes the account\'s — an Apple Pay one is a card mandate, shown as `applepay` — and every other ' +
|
|
2975
|
+
'mandate of the customer is revoked.',
|
|
2968
2976
|
},
|
|
2969
2977
|
{
|
|
2970
2978
|
method: 'POST', path: '/api/billing/cancel', section: 'billing',
|
|
@@ -3013,12 +3021,12 @@ export const ROUTES = [
|
|
|
3013
3021
|
summary: "Takes Mollie's payment-changed notification and reconciles the payment.",
|
|
3014
3022
|
audience: 'internal', auth: 'none', rateLimited: true, ownerTier: false, status: 200,
|
|
3015
3023
|
params: [], query: null, request: null, response: null,
|
|
3016
|
-
errors: [], transport: 'http',
|
|
3024
|
+
errors: ['rate_limited'], transport: 'http',
|
|
3017
3025
|
notes: '**The body is never trusted**: it names only a payment id (`id=tr_…`, form-encoded, Mollie\'s own shape), and this route ' +
|
|
3018
3026
|
'does nothing with it but call `reconcilePayment(deps, molliePaymentId)` — the same function `GET /api/billing/checkout/:id` and ' +
|
|
3019
3027
|
'the hourly sweep call — which fetches the payment from Mollie itself and applies what Mollie says, idempotently. Rate limited on ' +
|
|
3020
|
-
'the `billing.webhook` bucket, per ip, 600/min — generous, because this is Mollie\'s own infrastructure calling, not a browser
|
|
3021
|
-
'**Every answer is `200`**, including an id this cloud does not recognise, which is logged and otherwise ignored, **except a ' +
|
|
3028
|
+
'the `billing.webhook` bucket, per ip, 600/min — generous, because this is Mollie\'s own infrastructure calling, not a browser; ' +
|
|
3029
|
+
'over it the answer is `429 rate_limited`, and Mollie retries the notification later. **Every other answer is `200`**, including an id this cloud does not recognise, which is logged and otherwise ignored, **except a ' +
|
|
3022
3030
|
'processing fault, which is `500`** so Mollie retries the notification rather than this cloud losing it. `auth: \'none\'` because ' +
|
|
3023
3031
|
'Mollie signs nothing Fleetless checks here — the payment is only ever trusted once fetched back from Mollie\'s own API with the ' +
|
|
3024
3032
|
'configured key.',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fleetless/contracts",
|
|
3
|
-
"version": "6.3.0-next.
|
|
3
|
+
"version": "6.3.0-next.3",
|
|
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",
|