@fantastic.dev/better-stripe 0.68.1 → 0.70.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.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/client/usage/subscriptionCheckout.d.ts.map +1 -1
- package/dist/client/usage/subscriptionCheckout.js +2 -0
- package/dist/client/usage/subscriptionCheckout.js.map +1 -1
- package/dist/react/workflows/Products.d.ts +2 -2
- package/dist/react/workflows/Products.d.ts.map +1 -1
- package/dist/react/workflows/Products.js +8 -4
- package/dist/react/workflows/Products.js.map +1 -1
- package/dist/react/workflows/UsageSummary.d.ts.map +1 -1
- package/dist/react/workflows/UsageSummary.js +4 -1
- package/dist/react/workflows/UsageSummary.js.map +1 -1
- package/docs/evidence/native-metering/product-flows-2026-10-19.json +553 -0
- package/docs/metered-usage.md +1 -1
- package/docs/metering-setup.md +36 -26
- package/docs/react-workflows.md +35 -0
- package/docs/usage-example.md +159 -244
- package/docs/usage-protocol-diagnostics.md +251 -0
- package/docs/usage-verification.md +31 -0
- package/package.json +1 -1
- package/src/client/usage/subscriptionCheckout.test.ts +13 -0
- package/src/client/usage/subscriptionCheckout.ts +2 -0
- package/src/react/workflows/Products.test.tsx +194 -2
- package/src/react/workflows/Products.tsx +53 -43
- package/src/react/workflows/Usage.test.tsx +15 -0
- package/src/react/workflows/UsageSummary.tsx +5 -2
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "product-metered-example-native-test-mode",
|
|
3
|
+
"date": "2026-10-19",
|
|
4
|
+
"ticket": "BTS-284",
|
|
5
|
+
"livemode": false,
|
|
6
|
+
"method": "Public host adapter actions backed by the compiled BetterStripe package, plus actual browser actions with Stripe synthetic test cards. Retained IDs are test resources, not credentials.",
|
|
7
|
+
"included_overage": {
|
|
8
|
+
"snapshot": {
|
|
9
|
+
"summary": {
|
|
10
|
+
"status": "available",
|
|
11
|
+
"observedAt": 1792399339,
|
|
12
|
+
"value": {
|
|
13
|
+
"period": {
|
|
14
|
+
"end": 1795077380,
|
|
15
|
+
"start": 1792398980
|
|
16
|
+
},
|
|
17
|
+
"observedAt": 1792399322,
|
|
18
|
+
"complete": true,
|
|
19
|
+
"eventCount": 1,
|
|
20
|
+
"groups": [
|
|
21
|
+
{
|
|
22
|
+
"binding": {
|
|
23
|
+
"stripeCustomerId": "cus_VQz6jBP5zWlyWS",
|
|
24
|
+
"stripePriceId": "price_1USBuv6JR7kThJogV6whMAi1",
|
|
25
|
+
"eventName": "bs_ms7b7j76syc0fyd0qtes5k80eh8gks2f_product_usage_v1",
|
|
26
|
+
"apiVersion": "2026-09-30.endive",
|
|
27
|
+
"plan": {
|
|
28
|
+
"key": "demo_ms7b7j76syc0fyd0qtes5k80eh8gks2f_coaching-minutes",
|
|
29
|
+
"version": "v1",
|
|
30
|
+
"unit": {
|
|
31
|
+
"name": "minute",
|
|
32
|
+
"precision": 0
|
|
33
|
+
},
|
|
34
|
+
"rate": {
|
|
35
|
+
"currency": "usd",
|
|
36
|
+
"unitAmountDecimal": "100"
|
|
37
|
+
},
|
|
38
|
+
"model": "included_overage",
|
|
39
|
+
"includedQuantity": "60",
|
|
40
|
+
"reset": "billing_period"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"subscription": {
|
|
44
|
+
"subscriptionId": "sub_1USC3O6JR7kThJogep66wAiF",
|
|
45
|
+
"subscriptionItemId": "si_VT8KdSgYvRPsno",
|
|
46
|
+
"stripePriceId": "price_1USBuv6JR7kThJogV6whMAi1",
|
|
47
|
+
"period": {
|
|
48
|
+
"start": 1792398980,
|
|
49
|
+
"end": 1795077380
|
|
50
|
+
},
|
|
51
|
+
"interval": "month"
|
|
52
|
+
},
|
|
53
|
+
"acceptedScaledQuantity": "75",
|
|
54
|
+
"providerAcceptedScaledQuantity": "75",
|
|
55
|
+
"acceptedQuantity": "75",
|
|
56
|
+
"canceledQuantity": "0",
|
|
57
|
+
"effectiveQuantity": "75",
|
|
58
|
+
"effectiveScaledQuantity": "75",
|
|
59
|
+
"providerAcceptedQuantity": "75",
|
|
60
|
+
"eventCount": 1,
|
|
61
|
+
"validationErrorEventCount": 0,
|
|
62
|
+
"deliveryQuantities": {
|
|
63
|
+
"canceled": "0",
|
|
64
|
+
"queued": "0",
|
|
65
|
+
"sending": "0",
|
|
66
|
+
"provider_accepted": "75",
|
|
67
|
+
"rejected": "0",
|
|
68
|
+
"unknown": "0",
|
|
69
|
+
"held": "0"
|
|
70
|
+
},
|
|
71
|
+
"included": {
|
|
72
|
+
"status": "available",
|
|
73
|
+
"observedAt": 1792399322,
|
|
74
|
+
"value": {
|
|
75
|
+
"included": "60",
|
|
76
|
+
"consumed": "75",
|
|
77
|
+
"remaining": "0",
|
|
78
|
+
"overage": "15"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"estimate": {
|
|
82
|
+
"status": "available",
|
|
83
|
+
"observedAt": 1792399322,
|
|
84
|
+
"value": {
|
|
85
|
+
"amountDecimal": "1500",
|
|
86
|
+
"currency": "usd"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"credits": {
|
|
90
|
+
"status": "unavailable",
|
|
91
|
+
"reason": "not_prepaid_model",
|
|
92
|
+
"retryable": false
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"provider": {
|
|
99
|
+
"status": "unsupported",
|
|
100
|
+
"reason": "minute_alignment_required",
|
|
101
|
+
"retryable": false
|
|
102
|
+
},
|
|
103
|
+
"allowance": {
|
|
104
|
+
"status": "available",
|
|
105
|
+
"observedAt": 1792399339,
|
|
106
|
+
"value": {
|
|
107
|
+
"revision": 1,
|
|
108
|
+
"observedAt": 1792399322,
|
|
109
|
+
"period": {
|
|
110
|
+
"start": 1792398980,
|
|
111
|
+
"end": 1795077380
|
|
112
|
+
},
|
|
113
|
+
"accepting": true,
|
|
114
|
+
"policy": {
|
|
115
|
+
"reset": "billing_period",
|
|
116
|
+
"rollover": "none",
|
|
117
|
+
"entitled": true,
|
|
118
|
+
"overage": "allow",
|
|
119
|
+
"limit": {
|
|
120
|
+
"mode": "none"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"consumedQuantity": "75",
|
|
124
|
+
"reservedQuantity": "0",
|
|
125
|
+
"includedQuantity": "60",
|
|
126
|
+
"remainingIncludedQuantity": "0",
|
|
127
|
+
"billableOverageQuantity": "15",
|
|
128
|
+
"softLimitReached": false,
|
|
129
|
+
"hardLimitRemainingQuantity": null,
|
|
130
|
+
"committedEstimate": {
|
|
131
|
+
"amountDecimal": "1500",
|
|
132
|
+
"currency": "usd"
|
|
133
|
+
},
|
|
134
|
+
"projectedEstimate": {
|
|
135
|
+
"amountDecimal": "1500",
|
|
136
|
+
"currency": "usd"
|
|
137
|
+
},
|
|
138
|
+
"cashCollection": "none"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"draftInvoice": {
|
|
143
|
+
"status": "available",
|
|
144
|
+
"observedAt": 1792399620,
|
|
145
|
+
"value": {
|
|
146
|
+
"kind": "preview",
|
|
147
|
+
"invoiceId": "upcoming_in_1USCDh6JR7kThJogeQSM3lb9",
|
|
148
|
+
"status": "draft",
|
|
149
|
+
"finalized": false,
|
|
150
|
+
"amountDue": "3500",
|
|
151
|
+
"amountPaid": "0",
|
|
152
|
+
"total": "3500",
|
|
153
|
+
"currency": "usd",
|
|
154
|
+
"linesComplete": true,
|
|
155
|
+
"lines": [
|
|
156
|
+
{
|
|
157
|
+
"lineId": "il_tmp_1UdQpM6JR7kThJog44zlqj8J",
|
|
158
|
+
"stripePriceId": "price_1USBuv6JR7kThJogV6whMAi1",
|
|
159
|
+
"subscriptionItemId": "si_VT8KdSgYvRPsno",
|
|
160
|
+
"amount": "0",
|
|
161
|
+
"currency": "usd",
|
|
162
|
+
"quantity": "60",
|
|
163
|
+
"providerQuantityDecimal": "60",
|
|
164
|
+
"unitAmountDecimal": "0",
|
|
165
|
+
"creditAppliedAmount": "0",
|
|
166
|
+
"nativePeriod": {
|
|
167
|
+
"start": 1792398960,
|
|
168
|
+
"end": 1795077360
|
|
169
|
+
},
|
|
170
|
+
"proration": false
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"lineId": "il_tmp_1UdQpN6JR7kThJog7GhXQIFU",
|
|
174
|
+
"stripePriceId": "price_1USBuv6JR7kThJogV6whMAi1",
|
|
175
|
+
"subscriptionItemId": "si_VT8KdSgYvRPsno",
|
|
176
|
+
"amount": "1500",
|
|
177
|
+
"currency": "usd",
|
|
178
|
+
"quantity": "15",
|
|
179
|
+
"providerQuantityDecimal": "15",
|
|
180
|
+
"unitAmountDecimal": "100",
|
|
181
|
+
"creditAppliedAmount": "0",
|
|
182
|
+
"nativePeriod": {
|
|
183
|
+
"start": 1792398960,
|
|
184
|
+
"end": 1795077360
|
|
185
|
+
},
|
|
186
|
+
"proration": false
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
"meterAmount": {
|
|
190
|
+
"status": "available",
|
|
191
|
+
"observedAt": 1792399620,
|
|
192
|
+
"value": {
|
|
193
|
+
"amount": "1500",
|
|
194
|
+
"currency": "usd"
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
"paymentEvidence": "not_resolved"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"pay_as_you_go": {
|
|
202
|
+
"snapshot": {
|
|
203
|
+
"summary": {
|
|
204
|
+
"status": "available",
|
|
205
|
+
"observedAt": 1792401070,
|
|
206
|
+
"value": {
|
|
207
|
+
"period": {
|
|
208
|
+
"end": 1795079307,
|
|
209
|
+
"start": 1792400907
|
|
210
|
+
},
|
|
211
|
+
"observedAt": 1792401070,
|
|
212
|
+
"complete": true,
|
|
213
|
+
"eventCount": 1,
|
|
214
|
+
"groups": [
|
|
215
|
+
{
|
|
216
|
+
"binding": {
|
|
217
|
+
"stripeCustomerId": "cus_VQz6jBP5zWlyWS",
|
|
218
|
+
"stripePriceId": "price_1USCW26JR7kThJogaEsW4mQ4",
|
|
219
|
+
"eventName": "bs_ms7d7x1q5f0sc6j39d7eyzx5yx8gkkgq_product_usage_v1",
|
|
220
|
+
"apiVersion": "2026-09-30.endive",
|
|
221
|
+
"plan": {
|
|
222
|
+
"key": "demo_ms7d7x1q5f0sc6j39d7eyzx5yx8gkkgq_coaching-minutes",
|
|
223
|
+
"version": "v1",
|
|
224
|
+
"unit": {
|
|
225
|
+
"name": "minute",
|
|
226
|
+
"precision": 0
|
|
227
|
+
},
|
|
228
|
+
"rate": {
|
|
229
|
+
"currency": "usd",
|
|
230
|
+
"unitAmountDecimal": "100"
|
|
231
|
+
},
|
|
232
|
+
"model": "pay_as_you_go"
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
"subscription": {
|
|
236
|
+
"subscriptionId": "sub_1USCYT6JR7kThJogAVHowKNq",
|
|
237
|
+
"subscriptionItemId": "si_VT8qEOi3dr7ejz",
|
|
238
|
+
"stripePriceId": "price_1USCW26JR7kThJogaEsW4mQ4",
|
|
239
|
+
"period": {
|
|
240
|
+
"start": 1792400907,
|
|
241
|
+
"end": 1795079307
|
|
242
|
+
},
|
|
243
|
+
"interval": "month"
|
|
244
|
+
},
|
|
245
|
+
"acceptedScaledQuantity": "5",
|
|
246
|
+
"providerAcceptedScaledQuantity": "5",
|
|
247
|
+
"acceptedQuantity": "5",
|
|
248
|
+
"canceledQuantity": "0",
|
|
249
|
+
"effectiveQuantity": "5",
|
|
250
|
+
"effectiveScaledQuantity": "5",
|
|
251
|
+
"providerAcceptedQuantity": "5",
|
|
252
|
+
"eventCount": 1,
|
|
253
|
+
"validationErrorEventCount": 0,
|
|
254
|
+
"deliveryQuantities": {
|
|
255
|
+
"canceled": "0",
|
|
256
|
+
"queued": "0",
|
|
257
|
+
"sending": "0",
|
|
258
|
+
"provider_accepted": "5",
|
|
259
|
+
"rejected": "0",
|
|
260
|
+
"unknown": "0",
|
|
261
|
+
"held": "0"
|
|
262
|
+
},
|
|
263
|
+
"included": {
|
|
264
|
+
"status": "unavailable",
|
|
265
|
+
"reason": "not_included_model",
|
|
266
|
+
"retryable": false
|
|
267
|
+
},
|
|
268
|
+
"estimate": {
|
|
269
|
+
"status": "available",
|
|
270
|
+
"observedAt": 1792401070,
|
|
271
|
+
"value": {
|
|
272
|
+
"amountDecimal": "500",
|
|
273
|
+
"currency": "usd"
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
"credits": {
|
|
277
|
+
"status": "unavailable",
|
|
278
|
+
"reason": "not_prepaid_model",
|
|
279
|
+
"retryable": false
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
"provider": {
|
|
286
|
+
"status": "unsupported",
|
|
287
|
+
"reason": "minute_alignment_required",
|
|
288
|
+
"retryable": false
|
|
289
|
+
},
|
|
290
|
+
"allowance": {
|
|
291
|
+
"status": "available",
|
|
292
|
+
"observedAt": 1792401070,
|
|
293
|
+
"value": {
|
|
294
|
+
"revision": 1,
|
|
295
|
+
"observedAt": 1792401070,
|
|
296
|
+
"period": {
|
|
297
|
+
"start": 1792400907,
|
|
298
|
+
"end": 1795079307
|
|
299
|
+
},
|
|
300
|
+
"accepting": true,
|
|
301
|
+
"policy": {
|
|
302
|
+
"reset": "billing_period",
|
|
303
|
+
"rollover": "none",
|
|
304
|
+
"entitled": true,
|
|
305
|
+
"overage": "allow",
|
|
306
|
+
"limit": {
|
|
307
|
+
"mode": "none"
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
"consumedQuantity": "5",
|
|
311
|
+
"reservedQuantity": "0",
|
|
312
|
+
"includedQuantity": "0",
|
|
313
|
+
"remainingIncludedQuantity": "0",
|
|
314
|
+
"billableOverageQuantity": "5",
|
|
315
|
+
"softLimitReached": false,
|
|
316
|
+
"hardLimitRemainingQuantity": null,
|
|
317
|
+
"committedEstimate": {
|
|
318
|
+
"amountDecimal": "500",
|
|
319
|
+
"currency": "usd"
|
|
320
|
+
},
|
|
321
|
+
"projectedEstimate": {
|
|
322
|
+
"amountDecimal": "500",
|
|
323
|
+
"currency": "usd"
|
|
324
|
+
},
|
|
325
|
+
"cashCollection": "none"
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
"draftInvoice": {
|
|
330
|
+
"status": "available",
|
|
331
|
+
"observedAt": 1792401103,
|
|
332
|
+
"value": {
|
|
333
|
+
"kind": "preview",
|
|
334
|
+
"invoiceId": "upcoming_in_1USCbc6JR7kThJogAiHQO5yP",
|
|
335
|
+
"status": "draft",
|
|
336
|
+
"finalized": false,
|
|
337
|
+
"amountDue": "500",
|
|
338
|
+
"amountPaid": "0",
|
|
339
|
+
"total": "500",
|
|
340
|
+
"currency": "usd",
|
|
341
|
+
"linesComplete": true,
|
|
342
|
+
"lines": [
|
|
343
|
+
{
|
|
344
|
+
"lineId": "il_tmp_1UdRKR6JR7kThJogLvBYjTiq",
|
|
345
|
+
"stripePriceId": "price_1USCW26JR7kThJogaEsW4mQ4",
|
|
346
|
+
"subscriptionItemId": "si_VT8qEOi3dr7ejz",
|
|
347
|
+
"amount": "500",
|
|
348
|
+
"currency": "usd",
|
|
349
|
+
"quantity": "5",
|
|
350
|
+
"providerQuantityDecimal": "5",
|
|
351
|
+
"unitAmountDecimal": "100",
|
|
352
|
+
"creditAppliedAmount": "0",
|
|
353
|
+
"nativePeriod": {
|
|
354
|
+
"start": 1792400880,
|
|
355
|
+
"end": 1795079280
|
|
356
|
+
},
|
|
357
|
+
"proration": false
|
|
358
|
+
}
|
|
359
|
+
],
|
|
360
|
+
"meterAmount": {
|
|
361
|
+
"status": "available",
|
|
362
|
+
"observedAt": 1792401103,
|
|
363
|
+
"value": {
|
|
364
|
+
"amount": "500",
|
|
365
|
+
"currency": "usd"
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
"paymentEvidence": "not_resolved"
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
"prepaid": {
|
|
373
|
+
"snapshot": {
|
|
374
|
+
"summary": {
|
|
375
|
+
"status": "available",
|
|
376
|
+
"observedAt": 1792400668,
|
|
377
|
+
"value": {
|
|
378
|
+
"period": {
|
|
379
|
+
"end": 1795078860,
|
|
380
|
+
"start": 1792400460
|
|
381
|
+
},
|
|
382
|
+
"observedAt": 1792400668,
|
|
383
|
+
"complete": true,
|
|
384
|
+
"eventCount": 1,
|
|
385
|
+
"groups": [
|
|
386
|
+
{
|
|
387
|
+
"binding": {
|
|
388
|
+
"stripeCustomerId": "cus_VQz7dXpr24DfqB",
|
|
389
|
+
"stripePriceId": "price_1USCMU6JR7kThJogBWNtUi8l",
|
|
390
|
+
"eventName": "bs_ms7c2p22z5hrpev8mfds4efh3h8gk2a7_product_usage_v1",
|
|
391
|
+
"apiVersion": "2026-09-30.endive",
|
|
392
|
+
"plan": {
|
|
393
|
+
"key": "demo_ms7c2p22z5hrpev8mfds4efh3h8gk2a7_report-credits",
|
|
394
|
+
"version": "v1",
|
|
395
|
+
"unit": {
|
|
396
|
+
"name": "report",
|
|
397
|
+
"precision": 0
|
|
398
|
+
},
|
|
399
|
+
"rate": {
|
|
400
|
+
"currency": "usd",
|
|
401
|
+
"unitAmountDecimal": "100"
|
|
402
|
+
},
|
|
403
|
+
"model": "prepaid",
|
|
404
|
+
"insufficientBalance": "reject"
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
"subscription": {
|
|
408
|
+
"subscriptionId": "sub_1USCRE6JR7kThJogachZOokb",
|
|
409
|
+
"subscriptionItemId": "si_VT8iAGyjWDamzd",
|
|
410
|
+
"stripePriceId": "price_1USCMU6JR7kThJogBWNtUi8l",
|
|
411
|
+
"period": {
|
|
412
|
+
"start": 1792400460,
|
|
413
|
+
"end": 1795078860
|
|
414
|
+
},
|
|
415
|
+
"interval": "month"
|
|
416
|
+
},
|
|
417
|
+
"acceptedScaledQuantity": "10",
|
|
418
|
+
"providerAcceptedScaledQuantity": "10",
|
|
419
|
+
"acceptedQuantity": "10",
|
|
420
|
+
"canceledQuantity": "0",
|
|
421
|
+
"effectiveQuantity": "10",
|
|
422
|
+
"effectiveScaledQuantity": "10",
|
|
423
|
+
"providerAcceptedQuantity": "10",
|
|
424
|
+
"eventCount": 1,
|
|
425
|
+
"validationErrorEventCount": 0,
|
|
426
|
+
"deliveryQuantities": {
|
|
427
|
+
"canceled": "0",
|
|
428
|
+
"queued": "0",
|
|
429
|
+
"sending": "0",
|
|
430
|
+
"provider_accepted": "10",
|
|
431
|
+
"rejected": "0",
|
|
432
|
+
"unknown": "0",
|
|
433
|
+
"held": "0"
|
|
434
|
+
},
|
|
435
|
+
"included": {
|
|
436
|
+
"status": "unavailable",
|
|
437
|
+
"reason": "not_included_model",
|
|
438
|
+
"retryable": false
|
|
439
|
+
},
|
|
440
|
+
"estimate": {
|
|
441
|
+
"status": "unavailable",
|
|
442
|
+
"reason": "credit_balance_requires_scoped_reader",
|
|
443
|
+
"retryable": false
|
|
444
|
+
},
|
|
445
|
+
"credits": {
|
|
446
|
+
"status": "unavailable",
|
|
447
|
+
"reason": "credit_balance_requires_scoped_reader",
|
|
448
|
+
"retryable": false
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
"provider": {
|
|
455
|
+
"status": "unavailable",
|
|
456
|
+
"reason": "aggregation_pending",
|
|
457
|
+
"retryable": true
|
|
458
|
+
},
|
|
459
|
+
"credits": {
|
|
460
|
+
"status": "available",
|
|
461
|
+
"observedAt": 1792400668,
|
|
462
|
+
"value": {
|
|
463
|
+
"availableQuantity": "0",
|
|
464
|
+
"cashCollection": "none",
|
|
465
|
+
"consumedQuantity": "10",
|
|
466
|
+
"currency": "usd",
|
|
467
|
+
"expiredQuantity": "0",
|
|
468
|
+
"frozenQuantity": "0",
|
|
469
|
+
"precision": 0,
|
|
470
|
+
"reservedQuantity": "0",
|
|
471
|
+
"status": "available",
|
|
472
|
+
"unit": "report"
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
"draftInvoice": {
|
|
477
|
+
"status": "available",
|
|
478
|
+
"observedAt": 1792400846,
|
|
479
|
+
"value": {
|
|
480
|
+
"kind": "preview",
|
|
481
|
+
"invoiceId": "upcoming_in_1USCXT6JR7kThJogvouGEyfX",
|
|
482
|
+
"status": "draft",
|
|
483
|
+
"finalized": false,
|
|
484
|
+
"amountDue": "0",
|
|
485
|
+
"amountPaid": "0",
|
|
486
|
+
"total": "0",
|
|
487
|
+
"currency": "usd",
|
|
488
|
+
"linesComplete": true,
|
|
489
|
+
"lines": [
|
|
490
|
+
{
|
|
491
|
+
"lineId": "il_tmp_1UdRDE6JR7kThJogIcCFjRhw",
|
|
492
|
+
"stripePriceId": "price_1USCMU6JR7kThJogBWNtUi8l",
|
|
493
|
+
"subscriptionItemId": "si_VT8iAGyjWDamzd",
|
|
494
|
+
"amount": "1000",
|
|
495
|
+
"currency": "usd",
|
|
496
|
+
"quantity": "10",
|
|
497
|
+
"providerQuantityDecimal": "10",
|
|
498
|
+
"unitAmountDecimal": "100",
|
|
499
|
+
"creditAppliedAmount": "1000",
|
|
500
|
+
"nativePeriod": {
|
|
501
|
+
"start": 1792400460,
|
|
502
|
+
"end": 1795078860
|
|
503
|
+
},
|
|
504
|
+
"proration": false
|
|
505
|
+
}
|
|
506
|
+
],
|
|
507
|
+
"meterAmount": {
|
|
508
|
+
"status": "available",
|
|
509
|
+
"observedAt": 1792400846,
|
|
510
|
+
"value": {
|
|
511
|
+
"amount": "1000",
|
|
512
|
+
"currency": "usd"
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
"paymentEvidence": "not_resolved"
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
"originalPurchase": {
|
|
519
|
+
"purchaseId": "product_mx72qwxptr9y0bmrv38e1bf1v58gk88y",
|
|
520
|
+
"state": "ready",
|
|
521
|
+
"paymentIntentId": "pi_3USCTy6JR7kThJog0BOrUg5Q",
|
|
522
|
+
"creditGrantId": "credgr_test_61VbaRMpI1AJxgkMW416JR7kThJogLbc",
|
|
523
|
+
"quantity": "10",
|
|
524
|
+
"amount": 1000,
|
|
525
|
+
"currency": "usd"
|
|
526
|
+
},
|
|
527
|
+
"work": {
|
|
528
|
+
"status": "accepted",
|
|
529
|
+
"work": "completed_once",
|
|
530
|
+
"receiptId": "ss784ertb6b065ppxm7psr5zv58gj2x6"
|
|
531
|
+
},
|
|
532
|
+
"sameRequestReplay": {
|
|
533
|
+
"status": "accepted",
|
|
534
|
+
"work": "already_completed",
|
|
535
|
+
"receiptId": "ss784ertb6b065ppxm7psr5zv58gj2x6"
|
|
536
|
+
},
|
|
537
|
+
"eleventhReport": {
|
|
538
|
+
"status": "denied",
|
|
539
|
+
"work": "not_performed"
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
"cancellation": {
|
|
543
|
+
"cancelAtPeriodEnd": true,
|
|
544
|
+
"status": "active"
|
|
545
|
+
},
|
|
546
|
+
"limitations": [
|
|
547
|
+
"Draft invoice amounts are estimates, not collected funds or executed seller transfers.",
|
|
548
|
+
"Ordinary Checkout subscription boundaries have partial minutes. Exact provider aggregate is explicitly unsupported; no billing-period rounding is used.",
|
|
549
|
+
"Mixed base-fee and usage invoices remain ineligible for automatic seller settlement under the current verifier.",
|
|
550
|
+
"Original prepaid checkout test enrollment was held, its renewal canceled and its history retained. New prepaid enrollments use send_invoice; no original identity was rebound.",
|
|
551
|
+
"No shared customer test clock was advanced; no live money, production migration or npm publication."
|
|
552
|
+
]
|
|
553
|
+
}
|
package/docs/metered-usage.md
CHANGED
|
@@ -21,7 +21,7 @@ is included.
|
|
|
21
21
|
| `included_overage` | Gets included units each verified monthly period, then pays for overage | Atomic included/overage reservations, hard or soft limits, separate period counters |
|
|
22
22
|
| `prepaid` | Buys units before consumption | Verified original payment and price-scoped grant, atomic reservation/consumption, exhaustion and recovery |
|
|
23
23
|
|
|
24
|
-
Developers choose the unit, precision, price and policy.
|
|
24
|
+
Developers choose the unit, precision, price and policy. The recipe below uses whole
|
|
25
25
|
requests at USD 1 per request. Rates are decimal strings of **minor currency
|
|
26
26
|
units per whole billable unit**, so USD `"100"` means USD 1, not USD 100.
|
|
27
27
|
|
package/docs/metering-setup.md
CHANGED
|
@@ -88,32 +88,42 @@ The persona switcher is test-only, not production authentication. In an applicat
|
|
|
88
88
|
authenticate callers and resolve/authorize original payer, product, price, activity
|
|
89
89
|
and recipient policy on the server. See [usage security](usage-security.md).
|
|
90
90
|
|
|
91
|
-
## Verify
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
91
|
+
## Verify the product flows
|
|
92
|
+
|
|
93
|
+
Set the server-owned checkout return origin to your Vite URL. This value is not a
|
|
94
|
+
secret. For a default Vite server:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
pnpm exec convex env set FRONTEND_URL http://localhost:5173
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Use `http://localhost:4319` instead when Vite is running on port 4319. Set this
|
|
101
|
+
before creating an enrollment. The example retains the original return origin
|
|
102
|
+
with that enrollment, so changing the environment does not rewrite an existing
|
|
103
|
+
Checkout intent.
|
|
104
|
+
|
|
105
|
+
Choose Seller → Maya's Fitness Studio → Metered billing. Attach Included monthly
|
|
106
|
+
usage to the coaching membership product. The default terms are USD 20 monthly,
|
|
107
|
+
60 included coaching minutes and USD 1 per extra minute. Compare the via API and
|
|
108
|
+
BetterStripe components tabs before and after attachment.
|
|
109
|
+
|
|
110
|
+
Choose Customer, review the membership, complete its original test Checkout,
|
|
111
|
+
refresh enrollment, and record coaching minutes. Admin → Metered billing controls
|
|
112
|
+
store enablement separately. Sasha's Ceramics starts disabled. For pay as you go,
|
|
113
|
+
create another coaching product with a zero monthly base price. For prepaid,
|
|
114
|
+
configure the admin's own Store analytics reports product and verify that work is
|
|
115
|
+
held before a paid grant and denied after credit exhaustion.
|
|
116
|
+
|
|
117
|
+
Follow [the product walkthrough](usage-example.md) for exact steps, authorization,
|
|
118
|
+
payment verification, retained history and the mixed-invoice seller-settlement
|
|
119
|
+
limitation. Product subscriptions use actual native billing periods and the
|
|
120
|
+
customer's original account; this flow does not advance shared test clocks.
|
|
121
|
+
|
|
122
|
+
For isolated clock-driven renewal, correction and cleanup checks, use Admin →
|
|
123
|
+
Developer protocol diagnostics and follow the separate
|
|
124
|
+
[protocol diagnostics guide](usage-protocol-diagnostics.md). Those runs retain
|
|
125
|
+
their dedicated original resources and financial evidence. Never use diagnostic
|
|
126
|
+
cleanup to archive a seller's shared product or a real customer's account.
|
|
117
127
|
|
|
118
128
|
## Install in your own Convex application
|
|
119
129
|
|
package/docs/react-workflows.md
CHANGED
|
@@ -75,6 +75,41 @@ For checkout, change `orderKey` when the customer, price, or attribution changes
|
|
|
75
75
|
Do not put secret keys in these props. Browser code needs only a publishable key
|
|
76
76
|
and short-lived client secrets returned by your server.
|
|
77
77
|
|
|
78
|
+
## Product capabilities
|
|
79
|
+
|
|
80
|
+
`Products` and `useProductManager` accept product and price creation callbacks
|
|
81
|
+
independently. Supply only the operations your authenticated server supports.
|
|
82
|
+
For example, an existing catalog can offer editing and archiving while keeping
|
|
83
|
+
its compound plan-creation workflow separate:
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { Products } from "@fantastic.dev/better-stripe/react";
|
|
87
|
+
|
|
88
|
+
<Products
|
|
89
|
+
scopeKey={scopeKey}
|
|
90
|
+
products={products}
|
|
91
|
+
updateProduct={updateProduct}
|
|
92
|
+
deactivateProduct={deactivateProduct}
|
|
93
|
+
/>;
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
These callbacks bind your authorized server operations. Omitting `createProduct`
|
|
97
|
+
hides the default product-creation form. Omitting `createPrice` hides the default
|
|
98
|
+
Add price controls and price form. Editing and archiving remain available when
|
|
99
|
+
their callbacks are supplied. Custom renderers and companion-hook consumers
|
|
100
|
+
choose their own controls; invoking an unavailable creation handler reports a
|
|
101
|
+
configuration error through the existing workflow state without calling another
|
|
102
|
+
operation. Adding both callbacks retains the full creation workflow.
|
|
103
|
+
|
|
104
|
+
The Vite pages at `example/src/pages/seller/products.tsx` and
|
|
105
|
+
`example/src/pages/admin/products.tsx` demonstrate full callback wiring and
|
|
106
|
+
styled companion-hook rendering. Replace their demo identity adapters with your
|
|
107
|
+
authenticated server bindings and select the capabilities your application
|
|
108
|
+
needs. Do not add placeholder callbacks or expose
|
|
109
|
+
standalone creation merely to use editing. Capability props control presentation;
|
|
110
|
+
they do not replace server authorization. Change `scopeKey` when the actor or
|
|
111
|
+
authorized catalog context changes, as with the other workflows.
|
|
112
|
+
|
|
78
113
|
## Choose a checkout
|
|
79
114
|
|
|
80
115
|
`Checkout` supports all five checkout integrations. It creates the session or
|