@fantastic.dev/better-stripe 0.9.0 → 0.10.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 +6 -0
- package/MIGRATION.md +12 -0
- package/README.md +29 -1
- package/dist/client/billing/checkout.d.ts +1 -0
- package/dist/client/billing/checkout.d.ts.map +1 -1
- package/dist/client/billing/checkout.js +5 -1
- package/dist/client/billing/checkout.js.map +1 -1
- package/dist/client/billing/providerReads.d.ts +18 -0
- package/dist/client/billing/providerReads.d.ts.map +1 -0
- package/dist/client/billing/providerReads.js +15 -0
- package/dist/client/billing/providerReads.js.map +1 -0
- package/dist/client/billing/subscriptions.d.ts +1 -1
- package/dist/client/billing/subscriptions.d.ts.map +1 -1
- package/dist/client/billing/subscriptions.js.map +1 -1
- package/dist/client/connect/payoutSnapshot.d.ts +28 -0
- package/dist/client/connect/payoutSnapshot.d.ts.map +1 -0
- package/dist/client/connect/payoutSnapshot.js +81 -0
- package/dist/client/connect/payoutSnapshot.js.map +1 -0
- package/dist/client/connect/transfers.d.ts.map +1 -1
- package/dist/client/connect/transfers.js +13 -32
- package/dist/client/connect/transfers.js.map +1 -1
- package/dist/client/core/accounts.d.ts +12 -23
- package/dist/client/core/accounts.d.ts.map +1 -1
- package/dist/client/core/accounts.js +5 -1
- package/dist/client/core/accounts.js.map +1 -1
- package/dist/client/core/idempotency.d.ts +5 -0
- package/dist/client/core/idempotency.d.ts.map +1 -0
- package/dist/client/core/idempotency.js +10 -0
- package/dist/client/core/idempotency.js.map +1 -0
- package/dist/client/index.d.ts +31 -25
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +29 -52
- package/dist/client/index.js.map +1 -1
- package/dist/client/settlement/allocation.d.ts +30 -0
- package/dist/client/settlement/allocation.d.ts.map +1 -0
- package/dist/client/settlement/allocation.js +71 -0
- package/dist/client/settlement/allocation.js.map +1 -0
- package/dist/client/settlement/commissions.d.ts +27 -0
- package/dist/client/settlement/commissions.d.ts.map +1 -0
- package/dist/client/settlement/commissions.js +69 -0
- package/dist/client/settlement/commissions.js.map +1 -0
- package/dist/client/settlement/execution.d.ts +27 -0
- package/dist/client/settlement/execution.d.ts.map +1 -0
- package/dist/client/settlement/execution.js +70 -0
- package/dist/client/settlement/execution.js.map +1 -0
- package/dist/client/settlement/reconciliation.d.ts +10 -0
- package/dist/client/settlement/reconciliation.d.ts.map +1 -0
- package/dist/client/settlement/reconciliation.js +73 -0
- package/dist/client/settlement/reconciliation.js.map +1 -0
- package/dist/client/settlement/settleSale.d.ts +21 -0
- package/dist/client/settlement/settleSale.d.ts.map +1 -0
- package/dist/client/settlement/settleSale.js +27 -0
- package/dist/client/settlement/settleSale.js.map +1 -0
- package/dist/client/settlement/verifiedSale.d.ts +25 -0
- package/dist/client/settlement/verifiedSale.d.ts.map +1 -0
- package/dist/client/settlement/verifiedSale.js +100 -0
- package/dist/client/settlement/verifiedSale.js.map +1 -0
- package/dist/client/webhooks/asyncHooks.d.ts +5 -0
- package/dist/client/webhooks/asyncHooks.d.ts.map +1 -0
- package/dist/client/webhooks/asyncHooks.js +20 -0
- package/dist/client/webhooks/asyncHooks.js.map +1 -0
- package/dist/component/_generated/component.d.ts +80 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/schema.d.ts +67 -0
- package/dist/component/schema.js +4 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/settlement/mutations.d.ts +47 -0
- package/dist/component/settlement/mutations.d.ts.map +1 -0
- package/dist/component/settlement/mutations.js +104 -0
- package/dist/component/settlement/mutations.js.map +1 -0
- package/dist/component/settlement/queries.d.ts +29 -0
- package/dist/component/settlement/queries.d.ts.map +1 -0
- package/dist/component/settlement/queries.js +35 -0
- package/dist/component/settlement/queries.js.map +1 -0
- package/dist/component/settlement/schema.d.ts +99 -0
- package/dist/component/settlement/schema.d.ts.map +1 -0
- package/dist/component/settlement/schema.js +35 -0
- package/dist/component/settlement/schema.js.map +1 -0
- package/dist/react/workflows/Checkout.d.ts +3 -1
- package/dist/react/workflows/Checkout.d.ts.map +1 -1
- package/dist/react/workflows/Checkout.js +3 -2
- package/dist/react/workflows/Checkout.js.map +1 -1
- package/dist/react/workflows/Payouts.d.ts +3 -18
- package/dist/react/workflows/Payouts.d.ts.map +1 -1
- package/dist/react/workflows/Payouts.js +2 -2
- package/dist/react/workflows/Payouts.js.map +1 -1
- package/docs/react-workflows.md +5 -2
- package/docs/settlement.md +158 -0
- package/package.json +2 -1
- package/src/client/billing/checkout-idempotency.test.ts +82 -0
- package/src/client/billing/checkout.ts +6 -1
- package/src/client/billing/providerReads.test.ts +60 -0
- package/src/client/billing/providerReads.ts +30 -0
- package/src/client/billing/subscriptions.ts +1 -8
- package/src/client/connect/payoutSnapshot.test.ts +91 -0
- package/src/client/connect/payoutSnapshot.ts +130 -0
- package/src/client/connect/transfers.test.ts +15 -4
- package/src/client/connect/transfers.ts +13 -42
- package/src/client/core/account-idempotency.test.ts +78 -0
- package/src/client/core/accounts.ts +18 -25
- package/src/client/core/idempotency.test.ts +10 -0
- package/src/client/core/idempotency.ts +11 -0
- package/src/client/index.ts +84 -103
- package/src/client/settlement/allocation.test.ts +98 -0
- package/src/client/settlement/allocation.ts +110 -0
- package/src/client/settlement/commissions.test.ts +103 -0
- package/src/client/settlement/commissions.ts +125 -0
- package/src/client/settlement/execution.test.ts +186 -0
- package/src/client/settlement/execution.ts +134 -0
- package/src/client/settlement/reconciliation.ts +119 -0
- package/src/client/settlement/settleSale.ts +59 -0
- package/src/client/settlement/verifiedSale.test.ts +139 -0
- package/src/client/settlement/verifiedSale.ts +159 -0
- package/src/client/webhooks/asyncHooks.ts +38 -0
- package/src/client/webhooks/processors.test.ts +9 -9
- package/src/component/_generated/api.ts +4 -0
- package/src/component/_generated/component.ts +100 -0
- package/src/component/schema.ts +8 -0
- package/src/component/settlement/mutations.ts +119 -0
- package/src/component/settlement/queries.ts +38 -0
- package/src/component/settlement/schema.ts +45 -0
- package/src/component/settlement-claims.test.ts +77 -0
- package/src/react/components/EmbeddedDisputes.render.test.tsx +2 -2
- package/src/react/index.payment-element.test.ts +22 -37
- package/src/react/workflows/Checkout.test.tsx +30 -0
- package/src/react/workflows/Checkout.tsx +10 -3
- package/src/react/workflows/Payouts.test.tsx +33 -0
- package/src/react/workflows/Payouts.tsx +21 -15
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { mutation } from "../_generated/server.js";
|
|
3
|
+
import { allocationFields, commissionFields, termValidator } from "./schema.js";
|
|
4
|
+
const doc = v.object({
|
|
5
|
+
...allocationFields,
|
|
6
|
+
_id: v.id("settlementAllocations"),
|
|
7
|
+
_creationTime: v.number(),
|
|
8
|
+
});
|
|
9
|
+
export const reserveSettlementAllocation = mutation({
|
|
10
|
+
args: allocationFields,
|
|
11
|
+
returns: doc,
|
|
12
|
+
handler: async (ctx, args) => {
|
|
13
|
+
const existing = await ctx.db
|
|
14
|
+
.query("settlementAllocations")
|
|
15
|
+
.withIndex("by_source_charge", (q) => q.eq("sourceChargeId", args.sourceChargeId))
|
|
16
|
+
.first();
|
|
17
|
+
if (existing) {
|
|
18
|
+
if (existing.currency !== args.currency ||
|
|
19
|
+
existing.paymentIntentId !== args.paymentIntentId ||
|
|
20
|
+
existing.sourceInvoiceId !== args.sourceInvoiceId)
|
|
21
|
+
throw new Error("Settlement source identity cannot change.");
|
|
22
|
+
return existing;
|
|
23
|
+
}
|
|
24
|
+
const adjustment = args.adjustmentAmount ?? 0;
|
|
25
|
+
const amounts = [
|
|
26
|
+
args.gross,
|
|
27
|
+
args.processingFee,
|
|
28
|
+
args.platformNet,
|
|
29
|
+
...args.transfers.map((t) => t.amount),
|
|
30
|
+
];
|
|
31
|
+
const keys = args.transfers.map((t) => `${t.destinationAccountId}:${t.role}`);
|
|
32
|
+
if (!Number.isSafeInteger(adjustment) ||
|
|
33
|
+
args.processingFee + args.platformNet + adjustment < 0 ||
|
|
34
|
+
amounts.some((n) => !Number.isSafeInteger(n) || n < 0) ||
|
|
35
|
+
args.gross <= 0 ||
|
|
36
|
+
!args.currency ||
|
|
37
|
+
!args.sourceChargeId ||
|
|
38
|
+
args.transfers.some((t) => !t.destinationAccountId) ||
|
|
39
|
+
new Set(keys).size !== keys.length ||
|
|
40
|
+
args.gross !==
|
|
41
|
+
args.processingFee +
|
|
42
|
+
args.platformNet +
|
|
43
|
+
adjustment +
|
|
44
|
+
args.transfers.reduce((sum, t) => sum + t.amount, 0))
|
|
45
|
+
throw new Error("Settlement allocation must reconcile in integer currency units with unique recipient legs.");
|
|
46
|
+
const id = await ctx.db.insert("settlementAllocations", args);
|
|
47
|
+
return (await ctx.db.get("settlementAllocations", id));
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
export const claimCommissionInvoice = mutation({
|
|
51
|
+
args: { ...commissionFields, invoiceId: v.string() },
|
|
52
|
+
returns: v.object({
|
|
53
|
+
eligible: v.boolean(),
|
|
54
|
+
term: termValidator,
|
|
55
|
+
firstPaidInvoiceId: v.string(),
|
|
56
|
+
claimKey: v.string(),
|
|
57
|
+
replay: v.boolean(),
|
|
58
|
+
}),
|
|
59
|
+
handler: async (ctx, args) => {
|
|
60
|
+
let stored = await ctx.db
|
|
61
|
+
.query("commissionTerms")
|
|
62
|
+
.withIndex("by_subscription", (q) => q.eq("subscriptionId", args.subscriptionId))
|
|
63
|
+
.first();
|
|
64
|
+
if (stored && stored.affiliateAccountId !== args.affiliateAccountId)
|
|
65
|
+
throw new Error("Subscription affiliate identity cannot change.");
|
|
66
|
+
if (!stored) {
|
|
67
|
+
const fields = {
|
|
68
|
+
subscriptionId: args.subscriptionId,
|
|
69
|
+
term: args.term,
|
|
70
|
+
affiliateAccountId: args.affiliateAccountId,
|
|
71
|
+
firstPaidInvoiceId: args.firstPaidInvoiceId,
|
|
72
|
+
};
|
|
73
|
+
const id = await ctx.db.insert("commissionTerms", fields);
|
|
74
|
+
stored = (await ctx.db.get("commissionTerms", id));
|
|
75
|
+
}
|
|
76
|
+
const existing = await ctx.db
|
|
77
|
+
.query("commissionDecisions")
|
|
78
|
+
.withIndex("by_subscription_invoice", (q) => q
|
|
79
|
+
.eq("subscriptionId", args.subscriptionId)
|
|
80
|
+
.eq("invoiceId", args.invoiceId))
|
|
81
|
+
.first();
|
|
82
|
+
const claimKey = existing?.claimKey ??
|
|
83
|
+
`commission:${args.subscriptionId}:${args.invoiceId}`;
|
|
84
|
+
const eligible = existing?.eligible ??
|
|
85
|
+
(!!stored.affiliateAccountId &&
|
|
86
|
+
(stored.term === "forever" ||
|
|
87
|
+
args.invoiceId === stored.firstPaidInvoiceId));
|
|
88
|
+
if (!existing)
|
|
89
|
+
await ctx.db.insert("commissionDecisions", {
|
|
90
|
+
subscriptionId: args.subscriptionId,
|
|
91
|
+
invoiceId: args.invoiceId,
|
|
92
|
+
eligible,
|
|
93
|
+
claimKey,
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
eligible,
|
|
97
|
+
term: stored.term,
|
|
98
|
+
firstPaidInvoiceId: stored.firstPaidInvoiceId,
|
|
99
|
+
claimKey,
|
|
100
|
+
replay: !!existing,
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=mutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../../src/component/settlement/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChF,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,GAAG,gBAAgB;IACnB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,uBAAuB,CAAC;IAClC,aAAa,EAAE,CAAC,CAAC,MAAM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EAAE,CAAC;QACX,MAAM,QAAQ,GACZ,QAAQ,EAAE,QAAQ;YAClB,cAAc,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACxD,MAAM,QAAQ,GACZ,QAAQ,EAAE,QAAQ;YAClB,CAAC,CAAC,CAAC,MAAM,CAAC,kBAAkB;gBAC1B,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS;oBACxB,IAAI,CAAC,SAAS,KAAK,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACrD,IAAI,CAAC,QAAQ;YACX,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,qBAAqB,EAAE;gBACzC,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,QAAQ;gBACR,QAAQ;aACT,CAAC,CAAC;QACL,OAAO;YACL,QAAQ;YACR,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;YAC7C,QAAQ;YACR,MAAM,EAAE,CAAC,CAAC,QAAQ;SACnB,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const getSettlementAllocation: import("convex/server").RegisteredQuery<"public", {
|
|
2
|
+
sourceChargeId: string;
|
|
3
|
+
}, Promise<{
|
|
4
|
+
_creationTime: number;
|
|
5
|
+
_id: import("convex/values").GenericId<"settlementAllocations">;
|
|
6
|
+
adjustmentAmount?: number | undefined;
|
|
7
|
+
currency: string;
|
|
8
|
+
gross: number;
|
|
9
|
+
paymentId?: string | undefined;
|
|
10
|
+
paymentIntentId?: string | undefined;
|
|
11
|
+
platformNet: number;
|
|
12
|
+
processingFee: number;
|
|
13
|
+
sourceChargeId: string;
|
|
14
|
+
sourceInvoiceId?: string | undefined;
|
|
15
|
+
transfers: {
|
|
16
|
+
amount: number;
|
|
17
|
+
destinationAccountId: string;
|
|
18
|
+
role: "affiliate" | "other" | "store";
|
|
19
|
+
}[];
|
|
20
|
+
} | null>>;
|
|
21
|
+
export declare const getCommissionTerm: import("convex/server").RegisteredQuery<"public", {
|
|
22
|
+
subscriptionId: string;
|
|
23
|
+
}, Promise<{
|
|
24
|
+
subscriptionId: string;
|
|
25
|
+
term: "forever" | "one_time";
|
|
26
|
+
affiliateAccountId: string | undefined;
|
|
27
|
+
firstPaidInvoiceId: string;
|
|
28
|
+
} | null>>;
|
|
29
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/settlement/queries.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;UAUlC,CAAC;AACH,eAAO,MAAM,iBAAiB;;;;;;;UAkB5B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { query } from "../_generated/server.js";
|
|
3
|
+
import { allocationFields, commissionFields } from "./schema.js";
|
|
4
|
+
const doc = v.object({
|
|
5
|
+
...allocationFields,
|
|
6
|
+
_id: v.id("settlementAllocations"),
|
|
7
|
+
_creationTime: v.number(),
|
|
8
|
+
});
|
|
9
|
+
export const getSettlementAllocation = query({
|
|
10
|
+
args: { sourceChargeId: v.string() },
|
|
11
|
+
returns: v.union(doc, v.null()),
|
|
12
|
+
handler: (ctx, args) => ctx.db
|
|
13
|
+
.query("settlementAllocations")
|
|
14
|
+
.withIndex("by_source_charge", (q) => q.eq("sourceChargeId", args.sourceChargeId))
|
|
15
|
+
.first(),
|
|
16
|
+
});
|
|
17
|
+
export const getCommissionTerm = query({
|
|
18
|
+
args: { subscriptionId: v.string() },
|
|
19
|
+
returns: v.union(v.object(commissionFields), v.null()),
|
|
20
|
+
handler: async (ctx, args) => {
|
|
21
|
+
const row = await ctx.db
|
|
22
|
+
.query("commissionTerms")
|
|
23
|
+
.withIndex("by_subscription", (q) => q.eq("subscriptionId", args.subscriptionId))
|
|
24
|
+
.first();
|
|
25
|
+
if (!row)
|
|
26
|
+
return null;
|
|
27
|
+
return {
|
|
28
|
+
subscriptionId: row.subscriptionId,
|
|
29
|
+
term: row.term,
|
|
30
|
+
affiliateAccountId: row.affiliateAccountId,
|
|
31
|
+
firstPaidInvoiceId: row.firstPaidInvoiceId,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/component/settlement/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACjE,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,GAAG,gBAAgB;IACnB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,uBAAuB,CAAC;IAClC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;CAC1B,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;IAC3C,IAAI,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE;IACpC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/B,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CACrB,GAAG,CAAC,EAAE;SACH,KAAK,CAAC,uBAAuB,CAAC;SAC9B,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,EAAE,CACnC,CAAC,CAAC,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,cAAc,CAAC,CAC5C;SACA,KAAK,EAAE;CACb,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;IACrC,IAAI,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE;IACpC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACtD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,EAAE;aACrB,KAAK,CAAC,iBAAiB,CAAC;aACxB,SAAS,CAAC,iBAAiB,EAAE,CAAC,CAAC,EAAE,EAAE,CAClC,CAAC,CAAC,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,cAAc,CAAC,CAC5C;aACA,KAAK,EAAE,CAAC;QACX,IAAI,CAAC,GAAG;YAAE,OAAO,IAAI,CAAC;QACtB,OAAO;YACL,cAAc,EAAE,GAAG,CAAC,cAAc;YAClC,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,kBAAkB,EAAE,GAAG,CAAC,kBAAkB;YAC1C,kBAAkB,EAAE,GAAG,CAAC,kBAAkB;SAC3C,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export declare const termValidator: import("convex/values").VUnion<"forever" | "one_time", [import("convex/values").VLiteral<"forever", "required">, import("convex/values").VLiteral<"one_time", "required">], "required", never>;
|
|
2
|
+
export declare const allocationFields: {
|
|
3
|
+
sourceChargeId: import("convex/values").VString<string, "required">;
|
|
4
|
+
paymentIntentId: import("convex/values").VString<string | undefined, "optional">;
|
|
5
|
+
sourceInvoiceId: import("convex/values").VString<string | undefined, "optional">;
|
|
6
|
+
gross: import("convex/values").VFloat64<number, "required">;
|
|
7
|
+
currency: import("convex/values").VString<string, "required">;
|
|
8
|
+
processingFee: import("convex/values").VFloat64<number, "required">;
|
|
9
|
+
platformNet: import("convex/values").VFloat64<number, "required">;
|
|
10
|
+
adjustmentAmount: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
11
|
+
paymentId: import("convex/values").VString<string | undefined, "optional">;
|
|
12
|
+
transfers: import("convex/values").VArray<{
|
|
13
|
+
amount: number;
|
|
14
|
+
destinationAccountId: string;
|
|
15
|
+
role: "affiliate" | "other" | "store";
|
|
16
|
+
}[], import("convex/values").VObject<{
|
|
17
|
+
amount: number;
|
|
18
|
+
destinationAccountId: string;
|
|
19
|
+
role: "affiliate" | "other" | "store";
|
|
20
|
+
}, {
|
|
21
|
+
destinationAccountId: import("convex/values").VString<string, "required">;
|
|
22
|
+
role: import("convex/values").VUnion<"affiliate" | "other" | "store", [import("convex/values").VLiteral<"store", "required">, import("convex/values").VLiteral<"affiliate", "required">, import("convex/values").VLiteral<"other", "required">], "required", never>;
|
|
23
|
+
amount: import("convex/values").VFloat64<number, "required">;
|
|
24
|
+
}, "required", "amount" | "destinationAccountId" | "role">, "required">;
|
|
25
|
+
};
|
|
26
|
+
export declare const allocationsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
27
|
+
adjustmentAmount?: number | undefined;
|
|
28
|
+
currency: string;
|
|
29
|
+
gross: number;
|
|
30
|
+
paymentId?: string | undefined;
|
|
31
|
+
paymentIntentId?: string | undefined;
|
|
32
|
+
platformNet: number;
|
|
33
|
+
processingFee: number;
|
|
34
|
+
sourceChargeId: string;
|
|
35
|
+
sourceInvoiceId?: string | undefined;
|
|
36
|
+
transfers: {
|
|
37
|
+
amount: number;
|
|
38
|
+
destinationAccountId: string;
|
|
39
|
+
role: "affiliate" | "other" | "store";
|
|
40
|
+
}[];
|
|
41
|
+
}, {
|
|
42
|
+
sourceChargeId: import("convex/values").VString<string, "required">;
|
|
43
|
+
paymentIntentId: import("convex/values").VString<string | undefined, "optional">;
|
|
44
|
+
sourceInvoiceId: import("convex/values").VString<string | undefined, "optional">;
|
|
45
|
+
gross: import("convex/values").VFloat64<number, "required">;
|
|
46
|
+
currency: import("convex/values").VString<string, "required">;
|
|
47
|
+
processingFee: import("convex/values").VFloat64<number, "required">;
|
|
48
|
+
platformNet: import("convex/values").VFloat64<number, "required">;
|
|
49
|
+
adjustmentAmount: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
50
|
+
paymentId: import("convex/values").VString<string | undefined, "optional">;
|
|
51
|
+
transfers: import("convex/values").VArray<{
|
|
52
|
+
amount: number;
|
|
53
|
+
destinationAccountId: string;
|
|
54
|
+
role: "affiliate" | "other" | "store";
|
|
55
|
+
}[], import("convex/values").VObject<{
|
|
56
|
+
amount: number;
|
|
57
|
+
destinationAccountId: string;
|
|
58
|
+
role: "affiliate" | "other" | "store";
|
|
59
|
+
}, {
|
|
60
|
+
destinationAccountId: import("convex/values").VString<string, "required">;
|
|
61
|
+
role: import("convex/values").VUnion<"affiliate" | "other" | "store", [import("convex/values").VLiteral<"store", "required">, import("convex/values").VLiteral<"affiliate", "required">, import("convex/values").VLiteral<"other", "required">], "required", never>;
|
|
62
|
+
amount: import("convex/values").VFloat64<number, "required">;
|
|
63
|
+
}, "required", "amount" | "destinationAccountId" | "role">, "required">;
|
|
64
|
+
}, "required", "adjustmentAmount" | "currency" | "gross" | "paymentId" | "paymentIntentId" | "platformNet" | "processingFee" | "sourceChargeId" | "sourceInvoiceId" | "transfers">, {
|
|
65
|
+
by_source_charge: ["sourceChargeId", "_creationTime"];
|
|
66
|
+
}, {}, {}>;
|
|
67
|
+
export declare const commissionFields: {
|
|
68
|
+
subscriptionId: import("convex/values").VString<string, "required">;
|
|
69
|
+
term: import("convex/values").VUnion<"forever" | "one_time", [import("convex/values").VLiteral<"forever", "required">, import("convex/values").VLiteral<"one_time", "required">], "required", never>;
|
|
70
|
+
affiliateAccountId: import("convex/values").VString<string | undefined, "optional">;
|
|
71
|
+
firstPaidInvoiceId: import("convex/values").VString<string, "required">;
|
|
72
|
+
};
|
|
73
|
+
export declare const commissionTermsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
74
|
+
affiliateAccountId?: string | undefined;
|
|
75
|
+
firstPaidInvoiceId: string;
|
|
76
|
+
subscriptionId: string;
|
|
77
|
+
term: "forever" | "one_time";
|
|
78
|
+
}, {
|
|
79
|
+
subscriptionId: import("convex/values").VString<string, "required">;
|
|
80
|
+
term: import("convex/values").VUnion<"forever" | "one_time", [import("convex/values").VLiteral<"forever", "required">, import("convex/values").VLiteral<"one_time", "required">], "required", never>;
|
|
81
|
+
affiliateAccountId: import("convex/values").VString<string | undefined, "optional">;
|
|
82
|
+
firstPaidInvoiceId: import("convex/values").VString<string, "required">;
|
|
83
|
+
}, "required", "affiliateAccountId" | "firstPaidInvoiceId" | "subscriptionId" | "term">, {
|
|
84
|
+
by_subscription: ["subscriptionId", "_creationTime"];
|
|
85
|
+
}, {}, {}>;
|
|
86
|
+
export declare const commissionDecisionsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
87
|
+
claimKey: string;
|
|
88
|
+
eligible: boolean;
|
|
89
|
+
invoiceId: string;
|
|
90
|
+
subscriptionId: string;
|
|
91
|
+
}, {
|
|
92
|
+
subscriptionId: import("convex/values").VString<string, "required">;
|
|
93
|
+
invoiceId: import("convex/values").VString<string, "required">;
|
|
94
|
+
eligible: import("convex/values").VBoolean<boolean, "required">;
|
|
95
|
+
claimKey: import("convex/values").VString<string, "required">;
|
|
96
|
+
}, "required", "claimKey" | "eligible" | "invoiceId" | "subscriptionId">, {
|
|
97
|
+
by_subscription_invoice: ["subscriptionId", "invoiceId", "_creationTime"];
|
|
98
|
+
}, {}, {}>;
|
|
99
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/settlement/schema.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,gMAGzB,CAAC;AACF,eAAO,MAAM,gBAAgB;IAC3B,cAAc;IACd,eAAe;IACf,eAAe;IACf,KAAK;IACL,QAAQ;IACR,aAAa;IACb,WAAW;IACX,gBAAgB;IAChB,SAAS;IACT,SAAS;;;;;;;;;;;;;CAOV,CAAC;AACF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAG5B,CAAC;AACF,eAAO,MAAM,gBAAgB;IAC3B,cAAc;IACd,IAAI;IACJ,kBAAkB;IAClB,kBAAkB;CACnB,CAAC;AACF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;UAGhC,CAAC;AACF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;UAK+B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineTable } from "convex/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
import { splitRecipientRoleValidator } from "../lib/fees.js";
|
|
4
|
+
export const termValidator = v.union(v.literal("forever"), v.literal("one_time"));
|
|
5
|
+
export const allocationFields = {
|
|
6
|
+
sourceChargeId: v.string(),
|
|
7
|
+
paymentIntentId: v.optional(v.string()),
|
|
8
|
+
sourceInvoiceId: v.optional(v.string()),
|
|
9
|
+
gross: v.number(),
|
|
10
|
+
currency: v.string(),
|
|
11
|
+
processingFee: v.number(),
|
|
12
|
+
platformNet: v.number(),
|
|
13
|
+
adjustmentAmount: v.optional(v.number()),
|
|
14
|
+
paymentId: v.optional(v.string()),
|
|
15
|
+
transfers: v.array(v.object({
|
|
16
|
+
destinationAccountId: v.string(),
|
|
17
|
+
role: splitRecipientRoleValidator,
|
|
18
|
+
amount: v.number(),
|
|
19
|
+
})),
|
|
20
|
+
};
|
|
21
|
+
export const allocationsTable = defineTable(allocationFields).index("by_source_charge", ["sourceChargeId"]);
|
|
22
|
+
export const commissionFields = {
|
|
23
|
+
subscriptionId: v.string(),
|
|
24
|
+
term: termValidator,
|
|
25
|
+
affiliateAccountId: v.optional(v.string()),
|
|
26
|
+
firstPaidInvoiceId: v.string(),
|
|
27
|
+
};
|
|
28
|
+
export const commissionTermsTable = defineTable(commissionFields).index("by_subscription", ["subscriptionId"]);
|
|
29
|
+
export const commissionDecisionsTable = defineTable({
|
|
30
|
+
subscriptionId: v.string(),
|
|
31
|
+
invoiceId: v.string(),
|
|
32
|
+
eligible: v.boolean(),
|
|
33
|
+
claimKey: v.string(),
|
|
34
|
+
}).index("by_subscription_invoice", ["subscriptionId", "invoiceId"]);
|
|
35
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/component/settlement/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAClC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CACtB,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,eAAe,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACvC,eAAe,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACvC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,gBAAgB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACxC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACjC,SAAS,EAAE,CAAC,CAAC,KAAK,CAChB,CAAC,CAAC,MAAM,CAAC;QACP,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE;QAChC,IAAI,EAAE,2BAA2B;QACjC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;KACnB,CAAC,CACH;CACF,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC,gBAAgB,CAAC,CAAC,KAAK,CACjE,kBAAkB,EAClB,CAAC,gBAAgB,CAAC,CACnB,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,IAAI,EAAE,aAAa;IACnB,kBAAkB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1C,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE;CAC/B,CAAC;AACF,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAC,gBAAgB,CAAC,CAAC,KAAK,CACrE,iBAAiB,EACjB,CAAC,gBAAgB,CAAC,CACnB,CAAC;AACF,MAAM,CAAC,MAAM,wBAAwB,GAAG,WAAW,CAAC;IAClD,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
2
|
import { type CheckoutFormOptions } from "./CheckoutForms.js";
|
|
3
3
|
export type CheckoutMode = "redirect" | "embedded" | "custom" | "form" | "payment-intent";
|
|
4
4
|
export type CheckoutSessionResult = {
|
|
@@ -27,6 +27,8 @@ type Common = CheckoutFormOptions & {
|
|
|
27
27
|
publishableKey: string;
|
|
28
28
|
/** Changes when the price, signed-in customer, or referral attribution changes. */
|
|
29
29
|
orderKey: string;
|
|
30
|
+
/** Optional durable logical-order identity, persisted by the host app. */
|
|
31
|
+
requestId?: string;
|
|
30
32
|
returnUrl: string;
|
|
31
33
|
onNavigate?: (url: string) => void;
|
|
32
34
|
children?: (state: CheckoutRenderProps) => ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/Checkout.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/Checkout.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGjD,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAC;AAC5B,MAAM,MAAM,YAAY,GACtB,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,GAAG,gBAAgB,CAAC;AACjE,MAAM,MAAM,qBAAqB,GAAG;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAC9C,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,SAAS,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;CACjC,CAAC;AACF,KAAK,MAAM,GAAG,mBAAmB,GAAG;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,mFAAmF;IACnF,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,SAAS,CAAC;CACtD,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,MAAM,GAChC,CACI;IACE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAC9C,aAAa,EAAE,CACb,OAAO,EAAE,eAAe,KACrB,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACrC,GACD;IACE,IAAI,EAAE,gBAAgB,CAAC;IACvB,mBAAmB,EAAE,CAAC,OAAO,EAAE;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACrC,CACJ,CAAC;AACJ,6HAA6H;AAC7H,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,+BAO5C"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
3
4
|
import { EmbeddedCheckout } from "../components/EmbeddedCheckout.js";
|
|
4
5
|
import { useWorkflowResource } from "./useWorkflowResource.js";
|
|
5
6
|
import { CheckoutElementsForm, PaymentIntentForm, CheckoutForm, } from "./CheckoutForms.js";
|
|
6
7
|
/** All checkout integrations share one unstyled lifecycle. Callbacks must authenticate and validate prices on the server. */
|
|
7
8
|
export function Checkout(props) {
|
|
8
|
-
return _jsx(CheckoutBody, { ...props }, `${props.orderKey}:${props.mode}`);
|
|
9
|
+
return (_jsx(CheckoutBody, { ...props }, `${props.orderKey}:${props.mode}:${props.requestId ?? ""}`));
|
|
9
10
|
}
|
|
10
11
|
function CheckoutBody(props) {
|
|
12
|
+
const [requestId] = useState(() => props.requestId ?? crypto.randomUUID());
|
|
11
13
|
const state = useWorkflowResource(async () => {
|
|
12
|
-
const requestId = crypto.randomUUID();
|
|
13
14
|
const result = props.mode === "payment-intent"
|
|
14
15
|
? await props.createPaymentIntent({ requestId })
|
|
15
16
|
: await props.createSession({ mode: props.mode, requestId });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../../../src/react/workflows/Checkout.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;
|
|
1
|
+
{"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../../../src/react/workflows/Checkout.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,GAEb,MAAM,oBAAoB,CAAC;AAkD5B,6HAA6H;AAC7H,MAAM,UAAU,QAAQ,CAAC,KAAoB;IAC3C,OAAO,CACL,KAAC,YAAY,OAEP,KAAK,IADJ,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,SAAS,IAAI,EAAE,EAAE,CAE/D,CACH,CAAC;AACJ,CAAC;AACD,SAAS,YAAY,CAAC,KAAoB;IACxC,MAAM,CAAC,SAAS,CAAC,GAA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CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,MAAM,GAAwB;QAClC,OAAO;QACP,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,KAAK,EAAE,KAAK,CAAC,OAAO;QACpB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,SAAS;QACT,kBAAkB,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;KACtE,CAAC;IACF,OAAO,4BAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,GAAI,CAAC;AAClE,CAAC"}
|
|
@@ -1,24 +1,9 @@
|
|
|
1
|
+
import type { RecipientPayoutSnapshot, RecipientPayoutRow } from "../../client/connect/payoutSnapshot.js";
|
|
1
2
|
import { type ReactNode } from "react";
|
|
2
3
|
import { type ConnectProps } from "./Connect.js";
|
|
3
4
|
import { type CollectionProps, type WorkflowColumn } from "./Collection.js";
|
|
4
|
-
export type PayoutRow =
|
|
5
|
-
|
|
6
|
-
amount: number;
|
|
7
|
-
currency: string;
|
|
8
|
-
status: string;
|
|
9
|
-
/** Unix milliseconds. */ arrivalDate: number | null;
|
|
10
|
-
created: number;
|
|
11
|
-
};
|
|
12
|
-
export type PayoutSnapshot = {
|
|
13
|
-
balances: {
|
|
14
|
-
currency: string;
|
|
15
|
-
available: number;
|
|
16
|
-
pending: number;
|
|
17
|
-
}[];
|
|
18
|
-
payouts: PayoutRow[];
|
|
19
|
-
upcoming: PayoutRow[];
|
|
20
|
-
nextCursor: string | null;
|
|
21
|
-
};
|
|
5
|
+
export type PayoutRow = RecipientPayoutRow;
|
|
6
|
+
export type PayoutSnapshot = Pick<RecipientPayoutSnapshot, "balances" | "payouts" | "upcoming" | "nextCursor"> & Partial<Pick<RecipientPayoutSnapshot, "status" | "reason" | "upcomingComplete">>;
|
|
22
7
|
export type PayoutsRenderProps = {
|
|
23
8
|
data: PayoutSnapshot | undefined;
|
|
24
9
|
error: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Payouts.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/Payouts.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,SAAS,GAAG
|
|
1
|
+
{"version":3,"file":"Payouts.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/Payouts.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,SAAS,GAAG,kBAAkB,CAAC;AAC3C,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,uBAAuB,EACvB,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,CACnD,GACC,OAAO,CACL,IAAI,CAAC,uBAAuB,EAAE,QAAQ,GAAG,QAAQ,GAAG,kBAAkB,CAAC,CACxE,CAAC;AACJ,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,cAAc,GAAG,SAAS,CAAC;IACjC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,SAAS,GAAG,SAAS,CAAC;IAClC,eAAe,EAAE,SAAS,EAAE,CAAC;IAC7B,eAAe,EAAE,SAAS,EAAE,CAAC;IAC7B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACnD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,SAAS,CAAC;CACrD,CAAC;AACF,MAAM,MAAM,YAAY,GACpB,oBAAoB,GACpB,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,GAAG;IAAE,YAAY,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC;AAGrE,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,+BAM1C;AA+DD,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,SAAS,EACT,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,CACxD,CAAC;AACF,MAAM,MAAM,kBAAkB,CAC5B,GAAG,SAAS,gBAAgB,GAAG,gBAAgB,IAC7C,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,GAAG;IACrD,OAAO,CAAC,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;CACjC,CAAC;AACF,wBAAgB,aAAa,CAAC,GAAG,SAAS,gBAAgB,EACxD,KAAK,EAAE,kBAAkB,CAAC,GAAG,CAAC,+BAyB/B"}
|
|
@@ -79,9 +79,9 @@ export function PayoutHistory(props) {
|
|
|
79
79
|
return (_jsx(Collection, { emptyLabel: "No payouts yet.", ...props, getKey: (row) => row.id, columns: props.columns ?? columns }));
|
|
80
80
|
}
|
|
81
81
|
function NativePayouts({ data, isLoading, isPending, error, nextPayout, previousPayouts, upcomingPayouts, refresh, loadMore, }) {
|
|
82
|
-
return (_jsxs("section", { "data-better-stripe": "payouts", "aria-busy": isPending, children: [_jsx("h2", { children: "Payouts" }), _jsx("button", { type: "button", disabled: isPending, onClick: refresh, children: isPending ? "Refreshing…" : "Refresh" }), error && _jsx("p", { role: "alert", children: error }), isLoading && !data && _jsx("p", { role: "status", children: "Loading payouts\u2026" }), data && (_jsxs(_Fragment, { children: [_jsxs("dl", { children: [data.balances.map((balance) => (_jsxs("div", { children: [_jsx("dt", { children: "Available" }), _jsx("dd", { children: formatPrice(balance.available, balance.currency) }), _jsx("dt", { children: "Pending" }), _jsx("dd", { children: formatPrice(balance.pending, balance.currency) })] }, balance.currency))), _jsx("dt", { children: "Next payout" }), _jsx("dd", { children: nextPayout
|
|
82
|
+
return (_jsxs("section", { "data-better-stripe": "payouts", "aria-busy": isPending, children: [_jsx("h2", { children: "Payouts" }), _jsx("button", { type: "button", disabled: isPending, onClick: refresh, children: isPending ? "Refreshing…" : "Refresh" }), error && _jsx("p", { role: "alert", children: error }), isLoading && !data && _jsx("p", { role: "status", children: "Loading payouts\u2026" }), data?.status === "not_ready" && (_jsx("p", { role: "alert", children: "Stripe account data is not available yet." })), data && data.status !== "not_ready" && (_jsxs(_Fragment, { children: [_jsxs("dl", { children: [data.balances.map((balance) => (_jsxs("div", { children: [_jsx("dt", { children: "Available" }), _jsx("dd", { children: formatPrice(balance.available, balance.currency) }), _jsx("dt", { children: "Pending" }), _jsx("dd", { children: formatPrice(balance.pending, balance.currency) })] }, balance.currency))), _jsx("dt", { children: "Next payout" }), _jsx("dd", { children: nextPayout
|
|
83
83
|
? `${formatPrice(nextPayout.amount, nextPayout.currency)} · ${date(nextPayout.arrivalDate)}`
|
|
84
|
-
: "Not scheduled" })] }), _jsx("h3", { children: "Upcoming payouts" }), _jsx(PayoutHistory, { rows: upcomingPayouts, emptyLabel: "No upcoming payouts scheduled." }), _jsx("h3", { children: "Previous payouts" }), _jsx(PayoutHistory, { rows: previousPayouts, emptyLabel: "No previous payouts yet." }), data.nextCursor && (_jsx("button", { type: "button", disabled: isPending, onClick: () => {
|
|
84
|
+
: "Not scheduled" })] }), _jsx("h3", { children: "Upcoming payouts" }), data.upcomingComplete === false && (_jsx("p", { children: "Upcoming payouts are a bounded preview. More may be scheduled." })), _jsx(PayoutHistory, { rows: upcomingPayouts, emptyLabel: "No upcoming payouts scheduled." }), _jsx("h3", { children: "Previous payouts" }), _jsx(PayoutHistory, { rows: previousPayouts, emptyLabel: "No previous payouts yet." }), data.nextCursor && (_jsx("button", { type: "button", disabled: isPending, onClick: () => {
|
|
85
85
|
void loadMore();
|
|
86
86
|
}, children: isPending ? "Loading…" : "Load more payouts" }))] }))] }));
|
|
87
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Payouts.js","sourceRoot":"","sources":["../../../src/react/workflows/Payouts.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;
|
|
1
|
+
{"version":3,"file":"Payouts.js","sourceRoot":"","sources":["../../../src/react/workflows/Payouts.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAKb,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,UAAU,GAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AA6BtD,MAAM,QAAQ,GAAG,CAAC,GAAc,EAAE,EAAE,CAClC,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,KAAK,YAAY,CAAC;AAC1D,MAAM,UAAU,OAAO,CAAC,KAAmB;IACzC,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AC,EAAE;oCAC5F,CAAC,CAAC,eAAe,GAChB,IACF,EACL,4CAAyB,EACxB,IAAI,CAAC,gBAAgB,KAAK,KAAK,IAAI,CAClC,yFAEI,CACL,EACD,KAAC,aAAa,IACZ,IAAI,EAAE,eAAe,EACrB,UAAU,EAAC,gCAAgC,GAC3C,EACF,4CAAyB,EACzB,KAAC,aAAa,IACZ,IAAI,EAAE,eAAe,EACrB,UAAU,EAAC,0BAA0B,GACrC,EACD,IAAI,CAAC,UAAU,IAAI,CAClB,iBACE,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,GAAG,EAAE;4BACZ,KAAK,QAAQ,EAAE,CAAC;wBAClB,CAAC,YAEA,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,mBAAmB,GACtC,CACV,IACA,CACJ,IACO,CACX,CAAC;AACJ,CAAC"}
|
package/docs/react-workflows.md
CHANGED
|
@@ -52,8 +52,11 @@ function Purchase({ publishableKey, priceId, createSession }) {
|
|
|
52
52
|
|
|
53
53
|
The callback returns `{ stripeSessionId, clientSecret?, url? }`. It must return
|
|
54
54
|
`url` for `redirect` and `clientSecret` for the other session modes. Use the
|
|
55
|
-
request ID for server idempotency.
|
|
56
|
-
|
|
55
|
+
request ID for server idempotency. Retries and rerenders preserve the same ID.
|
|
56
|
+
Changing `orderKey` or checkout mode starts a new logical request. Pass a persisted
|
|
57
|
+
`requestId` prop to preserve identity across unmounts or page reloads. Forward it
|
|
58
|
+
to your authenticated server and Stripe request options; also enforce durable
|
|
59
|
+
application-level duplicate-order protection.
|
|
57
60
|
|
|
58
61
|
| Mode | Stripe integration | Tradeoff |
|
|
59
62
|
| ---------------- | ------------------------------------- | ---------------------------------------------------------------------- |
|