@fantastic.dev/better-stripe 0.48.1 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +1 -1
- package/dist/client/billing/invoicePaymentPages.d.ts +2 -5
- package/dist/client/billing/invoicePaymentPages.d.ts.map +1 -1
- package/dist/client/billing/invoicePaymentPages.js +2 -58
- package/dist/client/billing/invoicePaymentPages.js.map +1 -1
- package/dist/client/billing/invoicePaymentRead.d.ts +17 -0
- package/dist/client/billing/invoicePaymentRead.d.ts.map +1 -0
- package/dist/client/billing/invoicePaymentRead.js +25 -0
- package/dist/client/billing/invoicePaymentRead.js.map +1 -0
- package/dist/client/billing/invoicePaymentShared.d.ts +22 -0
- package/dist/client/billing/invoicePaymentShared.d.ts.map +1 -0
- package/dist/client/billing/invoicePaymentShared.js +62 -0
- package/dist/client/billing/invoicePaymentShared.js.map +1 -0
- package/dist/client/billing/setup-intent-read.d.ts +22 -0
- package/dist/client/billing/setup-intent-read.d.ts.map +1 -0
- package/dist/client/billing/setup-intent-read.js +63 -0
- package/dist/client/billing/setup-intent-read.js.map +1 -0
- package/dist/client/billing/subscription-payment-method.d.ts +28 -0
- package/dist/client/billing/subscription-payment-method.d.ts.map +1 -0
- package/dist/client/billing/subscription-payment-method.js +101 -0
- package/dist/client/billing/subscription-payment-method.js.map +1 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +10 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/invoiceReads.d.ts +3 -0
- package/dist/client/invoiceReads.d.ts.map +1 -1
- package/dist/client/invoiceReads.js +5 -0
- package/dist/client/invoiceReads.js.map +1 -1
- package/dist/component/_generated/component.d.ts +1 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/connect/queries.d.ts +1 -0
- package/dist/component/connect/queries.d.ts.map +1 -1
- package/dist/component/connect/queries.js +10 -4
- package/dist/component/connect/queries.js.map +1 -1
- package/dist/component/refundHistory/queries.d.ts +1 -1
- package/docs/invoice-payment-pages.md +62 -0
- package/docs/react-workflows.md +9 -0
- package/docs/read-contracts.md +45 -0
- package/docs/setup-intent-recovery.md +27 -0
- package/docs/subscription-payment-methods.md +121 -0
- package/package.json +4 -2
- package/src/client/billing/invoicePaymentPages.ts +9 -74
- package/src/client/billing/invoicePaymentRead.test.ts +233 -0
- package/src/client/billing/invoicePaymentRead.ts +44 -0
- package/src/client/billing/invoicePaymentReadTransport.test.ts +101 -0
- package/src/client/billing/invoicePaymentShared.ts +84 -0
- package/src/client/billing/setup-intent-read.test.ts +284 -0
- package/src/client/billing/setup-intent-read.ts +97 -0
- package/src/client/billing/subscription-payment-method.test.ts +460 -0
- package/src/client/billing/subscription-payment-method.ts +177 -0
- package/src/client/index.ts +39 -0
- package/src/client/invoiceReads.ts +9 -0
- package/src/component/_generated/component.ts +1 -1
- package/src/component/connect/payment-unique.test.ts +195 -0
- package/src/component/connect/queries.ts +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -26,6 +26,40 @@
|
|
|
26
26
|
- Remove internal tracker references from public documentation and add a
|
|
27
27
|
regression check that prevents their reintroduction.
|
|
28
28
|
|
|
29
|
+
## [0.50.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.49.0...v0.50.0) (2026-10-17)
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
- read an original qualified SetupIntent ([82301a5](https://github.com/FantasticDevHQ/better-stripe/commit/82301a594c07ae6f290eeba046f47fdbbadd142d))
|
|
34
|
+
- read an original qualified SetupIntent ([209d96b](https://github.com/FantasticDevHQ/better-stripe/commit/209d96b6cbb2970a4c990ac226a0c3293e92c830))
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
- preserve opaque original setup user identity ([e539a4c](https://github.com/FantasticDevHQ/better-stripe/commit/e539a4c0fa66a8f414655ea520da154a1e9de267))
|
|
39
|
+
|
|
40
|
+
### Maintenance
|
|
41
|
+
|
|
42
|
+
- ratchet measured SetupIntent reader coverage ([4794705](https://github.com/FantasticDevHQ/better-stripe/commit/4794705793190b4cc45346eabed645238944499f))
|
|
43
|
+
|
|
44
|
+
## [0.49.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.48.1...v0.49.0) (2026-10-17)
|
|
45
|
+
|
|
46
|
+
### Features
|
|
47
|
+
|
|
48
|
+
- add exact invoice-payment read with original scope verification ([c87abb3](https://github.com/FantasticDevHQ/better-stripe/commit/c87abb3d243f3c18fc2ccf37ef05c22c1eb463c3))
|
|
49
|
+
- read exact invoice payments with verified original scope ([f96853e](https://github.com/FantasticDevHQ/better-stripe/commit/f96853e1656fbc1ded60a87e58920598b90fd62a))
|
|
50
|
+
- scope card selection to an original subscription ([b1165e2](https://github.com/FantasticDevHQ/better-stripe/commit/b1165e20b058aa064c41b047b4226f709eab7cc6))
|
|
51
|
+
|
|
52
|
+
### Bug Fixes
|
|
53
|
+
|
|
54
|
+
- add opt-in exact PaymentIntent uniqueness ([f440725](https://github.com/FantasticDevHQ/better-stripe/commit/f4407258df63aeb448bb213ce870c70e000be56d))
|
|
55
|
+
- add opt-in unique cached PaymentIntent reads ([0148352](https://github.com/FantasticDevHQ/better-stripe/commit/0148352f011917e45500f8521ae30d0e0682d491))
|
|
56
|
+
- snapshot original subscription card selectors before reads ([eb92b1c](https://github.com/FantasticDevHQ/better-stripe/commit/eb92b1cc84943aef7ea38808cbeb120b7ed0de8e))
|
|
57
|
+
|
|
58
|
+
### Maintenance
|
|
59
|
+
|
|
60
|
+
- ratchet measured exact invoice-payment coverage floors ([3fc1443](https://github.com/FantasticDevHQ/better-stripe/commit/3fc1443fd4da8dea011ebf2821f754dad0c4a207))
|
|
61
|
+
- record native-generated strict payment reference ([17198e8](https://github.com/FantasticDevHQ/better-stripe/commit/17198e81733641507c872602d0170c216b42a58f))
|
|
62
|
+
|
|
29
63
|
## [0.48.1](https://github.com/FantasticDevHQ/better-stripe/compare/v0.48.0...v0.48.1) (2026-10-17)
|
|
30
64
|
|
|
31
65
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ claim execution are completed.
|
|
|
72
72
|
|
|
73
73
|
## Status
|
|
74
74
|
|
|
75
|
-
**Version**: `0.
|
|
75
|
+
**Version**: `0.50.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;
|
|
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
|
-
|
|
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,
|
|
1
|
+
{"version":3,"file":"invoicePaymentPages.js","sourceRoot":"","sources":["../../../src/client/billing/invoicePaymentPages.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,yBAAyB,IAAI,WAAW,EACxC,gBAAgB,EAChB,WAAW,GAEZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,aAAa,GAAG,WAAW;KAC9B,MAAM,CAAC;IACN,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACnD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ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6D,CAC9D,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;IACzD,IAAI,QAAQ,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,KAAK,KAAK,CAAC;QAChD,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;IACJ,OAAO;QACL,KAAK;QACL,IAAI,EAAE,QAAQ,CAAC,IAAI,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,CAA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IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
|
+
import type { Component, RunCtx } from "../helpers.js";
|
|
3
|
+
/** Host-authenticated immutable selectors for an already acknowledged setup. */
|
|
4
|
+
export type SetupIntentReadOptions = {
|
|
5
|
+
userId: string;
|
|
6
|
+
customerAccount: string;
|
|
7
|
+
setupIntentId: string;
|
|
8
|
+
usage: "on_session" | "off_session";
|
|
9
|
+
};
|
|
10
|
+
export type SetupIntentObservation = {
|
|
11
|
+
setupIntentId: string;
|
|
12
|
+
customerAccount: string;
|
|
13
|
+
usage: "on_session" | "off_session";
|
|
14
|
+
status: Stripe.SetupIntent.Status;
|
|
15
|
+
/** Present only for an incomplete confirmation. Never persist or log it. */
|
|
16
|
+
clientSecret?: string;
|
|
17
|
+
/** Time of this provider observation, in Unix milliseconds. */
|
|
18
|
+
observedAt: number;
|
|
19
|
+
};
|
|
20
|
+
/** Exact platform-realm GET only. Host authorization is required before and after I/O. */
|
|
21
|
+
export declare function getSetupIntentFromStripe(stripe: Stripe, component: Component, ctx: RunCtx, input: SetupIntentReadOptions): Promise<SetupIntentObservation>;
|
|
22
|
+
//# sourceMappingURL=setup-intent-read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-intent-read.d.ts","sourceRoot":"","sources":["../../../src/client/billing/setup-intent-read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvD,gFAAgF;AAChF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,YAAY,GAAG,aAAa,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,YAAY,GAAG,aAAa,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC;IAClC,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAiBF,0FAA0F;AAC1F,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,sBAAsB,CAAC,CAmDjC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { getAccountByStripeId } from "../core/accounts.js";
|
|
2
|
+
function validate(opts) {
|
|
3
|
+
if (typeof opts.userId !== "string" ||
|
|
4
|
+
!opts.userId ||
|
|
5
|
+
typeof opts.customerAccount !== "string" ||
|
|
6
|
+
opts.customerAccount.length > 255 ||
|
|
7
|
+
!/^acct_[A-Za-z0-9]+$/.test(opts.customerAccount) ||
|
|
8
|
+
typeof opts.setupIntentId !== "string" ||
|
|
9
|
+
opts.setupIntentId.length > 255 ||
|
|
10
|
+
!/^seti_[A-Za-z0-9]+$/.test(opts.setupIntentId) ||
|
|
11
|
+
(opts.usage !== "on_session" && opts.usage !== "off_session"))
|
|
12
|
+
throw new Error("Valid original SetupIntent selectors are required.");
|
|
13
|
+
}
|
|
14
|
+
/** Exact platform-realm GET only. Host authorization is required before and after I/O. */
|
|
15
|
+
export async function getSetupIntentFromStripe(stripe, component, ctx, input) {
|
|
16
|
+
const opts = {
|
|
17
|
+
userId: input.userId,
|
|
18
|
+
customerAccount: input.customerAccount,
|
|
19
|
+
setupIntentId: input.setupIntentId,
|
|
20
|
+
usage: input.usage,
|
|
21
|
+
};
|
|
22
|
+
validate(opts);
|
|
23
|
+
const account = await getAccountByStripeId(component, ctx, {
|
|
24
|
+
stripeAccountId: opts.customerAccount,
|
|
25
|
+
requireUnique: true,
|
|
26
|
+
});
|
|
27
|
+
if (!account ||
|
|
28
|
+
account.stripeAccountId !== opts.customerAccount ||
|
|
29
|
+
account.userId !== opts.userId)
|
|
30
|
+
throw new Error("Original customer account is unavailable.");
|
|
31
|
+
const setup = await stripe.setupIntents.retrieve(opts.setupIntentId);
|
|
32
|
+
if (setup.object !== "setup_intent" ||
|
|
33
|
+
setup.id !== opts.setupIntentId ||
|
|
34
|
+
setup.customer_account !== opts.customerAccount ||
|
|
35
|
+
setup.metadata?.userId !== opts.userId ||
|
|
36
|
+
setup.usage !== opts.usage ||
|
|
37
|
+
![
|
|
38
|
+
"requires_payment_method",
|
|
39
|
+
"requires_confirmation",
|
|
40
|
+
"requires_action",
|
|
41
|
+
"processing",
|
|
42
|
+
"canceled",
|
|
43
|
+
"succeeded",
|
|
44
|
+
].includes(setup.status))
|
|
45
|
+
throw new Error("SetupIntent does not match the original request.");
|
|
46
|
+
const isIncomplete = [
|
|
47
|
+
"requires_payment_method",
|
|
48
|
+
"requires_confirmation",
|
|
49
|
+
"requires_action",
|
|
50
|
+
].includes(setup.status);
|
|
51
|
+
const clientSecret = isIncomplete ? setup.client_secret : undefined;
|
|
52
|
+
if (isIncomplete && (typeof clientSecret !== "string" || !clientSecret))
|
|
53
|
+
throw new Error("Incomplete SetupIntent secret is unavailable.");
|
|
54
|
+
return {
|
|
55
|
+
setupIntentId: opts.setupIntentId,
|
|
56
|
+
customerAccount: opts.customerAccount,
|
|
57
|
+
usage: opts.usage,
|
|
58
|
+
status: setup.status,
|
|
59
|
+
...(typeof clientSecret === "string" ? { clientSecret } : {}),
|
|
60
|
+
observedAt: Date.now(),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=setup-intent-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-intent-read.js","s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CAAC;QAC7D,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;KACvB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Stripe from "stripe";
|
|
2
|
+
/** 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,EAAE,oBAAoB,CAAC;KAC7C,CAAC;IACF,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS;QACvC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,sBAA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C;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"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import * as setupIntentRead from "./billing/setup-intent-read.js";
|
|
2
|
+
export type { SetupIntentReadOptions, SetupIntentObservation, } from "./billing/setup-intent-read.js";
|
|
3
|
+
import * as subscriptionPaymentMethod from "./billing/subscription-payment-method.js";
|
|
1
4
|
import type { AccountByStripeIdOptions, SubscriptionByStripeIdOptions } from "./originalIdReadOptions.js";
|
|
2
5
|
import * as refundSyncImpl from "./connect/refundSync.js";
|
|
3
6
|
export type { RefundSyncOptions, RefundSyncResult, } from "./connect/refundSync.js";
|
|
@@ -39,6 +42,7 @@ import { type SupportedStripeApiVersion } from "./apiVersion.js";
|
|
|
39
42
|
export { STRIPE_CUSTOMER_PREVIEW_API_VERSION, type SupportedStripeApiVersion, } from "./apiVersion.js";
|
|
40
43
|
export type { CheckoutSessionReadOptions, SubscriptionReadOptions, CouponReadOptions, } from "./billing/providerReads.js";
|
|
41
44
|
import * as providerReads from "./billing/providerReads.js";
|
|
45
|
+
export type { InvoicePaymentReadOptions, ProviderInvoicePaymentRead, } from "./billing/invoicePaymentRead.js";
|
|
42
46
|
export type { InvoicePaymentPageOptions, ProviderInvoicePaymentPage, } from "./billing/invoicePaymentPages.js";
|
|
43
47
|
export type { InvoicePageOptions, ProviderInvoicePage, } from "./billing/invoicePages.js";
|
|
44
48
|
export type { CheckoutSessionPageOptions, ProviderCheckoutSessionPage, } from "./billing/checkoutPages.js";
|
|
@@ -605,6 +609,10 @@ export declare class BetterStripe extends PaymentSourceClient {
|
|
|
605
609
|
* feeds the headless `PayoutSchedule` component's `balance` prop directly.
|
|
606
610
|
*/
|
|
607
611
|
getCheckoutSessionFromStripe(_ctx: RunCtx, opts: providerReads.CheckoutSessionReadOptions): Promise<Stripe.Response<Stripe.Checkout.Session>>;
|
|
612
|
+
/** Host-authorized existing subscription card selection; never an account-wide default. */
|
|
613
|
+
updateSubscriptionDefaultPaymentMethod(_ctx: RunCtx, opts: subscriptionPaymentMethod.SubscriptionPaymentMethodOptions): Promise<subscriptionPaymentMethod.SubscriptionPaymentMethodResult>;
|
|
614
|
+
/** Qualified existing setup observation. Host must authenticate the original request. */
|
|
615
|
+
getSetupIntentFromStripe(ctx: RunCtx, opts: setupIntentRead.SetupIntentReadOptions): Promise<setupIntentRead.SetupIntentObservation>;
|
|
608
616
|
getSubscriptionFromStripe(_ctx: RunCtx, opts: providerReads.SubscriptionReadOptions): Promise<Stripe.Response<Stripe.Subscription>>;
|
|
609
617
|
getCouponFromStripe(_ctx: RunCtx, opts: providerReads.CouponReadOptions): Promise<Stripe.Response<Stripe.Coupon>>;
|
|
610
618
|
get affiliateRecovery(): AffiliateRecoveryClient;
|
|
@@ -854,4 +862,5 @@ export declare class BetterStripe extends PaymentSourceClient {
|
|
|
854
862
|
}, Promise<null>>;
|
|
855
863
|
};
|
|
856
864
|
}
|
|
865
|
+
export type { SubscriptionPaymentMethodOptions, SubscriptionPaymentMethodResult, } from "./billing/subscription-payment-method.js";
|
|
857
866
|
//# sourceMappingURL=index.d.ts.map
|