@fantastic.dev/better-stripe 0.4.0 → 0.5.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 +34 -0
- package/MIGRATION.md +135 -0
- package/README.md +23 -2
- package/dist/client/billing/checkout.d.ts.map +1 -1
- package/dist/client/billing/checkout.js +22 -8
- package/dist/client/billing/checkout.js.map +1 -1
- package/dist/client/billing/subscriptionRouting.d.ts +24 -0
- package/dist/client/billing/subscriptionRouting.d.ts.map +1 -0
- package/dist/client/billing/subscriptionRouting.js +19 -0
- package/dist/client/billing/subscriptionRouting.js.map +1 -0
- package/dist/client/billing/subscriptions.d.ts +6 -6
- package/dist/client/billing/subscriptions.d.ts.map +1 -1
- package/dist/client/billing/subscriptions.js +31 -12
- package/dist/client/billing/subscriptions.js.map +1 -1
- package/dist/client/connect/disputes.js.map +1 -1
- package/dist/client/constants.js +1 -1
- package/dist/client/core/accountLinks.d.ts +1 -0
- package/dist/client/core/accountLinks.d.ts.map +1 -1
- package/dist/client/core/accountLinks.js +0 -6
- package/dist/client/core/accountLinks.js.map +1 -1
- package/dist/client/core/accountStatus.d.ts.map +1 -1
- package/dist/client/core/accountStatus.js +23 -8
- package/dist/client/core/accountStatus.js.map +1 -1
- package/dist/client/index.d.ts +5 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/types/documents.d.ts +1 -0
- package/dist/client/types/documents.d.ts.map +1 -1
- package/dist/client/types/events.d.ts +2 -1
- package/dist/client/types/events.d.ts.map +1 -1
- package/dist/client/types/options.d.ts +7 -0
- package/dist/client/types/options.d.ts.map +1 -1
- package/dist/client/utils/stripeDashboardUrl.d.ts.map +1 -1
- package/dist/client/utils/webhookEndpoints.d.ts.map +1 -1
- package/dist/client/webhooks/handler.d.ts.map +1 -1
- package/dist/client/webhooks/handler.js +35 -1
- package/dist/client/webhooks/handler.js.map +1 -1
- package/dist/client/webhooks/hooks.d.ts +1 -1
- package/dist/client/webhooks/hooks.d.ts.map +1 -1
- package/dist/client/webhooks/hooks.js +5 -1
- package/dist/client/webhooks/hooks.js.map +1 -1
- package/dist/client/webhooks/processors.d.ts.map +1 -1
- package/dist/client/webhooks/processors.js +12 -2
- package/dist/client/webhooks/processors.js.map +1 -1
- package/dist/client/webhooks/v2.d.ts.map +1 -1
- package/dist/client/webhooks/v2.js +11 -3
- package/dist/client/webhooks/v2.js.map +1 -1
- package/dist/component/_generated/component.d.ts +8 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/_generated/server.d.ts +7 -1
- package/dist/component/_generated/server.d.ts.map +1 -1
- package/dist/component/_generated/server.js +2 -1
- package/dist/component/_generated/server.js.map +1 -1
- package/dist/component/billing/mutations.d.ts +29 -28
- package/dist/component/billing/mutations.d.ts.map +1 -1
- package/dist/component/billing/mutations.js +1 -0
- package/dist/component/billing/mutations.js.map +1 -1
- package/dist/component/billing/queries.d.ts +138 -131
- package/dist/component/billing/queries.d.ts.map +1 -1
- package/dist/component/billing/schema.d.ts +67 -65
- package/dist/component/billing/schema.d.ts.map +1 -1
- package/dist/component/billing/validators.d.ts +94 -91
- package/dist/component/billing/validators.d.ts.map +1 -1
- package/dist/component/billing/validators.js +1 -0
- package/dist/component/billing/validators.js.map +1 -1
- package/dist/component/connect/mutations.d.ts +37 -37
- package/dist/component/connect/queries.d.ts +115 -115
- package/dist/component/connect/queries.d.ts.map +1 -1
- package/dist/component/connect/queries.js +34 -71
- package/dist/component/connect/queries.js.map +1 -1
- package/dist/component/connect/schema.d.ts +73 -73
- package/dist/component/connect/validators.d.ts +119 -119
- package/dist/component/connect/validators.d.ts.map +1 -1
- package/dist/component/convex.config.d.ts +1 -0
- package/dist/component/convex.config.d.ts.map +1 -1
- package/dist/component/convex.config.js +2 -1
- package/dist/component/convex.config.js.map +1 -1
- package/dist/component/core/mutations.d.ts +12 -12
- package/dist/component/core/queries.d.ts +34 -34
- package/dist/component/core/schema.d.ts +11 -11
- package/dist/component/core/validators.d.ts +14 -14
- package/dist/component/core/validators.d.ts.map +1 -1
- package/dist/component/lib/fees.d.ts +12 -12
- package/dist/component/lib/fees.d.ts.map +1 -1
- package/dist/component/lib/fees.js +1 -1
- package/dist/component/lib/reversals.js.map +1 -1
- package/dist/component/products/mutations.d.ts +7 -7
- package/dist/component/products/queries.d.ts +33 -33
- package/dist/component/products/schema.d.ts +15 -15
- package/dist/component/products/validators.d.ts +16 -16
- package/dist/component/products/validators.d.ts.map +1 -1
- package/dist/component/schema.d.ts +173 -171
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/webhooks/mutations.d.ts +3 -3
- package/dist/component/webhooks/queries.d.ts +12 -12
- package/dist/component/webhooks/schema.d.ts +7 -7
- package/dist/component/webhooks/validators.d.ts +10 -10
- package/dist/component/webhooks/validators.d.ts.map +1 -1
- package/dist/react/components/AccountCreateCard.js.map +1 -1
- package/dist/react/components/BuyerBillingView.js +1 -1
- package/dist/react/components/CheckoutSessionProviderWithKey.d.ts +1 -1
- package/dist/react/components/DisputeDetail.js +1 -1
- package/dist/react/components/DisputesList.js +1 -1
- package/dist/react/components/EarningsSummary.js +1 -1
- package/dist/react/components/EmbeddedCheckout.d.ts.map +1 -1
- package/dist/react/components/EmbeddedCheckout.js +1 -1
- package/dist/react/components/EmbeddedCheckout.js.map +1 -1
- package/dist/react/components/PayoutSchedule.js +1 -1
- package/dist/react/components/SplitBreakdown.js +1 -1
- package/dist/react/components/StripeProvider.d.ts +1 -1
- package/dist/react/components/StripeProviderWithKey.d.ts +1 -1
- package/dist/react/hooks/useAccount.d.ts.map +1 -1
- package/dist/react/hooks/useAccountOnboarding.d.ts.map +1 -1
- package/dist/react/hooks/useCheckout.d.ts.map +1 -1
- package/dist/react/hooks/useDisputeWithCountdown.d.ts.map +1 -1
- package/dist/react/hooks/useDisputes.d.ts.map +1 -1
- package/dist/react/hooks/useEarnings.d.ts.map +1 -1
- package/dist/react/hooks/useInvoices.d.ts.map +1 -1
- package/dist/react/hooks/usePaymentMethodActions.js.map +1 -1
- package/dist/react/hooks/usePaymentMethods.d.ts.map +1 -1
- package/dist/react/hooks/usePrices.d.ts.map +1 -1
- package/dist/react/hooks/useProducts.d.ts.map +1 -1
- package/dist/react/hooks/useSplitBreakdown.d.ts.map +1 -1
- package/dist/react/hooks/useSubscription.d.ts.map +1 -1
- package/dist/react/hooks/useSubscriptions.d.ts.map +1 -1
- package/dist/react/lib/stripe-element-styles.d.ts.map +1 -1
- package/dist/react/lib/stripe-element-styles.js.map +1 -1
- package/package.json +25 -23
- package/src/client/billing/checkout.test.ts +62 -14
- package/src/client/billing/checkout.ts +26 -10
- package/src/client/billing/subscriptionRouting.ts +25 -0
- package/src/client/billing/subscriptions.test.ts +90 -28
- package/src/client/billing/subscriptions.ts +53 -18
- package/src/client/constants.ts +1 -1
- package/src/client/core/accountLinks.test.ts +20 -13
- package/src/client/core/accountLinks.ts +2 -10
- package/src/client/core/accountStatus.test.ts +67 -0
- package/src/client/core/accountStatus.ts +30 -13
- package/src/client/helpers.test.ts +2 -2
- package/src/client/index.ts +49 -44
- package/src/client/stripe-version.test.ts +47 -0
- package/src/client/types/documents.ts +1 -0
- package/src/client/types/events.ts +2 -1
- package/src/client/types/options.ts +7 -0
- package/src/client/webhooks/handler.ts +38 -1
- package/src/client/webhooks/hooks.ts +3 -0
- package/src/client/webhooks/processors.test.ts +201 -40
- package/src/client/webhooks/processors.ts +21 -17
- package/src/client/webhooks/retry.integration.test.ts +196 -0
- package/src/client/webhooks/v2.test.ts +36 -0
- package/src/client/webhooks/v2.ts +14 -4
- package/src/component/_generated/component.ts +15 -28
- package/src/component/_generated/server.ts +9 -2
- package/src/component/billing/mutations.ts +1 -0
- package/src/component/billing/validators.ts +1 -0
- package/src/component/config-queries.test.ts +8 -4
- package/src/component/connect/queries.ts +31 -66
- package/src/component/convex.config.ts +2 -1
- package/src/component/earnings-totals.test.ts +27 -1
- package/src/component/lib/fees.ts +1 -1
- package/src/react/components/EmbeddedCheckout.render.test.tsx +57 -0
- package/src/react/components/EmbeddedCheckout.tsx +1 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Tests for the earnings AGGREGATE queries (BTS-64). The row-list queries
|
|
4
4
|
* (`listTransfersByAccount`, `listPayouts`) `.take(50)`, so a busy account's
|
|
5
5
|
* earnings totals were silently truncated when summed client-side. These
|
|
6
|
-
* aggregate queries
|
|
6
|
+
* aggregate queries iterate the account's ledger to completion and return
|
|
7
7
|
* EXACT gross/reversed/paidOut regardless of row count, plus a bounded preview
|
|
8
8
|
* of rows for drill-down UIs.
|
|
9
9
|
*/
|
|
@@ -12,6 +12,7 @@ import { describe, expect, it } from "vitest";
|
|
|
12
12
|
|
|
13
13
|
import { api } from "./_generated/api.js";
|
|
14
14
|
import schema from "./schema.js";
|
|
15
|
+
import { getAccountEarnings, getAccountPayouts } from "./connect/queries.js";
|
|
15
16
|
|
|
16
17
|
const modules = import.meta.glob("./**/*.*s");
|
|
17
18
|
|
|
@@ -194,3 +195,28 @@ describe("getAccountPayouts — exact paidOut past the 50-row cap (BTS-64)", ()
|
|
|
194
195
|
expect(result.paidOut).toBe(210 * 100);
|
|
195
196
|
});
|
|
196
197
|
});
|
|
198
|
+
|
|
199
|
+
// convex-test does not enforce production document/byte read limits. Simulate
|
|
200
|
+
// a database iterator reaching that boundary after a row has been accumulated.
|
|
201
|
+
// The aggregate must reject rather than exposing the partial financial total.
|
|
202
|
+
describe("aggregate read-limit failures (BTS-116)", () => {
|
|
203
|
+
it.each([
|
|
204
|
+
["earnings", getAccountEarnings, { destinationAccountId: "acct_limit" }],
|
|
205
|
+
["payouts", getAccountPayouts, { accountId: "acct_limit" }],
|
|
206
|
+
])("rejects incomplete %s totals", async (_name, query, args) => {
|
|
207
|
+
const readLimit = new Error(
|
|
208
|
+
"Too many documents read in a single function execution",
|
|
209
|
+
);
|
|
210
|
+
const rows = {
|
|
211
|
+
async *[Symbol.asyncIterator]() {
|
|
212
|
+
yield { amount: 100, reversedAmount: 10, status: "paid" };
|
|
213
|
+
throw readLimit;
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
const ctx = { db: { query: () => ({ withIndex: () => rows }) } };
|
|
217
|
+
const registered = query as unknown as {
|
|
218
|
+
_handler: (ctx: unknown, args: unknown) => Promise<unknown>;
|
|
219
|
+
};
|
|
220
|
+
await expect(registered._handler(ctx, args)).rejects.toBe(readLimit);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
@@ -28,7 +28,7 @@ export type SplitRecipientRole = Infer<typeof splitRecipientRoleValidator>;
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* One destination in a multi-recipient split. The cut is expressed as either a
|
|
31
|
-
* fixed `amount` (minor units) or a `percent` of the
|
|
31
|
+
* fixed `amount` (minor units) or a `percent` of the gross charge; the resolver (BTS-14)
|
|
32
32
|
* decides precedence. App-owned attribution (who the affiliate is) lives in app
|
|
33
33
|
* tables — the component just records and executes the split.
|
|
34
34
|
*/
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { cleanup, render, waitFor } from "@testing-library/react";
|
|
3
|
+
import { afterEach, expect, it, vi } from "vitest";
|
|
4
|
+
|
|
5
|
+
import { EmbeddedCheckout } from "./EmbeddedCheckout.js";
|
|
6
|
+
|
|
7
|
+
const { createEmbeddedCheckoutPage, mount, destroy } = vi.hoisted(() => ({
|
|
8
|
+
createEmbeddedCheckoutPage: vi.fn(),
|
|
9
|
+
mount: vi.fn(),
|
|
10
|
+
destroy: vi.fn(),
|
|
11
|
+
}));
|
|
12
|
+
vi.mock("@stripe/stripe-js", () => ({
|
|
13
|
+
loadStripe: () =>
|
|
14
|
+
Promise.resolve({
|
|
15
|
+
createEmbeddedCheckoutPage,
|
|
16
|
+
// React Stripe.js validates a Stripe instance with these methods.
|
|
17
|
+
elements: vi.fn(),
|
|
18
|
+
createToken: vi.fn(),
|
|
19
|
+
createPaymentMethod: vi.fn(),
|
|
20
|
+
confirmCardPayment: vi.fn(),
|
|
21
|
+
}),
|
|
22
|
+
}));
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
cleanup();
|
|
25
|
+
vi.clearAllMocks();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("mounts through the current Stripe.js API, forwards completion, and remounts a new session", async () => {
|
|
29
|
+
createEmbeddedCheckoutPage.mockResolvedValue({ mount, destroy });
|
|
30
|
+
const onComplete = vi.fn();
|
|
31
|
+
const view = render(
|
|
32
|
+
<EmbeddedCheckout
|
|
33
|
+
publishableKey="pk_test_local"
|
|
34
|
+
clientSecret="cs_first_secret"
|
|
35
|
+
onComplete={onComplete}
|
|
36
|
+
/>,
|
|
37
|
+
);
|
|
38
|
+
await waitFor(() => expect(mount).toHaveBeenCalledTimes(1));
|
|
39
|
+
const firstOptions = createEmbeddedCheckoutPage.mock.calls[0][0];
|
|
40
|
+
expect(await firstOptions.fetchClientSecret()).toBe("cs_first_secret");
|
|
41
|
+
firstOptions.onComplete();
|
|
42
|
+
expect(onComplete).toHaveBeenCalledTimes(1);
|
|
43
|
+
view.rerender(
|
|
44
|
+
<EmbeddedCheckout
|
|
45
|
+
publishableKey="pk_test_local"
|
|
46
|
+
clientSecret="cs_second_secret"
|
|
47
|
+
onComplete={onComplete}
|
|
48
|
+
/>,
|
|
49
|
+
);
|
|
50
|
+
await waitFor(() => expect(mount).toHaveBeenCalledTimes(2));
|
|
51
|
+
expect(destroy).toHaveBeenCalledTimes(1);
|
|
52
|
+
expect(
|
|
53
|
+
await createEmbeddedCheckoutPage.mock.calls[1][0].fetchClientSecret(),
|
|
54
|
+
).toBe("cs_second_secret");
|
|
55
|
+
view.unmount();
|
|
56
|
+
expect(destroy).toHaveBeenCalledTimes(2);
|
|
57
|
+
});
|