@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.
Files changed (50) hide show
  1. package/dist/cjs/Client.js +2 -2
  2. package/dist/cjs/api/resources/plans/client/Client.d.ts +58 -0
  3. package/dist/cjs/api/resources/plans/client/Client.js +220 -0
  4. package/dist/cjs/api/resources/plans/client/requests/PlansSubscribeRequest.d.ts +13 -0
  5. package/dist/cjs/api/resources/plans/client/requests/PlansSubscribeRequest.js +3 -0
  6. package/dist/cjs/api/resources/plans/client/requests/PlansUnsubscribeRequest.d.ts +10 -0
  7. package/dist/cjs/api/resources/plans/client/requests/PlansUnsubscribeRequest.js +3 -0
  8. package/dist/cjs/api/resources/plans/client/requests/PlansUpgradeRequest.d.ts +16 -0
  9. package/dist/cjs/api/resources/plans/client/requests/PlansUpgradeRequest.js +3 -0
  10. package/dist/cjs/api/resources/plans/client/requests/index.d.ts +3 -0
  11. package/dist/cjs/api/types/Plan.d.ts +33 -0
  12. package/dist/cjs/api/types/Plan.js +19 -0
  13. package/dist/cjs/api/types/PlanWithFeatures.d.ts +33 -0
  14. package/dist/cjs/api/types/PlanWithFeatures.js +19 -0
  15. package/dist/cjs/integrations/adapters/nextjs/index.d.ts +1 -1
  16. package/dist/cjs/integrations/adapters/nextjs/index.js +5 -1
  17. package/dist/cjs/integrations/adapters/nextjs/routes.d.ts +60 -0
  18. package/dist/cjs/integrations/adapters/nextjs/routes.js +80 -0
  19. package/dist/cjs/integrations/controllers/index.d.ts +1 -1
  20. package/dist/cjs/integrations/controllers/index.js +11 -1
  21. package/dist/cjs/integrations/controllers/plans.d.ts +158 -0
  22. package/dist/cjs/integrations/controllers/plans.js +277 -0
  23. package/dist/cjs/version.d.ts +1 -1
  24. package/dist/cjs/version.js +1 -1
  25. package/dist/esm/Client.mjs +2 -2
  26. package/dist/esm/api/resources/plans/client/Client.d.mts +58 -0
  27. package/dist/esm/api/resources/plans/client/Client.mjs +220 -0
  28. package/dist/esm/api/resources/plans/client/requests/PlansSubscribeRequest.d.mts +13 -0
  29. package/dist/esm/api/resources/plans/client/requests/PlansSubscribeRequest.mjs +2 -0
  30. package/dist/esm/api/resources/plans/client/requests/PlansUnsubscribeRequest.d.mts +10 -0
  31. package/dist/esm/api/resources/plans/client/requests/PlansUnsubscribeRequest.mjs +2 -0
  32. package/dist/esm/api/resources/plans/client/requests/PlansUpgradeRequest.d.mts +16 -0
  33. package/dist/esm/api/resources/plans/client/requests/PlansUpgradeRequest.mjs +2 -0
  34. package/dist/esm/api/resources/plans/client/requests/index.d.mts +3 -0
  35. package/dist/esm/api/types/Plan.d.mts +33 -0
  36. package/dist/esm/api/types/Plan.mjs +18 -1
  37. package/dist/esm/api/types/PlanWithFeatures.d.mts +33 -0
  38. package/dist/esm/api/types/PlanWithFeatures.mjs +18 -1
  39. package/dist/esm/integrations/adapters/nextjs/index.d.mts +1 -1
  40. package/dist/esm/integrations/adapters/nextjs/index.mjs +1 -1
  41. package/dist/esm/integrations/adapters/nextjs/routes.d.mts +60 -0
  42. package/dist/esm/integrations/adapters/nextjs/routes.mjs +77 -1
  43. package/dist/esm/integrations/controllers/index.d.mts +1 -1
  44. package/dist/esm/integrations/controllers/index.mjs +1 -1
  45. package/dist/esm/integrations/controllers/plans.d.mts +158 -0
  46. package/dist/esm/integrations/controllers/plans.mjs +269 -0
  47. package/dist/esm/version.d.mts +1 -1
  48. package/dist/esm/version.mjs +1 -1
  49. package/package.json +1 -1
  50. package/reference.md +228 -0
@@ -50,8 +50,8 @@ class PaidClient {
50
50
  this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
51
51
  "X-Fern-Language": "JavaScript",
52
52
  "X-Fern-SDK-Name": "@paid-ai/paid-node",
53
- "X-Fern-SDK-Version": "1.0.1-alpha1",
54
- "User-Agent": "@paid-ai/paid-node/1.0.1-alpha1",
53
+ "X-Fern-SDK-Version": "1.0.1-alpha2",
54
+ "User-Agent": "@paid-ai/paid-node/1.0.1-alpha2",
55
55
  "X-Fern-Runtime": core.RUNTIME.type,
56
56
  "X-Fern-Runtime-Version": core.RUNTIME.version,
57
57
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -42,6 +42,62 @@ export declare class Plans {
42
42
  */
43
43
  getUsage(planId: string, request: Paid.PlansGetUsageRequest, requestOptions?: Plans.RequestOptions): core.HttpResponsePromise<Paid.UsageSummariesResponse>;
44
44
  private __getUsage;
45
+ /**
46
+ * Creates a new order for a customer subscribing to a plan. The order will be created with the plan's products and pricing attributes.
47
+ *
48
+ * @param {string} planId - The ID of the plan
49
+ * @param {Paid.PlansSubscribeRequest} request
50
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
51
+ *
52
+ * @throws {@link Paid.BadRequestError}
53
+ * @throws {@link Paid.ForbiddenError}
54
+ * @throws {@link Paid.NotFoundError}
55
+ *
56
+ * @example
57
+ * await client.plans.subscribe("planId", {
58
+ * customerExternalId: "customerExternalId",
59
+ * currency: "currency"
60
+ * })
61
+ */
62
+ subscribe(planId: string, request: Paid.PlansSubscribeRequest, requestOptions?: Plans.RequestOptions): core.HttpResponsePromise<Paid.Order>;
63
+ private __subscribe;
64
+ /**
65
+ * Cancels the renewal of an active order for a customer's plan subscription. The order will remain active until the cancellation date.
66
+ *
67
+ * @param {string} planId - The ID of the plan
68
+ * @param {Paid.PlansUnsubscribeRequest} request
69
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
70
+ *
71
+ * @throws {@link Paid.BadRequestError}
72
+ * @throws {@link Paid.ForbiddenError}
73
+ * @throws {@link Paid.NotFoundError}
74
+ *
75
+ * @example
76
+ * await client.plans.unsubscribe("planId", {
77
+ * customerExternalId: "customerExternalId"
78
+ * })
79
+ */
80
+ unsubscribe(planId: string, request: Paid.PlansUnsubscribeRequest, requestOptions?: Plans.RequestOptions): core.HttpResponsePromise<Paid.CancelRenewalResponse>;
81
+ private __unsubscribe;
82
+ /**
83
+ * 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.
84
+ *
85
+ * @param {Paid.PlansUpgradeRequest} request
86
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
87
+ *
88
+ * @throws {@link Paid.BadRequestError}
89
+ * @throws {@link Paid.ForbiddenError}
90
+ * @throws {@link Paid.NotFoundError}
91
+ *
92
+ * @example
93
+ * await client.plans.upgrade({
94
+ * customerExternalId: "customerExternalId",
95
+ * oldPlanId: "oldPlanId",
96
+ * newPlanId: "newPlanId"
97
+ * })
98
+ */
99
+ upgrade(request: Paid.PlansUpgradeRequest, requestOptions?: Plans.RequestOptions): core.HttpResponsePromise<Paid.ProrationUpgradeResponse>;
100
+ private __upgrade;
45
101
  /**
46
102
  * @param {string} planGroupId - The ID of the plan group
47
103
  * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
@@ -55,6 +111,8 @@ export declare class Plans {
55
111
  getGroupById(planGroupId: string, requestOptions?: Plans.RequestOptions): core.HttpResponsePromise<Paid.PlanGroup>;
56
112
  private __getGroupById;
57
113
  /**
114
+ * Retrieves all plans in a plan group with their features (product-attribute pairs)
115
+ *
58
116
  * @param {string} planGroupId - The ID of the plan group
59
117
  * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
60
118
  *
@@ -198,6 +198,224 @@ class Plans {
198
198
  }
199
199
  });
200
200
  }
201
+ /**
202
+ * Creates a new order for a customer subscribing to a plan. The order will be created with the plan's products and pricing attributes.
203
+ *
204
+ * @param {string} planId - The ID of the plan
205
+ * @param {Paid.PlansSubscribeRequest} request
206
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
207
+ *
208
+ * @throws {@link Paid.BadRequestError}
209
+ * @throws {@link Paid.ForbiddenError}
210
+ * @throws {@link Paid.NotFoundError}
211
+ *
212
+ * @example
213
+ * await client.plans.subscribe("planId", {
214
+ * customerExternalId: "customerExternalId",
215
+ * currency: "currency"
216
+ * })
217
+ */
218
+ subscribe(planId, request, requestOptions) {
219
+ return core.HttpResponsePromise.fromPromise(this.__subscribe(planId, request, requestOptions));
220
+ }
221
+ __subscribe(planId, request, requestOptions) {
222
+ return __awaiter(this, void 0, void 0, function* () {
223
+ var _a, _b, _c, _d, _e, _f, _g, _h;
224
+ const { customerExternalId, currency } = request;
225
+ const _queryParams = {};
226
+ _queryParams.customerExternalId = customerExternalId;
227
+ _queryParams.currency = currency;
228
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
229
+ const _response = yield core.fetcher({
230
+ 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`),
231
+ method: "POST",
232
+ headers: _headers,
233
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
234
+ 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,
235
+ 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,
236
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
237
+ });
238
+ if (_response.ok) {
239
+ return { data: _response.body, rawResponse: _response.rawResponse };
240
+ }
241
+ if (_response.error.reason === "status-code") {
242
+ switch (_response.error.statusCode) {
243
+ case 400:
244
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
245
+ case 403:
246
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
247
+ case 404:
248
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
249
+ default:
250
+ throw new errors.PaidError({
251
+ statusCode: _response.error.statusCode,
252
+ body: _response.error.body,
253
+ rawResponse: _response.rawResponse,
254
+ });
255
+ }
256
+ }
257
+ switch (_response.error.reason) {
258
+ case "non-json":
259
+ throw new errors.PaidError({
260
+ statusCode: _response.error.statusCode,
261
+ body: _response.error.rawBody,
262
+ rawResponse: _response.rawResponse,
263
+ });
264
+ case "timeout":
265
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /plans/{planId}/subscribe.");
266
+ case "unknown":
267
+ throw new errors.PaidError({
268
+ message: _response.error.errorMessage,
269
+ rawResponse: _response.rawResponse,
270
+ });
271
+ }
272
+ });
273
+ }
274
+ /**
275
+ * Cancels the renewal of an active order for a customer's plan subscription. The order will remain active until the cancellation date.
276
+ *
277
+ * @param {string} planId - The ID of the plan
278
+ * @param {Paid.PlansUnsubscribeRequest} request
279
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
280
+ *
281
+ * @throws {@link Paid.BadRequestError}
282
+ * @throws {@link Paid.ForbiddenError}
283
+ * @throws {@link Paid.NotFoundError}
284
+ *
285
+ * @example
286
+ * await client.plans.unsubscribe("planId", {
287
+ * customerExternalId: "customerExternalId"
288
+ * })
289
+ */
290
+ unsubscribe(planId, request, requestOptions) {
291
+ return core.HttpResponsePromise.fromPromise(this.__unsubscribe(planId, request, requestOptions));
292
+ }
293
+ __unsubscribe(planId, request, requestOptions) {
294
+ return __awaiter(this, void 0, void 0, function* () {
295
+ var _a, _b, _c, _d, _e, _f, _g, _h;
296
+ const { customerExternalId } = request;
297
+ const _queryParams = {};
298
+ _queryParams.customerExternalId = customerExternalId;
299
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
300
+ const _response = yield core.fetcher({
301
+ 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`),
302
+ method: "POST",
303
+ headers: _headers,
304
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
305
+ 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,
306
+ 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,
307
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
308
+ });
309
+ if (_response.ok) {
310
+ return { data: _response.body, rawResponse: _response.rawResponse };
311
+ }
312
+ if (_response.error.reason === "status-code") {
313
+ switch (_response.error.statusCode) {
314
+ case 400:
315
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
316
+ case 403:
317
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
318
+ case 404:
319
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
320
+ default:
321
+ throw new errors.PaidError({
322
+ statusCode: _response.error.statusCode,
323
+ body: _response.error.body,
324
+ rawResponse: _response.rawResponse,
325
+ });
326
+ }
327
+ }
328
+ switch (_response.error.reason) {
329
+ case "non-json":
330
+ throw new errors.PaidError({
331
+ statusCode: _response.error.statusCode,
332
+ body: _response.error.rawBody,
333
+ rawResponse: _response.rawResponse,
334
+ });
335
+ case "timeout":
336
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /plans/{planId}/unsubscribe.");
337
+ case "unknown":
338
+ throw new errors.PaidError({
339
+ message: _response.error.errorMessage,
340
+ rawResponse: _response.rawResponse,
341
+ });
342
+ }
343
+ });
344
+ }
345
+ /**
346
+ * 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.
347
+ *
348
+ * @param {Paid.PlansUpgradeRequest} request
349
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
350
+ *
351
+ * @throws {@link Paid.BadRequestError}
352
+ * @throws {@link Paid.ForbiddenError}
353
+ * @throws {@link Paid.NotFoundError}
354
+ *
355
+ * @example
356
+ * await client.plans.upgrade({
357
+ * customerExternalId: "customerExternalId",
358
+ * oldPlanId: "oldPlanId",
359
+ * newPlanId: "newPlanId"
360
+ * })
361
+ */
362
+ upgrade(request, requestOptions) {
363
+ return core.HttpResponsePromise.fromPromise(this.__upgrade(request, requestOptions));
364
+ }
365
+ __upgrade(request, requestOptions) {
366
+ return __awaiter(this, void 0, void 0, function* () {
367
+ var _a, _b, _c, _d, _e, _f, _g, _h;
368
+ const { customerExternalId, oldPlanId, newPlanId } = request;
369
+ const _queryParams = {};
370
+ _queryParams.customerExternalId = customerExternalId;
371
+ _queryParams.oldPlanId = oldPlanId;
372
+ _queryParams.newPlanId = newPlanId;
373
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
374
+ const _response = yield core.fetcher({
375
+ 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"),
376
+ method: "POST",
377
+ headers: _headers,
378
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
379
+ 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,
380
+ 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,
381
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
382
+ });
383
+ if (_response.ok) {
384
+ return { data: _response.body, rawResponse: _response.rawResponse };
385
+ }
386
+ if (_response.error.reason === "status-code") {
387
+ switch (_response.error.statusCode) {
388
+ case 400:
389
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
390
+ case 403:
391
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
392
+ case 404:
393
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
394
+ default:
395
+ throw new errors.PaidError({
396
+ statusCode: _response.error.statusCode,
397
+ body: _response.error.body,
398
+ rawResponse: _response.rawResponse,
399
+ });
400
+ }
401
+ }
402
+ switch (_response.error.reason) {
403
+ case "non-json":
404
+ throw new errors.PaidError({
405
+ statusCode: _response.error.statusCode,
406
+ body: _response.error.rawBody,
407
+ rawResponse: _response.rawResponse,
408
+ });
409
+ case "timeout":
410
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /plans/upgrade.");
411
+ case "unknown":
412
+ throw new errors.PaidError({
413
+ message: _response.error.errorMessage,
414
+ rawResponse: _response.rawResponse,
415
+ });
416
+ }
417
+ });
418
+ }
201
419
  /**
202
420
  * @param {string} planGroupId - The ID of the plan group
203
421
  * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
@@ -259,6 +477,8 @@ class Plans {
259
477
  });
260
478
  }
261
479
  /**
480
+ * Retrieves all plans in a plan group with their features (product-attribute pairs)
481
+ *
262
482
  * @param {string} planGroupId - The ID of the plan group
263
483
  * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
264
484
  *
@@ -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,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * customerExternalId: "customerExternalId"
5
+ * }
6
+ */
7
+ export interface PlansUnsubscribeRequest {
8
+ /** The external ID of the customer */
9
+ customerExternalId: string;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,4 @@
1
1
  export type { PlansGetUsageRequest } from "./PlansGetUsageRequest.js";
2
+ export type { PlansSubscribeRequest } from "./PlansSubscribeRequest.js";
3
+ export type { PlansUnsubscribeRequest } from "./PlansUnsubscribeRequest.js";
4
+ export type { PlansUpgradeRequest } from "./PlansUpgradeRequest.js";
@@ -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,3 +1,22 @@
1
1
  "use strict";
2
2
  // This file was auto-generated by Fern from our API Definition.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Plan = void 0;
5
+ var Plan;
6
+ (function (Plan) {
7
+ /** The type of plan (flat for fixed pricing, usage for usage-based, credit for prepaid credits) */
8
+ Plan.Type = {
9
+ Flat: "flat",
10
+ Usage: "usage",
11
+ Credit: "credit",
12
+ };
13
+ let Pricing;
14
+ (function (Pricing) {
15
+ /** The billing frequency for the plan */
16
+ Pricing.BillingFrequency = {
17
+ Monthly: "monthly",
18
+ Quarterly: "quarterly",
19
+ Annual: "annual",
20
+ };
21
+ })(Pricing = Plan.Pricing || (Plan.Pricing = {}));
22
+ })(Plan || (exports.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,3 +1,22 @@
1
1
  "use strict";
2
2
  // This file was auto-generated by Fern from our API Definition.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PlanWithFeatures = void 0;
5
+ var PlanWithFeatures;
6
+ (function (PlanWithFeatures) {
7
+ /** The type of plan (flat for fixed pricing, usage for usage-based, credit for prepaid credits) */
8
+ PlanWithFeatures.Type = {
9
+ Flat: "flat",
10
+ Usage: "usage",
11
+ Credit: "credit",
12
+ };
13
+ let Pricing;
14
+ (function (Pricing) {
15
+ /** The billing frequency for the plan */
16
+ Pricing.BillingFrequency = {
17
+ Monthly: "monthly",
18
+ Quarterly: "quarterly",
19
+ Annual: "annual",
20
+ };
21
+ })(Pricing = PlanWithFeatures.Pricing || (PlanWithFeatures.Pricing = {}));
22
+ })(PlanWithFeatures || (exports.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.js";
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.js";
@@ -4,7 +4,7 @@
4
4
  * Drop-in handlers for Next.js App Router
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createSetupIntentRoute = exports.createProvisioningRoute = exports.createPayInvoiceRoute = exports.createOrdersRoute = exports.createGetPlanGroupByIdRoute = exports.createGetCustomerRoute = exports.createCustomersRoute = exports.createCustomerInvoicesRoute = exports.createContactsRoute = exports.createActivateOrderSyncRoute = void 0;
7
+ exports.createUpgradeRoute = exports.createUnsubscribeRoute = exports.createSubscribeRoute = exports.createSetupIntentRoute = exports.createProvisioningRoute = exports.createPayInvoiceRoute = exports.createOrdersRoute = exports.createGetGroupPlansRoute = exports.createGetPlanGroupByIdRoute = exports.createGetCustomerRoute = exports.createCustomersRoute = exports.createCustomerInvoicesRoute = exports.createContactsRoute = exports.createActivateOrderSyncRoute = void 0;
8
8
  var routes_js_1 = require("./routes.js");
9
9
  Object.defineProperty(exports, "createActivateOrderSyncRoute", { enumerable: true, get: function () { return routes_js_1.createActivateOrderSyncRoute; } });
10
10
  Object.defineProperty(exports, "createContactsRoute", { enumerable: true, get: function () { return routes_js_1.createContactsRoute; } });
@@ -12,7 +12,11 @@ Object.defineProperty(exports, "createCustomerInvoicesRoute", { enumerable: true
12
12
  Object.defineProperty(exports, "createCustomersRoute", { enumerable: true, get: function () { return routes_js_1.createCustomersRoute; } });
13
13
  Object.defineProperty(exports, "createGetCustomerRoute", { enumerable: true, get: function () { return routes_js_1.createGetCustomerRoute; } });
14
14
  Object.defineProperty(exports, "createGetPlanGroupByIdRoute", { enumerable: true, get: function () { return routes_js_1.createGetPlanGroupByIdRoute; } });
15
+ Object.defineProperty(exports, "createGetGroupPlansRoute", { enumerable: true, get: function () { return routes_js_1.createGetGroupPlansRoute; } });
15
16
  Object.defineProperty(exports, "createOrdersRoute", { enumerable: true, get: function () { return routes_js_1.createOrdersRoute; } });
16
17
  Object.defineProperty(exports, "createPayInvoiceRoute", { enumerable: true, get: function () { return routes_js_1.createPayInvoiceRoute; } });
17
18
  Object.defineProperty(exports, "createProvisioningRoute", { enumerable: true, get: function () { return routes_js_1.createProvisioningRoute; } });
18
19
  Object.defineProperty(exports, "createSetupIntentRoute", { enumerable: true, get: function () { return routes_js_1.createSetupIntentRoute; } });
20
+ Object.defineProperty(exports, "createSubscribeRoute", { enumerable: true, get: function () { return routes_js_1.createSubscribeRoute; } });
21
+ Object.defineProperty(exports, "createUnsubscribeRoute", { enumerable: true, get: function () { return routes_js_1.createUnsubscribeRoute; } });
22
+ Object.defineProperty(exports, "createUpgradeRoute", { enumerable: true, get: function () { return routes_js_1.createUpgradeRoute; } });
@@ -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 {};