@fantastic.dev/better-stripe 0.48.1 → 0.49.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 (52) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/invoicePaymentPages.d.ts +2 -5
  4. package/dist/client/billing/invoicePaymentPages.d.ts.map +1 -1
  5. package/dist/client/billing/invoicePaymentPages.js +2 -58
  6. package/dist/client/billing/invoicePaymentPages.js.map +1 -1
  7. package/dist/client/billing/invoicePaymentRead.d.ts +17 -0
  8. package/dist/client/billing/invoicePaymentRead.d.ts.map +1 -0
  9. package/dist/client/billing/invoicePaymentRead.js +25 -0
  10. package/dist/client/billing/invoicePaymentRead.js.map +1 -0
  11. package/dist/client/billing/invoicePaymentShared.d.ts +22 -0
  12. package/dist/client/billing/invoicePaymentShared.d.ts.map +1 -0
  13. package/dist/client/billing/invoicePaymentShared.js +62 -0
  14. package/dist/client/billing/invoicePaymentShared.js.map +1 -0
  15. package/dist/client/billing/subscription-payment-method.d.ts +28 -0
  16. package/dist/client/billing/subscription-payment-method.d.ts.map +1 -0
  17. package/dist/client/billing/subscription-payment-method.js +101 -0
  18. package/dist/client/billing/subscription-payment-method.js.map +1 -0
  19. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
  20. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
  21. package/dist/client/index.d.ts +5 -0
  22. package/dist/client/index.d.ts.map +1 -1
  23. package/dist/client/index.js +5 -0
  24. package/dist/client/index.js.map +1 -1
  25. package/dist/client/invoiceReads.d.ts +3 -0
  26. package/dist/client/invoiceReads.d.ts.map +1 -1
  27. package/dist/client/invoiceReads.js +5 -0
  28. package/dist/client/invoiceReads.js.map +1 -1
  29. package/dist/component/_generated/component.d.ts +1 -0
  30. package/dist/component/_generated/component.d.ts.map +1 -1
  31. package/dist/component/balanceFunding/mutations.d.ts +16 -16
  32. package/dist/component/connect/queries.d.ts +1 -0
  33. package/dist/component/connect/queries.d.ts.map +1 -1
  34. package/dist/component/connect/queries.js +10 -4
  35. package/dist/component/connect/queries.js.map +1 -1
  36. package/dist/component/refundHistory/queries.d.ts +1 -1
  37. package/docs/invoice-payment-pages.md +62 -0
  38. package/docs/read-contracts.md +45 -0
  39. package/docs/subscription-payment-methods.md +121 -0
  40. package/package.json +2 -1
  41. package/src/client/billing/invoicePaymentPages.ts +9 -74
  42. package/src/client/billing/invoicePaymentRead.test.ts +233 -0
  43. package/src/client/billing/invoicePaymentRead.ts +44 -0
  44. package/src/client/billing/invoicePaymentReadTransport.test.ts +101 -0
  45. package/src/client/billing/invoicePaymentShared.ts +84 -0
  46. package/src/client/billing/subscription-payment-method.test.ts +460 -0
  47. package/src/client/billing/subscription-payment-method.ts +177 -0
  48. package/src/client/index.ts +21 -0
  49. package/src/client/invoiceReads.ts +9 -0
  50. package/src/component/_generated/component.ts +1 -1
  51. package/src/component/connect/payment-unique.test.ts +195 -0
  52. package/src/component/connect/queries.ts +9 -4
package/CHANGELOG.md CHANGED
@@ -26,6 +26,25 @@
26
26
  - Remove internal tracker references from public documentation and add a
27
27
  regression check that prevents their reintroduction.
28
28
 
29
+ ## [0.49.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.48.1...v0.49.0) (2026-10-17)
30
+
31
+ ### Features
32
+
33
+ - add exact invoice-payment read with original scope verification ([c87abb3](https://github.com/FantasticDevHQ/better-stripe/commit/c87abb3d243f3c18fc2ccf37ef05c22c1eb463c3))
34
+ - read exact invoice payments with verified original scope ([f96853e](https://github.com/FantasticDevHQ/better-stripe/commit/f96853e1656fbc1ded60a87e58920598b90fd62a))
35
+ - scope card selection to an original subscription ([b1165e2](https://github.com/FantasticDevHQ/better-stripe/commit/b1165e20b058aa064c41b047b4226f709eab7cc6))
36
+
37
+ ### Bug Fixes
38
+
39
+ - add opt-in exact PaymentIntent uniqueness ([f440725](https://github.com/FantasticDevHQ/better-stripe/commit/f4407258df63aeb448bb213ce870c70e000be56d))
40
+ - add opt-in unique cached PaymentIntent reads ([0148352](https://github.com/FantasticDevHQ/better-stripe/commit/0148352f011917e45500f8521ae30d0e0682d491))
41
+ - snapshot original subscription card selectors before reads ([eb92b1c](https://github.com/FantasticDevHQ/better-stripe/commit/eb92b1cc84943aef7ea38808cbeb120b7ed0de8e))
42
+
43
+ ### Maintenance
44
+
45
+ - ratchet measured exact invoice-payment coverage floors ([3fc1443](https://github.com/FantasticDevHQ/better-stripe/commit/3fc1443fd4da8dea011ebf2821f754dad0c4a207))
46
+ - record native-generated strict payment reference ([17198e8](https://github.com/FantasticDevHQ/better-stripe/commit/17198e81733641507c872602d0170c216b42a58f))
47
+
29
48
  ## [0.48.1](https://github.com/FantasticDevHQ/better-stripe/compare/v0.48.0...v0.48.1) (2026-10-17)
30
49
 
31
50
  ### Bug Fixes
package/README.md CHANGED
@@ -72,7 +72,7 @@ claim execution are completed.
72
72
 
73
73
  ## Status
74
74
 
75
- **Version**: `0.48.1` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
75
+ **Version**: `0.49.0` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
76
76
 
77
77
  Used in production by its authors. Webhook pipeline is covered by unit tests and a live E2E harness (`npm run e2e:webhooks`) that fires real Stripe-signed events and asserts the ledger.
78
78
 
@@ -1,4 +1,5 @@
1
1
  import type Stripe from "stripe";
2
+ import { type ProviderInvoicePaymentReference } from "./invoicePaymentShared.js";
2
3
  import { z } from "zod";
3
4
  declare const optionsSchema: z.ZodObject<{
4
5
  stripeInvoiceId: z.ZodString;
@@ -14,11 +15,7 @@ export type ProviderInvoicePaymentPage = {
14
15
  customerAccount: string;
15
16
  stripeSubscriptionId: string;
16
17
  };
17
- page: {
18
- invoicePayment: Stripe.InvoicePayment;
19
- paymentIntentId: string | null;
20
- referenceStatus: "payment_intent" | "unsupported" | "unavailable";
21
- }[];
18
+ page: ProviderInvoicePaymentReference[];
22
19
  hasMore: boolean;
23
20
  continueCursor: string | null;
24
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"invoicePaymentPages.d.ts","sourceRoot":"","sources":["../../../src/client/billing/invoicePaymentPages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkBxB,QAAA,MAAM,aAAa;;;;;;kBAKR,CAAC;AAWZ,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACtE,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE;QACL,eAAe,EAAE,MAAM,CAAC;QACxB,eAAe,EAAE,MAAM,CAAC;QACxB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,CAAC;IACF,IAAI,EAAE;QACJ,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC;QACtC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,eAAe,EAAE,gBAAgB,GAAG,aAAa,GAAG,aAAa,CAAC;KACnE,EAAE,CAAC;IACJ,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAiEF,gHAAgH;AAChH,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,0BAA0B,CAAC,CA8CrC"}
1
+ {"version":3,"file":"invoicePaymentPages.d.ts","sourceRoot":"","sources":["../../../src/client/billing/invoicePaymentPages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAKL,KAAK,+BAA+B,EACrC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,aAAa;;;;;;kBAKR,CAAC;AAWZ,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACtE,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE;QACL,eAAe,EAAE,MAAM,CAAC;QACxB,eAAe,EAAE,MAAM,CAAC;QACxB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,CAAC;IACF,IAAI,EAAE,+BAA+B,EAAE,CAAC;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAyBF,gHAAgH;AAChH,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,0BAA0B,CAAC,CAkCrC"}
@@ -1,20 +1,5 @@
1
+ import { assertInvoicePaymentScope, invoicePaymentScopeSchema as scopeSchema, paymentReference, referenceId, } from "./invoicePaymentShared.js";
1
2
  import { z } from "zod";
2
- const scopeSchema = z
3
- .object({
4
- stripeInvoiceId: z
5
- .string()
6
- .max(128)
7
- .regex(/^in_[A-Za-z0-9_]+$/),
8
- customerAccount: z
9
- .string()
10
- .max(128)
11
- .regex(/^acct_[A-Za-z0-9_]+$/),
12
- stripeSubscriptionId: z
13
- .string()
14
- .max(128)
15
- .regex(/^sub_[A-Za-z0-9_]+$/),
16
- })
17
- .strict();
18
3
  const optionsSchema = scopeSchema
19
4
  .extend({
20
5
  limit: z.number().int().min(1).max(100).default(25),
@@ -53,52 +38,11 @@ function decodeCursor(cursor, scope) {
53
38
  throw new Error("Invalid invoice payment page cursor or scope");
54
39
  }
55
40
  }
56
- /** Normalize provider references without inferring missing identifiers. */
57
- function referenceId(value) {
58
- return typeof value === "string" ? value : value?.id;
59
- }
60
- /** Keep financial evidence exact; reject units that JavaScript cannot safely represent. */
61
- function assertRepresentableUnits(row) {
62
- const amounts = [
63
- row.amount_requested,
64
- ...(row.amount_paid === null ? [] : [row.amount_paid]),
65
- ];
66
- if (amounts.some((amount) => !Number.isSafeInteger(amount) || amount < 0) ||
67
- !/^[a-z]{3}$/.test(row.currency)) {
68
- throw new Error("Invalid provider invoice payment units or currency");
69
- }
70
- }
71
- /** Retain unsupported rows while distinguishing canonical and unavailable references. */
72
- function paymentReference(invoicePayment) {
73
- assertRepresentableUnits(invoicePayment);
74
- const type = invoicePayment.payment.type;
75
- const id = type === "payment_intent"
76
- ? referenceId(invoicePayment.payment.payment_intent)
77
- : undefined;
78
- const paymentIntentId = id && /^pi_[A-Za-z0-9_]+$/.test(id) ? id : null;
79
- return {
80
- invoicePayment,
81
- paymentIntentId,
82
- referenceStatus: type !== "payment_intent"
83
- ? "unsupported"
84
- : paymentIntentId
85
- ? "payment_intent"
86
- : "unavailable",
87
- };
88
- }
89
41
  /** Canonical provider references only. The host authorizes scope and separately verifies refund eligibility. */
90
42
  export async function getInvoicePaymentPageFromStripe(stripe, input) {
91
43
  const { limit, cursor, ...scope } = optionsSchema.parse(input);
92
44
  const after = cursor ? decodeCursor(cursor, scope) : undefined;
93
- const invoice = await stripe.invoices.retrieve(scope.stripeInvoiceId);
94
- const parent = invoice.parent;
95
- if (invoice.id !== scope.stripeInvoiceId ||
96
- invoice.customer_account !== scope.customerAccount ||
97
- parent?.type !== "subscription_details" ||
98
- referenceId(parent.subscription_details?.subscription) !==
99
- scope.stripeSubscriptionId) {
100
- throw new Error("Invalid provider invoice payment buyer or subscription scope");
101
- }
45
+ await assertInvoicePaymentScope(stripe, scope);
102
46
  const response = await stripe.invoicePayments.list({
103
47
  invoice: scope.stripeInvoiceId,
104
48
  limit,
@@ -1 +1 @@
1
- {"version":3,"file":"invoicePaymentPages.js","sourceRoot":"","sources":["../../../src/client/billing/invoicePaymentPages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,WAAW,GAAG,CAAC;KAClB,MAAM,CAAC;IACN,eAAe,EAAE,CAAC;SACf,MAAM,EAAE;SACR,GAAG,CAAC,GAAG,CAAC;SACR,KAAK,C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AAI,CAAC,GAAG,CAAC,gBAAgB,CAAC;QACzC,OAAO,EAAE,QAAQ,CAAC,QAAQ;QAC1B,cAAc,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,IAAK,CAAC,CAAC,CAAC,CAAC,IAAI;KACtE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type Stripe from "stripe";
2
+ import { z } from "zod";
3
+ import { type InvoicePaymentScope, type ProviderInvoicePaymentReference } from "./invoicePaymentShared.js";
4
+ declare const optionsSchema: z.ZodObject<{
5
+ stripeInvoiceId: z.ZodString;
6
+ customerAccount: z.ZodString;
7
+ stripeSubscriptionId: z.ZodString;
8
+ stripeInvoicePaymentId: z.ZodString;
9
+ }, z.core.$strict>;
10
+ export type InvoicePaymentReadOptions = z.input<typeof optionsSchema>;
11
+ export type ProviderInvoicePaymentRead = ProviderInvoicePaymentReference & {
12
+ scope: InvoicePaymentScope;
13
+ };
14
+ /** Exact platform read, without page enumeration or refund-eligibility inference. */
15
+ export declare function getInvoicePaymentFromStripe(stripe: Stripe, input: InvoicePaymentReadOptions): Promise<ProviderInvoicePaymentRead>;
16
+ export {};
17
+ //# sourceMappingURL=invoicePaymentRead.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoicePaymentRead.d.ts","sourceRoot":"","sources":["../../../src/client/billing/invoicePaymentRead.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAKL,KAAK,mBAAmB,EACxB,KAAK,+BAA+B,EACrC,MAAM,2BAA2B,CAAC;AAEnC,QAAA,MAAM,aAAa;;;;;kBAOR,CAAC;AAEZ,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACtE,MAAM,MAAM,0BAA0B,GAAG,+BAA+B,GAAG;IACzE,KAAK,EAAE,mBAAmB,CAAC;CAC5B,CAAC;AAEF,qFAAqF;AACrF,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,0BAA0B,CAAC,CAcrC"}
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ import { assertInvoicePaymentScope, invoicePaymentScopeSchema, paymentReference, referenceId, } from "./invoicePaymentShared.js";
3
+ const optionsSchema = invoicePaymentScopeSchema
4
+ .extend({
5
+ stripeInvoicePaymentId: z
6
+ .string()
7
+ .max(128)
8
+ .regex(/^inpay_[A-Za-z0-9_]+$/),
9
+ })
10
+ .strict();
11
+ /** Exact platform read, without page enumeration or refund-eligibility inference. */
12
+ export async function getInvoicePaymentFromStripe(stripe, input) {
13
+ const { stripeInvoicePaymentId, ...scope } = optionsSchema.parse(input);
14
+ await assertInvoicePaymentScope(stripe, scope);
15
+ const row = await stripe.invoicePayments.retrieve(stripeInvoicePaymentId);
16
+ if (!row ||
17
+ row.object !== "invoice_payment" ||
18
+ row.id !== stripeInvoicePaymentId ||
19
+ referenceId(row.invoice) !== scope.stripeInvoiceId ||
20
+ !row.payment ||
21
+ typeof row.payment.type !== "string")
22
+ throw new Error("Invalid provider exact invoice payment scope or record");
23
+ return { scope, ...paymentReference(row) };
24
+ }
25
+ //# sourceMappingURL=invoicePaymentRead.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoicePaymentRead.js","sourceRoot":"","sources":["../../../src/client/billing/invoicePaymentRead.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EAChB,WAAW,GAGZ,MAAM,2BAA2B,CAAC;AAEnC,MAAM,aAAa,GAAG,yBAAyB;KAC5C,MAAM,CAAC;IACN,sBAAsB,EAAE,CAAC;SACtB,MAAM,EAAE;SACR,GAAG,CAAC,GAAG,CAAC;SACR,KAAK,CAAC,uBAAuB,CAAC;CAClC,CAAC;KACD,MAAM,EAAE,CAAC;AAOZ,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,MAAc,EACd,KAAgC;IAEhC,MAAM,EAAE,sBAAsB,EAAE,GAAG,KAAK,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACxE,MAAM,yBAAyB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/C,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;IAC1E,IACE,CAAC,GAAG;QACJ,GAAG,CAAC,MAAM,KAAK,iBAAiB;QAChC,GAAG,CAAC,EAAE,KAAK,sBAAsB;QACjC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,eAAe;QAClD,CAAC,GAAG,CAAC,OAAO;QACZ,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ;QAEpC,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,OAAO,EAAE,KAAK,EAAE,GAAG,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type Stripe from "stripe";
2
+ import { z } from "zod";
3
+ export declare const invoicePaymentScopeSchema: z.ZodObject<{
4
+ stripeInvoiceId: z.ZodString;
5
+ customerAccount: z.ZodString;
6
+ stripeSubscriptionId: z.ZodString;
7
+ }, z.core.$strict>;
8
+ export type InvoicePaymentScope = z.infer<typeof invoicePaymentScopeSchema>;
9
+ export type ProviderInvoicePaymentReference = {
10
+ invoicePayment: Stripe.InvoicePayment;
11
+ paymentIntentId: string | null;
12
+ referenceStatus: "payment_intent" | "unsupported" | "unavailable";
13
+ };
14
+ /** Normalize provider references without inferring missing identifiers. */
15
+ export declare function referenceId(value: string | {
16
+ id: string;
17
+ } | null | undefined): string | undefined;
18
+ /** Retain unsupported rows while distinguishing canonical and unavailable references. */
19
+ export declare function paymentReference(invoicePayment: Stripe.InvoicePayment): ProviderInvoicePaymentReference;
20
+ /** Provider observation only; the caller still authorizes original host scope. */
21
+ export declare function assertInvoicePaymentScope(stripe: Stripe, scope: InvoicePaymentScope): Promise<void>;
22
+ //# sourceMappingURL=invoicePaymentShared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoicePaymentShared.d.ts","sourceRoot":"","sources":["../../../src/client/billing/invoicePaymentShared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,yBAAyB;;;;kBAe3B,CAAC;AACZ,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,+BAA+B,GAAG;IAC5C,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC;IACtC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,eAAe,EAAE,gBAAgB,GAAG,aAAa,GAAG,aAAa,CAAC;CACnE,CAAC;AAEF,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,sBAE5E;AAcD,yFAAyF;AACzF,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,MAAM,CAAC,cAAc,GACpC,+BAA+B,CAkBjC;AAED,kFAAkF;AAClF,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,mBAAmB,iBAc3B"}
@@ -0,0 +1,62 @@
1
+ import { z } from "zod";
2
+ export const invoicePaymentScopeSchema = z
3
+ .object({
4
+ stripeInvoiceId: z
5
+ .string()
6
+ .max(128)
7
+ .regex(/^in_[A-Za-z0-9_]+$/),
8
+ customerAccount: z
9
+ .string()
10
+ .max(128)
11
+ .regex(/^acct_[A-Za-z0-9_]+$/),
12
+ stripeSubscriptionId: z
13
+ .string()
14
+ .max(128)
15
+ .regex(/^sub_[A-Za-z0-9_]+$/),
16
+ })
17
+ .strict();
18
+ /** Normalize provider references without inferring missing identifiers. */
19
+ export function referenceId(value) {
20
+ return typeof value === "string" ? value : value?.id;
21
+ }
22
+ /** Keep financial evidence exact; reject units that JavaScript cannot safely represent. */
23
+ function assertRepresentableUnits(row) {
24
+ const amounts = [
25
+ row.amount_requested,
26
+ ...(row.amount_paid === null ? [] : [row.amount_paid]),
27
+ ];
28
+ if (amounts.some((amount) => !Number.isSafeInteger(amount) || amount < 0) ||
29
+ !/^[a-z]{3}$/.test(row.currency)) {
30
+ throw new Error("Invalid provider invoice payment units or currency");
31
+ }
32
+ }
33
+ /** Retain unsupported rows while distinguishing canonical and unavailable references. */
34
+ export function paymentReference(invoicePayment) {
35
+ assertRepresentableUnits(invoicePayment);
36
+ const type = invoicePayment.payment.type;
37
+ const id = type === "payment_intent"
38
+ ? referenceId(invoicePayment.payment.payment_intent)
39
+ : undefined;
40
+ const paymentIntentId = id && /^pi_[A-Za-z0-9_]+$/.test(id) ? id : null;
41
+ return {
42
+ invoicePayment,
43
+ paymentIntentId,
44
+ referenceStatus: type !== "payment_intent"
45
+ ? "unsupported"
46
+ : paymentIntentId
47
+ ? "payment_intent"
48
+ : "unavailable",
49
+ };
50
+ }
51
+ /** Provider observation only; the caller still authorizes original host scope. */
52
+ export async function assertInvoicePaymentScope(stripe, scope) {
53
+ const invoice = await stripe.invoices.retrieve(scope.stripeInvoiceId);
54
+ const parent = invoice.parent;
55
+ if (invoice.id !== scope.stripeInvoiceId ||
56
+ invoice.customer_account !== scope.customerAccount ||
57
+ parent?.type !== "subscription_details" ||
58
+ referenceId(parent.subscription_details?.subscription) !==
59
+ scope.stripeSubscriptionId)
60
+ throw new Error("Invalid provider invoice payment buyer or subscription scope");
61
+ }
62
+ //# sourceMappingURL=invoicePaymentShared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoicePaymentShared.js","sourceRoot":"","sources":["../../../src/client/billing/invoicePaymentShared.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC;KACvC,MAAM,CAAC;IACN,eAAe,EAAE,CAAC;SACf,MAAM,EAAE;SACR,GAAG,CAAC,GAAG,CAAC;SACR,KAAK,CAAC,oBAAoB,CAAC;IAC9B,eAAe,EAAE,CAAC;SACf,MAAM,EAAE;SACR,GAAG,CAAC,GAAG,CAAC;SACR,KAAK,CAAC,sBAAsB,CAAC;IAChC,oBAAoB,EAAE,CAAC;SACpB,MAAM,EAAE;SACR,GAAG,CAAC,GAAG,CAAC;SACR,KAAK,CAAC,qBAAqB,CAAC;CAChC,CAAC;KACD,MAAM,EAAE,CAAC;AAQZ,2EAA2E;AAC3E,MAAM,UAAU,WAAW,CAAC,KAAiD;IAC3E,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;AACvD,CAAC;AACD,2FAA2F;AAC3F,SAAS,wBAAwB,CAAC,GAA0B;IAC1D,MAAM,OAAO,GAAG;QACd,GAAG,CAAC,gBAAgB;QACpB,GAAG,CAAC,GAAG,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;KACvD,CAAC;IACF,IACE,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC;QACrE,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAChC,CAAC;QACD,MAAM,I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 /** Trusted host selectors only; authenticate and freeze this entire tuple before calling. */
3
+ export type SubscriptionPaymentMethodOptions = {
4
+ stripeSubscriptionId: string;
5
+ customerAccount: string;
6
+ paymentMethodId: string;
7
+ idempotencyKey: string;
8
+ connectedAccountId?: string;
9
+ };
10
+ export type SubscriptionPaymentMethodResult = {
11
+ status: "updated";
12
+ stripeSubscriptionId: string;
13
+ customerAccount: string;
14
+ paymentMethodId: string;
15
+ observedAt: number;
16
+ } | {
17
+ status: "unsupported";
18
+ reason: "managed_payments" | "unknown_managed_payments" | "non_v2_payer" | "non_card_method";
19
+ } | {
20
+ status: "unavailable";
21
+ reason: "invalid_selector" | "subscription_mismatch" | "payer_mismatch" | "method_mismatch" | "method_owner_mismatch" | "provider_read_unavailable";
22
+ } | {
23
+ status: "unknown";
24
+ reason: "provider_write_unconfirmed" | "response_mismatch";
25
+ };
26
+ /** One SDK update, then a fresh observation. No package retry, shared default update, charge or component write. */
27
+ export declare function updateSubscriptionDefaultPaymentMethod(stripe: Stripe, input: SubscriptionPaymentMethodOptions): Promise<SubscriptionPaymentMethodResult>;
28
+ //# sourceMappingURL=subscription-payment-method.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription-payment-method.d.ts","sourceRoot":"","sources":["../../../src/client/billing/subscription-payment-method.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAI5B,6FAA6F;AAC7F,MAAM,MAAM,gCAAgC,GAAG;IAC7C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,+BAA+B,GACvC;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB,GACD;IACE,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EACF,kBAAkB,GAClB,0BAA0B,GAC1B,cAAc,GACd,iBAAiB,CAAC;CACvB,GACD;IACE,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EACF,kBAAkB,GAClB,uBAAuB,GACvB,gBAAgB,GAChB,iBAAiB,GACjB,uBAAuB,GACvB,2BAA2B,CAAC;CACjC,GACD;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,4BAA4B,GAAG,mBAAmB,CAAC;CAC5D,CAAC;AA2EN,oHAAoH;AACpH,wBAAsB,sCAAsC,CAC1D,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,gCAAgC,GACtC,OAAO,CAAC,+BAA+B,CAAC,CAuD1C"}
@@ -0,0 +1,101 @@
1
+ import Stripe from "stripe";
2
+ import { getSubscriptionFromStripe } from "./providerReads.js";
3
+ function isValidOptions(opts) {
4
+ const identifiers = [
5
+ [opts.stripeSubscriptionId, /^sub_[A-Za-z0-9_]+$/],
6
+ [opts.customerAccount, /^acct_[A-Za-z0-9_]+$/],
7
+ [opts.paymentMethodId, /^pm_[A-Za-z0-9_]+$/],
8
+ ];
9
+ if (opts.connectedAccountId !== undefined)
10
+ identifiers.push([opts.connectedAccountId, /^acct_[A-Za-z0-9_]+$/]);
11
+ return (identifiers.every(([value, pattern]) => typeof value === "string" && value.length <= 255 && pattern.test(value)) &&
12
+ typeof opts.idempotencyKey === "string" &&
13
+ opts.idempotencyKey.length > 0 &&
14
+ opts.idempotencyKey.length <= 255 &&
15
+ opts.idempotencyKey.trim() === opts.idempotencyKey &&
16
+ !/[\u0000-\u001f\u007f]/.test(opts.idempotencyKey));
17
+ }
18
+ function originalSubscriptionFailure(subscription, opts) {
19
+ if (subscription.id !== opts.stripeSubscriptionId)
20
+ return { status: "unavailable", reason: "subscription_mismatch" };
21
+ if (typeof subscription.customer_account !== "string")
22
+ return { status: "unsupported", reason: "non_v2_payer" };
23
+ if (subscription.customer_account !== opts.customerAccount)
24
+ return { status: "unavailable", reason: "payer_mismatch" };
25
+ if (subscription.managed_payments?.enabled === true)
26
+ return { status: "unsupported", reason: "managed_payments" };
27
+ if (subscription.managed_payments !== null &&
28
+ subscription.managed_payments?.enabled !== false)
29
+ return { status: "unsupported", reason: "unknown_managed_payments" };
30
+ return null;
31
+ }
32
+ function isConfirmedSelection(subscription, opts) {
33
+ if (originalSubscriptionFailure(subscription, opts))
34
+ return false;
35
+ const method = subscription.default_payment_method;
36
+ return typeof method === "string"
37
+ ? method === opts.paymentMethodId
38
+ : method?.id === opts.paymentMethodId &&
39
+ method.type === "card" &&
40
+ method.customer_account === opts.customerAccount;
41
+ }
42
+ /** Platform reads reuse the existing provider reader; explicit Connect scope stays unchanged on every call. */
43
+ function readOriginalSubscription(stripe, opts) {
44
+ return opts.connectedAccountId === undefined
45
+ ? getSubscriptionFromStripe(stripe, {
46
+ stripeSubscriptionId: opts.stripeSubscriptionId,
47
+ })
48
+ : stripe.subscriptions.retrieve(opts.stripeSubscriptionId, {}, { stripeAccount: opts.connectedAccountId });
49
+ }
50
+ /** One SDK update, then a fresh observation. No package retry, shared default update, charge or component write. */
51
+ export async function updateSubscriptionDefaultPaymentMethod(stripe, input) {
52
+ const opts = {
53
+ stripeSubscriptionId: input.stripeSubscriptionId,
54
+ customerAccount: input.customerAccount,
55
+ paymentMethodId: input.paymentMethodId,
56
+ idempotencyKey: input.idempotencyKey,
57
+ connectedAccountId: input.connectedAccountId,
58
+ };
59
+ if (!isValidOptions(opts))
60
+ return { status: "unavailable", reason: "invalid_selector" };
61
+ const realm = opts.connectedAccountId === undefined
62
+ ? undefined
63
+ : { stripeAccount: opts.connectedAccountId };
64
+ let isDispatched = false;
65
+ try {
66
+ const original = await readOriginalSubscription(stripe, opts);
67
+ const failure = originalSubscriptionFailure(original, opts);
68
+ if (failure)
69
+ return failure;
70
+ const method = await stripe.paymentMethods.retrieve(opts.paymentMethodId, {}, realm);
71
+ if (method.id !== opts.paymentMethodId)
72
+ return { status: "unavailable", reason: "method_mismatch" };
73
+ if (method.type !== "card")
74
+ return { status: "unsupported", reason: "non_card_method" };
75
+ if (method.customer_account !== opts.customerAccount)
76
+ return { status: "unavailable", reason: "method_owner_mismatch" };
77
+ isDispatched = true;
78
+ const updated = await stripe.subscriptions.update(opts.stripeSubscriptionId, { default_payment_method: opts.paymentMethodId }, { ...realm, idempotencyKey: opts.idempotencyKey });
79
+ if (!isConfirmedSelection(updated, opts))
80
+ return { status: "unknown", reason: "response_mismatch" };
81
+ // An idempotent POST can replay an old selection. Only a new GET can confirm current state.
82
+ const current = await readOriginalSubscription(stripe, opts);
83
+ if (!isConfirmedSelection(current, opts))
84
+ return { status: "unknown", reason: "response_mismatch" };
85
+ return {
86
+ status: "updated",
87
+ stripeSubscriptionId: opts.stripeSubscriptionId,
88
+ customerAccount: opts.customerAccount,
89
+ paymentMethodId: opts.paymentMethodId,
90
+ observedAt: Date.now(),
91
+ };
92
+ }
93
+ catch (error) {
94
+ if (!(error instanceof Stripe.errors.StripeError))
95
+ throw error;
96
+ if (isDispatched)
97
+ return { status: "unknown", reason: "provider_write_unconfirmed" };
98
+ return { status: "unavailable", reason: "provider_read_unavailable" };
99
+ }
100
+ }
101
+ //# sourceMappingURL=subscription-payment-method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription-payment-method.js","sourceRoot":"","sources":["../../../src/client/billing/subscription-payment-method.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AA0C/D,SAAS,cAAc,CAAC,IAAsC;IAC5D,MAAM,WAAW,GAAuB;QACtC,CAAC,IAAI,CAAC,oBAAoB,EAAE,qBAAqB,CAAC;QAClD,CAAC,IAAI,CAAC,eAAe,EAAE,sBAAsB,CAAC;QAC9C,CAAC,IAAI,CAAC,eAAe,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,eAAe,EAAE,EAChD,EAAE,GAAG,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAClD,CAAC;QACF,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC;YACtC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;QAC5D,4FAA4F;QAC5F,MAAM,OAAO,GAAG,MAAM,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC7D,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC;YACtC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;QAC5D,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;YAC/C,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;SACvB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;YAAE,MAAM,KAAK,CAAC;QAC/D,IAAI,YAAY;YACd,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,4BAA4B,EAAE,CAAC;QACrE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,2BAA2B,EAAE,CAAC;IACxE,CAAC;AACH,CAAC"}
@@ -1070,14 +1070,6 @@ export declare function setup(amounts?: number[]): Promise<{
1070
1070
  preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
1071
1071
  requestKey: string;
1072
1072
  result?: {
1073
- reason: "identity_changed" | "revision_changed" | "scope_busy";
1074
- retryable: false;
1075
- status: "conflict";
1076
- } | {
1077
- reason: "policy_invalid";
1078
- retryable: false;
1079
- status: "rejected";
1080
- } | {
1081
1073
  operation: {
1082
1074
  accountId: string;
1083
1075
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -1088,6 +1080,14 @@ export declare function setup(amounts?: number[]): Promise<{
1088
1080
  } | {
1089
1081
  enabled: boolean;
1090
1082
  status: "unchanged";
1083
+ } | {
1084
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
1085
+ retryable: false;
1086
+ status: "conflict";
1087
+ } | {
1088
+ reason: "policy_invalid";
1089
+ retryable: false;
1090
+ status: "rejected";
1091
1091
  } | {
1092
1092
  reason: "provider_pending";
1093
1093
  retryable: true;
@@ -1098,14 +1098,6 @@ export declare function setup(amounts?: number[]): Promise<{
1098
1098
  payload: import("convex/values").VString<string, "required">;
1099
1099
  preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
1100
1100
  result: import("convex/values").VUnion<{
1101
- reason: "identity_changed" | "revision_changed" | "scope_busy";
1102
- retryable: false;
1103
- status: "conflict";
1104
- } | {
1105
- reason: "policy_invalid";
1106
- retryable: false;
1107
- status: "rejected";
1108
- } | {
1109
1101
  operation: {
1110
1102
  accountId: string;
1111
1103
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -1116,6 +1108,14 @@ export declare function setup(amounts?: number[]): Promise<{
1116
1108
  } | {
1117
1109
  enabled: boolean;
1118
1110
  status: "unchanged";
1111
+ } | {
1112
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
1113
+ retryable: false;
1114
+ status: "conflict";
1115
+ } | {
1116
+ reason: "policy_invalid";
1117
+ retryable: false;
1118
+ status: "rejected";
1119
1119
  } | {
1120
1120
  reason: "provider_pending";
1121
1121
  retryable: true;
@@ -1060,6 +1060,14 @@ export declare function large(count?: number, amount?: number): Promise<{
1060
1060
  preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
1061
1061
  requestKey: string;
1062
1062
  result?: {
1063
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
1064
+ retryable: false;
1065
+ status: "conflict";
1066
+ } | {
1067
+ reason: "policy_invalid";
1068
+ retryable: false;
1069
+ status: "rejected";
1070
+ } | {
1063
1071
  operation: {
1064
1072
  accountId: string;
1065
1073
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -1070,14 +1078,6 @@ export declare function large(count?: number, amount?: number): Promise<{
1070
1078
  } | {
1071
1079
  enabled: boolean;
1072
1080
  status: "unchanged";
1073
- } | {
1074
- reason: "identity_changed" | "revision_changed" | "scope_busy";
1075
- retryable: false;
1076
- status: "conflict";
1077
- } | {
1078
- reason: "policy_invalid";
1079
- retryable: false;
1080
- status: "rejected";
1081
1081
  } | {
1082
1082
  reason: "provider_pending";
1083
1083
  retryable: true;
@@ -1088,6 +1088,14 @@ export declare function large(count?: number, amount?: number): Promise<{
1088
1088
  payload: import("convex/values").VString<string, "required">;
1089
1089
  preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
1090
1090
  result: import("convex/values").VUnion<{
1091
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
1092
+ retryable: false;
1093
+ status: "conflict";
1094
+ } | {
1095
+ reason: "policy_invalid";
1096
+ retryable: false;
1097
+ status: "rejected";
1098
+ } | {
1091
1099
  operation: {
1092
1100
  accountId: string;
1093
1101
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -1098,14 +1106,6 @@ export declare function large(count?: number, amount?: number): Promise<{
1098
1106
  } | {
1099
1107
  enabled: boolean;
1100
1108
  status: "unchanged";
1101
- } | {
1102
- reason: "identity_changed" | "revision_changed" | "scope_busy";
1103
- retryable: false;
1104
- status: "conflict";
1105
- } | {
1106
- reason: "policy_invalid";
1107
- retryable: false;
1108
- status: "rejected";
1109
1109
  } | {
1110
1110
  reason: "provider_pending";
1111
1111
  retryable: true;
@@ -4468,6 +4468,14 @@ export declare function withHistory(count?: number, amount?: number): Promise<{
4468
4468
  preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
4469
4469
  requestKey: string;
4470
4470
  result?: {
4471
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
4472
+ retryable: false;
4473
+ status: "conflict";
4474
+ } | {
4475
+ reason: "policy_invalid";
4476
+ retryable: false;
4477
+ status: "rejected";
4478
+ } | {
4471
4479
  operation: {
4472
4480
  accountId: string;
4473
4481
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -4478,14 +4486,6 @@ export declare function withHistory(count?: number, amount?: number): Promise<{
4478
4486
  } | {
4479
4487
  enabled: boolean;
4480
4488
  status: "unchanged";
4481
- } | {
4482
- reason: "identity_changed" | "revision_changed" | "scope_busy";
4483
- retryable: false;
4484
- status: "conflict";
4485
- } | {
4486
- reason: "policy_invalid";
4487
- retryable: false;
4488
- status: "rejected";
4489
4489
  } | {
4490
4490
  reason: "provider_pending";
4491
4491
  retryable: true;
@@ -4496,6 +4496,14 @@ export declare function withHistory(count?: number, amount?: number): Promise<{
4496
4496
  payload: import("convex/values").VString<string, "required">;
4497
4497
  preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
4498
4498
  result: import("convex/values").VUnion<{
4499
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
4500
+ retryable: false;
4501
+ status: "conflict";
4502
+ } | {
4503
+ reason: "policy_invalid";
4504
+ retryable: false;
4505
+ status: "rejected";
4506
+ } | {
4499
4507
  operation: {
4500
4508
  accountId: string;
4501
4509
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -4506,14 +4514,6 @@ export declare function withHistory(count?: number, amount?: number): Promise<{
4506
4514
  } | {
4507
4515
  enabled: boolean;
4508
4516
  status: "unchanged";
4509
- } | {
4510
- reason: "identity_changed" | "revision_changed" | "scope_busy";
4511
- retryable: false;
4512
- status: "conflict";
4513
- } | {
4514
- reason: "policy_invalid";
4515
- retryable: false;
4516
- status: "rejected";
4517
4517
  } | {
4518
4518
  reason: "provider_pending";
4519
4519
  retryable: true;