@siglume/direct-request-payment 0.4.13 → 0.4.15

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.
@@ -537,15 +537,20 @@ accepted by these user-authenticated routes.
537
537
  This client creates SDRP Standard Payment requirements for external merchant
538
538
  checkout flows. Micro Payment and Nano Payment are applied automatically by
539
539
  amount and settled on account-assigned weekly / monthly slots, or earlier when a
540
- buyer/payee/token batch reaches JPY 10,000 / USD 100.00; they are not created
541
- explicitly through this client. Use the statement APIs below to see open-period
542
- usage, the close time, the final-notice schedule, and settled / unsettled /
543
- past-due revenue.
540
+ buyer / provider / token / pricing-band batch reaches JPY 10,000 / USD 100.00;
541
+ they are not created explicitly through this client. Use the statement APIs
542
+ below to see open-period usage, the close time, the final-notice schedule, and
543
+ settled / unsettled / past-due revenue.
544
544
 
545
545
  Standard Payment requirements include `fee_bps` from the Siglume platform. The
546
546
  SDK does not calculate merchant plan fees locally. For Micro / Nano, use the
547
547
  statement API amount fields (`protocol_fee_minor`, `gross_buyer_debit_minor`,
548
- `buyer_debit_minor`, and `rounding_delta_minor`); see [Pricing](./pricing.md).
548
+ `buyer_debit_minor`, `provider_gross_amount_minor`, and
549
+ `rounding_delta_minor`); see [Pricing](./pricing.md).
550
+ `provider_gross_amount_minor` is canonical; `provider_usage_amount_minor` and
551
+ `gross_buyer_debit_minor` are compatibility aliases of the same provider gross
552
+ amount. Micro / Nano protocol fees are seller-borne, so
553
+ `buyer_debit_minor = provider_gross_amount_minor`.
549
554
 
550
555
  ```ts
551
556
  const siglume = new DirectRequestPaymentClient({
@@ -772,10 +777,15 @@ returns `{items, next_cursor}`. When `next_cursor` is non-null, pass it back as
772
777
  Buyer-facing amount names are centered on the debit:
773
778
 
774
779
  - `estimated_buyer_debit_minor`
780
+ - `provider_gross_amount_minor`
775
781
  - `provider_usage_amount_minor`
776
782
  - `gross_buyer_debit_minor`
777
783
  - `buyer_debit_minor`
778
784
  - `protocol_fee_minor`
785
+ - `settlement_trigger`
786
+ - `settlement_threshold_minor`
787
+ - `threshold_reached_at`
788
+ - `total_unsettled_exposure_minor`
779
789
 
780
790
  ### Provider summary
781
791
 
@@ -833,6 +843,7 @@ back as `cursor` to fetch the next page.
833
843
 
834
844
  Provider-facing amount names:
835
845
 
846
+ - `provider_gross_amount_minor`
836
847
  - `provider_usage_amount_minor`
837
848
  - `provider_receivable_minor`
838
849
  - `gross_buyer_debit_minor`
@@ -845,6 +856,10 @@ Provider-facing amount names:
845
856
  Schedule and execution fields:
846
857
 
847
858
  - `period_start`, `period_end`, `close_at`
859
+ - `settlement_trigger`
860
+ - `settlement_threshold_minor`
861
+ - `threshold_reached_at`
862
+ - `total_unsettled_exposure_minor`
848
863
  - `expected_scheduled_debit_at`
849
864
  - `scheduled_debit_at`
850
865
  - `not_before_attempt_at`
@@ -884,13 +899,14 @@ curl https://siglume.com/v1/sdrp/metered/provider/settlement-batches/<batch-id>/
884
899
  Columns:
885
900
 
886
901
  ```text
887
- metered_usage_id,created_at,plan_type,settlement_cadence,period_start,period_end,listing_id,capability_key,operation_key,currency,token_symbol,provider_usage_amount_minor,provider_receivable_minor,protocol_fee_minor,gross_buyer_debit_minor,rounding_delta_minor,buyer_debit_minor,status,settlement_batch_id,buyer_period_ref
902
+ metered_usage_id,created_at,plan_type,settlement_cadence,period_start,period_end,listing_id,capability_key,operation_key,currency,token_symbol,provider_gross_amount_minor,provider_usage_amount_minor,provider_receivable_minor,protocol_fee_minor,gross_buyer_debit_minor,rounding_delta_minor,buyer_debit_minor,status,settlement_batch_id,buyer_period_ref
888
903
  ```
889
904
 
890
905
  The CSV uses `buyer_period_ref`, not raw buyer account identifiers.
891
906
  The CSV keeps the `rounding_delta_minor` column for schema stability, but usage
892
- rows report `0`; the authoritative rounding adjustment is the settlement batch
893
- field `rounding_delta_minor`.
907
+ rows report `0`. If a batch-level `rounding_delta_minor` appears in historical
908
+ or internal records, do not add it to buyer debit and do not allocate it to
909
+ provider revenue.
894
910
 
895
911
  Micro / Nano amount fields are decimal minor-unit strings. In JavaScript, do
896
912
  not aggregate them with `number`; parse them with a decimal library. In Python,
@@ -942,14 +958,17 @@ Returns the prepared-transaction payload object.
942
958
  Returns the bare HMAC-SHA256 hex digest over `"<timestamp>.<body>"`. This is the
943
959
  primitive `buildWebhookSignatureHeader` / `verifyWebhookSignature` use. In
944
960
  TypeScript `options` is `{ timestamp: number }`; in Python `timestamp` is a
945
- keyword-only `int`. `body` may be raw bytes, a string, or a JSON object.
961
+ keyword-only `int`. `body` may be raw bytes, a string, or a JSON object when you
962
+ are building a test signature. Production webhook verification must use the
963
+ exact raw request body.
946
964
 
947
965
  ### `buildWebhookSignatureHeader(secret, body, options)` / `build_webhook_signature_header(secret, body, *, timestamp=None)`
948
966
 
949
967
  Returns a `t=<timestamp>,v1=<signature>` header string. Mainly for tests /
950
968
  mocking inbound webhooks. In TypeScript `options` is an optional
951
969
  `{ timestamp?: number }` (defaults to now); in Python `timestamp` is a
952
- keyword-only optional `int`.
970
+ keyword-only optional `int`. This helper accepts JSON objects for tests; the
971
+ verification helpers below do not.
953
972
 
954
973
  ### `verifyWebhookSignature(secret, body, signature_header, options)` / `verify_webhook_signature(secret, body, signature_header, *, tolerance_seconds=300, now=None)`
955
974
 
@@ -958,7 +977,9 @@ Verifies the `Siglume-Signature` header against the raw `body`. Throws
958
977
  the timestamp is outside tolerance or the signature does not match. In TypeScript
959
978
  `options` is `{ tolerance_seconds?, now? }`; in Python those are keyword-only
960
979
  (`tolerance_seconds` defaults to `DEFAULT_WEBHOOK_TOLERANCE_SECONDS` = 300).
961
- Returns `{ timestamp, signature }`.
980
+ Returns `{ timestamp, signature }`. Pass the exact raw request body bytes or raw
981
+ body string captured by your web framework. Passing a parsed JSON object is
982
+ rejected because re-stringifying changes the signed bytes.
962
983
 
963
984
  ### `parseDirectRequestPaymentWebhookEvent(payload)` / `parse_direct_request_payment_webhook_event(payload)`
964
985
 
@@ -1021,7 +1042,8 @@ return `kind: "unknown"` with a machine-readable `reason`.
1021
1042
 
1022
1043
  Verifies the signature and parses the event in one call. Returns
1023
1044
  `{ event, verification }` (TS) / `{"event": ..., "verification": ...}` (Py). Same
1024
- options shape as `verifyWebhookSignature` (keyword-only in Python).
1045
+ options shape as `verifyWebhookSignature` (keyword-only in Python). The `body`
1046
+ argument is raw bytes or a raw body string only; do not pass parsed JSON.
1025
1047
 
1026
1048
  Webhook-verification trio (typical inbound webhook handler):
1027
1049
 
@@ -1050,6 +1072,45 @@ event = verified["event"]
1050
1072
  # or equivalent fail-closed field checks before marking an order paid or fulfilled.
1051
1073
  ```
1052
1074
 
1075
+ Express example:
1076
+
1077
+ ```ts
1078
+ app.post("/siglume/webhook", express.raw({ type: "application/json" }), async (req, res) => {
1079
+ const { event } = await verifyDirectRequestPaymentWebhook(
1080
+ process.env.SIGLUME_WEBHOOK_SECRET!,
1081
+ req.body,
1082
+ req.header("siglume-signature") ?? "",
1083
+ );
1084
+ res.json({ received: event.id });
1085
+ });
1086
+ ```
1087
+
1088
+ FastAPI example:
1089
+
1090
+ ```py
1091
+ @app.post("/siglume/webhook")
1092
+ async def siglume_webhook(request: Request):
1093
+ raw_body = await request.body()
1094
+ verified = verify_direct_request_payment_webhook(
1095
+ os.environ["SIGLUME_WEBHOOK_SECRET"],
1096
+ raw_body,
1097
+ request.headers.get("siglume-signature", ""),
1098
+ )
1099
+ return {"received": verified["event"]["id"]}
1100
+ ```
1101
+
1102
+ Django example:
1103
+
1104
+ ```py
1105
+ def siglume_webhook(request):
1106
+ verified = verify_direct_request_payment_webhook(
1107
+ os.environ["SIGLUME_WEBHOOK_SECRET"],
1108
+ request.body,
1109
+ request.headers.get("Siglume-Signature", ""),
1110
+ )
1111
+ return JsonResponse({"received": verified["event"]["id"]})
1112
+ ```
1113
+
1053
1114
  ## Exported Constants
1054
1115
 
1055
1116
  Both packages export these importable constants:
@@ -91,38 +91,34 @@ open period. It can report `wallet_balance_checked: false` or
91
91
  `allowance_checked: false`; in that case it is guidance, not a final on-chain
92
92
  guarantee.
93
93
 
94
- ## Amount Rounding
94
+ ## Seller-borne Micro / Nano Amounts
95
95
 
96
96
  Micro / Nano usage rows keep provider price and protocol fee values as decimal
97
- minor-unit amounts. This allows Nano fees such as about JPY 0.2 per SDRP Tx to
98
- be accounted without rounding every accepted payment.
97
+ minor-unit amounts. This allows Nano fees such as JPY 0.2 per SDRP Tx to be
98
+ accounted without rounding every accepted payment.
99
99
 
100
- Rounding happens once when a settlement batch is created:
100
+ The buyer is charged only the provider-visible usage amount. Micro / Nano
101
+ protocol fees are seller-borne and are deducted from provider receivable:
101
102
 
102
103
  ```text
103
- provider_usage_amount_minor = sum(provider price minor units for accepted metered rows)
104
+ provider_gross_amount_minor = sum(provider price minor units for accepted metered rows)
105
+ provider_usage_amount_minor = provider_gross_amount_minor # legacy alias
106
+ gross_buyer_debit_minor = provider_gross_amount_minor # legacy alias
107
+ buyer_debit_minor = provider_gross_amount_minor
104
108
  protocol_fee_minor = sum(Micro/Nano fixed protocol fee minor units for accepted metered rows)
105
- provider_receivable_minor = max(provider_usage_amount_minor - protocol_fee_minor, 0)
106
- gross_buyer_debit_minor = provider_usage_amount_minor
107
- buyer_debit_minor = ceil(gross_buyer_debit_minor)
108
- rounding_delta_minor = buyer_debit_minor - gross_buyer_debit_minor
109
+ provider_receivable_minor = provider_gross_amount_minor - protocol_fee_minor
110
+ rounding_delta_minor = 0 for buyer/provider accounting
109
111
  ```
110
112
 
111
- For low-count Nano batches, the ceiling can make the effective rounded debit per
112
- SDRP Tx higher than the decimal provider usage amount. Here, `Tx` means one
113
- accepted SDRP payment, not an on-chain settlement transaction. The protocol fee
114
- remains the decimal statement amount and is deducted from provider receivable;
115
- the extra integer-minor-unit adjustment is recorded as `rounding_delta_minor` on
116
- the settlement batch. Each settlement batch can add a positive rounding
117
- adjustment of less than 1 token minor unit; if a buyer uses many providers /
118
- payees in one period, that adjustment can occur once per settlement batch.
119
-
120
- `rounding_delta_minor` belongs to the buyer debit and Siglume's rounding
121
- adjustment accounting for that batch. It is not provider revenue.
122
- `protocol_fee_minor` is provider-borne and is not added to the buyer debit.
123
- Provider reports should use `provider_receivable_minor`,
124
- `settled_provider_receivable_minor`, `unsettled_provider_receivable_minor`, and
125
- `past_due_provider_receivable_minor`.
113
+ Example: a JPY 100 Micro usage event has `buyer_debit_minor = 100`,
114
+ `protocol_fee_minor = 2`, and `provider_receivable_minor = 98`.
115
+
116
+ The `rounding_delta_minor` field remains in some statement schemas for
117
+ compatibility. It is not added to `buyer_debit_minor`, not added to
118
+ `provider_gross_amount_minor`, and not deducted again from
119
+ `provider_receivable_minor`. If non-zero in a historical or internal record,
120
+ treat it as a Siglume platform accounting adjustment, not buyer debit or
121
+ provider revenue.
126
122
 
127
123
  Micro / Nano amount fields are decimal minor-unit strings. JavaScript
128
124
  integrations should aggregate them with a decimal library, not `number`. Python
@@ -149,7 +145,9 @@ Buyer usage event amount fields:
149
145
 
150
146
  - `provider_usage_amount_minor`: provider price for the usage event
151
147
  - `protocol_fee_minor`: provider-borne metered protocol fee
152
- - `gross_buyer_debit_minor`: provider usage amount before integer-token rounding
148
+ - `provider_gross_amount_minor`: provider price before protocol fee
149
+ - `gross_buyer_debit_minor`: legacy alias of `provider_gross_amount_minor`
150
+ - `buyer_debit_minor`: buyer debit; equals `provider_gross_amount_minor`
153
151
  - `expected_scheduled_debit_at`: derived schedule for an open period before a
154
152
  settlement batch exists
155
153
 
@@ -175,8 +173,10 @@ Buyer batch amount fields:
175
173
 
176
174
  - `estimated_buyer_debit_minor`: total buyer debit for the batch
177
175
  - `provider_usage_amount_minor`: provider usage amount before protocol fee
178
- - `gross_buyer_debit_minor`: provider usage amount before integer-token rounding
176
+ - `provider_gross_amount_minor`: provider gross before protocol fee
177
+ - `gross_buyer_debit_minor`: legacy alias of `provider_gross_amount_minor`
179
178
  - `buyer_debit_minor`: amount scheduled for the debit transaction
179
+ - `provider_receivable_minor`: provider gross minus provider-borne protocol fee
180
180
 
181
181
  Past-due batches include:
182
182
 
@@ -190,6 +190,18 @@ Buyer-triggered requeue is not part of the MVP. The buyer-facing UI should show
190
190
  the block reason, tell the buyer to repair balance / allowance / BudgetVault /
191
191
  caps, and point them to support with `support_reference`.
192
192
 
193
+ Threshold-control fields:
194
+
195
+ - `settlement_trigger`: `amount_threshold` or `scheduled_close`
196
+ - `settlement_threshold_minor`: JPY `10000` or USD `10000` minor units
197
+ - `threshold_reached_at`: set when the fixed amount threshold closed the batch
198
+ - `total_unsettled_exposure_minor`: open plus `notice_pending`, `ready`,
199
+ `submitted`, retrying, and `past_due` provider gross exposure for the same
200
+ buyer / provider / token / pricing band
201
+
202
+ JPY 10,000 and USD 100.00 are market-specific fixed thresholds, not FX
203
+ conversions of one another.
204
+
193
205
  ## Provider Statement APIs
194
206
 
195
207
  ### Summary
@@ -301,6 +313,10 @@ Important batch fields:
301
313
  | `status` | Batch lifecycle state such as `notice_pending`, `ready`, `submitted`, `settled`, `failed`, `past_due`, or `notice_delivery_failed` |
302
314
  | `notice_status` | Final debit notice delivery status |
303
315
  | `period_start`, `period_end`, `close_at` | Statement period boundaries |
316
+ | `settlement_trigger` | `amount_threshold` for early threshold close, or `scheduled_close` for weekly/monthly close |
317
+ | `settlement_threshold_minor` | Fixed market threshold for early settlement: JPY `10000` or USD `10000` minor units |
318
+ | `threshold_reached_at` | Timestamp when the fixed threshold closed the batch, otherwise null |
319
+ | `total_unsettled_exposure_minor` | Current open plus notice/ready/submitted/retrying/past-due provider gross exposure for the same buyer / provider / token / pricing band |
304
320
  | `expected_scheduled_debit_at` | Expected debit time for an open period before a batch exists |
305
321
  | `scheduled_debit_at` | Scheduled debit time after batch creation |
306
322
  | `not_before_attempt_at` | Earliest allowed debit attempt; this is the close-plus-3-day gate |
@@ -308,14 +324,15 @@ Important batch fields:
308
324
  | `latest_execution_attempt_status` | Latest non-sensitive execution attempt status |
309
325
  | `chain_receipt_id` | On-chain receipt id when available |
310
326
  | `usage_event_digest` | Digest of usage rows included in the batch |
327
+ | `provider_gross_amount_minor` | Provider gross before provider-borne protocol fee |
311
328
  | `provider_usage_amount_minor` | Provider usage amount before protocol fee |
312
329
  | `provider_receivable_minor` | Provider amount for the batch after provider-borne protocol fee |
313
330
  | `settled_provider_receivable_minor` | Provider receivable that is settled on-chain |
314
331
  | `unsettled_provider_receivable_minor` | Provider receivable not yet settled |
315
332
  | `past_due_provider_receivable_minor` | Provider receivable blocked on past-due settlement |
316
- | `gross_buyer_debit_minor` | Provider usage amount before integer-token rounding |
333
+ | `gross_buyer_debit_minor` | Legacy alias of provider gross; protocol fee is not added |
317
334
  | `protocol_fee_minor` | Micro / Nano protocol fee deducted from provider receivable |
318
- | `buyer_debit_minor` | Amount scheduled for the buyer debit |
335
+ | `buyer_debit_minor` | Amount scheduled for the buyer debit; equals provider gross |
319
336
  | `attempt_count`, `next_attempt_at` | Retry state |
320
337
  | `failure_reason_code`, `failure_reason_label`, `failure_reason_help` | Sanitized public failure reason |
321
338
  | `support_reference` | Non-secret support reference |
@@ -334,14 +351,14 @@ curl https://siglume.com/v1/sdrp/metered/provider/settlement-batches/<batch-id>/
334
351
  The CSV contains exactly these columns:
335
352
 
336
353
  ```text
337
- metered_usage_id,created_at,plan_type,settlement_cadence,period_start,period_end,listing_id,capability_key,operation_key,currency,token_symbol,provider_usage_amount_minor,provider_receivable_minor,protocol_fee_minor,gross_buyer_debit_minor,rounding_delta_minor,buyer_debit_minor,status,settlement_batch_id,buyer_period_ref
354
+ metered_usage_id,created_at,plan_type,settlement_cadence,period_start,period_end,listing_id,capability_key,operation_key,currency,token_symbol,provider_gross_amount_minor,provider_usage_amount_minor,provider_receivable_minor,protocol_fee_minor,gross_buyer_debit_minor,rounding_delta_minor,buyer_debit_minor,status,settlement_batch_id,buyer_period_ref
338
355
  ```
339
356
 
340
357
  The CSV uses `buyer_period_ref`, not `buyer_user_id`.
341
358
  `rounding_delta_minor` is present for a stable usage-event schema, but per-row
342
- values are `0`. The authoritative rounding adjustment is the settlement batch
343
- `rounding_delta_minor`; do not allocate that adjustment to provider revenue
344
- from individual CSV rows.
359
+ values are `0`. If a batch-level `rounding_delta_minor` appears in historical or
360
+ internal records, do not add it to buyer debit and do not allocate it to provider
361
+ revenue.
345
362
 
346
363
  ## Notifications
347
364
 
@@ -375,9 +392,10 @@ Siglume retries failed Micro / Nano settlement every 6 hours for up to 28
375
392
  automatic attempts. After that the batch remains `past_due` until operator
376
393
  requeue.
377
394
 
378
- New Micro / Nano usage for the same buyer, plan type, and token is paused while
379
- the past-due block remains. The provider API is not called for the rejected
380
- request, and the request is not charged.
395
+ New Micro / Nano usage for the same buyer / provider / token is paused while
396
+ the total unsettled exposure is at or above the fixed threshold, and while a
397
+ failed or past-due block remains. The provider API is not called for the
398
+ rejected request, and the request is not charged.
381
399
 
382
400
  Public failure fields are sanitized. Show `failure_reason_code`,
383
401
  `failure_reason_label`, `failure_reason_help`, and `support_reference` to users
package/docs/pricing.md CHANGED
@@ -34,8 +34,8 @@ charging.
34
34
  | Public one-time payment amount | Applied automatically | What you select | Fee | Settlement |
35
35
  | --- | --- | --- | --- | --- |
36
36
  | JPY 501+ / USD 3.01+ | Standard Payment | Select one Standard plan: Launch, Starter, Growth, or Pro | Launch: JPY 0 / USD 0 monthly, 1.8%; Starter: JPY 980 / USD 6 monthly, 1.0%; Growth: JPY 2,980 / USD 18 monthly, 0.7%; Pro: JPY 9,800 / USD 60 monthly, 0.5%. Minimum JPY 30 / USD 0.20 per payment. | Settled on-chain immediately after the payment confirms |
37
- | JPY 50-500 / USD 0.31-3.00 | Micro Payment | Applied automatically by amount | USD 0.01 / SDRP Tx, about JPY 2 | Aggregated and settled **weekly**, or earlier once the buyer/payee batch reaches JPY 10,000 / USD 100.00 (see [Settlement schedule](#settlement-schedule)) |
38
- | JPY 1-49 / USD 0.01-0.30 | Nano Payment | Applied automatically by amount | USD 0.001 / SDRP Tx, about JPY 0.2 | Aggregated and settled **monthly**, or earlier once the buyer/payee batch reaches JPY 10,000 / USD 100.00 (see [Settlement schedule](#settlement-schedule)) |
37
+ | JPY 50-500 / USD 0.31-3.00 | Micro Payment | Applied automatically by amount | JPY 2 / USD 0.01 per SDRP Tx | Aggregated and settled **weekly**, or earlier once the buyer/payee batch reaches JPY 10,000 / USD 100.00 (see [Settlement schedule](#settlement-schedule)) |
38
+ | JPY 1-49 / USD 0.01-0.30 | Nano Payment | Applied automatically by amount | JPY 0.2 / USD 0.001 per SDRP Tx | Aggregated and settled **monthly**, or earlier once the buyer/payee batch reaches JPY 10,000 / USD 100.00 (see [Settlement schedule](#settlement-schedule)) |
39
39
 
40
40
  In this table, `Tx` means one accepted SDRP payment, not an on-chain settlement
41
41
  transaction. Micro / Nano settlement batches are aggregated on-chain after the
@@ -105,7 +105,9 @@ confirmed payment turns into money in your settlement wallet.
105
105
  spread settlement load.
106
106
  - **Early threshold settlement.** If a buyer/payee/token batch reaches JPY
107
107
  10,000 or USD 100.00 before the weekly close, Siglume can close that batch
108
- early and start the same final-notice and settlement flow.
108
+ early and start the same final-notice and settlement flow. JPY 10,000 and USD
109
+ 100.00 are market-specific fixed thresholds, not FX conversions of one
110
+ another.
109
111
  - **Timezone.** Period boundaries are evaluated in the buyer's configured
110
112
  settlement timezone, defaulting to UTC. Assigned slots are persisted and are
111
113
  not recalculated on the fly.
@@ -125,7 +127,9 @@ confirmed payment turns into money in your settlement wallet.
125
127
  spread settlement load.
126
128
  - **Early threshold settlement.** If a buyer/payee/token batch reaches JPY
127
129
  10,000 or USD 100.00 before the monthly close, Siglume can close that batch
128
- early and start the same final-notice and settlement flow.
130
+ early and start the same final-notice and settlement flow. JPY 10,000 and USD
131
+ 100.00 are market-specific fixed thresholds, not FX conversions of one
132
+ another.
129
133
  - **Timezone.** As with Micro, period boundaries use the buyer's configured
130
134
  settlement timezone, defaulting to UTC. Assigned slots are persisted and are
131
135
  not recalculated on the fly.
@@ -147,9 +151,12 @@ confirmed payment turns into money in your settlement wallet.
147
151
  the affected batch is treated as past due. Siglume currently retries every 6
148
152
  hours for up to 28 automatic attempts. After that, the batch remains past due
149
153
  and requires manual resolution before another attempt.
150
- - While a buyer has an unresolved failed Micro/Nano settlement for the same
151
- payment band and token, new Micro/Nano usage is paused with the machine-readable
152
- error `METERED_SETTLEMENT_PAST_DUE`; the provider API is not called.
154
+ - While the same buyer / provider / token / pricing band has total unsettled
155
+ exposure at or above the fixed threshold, new Micro/Nano usage is paused with the
156
+ machine-readable error `METERED_SETTLEMENT_PAST_DUE`; the provider API is not
157
+ called. Exposure includes open usage plus `notice_pending`, `ready`,
158
+ `submitted`, retrying, and `past_due` batches, and remains paused while
159
+ settlement failure or `past_due` is unresolved.
153
160
  - Outstanding amounts remain attached to the failed settlement and are retried
154
161
  under this policy. They are not settled revenue, and Siglume does not advance,
155
162
  guarantee, or insure provider revenue before on-chain settlement succeeds.
@@ -160,7 +167,7 @@ confirmed payment turns into money in your settlement wallet.
160
167
 
161
168
  Micro and Nano run a budget check before the buyer's paid request is fulfilled:
162
169
 
163
- - A buyer's wallet budget reservation is consumed at the **gross buyer debit
170
+ - A buyer's wallet budget reservation is consumed at the **provider gross
164
171
  amount** (your usage price, before any provider-borne protocol fee) from
165
172
  acceptance until settlement confirms. This
166
173
  is a reservation against Siglume spending limits; it does not lock, escrow,
@@ -178,51 +185,43 @@ Micro and Nano run a budget check before the buyer's paid request is fulfilled:
178
185
  ### What is fixed vs platform-managed
179
186
 
180
187
  The cadence fields are fixed: **Micro is weekly, Nano is monthly**. In both
181
- bands, Siglume can close a buyer/payee/token batch early once it reaches JPY
182
- 10,000 or USD 100.00. A payment is final only after its on-chain settlement
183
- confirms. Micro and Nano are automatic amount bands, not customer-selected
184
- options. The account-assigned period boundaries, roughly 3-day pre-debit notice
185
- window, early settlement threshold, and current retry policy above are the
186
- public behavior as of 2026-06-19. Treat the platform's statement status,
187
- `not_before_attempt_at`, Standard `fee_bps`, and Micro / Nano statement amount
188
- fields as authoritative rather than hard-coding local revenue recognition.
189
-
190
- ## Micro / Nano Amount Rounding
188
+ bands, Siglume can close a buyer / provider / token / pricing-band batch early
189
+ once provider gross reaches JPY 10,000 or USD 100.00. These are fixed
190
+ market-specific thresholds, not FX conversions of one another. A payment is
191
+ final only after its on-chain settlement confirms. Micro and Nano are automatic
192
+ amount bands, not customer-selected options. The account-assigned period
193
+ boundaries, roughly 3-day pre-debit notice window, early settlement threshold,
194
+ and current retry policy above are the public behavior as of 2026-06-19. Treat
195
+ the platform's statement status, `not_before_attempt_at`, Standard `fee_bps`,
196
+ and Micro / Nano statement amount fields as authoritative rather than
197
+ hard-coding local revenue recognition.
198
+
199
+ ## Micro / Nano Seller-borne Amounts
191
200
 
192
201
  Micro / Nano fees are stored internally as decimal minor-unit values so
193
- sub-yen and sub-cent Nano fees are not silently rounded per accepted SDRP Tx. The
194
- current settlement rule is:
202
+ sub-yen and sub-cent Nano fees are not silently rounded per accepted SDRP Tx.
203
+ The buyer is charged only the provider-visible usage amount; the protocol fee is
204
+ not added to the buyer debit:
195
205
 
196
206
  ```text
197
- provider_usage_amount_minor = sum(provider price minor units for accepted metered rows)
207
+ provider_gross_amount_minor = sum(provider price minor units for accepted metered rows)
208
+ provider_usage_amount_minor = provider_gross_amount_minor # legacy alias
209
+ gross_buyer_debit_minor = provider_gross_amount_minor # legacy alias
210
+ buyer_debit_minor = provider_gross_amount_minor
198
211
  protocol_fee_minor = sum(Micro/Nano fixed protocol fee minor units for accepted metered rows)
199
- provider_receivable_minor = max(provider_usage_amount_minor - protocol_fee_minor, 0)
200
- gross_buyer_debit_minor = provider_usage_amount_minor
201
- buyer_debit_minor = ceil(gross_buyer_debit_minor)
202
- rounding_delta_minor = buyer_debit_minor - gross_buyer_debit_minor
212
+ provider_receivable_minor = provider_gross_amount_minor - protocol_fee_minor
213
+ rounding_delta_minor = 0 for buyer/provider accounting
203
214
  ```
204
215
 
205
- Rounding happens once when the settlement batch is created, not per accepted
206
- SDRP Tx.
207
- The rounding mode is ceiling to the next integer token minor unit because
208
- on-chain settlement cannot debit fractional JPYC/USDC minor units. The positive
209
- `rounding_delta_minor` is part of the buyer debit for that batch and is retained
210
- as a rounding adjustment in Siglume's settlement accounting; it is not provider
211
- revenue. `protocol_fee_minor` is provider-borne and is deducted from provider
212
- receivable, not added to the buyer debit. Providers should reconcile their
213
- revenue with
214
- `provider_receivable_minor`, `settled_provider_receivable_minor`,
215
- `unsettled_provider_receivable_minor`, and
216
- `past_due_provider_receivable_minor`, not with `buyer_debit_minor`.
217
-
218
- For low-count Nano batches, the integer ceiling can make the effective buyer
219
- rounded debit per SDRP Tx higher than the decimal provider usage amount. The
220
- decimal protocol fee remains visible as `protocol_fee_minor` and is deducted
221
- from provider receivable; the difference created by integer-token settlement is
222
- visible as `rounding_delta_minor` on the batch. Each settlement batch can add a
223
- positive rounding adjustment of less than 1 token minor unit. If a buyer uses
224
- many providers / payees in one period, that adjustment can occur once per
225
- settlement batch. JavaScript integrations should not sum Micro / Nano minor
216
+ Example: a JPY 100 Micro usage event has buyer debit JPY 100, protocol fee JPY
217
+ 2, and provider receivable JPY 98.
218
+
219
+ The `rounding_delta_minor` field is retained in some schemas for compatibility.
220
+ It is not added to `buyer_debit_minor`, not added to
221
+ `provider_gross_amount_minor`, and not deducted again from
222
+ `provider_receivable_minor`. If non-zero in a historical or internal record,
223
+ treat it as a Siglume platform accounting adjustment, not buyer debit or
224
+ provider revenue. JavaScript integrations should not sum Micro / Nano minor
226
225
  amounts with `number`; use a decimal library. Python integrations should use
227
226
  `Decimal`.
228
227
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siglume/direct-request-payment",
3
- "version": "0.4.13",
3
+ "version": "0.4.15",
4
4
  "description": "SDK for the Siglume Direct Request Payment SDRP payment protocol",
5
5
  "keywords": [
6
6
  "siglume",