@fantastic.dev/better-stripe 0.37.1 → 0.38.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 +33 -0
- package/README.md +5 -1
- package/dist/client/core/accountCapabilities.d.ts +20 -0
- package/dist/client/core/accountCapabilities.d.ts.map +1 -0
- package/dist/client/core/accountCapabilities.js +7 -0
- package/dist/client/core/accountCapabilities.js.map +1 -0
- package/dist/client/core/accountConfigurations.d.ts +46 -0
- package/dist/client/core/accountConfigurations.d.ts.map +1 -0
- package/dist/client/core/accountConfigurations.js +99 -0
- package/dist/client/core/accountConfigurations.js.map +1 -0
- package/dist/client/core/accountLinks.d.ts +29 -2
- package/dist/client/core/accountLinks.d.ts.map +1 -1
- package/dist/client/core/accountLinks.js +56 -4
- package/dist/client/core/accountLinks.js.map +1 -1
- package/dist/client/core/accounts.d.ts +2 -36
- package/dist/client/core/accounts.d.ts.map +1 -1
- package/dist/client/core/accounts.js +3 -73
- package/dist/client/core/accounts.js.map +1 -1
- package/dist/client/core/billingPortalClient.d.ts +14 -0
- package/dist/client/core/billingPortalClient.d.ts.map +1 -0
- package/dist/client/core/billingPortalClient.js +18 -0
- package/dist/client/core/billingPortalClient.js.map +1 -0
- package/dist/client/costRecovery-invoices.d.ts +4 -4
- package/dist/client/costRecovery.d.ts +1 -1
- package/dist/client/financialOutcomes/adapters.d.ts +18 -0
- package/dist/client/financialOutcomes/adapters.d.ts.map +1 -0
- package/dist/client/financialOutcomes/adapters.js +60 -0
- package/dist/client/financialOutcomes/adapters.js.map +1 -0
- package/dist/client/financialOutcomes/contracts.d.ts +42 -0
- package/dist/client/financialOutcomes/contracts.d.ts.map +1 -0
- package/dist/client/financialOutcomes/contracts.js +39 -0
- package/dist/client/financialOutcomes/contracts.js.map +1 -0
- package/dist/client/financialOutcomes/errors.d.ts +6 -0
- package/dist/client/financialOutcomes/errors.d.ts.map +1 -0
- package/dist/client/financialOutcomes/errors.js +22 -0
- package/dist/client/financialOutcomes/errors.js.map +1 -0
- package/dist/client/financialOutcomes/index.d.ts +6 -0
- package/dist/client/financialOutcomes/index.d.ts.map +1 -0
- package/dist/client/financialOutcomes/index.js +4 -0
- package/dist/client/financialOutcomes/index.js.map +1 -0
- package/dist/client/financialOutcomes/retry.d.ts +24 -0
- package/dist/client/financialOutcomes/retry.d.ts.map +1 -0
- package/dist/client/financialOutcomes/retry.js +31 -0
- package/dist/client/financialOutcomes/retry.js.map +1 -0
- package/dist/client/index.d.ts +20 -111
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +10 -85
- package/dist/client/index.js.map +1 -1
- package/dist/client/products/catalog.d.ts +26 -0
- package/dist/client/products/catalog.d.ts.map +1 -0
- package/dist/client/products/catalog.js +140 -0
- package/dist/client/products/catalog.js.map +1 -0
- package/dist/client/products/catalogClient.d.ts +109 -0
- package/dist/client/products/catalogClient.d.ts.map +1 -0
- package/dist/client/products/catalogClient.js +84 -0
- package/dist/client/products/catalogClient.js.map +1 -0
- package/dist/client/products/prices.d.ts +1 -0
- package/dist/client/products/prices.d.ts.map +1 -1
- package/dist/client/products/prices.js +1 -0
- package/dist/client/products/prices.js.map +1 -1
- package/dist/client/publicTypes.d.ts +2 -0
- package/dist/client/publicTypes.d.ts.map +1 -1
- package/dist/component/_generated/component.d.ts +8 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/products/mutations.d.ts +9 -0
- package/dist/component/products/mutations.d.ts.map +1 -1
- package/dist/component/products/mutations.js +31 -2
- package/dist/component/products/mutations.js.map +1 -1
- package/docs/read-contracts.md +33 -0
- package/package.json +1 -1
- package/src/client/core/account-session-client.test.ts +74 -0
- package/src/client/core/accountCapabilities.ts +22 -0
- package/src/client/core/accountConfigurations.test.ts +183 -0
- package/src/client/core/accountConfigurations.ts +161 -0
- package/src/client/core/accountLinks.test.ts +6 -2
- package/src/client/core/accountLinks.ts +122 -5
- package/src/client/core/accounts.ts +8 -115
- package/src/client/core/billingPortal.test.ts +247 -0
- package/src/client/core/billingPortalClient.ts +35 -0
- package/src/client/financialOutcomes/adapters.ts +88 -0
- package/src/client/financialOutcomes/contracts.ts +43 -0
- package/src/client/financialOutcomes/errors.ts +29 -0
- package/src/client/financialOutcomes/index.ts +5 -0
- package/src/client/financialOutcomes/outcomes.test.ts +254 -0
- package/src/client/financialOutcomes/retry.ts +52 -0
- package/src/client/index.test.ts +0 -64
- package/src/client/index.ts +34 -185
- package/src/client/products/catalog.test.ts +389 -0
- package/src/client/products/catalog.ts +225 -0
- package/src/client/products/catalogClient.ts +172 -0
- package/src/client/products/prices.test.ts +24 -0
- package/src/client/products/prices.ts +2 -0
- package/src/client/publicTypes.ts +13 -0
- package/src/component/_generated/api.ts +4 -0
- package/src/component/_generated/component.ts +14 -0
- package/src/component/products/mutations.ts +39 -2
package/CHANGELOG.md
CHANGED
|
@@ -26,6 +26,39 @@
|
|
|
26
26
|
- Remove internal tracker references from public documentation and add a
|
|
27
27
|
regression check that prevents their reintroduction.
|
|
28
28
|
|
|
29
|
+
## [0.38.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.37.1...v0.38.0) (2026-10-17)
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
- **accounts:** add merchant configuration and transfer readiness ([e9994a9](https://github.com/FantasticDevHQ/better-stripe/commit/e9994a9e49295ebd963cf30ecd3fb6d62d38a409))
|
|
34
|
+
- add typed financial readiness and bounded retry policy ([9dae843](https://github.com/FantasticDevHQ/better-stripe/commit/9dae843d17d1a83fed9f496bb28f10e902b69170))
|
|
35
|
+
- **billing:** add typed portal configuration APIs ([f43f5f6](https://github.com/FantasticDevHQ/better-stripe/commit/f43f5f670a894d48f9bc29ba18f82c0b4ad5e369))
|
|
36
|
+
- **billing:** add typed portal configuration APIs ([8ff5510](https://github.com/FantasticDevHQ/better-stripe/commit/8ff5510ba6e9135bf7a4d48610a3cc85dbe8aff4))
|
|
37
|
+
- **catalog:** ensure lookup-key prices and adopt products ([e3f75fc](https://github.com/FantasticDevHQ/better-stripe/commit/e3f75fce959256dafa3475f67e9a2b65c4faeb71))
|
|
38
|
+
- **catalog:** ensure lookup-key prices and adopt products ([9dcc092](https://github.com/FantasticDevHQ/better-stripe/commit/9dcc0927543f87bb932e24e38811b413a07c97e4))
|
|
39
|
+
- standardize financial readiness and bounded retries ([06ae478](https://github.com/FantasticDevHQ/better-stripe/commit/06ae478ff2ee5c9e89f79d109ae1e92a3f8510b7))
|
|
40
|
+
|
|
41
|
+
### Bug Fixes
|
|
42
|
+
|
|
43
|
+
- **catalog:** enforce adoption ownership atomically ([afd9909](https://github.com/FantasticDevHQ/better-stripe/commit/afd9909f93973af329abe46858f646d03d1d24d2))
|
|
44
|
+
|
|
45
|
+
### Documentation
|
|
46
|
+
|
|
47
|
+
- complete durable preparation handoff contracts ([066dda2](https://github.com/FantasticDevHQ/better-stripe/commit/066dda2626f6f713af95bb5cb34bc09ddca2e8b9))
|
|
48
|
+
- define component extraction and durable execution contracts ([c27a215](https://github.com/FantasticDevHQ/better-stripe/commit/c27a21577e9f52ab62f3c45f14f484e584e9d0db))
|
|
49
|
+
- define scoped preparation results and migration pauses ([1d0a07f](https://github.com/FantasticDevHQ/better-stripe/commit/1d0a07f8b634182dc04ade4c36cca7311e2c3773))
|
|
50
|
+
- refresh extraction contract review baseline ([070ba5f](https://github.com/FantasticDevHQ/better-stripe/commit/070ba5f6ec833ee780414d2fae0ca6498699121e))
|
|
51
|
+
|
|
52
|
+
### Maintenance
|
|
53
|
+
|
|
54
|
+
- ratchet portal coverage after earnings integration ([a179036](https://github.com/FantasticDevHQ/better-stripe/commit/a17903630339e00041c0e86c5da3e223a6a0b084))
|
|
55
|
+
- ratchet portal coverage after merged contracts integration ([5faff9a](https://github.com/FantasticDevHQ/better-stripe/commit/5faff9aa5206bbcadf8086a966162631c5b7ac42))
|
|
56
|
+
- ratchet portal coverage after seller attribution integration ([fdcb303](https://github.com/FantasticDevHQ/better-stripe/commit/fdcb3033df39b43d2d33bb8e41ef7397ad36509d))
|
|
57
|
+
|
|
58
|
+
### Refactoring
|
|
59
|
+
|
|
60
|
+
- reuse package currency and embedded session APIs ([#247](https://github.com/FantasticDevHQ/better-stripe/issues/247)) ([c4ab43c](https://github.com/FantasticDevHQ/better-stripe/commit/c4ab43cc9bccf631fd5a576131ddc65f489fead5))
|
|
61
|
+
|
|
29
62
|
## [0.37.1](https://github.com/FantasticDevHQ/better-stripe/compare/v0.37.0...v0.37.1) (2026-10-17)
|
|
30
63
|
|
|
31
64
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ claim execution are completed.
|
|
|
70
70
|
|
|
71
71
|
## Status
|
|
72
72
|
|
|
73
|
-
**Version**: `0.
|
|
73
|
+
**Version**: `0.38.0` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
|
|
74
74
|
|
|
75
75
|
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.
|
|
76
76
|
|
|
@@ -382,6 +382,10 @@ shows where the host's authenticated-actor check belongs.
|
|
|
382
382
|
|
|
383
383
|
### Product and Price
|
|
384
384
|
|
|
385
|
+
`ensurePrice(ctx, { stripeProductId, lookupKey, unitAmount, type, idempotencyKey, currency?, interval?, intervalCount? })` finds a price by its provider lookup key, verifies its immutable terms, and adopts the price and product into the component mirrors. If absent, it creates the price with the supplied idempotency key. A matching provider result repairs a failed mirror write on retry. Inactive prices, different products or pricing terms, and metered or transformed pricing are rejected. Choose a new versioned lookup key when changing price terms; existing subscriptions retain their current price.
|
|
386
|
+
|
|
387
|
+
Scope the idempotency key to one catalog operation and reuse it only with identical creation parameters. Authorize product access in your host action. `getStripePriceByLookupKey(ctx, { lookupKey })` reads Stripe without changing mirrors. `adoptProduct(ctx, { stripeProductId, accountId? })` imports an existing provider product, preserving existing ownership and rejecting reassignment. Adoption does not update provider metadata or statement descriptors. `createPrice` also accepts `lookupKey` for callers handling adoption themselves. Tier names, lookup-key version policy, and entitlement mapping remain in the host app.
|
|
388
|
+
|
|
385
389
|
| Method | Description |
|
|
386
390
|
| --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
|
|
387
391
|
| `createProduct(ctx, { name, description?, active?, accountId?, metadata? })` | Create product in Stripe and component DB |
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Provider capability shape shared by V1 and V2 accounts. */
|
|
2
|
+
export type TransferCapabilityAccount = {
|
|
3
|
+
configuration?: {
|
|
4
|
+
recipient?: {
|
|
5
|
+
capabilities?: {
|
|
6
|
+
stripe_balance?: {
|
|
7
|
+
stripe_transfers?: {
|
|
8
|
+
status?: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
} | null;
|
|
13
|
+
} | null;
|
|
14
|
+
capabilities?: {
|
|
15
|
+
transfers?: string;
|
|
16
|
+
} | null;
|
|
17
|
+
};
|
|
18
|
+
/** True when Stripe reports active recipient transfers in either supported API shape. */
|
|
19
|
+
export declare function canReceiveTransfers(account: TransferCapabilityAccount | null | undefined): boolean;
|
|
20
|
+
//# sourceMappingURL=accountCapabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountCapabilities.d.ts","sourceRoot":"","sources":["../../../src/client/core/accountCapabilities.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,MAAM,yBAAyB,GAAG;IACtC,aAAa,CAAC,EAAE;QACd,SAAS,CAAC,EAAE;YACV,YAAY,CAAC,EAAE;gBACb,cAAc,CAAC,EAAE;oBAAE,gBAAgB,CAAC,EAAE;wBAAE,MAAM,CAAC,EAAE,MAAM,CAAA;qBAAE,CAAA;iBAAE,CAAC;aAC7D,CAAC;SACH,GAAG,IAAI,CAAC;KACV,GAAG,IAAI,CAAC;IACT,YAAY,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAC9C,CAAC;AAEF,yFAAyF;AACzF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,yBAAyB,GAAG,IAAI,GAAG,SAAS,GACpD,OAAO,CAMT"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** True when Stripe reports active recipient transfers in either supported API shape. */
|
|
2
|
+
export function canReceiveTransfers(account) {
|
|
3
|
+
return (account?.configuration?.recipient?.capabilities?.stripe_balance
|
|
4
|
+
?.stripe_transfers?.status === "active" ||
|
|
5
|
+
account?.capabilities?.transfers === "active");
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=accountCapabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountCapabilities.js","sourceRoot":"","sources":["../../../src/client/core/accountCapabilities.ts"],"names":[],"mappings":"AAYA,yFAAyF;AACzF,MAAM,UAAU,mBAAmB,CACjC,OAAqD;IAErD,OAAO,CACL,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc;QAC7D,EAAE,gBAAgB,EAAE,MAAM,KAAK,QAAQ;QACzC,OAAO,EAAE,YAAY,EAAE,SAAS,KAAK,QAAQ,CAC9C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
|
+
import type { Component, RunCtx } from "../helpers.js";
|
|
3
|
+
/**
|
|
4
|
+
* Default V2 customer configuration. Applying the customer configuration is
|
|
5
|
+
* what makes a V2 Account billable — the customer-facing payment/billing flows
|
|
6
|
+
* (subscriptions, invoices, billing portal). In the V2 Accounts API a single
|
|
7
|
+
* Account with this configuration replaces the legacy V1 Customer object, so
|
|
8
|
+
* `customer_account: acct_…` is what you pass to subscriptions, setup intents,
|
|
9
|
+
* and billing-portal sessions. No capabilities are requested by default;
|
|
10
|
+
* request `customer.capabilities.automatic_indirect_tax` separately if you need
|
|
11
|
+
* automatic tax on this account's invoices/subscriptions.
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEFAULT_CUSTOMER_CONFIGURATION: Record<string, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Apply the customer configuration to an existing V2 Account, making it
|
|
16
|
+
* billable, and record the resulting applied configurations on the component
|
|
17
|
+
* account. The account must already exist in the component DB (e.g. created via
|
|
18
|
+
* `createAccount`); its owning `userId` is recovered from that record.
|
|
19
|
+
*/
|
|
20
|
+
export declare function addCustomerConfiguration(stripe: Stripe, component: Component, ctx: RunCtx, opts: {
|
|
21
|
+
stripeAccountId: string;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
success: true;
|
|
24
|
+
appliedConfigurations: string[];
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Apply the V2 recipient configuration to an existing account, and record the
|
|
28
|
+
* resulting applied configurations on the component account. The account must
|
|
29
|
+
* already exist in the component DB (e.g. from {@link createAccount}); its
|
|
30
|
+
* owning `userId` is recovered from that record, matching
|
|
31
|
+
* {@link addCustomerConfiguration}.
|
|
32
|
+
*/
|
|
33
|
+
export declare function addRecipientConfiguration(stripe: Stripe, component: Component, ctx: RunCtx, opts: {
|
|
34
|
+
stripeAccountId: string;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
success: true;
|
|
37
|
+
appliedConfigurations: string[];
|
|
38
|
+
}>;
|
|
39
|
+
/** Request merchant card payments and refresh only this account's applied configurations. */
|
|
40
|
+
export declare function addMerchantConfiguration(stripe: Stripe, component: Component, ctx: RunCtx, opts: {
|
|
41
|
+
stripeAccountId: string;
|
|
42
|
+
}): Promise<{
|
|
43
|
+
success: true;
|
|
44
|
+
appliedConfigurations: string[];
|
|
45
|
+
}>;
|
|
46
|
+
//# sourceMappingURL=accountConfigurations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountConfigurations.d.ts","sourceRoot":"","sources":["../../../src/client/core/accountConfigurations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAQvD;;;;;;;;;GASG;AACH,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAElE,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,qBAAqB,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAiC7D;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,qBAAqB,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA4C7D;AAED,6FAA6F;AAC7F,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,qBAAqB,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA2B7D"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { runMutationOrThrow } from "../helpers.js";
|
|
2
|
+
import { throwStripeError } from "../errors.js";
|
|
3
|
+
import { componentRef } from "../webhooks/helpers.js";
|
|
4
|
+
import { DEFAULT_ACCOUNT_CONFIGURATION } from "./accountDefaults.js";
|
|
5
|
+
/**
|
|
6
|
+
* Default V2 customer configuration. Applying the customer configuration is
|
|
7
|
+
* what makes a V2 Account billable — the customer-facing payment/billing flows
|
|
8
|
+
* (subscriptions, invoices, billing portal). In the V2 Accounts API a single
|
|
9
|
+
* Account with this configuration replaces the legacy V1 Customer object, so
|
|
10
|
+
* `customer_account: acct_…` is what you pass to subscriptions, setup intents,
|
|
11
|
+
* and billing-portal sessions. No capabilities are requested by default;
|
|
12
|
+
* request `customer.capabilities.automatic_indirect_tax` separately if you need
|
|
13
|
+
* automatic tax on this account's invoices/subscriptions.
|
|
14
|
+
*/
|
|
15
|
+
export const DEFAULT_CUSTOMER_CONFIGURATION = {
|
|
16
|
+
customer: {},
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Apply the customer configuration to an existing V2 Account, making it
|
|
20
|
+
* billable, and record the resulting applied configurations on the component
|
|
21
|
+
* account. The account must already exist in the component DB (e.g. created via
|
|
22
|
+
* `createAccount`); its owning `userId` is recovered from that record.
|
|
23
|
+
*/
|
|
24
|
+
export async function addCustomerConfiguration(stripe, component, ctx, opts) {
|
|
25
|
+
const existing = (await ctx.runQuery(componentRef(component, "core/queries/getAccountByStripeId"), { stripeAccountId: opts.stripeAccountId }));
|
|
26
|
+
if (!existing) {
|
|
27
|
+
throwStripeError("ACCOUNT_NOT_FOUND", `No component account found for ${opts.stripeAccountId}; create it before applying the customer configuration`);
|
|
28
|
+
}
|
|
29
|
+
await stripe.v2.core.accounts.update(opts.stripeAccountId, {
|
|
30
|
+
configuration: DEFAULT_CUSTOMER_CONFIGURATION,
|
|
31
|
+
});
|
|
32
|
+
// Re-fetch to record the configurations Stripe actually applied
|
|
33
|
+
const updated = await stripe.v2.core.accounts.retrieve(opts.stripeAccountId);
|
|
34
|
+
const appliedConfigurations = updated.applied_configurations ?? [];
|
|
35
|
+
await runMutationOrThrow(ctx, componentRef(component, "core/mutations/upsertAccount"), {
|
|
36
|
+
stripeAccountId: opts.stripeAccountId,
|
|
37
|
+
userId: existing.userId,
|
|
38
|
+
...(existing.orgId !== undefined ? { orgId: existing.orgId } : {}),
|
|
39
|
+
appliedConfigurations,
|
|
40
|
+
});
|
|
41
|
+
return { success: true, appliedConfigurations };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Apply the V2 recipient configuration to an existing account, and record the
|
|
45
|
+
* resulting applied configurations on the component account. The account must
|
|
46
|
+
* already exist in the component DB (e.g. from {@link createAccount}); its
|
|
47
|
+
* owning `userId` is recovered from that record, matching
|
|
48
|
+
* {@link addCustomerConfiguration}.
|
|
49
|
+
*/
|
|
50
|
+
export async function addRecipientConfiguration(stripe, component, ctx, opts) {
|
|
51
|
+
const existing = (await ctx.runQuery(componentRef(component, "core/queries/getAccountByStripeId"), { stripeAccountId: opts.stripeAccountId }));
|
|
52
|
+
if (!existing) {
|
|
53
|
+
throwStripeError("ACCOUNT_NOT_FOUND", `No component account found for ${opts.stripeAccountId}; create it before applying the recipient configuration`);
|
|
54
|
+
}
|
|
55
|
+
await stripe.v2.core.accounts.update(opts.stripeAccountId, {
|
|
56
|
+
configuration: {
|
|
57
|
+
recipient: {
|
|
58
|
+
// V2 (API 2026-05-27.dahlia) requires the `capabilities` wrapper with an
|
|
59
|
+
// explicit `requested: true`. The bare `recipient.stripe_balance` shape
|
|
60
|
+
// is rejected with "Unknown field" (confirmed against the Stripe sandbox).
|
|
61
|
+
capabilities: {
|
|
62
|
+
stripe_balance: {
|
|
63
|
+
stripe_transfers: { requested: true },
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
// Re-fetch to record the configurations Stripe actually applied
|
|
70
|
+
const updated = await stripe.v2.core.accounts.retrieve(opts.stripeAccountId);
|
|
71
|
+
const appliedConfigurations = updated.applied_configurations ?? [];
|
|
72
|
+
await runMutationOrThrow(ctx, componentRef(component, "core/mutations/upsertAccount"), {
|
|
73
|
+
stripeAccountId: opts.stripeAccountId,
|
|
74
|
+
userId: existing.userId,
|
|
75
|
+
...(existing.orgId !== undefined ? { orgId: existing.orgId } : {}),
|
|
76
|
+
appliedConfigurations,
|
|
77
|
+
});
|
|
78
|
+
return { success: true, appliedConfigurations };
|
|
79
|
+
}
|
|
80
|
+
/** Request merchant card payments and refresh only this account's applied configurations. */
|
|
81
|
+
export async function addMerchantConfiguration(stripe, component, ctx, opts) {
|
|
82
|
+
const existing = (await ctx.runQuery(componentRef(component, "core/queries/getAccountByStripeId"), { stripeAccountId: opts.stripeAccountId }));
|
|
83
|
+
if (!existing) {
|
|
84
|
+
throwStripeError("ACCOUNT_NOT_FOUND", `No component account found for ${opts.stripeAccountId}; create it before applying the merchant configuration`);
|
|
85
|
+
}
|
|
86
|
+
await stripe.v2.core.accounts.update(opts.stripeAccountId, {
|
|
87
|
+
configuration: DEFAULT_ACCOUNT_CONFIGURATION,
|
|
88
|
+
});
|
|
89
|
+
const updated = await stripe.v2.core.accounts.retrieve(opts.stripeAccountId);
|
|
90
|
+
const appliedConfigurations = updated.applied_configurations ?? [];
|
|
91
|
+
await runMutationOrThrow(ctx, componentRef(component, "core/mutations/upsertAccount"), {
|
|
92
|
+
stripeAccountId: opts.stripeAccountId,
|
|
93
|
+
userId: existing.userId,
|
|
94
|
+
...(existing.orgId !== undefined ? { orgId: existing.orgId } : {}),
|
|
95
|
+
appliedConfigurations,
|
|
96
|
+
});
|
|
97
|
+
return { success: true, appliedConfigurations };
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=accountConfigurations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountConfigurations.js","sourceRoot":"","sources":["../../../src/client/core/accountConfigurations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAErE;;;;;;;;;GASG;AACH,M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,14 @@ export declare function createDisputeSession(stripe: Stripe, ctx: RunCtx, opts:
|
|
|
36
36
|
stripeAccountId: string;
|
|
37
37
|
}): Promise<{
|
|
38
38
|
clientSecret: string;
|
|
39
|
+
expiresAt: number;
|
|
39
40
|
}>;
|
|
40
41
|
export declare function createAccountSession(stripe: Stripe, _ctx: RunCtx, opts: {
|
|
41
42
|
stripeAccountId: string;
|
|
42
43
|
components: Stripe.AccountSessionCreateParams.Components;
|
|
43
44
|
}): Promise<{
|
|
44
45
|
clientSecret: string;
|
|
46
|
+
expiresAt: number;
|
|
45
47
|
}>;
|
|
46
48
|
export declare function createLoginLink(stripe: Stripe, _ctx: RunCtx, opts: {
|
|
47
49
|
stripeAccountId: string;
|
|
@@ -57,13 +59,38 @@ export declare function getAccountLinkWithStatus(stripe: Stripe, ctx: RunCtx, op
|
|
|
57
59
|
refreshUrl: string;
|
|
58
60
|
returnUrl: string;
|
|
59
61
|
}): Promise<AccountLinkWithStatus>;
|
|
60
|
-
|
|
62
|
+
/** The connected account that owns the configuration and its customer data.
|
|
63
|
+
* Omit for platform scope. Hosts must authorize both this scope and the customer.
|
|
64
|
+
*/
|
|
65
|
+
type BillingPortalScope = {
|
|
66
|
+
connectedAccountId?: string;
|
|
67
|
+
};
|
|
68
|
+
export type CreateBillingPortalConfigurationOptions = BillingPortalScope & {
|
|
69
|
+
/** Host-owned allowlists, proration, cancellation, and branding policy. */
|
|
70
|
+
params: Stripe.BillingPortal.ConfigurationCreateParams;
|
|
71
|
+
};
|
|
72
|
+
export type RetrieveBillingPortalConfigurationOptions = BillingPortalScope & {
|
|
73
|
+
configurationId: string;
|
|
74
|
+
};
|
|
75
|
+
export type UpdateBillingPortalConfigurationOptions = BillingPortalScope & {
|
|
76
|
+
configurationId: string;
|
|
77
|
+
params: Stripe.BillingPortal.ConfigurationUpdateParams;
|
|
78
|
+
};
|
|
79
|
+
export type CreateBillingPortalSessionOptions = BillingPortalScope & {
|
|
80
|
+
/** Customer account opening the portal, distinct from connectedAccountId. */
|
|
61
81
|
stripeAccountId: string;
|
|
62
82
|
returnUrl: string;
|
|
63
|
-
|
|
83
|
+
/** Omit to use Stripe's default portal configuration. */
|
|
84
|
+
configurationId?: string;
|
|
85
|
+
};
|
|
86
|
+
export declare function createBillingPortalConfiguration(stripe: Stripe, _ctx: RunCtx, opts: CreateBillingPortalConfigurationOptions): Promise<Stripe.BillingPortal.Configuration>;
|
|
87
|
+
export declare function retrieveBillingPortalConfiguration(stripe: Stripe, _ctx: RunCtx, opts: RetrieveBillingPortalConfigurationOptions): Promise<Stripe.BillingPortal.Configuration>;
|
|
88
|
+
export declare function updateBillingPortalConfiguration(stripe: Stripe, _ctx: RunCtx, opts: UpdateBillingPortalConfigurationOptions): Promise<Stripe.BillingPortal.Configuration>;
|
|
89
|
+
export declare function createBillingPortalSession(stripe: Stripe, _ctx: RunCtx, opts: CreateBillingPortalSessionOptions): Promise<{
|
|
64
90
|
url: string;
|
|
65
91
|
}>;
|
|
66
92
|
export declare function getCountrySpecs(stripe: Stripe, _ctx: RunCtx, opts: {
|
|
67
93
|
countryCode: string;
|
|
68
94
|
}): Promise<Stripe.Response<Stripe.CountrySpec>>;
|
|
95
|
+
export {};
|
|
69
96
|
//# sourceMappingURL=accountLinks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountLinks.d.ts","sourceRoot":"","sources":["../../../src/client/core/accountLinks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAMzD,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;IACJ,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;I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ACF,MAAM,MAAM,iCAAiC,GAAG,kBAAkB,GAAG;IACnE,6EAA6E;IAC7E,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,uCAAuC,GAC5C,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAc7C;AAED,wBAAsB,kCAAkC,CACtD,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,yCAAyC,GAC9C,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAoB7C;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,uCAAuC,GAC5C,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAqB7C;AAED,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,iCAAiC;;GAwBxC;AAED,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,gDAG9B"}
|
|
@@ -63,7 +63,10 @@ export async function createAccountSession(stripe, _ctx, opts) {
|
|
|
63
63
|
account: opts.stripeAccountId,
|
|
64
64
|
components: opts.components,
|
|
65
65
|
});
|
|
66
|
-
return {
|
|
66
|
+
return {
|
|
67
|
+
clientSecret: session.client_secret,
|
|
68
|
+
expiresAt: session.expires_at,
|
|
69
|
+
};
|
|
67
70
|
}
|
|
68
71
|
catch (error) {
|
|
69
72
|
throwStripeError("STRIPE_API_ERROR", `Failed to create account session for ${opts.stripeAccountId}`, error);
|
|
@@ -112,12 +115,61 @@ export async function getAccountLinkWithStatus(stripe, ctx, opts) {
|
|
|
112
115
|
}
|
|
113
116
|
return getOnboardingLink();
|
|
114
117
|
}
|
|
118
|
+
export async function createBillingPortalConfiguration(stripe, _ctx, opts) {
|
|
119
|
+
try {
|
|
120
|
+
return opts.connectedAccountId !== undefined
|
|
121
|
+
? await stripe.billingPortal.configurations.create(opts.params, {
|
|
122
|
+
stripeAccount: opts.connectedAccountId,
|
|
123
|
+
})
|
|
124
|
+
: await stripe.billingPortal.configurations.create(opts.params);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
throwStripeError("STRIPE_API_ERROR", "Failed to create Billing Portal configuration", error);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export async function retrieveBillingPortalConfiguration(stripe, _ctx, opts) {
|
|
131
|
+
try {
|
|
132
|
+
return opts.connectedAccountId !== undefined
|
|
133
|
+
? await stripe.billingPortal.configurations.retrieve(opts.configurationId, {}, {
|
|
134
|
+
stripeAccount: opts.connectedAccountId,
|
|
135
|
+
})
|
|
136
|
+
: await stripe.billingPortal.configurations.retrieve(opts.configurationId);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
throwStripeError("STRIPE_API_ERROR", "Failed to retrieve Billing Portal configuration", error);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
export async function updateBillingPortalConfiguration(stripe, _ctx, opts) {
|
|
143
|
+
try {
|
|
144
|
+
return opts.connectedAccountId !== undefined
|
|
145
|
+
? await stripe.billingPortal.configurations.update(opts.configurationId, opts.params, {
|
|
146
|
+
stripeAccount: opts.connectedAccountId,
|
|
147
|
+
})
|
|
148
|
+
: await stripe.billingPortal.configurations.update(opts.configurationId, opts.params);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
throwStripeError("STRIPE_API_ERROR", "Failed to update Billing Portal configuration", error);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
115
154
|
export async function createBillingPortalSession(stripe, _ctx, opts) {
|
|
116
|
-
const
|
|
155
|
+
const params = {
|
|
117
156
|
customer_account: opts.stripeAccountId,
|
|
118
157
|
return_url: opts.returnUrl,
|
|
119
|
-
|
|
120
|
-
|
|
158
|
+
...(opts.configurationId !== undefined
|
|
159
|
+
? { configuration: opts.configurationId }
|
|
160
|
+
: {}),
|
|
161
|
+
};
|
|
162
|
+
try {
|
|
163
|
+
const session = opts.connectedAccountId !== undefined
|
|
164
|
+
? await stripe.billingPortal.sessions.create(params, {
|
|
165
|
+
stripeAccount: opts.connectedAccountId,
|
|
166
|
+
})
|
|
167
|
+
: await stripe.billingPortal.sessions.create(params);
|
|
168
|
+
return { url: session.url };
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
throwStripeError("STRIPE_API_ERROR", "Failed to create Billing Portal session", error);
|
|
172
|
+
}
|
|
121
173
|
}
|
|
122
174
|
export async function getCountrySpecs(stripe, _ctx, opts) {
|
|
123
175
|
return await stripe.countrySpecs.retrieve(opts.countryCode);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountLinks.js","sourceRoot":"","sources":["../../../src/client/core/accountLinks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKhD,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,IAAY,EACZ,IAKC;IAED,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC;QACnD,OAAO,EAAE,IAAI,CAAC,eAAe;QAC7B,WAAW,EAAE,IAAI,CAAC,UAAU;QAC5B,UAAU,EAAE,IAAI,CAAC,SAAS;QAC1B,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC;AAClC,CAAC;AAED,MAAM,CAAC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AAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAc,EACd,IAAY,EACZ,IAA6B;IAE7B,OAAO,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -122,42 +122,8 @@ export declare function restartAccountOnboarding(stripe: Stripe, component: Comp
|
|
|
122
122
|
}): Promise<{
|
|
123
123
|
closed: boolean;
|
|
124
124
|
}>;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
* what makes a V2 Account billable — the customer-facing payment/billing flows
|
|
128
|
-
* (subscriptions, invoices, billing portal). In the V2 Accounts API a single
|
|
129
|
-
* Account with this configuration replaces the legacy V1 Customer object, so
|
|
130
|
-
* `customer_account: acct_…` is what you pass to subscriptions, setup intents,
|
|
131
|
-
* and billing-portal sessions. No capabilities are requested by default;
|
|
132
|
-
* request `customer.capabilities.automatic_indirect_tax` separately if you need
|
|
133
|
-
* automatic tax on this account's invoices/subscriptions.
|
|
134
|
-
*/
|
|
135
|
-
export declare const DEFAULT_CUSTOMER_CONFIGURATION: Record<string, unknown>;
|
|
136
|
-
/**
|
|
137
|
-
* Apply the customer configuration to an existing V2 Account, making it
|
|
138
|
-
* billable, and record the resulting applied configurations on the component
|
|
139
|
-
* account. The account must already exist in the component DB (e.g. created via
|
|
140
|
-
* `createAccount`); its owning `userId` is recovered from that record.
|
|
141
|
-
*/
|
|
142
|
-
export declare function addCustomerConfiguration(stripe: Stripe, component: Component, ctx: RunCtx, opts: {
|
|
143
|
-
stripeAccountId: string;
|
|
144
|
-
}): Promise<{
|
|
145
|
-
success: true;
|
|
146
|
-
appliedConfigurations: string[];
|
|
147
|
-
}>;
|
|
148
|
-
/**
|
|
149
|
-
* Apply the V2 recipient configuration to an existing account, and record the
|
|
150
|
-
* resulting applied configurations on the component account. The account must
|
|
151
|
-
* already exist in the component DB (e.g. from {@link createAccount}); its
|
|
152
|
-
* owning `userId` is recovered from that record, matching
|
|
153
|
-
* {@link addCustomerConfiguration}.
|
|
154
|
-
*/
|
|
155
|
-
export declare function addRecipientConfiguration(stripe: Stripe, component: Component, ctx: RunCtx, opts: {
|
|
156
|
-
stripeAccountId: string;
|
|
157
|
-
}): Promise<{
|
|
158
|
-
success: true;
|
|
159
|
-
appliedConfigurations: string[];
|
|
160
|
-
}>;
|
|
125
|
+
export { DEFAULT_CUSTOMER_CONFIGURATION, addCustomerConfiguration, addRecipientConfiguration, addMerchantConfiguration, } from "./accountConfigurations.js";
|
|
126
|
+
export { canReceiveTransfers } from "./accountCapabilities.js";
|
|
161
127
|
export declare function syncAllAccounts(stripe: Stripe, component: Component, ctx: RunCtx): Promise<{
|
|
162
128
|
synced: number;
|
|
163
129
|
errors: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../../src/client/core/accounts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../../src/client/core/accounts.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,oFAAoF;IACpF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AACF,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,KAAK,EAEV,qBAAqB,EACrB,wBAAwB,EAEzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAS1D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,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAKjC;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACxB,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAUnC;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,CAgC9B;AAED,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,CAE9B;AAED,OAAO,EACL,8BAA8B,EAC9B,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAM/D,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM;;;;GAoDZ"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { addCustomerConfiguration } from "./accountConfigurations.js";
|
|
1
2
|
import { idempotencyOptions } from "./idempotency.js";
|
|
2
3
|
import { runMutationOrThrow } from "../helpers.js";
|
|
3
4
|
import { throwStripeError } from "../errors.js";
|
|
@@ -224,79 +225,8 @@ export async function closeAccount(stripe, component, ctx, opts) {
|
|
|
224
225
|
export async function restartAccountOnboarding(stripe, component, ctx, opts) {
|
|
225
226
|
return closeAccount(stripe, component, ctx, opts);
|
|
226
227
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
* what makes a V2 Account billable — the customer-facing payment/billing flows
|
|
230
|
-
* (subscriptions, invoices, billing portal). In the V2 Accounts API a single
|
|
231
|
-
* Account with this configuration replaces the legacy V1 Customer object, so
|
|
232
|
-
* `customer_account: acct_…` is what you pass to subscriptions, setup intents,
|
|
233
|
-
* and billing-portal sessions. No capabilities are requested by default;
|
|
234
|
-
* request `customer.capabilities.automatic_indirect_tax` separately if you need
|
|
235
|
-
* automatic tax on this account's invoices/subscriptions.
|
|
236
|
-
*/
|
|
237
|
-
export const DEFAULT_CUSTOMER_CONFIGURATION = {
|
|
238
|
-
customer: {},
|
|
239
|
-
};
|
|
240
|
-
/**
|
|
241
|
-
* Apply the customer configuration to an existing V2 Account, making it
|
|
242
|
-
* billable, and record the resulting applied configurations on the component
|
|
243
|
-
* account. The account must already exist in the component DB (e.g. created via
|
|
244
|
-
* `createAccount`); its owning `userId` is recovered from that record.
|
|
245
|
-
*/
|
|
246
|
-
export async function addCustomerConfiguration(stripe, component, ctx, opts) {
|
|
247
|
-
const existing = (await ctx.runQuery(componentRef(component, "core/queries/getAccountByStripeId"), { stripeAccountId: opts.stripeAccountId }));
|
|
248
|
-
if (!existing) {
|
|
249
|
-
throwStripeError("ACCOUNT_NOT_FOUND", `No component account found for ${opts.stripeAccountId}; create it before applying the customer configuration`);
|
|
250
|
-
}
|
|
251
|
-
await stripe.v2.core.accounts.update(opts.stripeAccountId, {
|
|
252
|
-
configuration: DEFAULT_CUSTOMER_CONFIGURATION,
|
|
253
|
-
});
|
|
254
|
-
// Re-fetch to record the configurations Stripe actually applied
|
|
255
|
-
const updated = await stripe.v2.core.accounts.retrieve(opts.stripeAccountId);
|
|
256
|
-
const appliedConfigurations = updated.applied_configurations ?? [];
|
|
257
|
-
await runMutationOrThrow(ctx, componentRef(component, "core/mutations/upsertAccount"), {
|
|
258
|
-
stripeAccountId: opts.stripeAccountId,
|
|
259
|
-
userId: existing.userId,
|
|
260
|
-
appliedConfigurations,
|
|
261
|
-
});
|
|
262
|
-
return { success: true, appliedConfigurations };
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Apply the V2 recipient configuration to an existing account, and record the
|
|
266
|
-
* resulting applied configurations on the component account. The account must
|
|
267
|
-
* already exist in the component DB (e.g. from {@link createAccount}); its
|
|
268
|
-
* owning `userId` is recovered from that record, matching
|
|
269
|
-
* {@link addCustomerConfiguration}.
|
|
270
|
-
*/
|
|
271
|
-
export async function addRecipientConfiguration(stripe, component, ctx, opts) {
|
|
272
|
-
const existing = (await ctx.runQuery(componentRef(component, "core/queries/getAccountByStripeId"), { stripeAccountId: opts.stripeAccountId }));
|
|
273
|
-
if (!existing) {
|
|
274
|
-
throwStripeError("ACCOUNT_NOT_FOUND", `No component account found for ${opts.stripeAccountId}; create it before applying the recipient configuration`);
|
|
275
|
-
}
|
|
276
|
-
await stripe.v2.core.accounts.update(opts.stripeAccountId, {
|
|
277
|
-
configuration: {
|
|
278
|
-
recipient: {
|
|
279
|
-
// V2 (API 2026-05-27.dahlia) requires the `capabilities` wrapper with an
|
|
280
|
-
// explicit `requested: true`. The bare `recipient.stripe_balance` shape
|
|
281
|
-
// is rejected with "Unknown field" (confirmed against the Stripe sandbox).
|
|
282
|
-
capabilities: {
|
|
283
|
-
stripe_balance: {
|
|
284
|
-
stripe_transfers: { requested: true },
|
|
285
|
-
},
|
|
286
|
-
},
|
|
287
|
-
},
|
|
288
|
-
},
|
|
289
|
-
});
|
|
290
|
-
// Re-fetch to record the configurations Stripe actually applied
|
|
291
|
-
const updated = await stripe.v2.core.accounts.retrieve(opts.stripeAccountId);
|
|
292
|
-
const appliedConfigurations = updated.applied_configurations ?? [];
|
|
293
|
-
await runMutationOrThrow(ctx, componentRef(component, "core/mutations/upsertAccount"), {
|
|
294
|
-
stripeAccountId: opts.stripeAccountId,
|
|
295
|
-
userId: existing.userId,
|
|
296
|
-
appliedConfigurations,
|
|
297
|
-
});
|
|
298
|
-
return { success: true, appliedConfigurations };
|
|
299
|
-
}
|
|
228
|
+
export { DEFAULT_CUSTOMER_CONFIGURATION, addCustomerConfiguration, addRecipientConfiguration, addMerchantConfiguration, } from "./accountConfigurations.js";
|
|
229
|
+
export { canReceiveTransfers } from "./accountCapabilities.js";
|
|
300
230
|
// =============================================================================
|
|
301
231
|
// Sync
|
|
302
232
|
// =============================================================================
|