@paid-ai/paid-node 1.0.1-alpha1 → 1.0.1-alpha2
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/dist/cjs/Client.js +2 -2
- package/dist/cjs/api/resources/plans/client/Client.d.ts +58 -0
- package/dist/cjs/api/resources/plans/client/Client.js +220 -0
- package/dist/cjs/api/resources/plans/client/requests/PlansSubscribeRequest.d.ts +13 -0
- package/dist/cjs/api/resources/plans/client/requests/PlansSubscribeRequest.js +3 -0
- package/dist/cjs/api/resources/plans/client/requests/PlansUnsubscribeRequest.d.ts +10 -0
- package/dist/cjs/api/resources/plans/client/requests/PlansUnsubscribeRequest.js +3 -0
- package/dist/cjs/api/resources/plans/client/requests/PlansUpgradeRequest.d.ts +16 -0
- package/dist/cjs/api/resources/plans/client/requests/PlansUpgradeRequest.js +3 -0
- package/dist/cjs/api/resources/plans/client/requests/index.d.ts +3 -0
- package/dist/cjs/api/types/Plan.d.ts +33 -0
- package/dist/cjs/api/types/Plan.js +19 -0
- package/dist/cjs/api/types/PlanWithFeatures.d.ts +33 -0
- package/dist/cjs/api/types/PlanWithFeatures.js +19 -0
- package/dist/cjs/integrations/adapters/nextjs/index.d.ts +1 -1
- package/dist/cjs/integrations/adapters/nextjs/index.js +5 -1
- package/dist/cjs/integrations/adapters/nextjs/routes.d.ts +60 -0
- package/dist/cjs/integrations/adapters/nextjs/routes.js +80 -0
- package/dist/cjs/integrations/controllers/index.d.ts +1 -1
- package/dist/cjs/integrations/controllers/index.js +11 -1
- package/dist/cjs/integrations/controllers/plans.d.ts +158 -0
- package/dist/cjs/integrations/controllers/plans.js +277 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/api/resources/plans/client/Client.d.mts +58 -0
- package/dist/esm/api/resources/plans/client/Client.mjs +220 -0
- package/dist/esm/api/resources/plans/client/requests/PlansSubscribeRequest.d.mts +13 -0
- package/dist/esm/api/resources/plans/client/requests/PlansSubscribeRequest.mjs +2 -0
- package/dist/esm/api/resources/plans/client/requests/PlansUnsubscribeRequest.d.mts +10 -0
- package/dist/esm/api/resources/plans/client/requests/PlansUnsubscribeRequest.mjs +2 -0
- package/dist/esm/api/resources/plans/client/requests/PlansUpgradeRequest.d.mts +16 -0
- package/dist/esm/api/resources/plans/client/requests/PlansUpgradeRequest.mjs +2 -0
- package/dist/esm/api/resources/plans/client/requests/index.d.mts +3 -0
- package/dist/esm/api/types/Plan.d.mts +33 -0
- package/dist/esm/api/types/Plan.mjs +18 -1
- package/dist/esm/api/types/PlanWithFeatures.d.mts +33 -0
- package/dist/esm/api/types/PlanWithFeatures.mjs +18 -1
- package/dist/esm/integrations/adapters/nextjs/index.d.mts +1 -1
- package/dist/esm/integrations/adapters/nextjs/index.mjs +1 -1
- package/dist/esm/integrations/adapters/nextjs/routes.d.mts +60 -0
- package/dist/esm/integrations/adapters/nextjs/routes.mjs +77 -1
- package/dist/esm/integrations/controllers/index.d.mts +1 -1
- package/dist/esm/integrations/controllers/index.mjs +1 -1
- package/dist/esm/integrations/controllers/plans.d.mts +158 -0
- package/dist/esm/integrations/controllers/plans.mjs +269 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +228 -0
|
@@ -162,6 +162,224 @@ export class Plans {
|
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Creates a new order for a customer subscribing to a plan. The order will be created with the plan's products and pricing attributes.
|
|
167
|
+
*
|
|
168
|
+
* @param {string} planId - The ID of the plan
|
|
169
|
+
* @param {Paid.PlansSubscribeRequest} request
|
|
170
|
+
* @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
|
|
171
|
+
*
|
|
172
|
+
* @throws {@link Paid.BadRequestError}
|
|
173
|
+
* @throws {@link Paid.ForbiddenError}
|
|
174
|
+
* @throws {@link Paid.NotFoundError}
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* await client.plans.subscribe("planId", {
|
|
178
|
+
* customerExternalId: "customerExternalId",
|
|
179
|
+
* currency: "currency"
|
|
180
|
+
* })
|
|
181
|
+
*/
|
|
182
|
+
subscribe(planId, request, requestOptions) {
|
|
183
|
+
return core.HttpResponsePromise.fromPromise(this.__subscribe(planId, request, requestOptions));
|
|
184
|
+
}
|
|
185
|
+
__subscribe(planId, request, requestOptions) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
188
|
+
const { customerExternalId, currency } = request;
|
|
189
|
+
const _queryParams = {};
|
|
190
|
+
_queryParams.customerExternalId = customerExternalId;
|
|
191
|
+
_queryParams.currency = currency;
|
|
192
|
+
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
193
|
+
const _response = yield core.fetcher({
|
|
194
|
+
url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, `plans/${core.url.encodePathParam(planId)}/subscribe`),
|
|
195
|
+
method: "POST",
|
|
196
|
+
headers: _headers,
|
|
197
|
+
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
198
|
+
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
199
|
+
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
200
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
201
|
+
});
|
|
202
|
+
if (_response.ok) {
|
|
203
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
204
|
+
}
|
|
205
|
+
if (_response.error.reason === "status-code") {
|
|
206
|
+
switch (_response.error.statusCode) {
|
|
207
|
+
case 400:
|
|
208
|
+
throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
|
|
209
|
+
case 403:
|
|
210
|
+
throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
211
|
+
case 404:
|
|
212
|
+
throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
|
|
213
|
+
default:
|
|
214
|
+
throw new errors.PaidError({
|
|
215
|
+
statusCode: _response.error.statusCode,
|
|
216
|
+
body: _response.error.body,
|
|
217
|
+
rawResponse: _response.rawResponse,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
switch (_response.error.reason) {
|
|
222
|
+
case "non-json":
|
|
223
|
+
throw new errors.PaidError({
|
|
224
|
+
statusCode: _response.error.statusCode,
|
|
225
|
+
body: _response.error.rawBody,
|
|
226
|
+
rawResponse: _response.rawResponse,
|
|
227
|
+
});
|
|
228
|
+
case "timeout":
|
|
229
|
+
throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /plans/{planId}/subscribe.");
|
|
230
|
+
case "unknown":
|
|
231
|
+
throw new errors.PaidError({
|
|
232
|
+
message: _response.error.errorMessage,
|
|
233
|
+
rawResponse: _response.rawResponse,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Cancels the renewal of an active order for a customer's plan subscription. The order will remain active until the cancellation date.
|
|
240
|
+
*
|
|
241
|
+
* @param {string} planId - The ID of the plan
|
|
242
|
+
* @param {Paid.PlansUnsubscribeRequest} request
|
|
243
|
+
* @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
|
|
244
|
+
*
|
|
245
|
+
* @throws {@link Paid.BadRequestError}
|
|
246
|
+
* @throws {@link Paid.ForbiddenError}
|
|
247
|
+
* @throws {@link Paid.NotFoundError}
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* await client.plans.unsubscribe("planId", {
|
|
251
|
+
* customerExternalId: "customerExternalId"
|
|
252
|
+
* })
|
|
253
|
+
*/
|
|
254
|
+
unsubscribe(planId, request, requestOptions) {
|
|
255
|
+
return core.HttpResponsePromise.fromPromise(this.__unsubscribe(planId, request, requestOptions));
|
|
256
|
+
}
|
|
257
|
+
__unsubscribe(planId, request, requestOptions) {
|
|
258
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
259
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
260
|
+
const { customerExternalId } = request;
|
|
261
|
+
const _queryParams = {};
|
|
262
|
+
_queryParams.customerExternalId = customerExternalId;
|
|
263
|
+
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
264
|
+
const _response = yield core.fetcher({
|
|
265
|
+
url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, `plans/${core.url.encodePathParam(planId)}/unsubscribe`),
|
|
266
|
+
method: "POST",
|
|
267
|
+
headers: _headers,
|
|
268
|
+
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
269
|
+
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
270
|
+
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
271
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
272
|
+
});
|
|
273
|
+
if (_response.ok) {
|
|
274
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
275
|
+
}
|
|
276
|
+
if (_response.error.reason === "status-code") {
|
|
277
|
+
switch (_response.error.statusCode) {
|
|
278
|
+
case 400:
|
|
279
|
+
throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
|
|
280
|
+
case 403:
|
|
281
|
+
throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
282
|
+
case 404:
|
|
283
|
+
throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
|
|
284
|
+
default:
|
|
285
|
+
throw new errors.PaidError({
|
|
286
|
+
statusCode: _response.error.statusCode,
|
|
287
|
+
body: _response.error.body,
|
|
288
|
+
rawResponse: _response.rawResponse,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
switch (_response.error.reason) {
|
|
293
|
+
case "non-json":
|
|
294
|
+
throw new errors.PaidError({
|
|
295
|
+
statusCode: _response.error.statusCode,
|
|
296
|
+
body: _response.error.rawBody,
|
|
297
|
+
rawResponse: _response.rawResponse,
|
|
298
|
+
});
|
|
299
|
+
case "timeout":
|
|
300
|
+
throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /plans/{planId}/unsubscribe.");
|
|
301
|
+
case "unknown":
|
|
302
|
+
throw new errors.PaidError({
|
|
303
|
+
message: _response.error.errorMessage,
|
|
304
|
+
rawResponse: _response.rawResponse,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Upgrades a customer from one plan to another with automatic proration. Credits are applied for the unused portion of the current billing period, and the order is updated with the new plan's pricing.
|
|
311
|
+
*
|
|
312
|
+
* @param {Paid.PlansUpgradeRequest} request
|
|
313
|
+
* @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
|
|
314
|
+
*
|
|
315
|
+
* @throws {@link Paid.BadRequestError}
|
|
316
|
+
* @throws {@link Paid.ForbiddenError}
|
|
317
|
+
* @throws {@link Paid.NotFoundError}
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* await client.plans.upgrade({
|
|
321
|
+
* customerExternalId: "customerExternalId",
|
|
322
|
+
* oldPlanId: "oldPlanId",
|
|
323
|
+
* newPlanId: "newPlanId"
|
|
324
|
+
* })
|
|
325
|
+
*/
|
|
326
|
+
upgrade(request, requestOptions) {
|
|
327
|
+
return core.HttpResponsePromise.fromPromise(this.__upgrade(request, requestOptions));
|
|
328
|
+
}
|
|
329
|
+
__upgrade(request, requestOptions) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
332
|
+
const { customerExternalId, oldPlanId, newPlanId } = request;
|
|
333
|
+
const _queryParams = {};
|
|
334
|
+
_queryParams.customerExternalId = customerExternalId;
|
|
335
|
+
_queryParams.oldPlanId = oldPlanId;
|
|
336
|
+
_queryParams.newPlanId = newPlanId;
|
|
337
|
+
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
338
|
+
const _response = yield core.fetcher({
|
|
339
|
+
url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, "plans/upgrade"),
|
|
340
|
+
method: "POST",
|
|
341
|
+
headers: _headers,
|
|
342
|
+
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
343
|
+
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
344
|
+
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
345
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
346
|
+
});
|
|
347
|
+
if (_response.ok) {
|
|
348
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
349
|
+
}
|
|
350
|
+
if (_response.error.reason === "status-code") {
|
|
351
|
+
switch (_response.error.statusCode) {
|
|
352
|
+
case 400:
|
|
353
|
+
throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
|
|
354
|
+
case 403:
|
|
355
|
+
throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
356
|
+
case 404:
|
|
357
|
+
throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
|
|
358
|
+
default:
|
|
359
|
+
throw new errors.PaidError({
|
|
360
|
+
statusCode: _response.error.statusCode,
|
|
361
|
+
body: _response.error.body,
|
|
362
|
+
rawResponse: _response.rawResponse,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
switch (_response.error.reason) {
|
|
367
|
+
case "non-json":
|
|
368
|
+
throw new errors.PaidError({
|
|
369
|
+
statusCode: _response.error.statusCode,
|
|
370
|
+
body: _response.error.rawBody,
|
|
371
|
+
rawResponse: _response.rawResponse,
|
|
372
|
+
});
|
|
373
|
+
case "timeout":
|
|
374
|
+
throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /plans/upgrade.");
|
|
375
|
+
case "unknown":
|
|
376
|
+
throw new errors.PaidError({
|
|
377
|
+
message: _response.error.errorMessage,
|
|
378
|
+
rawResponse: _response.rawResponse,
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
}
|
|
165
383
|
/**
|
|
166
384
|
* @param {string} planGroupId - The ID of the plan group
|
|
167
385
|
* @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -223,6 +441,8 @@ export class Plans {
|
|
|
223
441
|
});
|
|
224
442
|
}
|
|
225
443
|
/**
|
|
444
|
+
* Retrieves all plans in a plan group with their features (product-attribute pairs)
|
|
445
|
+
*
|
|
226
446
|
* @param {string} planGroupId - The ID of the plan group
|
|
227
447
|
* @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
|
|
228
448
|
*
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
* {
|
|
4
|
+
* customerExternalId: "customerExternalId",
|
|
5
|
+
* currency: "currency"
|
|
6
|
+
* }
|
|
7
|
+
*/
|
|
8
|
+
export interface PlansSubscribeRequest {
|
|
9
|
+
/** The external ID of the customer */
|
|
10
|
+
customerExternalId: string;
|
|
11
|
+
/** The currency code for the order (e.g., "USD", "EUR") */
|
|
12
|
+
currency: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
* {
|
|
4
|
+
* customerExternalId: "customerExternalId",
|
|
5
|
+
* oldPlanId: "oldPlanId",
|
|
6
|
+
* newPlanId: "newPlanId"
|
|
7
|
+
* }
|
|
8
|
+
*/
|
|
9
|
+
export interface PlansUpgradeRequest {
|
|
10
|
+
/** The external ID of the customer */
|
|
11
|
+
customerExternalId: string;
|
|
12
|
+
/** The ID of the current plan */
|
|
13
|
+
oldPlanId: string;
|
|
14
|
+
/** The ID of the plan to upgrade to */
|
|
15
|
+
newPlanId: string;
|
|
16
|
+
}
|
|
@@ -1 +1,4 @@
|
|
|
1
1
|
export type { PlansGetUsageRequest } from "./PlansGetUsageRequest.mjs";
|
|
2
|
+
export type { PlansSubscribeRequest } from "./PlansSubscribeRequest.mjs";
|
|
3
|
+
export type { PlansUnsubscribeRequest } from "./PlansUnsubscribeRequest.mjs";
|
|
4
|
+
export type { PlansUpgradeRequest } from "./PlansUpgradeRequest.mjs";
|
|
@@ -13,6 +13,10 @@ export interface Plan {
|
|
|
13
13
|
name: string;
|
|
14
14
|
/** The description of the plan */
|
|
15
15
|
description?: string;
|
|
16
|
+
/** The type of plan (flat for fixed pricing, usage for usage-based, credit for prepaid credits) */
|
|
17
|
+
type: Plan.Type;
|
|
18
|
+
/** The pricing configuration for the plan */
|
|
19
|
+
pricing: Plan.Pricing;
|
|
16
20
|
/** The ID of the next plan in the sequence */
|
|
17
21
|
nextPlanId?: string;
|
|
18
22
|
/** The ID of the previous plan in the sequence */
|
|
@@ -25,6 +29,35 @@ export interface Plan {
|
|
|
25
29
|
planProducts?: Plan.PlanProducts.Item[];
|
|
26
30
|
}
|
|
27
31
|
export declare namespace Plan {
|
|
32
|
+
/** The type of plan (flat for fixed pricing, usage for usage-based, credit for prepaid credits) */
|
|
33
|
+
const Type: {
|
|
34
|
+
readonly Flat: "flat";
|
|
35
|
+
readonly Usage: "usage";
|
|
36
|
+
readonly Credit: "credit";
|
|
37
|
+
};
|
|
38
|
+
type Type = (typeof Type)[keyof typeof Type];
|
|
39
|
+
/**
|
|
40
|
+
* The pricing configuration for the plan
|
|
41
|
+
*/
|
|
42
|
+
interface Pricing {
|
|
43
|
+
/** The currency code (e.g., "USD", "EUR") */
|
|
44
|
+
currency: string;
|
|
45
|
+
/** The fixed amount for flat plans (in smallest currency unit, e.g., cents) */
|
|
46
|
+
amount?: number;
|
|
47
|
+
/** The billing frequency for the plan */
|
|
48
|
+
billingFrequency: Pricing.BillingFrequency;
|
|
49
|
+
/** Custom billing frequency in months (if not using standard frequencies) */
|
|
50
|
+
billingFrequencyCustomMonths?: number;
|
|
51
|
+
}
|
|
52
|
+
namespace Pricing {
|
|
53
|
+
/** The billing frequency for the plan */
|
|
54
|
+
const BillingFrequency: {
|
|
55
|
+
readonly Monthly: "monthly";
|
|
56
|
+
readonly Quarterly: "quarterly";
|
|
57
|
+
readonly Annual: "annual";
|
|
58
|
+
};
|
|
59
|
+
type BillingFrequency = (typeof BillingFrequency)[keyof typeof BillingFrequency];
|
|
60
|
+
}
|
|
28
61
|
type PlanProducts = PlanProducts.Item[];
|
|
29
62
|
namespace PlanProducts {
|
|
30
63
|
interface Item {
|
|
@@ -1,2 +1,19 @@
|
|
|
1
1
|
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
-
export
|
|
2
|
+
export var Plan;
|
|
3
|
+
(function (Plan) {
|
|
4
|
+
/** The type of plan (flat for fixed pricing, usage for usage-based, credit for prepaid credits) */
|
|
5
|
+
Plan.Type = {
|
|
6
|
+
Flat: "flat",
|
|
7
|
+
Usage: "usage",
|
|
8
|
+
Credit: "credit",
|
|
9
|
+
};
|
|
10
|
+
let Pricing;
|
|
11
|
+
(function (Pricing) {
|
|
12
|
+
/** The billing frequency for the plan */
|
|
13
|
+
Pricing.BillingFrequency = {
|
|
14
|
+
Monthly: "monthly",
|
|
15
|
+
Quarterly: "quarterly",
|
|
16
|
+
Annual: "annual",
|
|
17
|
+
};
|
|
18
|
+
})(Pricing = Plan.Pricing || (Plan.Pricing = {}));
|
|
19
|
+
})(Plan || (Plan = {}));
|
|
@@ -8,6 +8,10 @@ export interface PlanWithFeatures {
|
|
|
8
8
|
name: string;
|
|
9
9
|
/** The description of the plan */
|
|
10
10
|
description?: string;
|
|
11
|
+
/** The type of plan (flat for fixed pricing, usage for usage-based, credit for prepaid credits) */
|
|
12
|
+
type: PlanWithFeatures.Type;
|
|
13
|
+
/** The pricing configuration for the plan */
|
|
14
|
+
pricing: PlanWithFeatures.Pricing;
|
|
11
15
|
/** When the plan was created */
|
|
12
16
|
createdAt: string;
|
|
13
17
|
/** When the plan was last updated */
|
|
@@ -20,6 +24,35 @@ export interface PlanWithFeatures {
|
|
|
20
24
|
features: PlanWithFeatures.Features.Item[];
|
|
21
25
|
}
|
|
22
26
|
export declare namespace PlanWithFeatures {
|
|
27
|
+
/** The type of plan (flat for fixed pricing, usage for usage-based, credit for prepaid credits) */
|
|
28
|
+
const Type: {
|
|
29
|
+
readonly Flat: "flat";
|
|
30
|
+
readonly Usage: "usage";
|
|
31
|
+
readonly Credit: "credit";
|
|
32
|
+
};
|
|
33
|
+
type Type = (typeof Type)[keyof typeof Type];
|
|
34
|
+
/**
|
|
35
|
+
* The pricing configuration for the plan
|
|
36
|
+
*/
|
|
37
|
+
interface Pricing {
|
|
38
|
+
/** The currency code (e.g., "USD", "EUR") */
|
|
39
|
+
currency: string;
|
|
40
|
+
/** The fixed amount for flat plans (in smallest currency unit, e.g., cents) */
|
|
41
|
+
amount?: number;
|
|
42
|
+
/** The billing frequency for the plan */
|
|
43
|
+
billingFrequency: Pricing.BillingFrequency;
|
|
44
|
+
/** Custom billing frequency in months (if not using standard frequencies) */
|
|
45
|
+
billingFrequencyCustomMonths?: number;
|
|
46
|
+
}
|
|
47
|
+
namespace Pricing {
|
|
48
|
+
/** The billing frequency for the plan */
|
|
49
|
+
const BillingFrequency: {
|
|
50
|
+
readonly Monthly: "monthly";
|
|
51
|
+
readonly Quarterly: "quarterly";
|
|
52
|
+
readonly Annual: "annual";
|
|
53
|
+
};
|
|
54
|
+
type BillingFrequency = (typeof BillingFrequency)[keyof typeof BillingFrequency];
|
|
55
|
+
}
|
|
23
56
|
type Features = Features.Item[];
|
|
24
57
|
namespace Features {
|
|
25
58
|
interface Item {
|
|
@@ -1,2 +1,19 @@
|
|
|
1
1
|
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
-
export
|
|
2
|
+
export var PlanWithFeatures;
|
|
3
|
+
(function (PlanWithFeatures) {
|
|
4
|
+
/** The type of plan (flat for fixed pricing, usage for usage-based, credit for prepaid credits) */
|
|
5
|
+
PlanWithFeatures.Type = {
|
|
6
|
+
Flat: "flat",
|
|
7
|
+
Usage: "usage",
|
|
8
|
+
Credit: "credit",
|
|
9
|
+
};
|
|
10
|
+
let Pricing;
|
|
11
|
+
(function (Pricing) {
|
|
12
|
+
/** The billing frequency for the plan */
|
|
13
|
+
Pricing.BillingFrequency = {
|
|
14
|
+
Monthly: "monthly",
|
|
15
|
+
Quarterly: "quarterly",
|
|
16
|
+
Annual: "annual",
|
|
17
|
+
};
|
|
18
|
+
})(Pricing = PlanWithFeatures.Pricing || (PlanWithFeatures.Pricing = {}));
|
|
19
|
+
})(PlanWithFeatures || (PlanWithFeatures = {}));
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Next.js API Route handlers for Paid integration
|
|
3
3
|
* Drop-in handlers for Next.js App Router
|
|
4
4
|
*/
|
|
5
|
-
export { createActivateOrderSyncRoute, createContactsRoute, createCustomerInvoicesRoute, createCustomersRoute, createGetCustomerRoute, createGetPlanGroupByIdRoute, createOrdersRoute, createPayInvoiceRoute, createProvisioningRoute, createSetupIntentRoute, type ActivateOrderSyncRouteConfig, type OrdersRouteConfig, type ProvisioningRouteConfig, type SetupIntentRouteConfig, } from "./routes.mjs";
|
|
5
|
+
export { createActivateOrderSyncRoute, createContactsRoute, createCustomerInvoicesRoute, createCustomersRoute, createGetCustomerRoute, createGetPlanGroupByIdRoute, createGetGroupPlansRoute, createOrdersRoute, createPayInvoiceRoute, createProvisioningRoute, createSetupIntentRoute, createSubscribeRoute, createUnsubscribeRoute, createUpgradeRoute, type ActivateOrderSyncRouteConfig, type OrdersRouteConfig, type ProvisioningRouteConfig, type SetupIntentRouteConfig, } from "./routes.mjs";
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Next.js API Route handlers for Paid integration
|
|
3
3
|
* Drop-in handlers for Next.js App Router
|
|
4
4
|
*/
|
|
5
|
-
export { createActivateOrderSyncRoute, createContactsRoute, createCustomerInvoicesRoute, createCustomersRoute, createGetCustomerRoute, createGetPlanGroupByIdRoute, createOrdersRoute, createPayInvoiceRoute, createProvisioningRoute, createSetupIntentRoute, } from "./routes.mjs";
|
|
5
|
+
export { createActivateOrderSyncRoute, createContactsRoute, createCustomerInvoicesRoute, createCustomersRoute, createGetCustomerRoute, createGetPlanGroupByIdRoute, createGetGroupPlansRoute, createOrdersRoute, createPayInvoiceRoute, createProvisioningRoute, createSetupIntentRoute, createSubscribeRoute, createUnsubscribeRoute, createUpgradeRoute, } from "./routes.mjs";
|
|
@@ -239,4 +239,64 @@ export declare function createSetupIntentRoute(config?: SetupIntentRouteConfig):
|
|
|
239
239
|
* ```
|
|
240
240
|
*/
|
|
241
241
|
export declare function createGetPlanGroupByIdRoute(config?: BaseHandlerConfig): (request: any, context?: any) => Promise<any>;
|
|
242
|
+
/**
|
|
243
|
+
* Create a Next.js API route handler for getting all plans in a plan group
|
|
244
|
+
*
|
|
245
|
+
* @param config - Handler configuration options
|
|
246
|
+
* @returns Next.js route handler function
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```typescript
|
|
250
|
+
* // src/app/api/plans/[planGroupId]/plans/route.ts
|
|
251
|
+
* import { createGetGroupPlansRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
252
|
+
*
|
|
253
|
+
* export const GET = createGetGroupPlansRoute();
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
export declare function createGetGroupPlansRoute(config?: BaseHandlerConfig): (request: any, context?: any) => Promise<any>;
|
|
257
|
+
/**
|
|
258
|
+
* Create a Next.js API route handler for subscribing a customer to a plan
|
|
259
|
+
*
|
|
260
|
+
* @param config - Handler configuration options
|
|
261
|
+
* @returns Next.js route handler function
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* // src/app/api/plans/[planId]/subscribe/route.ts
|
|
266
|
+
* import { createSubscribeRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
267
|
+
*
|
|
268
|
+
* export const POST = createSubscribeRoute();
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
export declare function createSubscribeRoute(config?: BaseHandlerConfig): (request: any, context?: any) => Promise<any>;
|
|
272
|
+
/**
|
|
273
|
+
* Create a Next.js API route handler for unsubscribing a customer from a plan
|
|
274
|
+
*
|
|
275
|
+
* @param config - Handler configuration options
|
|
276
|
+
* @returns Next.js route handler function
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* // src/app/api/plans/[planId]/unsubscribe/route.ts
|
|
281
|
+
* import { createUnsubscribeRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
282
|
+
*
|
|
283
|
+
* export const POST = createUnsubscribeRoute();
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
export declare function createUnsubscribeRoute(config?: BaseHandlerConfig): (request: any, context?: any) => Promise<any>;
|
|
287
|
+
/**
|
|
288
|
+
* Create a Next.js API route handler for upgrading a customer's plan
|
|
289
|
+
*
|
|
290
|
+
* @param config - Handler configuration options
|
|
291
|
+
* @returns Next.js route handler function
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```typescript
|
|
295
|
+
* // src/app/api/plans/upgrade/route.ts
|
|
296
|
+
* import { createUpgradeRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
297
|
+
*
|
|
298
|
+
* export const POST = createUpgradeRoute();
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
export declare function createUpgradeRoute(config?: BaseHandlerConfig): (request: any, context?: any) => Promise<any>;
|
|
242
302
|
export {};
|
|
@@ -5,7 +5,7 @@ import { createCustomersHandler, createGetCustomerHandler } from "../../controll
|
|
|
5
5
|
import { createOrdersHandler } from "../../controllers/orders.mjs";
|
|
6
6
|
import { createProvisioningHandler } from "../../controllers/provision-users.mjs";
|
|
7
7
|
import { createActivateOrderSyncHandler, createPayInvoiceHandler, createSetupIntentHandler } from "../../controllers/billing.mjs";
|
|
8
|
-
import { createGetPlanGroupByIdHandler } from "../../controllers/plans.mjs";
|
|
8
|
+
import { createGetPlanGroupByIdHandler, createGetGroupPlansHandler, createSubscribeHandler, createUnsubscribeHandler, createUpgradeHandler } from "../../controllers/plans.mjs";
|
|
9
9
|
/**
|
|
10
10
|
* Create a Next.js API route handler for synchronous order activation
|
|
11
11
|
*
|
|
@@ -262,3 +262,79 @@ export function createGetPlanGroupByIdRoute(config = {}) {
|
|
|
262
262
|
const adaptedHandler = nextjsAdapter(handler);
|
|
263
263
|
return (request, context) => adaptedHandler(request, context, config);
|
|
264
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* Create a Next.js API route handler for getting all plans in a plan group
|
|
267
|
+
*
|
|
268
|
+
* @param config - Handler configuration options
|
|
269
|
+
* @returns Next.js route handler function
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```typescript
|
|
273
|
+
* // src/app/api/plans/[planGroupId]/plans/route.ts
|
|
274
|
+
* import { createGetGroupPlansRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
275
|
+
*
|
|
276
|
+
* export const GET = createGetGroupPlansRoute();
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
export function createGetGroupPlansRoute(config = {}) {
|
|
280
|
+
const handler = createGetGroupPlansHandler();
|
|
281
|
+
const adaptedHandler = nextjsAdapter(handler);
|
|
282
|
+
return (request, context) => adaptedHandler(request, context, config);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Create a Next.js API route handler for subscribing a customer to a plan
|
|
286
|
+
*
|
|
287
|
+
* @param config - Handler configuration options
|
|
288
|
+
* @returns Next.js route handler function
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```typescript
|
|
292
|
+
* // src/app/api/plans/[planId]/subscribe/route.ts
|
|
293
|
+
* import { createSubscribeRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
294
|
+
*
|
|
295
|
+
* export const POST = createSubscribeRoute();
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
export function createSubscribeRoute(config = {}) {
|
|
299
|
+
const handler = createSubscribeHandler();
|
|
300
|
+
const adaptedHandler = nextjsAdapter(handler);
|
|
301
|
+
return (request, context) => adaptedHandler(request, context, config);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Create a Next.js API route handler for unsubscribing a customer from a plan
|
|
305
|
+
*
|
|
306
|
+
* @param config - Handler configuration options
|
|
307
|
+
* @returns Next.js route handler function
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```typescript
|
|
311
|
+
* // src/app/api/plans/[planId]/unsubscribe/route.ts
|
|
312
|
+
* import { createUnsubscribeRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
313
|
+
*
|
|
314
|
+
* export const POST = createUnsubscribeRoute();
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
export function createUnsubscribeRoute(config = {}) {
|
|
318
|
+
const handler = createUnsubscribeHandler();
|
|
319
|
+
const adaptedHandler = nextjsAdapter(handler);
|
|
320
|
+
return (request, context) => adaptedHandler(request, context, config);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Create a Next.js API route handler for upgrading a customer's plan
|
|
324
|
+
*
|
|
325
|
+
* @param config - Handler configuration options
|
|
326
|
+
* @returns Next.js route handler function
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```typescript
|
|
330
|
+
* // src/app/api/plans/upgrade/route.ts
|
|
331
|
+
* import { createUpgradeRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
332
|
+
*
|
|
333
|
+
* export const POST = createUpgradeRoute();
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
export function createUpgradeRoute(config = {}) {
|
|
337
|
+
const handler = createUpgradeHandler();
|
|
338
|
+
const adaptedHandler = nextjsAdapter(handler);
|
|
339
|
+
return (request, context) => adaptedHandler(request, context, config);
|
|
340
|
+
}
|
|
@@ -4,4 +4,4 @@ export { createOrder, createOrderWithDefaults, createOrdersHandler, } from "./or
|
|
|
4
4
|
export { payInvoice, createPayInvoiceHandler, type PayInvoiceConfig, type PayInvoiceRequest, type PayInvoiceResult, activateOrderSync, createActivateOrderSyncHandler, type ActivateOrderSyncConfig, type ActivateOrderSyncRequest, type ActivateOrderSyncResult, createSetupIntent, createSetupIntentHandler, type SetupIntentConfig, type SetupIntentRequest, type SetupIntentResponse, } from "./billing.mjs";
|
|
5
5
|
export { getCustomerInvoices, createCustomerInvoicesHandler, type CustomerInvoicesResult, } from "./invoices.mjs";
|
|
6
6
|
export { provisionNewUser, createProvisioningHandler, } from "./provision-users.mjs";
|
|
7
|
-
export { createGetPlanGroupByIdHandler, } from "./plans.mjs";
|
|
7
|
+
export { getPlanById, getPlanGroupById, createGetPlanGroupByIdHandler, getGroupPlans, createGetGroupPlansHandler, subscribe, createSubscribeHandler, unsubscribe, createUnsubscribeHandler, upgrade, createUpgradeHandler, } from "./plans.mjs";
|
|
@@ -4,4 +4,4 @@ export { createOrder, createOrderWithDefaults, createOrdersHandler, } from "./or
|
|
|
4
4
|
export { payInvoice, createPayInvoiceHandler, activateOrderSync, createActivateOrderSyncHandler, createSetupIntent, createSetupIntentHandler, } from "./billing.mjs";
|
|
5
5
|
export { getCustomerInvoices, createCustomerInvoicesHandler, } from "./invoices.mjs";
|
|
6
6
|
export { provisionNewUser, createProvisioningHandler, } from "./provision-users.mjs";
|
|
7
|
-
export { createGetPlanGroupByIdHandler, } from "./plans.mjs";
|
|
7
|
+
export { getPlanById, getPlanGroupById, createGetPlanGroupByIdHandler, getGroupPlans, createGetGroupPlansHandler, subscribe, createSubscribeHandler, unsubscribe, createUnsubscribeHandler, upgrade, createUpgradeHandler, } from "./plans.mjs";
|