@fantastic.dev/better-stripe 0.11.0 → 0.13.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 +30 -0
- package/README.md +267 -2
- package/dist/client/billing/balanceFunding.d.ts +36 -0
- package/dist/client/billing/balanceFunding.d.ts.map +1 -0
- package/dist/client/billing/balanceFunding.js +107 -0
- package/dist/client/billing/balanceFunding.js.map +1 -0
- package/dist/client/billing/invoicePreview.d.ts +28 -0
- package/dist/client/billing/invoicePreview.d.ts.map +1 -0
- package/dist/client/billing/invoicePreview.js +56 -0
- package/dist/client/billing/invoicePreview.js.map +1 -0
- package/dist/client/charge-currency-format.d.ts +3 -0
- package/dist/client/charge-currency-format.d.ts.map +1 -0
- package/dist/client/charge-currency-format.js +22 -0
- package/dist/client/charge-currency-format.js.map +1 -0
- package/dist/client/charge-currency.d.ts +14 -0
- package/dist/client/charge-currency.d.ts.map +1 -0
- package/dist/client/charge-currency.js +85 -0
- package/dist/client/charge-currency.js.map +1 -0
- package/dist/client/costRecovery-invoices.d.ts +38 -0
- package/dist/client/costRecovery-invoices.d.ts.map +1 -0
- package/dist/client/costRecovery-invoices.js +105 -0
- package/dist/client/costRecovery-invoices.js.map +1 -0
- package/dist/client/costRecovery.d.ts +156 -0
- package/dist/client/costRecovery.d.ts.map +1 -0
- package/dist/client/costRecovery.js +117 -0
- package/dist/client/costRecovery.js.map +1 -0
- package/dist/client/index.d.ts +28 -66
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +25 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/products/prices.d.ts +3 -2
- package/dist/client/products/prices.d.ts.map +1 -1
- package/dist/client/products/prices.js +0 -3
- package/dist/client/products/prices.js.map +1 -1
- package/dist/client/products/products.d.ts +3 -2
- package/dist/client/products/products.d.ts.map +1 -1
- package/dist/client/products/products.js +0 -3
- package/dist/client/products/products.js.map +1 -1
- package/dist/client/settlement/processingCosts.d.ts +56 -0
- package/dist/client/settlement/processingCosts.d.ts.map +1 -0
- package/dist/client/settlement/processingCosts.js +173 -0
- package/dist/client/settlement/processingCosts.js.map +1 -0
- package/dist/client/utils/webhookEndpoints.d.ts +1 -1
- package/dist/client/utils/webhookEndpoints.d.ts.map +1 -1
- package/dist/client/utils/webhookEndpoints.js +1 -0
- package/dist/client/utils/webhookEndpoints.js.map +1 -1
- package/dist/client/webhooks/processors.d.ts.map +1 -1
- package/dist/client/webhooks/processors.js +1 -0
- package/dist/client/webhooks/processors.js.map +1 -1
- package/dist/component/_generated/component.d.ts +322 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/costRecovery/claims.d.ts +68 -0
- package/dist/component/costRecovery/claims.d.ts.map +1 -0
- package/dist/component/costRecovery/claims.js +92 -0
- package/dist/component/costRecovery/claims.js.map +1 -0
- package/dist/component/costRecovery/completion.d.ts +39 -0
- package/dist/component/costRecovery/completion.d.ts.map +1 -0
- package/dist/component/costRecovery/completion.js +69 -0
- package/dist/component/costRecovery/completion.js.map +1 -0
- package/dist/component/costRecovery/helpers.d.ts +68 -0
- package/dist/component/costRecovery/helpers.d.ts.map +1 -0
- package/dist/component/costRecovery/helpers.js +71 -0
- package/dist/component/costRecovery/helpers.js.map +1 -0
- package/dist/component/costRecovery/mutations.d.ts +210 -0
- package/dist/component/costRecovery/mutations.d.ts.map +1 -0
- package/dist/component/costRecovery/mutations.js +93 -0
- package/dist/component/costRecovery/mutations.js.map +1 -0
- package/dist/component/costRecovery/queries.d.ts +108 -0
- package/dist/component/costRecovery/queries.d.ts.map +1 -0
- package/dist/component/costRecovery/queries.js +73 -0
- package/dist/component/costRecovery/queries.js.map +1 -0
- package/dist/component/costRecovery/reservations.d.ts +95 -0
- package/dist/component/costRecovery/reservations.d.ts.map +1 -0
- package/dist/component/costRecovery/reservations.js +134 -0
- package/dist/component/costRecovery/reservations.js.map +1 -0
- package/dist/component/costRecovery/schema.d.ts +382 -0
- package/dist/component/costRecovery/schema.d.ts.map +1 -0
- package/dist/component/costRecovery/schema.js +115 -0
- package/dist/component/costRecovery/schema.js.map +1 -0
- package/dist/component/schema.d.ts +135 -0
- package/dist/component/schema.js +5 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/react/components/PriceCard.d.ts +3 -1
- package/dist/react/components/PriceCard.d.ts.map +1 -1
- package/dist/react/components/PriceCard.js +2 -2
- package/dist/react/components/PriceCard.js.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/lib/price-helpers.d.ts +4 -6
- package/dist/react/lib/price-helpers.d.ts.map +1 -1
- package/dist/react/lib/price-helpers.js +16 -9
- package/dist/react/lib/price-helpers.js.map +1 -1
- package/dist/react/workflows/Collections.d.ts.map +1 -1
- package/dist/react/workflows/Collections.js +2 -1
- package/dist/react/workflows/Collections.js.map +1 -1
- package/dist/react/workflows/PlanPricingEditor.d.ts +4 -0
- package/dist/react/workflows/PlanPricingEditor.d.ts.map +1 -1
- package/dist/react/workflows/PlanPricingEditor.js +12 -9
- package/dist/react/workflows/PlanPricingEditor.js.map +1 -1
- package/dist/react/workflows/Refunds.d.ts +14 -3
- package/dist/react/workflows/Refunds.d.ts.map +1 -1
- package/dist/react/workflows/Refunds.js +58 -16
- package/dist/react/workflows/Refunds.js.map +1 -1
- package/dist/react/workflows/index.d.ts +3 -1
- package/dist/react/workflows/index.d.ts.map +1 -1
- package/dist/react/workflows/index.js +2 -1
- package/dist/react/workflows/index.js.map +1 -1
- package/dist/react/workflows/refund-preview.d.ts +16 -0
- package/dist/react/workflows/refund-preview.d.ts.map +1 -0
- package/dist/react/workflows/refund-preview.js +38 -0
- package/dist/react/workflows/refund-preview.js.map +1 -0
- package/docs/react-workflows.md +167 -1
- package/package.json +2 -2
- package/src/client/billing/balanceFunding.test.ts +257 -0
- package/src/client/billing/balanceFunding.ts +183 -0
- package/src/client/billing/balanceFundingTransport.test.ts +89 -0
- package/src/client/billing/invoicePreview.test.ts +123 -0
- package/src/client/billing/invoicePreview.ts +94 -0
- package/src/client/billing/invoicePreviewTransport.test.ts +70 -0
- package/src/client/charge-currency-format.ts +29 -0
- package/src/client/charge-currency.test.ts +113 -0
- package/src/client/charge-currency.ts +119 -0
- package/src/client/costRecovery-invoices.test.ts +401 -0
- package/src/client/costRecovery-invoices.transport.test.ts +107 -0
- package/src/client/costRecovery-invoices.ts +144 -0
- package/src/client/costRecovery.test.ts +76 -0
- package/src/client/costRecovery.ts +254 -0
- package/src/client/index.ts +76 -75
- package/src/client/products/prices.ts +13 -11
- package/src/client/products/products.ts +10 -10
- package/src/client/settlement/processingCosts.test.ts +349 -0
- package/src/client/settlement/processingCosts.ts +315 -0
- package/src/client/settlement/processingCostsTransport.test.ts +135 -0
- package/src/client/utils/webhookEndpoints.test.ts +5 -0
- package/src/client/utils/webhookEndpoints.ts +1 -0
- package/src/client/webhooks/hooks.test.ts +9 -0
- package/src/client/webhooks/payout-canceled.integration.test.ts +192 -0
- package/src/client/webhooks/processors.ts +1 -0
- package/src/component/_generated/api.ts +12 -0
- package/src/component/_generated/component.ts +407 -0
- package/src/component/cost-recovery.test.ts +344 -0
- package/src/component/costRecovery/claims.ts +119 -0
- package/src/component/costRecovery/completion.ts +92 -0
- package/src/component/costRecovery/helpers.ts +83 -0
- package/src/component/costRecovery/mutations.ts +115 -0
- package/src/component/costRecovery/queries.ts +88 -0
- package/src/component/costRecovery/reservations.ts +164 -0
- package/src/component/costRecovery/schema.ts +135 -0
- package/src/component/schema.ts +10 -0
- package/src/react/components/PayoutSchedule.render.test.tsx +15 -0
- package/src/react/components/PriceCard.render.test.tsx +37 -0
- package/src/react/components/PriceCard.tsx +9 -1
- package/src/react/index.test.ts +5 -0
- package/src/react/index.ts +7 -0
- package/src/react/lib/price-helpers.test.ts +15 -2
- package/src/react/lib/price-helpers.ts +25 -8
- package/src/react/workflows/Billing.test.tsx +1 -1
- package/src/react/workflows/Collections.test.tsx +36 -0
- package/src/react/workflows/Collections.tsx +3 -1
- package/src/react/workflows/PlanPricingEditor.currency.test.tsx +164 -0
- package/src/react/workflows/PlanPricingEditor.tsx +26 -10
- package/src/react/workflows/Refunds.currency.test.tsx +290 -0
- package/src/react/workflows/Refunds.tsx +115 -25
- package/src/react/workflows/index.ts +8 -1
- package/src/react/workflows/refund-preview.test.ts +65 -0
- package/src/react/workflows/refund-preview.ts +56 -0
|
@@ -3,24 +3,39 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { useState, useId } from "react";
|
|
4
4
|
import { useWorkflowAction } from "./useWorkflowAction.js";
|
|
5
5
|
import { Connect } from "./Connect.js";
|
|
6
|
-
|
|
6
|
+
import { getChargeCurrencyMetadata, parseChargeAmount, } from "../../client/charge-currency.js";
|
|
7
|
+
/** Exact positive refund amount in the original charge currency's provider units. */
|
|
8
|
+
export function parseRefundAmount(value, currency) {
|
|
9
|
+
const amount = parseChargeAmount(value.trim(), currency);
|
|
10
|
+
return amount !== null && amount > 0 ? amount : null;
|
|
11
|
+
}
|
|
12
|
+
/** Legacy USD-only parser. Use parseRefundAmount for original-currency inputs. */
|
|
7
13
|
export function parseAmountCents(value) {
|
|
8
|
-
|
|
9
|
-
return null;
|
|
10
|
-
const [whole, fraction = ""] = value.trim().split(".");
|
|
11
|
-
const amount = Number(whole) * 100 + Number(fraction.padEnd(2, "0"));
|
|
12
|
-
return Number.isSafeInteger(amount) && amount > 0 ? amount : null;
|
|
14
|
+
return parseRefundAmount(value, "usd");
|
|
13
15
|
}
|
|
14
16
|
export function useRefunds(props) {
|
|
17
|
+
const paymentCurrency = props.paymentCurrency === undefined
|
|
18
|
+
? "usd"
|
|
19
|
+
: (props.paymentCurrency?.toLowerCase() ?? null);
|
|
20
|
+
const sourceChargeCurrency = props.sourceChargeCurrency === undefined
|
|
21
|
+
? "usd"
|
|
22
|
+
: (props.sourceChargeCurrency?.toLowerCase() ?? null);
|
|
23
|
+
const scope = JSON.stringify([
|
|
24
|
+
props.scopeKey,
|
|
25
|
+
props.paymentIntentId?.trim(),
|
|
26
|
+
props.sourceChargeId?.trim(),
|
|
27
|
+
paymentCurrency,
|
|
28
|
+
sourceChargeCurrency,
|
|
29
|
+
]);
|
|
15
30
|
const initial = {
|
|
16
|
-
scope
|
|
31
|
+
scope,
|
|
17
32
|
paymentIntentId: props.paymentIntentId ?? "",
|
|
18
33
|
sourceChargeId: props.sourceChargeId ?? "",
|
|
19
34
|
refundAmount: "",
|
|
20
35
|
reversalAmount: "",
|
|
21
36
|
};
|
|
22
37
|
const [fields, setFields] = useState(initial);
|
|
23
|
-
if (fields.scope !==
|
|
38
|
+
if (fields.scope !== scope)
|
|
24
39
|
setFields(initial);
|
|
25
40
|
const [operationType, setOperationType] = useState("refund");
|
|
26
41
|
const action = useWorkflowAction(async (operation) => {
|
|
@@ -32,19 +47,30 @@ export function useRefunds(props) {
|
|
|
32
47
|
throw new Error(operation.type === "refund"
|
|
33
48
|
? "Enter a PaymentIntent id before issuing a refund."
|
|
34
49
|
: "Enter a source charge id before reversing transfers.");
|
|
50
|
+
const currency = operation.type === "refund" ? paymentCurrency : sourceChargeCurrency;
|
|
51
|
+
const boundId = operation.type === "refund"
|
|
52
|
+
? props.paymentIntentId
|
|
53
|
+
: props.sourceChargeId;
|
|
54
|
+
const hasExplicitCurrency = operation.type === "refund"
|
|
55
|
+
? props.paymentCurrency !== undefined
|
|
56
|
+
: props.sourceChargeCurrency !== undefined;
|
|
57
|
+
if (operation.kind === "partial" &&
|
|
58
|
+
hasExplicitCurrency &&
|
|
59
|
+
id !== boundId?.trim())
|
|
60
|
+
throw new Error("Original currency is not verified for this identifier.");
|
|
35
61
|
const amount = operation.kind === "partial"
|
|
36
|
-
?
|
|
62
|
+
? parseRefundAmount(operation.type === "refund"
|
|
37
63
|
? fields.refundAmount
|
|
38
|
-
: fields.reversalAmount)
|
|
64
|
+
: fields.reversalAmount, currency ?? "")
|
|
39
65
|
: undefined;
|
|
40
66
|
if (amount === null)
|
|
41
|
-
throw new Error(`Enter a positive partial ${operation.type === "refund" ? "refund" : "reversal"} amount
|
|
67
|
+
throw new Error(`Enter a positive partial ${operation.type === "refund" ? "refund" : "reversal"} amount in supported original currency units.`);
|
|
42
68
|
if (operation.type === "refund")
|
|
43
69
|
return {
|
|
44
70
|
type: "refund",
|
|
45
71
|
value: await props.issueRefund({
|
|
46
72
|
stripePaymentIntentId: id,
|
|
47
|
-
amountCents: amount,
|
|
73
|
+
...(amount === undefined ? {} : { amountCents: amount }),
|
|
48
74
|
reason: "requested_by_customer",
|
|
49
75
|
}),
|
|
50
76
|
};
|
|
@@ -54,13 +80,23 @@ export function useRefunds(props) {
|
|
|
54
80
|
type: "reversal",
|
|
55
81
|
value: await props.reverseTransfers({
|
|
56
82
|
sourceChargeId: id,
|
|
57
|
-
amountCents: amount,
|
|
83
|
+
...(amount === undefined ? {} : { amountCents: amount }),
|
|
58
84
|
}),
|
|
59
85
|
};
|
|
60
|
-
},
|
|
86
|
+
}, JSON.stringify([
|
|
87
|
+
scope,
|
|
88
|
+
fields.paymentIntentId.trim(),
|
|
89
|
+
fields.sourceChargeId.trim(),
|
|
90
|
+
]));
|
|
61
91
|
const set = (name, value) => setFields((previous) => ({ ...previous, [name]: value }));
|
|
62
92
|
return {
|
|
63
93
|
...fields,
|
|
94
|
+
scope: props.scopeKey,
|
|
95
|
+
paymentCurrency,
|
|
96
|
+
sourceChargeCurrency,
|
|
97
|
+
refundInputDecimalPlaces: getChargeCurrencyMetadata(paymentCurrency ?? "")?.displayDecimals ?? null,
|
|
98
|
+
reversalInputDecimalPlaces: getChargeCurrencyMetadata(sourceChargeCurrency ?? "")?.displayDecimals ??
|
|
99
|
+
null,
|
|
64
100
|
setPaymentIntentId: (value) => set("paymentIntentId", value),
|
|
65
101
|
setSourceChargeId: (value) => set("sourceChargeId", value),
|
|
66
102
|
setRefundAmount: (value) => set("refundAmount", value),
|
|
@@ -77,16 +113,22 @@ export function useRefunds(props) {
|
|
|
77
113
|
export function Refunds(props) {
|
|
78
114
|
return props.presentation === "embedded" ? (_jsx(Connect, { ...props, component: "refunds" })) : (_jsx(RefundsBody, { ...props }, props.scopeKey));
|
|
79
115
|
}
|
|
116
|
+
function RefundAmountInput(props) {
|
|
117
|
+
const step = props.decimalPlaces === 0 ? "1" : "0.01";
|
|
118
|
+
return (_jsxs(_Fragment, { children: [_jsxs("label", { htmlFor: props.id, children: [props.label, props.currency !== undefined
|
|
119
|
+
? ` (${props.currency?.toUpperCase() ?? "currency unavailable"})`
|
|
120
|
+
: ""] }), _jsx("input", { id: props.id, type: "number", min: step, step: step, inputMode: props.decimalPlaces === 0 ? "numeric" : "decimal", value: props.value, onChange: (event) => props.onChange(event.target.value) })] }));
|
|
121
|
+
}
|
|
80
122
|
function RefundsBody(props) {
|
|
81
123
|
const state = useRefunds(props);
|
|
82
124
|
const id = useId();
|
|
83
125
|
if (props.children)
|
|
84
126
|
return _jsx(_Fragment, { children: props.children(state) });
|
|
85
|
-
return (_jsxs("section", { "data-better-stripe": "refunds", "aria-busy": state.isPending, children: [_jsx("h2", { children: "Refunds" }), state.error && _jsx("p", { role: "alert", children: state.error }), _jsx("label", { htmlFor: `${id}-payment`, children: "PaymentIntent ID" }), _jsx("input", { id: `${id}-payment`, value: state.paymentIntentId, onChange: (event) => state.setPaymentIntentId(event.target.value) }), _jsx(
|
|
127
|
+
return (_jsxs("section", { "data-better-stripe": "refunds", "aria-busy": state.isPending, children: [_jsx("h2", { children: "Refunds" }), state.error && _jsx("p", { role: "alert", children: state.error }), _jsx("label", { htmlFor: `${id}-payment`, children: "PaymentIntent ID" }), _jsx("input", { id: `${id}-payment`, value: state.paymentIntentId, onChange: (event) => state.setPaymentIntentId(event.target.value) }), _jsx(RefundAmountInput, { id: `${id}-amount`, label: "Partial refund amount", currency: props.paymentCurrency, decimalPlaces: state.refundInputDecimalPlaces, value: state.refundAmount, onChange: state.setRefundAmount }), _jsx("button", { type: "button", disabled: state.isPending, onClick: () => {
|
|
86
128
|
void state.submitRefund("full");
|
|
87
129
|
}, children: state.isPending ? "Processing…" : "Full refund" }), _jsx("button", { type: "button", disabled: state.isPending, onClick: () => {
|
|
88
130
|
void state.submitRefund("partial");
|
|
89
|
-
}, children: "Partial refund" }), state.refundResult && (_jsxs("p", { role: "status", children: ["Refund created: ", state.refundResult.stripeRefundId] })), props.reverseTransfers && (_jsxs(_Fragment, { children: [_jsx("h3", { children: "Transfer reversals" }), _jsx("label", { htmlFor: `${id}-charge`, children: "Source charge ID" }), _jsx("input", { id: `${id}-charge`, value: state.sourceChargeId, onChange: (event) => state.setSourceChargeId(event.target.value) }), _jsx(
|
|
131
|
+
}, children: "Partial refund" }), state.refundResult && (_jsxs("p", { role: "status", children: ["Refund created: ", state.refundResult.stripeRefundId] })), props.reverseTransfers && (_jsxs(_Fragment, { children: [_jsx("h3", { children: "Transfer reversals" }), _jsx("label", { htmlFor: `${id}-charge`, children: "Source charge ID" }), _jsx("input", { id: `${id}-charge`, value: state.sourceChargeId, onChange: (event) => state.setSourceChargeId(event.target.value) }), _jsx(RefundAmountInput, { id: `${id}-reversal`, label: "Partial reversal amount", currency: props.sourceChargeCurrency, decimalPlaces: state.reversalInputDecimalPlaces, value: state.reversalAmount, onChange: state.setReversalAmount }), _jsx("button", { type: "button", disabled: state.isPending, onClick: () => {
|
|
90
132
|
void state.submitReversal("full");
|
|
91
133
|
}, children: "Reverse all transfers" }), _jsx("button", { type: "button", disabled: state.isPending, onClick: () => {
|
|
92
134
|
void state.submitReversal("partial");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Refunds.js","sourceRoot":"","sources":["../../../src/react/workflows/Refunds.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAkB,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE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AAM,CAAC,CAAC;wBACpC,CAAC,sCAGM,EACT,iBACE,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,OAAO,EAAE,GAAG,EAAE;4BACZ,KAAK,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;wBACvC,CAAC,iCAGM,EACR,KAAK,CAAC,cAAc,IAAI,CACvB,aAAG,IAAI,EAAC,QAAQ,0BACJ,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,aAAa,mBAClD,CACL,IACA,CACJ,IACO,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -9,9 +9,11 @@ export { Connect } from "./Connect.js";
|
|
|
9
9
|
export type { ConnectProps, ConnectComponent, ConnectRenderProps, } from "./Connect.js";
|
|
10
10
|
export { Payouts } from "./Payouts.js";
|
|
11
11
|
export type { PayoutsProps, HeadlessPayoutsProps, PayoutsRenderProps, PayoutSnapshot, PayoutRow, } from "./Payouts.js";
|
|
12
|
-
export { Refunds, useRefunds, parseAmountCents } from "./Refunds.js";
|
|
12
|
+
export { Refunds, useRefunds, parseAmountCents, parseRefundAmount, } from "./Refunds.js";
|
|
13
13
|
export type { RefundsProps, RefundsRenderProps, RefundActionsProps, RefundRequest, ReversalRequest, RefundResult, ReversalResult, } from "./Refunds.js";
|
|
14
14
|
export { Collection } from "./Collection.js";
|
|
15
|
+
export { formatRefundAmount, groupRefundPreview } from "./refund-preview.js";
|
|
16
|
+
export type { RefundPreviewGroup } from "./refund-preview.js";
|
|
15
17
|
export type { CollectionProps, CollectionRenderProps, WorkflowColumn, } from "./Collection.js";
|
|
16
18
|
export { Sales, Invoices, RefundHistory, ReferredSales, WebhookEvents, } from "./Collections.js";
|
|
17
19
|
export type { ResourceCollectionProps, SaleRow, InvoiceRow, RefundRow, ReferredSaleRow, WebhookEventRow, } from "./Collections.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EACV,aAAa,EACb,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,SAAS,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EACV,aAAa,EACb,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB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E,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EACV,uBAAuB,EACvB,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,4BAA4B,CAAC"}
|
|
@@ -4,8 +4,9 @@ export { Checkout } from "./Checkout.js";
|
|
|
4
4
|
export { CheckoutElementsForm, PaymentIntentForm, CheckoutForm, } from "./CheckoutForms.js";
|
|
5
5
|
export { Connect } from "./Connect.js";
|
|
6
6
|
export { Payouts } from "./Payouts.js";
|
|
7
|
-
export { Refunds, useRefunds, parseAmountCents } from "./Refunds.js";
|
|
7
|
+
export { Refunds, useRefunds, parseAmountCents, parseRefundAmount, } from "./Refunds.js";
|
|
8
8
|
export { Collection } from "./Collection.js";
|
|
9
|
+
export { formatRefundAmount, groupRefundPreview } from "./refund-preview.js";
|
|
9
10
|
export { Sales, Invoices, RefundHistory, ReferredSales, WebhookEvents, } from "./Collections.js";
|
|
10
11
|
export { Products, useProductManager } from "./Products.js";
|
|
11
12
|
export { Onboarding, useOnboarding } from "./Onboarding.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAA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,CAAC;AAKjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAOhE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAO3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAM/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type RefundPreviewGroup = {
|
|
2
|
+
currency: string;
|
|
3
|
+
status: string;
|
|
4
|
+
/** Loaded rows only. Null means unknown/invalid units or an unsafe sum. */
|
|
5
|
+
amount: number | null;
|
|
6
|
+
count: number;
|
|
7
|
+
};
|
|
8
|
+
/** Observed refund units, including fractional ISK/UGX amounts; not input eligibility. */
|
|
9
|
+
export declare function formatRefundAmount(amount: number, currency: string, locale?: string): string | null;
|
|
10
|
+
/** Group only the supplied preview, preserving provider status and currency. */
|
|
11
|
+
export declare function groupRefundPreview(rows: readonly {
|
|
12
|
+
amount: number;
|
|
13
|
+
currency: string;
|
|
14
|
+
status: string;
|
|
15
|
+
}[]): RefundPreviewGroup[];
|
|
16
|
+
//# sourceMappingURL=refund-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refund-preview.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/refund-preview.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAUF,0FAA0F;AAC1F,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,SAAU,GACf,MAAM,GAAG,IAAI,CAIf;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,GACpE,kBAAkB,EAAE,CAsBtB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getChargeCurrencyMetadata } from "../../client/charge-currency.js";
|
|
2
|
+
import { formatPrice } from "../lib/price-helpers.js";
|
|
3
|
+
function isRefundAmount(amount, currency) {
|
|
4
|
+
return (Number.isSafeInteger(amount) &&
|
|
5
|
+
amount >= 0 &&
|
|
6
|
+
getChargeCurrencyMetadata(currency) !== null);
|
|
7
|
+
}
|
|
8
|
+
/** Observed refund units, including fractional ISK/UGX amounts; not input eligibility. */
|
|
9
|
+
export function formatRefundAmount(amount, currency, locale = "en-US") {
|
|
10
|
+
return isRefundAmount(amount, currency)
|
|
11
|
+
? formatPrice(amount, currency, locale)
|
|
12
|
+
: null;
|
|
13
|
+
}
|
|
14
|
+
/** Group only the supplied preview, preserving provider status and currency. */
|
|
15
|
+
export function groupRefundPreview(rows) {
|
|
16
|
+
const groups = new Map();
|
|
17
|
+
for (const row of rows) {
|
|
18
|
+
const currency = row.currency.toLowerCase();
|
|
19
|
+
const key = JSON.stringify([currency, row.status]);
|
|
20
|
+
const group = groups.get(key) ?? {
|
|
21
|
+
currency,
|
|
22
|
+
status: row.status,
|
|
23
|
+
amount: 0,
|
|
24
|
+
count: 0,
|
|
25
|
+
};
|
|
26
|
+
group.count++;
|
|
27
|
+
if (group.amount === null || !isRefundAmount(row.amount, currency))
|
|
28
|
+
group.amount = null;
|
|
29
|
+
else {
|
|
30
|
+
const sum = BigInt(group.amount) + BigInt(row.amount);
|
|
31
|
+
group.amount =
|
|
32
|
+
sum <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(sum) : null;
|
|
33
|
+
}
|
|
34
|
+
groups.set(key, group);
|
|
35
|
+
}
|
|
36
|
+
return [...groups.values()];
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=refund-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refund-preview.js","sourceRoot":"","sources":["../../../src/react/workflows/refund-preview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAUtD,SAAS,cAAc,CAAC,MAAc,EAAE,QAAgB;IACtD,OAAO,CACL,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC;QAC5B,MAAM,IAAI,CAAC;QACX,yBAAyB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAC7C,CAAC;AACJ,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,kBAAkB,CAChC,MAAc,EACd,QAAgB,EAChB,MAAM,GAAG,OAAO;IAEhB,OAAO,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC;QACrC,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC;QACvC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,kBAAkB,CAChC,IAAqE;IAErE,MAAM,MAAM,GAAG,IAAI,GAAG,EAA8B,CAAC;IACrD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI;YAC/B,QAAQ;YACR,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,CAAC;SACT,CAAC;QACF,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;YAChE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;aACjB,CAAC;YACJ,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACtD,KAAK,CAAC,MAAM;gBACV,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAChE,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAC9B,CAAC"}
|
package/docs/react-workflows.md
CHANGED
|
@@ -8,6 +8,59 @@ Components render semantic HTML without package CSS. Use their render props or
|
|
|
8
8
|
companion hooks to supply your own design system. Stripe iframe contents use
|
|
9
9
|
Stripe's `appearance` options and retain Stripe's own styling.
|
|
10
10
|
|
|
11
|
+
## Charge and Price currency units
|
|
12
|
+
|
|
13
|
+
`getChargeCurrencyMetadata`, `chargeAmountToDecimal`, `parseChargeAmount` and `formatChargeAmount` are
|
|
14
|
+
browser-safe pure helpers exported from the main package and `/react`. They
|
|
15
|
+
apply Stripe charge/Price rules, not payout or Global Payouts rules. See
|
|
16
|
+
[Stripe currencies](https://docs.stripe.com/currencies).
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import {
|
|
20
|
+
getChargeCurrencyMetadata,
|
|
21
|
+
parseChargeAmount,
|
|
22
|
+
formatChargeAmount,
|
|
23
|
+
} from "@fantastic.dev/better-stripe/react";
|
|
24
|
+
|
|
25
|
+
getChargeCurrencyMetadata("jpy"); // { currency: "jpy", apiDecimals: 0, displayDecimals: 0 }
|
|
26
|
+
parseChargeAmount("500", "jpy"); // 500
|
|
27
|
+
formatChargeAmount(500, "jpy"); // ¥500
|
|
28
|
+
parseChargeAmount("500", "isk"); // 50000, compatibility units
|
|
29
|
+
parseChargeAmount("10.45", "huf"); // 1045, charge fractions are supported
|
|
30
|
+
parseChargeAmount("1.005", "usd"); // null, no rounding
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The parser accepts nonnegative ASCII decimals, including zero, and returns a
|
|
34
|
+
safe integer or `null`. Reject a zero refund or non-free product separately in
|
|
35
|
+
the authorized operation. Exponents, separators, signs, excess precision and
|
|
36
|
+
unsafe integers are invalid. ISK/UGX accept whole amounts and use two-decimal
|
|
37
|
+
API compatibility units. Zero-decimal charge currencies include JPY and MGA.
|
|
38
|
+
HUF/TWD charges retain two decimals despite their payout restrictions. Unknown
|
|
39
|
+
currencies and unsupported three/four-decimal precision fail closed; formatting
|
|
40
|
+
invalid amounts throws `RangeError`. The formatter supports signed adjustments
|
|
41
|
+
and preserves negative sub-unit values. Parsing new charge inputs remains
|
|
42
|
+
nonnegative. No helper performs FX or provider writes. Environments without
|
|
43
|
+
`Intl.supportedValuesOf` fail closed with no recognized currencies.
|
|
44
|
+
|
|
45
|
+
`PriceCard` and `formatPriceWithInterval` use the strict charge/Price rules.
|
|
46
|
+
The legacy `formatPrice` display helper also serves observed account balances
|
|
47
|
+
and signed costs. It preserves fractional ISK/UGX minor units without applying
|
|
48
|
+
whole-charge eligibility, so an observed UGX balance of `101` displays `1.01`.
|
|
49
|
+
It is not a charge validator. No helper establishes payout eligibility or
|
|
50
|
+
Global Payouts units.
|
|
51
|
+
Missing/null amounts display `Custom price`, distinct from a real zero price.
|
|
52
|
+
Pass `customPriceLabel` and `locale` to `PriceCard` for translated presentation,
|
|
53
|
+
or the third argument to `formatPriceWithInterval` for a custom missing-amount
|
|
54
|
+
label. The Vite Products component example keeps the package's formatted price
|
|
55
|
+
inside its Shadcn render prop. Invalid non-null provider values must be handled
|
|
56
|
+
by the host's error boundary rather than presented as a fabricated amount.
|
|
57
|
+
|
|
58
|
+
Metadata describes precision only. Derive selectable presentment currencies
|
|
59
|
+
from the public `getCountrySpecs` result and validate account/payment-method
|
|
60
|
+
support on the server. Do not derive an account's supported currencies from
|
|
61
|
+
`Intl.supportedValuesOf` or this helper. Refunds and PlanPricingEditor reuse the
|
|
62
|
+
charge helpers for original-currency inputs; neither establishes payout units.
|
|
63
|
+
|
|
11
64
|
## Bind your backend
|
|
12
65
|
|
|
13
66
|
Pass authenticated server callbacks and query results to the components. This
|
|
@@ -153,7 +206,7 @@ widgets. Use package UI or the hosted Billing Portal for those workflows.
|
|
|
153
206
|
| Earnings | `Earnings`, `EarningsSummary` | `earningsFromBalance` |
|
|
154
207
|
| Payouts | `Payouts`, `PayoutSchedule`, `PayoutHistory`, `PayoutOverview` | `getPayoutTotals` |
|
|
155
208
|
| Sales | `Sales`, `ReferredSales` | Server-authoritative economic rows |
|
|
156
|
-
| Refunds | `Refunds`, `RefundHistory` | `useRefunds`, `parseAmountCents`
|
|
209
|
+
| Refunds | `Refunds`, `RefundHistory` | `useRefunds`, `parseRefundAmount`; legacy USD-only `parseAmountCents` |
|
|
157
210
|
| Disputes | `Disputes`, `DisputesList`, `DisputeDetail`, `EvidenceForm`, `ChargebackLedger` | `useDisputeResponse` |
|
|
158
211
|
| Onboarding | `Onboarding` | `useOnboarding` |
|
|
159
212
|
| Accounts | `Account`, `AccountConfigurations` | `useAccountManager` |
|
|
@@ -262,6 +315,82 @@ loading. The example's affiliate sales page uses this with the component query
|
|
|
262
315
|
pages scoped to the recipient account. Earnings totals still use aggregate
|
|
263
316
|
queries independently of pagination.
|
|
264
317
|
|
|
318
|
+
## Original-currency refunds and reversals
|
|
319
|
+
|
|
320
|
+
`Refunds` and `useRefunds` accept `paymentCurrency` for the selected
|
|
321
|
+
`paymentIntentId` and independent `sourceChargeCurrency` for `sourceChargeId`.
|
|
322
|
+
Derive both from authorized original records. The Vite seller refunds page
|
|
323
|
+
loads the selected payment before parsing a partial refund. Its readonly
|
|
324
|
+
`getRefundChargeContext` adapter reads the component's stored settlement allocation
|
|
325
|
+
for the selected source charge and matches the claimed persona's current account
|
|
326
|
+
to its original `store` leg. Missing allocations, unavailable accounts, foreign
|
|
327
|
+
store legs and affiliate/collaborator-only recipients return no context. Partial
|
|
328
|
+
reversals remain disabled until the selected charge has supported verified currency,
|
|
329
|
+
independently of payment currency. A charge without verified currency can still use
|
|
330
|
+
its separately authorized full operation, but cannot submit an assumed-USD partial
|
|
331
|
+
amount. This adapter adds no provider calls, writes or settlement ledger.
|
|
332
|
+
|
|
333
|
+
The example binds a client-claimed demo persona, not an authenticated identity.
|
|
334
|
+
Production hosts such as Dojo must derive an enabled user from the authenticated
|
|
335
|
+
session, authorize merchant ownership on the server and expose only the permitted
|
|
336
|
+
original-charge context. Loading context does not authorize a reversal.
|
|
337
|
+
|
|
338
|
+
```tsx
|
|
339
|
+
<Refunds
|
|
340
|
+
scopeKey={authenticatedUser.id}
|
|
341
|
+
paymentIntentId={selectedPayment.stripePaymentIntentId}
|
|
342
|
+
paymentCurrency={selectedPayment.currency}
|
|
343
|
+
sourceChargeId={verifiedOriginalCharge.id}
|
|
344
|
+
sourceChargeCurrency={verifiedOriginalCharge.currency}
|
|
345
|
+
issueRefund={authorizedRefund}
|
|
346
|
+
reverseTransfers={authorizedRecoveryReversal}
|
|
347
|
+
/>
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
The callbacks remain application-authenticated server bindings. Their optional
|
|
351
|
+
`amountCents` property keeps its legacy name but contains exact provider units
|
|
352
|
+
in the original operation's currency, not universal hundredths. JPY 500 emits
|
|
353
|
+
500; ISK 500 emits 50000; HUF/TWD charges retain fractions. Full operations omit
|
|
354
|
+
the property entirely. Currency parsing does not authorize a refund, calculate
|
|
355
|
+
the remaining refundable balance, reverse ordinary-refund legs a second time,
|
|
356
|
+
cancel a subscription or change access.
|
|
357
|
+
|
|
358
|
+
Omitting a currency retains the legacy USD contract. Pass explicit `null` while
|
|
359
|
+
original currency is unknown; partial operations then fail safely. An explicit
|
|
360
|
+
currency requires its matching original identifier prop. Editing to another
|
|
361
|
+
identifier cannot reuse the old currency; the host must select/load its verified
|
|
362
|
+
record. Unknown currencies, unsupported precision, unsafe integers, scientific
|
|
363
|
+
notation, excess decimals and nonpositive partial amounts never reach callbacks.
|
|
364
|
+
`parseRefundAmount(value, currency)` exposes this exact positive parser through
|
|
365
|
+
`/react`. `parseAmountCents(value)` remains a USD-only compatibility wrapper.
|
|
366
|
+
|
|
367
|
+
Headless state exposes both currencies and nullable `refundInputDecimalPlaces`
|
|
368
|
+
and `reversalInputDecimalPlaces`. Use these for translated labels and input
|
|
369
|
+
precision. Fields, pending/error/result state reset by authenticated scope,
|
|
370
|
+
selected identifiers and currencies. Late completion cannot update another
|
|
371
|
+
context. Changing the view does not cancel an already-submitted server operation;
|
|
372
|
+
reconcile that intent before requesting another. Revalidate authorization,
|
|
373
|
+
original merchant/currency, positive units, remaining refundable limits and
|
|
374
|
+
stable provider idempotency on the server before moving money.
|
|
375
|
+
|
|
376
|
+
The Vite refund history is a bounded preview of up to 25 loaded rows, not an
|
|
377
|
+
authoritative account total. `groupRefundPreview(rows)` groups only supplied rows
|
|
378
|
+
by original currency and exact provider status, returning currency, status, nullable
|
|
379
|
+
amount and row count. It never adds currencies or combines pending/failed/canceled
|
|
380
|
+
requests with succeeded refunds. An empty preview has no monetary group; an explicit
|
|
381
|
+
zero remains zero. Invalid or unsupported units and unsafe sums yield an unavailable
|
|
382
|
+
group amount instead of a rounded or invented total.
|
|
383
|
+
|
|
384
|
+
`formatRefundAmount(amount, currency, locale?)` returns a nullable display string
|
|
385
|
+
using package ordinary provider-unit helpers. It preserves observed fractional
|
|
386
|
+
ISK/UGX refunds; display does not establish eligibility for a new partial input.
|
|
387
|
+
The native `RefundHistory` and the Vite render-prop table use this safe formatter.
|
|
388
|
+
Both helpers are public through `/react`, allowing Dojo to supply translated
|
|
389
|
+
Shadcn labels and empty/unavailable states without rebuilding financial arithmetic.
|
|
390
|
+
Preview grouping performs no reads, writes or provider operations and cannot prove
|
|
391
|
+
bank delivery or complete-account earnings. Authorize and bound the source read in
|
|
392
|
+
the host; keep authoritative full-account aggregates separate.
|
|
393
|
+
|
|
265
394
|
## Store-plan pricing editor
|
|
266
395
|
|
|
267
396
|
`PlanPricingEditor` accepts a `plan` with `id`, `name`, `monthlyAmount` in minor
|
|
@@ -272,6 +401,31 @@ your design system. Server-side authorization, fee floors, Stripe Price creation
|
|
|
272
401
|
and conflict checks belong in your backend. Existing subscription migration is
|
|
273
402
|
an application policy, not an automatic side effect of this editor.
|
|
274
403
|
|
|
404
|
+
The plan also accepts optional `currency`, defaulting to `usd` for existing
|
|
405
|
+
consumers. The callback shape stays unchanged. Derive its plan, currency and
|
|
406
|
+
version from authorized server data, validate the stored currency/version again
|
|
407
|
+
before creating a price, and enforce country/account/payment-method support on
|
|
408
|
+
the server. React does not change provider prices or authorize a currency.
|
|
409
|
+
|
|
410
|
+
Initialization uses `chargeAmountToDecimal` to retain exact ASCII decimal
|
|
411
|
+
strings, including the final minor unit at `Number.MAX_SAFE_INTEGER`. Saving
|
|
412
|
+
uses `parseChargeAmount` without floating-point multiplication or rounding.
|
|
413
|
+
JPY/MGA inputs use whole units; ISK/UGX inputs also use whole major units while
|
|
414
|
+
callbacks emit their two-decimal compatibility units. HUF/TWD charge inputs
|
|
415
|
+
retain two decimal places. Unsupported currencies, excess precision, unsafe
|
|
416
|
+
units and nonpositive monthly prices never reach `onSave`. Invalid stored
|
|
417
|
+
amounts initialize blank instead of inventing a valid price.
|
|
418
|
+
|
|
419
|
+
Headless state exposes `currency` and nullable `inputDecimalPlaces` in addition
|
|
420
|
+
to editable strings. Use them for your currency label, input mode and step, as
|
|
421
|
+
the Vite admin store-plans page does. The example's current backend plans remain
|
|
422
|
+
USD; a host with another supported currency must pass its verified plan currency.
|
|
423
|
+
Fields, pending state, errors and prior success messages reset when plan ID,
|
|
424
|
+
version or currency changes. A late save from the previous scope cannot update
|
|
425
|
+
the new editor. Retries retain the current version; server conflict handling and
|
|
426
|
+
idempotency remain the host's responsibility. Fee and affiliate defaults are
|
|
427
|
+
unchanged.
|
|
428
|
+
|
|
275
429
|
`PlanPricingEditor` also supports optional `affiliateBasisPoints` on the plan and
|
|
276
430
|
save update, defaulting to 0. Its render state exposes `affiliateShare` and
|
|
277
431
|
`setAffiliateShare`. The native field is labeled Affiliate payout (%), accepts
|
|
@@ -323,3 +477,15 @@ removes both overrides. The example saves the resolved subscription term in
|
|
|
323
477
|
Stripe metadata at checkout and claims the first paid invoice atomically in its
|
|
324
478
|
Convex ledger; the UI component does not itself create transfers or process
|
|
325
479
|
renewals.
|
|
480
|
+
|
|
481
|
+
### Balance funding server adapter
|
|
482
|
+
|
|
483
|
+
`BalancePaymentSource` and `useBalanceFunding` call host-owned authenticated
|
|
484
|
+
callbacks. Their server adapter can now use the client's
|
|
485
|
+
`prepareBalanceFunding` and `setBalanceFunding` operations. Persist the immutable
|
|
486
|
+
restoration record and explicit consent before enabling, serialize operations per
|
|
487
|
+
subscription, and retain request identities through retries. Opt-out restores the
|
|
488
|
+
original method and types; it does not retry an unpaid invoice or automatically
|
|
489
|
+
fall back to a card. The example demonstrates durable preparation and pending
|
|
490
|
+
operation records in `storeBalanceFunding.ts` with a separate preview client.
|
|
491
|
+
See the [README balance-funding workflow](../README.md#optional-balance-funded-subscriptions).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fantastic.dev/better-stripe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "A Convex component for Stripe V2 Accounts API integration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"stripe",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"dev": "cd example && pnpm run dev",
|
|
70
70
|
"clean": "rm -rf dist",
|
|
71
71
|
"codegen": "pnpm run codegen:lib && pnpm run codegen:example",
|
|
72
|
-
"codegen:lib": "convex codegen --component-dir src/component --typecheck disable",
|
|
72
|
+
"codegen:lib": "cd example && convex codegen --component-dir ../src/component --typecheck disable",
|
|
73
73
|
"codegen:example": "pnpm --filter ./example run codegen",
|
|
74
74
|
"codegen:check": "node scripts/check-codegen-drift.mjs",
|
|
75
75
|
"typecheck": "npm run typecheck:lib && npm run typecheck:example",
|