@fantastic.dev/better-stripe 0.72.2 → 0.73.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 +12 -0
- package/README.md +1 -1
- package/dist/client/products/catalogClient.d.ts +5 -0
- package/dist/client/products/catalogClient.d.ts.map +1 -1
- package/dist/client/products/catalogClient.js.map +1 -1
- package/dist/client/products/products.d.ts +7 -0
- package/dist/client/products/products.d.ts.map +1 -1
- package/dist/client/products/products.js +25 -11
- package/dist/client/products/products.js.map +1 -1
- package/docs/client-api.md +79 -14
- package/package.json +1 -1
- package/src/client/products/catalogClient.ts +8 -1
- package/src/client/products/product-descriptors.test.ts +260 -0
- package/src/client/products/product-set-idempotency.test.ts +188 -0
- package/src/client/products/products.ts +33 -9
package/CHANGELOG.md
CHANGED
|
@@ -26,6 +26,18 @@
|
|
|
26
26
|
- Remove internal tracker references from public documentation and add a
|
|
27
27
|
regression check that prevents their reintroduction.
|
|
28
28
|
|
|
29
|
+
## [0.73.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.72.3...v0.73.0) (2026-10-20)
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
- **products:** support explicit platform product descriptors ([#378](https://github.com/FantasticDevHQ/better-stripe/issues/378)) ([8cda57a](https://github.com/FantasticDevHQ/better-stripe/commit/8cda57a2bbcc16a898d2dd69601a6d4641fc1c18))
|
|
34
|
+
|
|
35
|
+
## [0.72.3](https://github.com/FantasticDevHQ/better-stripe/compare/v0.72.2...v0.72.3) (2026-10-20)
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
- preserve caller keys for product SETs ([#376](https://github.com/FantasticDevHQ/better-stripe/issues/376)) ([9101beb](https://github.com/FantasticDevHQ/better-stripe/commit/9101beb09c4f2c1f43f536cd83c881784da61b29))
|
|
40
|
+
|
|
29
41
|
## [0.72.2](https://github.com/FantasticDevHQ/better-stripe/compare/v0.72.1...v0.72.2) (2026-10-20)
|
|
30
42
|
|
|
31
43
|
### Tests
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ billing, and Connect marketplaces. It provides checkout, subscriptions, webhook
|
|
|
5
5
|
syncing, marketplace fees and splits, payouts, refunds, and disputes, with React
|
|
6
6
|
hooks and headless UI components.
|
|
7
7
|
|
|
8
|
-
**Version**: `0.
|
|
8
|
+
**Version**: `0.73.0` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
|
|
9
9
|
|
|
10
10
|
Connect platforms use the default GA API version. Non-Connect merchants using
|
|
11
11
|
customer-only Accounts v2 need preview access and an explicit preview version.
|
|
@@ -53,11 +53,16 @@ export declare abstract class CatalogClient extends BillingPortalClient {
|
|
|
53
53
|
active?: boolean;
|
|
54
54
|
defaultPrice?: string | null;
|
|
55
55
|
metadata?: Record<string, string>;
|
|
56
|
+
/** Explicit string overrides store defaults; null clears the descriptor. */
|
|
57
|
+
statementDescriptor?: string | null;
|
|
58
|
+
/** Reuse only for identical retries of the same provider SET. */
|
|
59
|
+
idempotencyKey?: string;
|
|
56
60
|
}): Promise<{
|
|
57
61
|
success: boolean;
|
|
58
62
|
}>;
|
|
59
63
|
deactivateProduct(ctx: RunCtx, opts: {
|
|
60
64
|
stripeProductId: string;
|
|
65
|
+
idempotencyKey?: string;
|
|
61
66
|
}): Promise<{
|
|
62
67
|
success: boolean;
|
|
63
68
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogClient.d.ts","sourceRoot":"","sources":["../../../src/client/products/catalogClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,cAAc,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAA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AAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,UAAU,CACd,GAAW,EACX,IAA+D;QAE/D,OAAO,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,mBAAmB,CACvB,GAAW,EACX,IAAiC;QAEjC,OAAO,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,WAAW,CACf,GAAW,EACX,IAAkD;QAElD,OAAO,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,GAAW,EACX,IAA+D;QAE/D,OAAO,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,GAAW;QAC/B,OAAO,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAC1E,CAAC;CACF"}
|
|
@@ -8,6 +8,8 @@ export type CreateProductOptions = {
|
|
|
8
8
|
accountId?: string;
|
|
9
9
|
metadata?: Record<string, string>;
|
|
10
10
|
idempotencyKey?: string;
|
|
11
|
+
/** Explicit string overrides store defaults; null suppresses inheritance on create. */
|
|
12
|
+
statementDescriptor?: string | null;
|
|
11
13
|
};
|
|
12
14
|
export declare function createProduct(stripe: Stripe, component: Component, ctx: RunCtx, opts: CreateProductOptions & {
|
|
13
15
|
defaultStatementDescriptorSuffix?: string;
|
|
@@ -24,11 +26,16 @@ export declare function updateProduct(stripe: Stripe, component: Component, ctx:
|
|
|
24
26
|
metadata?: Record<string, string>;
|
|
25
27
|
/** Platform default statement-descriptor suffix (BetterStripe option). */
|
|
26
28
|
defaultStatementDescriptorSuffix?: string;
|
|
29
|
+
/** String overrides store defaults; null clears without restoring a fallback. */
|
|
30
|
+
statementDescriptor?: string | null;
|
|
31
|
+
/** Caller-owned stable key for identical retries of this provider SET. */
|
|
32
|
+
idempotencyKey?: string;
|
|
27
33
|
}): Promise<{
|
|
28
34
|
success: boolean;
|
|
29
35
|
}>;
|
|
30
36
|
export declare function deactivateProduct(stripe: Stripe, _ctx: RunCtx, opts: {
|
|
31
37
|
stripeProductId: string;
|
|
38
|
+
idempotencyKey?: string;
|
|
32
39
|
}): Promise<{
|
|
33
40
|
success: boolean;
|
|
34
41
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"products.d.ts","sourceRoot":"","sources":["../../../src/client/products/products.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"products.d.ts","sourceRoot":"","sources":["../../../src/client/products/products.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAwD1D,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,cAAc,CAAC,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EACX,IAAI,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAKxC;AAED,wBAAsB,YAAY,CAChC,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9D,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAKnC;AAED,wBAAsB,aAAa,CACjC,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IACJ,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,iBAQF;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,6BAiB5C;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,mDAGlC;AAMD,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM;;;;;GAiFZ"}
|
|
@@ -16,13 +16,18 @@ import { componentRef } from "../webhooks/helpers.js";
|
|
|
16
16
|
* charge-type default, so a product-level descriptor covers every cycle
|
|
17
17
|
* including the first, while the invoice-level path still wins when it applies.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
19
|
+
* An explicit product value supports platform-owned products independently of
|
|
20
|
+
* payout accounts. Without an explicit value, resolution mirrors the account-level suffix logic (BTS-32) —
|
|
20
21
|
* the store's stored suffix, else the platform default. Products with no store
|
|
21
|
-
* (`accountId`)
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* (`accountId`) receive no inherited descriptor. Explicit invalid values fail
|
|
23
|
+
* before provider HTTP; invalid inherited values retain the legacy logged-skip
|
|
24
|
+
* behavior. Null suppresses inheritance without querying the account.
|
|
24
25
|
*/
|
|
25
|
-
async function resolveProductStatementDescriptor(component, ctx, accountId, defaultSuffix) {
|
|
26
|
+
async function resolveProductStatementDescriptor(component, ctx, accountId, defaultSuffix, explicit) {
|
|
27
|
+
if (explicit !== undefined)
|
|
28
|
+
return explicit === null
|
|
29
|
+
? undefined
|
|
30
|
+
: validateStatementDescriptorSuffix(explicit);
|
|
26
31
|
if (!accountId)
|
|
27
32
|
return undefined;
|
|
28
33
|
const account = (await ctx.runQuery(componentRef(component, "core/queries/getAccountByStripeId"), { stripeAccountId: accountId }));
|
|
@@ -38,7 +43,7 @@ async function resolveProductStatementDescriptor(component, ctx, accountId, defa
|
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
45
|
export async function createProduct(stripe, component, ctx, opts) {
|
|
41
|
-
const statementDescriptor = await resolveProductStatementDescriptor(component, ctx, opts.accountId, opts.defaultStatementDescriptorSuffix);
|
|
46
|
+
const statementDescriptor = await resolveProductStatementDescriptor(component, ctx, opts.accountId, opts.defaultStatementDescriptorSuffix, opts.statementDescriptor);
|
|
42
47
|
const params = {
|
|
43
48
|
name: opts.name,
|
|
44
49
|
description: opts.description ?? undefined,
|
|
@@ -84,15 +89,24 @@ export async function updateProduct(stripe, component, ctx, opts) {
|
|
|
84
89
|
// propagates to its products' first-invoice charges. Re-set only when a value
|
|
85
90
|
// resolves (never clears an existing descriptor).
|
|
86
91
|
const stored = (await ctx.runQuery(componentRef(component, "products/queries/getProductByStripeId"), { stripeProductId: opts.stripeProductId }));
|
|
87
|
-
const statementDescriptor = await resolveProductStatementDescriptor(component, ctx, stored?.accountId, opts.defaultStatementDescriptorSuffix);
|
|
88
|
-
if (statementDescriptor)
|
|
92
|
+
const statementDescriptor = await resolveProductStatementDescriptor(component, ctx, stored?.accountId, opts.defaultStatementDescriptorSuffix, opts.statementDescriptor);
|
|
93
|
+
if (opts.statementDescriptor === null)
|
|
94
|
+
updateParams.statement_descriptor = "";
|
|
95
|
+
else if (statementDescriptor)
|
|
89
96
|
updateParams.statement_descriptor = statementDescriptor;
|
|
90
|
-
|
|
91
|
-
|
|
97
|
+
if (opts.idempotencyKey !== undefined)
|
|
98
|
+
await stripe.products.update(opts.stripeProductId, updateParams, {
|
|
99
|
+
idempotencyKey: opts.idempotencyKey,
|
|
100
|
+
});
|
|
101
|
+
else
|
|
102
|
+
await stripe.products.update(opts.stripeProductId, updateParams);
|
|
92
103
|
return { success: true };
|
|
93
104
|
}
|
|
94
105
|
export async function deactivateProduct(stripe, _ctx, opts) {
|
|
95
|
-
|
|
106
|
+
if (opts.idempotencyKey !== undefined)
|
|
107
|
+
await stripe.products.update(opts.stripeProductId, { active: false }, { idempotencyKey: opts.idempotencyKey });
|
|
108
|
+
else
|
|
109
|
+
await stripe.products.update(opts.stripeProductId, { active: false });
|
|
96
110
|
return { success: true };
|
|
97
111
|
}
|
|
98
112
|
export async function getProduct(component, ctx, opts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"products.js","sourceRoot":"","sources":["../../../src/client/products/products.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EAAE,YA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AAI,CACT,SAAS,KAAK,CAAC,EAAE,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CACjF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,cAAc,EAAE,MAAM;QACtB,YAAY;QACZ,MAAM;QACN,UAAU,EAAE,MAAM,CAAC,MAAM;KAC1B,CAAC;AACJ,CAAC"}
|
package/docs/client-api.md
CHANGED
|
@@ -65,20 +65,70 @@ shows where the host's authenticated-actor check belongs.
|
|
|
65
65
|
|
|
66
66
|
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.
|
|
67
67
|
|
|
68
|
-
| Method | Description
|
|
69
|
-
| --------------------------------------------------------------------------------------------------------------------- |
|
|
70
|
-
| `createProduct(ctx, { name, description?, active?, accountId?, metadata? })`
|
|
71
|
-
| `getProduct(ctx, { productId })` | Get product by component document ID
|
|
72
|
-
| `getProductByStripeId(ctx, { stripeProductId })` | Get product by Stripe product ID
|
|
73
|
-
| `listProducts(ctx, { accountId?, active?, limit? })` | List products with optional filters
|
|
74
|
-
| `updateProduct(ctx, { stripeProductId, ...updates })`
|
|
75
|
-
| `deactivateProduct(ctx, { stripeProductId })`
|
|
76
|
-
| `createPrice(ctx, { stripeProductId, unitAmount, type, currency?, interval?, intervalCount?, nickname?, metadata? })` | Create price in Stripe and component DB
|
|
77
|
-
| `getPrice(ctx, { priceId })` | Get price by component document ID
|
|
78
|
-
| `getPriceByStripeId(ctx, { stripePriceId })` | Get price by Stripe price ID
|
|
79
|
-
| `listPrices(ctx, { productId?, active?, limit? })` | List prices with optional filters
|
|
80
|
-
| `updatePrice(ctx, { stripePriceId, ...updates })` | Update price fields
|
|
81
|
-
| `deactivatePrice(ctx, { stripePriceId })` | Deactivate price in Stripe and component DB
|
|
68
|
+
| Method | Description |
|
|
69
|
+
| --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
|
|
70
|
+
| `createProduct(ctx, { name, description?, active?, accountId?, metadata?, statementDescriptor?, idempotencyKey? })` | Create product in Stripe and component DB |
|
|
71
|
+
| `getProduct(ctx, { productId })` | Get product by component document ID |
|
|
72
|
+
| `getProductByStripeId(ctx, { stripeProductId })` | Get product by Stripe product ID |
|
|
73
|
+
| `listProducts(ctx, { accountId?, active?, limit? })` | List products with optional filters |
|
|
74
|
+
| `updateProduct(ctx, { stripeProductId, idempotencyKey?, ...updates })` | Update product fields |
|
|
75
|
+
| `deactivateProduct(ctx, { stripeProductId, idempotencyKey? })` | Deactivate product at Stripe |
|
|
76
|
+
| `createPrice(ctx, { stripeProductId, unitAmount, type, currency?, interval?, intervalCount?, nickname?, metadata? })` | Create price in Stripe and component DB |
|
|
77
|
+
| `getPrice(ctx, { priceId })` | Get price by component document ID |
|
|
78
|
+
| `getPriceByStripeId(ctx, { stripePriceId })` | Get price by Stripe price ID |
|
|
79
|
+
| `listPrices(ctx, { productId?, active?, limit? })` | List prices with optional filters |
|
|
80
|
+
| `updatePrice(ctx, { stripePriceId, ...updates })` | Update price fields |
|
|
81
|
+
| `deactivatePrice(ctx, { stripePriceId })` | Deactivate price in Stripe and component DB |
|
|
82
|
+
|
|
83
|
+
### Product statement descriptors
|
|
84
|
+
|
|
85
|
+
`createProduct` and `updateProduct` accept `statementDescriptor?: string | null`,
|
|
86
|
+
including for platform-owned products without an `accountId`.
|
|
87
|
+
|
|
88
|
+
| Input | Create | Update |
|
|
89
|
+
| ---------------------- | -------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
90
|
+
| Explicit string | Trim, validate and send `statement_descriptor` | Trim, validate and send `statement_descriptor` |
|
|
91
|
+
| Omitted or `undefined` | Keep legacy store/default resolution; a storeless product receives no descriptor | Keep legacy store/default refresh behavior |
|
|
92
|
+
| `null` | Suppress inheritance and omit the provider field | Send an empty provider field to clear it, without account/default fallback in this call |
|
|
93
|
+
|
|
94
|
+
Invalid explicit values reject before provider HTTP. An invalid inherited
|
|
95
|
+
store/default value retains the legacy logged-skip behavior. Null is an input
|
|
96
|
+
for this operation, not a persisted override: a later omitted-option update of
|
|
97
|
+
an account-associated product can restore its legacy account/default descriptor.
|
|
98
|
+
Use the same explicit input and stable `idempotencyKey` for an identical retry.
|
|
99
|
+
The SDK forwards provider errors and does not invent a new key or retry command.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
await stripe.createProduct(ctx, {
|
|
103
|
+
name: "Community membership",
|
|
104
|
+
statementDescriptor: "COMMUNITY ONE",
|
|
105
|
+
idempotencyKey: "catalog:create:original",
|
|
106
|
+
});
|
|
107
|
+
await stripe.updateProduct(ctx, {
|
|
108
|
+
stripeProductId: originalProductId,
|
|
109
|
+
statementDescriptor: null,
|
|
110
|
+
idempotencyKey: "catalog:descriptor-clear:original",
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The matching Vite `example/convex/products/actions.ts` forwards the same optional
|
|
115
|
+
inputs. Its demo actions do not supply host authorization. A host must authorize
|
|
116
|
+
the operator, bind its community to the exact original product and reject shared
|
|
117
|
+
products that would need different descriptors. This API does not change payout
|
|
118
|
+
accounts, merchant routing or the host's saved community policy. Product updates
|
|
119
|
+
do not synchronously refresh the component mirror; retain the existing signed
|
|
120
|
+
mirror/read reconciliation contract.
|
|
121
|
+
|
|
122
|
+
[Stripe's subscription precedence](https://docs.stripe.com/connect/statement-descriptors#subscriptions-and-invoices)
|
|
123
|
+
is invoice, product, then the charge-type default. Product configuration can
|
|
124
|
+
cover the first automatic subscription invoice before an invoice webhook runs.
|
|
125
|
+
It does not configure a one-time card PaymentIntent suffix. The existing invoice
|
|
126
|
+
processor's timing and logged-failure limits remain unchanged. Respect the
|
|
127
|
+
[descriptor format and combined-length rules](https://docs.stripe.com/get-started/account/statement-descriptors)
|
|
128
|
+
and actual platform prefix. Issuers can render descriptors differently; synthetic
|
|
129
|
+
transport tests are not live first-invoice, renewal or bank-statement evidence.
|
|
130
|
+
Public release, artifact verification and accepted host adoption precede use of
|
|
131
|
+
this new option by a downstream app.
|
|
82
132
|
|
|
83
133
|
### Checkout and Subscription
|
|
84
134
|
|
|
@@ -519,6 +569,21 @@ creation parameters change. Creating a new Price does not migrate existing
|
|
|
519
569
|
subscriptions; they retain their prior price until the host explicitly changes
|
|
520
570
|
them. Never reuse a version key for different parameters.
|
|
521
571
|
|
|
572
|
+
`updateProduct` and `deactivateProduct` also accept an optional `idempotencyKey`,
|
|
573
|
+
including through the example's product actions. It is a Stripe request option,
|
|
574
|
+
not product metadata. Persist one key for an intentional SET and reuse it only
|
|
575
|
+
for identical provider parameters; a later intentional change needs a new key.
|
|
576
|
+
Omitting it preserves Stripe SDK behavior, including automatic retry keys.
|
|
577
|
+
|
|
578
|
+
For these v1 product POSTs, Stripe retains the first executed response, including
|
|
579
|
+
`500` failures. A concurrent execution conflict does not establish completion;
|
|
580
|
+
the SDK preserves that error. Keys may be removed after at least 24 hours, and a
|
|
581
|
+
subsequent reuse can execute again. The host must bound retries before that
|
|
582
|
+
window, retain unresolved operations beyond its cutoff, and serialize conflicting
|
|
583
|
+
business operations itself. This option does not provide a host command ledger
|
|
584
|
+
or an unlimited exactly-once guarantee. Provider errors never trigger a new-key
|
|
585
|
+
retry in these methods. See [Stripe's idempotency contract](https://docs.stripe.com/api/idempotent_requests).
|
|
586
|
+
|
|
522
587
|
React `Checkout` preserves its request ID through retries; your server must
|
|
523
588
|
forward that identity as the SDK request option. Persist it in the host order
|
|
524
589
|
for recovery across reloads. Omission retains the previous SDK behavior.
|
package/package.json
CHANGED
|
@@ -119,6 +119,10 @@ export abstract class CatalogClient extends BillingPortalClient {
|
|
|
119
119
|
active?: boolean;
|
|
120
120
|
defaultPrice?: string | null;
|
|
121
121
|
metadata?: Record<string, string>;
|
|
122
|
+
/** Explicit string overrides store defaults; null clears the descriptor. */
|
|
123
|
+
statementDescriptor?: string | null;
|
|
124
|
+
/** Reuse only for identical retries of the same provider SET. */
|
|
125
|
+
idempotencyKey?: string;
|
|
122
126
|
},
|
|
123
127
|
) {
|
|
124
128
|
return productsImpl.updateProduct(this.stripe(), this.component, ctx, {
|
|
@@ -127,7 +131,10 @@ export abstract class CatalogClient extends BillingPortalClient {
|
|
|
127
131
|
});
|
|
128
132
|
}
|
|
129
133
|
|
|
130
|
-
async deactivateProduct(
|
|
134
|
+
async deactivateProduct(
|
|
135
|
+
ctx: RunCtx,
|
|
136
|
+
opts: { stripeProductId: string; idempotencyKey?: string },
|
|
137
|
+
) {
|
|
131
138
|
return productsImpl.deactivateProduct(this.stripe(), ctx, opts);
|
|
132
139
|
}
|
|
133
140
|
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { componentsGeneric } from "convex/server";
|
|
2
|
+
import Stripe from "stripe";
|
|
3
|
+
import { expect, it, vi } from "vitest";
|
|
4
|
+
|
|
5
|
+
import { STRIPE_API_VERSION } from "../constants.js";
|
|
6
|
+
import type { Component, RunCtx } from "../helpers.js";
|
|
7
|
+
import { BetterStripe } from "../index.js";
|
|
8
|
+
|
|
9
|
+
function fixture(store?: string) {
|
|
10
|
+
const requests: {
|
|
11
|
+
path: string;
|
|
12
|
+
key: string | null;
|
|
13
|
+
form: URLSearchParams;
|
|
14
|
+
}[] = [];
|
|
15
|
+
let failure: { status: number; type: string; code?: string } | undefined;
|
|
16
|
+
const sdk = new Stripe("sk_test_product_descriptor_synthetic", {
|
|
17
|
+
apiVersion: STRIPE_API_VERSION,
|
|
18
|
+
maxNetworkRetries: 0,
|
|
19
|
+
httpClient: Stripe.createFetchHttpClient(async (url, init) => {
|
|
20
|
+
expect(init?.method).toBe("POST");
|
|
21
|
+
requests.push({
|
|
22
|
+
path: new URL(String(url)).pathname,
|
|
23
|
+
key: new Headers(init?.headers).get("Idempotency-Key"),
|
|
24
|
+
form: new URLSearchParams(String(init?.body ?? "")),
|
|
25
|
+
});
|
|
26
|
+
return new Response(
|
|
27
|
+
JSON.stringify(
|
|
28
|
+
failure
|
|
29
|
+
? { error: { ...failure, message: "Synthetic descriptor failure" } }
|
|
30
|
+
: {
|
|
31
|
+
id: "prod_original",
|
|
32
|
+
object: "product",
|
|
33
|
+
name: "Original",
|
|
34
|
+
active: true,
|
|
35
|
+
metadata: {},
|
|
36
|
+
},
|
|
37
|
+
),
|
|
38
|
+
{
|
|
39
|
+
status: failure?.status ?? 200,
|
|
40
|
+
headers: { "content-type": "application/json" },
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
class Client extends BetterStripe {
|
|
46
|
+
protected override stripe() {
|
|
47
|
+
return sdk;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const client = new Client(
|
|
51
|
+
componentsGeneric().betterStripe as unknown as Component,
|
|
52
|
+
{
|
|
53
|
+
STRIPE_SECRET_KEY: "sk_test_product_descriptor_synthetic",
|
|
54
|
+
statementDescriptorSuffix: "PLATFORM",
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
const ctx: RunCtx = {
|
|
58
|
+
runQuery: vi.fn().mockImplementation(async (_ref, args) =>
|
|
59
|
+
args.stripeAccountId
|
|
60
|
+
? { statementDescriptor: store }
|
|
61
|
+
: {
|
|
62
|
+
_id: "component_original",
|
|
63
|
+
accountId: store === undefined ? undefined : "acct_store",
|
|
64
|
+
},
|
|
65
|
+
),
|
|
66
|
+
runMutation: vi.fn().mockResolvedValue(null),
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
client,
|
|
70
|
+
ctx,
|
|
71
|
+
requests,
|
|
72
|
+
fail(status: number, type: string, code?: string) {
|
|
73
|
+
failure = { status, type, code };
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
it.each(["create", "update"] as const)(
|
|
79
|
+
"%s sends an explicit descriptor for a platform product",
|
|
80
|
+
async (method) => {
|
|
81
|
+
const f = fixture();
|
|
82
|
+
if (method === "create")
|
|
83
|
+
await f.client.createProduct(f.ctx, {
|
|
84
|
+
name: "Original",
|
|
85
|
+
statementDescriptor: " COMMUNITY ONE ",
|
|
86
|
+
metadata: { communityId: "one" },
|
|
87
|
+
idempotencyKey: "descriptor:original",
|
|
88
|
+
} satisfies Parameters<BetterStripe["createProduct"]>[1]);
|
|
89
|
+
else
|
|
90
|
+
await f.client.updateProduct(f.ctx, {
|
|
91
|
+
stripeProductId: "prod_original",
|
|
92
|
+
statementDescriptor: " COMMUNITY ONE ",
|
|
93
|
+
metadata: { communityId: "one" },
|
|
94
|
+
idempotencyKey: "descriptor:original",
|
|
95
|
+
} satisfies Parameters<BetterStripe["updateProduct"]>[1]);
|
|
96
|
+
expect(f.requests).toHaveLength(1);
|
|
97
|
+
expect(f.requests[0]?.form.get("statement_descriptor")).toBe(
|
|
98
|
+
"COMMUNITY ONE",
|
|
99
|
+
);
|
|
100
|
+
expect(f.requests[0]?.form.get("metadata[communityId]")).toBe("one");
|
|
101
|
+
expect(f.requests[0]?.form.has("accountId")).toBe(false);
|
|
102
|
+
expect(f.requests[0]?.key).toBe("descriptor:original");
|
|
103
|
+
expect(f.requests[0]?.path).toBe(
|
|
104
|
+
method === "create" ? "/v1/products" : "/v1/products/prod_original",
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
it("an explicit string overrides a store descriptor without changing the account", async () => {
|
|
110
|
+
const f = fixture("OLD STORE");
|
|
111
|
+
await f.client.createProduct(f.ctx, {
|
|
112
|
+
name: "Original",
|
|
113
|
+
accountId: "acct_store",
|
|
114
|
+
statementDescriptor: "COMMUNITY TWO",
|
|
115
|
+
});
|
|
116
|
+
await f.client.updateProduct(f.ctx, {
|
|
117
|
+
stripeProductId: "prod_original",
|
|
118
|
+
statementDescriptor: "COMMUNITY TWO",
|
|
119
|
+
});
|
|
120
|
+
expect(f.requests.map((r) => r.form.get("statement_descriptor"))).toEqual([
|
|
121
|
+
"COMMUNITY TWO",
|
|
122
|
+
"COMMUNITY TWO",
|
|
123
|
+
]);
|
|
124
|
+
expect(f.ctx.runMutation).toHaveBeenCalledTimes(1);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("update null clears exactly the selected product without restoring a store/default", async () => {
|
|
128
|
+
const f = fixture("OLD STORE");
|
|
129
|
+
await f.client.updateProduct(f.ctx, {
|
|
130
|
+
stripeProductId: "prod_original",
|
|
131
|
+
statementDescriptor: null,
|
|
132
|
+
idempotencyKey: "descriptor:clear",
|
|
133
|
+
});
|
|
134
|
+
expect(f.requests).toHaveLength(1);
|
|
135
|
+
expect(f.requests[0]?.path).toBe("/v1/products/prod_original");
|
|
136
|
+
expect(f.requests[0]?.form.has("statement_descriptor")).toBe(true);
|
|
137
|
+
expect(f.requests[0]?.form.get("statement_descriptor")).toBe("");
|
|
138
|
+
expect(f.requests[0]?.key).toBe("descriptor:clear");
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("create null suppresses inherited descriptors without sending an empty provider field", async () => {
|
|
142
|
+
const f = fixture("OLD STORE");
|
|
143
|
+
await f.client.createProduct(f.ctx, {
|
|
144
|
+
name: "Original",
|
|
145
|
+
accountId: "acct_store",
|
|
146
|
+
statementDescriptor: null,
|
|
147
|
+
});
|
|
148
|
+
expect(f.requests[0]?.form.has("statement_descriptor")).toBe(false);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("omission retains store/default resolution and leaves platform products unchanged", async () => {
|
|
152
|
+
const store = fixture("OLD STORE");
|
|
153
|
+
await store.client.createProduct(store.ctx, {
|
|
154
|
+
name: "Original",
|
|
155
|
+
accountId: "acct_store",
|
|
156
|
+
});
|
|
157
|
+
await store.client.updateProduct(store.ctx, {
|
|
158
|
+
stripeProductId: "prod_original",
|
|
159
|
+
});
|
|
160
|
+
expect(store.requests.map((r) => r.form.get("statement_descriptor"))).toEqual(
|
|
161
|
+
["OLD STORE", "OLD STORE"],
|
|
162
|
+
);
|
|
163
|
+
const platform = fixture();
|
|
164
|
+
await platform.client.createProduct(platform.ctx, { name: "Original" });
|
|
165
|
+
await platform.client.updateProduct(platform.ctx, {
|
|
166
|
+
stripeProductId: "prod_original",
|
|
167
|
+
});
|
|
168
|
+
expect(
|
|
169
|
+
platform.requests.every((r) => !r.form.has("statement_descriptor")),
|
|
170
|
+
).toBe(true);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it.each([
|
|
174
|
+
"",
|
|
175
|
+
" ",
|
|
176
|
+
"BAD*NAME",
|
|
177
|
+
"NO<NAME",
|
|
178
|
+
"1234",
|
|
179
|
+
"NONLATINé",
|
|
180
|
+
"THIS DESCRIPTOR IS FAR TOO LONG",
|
|
181
|
+
])(
|
|
182
|
+
"rejects explicit invalid %j before provider HTTP",
|
|
183
|
+
async (statementDescriptor) => {
|
|
184
|
+
const f = fixture();
|
|
185
|
+
await expect(
|
|
186
|
+
f.client.createProduct(f.ctx, { name: "Original", statementDescriptor }),
|
|
187
|
+
).rejects.toThrow(/statement descriptor/i);
|
|
188
|
+
await expect(
|
|
189
|
+
f.client.updateProduct(f.ctx, {
|
|
190
|
+
stripeProductId: "prod_original",
|
|
191
|
+
statementDescriptor,
|
|
192
|
+
}),
|
|
193
|
+
).rejects.toThrow(/statement descriptor/i);
|
|
194
|
+
expect(f.requests).toHaveLength(0);
|
|
195
|
+
expect(f.ctx.runMutation).not.toHaveBeenCalled();
|
|
196
|
+
},
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
it("does not inherit another explicit community descriptor or stable key", async () => {
|
|
200
|
+
const f = fixture();
|
|
201
|
+
for (const [stripeProductId, statementDescriptor, idempotencyKey] of [
|
|
202
|
+
["prod_original", "COMMUNITY ONE", "descriptor:one"],
|
|
203
|
+
["prod_other", "COMMUNITY TWO", "descriptor:two"],
|
|
204
|
+
["prod_original", "COMMUNITY ONE", "descriptor:one"],
|
|
205
|
+
])
|
|
206
|
+
await f.client.updateProduct(f.ctx, {
|
|
207
|
+
stripeProductId,
|
|
208
|
+
statementDescriptor,
|
|
209
|
+
idempotencyKey,
|
|
210
|
+
});
|
|
211
|
+
expect(
|
|
212
|
+
f.requests.map((r) => [r.path, r.key, r.form.get("statement_descriptor")]),
|
|
213
|
+
).toEqual([
|
|
214
|
+
["/v1/products/prod_original", "descriptor:one", "COMMUNITY ONE"],
|
|
215
|
+
["/v1/products/prod_other", "descriptor:two", "COMMUNITY TWO"],
|
|
216
|
+
["/v1/products/prod_original", "descriptor:one", "COMMUNITY ONE"],
|
|
217
|
+
]);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it.each(
|
|
221
|
+
(["create", "update"] as const).flatMap((method) =>
|
|
222
|
+
[400, 409, 500].map((status) => ({ method, status })),
|
|
223
|
+
),
|
|
224
|
+
)(
|
|
225
|
+
"preserves $method HTTP$status and original descriptor/key without another attempt",
|
|
226
|
+
async ({ method, status }) => {
|
|
227
|
+
const f = fixture();
|
|
228
|
+
f.fail(
|
|
229
|
+
status,
|
|
230
|
+
status === 500 ? "api_error" : "idempotency_error",
|
|
231
|
+
status === 409 ? "idempotency_key_in_use" : undefined,
|
|
232
|
+
);
|
|
233
|
+
const request =
|
|
234
|
+
method === "create"
|
|
235
|
+
? f.client.createProduct(f.ctx, {
|
|
236
|
+
name: "Original",
|
|
237
|
+
statementDescriptor: "COMMUNITY ONE",
|
|
238
|
+
idempotencyKey: "descriptor:failure",
|
|
239
|
+
})
|
|
240
|
+
: f.client.updateProduct(f.ctx, {
|
|
241
|
+
stripeProductId: "prod_original",
|
|
242
|
+
statementDescriptor: "COMMUNITY ONE",
|
|
243
|
+
idempotencyKey: "descriptor:failure",
|
|
244
|
+
});
|
|
245
|
+
await expect(request).rejects.toBeInstanceOf(
|
|
246
|
+
status === 400
|
|
247
|
+
? Stripe.errors.StripeIdempotencyError
|
|
248
|
+
: Stripe.errors.StripeAPIError,
|
|
249
|
+
);
|
|
250
|
+
await expect(request).rejects.toMatchObject({
|
|
251
|
+
statusCode: status,
|
|
252
|
+
code: status === 409 ? "idempotency_key_in_use" : undefined,
|
|
253
|
+
});
|
|
254
|
+
expect(f.requests).toHaveLength(1);
|
|
255
|
+
expect(f.requests[0]?.key).toBe("descriptor:failure");
|
|
256
|
+
expect(f.requests[0]?.form.get("statement_descriptor")).toBe(
|
|
257
|
+
"COMMUNITY ONE",
|
|
258
|
+
);
|
|
259
|
+
},
|
|
260
|
+
);
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { componentsGeneric } from "convex/server";
|
|
2
|
+
import Stripe from "stripe";
|
|
3
|
+
import { expect, it, vi } from "vitest";
|
|
4
|
+
|
|
5
|
+
import { STRIPE_API_VERSION } from "../constants.js";
|
|
6
|
+
import type { Component, RunCtx } from "../helpers.js";
|
|
7
|
+
import { BetterStripe } from "../index.js";
|
|
8
|
+
|
|
9
|
+
function fixture() {
|
|
10
|
+
const requests: { path: string; key: string | null; body: string }[] = [];
|
|
11
|
+
let failure: { status: number; type: string; code?: string } | undefined;
|
|
12
|
+
const sdk = new Stripe("sk_test_product_set_synthetic", {
|
|
13
|
+
apiVersion: STRIPE_API_VERSION,
|
|
14
|
+
maxNetworkRetries: 0,
|
|
15
|
+
httpClient: Stripe.createFetchHttpClient(async (url, init) => {
|
|
16
|
+
expect(init?.method).toBe("POST");
|
|
17
|
+
expect(new URL(String(url)).pathname).toBe("/v1/products/prod_original");
|
|
18
|
+
requests.push({
|
|
19
|
+
path: new URL(String(url)).pathname,
|
|
20
|
+
key: new Headers(init?.headers).get("Idempotency-Key"),
|
|
21
|
+
body: String(init?.body ?? ""),
|
|
22
|
+
});
|
|
23
|
+
return new Response(
|
|
24
|
+
JSON.stringify(
|
|
25
|
+
failure
|
|
26
|
+
? {
|
|
27
|
+
error: {
|
|
28
|
+
type: failure.type,
|
|
29
|
+
code: failure.code,
|
|
30
|
+
message: "Synthetic SET failure",
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
: { id: "prod_original", object: "product", active: false },
|
|
34
|
+
),
|
|
35
|
+
{
|
|
36
|
+
status: failure?.status ?? 200,
|
|
37
|
+
headers: { "content-type": "application/json" },
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
class Client extends BetterStripe {
|
|
43
|
+
protected override stripe() {
|
|
44
|
+
return sdk;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const client = new Client(
|
|
48
|
+
componentsGeneric().betterStripe as unknown as Component,
|
|
49
|
+
{ STRIPE_SECRET_KEY: "sk_test_product_set_synthetic" },
|
|
50
|
+
);
|
|
51
|
+
const ctx: RunCtx = { runQuery: vi.fn().mockResolvedValue(null) };
|
|
52
|
+
return {
|
|
53
|
+
client,
|
|
54
|
+
ctx,
|
|
55
|
+
requests,
|
|
56
|
+
fail(status: number, type: string, code?: string) {
|
|
57
|
+
failure = { status, type, code };
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
it("forwards the public update key as an HTTP request option without changing product parameters", async () => {
|
|
63
|
+
const f = fixture();
|
|
64
|
+
const opts = {
|
|
65
|
+
stripeProductId: "prod_original",
|
|
66
|
+
name: "Renamed",
|
|
67
|
+
active: false,
|
|
68
|
+
idempotencyKey: "catalog-set:original",
|
|
69
|
+
} satisfies Parameters<BetterStripe["updateProduct"]>[1];
|
|
70
|
+
expect(await f.client.updateProduct(f.ctx, opts)).toEqual({ success: true });
|
|
71
|
+
expect(f.requests).toEqual([
|
|
72
|
+
{
|
|
73
|
+
path: "/v1/products/prod_original",
|
|
74
|
+
key: "catalog-set:original",
|
|
75
|
+
body: "name=Renamed&active=false",
|
|
76
|
+
},
|
|
77
|
+
]);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("forwards the public deactivate key without putting it into product metadata or parameters", async () => {
|
|
81
|
+
const f = fixture();
|
|
82
|
+
const opts = {
|
|
83
|
+
stripeProductId: "prod_original",
|
|
84
|
+
idempotencyKey: "catalog-archive:original",
|
|
85
|
+
} satisfies Parameters<BetterStripe["deactivateProduct"]>[1];
|
|
86
|
+
expect(await f.client.deactivateProduct(f.ctx, opts)).toEqual({
|
|
87
|
+
success: true,
|
|
88
|
+
});
|
|
89
|
+
expect(f.requests).toEqual([
|
|
90
|
+
{
|
|
91
|
+
path: "/v1/products/prod_original",
|
|
92
|
+
key: "catalog-archive:original",
|
|
93
|
+
body: "active=false",
|
|
94
|
+
},
|
|
95
|
+
]);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("keeps repeated and later intentional SET keys isolated across the same client", async () => {
|
|
99
|
+
const f = fixture();
|
|
100
|
+
const opts = {
|
|
101
|
+
stripeProductId: "prod_original",
|
|
102
|
+
active: false,
|
|
103
|
+
idempotencyKey: "catalog-set:original",
|
|
104
|
+
};
|
|
105
|
+
await f.client.updateProduct(f.ctx, opts);
|
|
106
|
+
await f.client.updateProduct(f.ctx, opts);
|
|
107
|
+
await f.client.deactivateProduct(f.ctx, {
|
|
108
|
+
stripeProductId: "prod_original",
|
|
109
|
+
idempotencyKey: "catalog-set:later",
|
|
110
|
+
});
|
|
111
|
+
expect(f.requests.map((r) => r.key)).toEqual([
|
|
112
|
+
"catalog-set:original",
|
|
113
|
+
"catalog-set:original",
|
|
114
|
+
"catalog-set:later",
|
|
115
|
+
]);
|
|
116
|
+
expect(f.requests.map((r) => r.body)).toEqual([
|
|
117
|
+
"active=false",
|
|
118
|
+
"active=false",
|
|
119
|
+
"active=false",
|
|
120
|
+
]);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("preserves omitted-key SET behavior and does not inherit a previous caller key", async () => {
|
|
124
|
+
const f = fixture();
|
|
125
|
+
await f.client.updateProduct(f.ctx, {
|
|
126
|
+
stripeProductId: "prod_original",
|
|
127
|
+
idempotencyKey: "catalog-set:previous",
|
|
128
|
+
});
|
|
129
|
+
await f.client.updateProduct(f.ctx, {
|
|
130
|
+
stripeProductId: "prod_original",
|
|
131
|
+
name: "Unkeyed edit",
|
|
132
|
+
});
|
|
133
|
+
await f.client.deactivateProduct(f.ctx, { stripeProductId: "prod_original" });
|
|
134
|
+
// Stripe-node supplies fresh automatic retry keys; callers without a key must
|
|
135
|
+
// retain that behavior, rather than inheriting another caller's stable key.
|
|
136
|
+
expect(f.requests.slice(1).map((r) => r.key)).toEqual([
|
|
137
|
+
expect.stringMatching(/^stripe-node-retry-/),
|
|
138
|
+
expect.stringMatching(/^stripe-node-retry-/),
|
|
139
|
+
]);
|
|
140
|
+
expect(new Set(f.requests.slice(1).map((r) => r.key)).size).toBe(2);
|
|
141
|
+
expect(f.requests.slice(1).map((r) => r.body)).toEqual([
|
|
142
|
+
"name=Unkeyed%20edit",
|
|
143
|
+
"active=false",
|
|
144
|
+
]);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it.each(
|
|
148
|
+
(["update", "deactivate"] as const).flatMap((method) =>
|
|
149
|
+
[
|
|
150
|
+
{
|
|
151
|
+
status: 400,
|
|
152
|
+
type: "idempotency_error",
|
|
153
|
+
code: undefined,
|
|
154
|
+
errorClass: Stripe.errors.StripeIdempotencyError,
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
status: 409,
|
|
158
|
+
type: "idempotency_error",
|
|
159
|
+
code: "idempotency_key_in_use",
|
|
160
|
+
errorClass: Stripe.errors.StripeAPIError,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
status: 500,
|
|
164
|
+
type: "api_error",
|
|
165
|
+
code: undefined,
|
|
166
|
+
errorClass: Stripe.errors.StripeAPIError,
|
|
167
|
+
},
|
|
168
|
+
].map((failure) => ({ method, ...failure })),
|
|
169
|
+
),
|
|
170
|
+
)(
|
|
171
|
+
"preserves HTTP$status for $method with the original key and no extra attempt",
|
|
172
|
+
async ({ method, status, type, code, errorClass }) => {
|
|
173
|
+
const f = fixture();
|
|
174
|
+
f.fail(status, type, code);
|
|
175
|
+
const opts = {
|
|
176
|
+
stripeProductId: "prod_original",
|
|
177
|
+
idempotencyKey: "catalog-set:conflict",
|
|
178
|
+
};
|
|
179
|
+
const request =
|
|
180
|
+
method === "update"
|
|
181
|
+
? f.client.updateProduct(f.ctx, opts)
|
|
182
|
+
: f.client.deactivateProduct(f.ctx, opts);
|
|
183
|
+
await expect(request).rejects.toBeInstanceOf(errorClass);
|
|
184
|
+
await expect(request).rejects.toMatchObject({ statusCode: status, code });
|
|
185
|
+
expect(f.requests).toHaveLength(1);
|
|
186
|
+
expect(f.requests[0]?.key).toBe(opts.idempotencyKey);
|
|
187
|
+
},
|
|
188
|
+
);
|
|
@@ -22,18 +22,24 @@ import { componentRef } from "../webhooks/helpers.js";
|
|
|
22
22
|
* charge-type default, so a product-level descriptor covers every cycle
|
|
23
23
|
* including the first, while the invoice-level path still wins when it applies.
|
|
24
24
|
*
|
|
25
|
-
*
|
|
25
|
+
* An explicit product value supports platform-owned products independently of
|
|
26
|
+
* payout accounts. Without an explicit value, resolution mirrors the account-level suffix logic (BTS-32) —
|
|
26
27
|
* the store's stored suffix, else the platform default. Products with no store
|
|
27
|
-
* (`accountId`)
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* (`accountId`) receive no inherited descriptor. Explicit invalid values fail
|
|
29
|
+
* before provider HTTP; invalid inherited values retain the legacy logged-skip
|
|
30
|
+
* behavior. Null suppresses inheritance without querying the account.
|
|
30
31
|
*/
|
|
31
32
|
async function resolveProductStatementDescriptor(
|
|
32
33
|
component: Component,
|
|
33
34
|
ctx: RunCtx,
|
|
34
35
|
accountId: string | undefined,
|
|
35
36
|
defaultSuffix: string | undefined,
|
|
37
|
+
explicit?: string | null,
|
|
36
38
|
): Promise<string | undefined> {
|
|
39
|
+
if (explicit !== undefined)
|
|
40
|
+
return explicit === null
|
|
41
|
+
? undefined
|
|
42
|
+
: validateStatementDescriptorSuffix(explicit);
|
|
37
43
|
if (!accountId) return undefined;
|
|
38
44
|
const account = (await ctx.runQuery(
|
|
39
45
|
componentRef(component, "core/queries/getAccountByStripeId"),
|
|
@@ -62,6 +68,8 @@ export type CreateProductOptions = {
|
|
|
62
68
|
accountId?: string;
|
|
63
69
|
metadata?: Record<string, string>;
|
|
64
70
|
idempotencyKey?: string;
|
|
71
|
+
/** Explicit string overrides store defaults; null suppresses inheritance on create. */
|
|
72
|
+
statementDescriptor?: string | null;
|
|
65
73
|
};
|
|
66
74
|
|
|
67
75
|
export async function createProduct(
|
|
@@ -75,6 +83,7 @@ export async function createProduct(
|
|
|
75
83
|
ctx,
|
|
76
84
|
opts.accountId,
|
|
77
85
|
opts.defaultStatementDescriptorSuffix,
|
|
86
|
+
opts.statementDescriptor,
|
|
78
87
|
);
|
|
79
88
|
|
|
80
89
|
const params: Stripe.ProductCreateParams = {
|
|
@@ -128,6 +137,10 @@ export async function updateProduct(
|
|
|
128
137
|
metadata?: Record<string, string>;
|
|
129
138
|
/** Platform default statement-descriptor suffix (BetterStripe option). */
|
|
130
139
|
defaultStatementDescriptorSuffix?: string;
|
|
140
|
+
/** String overrides store defaults; null clears without restoring a fallback. */
|
|
141
|
+
statementDescriptor?: string | null;
|
|
142
|
+
/** Caller-owned stable key for identical retries of this provider SET. */
|
|
143
|
+
idempotencyKey?: string;
|
|
131
144
|
},
|
|
132
145
|
) {
|
|
133
146
|
const updateParams: Stripe.ProductUpdateParams = {};
|
|
@@ -153,21 +166,32 @@ export async function updateProduct(
|
|
|
153
166
|
ctx,
|
|
154
167
|
stored?.accountId,
|
|
155
168
|
opts.defaultStatementDescriptorSuffix,
|
|
169
|
+
opts.statementDescriptor,
|
|
156
170
|
);
|
|
157
|
-
if (statementDescriptor)
|
|
171
|
+
if (opts.statementDescriptor === null) updateParams.statement_descriptor = "";
|
|
172
|
+
else if (statementDescriptor)
|
|
158
173
|
updateParams.statement_descriptor = statementDescriptor;
|
|
159
|
-
}
|
|
160
174
|
|
|
161
|
-
|
|
175
|
+
if (opts.idempotencyKey !== undefined)
|
|
176
|
+
await stripe.products.update(opts.stripeProductId, updateParams, {
|
|
177
|
+
idempotencyKey: opts.idempotencyKey,
|
|
178
|
+
});
|
|
179
|
+
else await stripe.products.update(opts.stripeProductId, updateParams);
|
|
162
180
|
return { success: true };
|
|
163
181
|
}
|
|
164
182
|
|
|
165
183
|
export async function deactivateProduct(
|
|
166
184
|
stripe: Stripe,
|
|
167
185
|
_ctx: RunCtx,
|
|
168
|
-
opts: { stripeProductId: string },
|
|
186
|
+
opts: { stripeProductId: string; idempotencyKey?: string },
|
|
169
187
|
) {
|
|
170
|
-
|
|
188
|
+
if (opts.idempotencyKey !== undefined)
|
|
189
|
+
await stripe.products.update(
|
|
190
|
+
opts.stripeProductId,
|
|
191
|
+
{ active: false },
|
|
192
|
+
{ idempotencyKey: opts.idempotencyKey },
|
|
193
|
+
);
|
|
194
|
+
else await stripe.products.update(opts.stripeProductId, { active: false });
|
|
171
195
|
return { success: true };
|
|
172
196
|
}
|
|
173
197
|
|