@usehercules/sdk 1.3.0 → 1.5.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 +20 -0
- package/LICENSE +1 -1
- package/package.json +1 -1
- package/resources/beta/beta.d.mts +4 -0
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +4 -0
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js +4 -0
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs +4 -0
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/index.d.mts +1 -0
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +1 -0
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js +3 -1
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs +1 -0
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/pay/coupons.d.mts +1 -1
- package/resources/beta/pay/coupons.d.ts +1 -1
- package/resources/beta/pay/customers.d.mts +1 -1
- package/resources/beta/pay/customers.d.ts +1 -1
- package/resources/beta/pay/entitlements.d.mts +4 -22
- package/resources/beta/pay/entitlements.d.mts.map +1 -1
- package/resources/beta/pay/entitlements.d.ts +4 -22
- package/resources/beta/pay/entitlements.d.ts.map +1 -1
- package/resources/beta/pay/entitlements.js +3 -4
- package/resources/beta/pay/entitlements.js.map +1 -1
- package/resources/beta/pay/entitlements.mjs +3 -4
- package/resources/beta/pay/entitlements.mjs.map +1 -1
- package/resources/beta/pay/pay.d.mts +76 -16
- package/resources/beta/pay/pay.d.mts.map +1 -1
- package/resources/beta/pay/pay.d.ts +76 -16
- package/resources/beta/pay/pay.d.ts.map +1 -1
- package/resources/beta/pay/pay.js.map +1 -1
- package/resources/beta/pay/pay.mjs.map +1 -1
- package/resources/beta/pay/products/entitlements.d.mts +1 -1
- package/resources/beta/pay/products/entitlements.d.ts +1 -1
- package/resources/beta/pay/products/index.d.mts +1 -0
- package/resources/beta/pay/products/index.d.mts.map +1 -1
- package/resources/beta/pay/products/index.d.ts +1 -0
- package/resources/beta/pay/products/index.d.ts.map +1 -1
- package/resources/beta/pay/products/index.js +3 -1
- package/resources/beta/pay/products/index.js.map +1 -1
- package/resources/beta/pay/products/index.mjs +1 -0
- package/resources/beta/pay/products/index.mjs.map +1 -1
- package/resources/beta/pay/products/products.d.mts +45 -14
- package/resources/beta/pay/products/products.d.mts.map +1 -1
- package/resources/beta/pay/products/products.d.ts +45 -14
- package/resources/beta/pay/products/products.d.ts.map +1 -1
- package/resources/beta/pay/products/products.js +4 -0
- package/resources/beta/pay/products/products.js.map +1 -1
- package/resources/beta/pay/products/products.mjs +4 -0
- package/resources/beta/pay/products/products.mjs.map +1 -1
- package/resources/beta/pay/products/variants.d.mts +206 -0
- package/resources/beta/pay/products/variants.d.mts.map +1 -0
- package/resources/beta/pay/products/variants.d.ts +206 -0
- package/resources/beta/pay/products/variants.d.ts.map +1 -0
- package/resources/beta/pay/products/variants.js +56 -0
- package/resources/beta/pay/products/variants.js.map +1 -0
- package/resources/beta/pay/products/variants.mjs +52 -0
- package/resources/beta/pay/products/variants.mjs.map +1 -0
- package/resources/beta/push-notifications/index.d.mts +3 -0
- package/resources/beta/push-notifications/index.d.mts.map +1 -0
- package/resources/beta/push-notifications/index.d.ts +3 -0
- package/resources/beta/push-notifications/index.d.ts.map +1 -0
- package/resources/beta/push-notifications/index.js +9 -0
- package/resources/beta/push-notifications/index.js.map +1 -0
- package/resources/beta/push-notifications/index.mjs +4 -0
- package/resources/beta/push-notifications/index.mjs.map +1 -0
- package/resources/beta/push-notifications/push-notifications.d.mts +78 -0
- package/resources/beta/push-notifications/push-notifications.d.mts.map +1 -0
- package/resources/beta/push-notifications/push-notifications.d.ts +78 -0
- package/resources/beta/push-notifications/push-notifications.d.ts.map +1 -0
- package/resources/beta/push-notifications/push-notifications.js +32 -0
- package/resources/beta/push-notifications/push-notifications.js.map +1 -0
- package/resources/beta/push-notifications/push-notifications.mjs +27 -0
- package/resources/beta/push-notifications/push-notifications.mjs.map +1 -0
- package/resources/beta/push-notifications/subscriptions.d.mts +74 -0
- package/resources/beta/push-notifications/subscriptions.d.mts.map +1 -0
- package/resources/beta/push-notifications/subscriptions.d.ts +74 -0
- package/resources/beta/push-notifications/subscriptions.d.ts.map +1 -0
- package/resources/beta/push-notifications/subscriptions.js +23 -0
- package/resources/beta/push-notifications/subscriptions.js.map +1 -0
- package/resources/beta/push-notifications/subscriptions.mjs +19 -0
- package/resources/beta/push-notifications/subscriptions.mjs.map +1 -0
- package/resources/beta/push-notifications.d.mts +2 -0
- package/resources/beta/push-notifications.d.mts.map +1 -0
- package/resources/beta/push-notifications.d.ts +2 -0
- package/resources/beta/push-notifications.d.ts.map +1 -0
- package/resources/beta/push-notifications.js +6 -0
- package/resources/beta/push-notifications.js.map +1 -0
- package/resources/beta/push-notifications.mjs +3 -0
- package/resources/beta/push-notifications.mjs.map +1 -0
- package/src/resources/beta/beta.ts +18 -0
- package/src/resources/beta/index.ts +6 -0
- package/src/resources/beta/pay/coupons.ts +1 -1
- package/src/resources/beta/pay/customers.ts +1 -1
- package/src/resources/beta/pay/entitlements.ts +4 -26
- package/src/resources/beta/pay/pay.ts +87 -17
- package/src/resources/beta/pay/products/entitlements.ts +1 -1
- package/src/resources/beta/pay/products/index.ts +10 -0
- package/src/resources/beta/pay/products/products.ts +70 -14
- package/src/resources/beta/pay/products/variants.ts +279 -0
- package/src/resources/beta/push-notifications/index.ts +14 -0
- package/src/resources/beta/push-notifications/push-notifications.ts +112 -0
- package/src/resources/beta/push-notifications/subscriptions.ts +96 -0
- package/src/resources/beta/push-notifications.ts +3 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -108,34 +108,76 @@ export interface PayCancelResponse {
|
|
|
108
108
|
*/
|
|
109
109
|
export interface PayCheckResponse {
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
112
|
-
*/
|
|
113
|
-
has_entitlement: boolean;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* The entitlement key that was checked
|
|
111
|
+
* The entitlement ID that was checked
|
|
117
112
|
*/
|
|
118
|
-
|
|
113
|
+
entitlement_id: string;
|
|
119
114
|
|
|
120
115
|
/**
|
|
121
|
-
*
|
|
116
|
+
* Whether the customer has the entitlement
|
|
122
117
|
*/
|
|
123
|
-
|
|
118
|
+
has_entitlement: boolean;
|
|
124
119
|
}
|
|
125
120
|
|
|
126
121
|
/**
|
|
127
|
-
* Checkout
|
|
122
|
+
* Checkout response. For new customers, returns a checkout URL. For existing
|
|
123
|
+
* subscribers, returns the updated subscription.
|
|
128
124
|
*/
|
|
129
125
|
export interface PayCheckoutResponse {
|
|
130
126
|
/**
|
|
131
|
-
* The checkout session ID
|
|
127
|
+
* The checkout session ID (for checkout action) or subscription ID (for update
|
|
128
|
+
* action)
|
|
132
129
|
*/
|
|
133
130
|
id: string;
|
|
134
131
|
|
|
135
132
|
/**
|
|
136
|
-
* The checkout
|
|
133
|
+
* The action taken: 'checkout' for new subscriptions (redirect to URL), 'update'
|
|
134
|
+
* for subscription changes (already applied)
|
|
135
|
+
*/
|
|
136
|
+
action: 'checkout' | 'update';
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The checkout mode: subscription for recurring prices, payment for one-time
|
|
140
|
+
* prices. Only present for 'checkout' action.
|
|
141
|
+
*/
|
|
142
|
+
mode?: 'subscription' | 'payment' | null;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The updated subscription details. Only present for 'update' action.
|
|
146
|
+
*/
|
|
147
|
+
subscription?: PayCheckoutResponse.Subscription | null;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The checkout URL to redirect the customer to. Only present for 'checkout'
|
|
151
|
+
* action.
|
|
152
|
+
*/
|
|
153
|
+
url?: string | null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export namespace PayCheckoutResponse {
|
|
157
|
+
/**
|
|
158
|
+
* The updated subscription details. Only present for 'update' action.
|
|
137
159
|
*/
|
|
138
|
-
|
|
160
|
+
export interface Subscription {
|
|
161
|
+
/**
|
|
162
|
+
* The subscription ID
|
|
163
|
+
*/
|
|
164
|
+
id: string;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The product ID
|
|
168
|
+
*/
|
|
169
|
+
product_id: string;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The subscription status
|
|
173
|
+
*/
|
|
174
|
+
status: string;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* The variant ID if applicable
|
|
178
|
+
*/
|
|
179
|
+
variant_id?: string | null;
|
|
180
|
+
}
|
|
139
181
|
}
|
|
140
182
|
|
|
141
183
|
export interface PayCancelParams {
|
|
@@ -163,9 +205,9 @@ export interface PayCheckParams {
|
|
|
163
205
|
customer_id: string;
|
|
164
206
|
|
|
165
207
|
/**
|
|
166
|
-
* The entitlement
|
|
208
|
+
* The entitlement ID to check for access
|
|
167
209
|
*/
|
|
168
|
-
|
|
210
|
+
entitlement_id: string;
|
|
169
211
|
}
|
|
170
212
|
|
|
171
213
|
export interface PayCheckoutParams {
|
|
@@ -175,15 +217,23 @@ export interface PayCheckoutParams {
|
|
|
175
217
|
customer_id: string;
|
|
176
218
|
|
|
177
219
|
/**
|
|
178
|
-
* The product ID to
|
|
220
|
+
* The product ID to purchase
|
|
179
221
|
*/
|
|
180
222
|
product_id: string;
|
|
181
223
|
|
|
182
224
|
/**
|
|
183
|
-
* Optional custom ID for the subscription. If not provided, one will be
|
|
225
|
+
* Optional custom ID for the subscription or payment. If not provided, one will be
|
|
226
|
+
* generated.
|
|
184
227
|
*/
|
|
185
228
|
id?: string;
|
|
186
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Override billing cycle anchor behavior for subscription updates. 'now' resets to
|
|
232
|
+
* current time, 'unchanged' keeps original anchor. If not provided, uses the
|
|
233
|
+
* price's configured default.
|
|
234
|
+
*/
|
|
235
|
+
billing_cycle_anchor?: 'now' | 'unchanged';
|
|
236
|
+
|
|
187
237
|
/**
|
|
188
238
|
* URL to redirect on cancel
|
|
189
239
|
*/
|
|
@@ -194,10 +244,30 @@ export interface PayCheckoutParams {
|
|
|
194
244
|
*/
|
|
195
245
|
promotion_code?: string;
|
|
196
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Override proration behavior for subscription updates. 'default' creates
|
|
249
|
+
* prorations, 'none' disables them. If not provided, uses the price's configured
|
|
250
|
+
* default.
|
|
251
|
+
*/
|
|
252
|
+
proration_behavior?: 'default' | 'none';
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Override proration date calculation for subscription updates. 'now' uses current
|
|
256
|
+
* time, 'start_of_period' uses billing period start. If not provided, uses the
|
|
257
|
+
* price's configured default.
|
|
258
|
+
*/
|
|
259
|
+
proration_date?: 'now' | 'start_of_period';
|
|
260
|
+
|
|
197
261
|
/**
|
|
198
262
|
* URL to redirect on success
|
|
199
263
|
*/
|
|
200
264
|
success_url?: string;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Optional variant ID to specify a particular pricing tier. If not provided, the
|
|
268
|
+
* product's default price is used.
|
|
269
|
+
*/
|
|
270
|
+
variant_id?: string;
|
|
201
271
|
}
|
|
202
272
|
|
|
203
273
|
Pay.Customers = Customers;
|
|
@@ -16,3 +16,13 @@ export {
|
|
|
16
16
|
type ProductListParams,
|
|
17
17
|
type ProductsCursorIDPage,
|
|
18
18
|
} from './products';
|
|
19
|
+
export {
|
|
20
|
+
Variants,
|
|
21
|
+
type Variant,
|
|
22
|
+
type VariantCreateParams,
|
|
23
|
+
type VariantUpdateParams,
|
|
24
|
+
type VariantListParams,
|
|
25
|
+
type VariantArchiveParams,
|
|
26
|
+
type VariantGetParams,
|
|
27
|
+
type VariantsCursorIDPage,
|
|
28
|
+
} from './variants';
|
|
@@ -10,6 +10,17 @@ import {
|
|
|
10
10
|
ProductEntitlement,
|
|
11
11
|
ProductEntitlementsCursorIDPage,
|
|
12
12
|
} from './entitlements';
|
|
13
|
+
import * as VariantsAPI from './variants';
|
|
14
|
+
import {
|
|
15
|
+
Variant,
|
|
16
|
+
VariantArchiveParams,
|
|
17
|
+
VariantCreateParams,
|
|
18
|
+
VariantGetParams,
|
|
19
|
+
VariantListParams,
|
|
20
|
+
VariantUpdateParams,
|
|
21
|
+
Variants,
|
|
22
|
+
VariantsCursorIDPage,
|
|
23
|
+
} from './variants';
|
|
13
24
|
import { APIPromise } from '../../../../core/api-promise';
|
|
14
25
|
import { CursorIDPage, type CursorIDPageParams, PagePromise } from '../../../../core/pagination';
|
|
15
26
|
import { RequestOptions } from '../../../../internal/request-options';
|
|
@@ -17,6 +28,7 @@ import { path } from '../../../../internal/utils/path';
|
|
|
17
28
|
|
|
18
29
|
export class Products extends APIResource {
|
|
19
30
|
entitlements: EntitlementsAPI.Entitlements = new EntitlementsAPI.Entitlements(this._client);
|
|
31
|
+
variants: VariantsAPI.Variants = new VariantsAPI.Variants(this._client);
|
|
20
32
|
|
|
21
33
|
/**
|
|
22
34
|
* Creates a new subscription product with a recurring price. Common examples
|
|
@@ -72,18 +84,18 @@ export class Products extends APIResource {
|
|
|
72
84
|
export type ProductsCursorIDPage = CursorIDPage<Product>;
|
|
73
85
|
|
|
74
86
|
/**
|
|
75
|
-
* A
|
|
76
|
-
*
|
|
77
|
-
*
|
|
87
|
+
* A product that customers can purchase. Products can be one-time purchases or
|
|
88
|
+
* recurring subscriptions. Attach entitlements to a product to grant features to
|
|
89
|
+
* customers.
|
|
78
90
|
*/
|
|
79
91
|
export interface Product {
|
|
80
92
|
/**
|
|
81
|
-
* Unique identifier for the
|
|
93
|
+
* Unique identifier for the price
|
|
82
94
|
*/
|
|
83
95
|
id: string;
|
|
84
96
|
|
|
85
97
|
/**
|
|
86
|
-
* Whether the product is available for new
|
|
98
|
+
* Whether the product is available for new purchases
|
|
87
99
|
*/
|
|
88
100
|
active: boolean;
|
|
89
101
|
|
|
@@ -98,7 +110,7 @@ export interface Product {
|
|
|
98
110
|
name: string;
|
|
99
111
|
|
|
100
112
|
/**
|
|
101
|
-
*
|
|
113
|
+
* Price configuration for a product. Can be one-time or recurring (subscription).
|
|
102
114
|
*/
|
|
103
115
|
default_price?: Product.DefaultPrice | null;
|
|
104
116
|
|
|
@@ -110,28 +122,53 @@ export interface Product {
|
|
|
110
122
|
|
|
111
123
|
export namespace Product {
|
|
112
124
|
/**
|
|
113
|
-
*
|
|
125
|
+
* Price configuration for a product. Can be one-time or recurring (subscription).
|
|
114
126
|
*/
|
|
115
127
|
export interface DefaultPrice {
|
|
116
128
|
/**
|
|
117
|
-
* Unique identifier for the
|
|
129
|
+
* Unique identifier for the price
|
|
118
130
|
*/
|
|
119
131
|
id: string;
|
|
120
132
|
|
|
133
|
+
/**
|
|
134
|
+
* How to handle the billing cycle when switching plans. 'now' resets to current
|
|
135
|
+
* time, 'unchanged' keeps the original anchor. Null for one-time prices.
|
|
136
|
+
*/
|
|
137
|
+
billing_cycle_anchor: 'now' | 'unchanged' | null;
|
|
138
|
+
|
|
121
139
|
/**
|
|
122
140
|
* Three-letter ISO currency code (e.g., usd, eur)
|
|
123
141
|
*/
|
|
124
142
|
currency: string;
|
|
125
143
|
|
|
126
144
|
/**
|
|
127
|
-
* Billing frequency: day, week, month, or year
|
|
145
|
+
* Billing frequency for recurring prices: day, week, month, or year. Null for
|
|
146
|
+
* one-time prices.
|
|
147
|
+
*/
|
|
148
|
+
interval: 'day' | 'week' | 'month' | 'year' | null;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Number of intervals between billings for recurring prices. Null for one-time
|
|
152
|
+
* prices.
|
|
153
|
+
*/
|
|
154
|
+
interval_count: number | null;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* How to handle prorations when switching plans. 'default' creates prorations,
|
|
158
|
+
* 'none' disables them. Null for one-time prices.
|
|
128
159
|
*/
|
|
129
|
-
|
|
160
|
+
proration_behavior: 'default' | 'none' | null;
|
|
130
161
|
|
|
131
162
|
/**
|
|
132
|
-
*
|
|
163
|
+
* When to calculate proration. 'now' uses current time, 'start_of_period' uses the
|
|
164
|
+
* billing period start. Null for one-time prices or to use Stripe's default.
|
|
133
165
|
*/
|
|
134
|
-
|
|
166
|
+
proration_date: 'now' | 'start_of_period' | null;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Price type: one_time for single purchases, recurring for subscriptions
|
|
170
|
+
*/
|
|
171
|
+
type: 'one_time' | 'recurring';
|
|
135
172
|
|
|
136
173
|
/**
|
|
137
174
|
* Price amount in the smallest currency unit (e.g., cents)
|
|
@@ -168,14 +205,21 @@ export interface ProductCreateParams {
|
|
|
168
205
|
description?: string;
|
|
169
206
|
|
|
170
207
|
/**
|
|
171
|
-
* Billing frequency: day, week, month, or year
|
|
208
|
+
* Billing frequency for recurring prices: day, week, month, or year. Required for
|
|
209
|
+
* recurring type, ignored for one_time.
|
|
172
210
|
*/
|
|
173
211
|
interval?: 'day' | 'week' | 'month' | 'year';
|
|
174
212
|
|
|
175
213
|
/**
|
|
176
|
-
* Number of intervals between billings
|
|
214
|
+
* Number of intervals between billings for recurring prices. Required for
|
|
215
|
+
* recurring type, ignored for one_time.
|
|
177
216
|
*/
|
|
178
217
|
interval_count?: number;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Price type: one_time for single purchases, recurring for subscriptions
|
|
221
|
+
*/
|
|
222
|
+
type?: 'one_time' | 'recurring';
|
|
179
223
|
}
|
|
180
224
|
|
|
181
225
|
export interface ProductUpdateParams {
|
|
@@ -203,6 +247,7 @@ export interface ProductListParams extends CursorIDPageParams {
|
|
|
203
247
|
}
|
|
204
248
|
|
|
205
249
|
Products.Entitlements = Entitlements;
|
|
250
|
+
Products.Variants = Variants;
|
|
206
251
|
|
|
207
252
|
export declare namespace Products {
|
|
208
253
|
export {
|
|
@@ -221,4 +266,15 @@ export declare namespace Products {
|
|
|
221
266
|
type EntitlementAttachParams as EntitlementAttachParams,
|
|
222
267
|
type EntitlementRemoveParams as EntitlementRemoveParams,
|
|
223
268
|
};
|
|
269
|
+
|
|
270
|
+
export {
|
|
271
|
+
Variants as Variants,
|
|
272
|
+
type Variant as Variant,
|
|
273
|
+
type VariantsCursorIDPage as VariantsCursorIDPage,
|
|
274
|
+
type VariantCreateParams as VariantCreateParams,
|
|
275
|
+
type VariantUpdateParams as VariantUpdateParams,
|
|
276
|
+
type VariantListParams as VariantListParams,
|
|
277
|
+
type VariantArchiveParams as VariantArchiveParams,
|
|
278
|
+
type VariantGetParams as VariantGetParams,
|
|
279
|
+
};
|
|
224
280
|
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../../../core/resource';
|
|
4
|
+
import { APIPromise } from '../../../../core/api-promise';
|
|
5
|
+
import { CursorIDPage, type CursorIDPageParams, PagePromise } from '../../../../core/pagination';
|
|
6
|
+
import { RequestOptions } from '../../../../internal/request-options';
|
|
7
|
+
import { path } from '../../../../internal/utils/path';
|
|
8
|
+
|
|
9
|
+
export class Variants extends APIResource {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new variant with pricing for a product. Use variants to offer multiple
|
|
12
|
+
* pricing tiers or configurations (e.g., Basic at $10/month, Pro at $25/month). A
|
|
13
|
+
* Stripe Price is automatically created.
|
|
14
|
+
*/
|
|
15
|
+
create(productID: string, body: VariantCreateParams, options?: RequestOptions): APIPromise<Variant> {
|
|
16
|
+
return this._client.post(path`/v1/pay/products/${productID}/variants`, { body, ...options });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Updates an existing variant. Use this to modify the name, description, or active
|
|
21
|
+
* status. Pricing cannot be changed after creation—create a new variant instead.
|
|
22
|
+
*/
|
|
23
|
+
update(variantID: string, params: VariantUpdateParams, options?: RequestOptions): APIPromise<Variant> {
|
|
24
|
+
const { product_id, ...body } = params;
|
|
25
|
+
return this._client.patch(path`/v1/pay/products/${product_id}/variants/${variantID}`, {
|
|
26
|
+
body,
|
|
27
|
+
...options,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves all variants for a product. Variants represent different pricing tiers
|
|
33
|
+
* or configurations (e.g., Basic, Pro, Enterprise) within a single product.
|
|
34
|
+
*/
|
|
35
|
+
list(
|
|
36
|
+
productID: string,
|
|
37
|
+
query: VariantListParams | null | undefined = {},
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): PagePromise<VariantsCursorIDPage, Variant> {
|
|
40
|
+
return this._client.getAPIList(path`/v1/pay/products/${productID}/variants`, CursorIDPage<Variant>, {
|
|
41
|
+
query,
|
|
42
|
+
...options,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Archives a variant, preventing new subscriptions. The associated Stripe Price is
|
|
48
|
+
* also archived. Existing subscriptions remain active.
|
|
49
|
+
*/
|
|
50
|
+
archive(variantID: string, params: VariantArchiveParams, options?: RequestOptions): APIPromise<Variant> {
|
|
51
|
+
const { product_id } = params;
|
|
52
|
+
return this._client.delete(path`/v1/pay/products/${product_id}/variants/${variantID}`, options);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves a variant by ID. Returns the variant object including pricing details
|
|
57
|
+
* and status.
|
|
58
|
+
*/
|
|
59
|
+
get(variantID: string, params: VariantGetParams, options?: RequestOptions): APIPromise<Variant> {
|
|
60
|
+
const { product_id } = params;
|
|
61
|
+
return this._client.get(path`/v1/pay/products/${product_id}/variants/${variantID}`, options);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type VariantsCursorIDPage = CursorIDPage<Variant>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A product variant representing a specific tier or configuration. Each variant
|
|
69
|
+
* has its own pricing. Variants allow a single product to have multiple pricing
|
|
70
|
+
* options (e.g., Basic, Pro, Enterprise tiers).
|
|
71
|
+
*/
|
|
72
|
+
export interface Variant {
|
|
73
|
+
/**
|
|
74
|
+
* Unique identifier for the price
|
|
75
|
+
*/
|
|
76
|
+
id: string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Whether the variant is available for new purchases
|
|
80
|
+
*/
|
|
81
|
+
active: boolean;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Timestamp when the variant was created
|
|
85
|
+
*/
|
|
86
|
+
created: string;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Display name for the variant (e.g., Basic, Standard, Premium)
|
|
90
|
+
*/
|
|
91
|
+
name: string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Price configuration for a product. Can be one-time or recurring (subscription).
|
|
95
|
+
*/
|
|
96
|
+
default_price?: Variant.DefaultPrice | null;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Detailed description of what this variant includes
|
|
100
|
+
*/
|
|
101
|
+
description?: string | null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export namespace Variant {
|
|
105
|
+
/**
|
|
106
|
+
* Price configuration for a product. Can be one-time or recurring (subscription).
|
|
107
|
+
*/
|
|
108
|
+
export interface DefaultPrice {
|
|
109
|
+
/**
|
|
110
|
+
* Unique identifier for the price
|
|
111
|
+
*/
|
|
112
|
+
id: string;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* How to handle the billing cycle when switching plans. 'now' resets to current
|
|
116
|
+
* time, 'unchanged' keeps the original anchor. Null for one-time prices.
|
|
117
|
+
*/
|
|
118
|
+
billing_cycle_anchor: 'now' | 'unchanged' | null;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Three-letter ISO currency code (e.g., usd, eur)
|
|
122
|
+
*/
|
|
123
|
+
currency: string;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Billing frequency for recurring prices: day, week, month, or year. Null for
|
|
127
|
+
* one-time prices.
|
|
128
|
+
*/
|
|
129
|
+
interval: 'day' | 'week' | 'month' | 'year' | null;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Number of intervals between billings for recurring prices. Null for one-time
|
|
133
|
+
* prices.
|
|
134
|
+
*/
|
|
135
|
+
interval_count: number | null;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* How to handle prorations when switching plans. 'default' creates prorations,
|
|
139
|
+
* 'none' disables them. Null for one-time prices.
|
|
140
|
+
*/
|
|
141
|
+
proration_behavior: 'default' | 'none' | null;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* When to calculate proration. 'now' uses current time, 'start_of_period' uses the
|
|
145
|
+
* billing period start. Null for one-time prices or to use Stripe's default.
|
|
146
|
+
*/
|
|
147
|
+
proration_date: 'now' | 'start_of_period' | null;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Price type: one_time for single purchases, recurring for subscriptions
|
|
151
|
+
*/
|
|
152
|
+
type: 'one_time' | 'recurring';
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Price amount in the smallest currency unit (e.g., cents)
|
|
156
|
+
*/
|
|
157
|
+
unit_amount: number | null;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface VariantCreateParams {
|
|
162
|
+
/**
|
|
163
|
+
* Display name for the variant (e.g., Basic, Standard, Premium)
|
|
164
|
+
*/
|
|
165
|
+
name: string;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Price amount in the smallest currency unit (e.g., cents). Use 0 for free
|
|
169
|
+
* variants.
|
|
170
|
+
*/
|
|
171
|
+
unit_amount: number;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Optional custom ID for the variant. If not provided, one will be generated.
|
|
175
|
+
*/
|
|
176
|
+
id?: string;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Default billing cycle anchor behavior when switching to this price. 'now' resets
|
|
180
|
+
* to current time, 'unchanged' keeps original anchor. Only applies to recurring
|
|
181
|
+
* prices.
|
|
182
|
+
*/
|
|
183
|
+
billing_cycle_anchor?: 'now' | 'unchanged';
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Three-letter ISO currency code
|
|
187
|
+
*/
|
|
188
|
+
currency?: string;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Detailed description of what this variant includes
|
|
192
|
+
*/
|
|
193
|
+
description?: string;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Billing frequency for recurring prices: day, week, month, or year. Required for
|
|
197
|
+
* recurring type, ignored for one_time.
|
|
198
|
+
*/
|
|
199
|
+
interval?: 'day' | 'week' | 'month' | 'year';
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Number of intervals between billings for recurring prices. Required for
|
|
203
|
+
* recurring type, ignored for one_time.
|
|
204
|
+
*/
|
|
205
|
+
interval_count?: number;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Default proration behavior when switching to this price. 'default' creates
|
|
209
|
+
* prorations, 'none' disables them. Only applies to recurring prices.
|
|
210
|
+
*/
|
|
211
|
+
proration_behavior?: 'default' | 'none';
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Default proration date calculation when switching to this price. 'now' uses
|
|
215
|
+
* current time, 'start_of_period' uses billing period start. Only applies to
|
|
216
|
+
* recurring prices.
|
|
217
|
+
*/
|
|
218
|
+
proration_date?: 'now' | 'start_of_period';
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Price type: one_time for single purchases, recurring for subscriptions
|
|
222
|
+
*/
|
|
223
|
+
type?: 'one_time' | 'recurring';
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface VariantUpdateParams {
|
|
227
|
+
/**
|
|
228
|
+
* Path param: The unique identifier of the product
|
|
229
|
+
*/
|
|
230
|
+
product_id: string;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Body param: Whether the variant is available for new purchases
|
|
234
|
+
*/
|
|
235
|
+
active?: boolean;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Body param: Detailed description of what this variant includes
|
|
239
|
+
*/
|
|
240
|
+
description?: string;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Body param: Display name for the variant
|
|
244
|
+
*/
|
|
245
|
+
name?: string;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface VariantListParams extends CursorIDPageParams {
|
|
249
|
+
/**
|
|
250
|
+
* Filter by active status
|
|
251
|
+
*/
|
|
252
|
+
active?: 'true' | 'false';
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface VariantArchiveParams {
|
|
256
|
+
/**
|
|
257
|
+
* The unique identifier of the product
|
|
258
|
+
*/
|
|
259
|
+
product_id: string;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface VariantGetParams {
|
|
263
|
+
/**
|
|
264
|
+
* The unique identifier of the product
|
|
265
|
+
*/
|
|
266
|
+
product_id: string;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export declare namespace Variants {
|
|
270
|
+
export {
|
|
271
|
+
type Variant as Variant,
|
|
272
|
+
type VariantsCursorIDPage as VariantsCursorIDPage,
|
|
273
|
+
type VariantCreateParams as VariantCreateParams,
|
|
274
|
+
type VariantUpdateParams as VariantUpdateParams,
|
|
275
|
+
type VariantListParams as VariantListParams,
|
|
276
|
+
type VariantArchiveParams as VariantArchiveParams,
|
|
277
|
+
type VariantGetParams as VariantGetParams,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
PushNotifications,
|
|
5
|
+
type PushNotificationEnableResponse,
|
|
6
|
+
type PushNotificationSendResponse,
|
|
7
|
+
type PushNotificationSendParams,
|
|
8
|
+
} from './push-notifications';
|
|
9
|
+
export {
|
|
10
|
+
Subscriptions,
|
|
11
|
+
type SubscriptionCreateResponse,
|
|
12
|
+
type SubscriptionDeleteResponse,
|
|
13
|
+
type SubscriptionCreateParams,
|
|
14
|
+
} from './subscriptions';
|