@fantastic.dev/better-stripe 0.47.1 → 0.48.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/historyPages.d.ts +22 -0
  4. package/dist/client/billing/historyPages.d.ts.map +1 -0
  5. package/dist/client/billing/historyPages.js +8 -0
  6. package/dist/client/billing/historyPages.js.map +1 -0
  7. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +10 -0
  8. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  9. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +21 -16
  10. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  11. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +42 -32
  12. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  13. package/dist/client/connect/payoutSyncTestHelpers.d.ts +5 -0
  14. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  15. package/dist/client/publicTypes.d.ts +1 -0
  16. package/dist/client/publicTypes.d.ts.map +1 -1
  17. package/dist/client/readContracts.d.ts +4 -0
  18. package/dist/client/readContracts.d.ts.map +1 -1
  19. package/dist/client/readContracts.js +8 -0
  20. package/dist/client/readContracts.js.map +1 -1
  21. package/dist/client/webhooks/handler.d.ts.map +1 -1
  22. package/dist/client/webhooks/handler.js +6 -3
  23. package/dist/client/webhooks/handler.js.map +1 -1
  24. package/dist/client/webhooks/processors.d.ts.map +1 -1
  25. package/dist/client/webhooks/processors.js +3 -65
  26. package/dist/client/webhooks/processors.js.map +1 -1
  27. package/dist/client/webhooks/refundDelivery.d.ts +5 -0
  28. package/dist/client/webhooks/refundDelivery.d.ts.map +1 -0
  29. package/dist/client/webhooks/refundDelivery.js +28 -0
  30. package/dist/client/webhooks/refundDelivery.js.map +1 -0
  31. package/dist/client/webhooks/refundRecovery.d.ts +5 -0
  32. package/dist/client/webhooks/refundRecovery.d.ts.map +1 -0
  33. package/dist/client/webhooks/refundRecovery.js +36 -0
  34. package/dist/client/webhooks/refundRecovery.js.map +1 -0
  35. package/dist/component/_generated/api.d.ts +4 -0
  36. package/dist/component/_generated/api.d.ts.map +1 -1
  37. package/dist/component/_generated/api.js.map +1 -1
  38. package/dist/component/_generated/component.d.ts +100 -0
  39. package/dist/component/_generated/component.d.ts.map +1 -1
  40. package/dist/component/balanceFunding/mutations.d.ts +16 -16
  41. package/dist/component/billing/schema.d.ts +5 -0
  42. package/dist/component/billing/schema.d.ts.map +1 -1
  43. package/dist/component/billing/schema.js +13 -0
  44. package/dist/component/billing/schema.js.map +1 -1
  45. package/dist/component/billingHistory/queries.d.ts +97 -0
  46. package/dist/component/billingHistory/queries.d.ts.map +1 -0
  47. package/dist/component/billingHistory/queries.js +65 -0
  48. package/dist/component/billingHistory/queries.js.map +1 -0
  49. package/dist/component/billingHistory/scope.d.ts +23 -0
  50. package/dist/component/billingHistory/scope.d.ts.map +1 -0
  51. package/dist/component/billingHistory/scope.js +54 -0
  52. package/dist/component/billingHistory/scope.js.map +1 -0
  53. package/dist/component/earnings/triggers.d.ts +10 -0
  54. package/dist/component/earnings/triggers.d.ts.map +1 -1
  55. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  56. package/dist/component/refundSync/mutations.d.ts +1 -1
  57. package/dist/component/refundSync/mutations.d.ts.map +1 -1
  58. package/dist/component/schema.d.ts +5 -0
  59. package/docs/billing-history.md +13 -0
  60. package/docs/refund-context.md +42 -9
  61. package/package.json +2 -1
  62. package/src/client/billing/historyPages.test.ts +58 -0
  63. package/src/client/billing/historyPages.ts +48 -0
  64. package/src/client/publicTypes.ts +7 -0
  65. package/src/client/readContracts.ts +16 -0
  66. package/src/client/webhooks/handler.ts +7 -3
  67. package/src/client/webhooks/processors.test.ts +9 -7
  68. package/src/client/webhooks/processors.ts +3 -88
  69. package/src/client/webhooks/refund-delivery.test.ts +512 -0
  70. package/src/client/webhooks/refundDelivery.ts +42 -0
  71. package/src/client/webhooks/refundRecovery.ts +52 -0
  72. package/src/client/webhooks.test.ts +35 -42
  73. package/src/component/_generated/api.ts +4 -0
  74. package/src/component/_generated/component.ts +128 -0
  75. package/src/component/billing/schema.ts +13 -0
  76. package/src/component/billingHistory/guards.test.ts +235 -0
  77. package/src/component/billingHistory/options.test.ts +35 -0
  78. package/src/component/billingHistory/pages.test.ts +74 -0
  79. package/src/component/billingHistory/queries.ts +88 -0
  80. package/src/component/billingHistory/scope.ts +77 -0
@@ -22,6 +22,14 @@ export declare const begin: import("convex/server").RegisteredMutation<"public",
22
22
  requestKey: string;
23
23
  scopeKey: string;
24
24
  }, Promise<{
25
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
26
+ retryable: false;
27
+ status: "conflict";
28
+ } | {
29
+ reason: "policy_invalid";
30
+ retryable: false;
31
+ status: "rejected";
32
+ } | {
25
33
  operation: {
26
34
  accountId: string;
27
35
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -32,14 +40,6 @@ export declare const begin: import("convex/server").RegisteredMutation<"public",
32
40
  } | {
33
41
  enabled: boolean;
34
42
  status: "unchanged";
35
- } | {
36
- reason: "identity_changed" | "revision_changed" | "scope_busy";
37
- retryable: false;
38
- status: "conflict";
39
- } | {
40
- reason: "policy_invalid";
41
- retryable: false;
42
- status: "rejected";
43
43
  } | {
44
44
  reason: "provider_pending";
45
45
  retryable: true;
@@ -395,6 +395,14 @@ export declare const prepare: import("convex/server").RegisteredMutation<"public
395
395
  requestKey: string;
396
396
  scopeKey: string;
397
397
  }, Promise<{
398
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
399
+ retryable: false;
400
+ status: "conflict";
401
+ } | {
402
+ reason: "policy_invalid";
403
+ retryable: false;
404
+ status: "rejected";
405
+ } | {
398
406
  operation: {
399
407
  accountId: string;
400
408
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -405,14 +413,6 @@ export declare const prepare: import("convex/server").RegisteredMutation<"public
405
413
  } | {
406
414
  enabled: boolean;
407
415
  status: "unchanged";
408
- } | {
409
- reason: "identity_changed" | "revision_changed" | "scope_busy";
410
- retryable: false;
411
- status: "conflict";
412
- } | {
413
- reason: "policy_invalid";
414
- retryable: false;
415
- status: "rejected";
416
416
  } | {
417
417
  reason: "provider_pending";
418
418
  retryable: true;
@@ -78,6 +78,9 @@ export declare const subscriptionsTable: import("convex/server").TableDefinition
78
78
  by_price_id: ["priceId", "_creationTime"];
79
79
  by_status: ["status", "_creationTime"];
80
80
  by_stripe_subscription_id: ["stripeSubscriptionId", "_creationTime"];
81
+ by_userId_and_accountId: ["userId", "accountId", "_creationTime"];
82
+ by_userId_and_accountId_and_status: ["userId", "accountId", "status", "_creationTime"];
83
+ by_userId_and_status: ["userId", "status", "_creationTime"];
81
84
  by_user_id: ["userId", "_creationTime"];
82
85
  }, {}, {}>;
83
86
  /**
@@ -144,6 +147,8 @@ export declare const checkoutSessionsTable: import("convex/server").TableDefinit
144
147
  }, "required", "accountId" | "applicationFeeAmount" | "applicationFeePercent" | "chargeType" | "clientSecret" | "currency" | "destinationAccountId" | "feeCollectedAmount" | "feeRefundedAmount" | "metadata" | "mode" | "orgId" | "priceId" | "splitRecipients" | "status" | "stripeSessionId" | "url" | "userId" | `metadata.${string}`>, {
145
148
  by_account_id: ["accountId", "_creationTime"];
146
149
  by_stripe_session_id: ["stripeSessionId", "_creationTime"];
150
+ by_userId_and_accountId: ["userId", "accountId", "_creationTime"];
151
+ by_userId_and_accountId_and_status: ["userId", "accountId", "status", "_creationTime"];
147
152
  by_user_id: ["userId", "_creationTime"];
148
153
  by_user_status: ["userId", "status", "_creationTime"];
149
154
  }, {}, {}>;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/billing/schema.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAOuB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAIc,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAQO,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/billing/schema.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAcuB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAUc,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAQO,CAAC"}
@@ -7,6 +7,13 @@ export const subscriptionsTable = defineTable(subscriptionFields)
7
7
  .index("by_stripe_subscription_id", ["stripeSubscriptionId"])
8
8
  .index("by_price_id", ["priceId"])
9
9
  .index("by_user_id", ["userId"])
10
+ .index("by_userId_and_status", ["userId", "status"])
11
+ .index("by_userId_and_accountId", ["userId", "accountId"])
12
+ .index("by_userId_and_accountId_and_status", [
13
+ "userId",
14
+ "accountId",
15
+ "status",
16
+ ])
10
17
  .index("by_org_id", ["orgId"])
11
18
  .index("by_status", ["status"])
12
19
  .index("by_account_id", ["accountId"])
@@ -17,6 +24,12 @@ export const subscriptionsTable = defineTable(subscriptionFields)
17
24
  export const checkoutSessionsTable = defineTable(checkoutSessionFields)
18
25
  .index("by_stripe_session_id", ["stripeSessionId"])
19
26
  .index("by_user_id", ["userId"])
27
+ .index("by_userId_and_accountId", ["userId", "accountId"])
28
+ .index("by_userId_and_accountId_and_status", [
29
+ "userId",
30
+ "accountId",
31
+ "status",
32
+ ])
20
33
  .index("by_account_id", ["accountId"])
21
34
  .index("by_user_status", ["userId", "status"]);
22
35
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/component/billing/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC,kBAAkB,CAAC;KAC9D,KAAK,CAAC,2BAA2B,EAAE,CAAC,sBAAsB,CAAC,CAAC;KAC5D,KAAK,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,CAAC;KACjC,KAAK,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,CAAC;KAC/B,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,CAAC;KAC7B,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC;KAC9B,KAAK,CAAC,eAAe,EAAE,CAAC,WAAW,CAAC,CAAC;KACrC,KAAK,CAAC,mBAAmB,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEvD;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,WAAW,CAAC,qBAAqB,CAAC;KACpE,KAAK,CAAC,sBAAsB,EAAE,CAAC,iBAAiB,CAAC,CAAC;KAClD,KAAK,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,CAAC;KAC/B,KAAK,CAAC,eAAe,EAAE,CAAC,WAAW,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,QAAQ,EAAE,QAAQ,CAAC,CAAC;KAC7C,KAAK,CAAC,wBAAwB,EAAE,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;KAC7D,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,97 @@
1
+ export declare const paginateSubscriptions: import("convex/server").RegisteredQuery<"public", {
2
+ accountId?: string | undefined;
3
+ paginationOpts: {
4
+ id?: number;
5
+ endCursor?: string | null;
6
+ maximumRowsRead?: number;
7
+ maximumBytesRead?: number;
8
+ numItems: number;
9
+ cursor: string | null;
10
+ };
11
+ status?: "active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "trialing" | "unpaid" | undefined;
12
+ userId: string;
13
+ }, Promise<{
14
+ page: {
15
+ _creationTime: number;
16
+ _id: import("convex/values").GenericId<"subscriptions">;
17
+ accountId?: string | undefined;
18
+ applicationFeeAmount?: number | undefined;
19
+ applicationFeePercent?: number | undefined;
20
+ cancelAtPeriodEnd: boolean;
21
+ canceledAt?: string | undefined;
22
+ chargeType?: "destination" | "separate" | undefined;
23
+ currency?: string | undefined;
24
+ currentPeriodEnd?: string | undefined;
25
+ currentPeriodStart?: string | undefined;
26
+ destinationAccountId?: string | undefined;
27
+ feeCollectedAmount?: number | undefined;
28
+ feeRefundedAmount?: number | undefined;
29
+ isCollectionPaused?: boolean | undefined;
30
+ isTrialing: boolean;
31
+ metadata?: any;
32
+ orgId?: string | undefined;
33
+ priceId?: string | undefined;
34
+ quantity?: number | undefined;
35
+ splitRecipients?: {
36
+ amount?: number | undefined;
37
+ destinationAccountId: string;
38
+ percent?: number | undefined;
39
+ role: "affiliate" | "other" | "store";
40
+ }[] | undefined;
41
+ status: "active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "trialing" | "unpaid";
42
+ stripeSubscriptionId: string;
43
+ trialEnd?: string | undefined;
44
+ trialStart?: string | undefined;
45
+ userId: string;
46
+ }[];
47
+ isDone: boolean;
48
+ splitCursor?: import("convex/server").Cursor | null;
49
+ pageStatus?: "SplitRecommended" | "SplitRequired" | null;
50
+ continueCursor: string;
51
+ }>>;
52
+ export declare const paginateCheckoutSessions: import("convex/server").RegisteredQuery<"public", {
53
+ accountId?: string | undefined;
54
+ paginationOpts: {
55
+ id?: number;
56
+ endCursor?: string | null;
57
+ maximumRowsRead?: number;
58
+ maximumBytesRead?: number;
59
+ numItems: number;
60
+ cursor: string | null;
61
+ };
62
+ status?: "complete" | "expired" | "open" | undefined;
63
+ userId: string;
64
+ }, Promise<{
65
+ page: {
66
+ _creationTime: number;
67
+ _id: import("convex/values").GenericId<"checkoutSessions">;
68
+ accountId?: string | undefined;
69
+ applicationFeeAmount?: number | undefined;
70
+ applicationFeePercent?: number | undefined;
71
+ chargeType?: "destination" | "separate" | undefined;
72
+ clientSecret?: string | undefined;
73
+ currency?: string | undefined;
74
+ destinationAccountId?: string | undefined;
75
+ feeCollectedAmount?: number | undefined;
76
+ feeRefundedAmount?: number | undefined;
77
+ metadata?: any;
78
+ mode: "payment" | "setup" | "subscription";
79
+ orgId?: string | undefined;
80
+ priceId?: string | undefined;
81
+ splitRecipients?: {
82
+ amount?: number | undefined;
83
+ destinationAccountId: string;
84
+ percent?: number | undefined;
85
+ role: "affiliate" | "other" | "store";
86
+ }[] | undefined;
87
+ status: "complete" | "expired" | "open";
88
+ stripeSessionId: string;
89
+ url?: string | undefined;
90
+ userId: string;
91
+ }[];
92
+ isDone: boolean;
93
+ splitCursor?: import("convex/server").Cursor | null;
94
+ pageStatus?: "SplitRecommended" | "SplitRequired" | null;
95
+ continueCursor: string;
96
+ }>>;
97
+ //# sourceMappingURL=queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/billingHistory/queries.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgChC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCnC,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { paginator } from "convex-helpers/server/pagination";
2
+ import { paginationOptsValidator, paginationResultValidator, } from "convex/server";
3
+ import { v } from "convex/values";
4
+ import { query } from "../_generated/server.js";
5
+ import schema from "../schema.js";
6
+ import { checkoutSessionDocValidator, checkoutSessionStatusValidator, subscriptionDocValidator, subscriptionStatusValidator, } from "../billing/validators.js";
7
+ import { historyOptions, historyResult } from "./scope.js";
8
+ export const paginateSubscriptions = query({
9
+ args: {
10
+ userId: v.string(),
11
+ accountId: v.optional(v.string()),
12
+ status: v.optional(subscriptionStatusValidator),
13
+ paginationOpts: paginationOptsValidator,
14
+ },
15
+ returns: paginationResultValidator(subscriptionDocValidator),
16
+ handler: async (ctx, args) => {
17
+ const { userId, accountId, status } = args;
18
+ const scope = { kind: "subscriptions", userId, accountId, status };
19
+ const options = historyOptions(scope, args.paginationOpts);
20
+ const rows = paginator(ctx.db, schema).query("subscriptions");
21
+ const scoped = accountId !== undefined
22
+ ? status !== undefined
23
+ ? rows.withIndex("by_userId_and_accountId_and_status", (q) => q
24
+ .eq("userId", userId)
25
+ .eq("accountId", accountId)
26
+ .eq("status", status))
27
+ : rows.withIndex("by_userId_and_accountId", (q) => q.eq("userId", userId).eq("accountId", accountId))
28
+ : status !== undefined
29
+ ? rows.withIndex("by_userId_and_status", (q) => q.eq("userId", userId).eq("status", status))
30
+ : rows.withIndex("by_user_id", (q) => q.eq("userId", userId));
31
+ return historyResult(scope, await scoped.order("desc").paginate(options));
32
+ },
33
+ });
34
+ export const paginateCheckoutSessions = query({
35
+ args: {
36
+ userId: v.string(),
37
+ accountId: v.optional(v.string()),
38
+ status: v.optional(checkoutSessionStatusValidator),
39
+ paginationOpts: paginationOptsValidator,
40
+ },
41
+ returns: paginationResultValidator(checkoutSessionDocValidator),
42
+ handler: async (ctx, args) => {
43
+ const { userId, accountId, status } = args;
44
+ const scope = {
45
+ kind: "checkoutSessions",
46
+ userId,
47
+ accountId,
48
+ status,
49
+ };
50
+ const options = historyOptions(scope, args.paginationOpts);
51
+ const rows = paginator(ctx.db, schema).query("checkoutSessions");
52
+ const scoped = accountId !== undefined
53
+ ? status !== undefined
54
+ ? rows.withIndex("by_userId_and_accountId_and_status", (q) => q
55
+ .eq("userId", userId)
56
+ .eq("accountId", accountId)
57
+ .eq("status", status))
58
+ : rows.withIndex("by_userId_and_accountId", (q) => q.eq("userId", userId).eq("accountId", accountId))
59
+ : status !== undefined
60
+ ? rows.withIndex("by_user_status", (q) => q.eq("userId", userId).eq("status", status))
61
+ : rows.withIndex("by_user_id", (q) => q.eq("userId", userId));
62
+ return historyResult(scope, await scoped.order("desc").paginate(options));
63
+ },
64
+ });
65
+ //# sourceMappingURL=queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/component/billingHistory/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EACL,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;IACzC,IAAI,EAAE;QACJ,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;QAClB,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE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,CAAC,EAAE,EAAE,CACzD,CAAC;qBACE,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;qBACpB,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC;qBAC1B,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CACxB;gBACH,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,yBAAyB,EAAE,CAAC,CAAC,EAAE,EAAE,CAC9C,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,CAClD;YACL,CAAC,CAAC,MAAM,KAAK,SAAS;gBACpB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,CACrC,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAC5C;gBACH,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QACpE,OAAO,aAAa,CAAC,KAAK,EAAE,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { PaginationOptions, PaginationResult } from "convex/server";
2
+ export type HistoryScope = {
3
+ kind: "subscriptions" | "checkoutSessions";
4
+ userId: string;
5
+ accountId?: string;
6
+ status?: string;
7
+ };
8
+ /** Context binding only; the trusted host must authorize every call. */
9
+ export declare function historyOptions(scope: HistoryScope, options: PaginationOptions): {
10
+ numItems: number;
11
+ endCursor?: import("convex/server").Cursor | null;
12
+ cursor: string | null;
13
+ maximumRowsRead: number;
14
+ maximumBytesRead: number;
15
+ };
16
+ export declare function historyResult<T>(scope: HistoryScope, result: PaginationResult<T>): {
17
+ page: T[];
18
+ isDone: boolean;
19
+ splitCursor?: import("convex/server").Cursor | null;
20
+ pageStatus?: "SplitRecommended" | "SplitRequired" | null;
21
+ continueCursor: string;
22
+ };
23
+ //# sourceMappingURL=scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/component/billingHistory/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEzE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,eAAe,GAAG,kBAAkB,CAAC;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAuBF,wEAAwE;AACxE,wBAAgB,cAAc,CAC5B,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,iBAAiB;;;;;;EAmB3B;AAED,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;;;;;;EAS5B"}
@@ -0,0 +1,54 @@
1
+ function encoded(scope, cursor) {
2
+ return btoa(encodeURIComponent(JSON.stringify({ version: 1, scope, cursor })));
3
+ }
4
+ function decoded(scope, cursor) {
5
+ try {
6
+ const value = JSON.parse(decodeURIComponent(atob(cursor)));
7
+ if (value.version !== 1 ||
8
+ typeof value.cursor !== "string" ||
9
+ encoded(scope, value.cursor) !== cursor)
10
+ throw new Error();
11
+ return value.cursor;
12
+ }
13
+ catch {
14
+ throw new Error("Invalid billing history cursor or scope");
15
+ }
16
+ }
17
+ /** Context binding only; the trusted host must authorize every call. */
18
+ export function historyOptions(scope, options) {
19
+ if (!isCanonical(scope.userId) ||
20
+ (scope.accountId !== undefined && !isCanonical(scope.accountId)) ||
21
+ !Number.isSafeInteger(options.numItems) ||
22
+ options.numItems < 1 ||
23
+ options.numItems > 100)
24
+ throw new Error("Invalid billing history selector or page size");
25
+ return {
26
+ ...options,
27
+ cursor: options.cursor === null ? null : decoded(scope, options.cursor),
28
+ ...(options.endCursor !== undefined && options.endCursor !== null
29
+ ? { endCursor: decoded(scope, options.endCursor) }
30
+ : {}),
31
+ maximumRowsRead: ceiling(options.maximumRowsRead, 200),
32
+ maximumBytesRead: ceiling(options.maximumBytesRead, 1_000_000),
33
+ };
34
+ }
35
+ export function historyResult(scope, result) {
36
+ return {
37
+ ...result,
38
+ continueCursor: encoded(scope, result.continueCursor),
39
+ ...(result.splitCursor
40
+ ? { splitCursor: encoded(scope, result.splitCursor) }
41
+ : {}),
42
+ };
43
+ }
44
+ function ceiling(requested, policy) {
45
+ if (requested === undefined)
46
+ return policy;
47
+ if (!Number.isSafeInteger(requested) || requested < 1)
48
+ throw new Error("Invalid billing history read ceiling");
49
+ return Math.min(requested, policy);
50
+ }
51
+ function isCanonical(value) {
52
+ return value.length > 0 && value === value.trim() && !/\p{Cc}/u.test(value);
53
+ }
54
+ //# sourceMappingURL=scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/component/billingHistory/scope.ts"],"names":[],"mappings":"AASA,SAAS,OAAO,CAAC,KAAmB,EAAE,MAAc;IAClD,OAAO,IAAI,CACT,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAClE,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,KAAmB,EAAE,MAAc;IAClD,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC3D,IACE,KAAK,CAAC,OAAO,KAAK,CAAC;YACnB,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;YAChC,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,OAAO;QACL,GAAG,MAAM;QACT,cAAc,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;QACrD,GAAG,CAAC,MAAM,CAAC,WAAW;YACpB,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE;YACrD,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,SAA6B,EAAE,MAAc;IAC5D,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IAC3C,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
@@ -439,6 +439,8 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
439
439
  by_creation_time: ["_creationTime"];
440
440
  by_account_id: ["accountId", "_creationTime"];
441
441
  by_stripe_session_id: ["stripeSessionId", "_creationTime"];
442
+ by_userId_and_accountId: ["userId", "accountId", "_creationTime"];
443
+ by_userId_and_accountId_and_status: ["userId", "accountId", "status", "_creationTime"];
442
444
  by_user_id: ["userId", "_creationTime"];
443
445
  by_user_status: ["userId", "status", "_creationTime"];
444
446
  };
@@ -1919,6 +1921,9 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
1919
1921
  by_price_id: ["priceId", "_creationTime"];
1920
1922
  by_status: ["status", "_creationTime"];
1921
1923
  by_stripe_subscription_id: ["stripeSubscriptionId", "_creationTime"];
1924
+ by_userId_and_accountId: ["userId", "accountId", "_creationTime"];
1925
+ by_userId_and_accountId_and_status: ["userId", "accountId", "status", "_creationTime"];
1926
+ by_userId_and_status: ["userId", "status", "_creationTime"];
1922
1927
  by_user_id: ["userId", "_creationTime"];
1923
1928
  };
1924
1929
  searchIndexes: {};
@@ -2450,6 +2455,8 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
2450
2455
  by_creation_time: ["_creationTime"];
2451
2456
  by_account_id: ["accountId", "_creationTime"];
2452
2457
  by_stripe_session_id: ["stripeSessionId", "_creationTime"];
2458
+ by_userId_and_accountId: ["userId", "accountId", "_creationTime"];
2459
+ by_userId_and_accountId_and_status: ["userId", "accountId", "status", "_creationTime"];
2453
2460
  by_user_id: ["userId", "_creationTime"];
2454
2461
  by_user_status: ["userId", "status", "_creationTime"];
2455
2462
  };
@@ -3930,6 +3937,9 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
3930
3937
  by_price_id: ["priceId", "_creationTime"];
3931
3938
  by_status: ["status", "_creationTime"];
3932
3939
  by_stripe_subscription_id: ["stripeSubscriptionId", "_creationTime"];
3940
+ by_userId_and_accountId: ["userId", "accountId", "_creationTime"];
3941
+ by_userId_and_accountId_and_status: ["userId", "accountId", "status", "_creationTime"];
3942
+ by_userId_and_status: ["userId", "status", "_creationTime"];
3933
3943
  by_user_id: ["userId", "_creationTime"];
3934
3944
  };
3935
3945
  searchIndexes: {};
@@ -1 +1 @@
1
- {"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../../../src/component/earnings/triggers.ts"],"names":[],"mappings":"AA6GA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAA0D,CAAC"}
@@ -14,7 +14,7 @@ export declare function checkRollback(ctx: MutationCtx, op: Doc<"processingCostR
14
14
  readonly bindFunding?: undefined;
15
15
  } | {
16
16
  reason?: undefined;
17
- readonly retryable?: undefined;
17
+ retryable?: undefined;
18
18
  readonly status: "ready";
19
19
  readonly bindFunding: boolean;
20
20
  }>;
@@ -21,10 +21,10 @@ export declare const finish: import("convex/server").RegisteredMutation<"public"
21
21
  };
22
22
  stripeRefundId: string;
23
23
  }, Promise<{
24
+ changed?: undefined;
24
25
  refund?: undefined;
25
26
  status: "superseded";
26
27
  generation: number;
27
- changed?: undefined;
28
28
  } | {
29
29
  status: "accepted";
30
30
  generation: number;
@@ -1 +1 @@
1
- {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../../src/component/refundSync/mutations.ts"],"names":[],"mappings":"AAcA,wFAAwF;AACxF,eAAO,MAAM,KAAK;;;mBA6BhB,CAAC;AAEH,kFAAkF;AAClF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;YAUI,YAAY;;;;YA+BnB,UAAU;;;;;;;;;;;;;;;;;;;;;GA2BxB,CAAC;AACH,eAAO,MAAM,WAAW;;;;iBActB,CAAC"}
1
+ {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../../src/component/refundSync/mutations.ts"],"names":[],"mappings":"AAcA,wFAAwF;AACxF,eAAO,MAAM,KAAK;;;mBA6BhB,CAAC;AAEH,kFAAkF;AAClF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;YAUI,YAAY;;;YA+BnB,UAAU;;;;;;;;;;;;;;;;;;;;;GA2BxB,CAAC;AACH,eAAO,MAAM,WAAW;;;;iBActB,CAAC"}
@@ -2796,6 +2796,9 @@ declare const _default: import("convex/server").SchemaDefinition<{
2796
2796
  by_price_id: ["priceId", "_creationTime"];
2797
2797
  by_status: ["status", "_creationTime"];
2798
2798
  by_stripe_subscription_id: ["stripeSubscriptionId", "_creationTime"];
2799
+ by_userId_and_accountId: ["userId", "accountId", "_creationTime"];
2800
+ by_userId_and_accountId_and_status: ["userId", "accountId", "status", "_creationTime"];
2801
+ by_userId_and_status: ["userId", "status", "_creationTime"];
2799
2802
  by_user_id: ["userId", "_creationTime"];
2800
2803
  }, {}, {}>;
2801
2804
  checkoutSessions: import("convex/server").TableDefinition<import("convex/values").VObject<{
@@ -2859,6 +2862,8 @@ declare const _default: import("convex/server").SchemaDefinition<{
2859
2862
  }, "required", "accountId" | "applicationFeeAmount" | "applicationFeePercent" | "chargeType" | "clientSecret" | "currency" | "destinationAccountId" | "feeCollectedAmount" | "feeRefundedAmount" | "metadata" | "mode" | "orgId" | "priceId" | "splitRecipients" | "status" | "stripeSessionId" | "url" | "userId" | `metadata.${string}`>, {
2860
2863
  by_account_id: ["accountId", "_creationTime"];
2861
2864
  by_stripe_session_id: ["stripeSessionId", "_creationTime"];
2865
+ by_userId_and_accountId: ["userId", "accountId", "_creationTime"];
2866
+ by_userId_and_accountId_and_status: ["userId", "accountId", "status", "_creationTime"];
2862
2867
  by_user_id: ["userId", "_creationTime"];
2863
2868
  by_user_status: ["userId", "status", "_creationTime"];
2864
2869
  }, {}, {}>;
@@ -0,0 +1,13 @@
1
+ # Component billing history pages
2
+
3
+ `paginateSubscriptions` and `paginateCheckoutSessions` read the existing synchronized component tables. Each requires an original `userId` selected by a trusted host and accepts an optional exact `accountId`, typed `status`, and Convex `paginationOpts`. Selectors must be nonempty, trimmed original strings without control characters; they are rejected rather than normalized. There is no new lifetime or legacy-ID length cap. The account predicate is conjunctive with the buyer predicate. A user-only page includes valid legacy rows without an account ID; adding an account predicate intentionally excludes them.
4
+
5
+ Use independent cursors for the two readers. Page sizes are 1–100; they bound one page, never lifetime history. Optional caller read ceilings must be positive safe integers; stricter ceilings are preserved within the package policy of 200 rows/1 MB per invocation. Cursors bind the reader kind, buyer, optional account and status. Forward returned continuation and split cursors unchanged. Preserve `endCursor`, `pageStatus` and split obligations when a reactive pinned range grows. Cursor encoding is context binding, not authentication or a signed capability. Authorize every request and continued page before calling the package.
6
+
7
+ These are cached observations, not an atomic provider history certificate. Exhaustion means the selected component range was exhausted at that query, not that every provider event arrived. No reads synchronize or mutate provider resources. A completed Checkout session, an invoice, a trial and a paid one-time order are different facts; hosts must use their original request/fulfillment bindings and qualified payment evidence before making purchase or access decisions.
8
+
9
+ The SDK returns server-side component documents, including fields inappropriate for browsers. A host must whitelist its response: never forward Checkout `clientSecret`, `url` or arbitrary metadata. Do not infer buyer ownership from a caller-supplied account ID or remap historical buyers to a current account. Community, session and enabled-actor authorization remain app-owned. Missing or conflicting provenance is unavailable, not an empty successful financial history.
10
+
11
+ The matching Vite reference is `example/convex/billing/history/queries.ts`. Unlike the old synthetic-persona demo routes, this opt-in adapter requires a genuine Convex authenticated identity mapped uniquely through the existing `authTokenIdentifier` index, then an existing buyer/customer role. The ordinary demo does not configure authentication or mint that mapping; it therefore fails closed. A production host must supply its real account restriction and domain authorization checks rather than treating the example's demo role as a complete security model. The adapter takes no browser buyer/account selectors and whitelists safe observations.
12
+
13
+ Existing array readers retain their behavior. `listCheckoutSessionsByUser` remains a first-50 preview; it is not the pagination API. `getCheckoutSessionPageFromStripe` remains separate live provider discovery. Consumers can expose one authorized entrypoint returning both pages with independent cursors; these methods do not require a shared stream or a new ledger. In Dojo, DOJO-962 owns that authorized composition and DOJO-2238 owns the caller/UI migration; no UI or entitlement activation ships in this package slice.
@@ -129,11 +129,11 @@ history is not cardinality bounded: native resource limits can abort the whole
129
129
  accepting transaction, preserving the last committed projection. There is no
130
130
  partial sum, silent truncation or all-backlog-capacity guarantee.
131
131
 
132
- This primitive does **not** yet route the legacy signed refund webhook pipeline
133
- through generation qualification. Legacy `upsertRefund` and raw callbacks remain
134
- unfenced; they can still overwrite observations outside this operation. The
135
- separate shared-pipeline integration must preserve generation qualification
136
- through its callback transaction before hosts claim webhook-wide convergence.
132
+ This standalone primitive does not run application callbacks or transfer recovery.
133
+ The maintained signed route uses the qualified callback seam below. Direct legacy
134
+ `upsertRefund`/raw-dispatcher calls remain outside generation fencing; hosts must
135
+ not reapply notification snapshots after qualified acceptance. No convergence
136
+ claim covers independent legacy writers.
137
137
  The server-only Vite reference is
138
138
  [`example/convex/connect/refundSync.ts`](../example/convex/connect/refundSync.ts).
139
139
 
@@ -160,7 +160,40 @@ reconciliation; the package does not silently retry a raw upsert as fallback.
160
160
 
161
161
  The direct-component path returns the same accepted observation and rejects
162
162
  superseded results. It has no application callback because no host handler was
163
- registered. This seam does not activate signed notification reconciliation or
164
- change existing reversal recovery. Legacy raw refund delivery remains unfenced
165
- until that separate consumer is adopted. A successful or unchanged mirror is not
166
- proof that a prior provider reversal or financial recovery completed.
163
+ registered. A successful or unchanged mirror is not proof that a prior provider
164
+ reversal or financial recovery completed.
165
+
166
+ ### Signed refund delivery and recovery
167
+
168
+ The existing single `registerRoutes` endpoint verifies the signature before any
169
+ provider access. For `refund.created`, `refund.updated` and `refund.failed`, only
170
+ the signed refund ID and `event.account` select the original refund/API realm.
171
+ The package retrieves current provider state, qualifies it and accepts its durable
172
+ generation through the transaction above. It never substitutes notification
173
+ status, metadata or `event.created` for current state. A legitimate current
174
+ bank-return transition remains valid after a previous succeeded observation.
175
+
176
+ Required synchronization failures return non-2xx and retain failed/retryable event
177
+ ledger state. This applies independently of optional application-hook retry policy.
178
+ An in-flight duplicate returns retryable failure; a processed duplicate does not
179
+ read or notify again. Existing stale-processing recovery reopens an abandoned
180
+ attempt. Superseded observations cannot invoke changed callbacks or be acknowledged
181
+ as reconciled merely because a later generation started. Retry does not prove that
182
+ a later provider observation or economic operation succeeded.
183
+
184
+ After acceptance, current succeeded state can select the existing platform split
185
+ recovery operation. An unchanged mirror still checks that operation: an earlier
186
+ reversal failure or lost response is handled by its existing claim, original
187
+ idempotency key and transfer-receipt reconciliation. The synchronization layer
188
+ adds no reversal calculation or new financial retry permission. A connected refund
189
+ with no platform split obligation can synchronize; a connected refund associated
190
+ with platform recovery legs is held before any unscoped platform provider operation.
191
+ Its qualified mirror may already be committed, but the delivery remains retryable
192
+ and must not advertise complete economic recovery.
193
+
194
+ Refund `onCreate`/`onUpdate` callbacks receive qualified current stored rows and run
195
+ only for changed acceptance. Generic `onEvent`/`events` hooks keep their existing
196
+ verified `Stripe.Event` notification payload; that payload is not authoritative
197
+ current refund state or financial-completion evidence. Async hooks keep their
198
+ existing committed-document/scheduling contract. No live-provider atomicity or
199
+ all-history/native-capacity guarantee is introduced.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fantastic.dev/better-stripe",
3
- "version": "0.47.1",
3
+ "version": "0.48.0",
4
4
  "description": "A Convex component for Stripe V2 Accounts API integration.",
5
5
  "keywords": [
6
6
  "stripe",
@@ -65,6 +65,7 @@
65
65
  "CHANGELOG.md",
66
66
  "MIGRATION.md",
67
67
  "docs/read-contracts.md",
68
+ "docs/billing-history.md",
68
69
  "docs/invoice-payment-pages.md",
69
70
  "docs/checkout-session-pages.md",
70
71
  "docs/refund-context.md",