@fantastic.dev/better-stripe 0.45.2 → 0.46.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 (87) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +1 -1
  3. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +46 -0
  4. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  5. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +23 -0
  6. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  7. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +46 -0
  8. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  9. package/dist/client/connect/payoutSyncTestHelpers.d.ts +23 -0
  10. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  11. package/dist/client/connect/refundSync.d.ts +32 -0
  12. package/dist/client/connect/refundSync.d.ts.map +1 -0
  13. package/dist/client/connect/refundSync.js +61 -0
  14. package/dist/client/connect/refundSync.js.map +1 -0
  15. package/dist/client/connect/refundSyncValidation.d.ts +16 -0
  16. package/dist/client/connect/refundSyncValidation.d.ts.map +1 -0
  17. package/dist/client/connect/refundSyncValidation.js +87 -0
  18. package/dist/client/connect/refundSyncValidation.js.map +1 -0
  19. package/dist/client/index.d.ts +30 -0
  20. package/dist/client/index.d.ts.map +1 -1
  21. package/dist/client/index.js +5 -0
  22. package/dist/client/index.js.map +1 -1
  23. package/dist/component/_generated/api.d.ts +12 -0
  24. package/dist/component/_generated/api.d.ts.map +1 -1
  25. package/dist/component/_generated/api.js.map +1 -1
  26. package/dist/component/_generated/component.d.ts +67 -0
  27. package/dist/component/_generated/component.d.ts.map +1 -1
  28. package/dist/component/connect/mutations.d.ts.map +1 -1
  29. package/dist/component/connect/mutations.js +2 -53
  30. package/dist/component/connect/mutations.js.map +1 -1
  31. package/dist/component/connect/refundWrites.d.ts +6 -0
  32. package/dist/component/connect/refundWrites.d.ts.map +1 -0
  33. package/dist/component/connect/refundWrites.js +56 -0
  34. package/dist/component/connect/refundWrites.js.map +1 -0
  35. package/dist/component/earnings/triggers.d.ts +46 -0
  36. package/dist/component/earnings/triggers.d.ts.map +1 -1
  37. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  38. package/dist/component/refundHistory/originalSeller.d.ts +1 -1
  39. package/dist/component/refundHistory/originalSeller.d.ts.map +1 -1
  40. package/dist/component/refundHistory/originalSeller.js.map +1 -1
  41. package/dist/component/refundSync/helpers.d.ts +43 -0
  42. package/dist/component/refundSync/helpers.d.ts.map +1 -0
  43. package/dist/component/refundSync/helpers.js +71 -0
  44. package/dist/component/refundSync/helpers.js.map +1 -0
  45. package/dist/component/refundSync/mutations.d.ts +56 -0
  46. package/dist/component/refundSync/mutations.d.ts.map +1 -0
  47. package/dist/component/refundSync/mutations.js +113 -0
  48. package/dist/component/refundSync/mutations.js.map +1 -0
  49. package/dist/component/refundSync/queries.d.ts +12 -0
  50. package/dist/component/refundSync/queries.d.ts.map +1 -0
  51. package/dist/component/refundSync/queries.js +10 -0
  52. package/dist/component/refundSync/queries.js.map +1 -0
  53. package/dist/component/refundSync/routing.d.ts +8 -0
  54. package/dist/component/refundSync/routing.d.ts.map +1 -0
  55. package/dist/component/refundSync/routing.js +42 -0
  56. package/dist/component/refundSync/routing.js.map +1 -0
  57. package/dist/component/refundSync/schema.d.ts +25 -0
  58. package/dist/component/refundSync/schema.d.ts.map +1 -0
  59. package/dist/component/refundSync/schema.js +15 -0
  60. package/dist/component/refundSync/schema.js.map +1 -0
  61. package/dist/component/refundSync/validators.d.ts +164 -0
  62. package/dist/component/refundSync/validators.d.ts.map +1 -0
  63. package/dist/component/refundSync/validators.js +32 -0
  64. package/dist/component/refundSync/validators.js.map +1 -0
  65. package/dist/component/schema.d.ts +23 -0
  66. package/dist/component/schema.js +2 -0
  67. package/dist/component/schema.js.map +1 -1
  68. package/docs/refund-context.md +54 -0
  69. package/package.json +1 -1
  70. package/src/client/connect/refundSync.test.ts +239 -0
  71. package/src/client/connect/refundSync.transport.test.ts +396 -0
  72. package/src/client/connect/refundSync.ts +125 -0
  73. package/src/client/connect/refundSyncValidation.ts +120 -0
  74. package/src/client/index.ts +19 -0
  75. package/src/component/_generated/api.ts +12 -0
  76. package/src/component/_generated/component.ts +100 -0
  77. package/src/component/connect/mutations.ts +2 -67
  78. package/src/component/connect/refundWrites.ts +76 -0
  79. package/src/component/refundHistory/originalSeller.ts +4 -1
  80. package/src/component/refundSync/helpers.ts +99 -0
  81. package/src/component/refundSync/mutations.ts +131 -0
  82. package/src/component/refundSync/queries.ts +10 -0
  83. package/src/component/refundSync/refund-sync.test.ts +255 -0
  84. package/src/component/refundSync/routing.ts +55 -0
  85. package/src/component/refundSync/schema.ts +19 -0
  86. package/src/component/refundSync/validators.ts +35 -0
  87. package/src/component/schema.ts +2 -0
@@ -0,0 +1,12 @@
1
+ /** Trusted-host routing proof only; this does not establish seller dispatch authority. */
2
+ export declare const routing: import("convex/server").RegisteredQuery<"public", {
3
+ stripeRefundId: string;
4
+ stripePaymentIntentId: string;
5
+ stripeChargeId: string;
6
+ currency: string;
7
+ }, Promise<{
8
+ merchantAccount: string | null;
9
+ requiresChargeProof: boolean;
10
+ status: "held" | "known" | "unknown";
11
+ }>>;
12
+ //# sourceMappingURL=queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/refundSync/queries.ts"],"names":[],"mappings":"AAIA,0FAA0F;AAC1F,eAAO,MAAM,OAAO;;;;;;;;;GAIlB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { query } from "../_generated/server.js";
2
+ import { routingInput, routingResult } from "./validators.js";
3
+ import { refundRouting } from "./routing.js";
4
+ /** Trusted-host routing proof only; this does not establish seller dispatch authority. */
5
+ export const routing = query({
6
+ args: routingInput,
7
+ returns: routingResult,
8
+ handler: refundRouting,
9
+ });
10
+ //# sourceMappingURL=queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/component/refundSync/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,0FAA0F;AAC1F,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC;IAC3B,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,aAAa;IACtB,OAAO,EAAE,aAAa;CACvB,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Infer } from "convex/values";
2
+ import type { QueryCtx, MutationCtx } from "../_generated/server.js";
3
+ import type { routingInput, routingResult } from "./validators.js";
4
+ /** Unknown attribution cannot silently inherit a mutable payment's current destination. */
5
+ export declare function refundRouting(ctx: QueryCtx | MutationCtx, input: {
6
+ [K in keyof typeof routingInput]: Infer<(typeof routingInput)[K]>;
7
+ }): Promise<Infer<typeof routingResult>>;
8
+ //# sourceMappingURL=routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../../src/component/refundSync/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGrE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEnE,2FAA2F;AAC3F,wBAAsB,aAAa,CACjC,GAAG,EAAE,QAAQ,GAAG,WAAW,EAC3B,KAAK,EAAE;KAAG,CAAC,IAAI,MAAM,OAAO,YAAY,GAAG,KAAK,CAAC,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC3E,OAAO,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC,CA4CtC"}
@@ -0,0 +1,42 @@
1
+ import { originalRefundSeller } from "../refundHistory/originalSeller.js";
2
+ import { refundById } from "./helpers.js";
3
+ /** Unknown attribution cannot silently inherit a mutable payment's current destination. */
4
+ export async function refundRouting(ctx, input) {
5
+ const existing = await refundById(ctx, input.stripeRefundId);
6
+ const allocations = await ctx.db
7
+ .query("settlementAllocations")
8
+ .withIndex("by_source_charge", (q) => q.eq("sourceChargeId", input.stripeChargeId))
9
+ .take(2);
10
+ const merchant = await originalRefundSeller(ctx, input);
11
+ const payments = await ctx.db
12
+ .query("payments")
13
+ .withIndex("by_stripe_payment_intent_id", (q) => q.eq("stripePaymentIntentId", input.stripePaymentIntentId))
14
+ .take(2);
15
+ if (payments.length > 1 ||
16
+ (payments[0] !== undefined && payments[0].currency !== input.currency) ||
17
+ (allocations.length > 0 && !merchant) ||
18
+ (existing?.accountId !== undefined &&
19
+ !/^acct_[A-Za-z0-9_]{1,250}$/.test(existing.accountId)) ||
20
+ (merchant &&
21
+ existing?.accountId !== undefined &&
22
+ merchant !== existing.accountId))
23
+ return {
24
+ status: "held",
25
+ merchantAccount: null,
26
+ requiresChargeProof: false,
27
+ };
28
+ if (merchant)
29
+ return {
30
+ status: "known",
31
+ merchantAccount: merchant,
32
+ requiresChargeProof: false,
33
+ };
34
+ const payment = payments[0];
35
+ const fallback = payment?.destinationAccountId;
36
+ return {
37
+ status: "unknown",
38
+ merchantAccount: null,
39
+ requiresChargeProof: existing?.accountId !== undefined || fallback !== undefined,
40
+ };
41
+ }
42
+ //# sourceMappingURL=routing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../../src/component/refundSync/routing.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,2FAA2F;AAC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rB,mBAAmB,EAAE,KAAK;SAC3B,CAAC;IACJ,IAAI,QAAQ;QACV,OAAO;YACL,MAAM,EAAE,OAAO;YACf,eAAe,EAAE,QAAQ;YACzB,mBAAmB,EAAE,KAAK;SAC3B,CAAC;IACJ,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,QAAQ,GAAG,OAAO,EAAE,oBAAoB,CAAC;IAC/C,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,eAAe,EAAE,IAAI;QACrB,mBAAmB,EACjB,QAAQ,EAAE,SAAS,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS;KAC9D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ /** Observation claims only; refunds and payment aggregates remain in existing tables. */
2
+ export declare const claimsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
3
+ acceptedAt?: number | undefined;
4
+ acceptedContext?: string | undefined;
5
+ acceptedFingerprint?: string | undefined;
6
+ acceptedGeneration?: number | undefined;
7
+ generation: number;
8
+ requestedContext: string;
9
+ startedAt: number;
10
+ status: "accepted" | "pending" | "unknown";
11
+ stripeRefundId: string;
12
+ }, {
13
+ stripeRefundId: import("convex/values").VString<string, "required">;
14
+ requestedContext: import("convex/values").VString<string, "required">;
15
+ generation: import("convex/values").VFloat64<number, "required">;
16
+ status: import("convex/values").VUnion<"accepted" | "pending" | "unknown", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"accepted", "required">, import("convex/values").VLiteral<"unknown", "required">], "required", never>;
17
+ startedAt: import("convex/values").VFloat64<number, "required">;
18
+ acceptedContext: import("convex/values").VString<string | undefined, "optional">;
19
+ acceptedGeneration: import("convex/values").VFloat64<number | undefined, "optional">;
20
+ acceptedAt: import("convex/values").VFloat64<number | undefined, "optional">;
21
+ acceptedFingerprint: import("convex/values").VString<string | undefined, "optional">;
22
+ }, "required", "acceptedAt" | "acceptedContext" | "acceptedFingerprint" | "acceptedGeneration" | "generation" | "requestedContext" | "startedAt" | "status" | "stripeRefundId">, {
23
+ by_stripe_refund_id: ["stripeRefundId", "_creationTime"];
24
+ }, {}, {}>;
25
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/refundSync/schema.ts"],"names":[],"mappings":"AAGA,yFAAyF;AACzF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;UAc2B,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { defineTable } from "convex/server";
2
+ import { v } from "convex/values";
3
+ /** Observation claims only; refunds and payment aggregates remain in existing tables. */
4
+ export const claimsTable = defineTable({
5
+ stripeRefundId: v.string(),
6
+ requestedContext: v.string(),
7
+ generation: v.number(),
8
+ status: v.union(v.literal("pending"), v.literal("accepted"), v.literal("unknown")),
9
+ startedAt: v.number(),
10
+ acceptedContext: v.optional(v.string()),
11
+ acceptedGeneration: v.optional(v.number()),
12
+ acceptedAt: v.optional(v.number()),
13
+ acceptedFingerprint: v.optional(v.string()),
14
+ }).index("by_stripe_refund_id", ["stripeRefundId"]);
15
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/component/refundSync/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,yFAAyF;AACzF,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;IACrC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC5B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,MAAM,EAAE,CAAC,CAAC,KAAK,CACb,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EACrB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CACrB;IACD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,eAAe,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACvC,kBAAkB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1C,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,mBAAmB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAC5C,CAAC,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,164 @@
1
+ export declare const identity: {
2
+ stripeRefundId: import("convex/values").VString<string, "required">;
3
+ apiContext: import("convex/values").VString<string, "required">;
4
+ };
5
+ export declare const snapshot: import("convex/values").VObject<{
6
+ accountId?: string | undefined;
7
+ amount: number;
8
+ currency: string;
9
+ failureReason?: string | undefined;
10
+ metadata?: Record<string, string> | undefined;
11
+ reason?: "duplicate" | "expired_uncaptured_charge" | "fraudulent" | "requested_by_customer" | undefined;
12
+ status: "canceled" | "failed" | "pending" | "requires_action" | "succeeded";
13
+ stripeChargeId: string;
14
+ stripePaymentIntentId: string;
15
+ stripeRefundId: string;
16
+ }, {
17
+ stripeRefundId: import("convex/values").VString<string, "required">;
18
+ accountId: import("convex/values").VString<string | undefined, "optional">;
19
+ amount: import("convex/values").VFloat64<number, "required">;
20
+ currency: import("convex/values").VString<string, "required">;
21
+ status: import("convex/values").VUnion<"canceled" | "failed" | "pending" | "requires_action" | "succeeded", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"requires_action", "required">, import("convex/values").VLiteral<"succeeded", "required">, import("convex/values").VLiteral<"failed", "required">, import("convex/values").VLiteral<"canceled", "required">], "required", never>;
22
+ reason: import("convex/values").VUnion<"duplicate" | "expired_uncaptured_charge" | "fraudulent" | "requested_by_customer" | undefined, [import("convex/values").VLiteral<"duplicate", "required">, import("convex/values").VLiteral<"fraudulent", "required">, import("convex/values").VLiteral<"requested_by_customer", "required">, import("convex/values").VLiteral<"expired_uncaptured_charge", "required">], "optional", never>;
23
+ failureReason: import("convex/values").VString<string | undefined, "optional">;
24
+ stripePaymentIntentId: import("convex/values").VString<string, "required">;
25
+ stripeChargeId: import("convex/values").VString<string, "required">;
26
+ metadata: import("convex/values").VRecord<Record<string, string> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VString<string, "required">, "optional", string>;
27
+ }, "required", "accountId" | "amount" | "currency" | "failureReason" | "metadata" | "reason" | "status" | "stripeChargeId" | "stripePaymentIntentId" | "stripeRefundId" | `metadata.${string}`>;
28
+ export declare const prepared: {
29
+ stripeRefundId: import("convex/values").VString<string, "required">;
30
+ apiContext: import("convex/values").VString<string, "required">;
31
+ generation: import("convex/values").VFloat64<number, "required">;
32
+ refund: import("convex/values").VObject<{
33
+ accountId?: string | undefined;
34
+ amount: number;
35
+ currency: string;
36
+ failureReason?: string | undefined;
37
+ metadata?: Record<string, string> | undefined;
38
+ reason?: "duplicate" | "expired_uncaptured_charge" | "fraudulent" | "requested_by_customer" | undefined;
39
+ status: "canceled" | "failed" | "pending" | "requires_action" | "succeeded";
40
+ stripeChargeId: string;
41
+ stripePaymentIntentId: string;
42
+ stripeRefundId: string;
43
+ }, {
44
+ stripeRefundId: import("convex/values").VString<string, "required">;
45
+ accountId: import("convex/values").VString<string | undefined, "optional">;
46
+ amount: import("convex/values").VFloat64<number, "required">;
47
+ currency: import("convex/values").VString<string, "required">;
48
+ status: import("convex/values").VUnion<"canceled" | "failed" | "pending" | "requires_action" | "succeeded", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"requires_action", "required">, import("convex/values").VLiteral<"succeeded", "required">, import("convex/values").VLiteral<"failed", "required">, import("convex/values").VLiteral<"canceled", "required">], "required", never>;
49
+ reason: import("convex/values").VUnion<"duplicate" | "expired_uncaptured_charge" | "fraudulent" | "requested_by_customer" | undefined, [import("convex/values").VLiteral<"duplicate", "required">, import("convex/values").VLiteral<"fraudulent", "required">, import("convex/values").VLiteral<"requested_by_customer", "required">, import("convex/values").VLiteral<"expired_uncaptured_charge", "required">], "optional", never>;
50
+ failureReason: import("convex/values").VString<string | undefined, "optional">;
51
+ stripePaymentIntentId: import("convex/values").VString<string, "required">;
52
+ stripeChargeId: import("convex/values").VString<string, "required">;
53
+ metadata: import("convex/values").VRecord<Record<string, string> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VString<string, "required">, "optional", string>;
54
+ }, "required", "accountId" | "amount" | "currency" | "failureReason" | "metadata" | "reason" | "status" | "stripeChargeId" | "stripePaymentIntentId" | "stripeRefundId" | `metadata.${string}`>;
55
+ };
56
+ export declare const result: import("convex/values").VUnion<{
57
+ changed: boolean;
58
+ generation: number;
59
+ refund: {
60
+ _creationTime: number;
61
+ _id: import("convex/values").GenericId<"refunds">;
62
+ accountId?: string | undefined;
63
+ amount: number;
64
+ currency: string;
65
+ failureReason?: string | undefined;
66
+ metadata?: any;
67
+ reason?: "duplicate" | "expired_uncaptured_charge" | "fraudulent" | "requested_by_customer" | undefined;
68
+ refundCommandConflict?: boolean | undefined;
69
+ refundCommandKey?: string | undefined;
70
+ refundCommandNormalizationVersion?: 1 | undefined;
71
+ refundCommandObservedAt?: number | undefined;
72
+ status: "canceled" | "failed" | "pending" | "requires_action" | "succeeded";
73
+ stripeChargeId?: string | undefined;
74
+ stripePaymentIntentId?: string | undefined;
75
+ stripeRefundId: string;
76
+ };
77
+ status: "accepted";
78
+ } | {
79
+ generation: number;
80
+ status: "superseded";
81
+ }, [import("convex/values").VObject<{
82
+ changed: boolean;
83
+ generation: number;
84
+ refund: {
85
+ _creationTime: number;
86
+ _id: import("convex/values").GenericId<"refunds">;
87
+ accountId?: string | undefined;
88
+ amount: number;
89
+ currency: string;
90
+ failureReason?: string | undefined;
91
+ metadata?: any;
92
+ reason?: "duplicate" | "expired_uncaptured_charge" | "fraudulent" | "requested_by_customer" | undefined;
93
+ refundCommandConflict?: boolean | undefined;
94
+ refundCommandKey?: string | undefined;
95
+ refundCommandNormalizationVersion?: 1 | undefined;
96
+ refundCommandObservedAt?: number | undefined;
97
+ status: "canceled" | "failed" | "pending" | "requires_action" | "succeeded";
98
+ stripeChargeId?: string | undefined;
99
+ stripePaymentIntentId?: string | undefined;
100
+ stripeRefundId: string;
101
+ };
102
+ status: "accepted";
103
+ }, {
104
+ status: import("convex/values").VLiteral<"accepted", "required">;
105
+ generation: import("convex/values").VFloat64<number, "required">;
106
+ changed: import("convex/values").VBoolean<boolean, "required">;
107
+ refund: import("convex/values").VObject<{
108
+ _creationTime: number;
109
+ _id: import("convex/values").GenericId<"refunds">;
110
+ accountId?: string | undefined;
111
+ amount: number;
112
+ currency: string;
113
+ failureReason?: string | undefined;
114
+ metadata?: any;
115
+ reason?: "duplicate" | "expired_uncaptured_charge" | "fraudulent" | "requested_by_customer" | undefined;
116
+ refundCommandConflict?: boolean | undefined;
117
+ refundCommandKey?: string | undefined;
118
+ refundCommandNormalizationVersion?: 1 | undefined;
119
+ refundCommandObservedAt?: number | undefined;
120
+ status: "canceled" | "failed" | "pending" | "requires_action" | "succeeded";
121
+ stripeChargeId?: string | undefined;
122
+ stripePaymentIntentId?: string | undefined;
123
+ stripeRefundId: string;
124
+ }, {
125
+ refundCommandNormalizationVersion: import("convex/values").VLiteral<1 | undefined, "optional">;
126
+ refundCommandKey: import("convex/values").VString<string | undefined, "optional">;
127
+ refundCommandConflict: import("convex/values").VBoolean<boolean | undefined, "optional">;
128
+ refundCommandObservedAt: import("convex/values").VFloat64<number | undefined, "optional">;
129
+ stripeRefundId: import("convex/values").VString<string, "required">;
130
+ stripePaymentIntentId: import("convex/values").VString<string | undefined, "optional">;
131
+ stripeChargeId: import("convex/values").VString<string | undefined, "optional">;
132
+ accountId: import("convex/values").VString<string | undefined, "optional">;
133
+ amount: import("convex/values").VFloat64<number, "required">;
134
+ currency: import("convex/values").VString<string, "required">;
135
+ status: import("convex/values").VUnion<"canceled" | "failed" | "pending" | "requires_action" | "succeeded", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"requires_action", "required">, import("convex/values").VLiteral<"succeeded", "required">, import("convex/values").VLiteral<"failed", "required">, import("convex/values").VLiteral<"canceled", "required">], "required", never>;
136
+ reason: import("convex/values").VUnion<"duplicate" | "expired_uncaptured_charge" | "fraudulent" | "requested_by_customer" | undefined, [import("convex/values").VLiteral<"duplicate", "required">, import("convex/values").VLiteral<"fraudulent", "required">, import("convex/values").VLiteral<"requested_by_customer", "required">, import("convex/values").VLiteral<"expired_uncaptured_charge", "required">], "optional", never>;
137
+ failureReason: import("convex/values").VString<string | undefined, "optional">;
138
+ metadata: import("convex/values").VAny<any, "optional", string>;
139
+ _id: import("convex/values").VId<import("convex/values").GenericId<"refunds">, "required">;
140
+ _creationTime: import("convex/values").VFloat64<number, "required">;
141
+ }, "required", "_creationTime" | "_id" | "accountId" | "amount" | "currency" | "failureReason" | "metadata" | "reason" | "refundCommandConflict" | "refundCommandKey" | "refundCommandNormalizationVersion" | "refundCommandObservedAt" | "status" | "stripeChargeId" | "stripePaymentIntentId" | "stripeRefundId" | `metadata.${string}`>;
142
+ }, "required", "changed" | "generation" | "refund" | "refund._creationTime" | "refund._id" | "refund.accountId" | "refund.amount" | "refund.currency" | "refund.failureReason" | "refund.metadata" | "refund.reason" | "refund.refundCommandConflict" | "refund.refundCommandKey" | "refund.refundCommandNormalizationVersion" | "refund.refundCommandObservedAt" | "refund.status" | "refund.stripeChargeId" | "refund.stripePaymentIntentId" | "refund.stripeRefundId" | "status" | `refund.metadata.${string}`>, import("convex/values").VObject<{
143
+ generation: number;
144
+ status: "superseded";
145
+ }, {
146
+ status: import("convex/values").VLiteral<"superseded", "required">;
147
+ generation: import("convex/values").VFloat64<number, "required">;
148
+ }, "required", "generation" | "status">], "required", "changed" | "generation" | "refund" | "refund._creationTime" | "refund._id" | "refund.accountId" | "refund.amount" | "refund.currency" | "refund.failureReason" | "refund.metadata" | "refund.reason" | "refund.refundCommandConflict" | "refund.refundCommandKey" | "refund.refundCommandNormalizationVersion" | "refund.refundCommandObservedAt" | "refund.status" | "refund.stripeChargeId" | "refund.stripePaymentIntentId" | "refund.stripeRefundId" | "status" | `refund.metadata.${string}`>;
149
+ export declare const routingInput: {
150
+ stripeRefundId: import("convex/values").VString<string, "required">;
151
+ stripePaymentIntentId: import("convex/values").VString<string, "required">;
152
+ stripeChargeId: import("convex/values").VString<string, "required">;
153
+ currency: import("convex/values").VString<string, "required">;
154
+ };
155
+ export declare const routingResult: import("convex/values").VObject<{
156
+ merchantAccount: string | null;
157
+ requiresChargeProof: boolean;
158
+ status: "held" | "known" | "unknown";
159
+ }, {
160
+ status: import("convex/values").VUnion<"held" | "known" | "unknown", [import("convex/values").VLiteral<"known", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"held", "required">], "required", never>;
161
+ merchantAccount: import("convex/values").VUnion<string | null, [import("convex/values").VString<string, "required">, import("convex/values").VNull<null, "required">], "required", never>;
162
+ requiresChargeProof: import("convex/values").VBoolean<boolean, "required">;
163
+ }, "required", "merchantAccount" | "requiresChargeProof" | "status">;
164
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/component/refundSync/validators.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ;IAAK,cAAc;IAAc,UAAU;CAAc,CAAC;AAC/E,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;+LAKnB,CAAC;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIpB,CAAC;AACF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yhBAQlB,CAAC;AACF,eAAO,MAAM,YAAY;IACvB,cAAc;IACd,qBAAqB;IACrB,cAAc;IACd,QAAQ;CACT,CAAC;AACF,eAAO,MAAM,aAAa;;;;;;;;oEAIxB,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { v } from "convex/values";
2
+ import { refundFields, refundDocValidator } from "../connect/validators.js";
3
+ export const identity = { stripeRefundId: v.string(), apiContext: v.string() };
4
+ export const snapshot = v.object({
5
+ ...refundFields,
6
+ stripePaymentIntentId: v.string(),
7
+ stripeChargeId: v.string(),
8
+ metadata: v.optional(v.record(v.string(), v.string())),
9
+ });
10
+ export const prepared = {
11
+ ...identity,
12
+ generation: v.number(),
13
+ refund: snapshot,
14
+ };
15
+ export const result = v.union(v.object({
16
+ status: v.literal("accepted"),
17
+ generation: v.number(),
18
+ changed: v.boolean(),
19
+ refund: refundDocValidator,
20
+ }), v.object({ status: v.literal("superseded"), generation: v.number() }));
21
+ export const routingInput = {
22
+ stripeRefundId: v.string(),
23
+ stripePaymentIntentId: v.string(),
24
+ stripeChargeId: v.string(),
25
+ currency: v.string(),
26
+ };
27
+ export const routingResult = v.object({
28
+ status: v.union(v.literal("known"), v.literal("unknown"), v.literal("held")),
29
+ merchantAccount: v.union(v.string(), v.null()),
30
+ requiresChargeProof: v.boolean(),
31
+ });
32
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/component/refundSync/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE5E,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;AAC/E,MAAM,CAAC,MAAM,QAAQ,GAAG,C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E,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5E,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,mBAAmB,EAAE,CAAC,CAAC,OAAO,EAAE;CACjC,CAAC,CAAC"}
@@ -1,4 +1,27 @@
1
1
  declare const _default: import("convex/server").SchemaDefinition<{
2
+ refundSyncClaims: import("convex/server").TableDefinition<import("convex/values").VObject<{
3
+ acceptedAt?: number | undefined;
4
+ acceptedContext?: string | undefined;
5
+ acceptedFingerprint?: string | undefined;
6
+ acceptedGeneration?: number | undefined;
7
+ generation: number;
8
+ requestedContext: string;
9
+ startedAt: number;
10
+ status: "accepted" | "pending" | "unknown";
11
+ stripeRefundId: string;
12
+ }, {
13
+ stripeRefundId: import("convex/values").VString<string, "required">;
14
+ requestedContext: import("convex/values").VString<string, "required">;
15
+ generation: import("convex/values").VFloat64<number, "required">;
16
+ status: import("convex/values").VUnion<"accepted" | "pending" | "unknown", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"accepted", "required">, import("convex/values").VLiteral<"unknown", "required">], "required", never>;
17
+ startedAt: import("convex/values").VFloat64<number, "required">;
18
+ acceptedContext: import("convex/values").VString<string | undefined, "optional">;
19
+ acceptedGeneration: import("convex/values").VFloat64<number | undefined, "optional">;
20
+ acceptedAt: import("convex/values").VFloat64<number | undefined, "optional">;
21
+ acceptedFingerprint: import("convex/values").VString<string | undefined, "optional">;
22
+ }, "required", "acceptedAt" | "acceptedContext" | "acceptedFingerprint" | "acceptedGeneration" | "generation" | "requestedContext" | "startedAt" | "status" | "stripeRefundId">, {
23
+ by_stripe_refund_id: ["stripeRefundId", "_creationTime"];
24
+ }, {}, {}>;
2
25
  processingCostReconciliationOperations: import("convex/server").TableDefinition<import("convex/values").VObject<{
3
26
  accountId: string;
4
27
  claimKey: string;
@@ -1,3 +1,4 @@
1
+ import { claimsTable as refundSyncClaimsTable } from "./refundSync/schema.js";
1
2
  import { operationsTable as processingCostReconciliationOperations } from "./processingCostReconciliation/schema.js";
2
3
  import { operationsTable as recoveryWorkflowOperations, requestsTable as recoveryWorkflowRequests, } from "./recoveryWorkflow/schema.js";
3
4
  import { preparationsTable as balanceFundingPreparations, operationsTable as balanceFundingOperations, requestsTable as balanceFundingRequests, } from "./balanceFunding/schema.js";
@@ -24,6 +25,7 @@ import { accountsTable } from "./core/schema";
24
25
  import { pricesTable, productsTable } from "./products/schema";
25
26
  import { webhookEventsTable } from "./webhooks/schema";
26
27
  export default defineSchema({
28
+ refundSyncClaims: refundSyncClaimsTable,
27
29
  processingCostReconciliationOperations,
28
30
  recoveryWorkflowOperations,
29
31
  recoveryWorkflowRequests,
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,sCAAsC,EAAE,MAAM,0CAA0C,CAAC;AACrH,OAAO,EACL,eAAe,IAAI,0BAA0B,EAC7C,aAAa,IAAI,wBAAwB,GAC1C,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,iBAAiB,IAAI,0BAA0B,EAC/C,eAAe,IAAI,wBAAwB,EAC3C,aAAa,IAAI,sBAAsB,GACxC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,aAAa,IAAI,yBAAyB,EAC1C,YAAY,IAAI,wBAAwB,GACzC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAClG,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,2BAA2B,GAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAA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C3B,oBAAoB,EAAE,iBAAiB;IACvC,qBAAqB,EAAE,gBAAgB;IACvC,eAAe,EAAE,oBAAoB;IACrC,mBAAmB,EAAE,wBAAwB;IAC7C,OAAO;IACP,QAAQ,EAAE,aAAa;IACvB,eAAe,EAAE,oBAAoB;IAErC,WAAW;IACX,QAAQ,EAAE,aAAa;IACvB,MAAM,EAAE,WAAW;IAEnB,UAAU;IACV,aAAa,EAAE,kBAAkB;IACjC,gBAAgB,EAAE,qBAAqB;IACvC,QAAQ,EAAE,aAAa;IAEvB,UAAU;IACV,QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,YAAY;IACrB,iBAAiB,EAAE,sBAAsB;IACzC,OAAO,EAAE,YAAY;IACrB,QAAQ,EAAE,aAAa;IACvB,SAAS,EAAE,cAAc;IACzB,mBAAmB,EAAE,wBAAwB;IAE7C,WAAW;IACX,aAAa,EAAE,kBAAkB;CAClC,CAAC,CAAC"}
@@ -82,3 +82,57 @@ PaymentIntent's refund authority. Deny ambiguous cross-invoice/community scopes
82
82
  until a safe original-payment binding is established. A ready zero remainder
83
83
  must not enable another refund. This reader does not grant authority to remove
84
84
  access, cancel a subscription or change the original financial recipients.
85
+
86
+ ## Current refund synchronization
87
+
88
+ `betterStripe.syncRefundFromStripe(ctx, { stripeRefundId, scope })` is a separate
89
+ trusted-host operation. It retrieves the current provider refund and synchronizes
90
+ the existing component refund/payment projection. It never creates or cancels a
91
+ refund, reverses transfers, changes access or authorizes a retry. Hosts must
92
+ authenticate and authorize the original refund and provider API scope before
93
+ calling it; the method is not an application authorization boundary.
94
+
95
+ ```ts
96
+ const observation = await betterStripe.syncRefundFromStripe(ctx, {
97
+ stripeRefundId: originalRefundId,
98
+ scope: { type: "platform" },
99
+ });
100
+ // Or use { type: "connected", accountId: trustedOriginalApiAccount }.
101
+ ```
102
+
103
+ The API namespace is required and runtime validated before component/provider
104
+ access. A connected API account is not a buyer, destination merchant or seller
105
+ entitlement. Provider metadata cannot select that account. Original merchant
106
+ attribution uses the existing immutable store-allocation proof, or the original
107
+ charge's destination when needed to qualify a legacy destination fallback.
108
+ Known original merchant/PI/charge/currency/amount disagreement or ambiguous evidence
109
+ holds the observation. An unattributed refund can remain unattributed where no
110
+ legacy destination fallback would invent an owner. This does not establish seller
111
+ authorization or historical ingestion completeness.
112
+
113
+ Each current read receives a durable per-refund generation. Only the newest
114
+ claimed generation can commit the qualified snapshot and existing cumulative
115
+ payment projection together. An older completion returns `superseded` without
116
+ writing that snapshot, including when the newer read failed. Superseded is not
117
+ proof that any newer observation succeeded. `accepted` returns the generation,
118
+ `changed` and stored refund; it is an observation, not financial completion.
119
+ Current `succeeded` may legitimately become `requires_action`, `pending` or later
120
+ failure. No status ordering, provider revision or webhook timestamp is invented.
121
+
122
+ Provider or accepting-transaction failures propagate rather than falling back to
123
+ a notification snapshot. A failed pending generation is marked unknown when that
124
+ marker can be saved. Lost responses can leave a pending or accepted generation;
125
+ a fresh explicit observation obtains a new generation. It does not dispatch a
126
+ refund. The original cumulative writer remains a complete indexed collection of
127
+ all refund rows for the payment, excluding failed/canceled contributions. Failed
128
+ history is not cardinality bounded: native resource limits can abort the whole
129
+ accepting transaction, preserving the last committed projection. There is no
130
+ partial sum, silent truncation or all-backlog-capacity guarantee.
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.
137
+ The server-only Vite reference is
138
+ [`example/convex/connect/refundSync.ts`](../example/convex/connect/refundSync.ts).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fantastic.dev/better-stripe",
3
- "version": "0.45.2",
3
+ "version": "0.46.0",
4
4
  "description": "A Convex component for Stripe V2 Accounts API integration.",
5
5
  "keywords": [
6
6
  "stripe",