@paid-ai/paid-node 1.0.1-alpha1 → 1.0.1-alpha5
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/README.md +4 -4
- package/dist/cjs/Client.js +2 -2
- package/dist/cjs/api/resources/index.d.ts +1 -0
- package/dist/cjs/api/resources/index.js +1 -0
- package/dist/cjs/api/resources/plans/client/Client.d.ts +75 -0
- package/dist/cjs/api/resources/plans/client/Client.js +290 -0
- package/dist/cjs/api/resources/plans/client/requests/PlansGetCurrentRequest.d.ts +15 -0
- package/dist/cjs/api/resources/plans/client/requests/PlansGetCurrentRequest.js +3 -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 +4 -0
- package/dist/cjs/api/resources/plans/index.d.ts +1 -0
- package/dist/cjs/api/resources/plans/index.js +1 -0
- package/dist/cjs/api/resources/plans/types/PlansGetCurrentResponse.d.ts +83 -0
- package/dist/cjs/api/resources/plans/types/PlansGetCurrentResponse.js +16 -0
- package/dist/cjs/api/resources/plans/types/index.d.ts +1 -0
- package/dist/cjs/api/resources/plans/types/index.js +17 -0
- package/dist/cjs/api/types/Plan.d.ts +10 -0
- package/dist/cjs/api/types/Plan.js +10 -0
- package/dist/cjs/api/types/PlanPricing.d.ts +23 -0
- package/dist/cjs/api/types/PlanPricing.js +15 -0
- package/dist/cjs/api/types/PlanWithFeatures.d.ts +11 -0
- package/dist/cjs/api/types/PlanWithFeatures.js +10 -0
- package/dist/cjs/api/types/index.d.ts +1 -0
- package/dist/cjs/api/types/index.js +1 -0
- package/dist/cjs/integrations/adapters/nextjs/index.d.ts +1 -1
- package/dist/cjs/integrations/adapters/nextjs/index.js +6 -1
- package/dist/cjs/integrations/adapters/nextjs/routes.d.ts +76 -0
- package/dist/cjs/integrations/adapters/nextjs/routes.js +101 -0
- package/dist/cjs/integrations/controllers/index.d.ts +1 -1
- package/dist/cjs/integrations/controllers/index.js +13 -1
- package/dist/cjs/integrations/controllers/plans.d.ts +198 -0
- package/dist/cjs/integrations/controllers/plans.js +339 -0
- package/dist/cjs/tracing/autoInstrumentation.d.ts +1 -1
- package/dist/cjs/tracing/autoInstrumentation.js +115 -39
- package/dist/cjs/tracing/signal.js +1 -4
- package/dist/cjs/tracing/spanProcessor.js +12 -0
- package/dist/cjs/tracing/tracing.js +3 -6
- 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/index.d.mts +1 -0
- package/dist/esm/api/resources/index.mjs +1 -0
- package/dist/esm/api/resources/plans/client/Client.d.mts +75 -0
- package/dist/esm/api/resources/plans/client/Client.mjs +290 -0
- package/dist/esm/api/resources/plans/client/requests/PlansGetCurrentRequest.d.mts +15 -0
- package/dist/esm/api/resources/plans/client/requests/PlansGetCurrentRequest.mjs +2 -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 +4 -0
- package/dist/esm/api/resources/plans/index.d.mts +1 -0
- package/dist/esm/api/resources/plans/index.mjs +1 -0
- package/dist/esm/api/resources/plans/types/PlansGetCurrentResponse.d.mts +83 -0
- package/dist/esm/api/resources/plans/types/PlansGetCurrentResponse.mjs +13 -0
- package/dist/esm/api/resources/plans/types/index.d.mts +1 -0
- package/dist/esm/api/resources/plans/types/index.mjs +1 -0
- package/dist/esm/api/types/Plan.d.mts +10 -0
- package/dist/esm/api/types/Plan.mjs +9 -1
- package/dist/esm/api/types/PlanPricing.d.mts +23 -0
- package/dist/esm/api/types/PlanPricing.mjs +12 -0
- package/dist/esm/api/types/PlanWithFeatures.d.mts +11 -0
- package/dist/esm/api/types/PlanWithFeatures.mjs +9 -1
- package/dist/esm/api/types/index.d.mts +1 -0
- package/dist/esm/api/types/index.mjs +1 -0
- 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 +76 -0
- package/dist/esm/integrations/adapters/nextjs/routes.mjs +97 -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 +198 -0
- package/dist/esm/integrations/controllers/plans.mjs +329 -0
- package/dist/esm/tracing/autoInstrumentation.d.mts +1 -1
- package/dist/esm/tracing/autoInstrumentation.mjs +82 -39
- package/dist/esm/tracing/signal.mjs +1 -4
- package/dist/esm/tracing/spanProcessor.mjs +12 -0
- package/dist/esm/tracing/tracing.mjs +3 -6
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +293 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.PlansGetCurrentResponse = void 0;
|
|
5
|
+
var PlansGetCurrentResponse;
|
|
6
|
+
(function (PlansGetCurrentResponse) {
|
|
7
|
+
let Plan;
|
|
8
|
+
(function (Plan) {
|
|
9
|
+
/** The type of plan */
|
|
10
|
+
Plan.Type = {
|
|
11
|
+
Flat: "flat",
|
|
12
|
+
Usage: "usage",
|
|
13
|
+
Credit: "credit",
|
|
14
|
+
};
|
|
15
|
+
})(Plan = PlansGetCurrentResponse.Plan || (PlansGetCurrentResponse.Plan = {}));
|
|
16
|
+
})(PlansGetCurrentResponse || (exports.PlansGetCurrentResponse = PlansGetCurrentResponse = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./PlansGetCurrentResponse.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./PlansGetCurrentResponse.js"), exports);
|
|
@@ -13,6 +13,9 @@ 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
|
+
pricing: Paid.PlanPricing;
|
|
16
19
|
/** The ID of the next plan in the sequence */
|
|
17
20
|
nextPlanId?: string;
|
|
18
21
|
/** The ID of the previous plan in the sequence */
|
|
@@ -25,6 +28,13 @@ export interface Plan {
|
|
|
25
28
|
planProducts?: Plan.PlanProducts.Item[];
|
|
26
29
|
}
|
|
27
30
|
export declare namespace Plan {
|
|
31
|
+
/** The type of plan (flat for fixed pricing, usage for usage-based, credit for prepaid credits) */
|
|
32
|
+
const Type: {
|
|
33
|
+
readonly Flat: "flat";
|
|
34
|
+
readonly Usage: "usage";
|
|
35
|
+
readonly Credit: "credit";
|
|
36
|
+
};
|
|
37
|
+
type Type = (typeof Type)[keyof typeof Type];
|
|
28
38
|
type PlanProducts = PlanProducts.Item[];
|
|
29
39
|
namespace PlanProducts {
|
|
30
40
|
interface Item {
|
|
@@ -1,3 +1,13 @@
|
|
|
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
|
+
})(Plan || (exports.Plan = Plan = {}));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type * as Paid from "../index.js";
|
|
2
|
+
/**
|
|
3
|
+
* The pricing configuration for a plan. Uses the same PricePoints structure as product pricing.
|
|
4
|
+
*/
|
|
5
|
+
export interface PlanPricing {
|
|
6
|
+
/** Price points keyed by currency code (e.g., "USD", "EUR") */
|
|
7
|
+
PricePoints: Record<string, Paid.PricePoint>;
|
|
8
|
+
/** The billing frequency for the plan */
|
|
9
|
+
billingFrequency: PlanPricing.BillingFrequency;
|
|
10
|
+
/** Custom billing frequency in months (when billingFrequency is "custom") */
|
|
11
|
+
billingFrequencyCustomMonths?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare namespace PlanPricing {
|
|
14
|
+
/** The billing frequency for the plan */
|
|
15
|
+
const BillingFrequency: {
|
|
16
|
+
readonly Monthly: "monthly";
|
|
17
|
+
readonly Quarterly: "quarterly";
|
|
18
|
+
readonly SemiAnnually: "semi-annually";
|
|
19
|
+
readonly Yearly: "yearly";
|
|
20
|
+
readonly Custom: "custom";
|
|
21
|
+
};
|
|
22
|
+
type BillingFrequency = (typeof BillingFrequency)[keyof typeof BillingFrequency];
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.PlanPricing = void 0;
|
|
5
|
+
var PlanPricing;
|
|
6
|
+
(function (PlanPricing) {
|
|
7
|
+
/** The billing frequency for the plan */
|
|
8
|
+
PlanPricing.BillingFrequency = {
|
|
9
|
+
Monthly: "monthly",
|
|
10
|
+
Quarterly: "quarterly",
|
|
11
|
+
SemiAnnually: "semi-annually",
|
|
12
|
+
Yearly: "yearly",
|
|
13
|
+
Custom: "custom",
|
|
14
|
+
};
|
|
15
|
+
})(PlanPricing || (exports.PlanPricing = PlanPricing = {}));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type * as Paid from "../index.js";
|
|
1
2
|
/**
|
|
2
3
|
* A plan with its features (product-attribute pairs) for display
|
|
3
4
|
*/
|
|
@@ -8,6 +9,9 @@ export interface PlanWithFeatures {
|
|
|
8
9
|
name: string;
|
|
9
10
|
/** The description of the plan */
|
|
10
11
|
description?: string;
|
|
12
|
+
/** The type of plan (flat for fixed pricing, usage for usage-based, credit for prepaid credits) */
|
|
13
|
+
type: PlanWithFeatures.Type;
|
|
14
|
+
pricing: Paid.PlanPricing;
|
|
11
15
|
/** When the plan was created */
|
|
12
16
|
createdAt: string;
|
|
13
17
|
/** When the plan was last updated */
|
|
@@ -20,6 +24,13 @@ 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];
|
|
23
34
|
type Features = Features.Item[];
|
|
24
35
|
namespace Features {
|
|
25
36
|
interface Item {
|
|
@@ -1,3 +1,13 @@
|
|
|
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
|
+
})(PlanWithFeatures || (exports.PlanWithFeatures = PlanWithFeatures = {}));
|
|
@@ -30,6 +30,7 @@ export * from "./PaginationMeta.js";
|
|
|
30
30
|
export * from "./PaymentMethod.js";
|
|
31
31
|
export * from "./Plan.js";
|
|
32
32
|
export * from "./PlanGroup.js";
|
|
33
|
+
export * from "./PlanPricing.js";
|
|
33
34
|
export * from "./PlanWithFeatures.js";
|
|
34
35
|
export * from "./PricePoint.js";
|
|
35
36
|
export * from "./Pricing.js";
|
|
@@ -46,6 +46,7 @@ __exportStar(require("./PaginationMeta.js"), exports);
|
|
|
46
46
|
__exportStar(require("./PaymentMethod.js"), exports);
|
|
47
47
|
__exportStar(require("./Plan.js"), exports);
|
|
48
48
|
__exportStar(require("./PlanGroup.js"), exports);
|
|
49
|
+
__exportStar(require("./PlanPricing.js"), exports);
|
|
49
50
|
__exportStar(require("./PlanWithFeatures.js"), exports);
|
|
50
51
|
__exportStar(require("./PricePoint.js"), exports);
|
|
51
52
|
__exportStar(require("./Pricing.js"), exports);
|
|
@@ -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, createGetCurrentRoute, 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.createGetCurrentRoute = 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,12 @@ 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; } });
|
|
16
|
+
Object.defineProperty(exports, "createGetCurrentRoute", { enumerable: true, get: function () { return routes_js_1.createGetCurrentRoute; } });
|
|
15
17
|
Object.defineProperty(exports, "createOrdersRoute", { enumerable: true, get: function () { return routes_js_1.createOrdersRoute; } });
|
|
16
18
|
Object.defineProperty(exports, "createPayInvoiceRoute", { enumerable: true, get: function () { return routes_js_1.createPayInvoiceRoute; } });
|
|
17
19
|
Object.defineProperty(exports, "createProvisioningRoute", { enumerable: true, get: function () { return routes_js_1.createProvisioningRoute; } });
|
|
18
20
|
Object.defineProperty(exports, "createSetupIntentRoute", { enumerable: true, get: function () { return routes_js_1.createSetupIntentRoute; } });
|
|
21
|
+
Object.defineProperty(exports, "createSubscribeRoute", { enumerable: true, get: function () { return routes_js_1.createSubscribeRoute; } });
|
|
22
|
+
Object.defineProperty(exports, "createUnsubscribeRoute", { enumerable: true, get: function () { return routes_js_1.createUnsubscribeRoute; } });
|
|
23
|
+
Object.defineProperty(exports, "createUpgradeRoute", { enumerable: true, get: function () { return routes_js_1.createUpgradeRoute; } });
|
|
@@ -239,4 +239,80 @@ 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>;
|
|
302
|
+
/**
|
|
303
|
+
* Create a Next.js API route handler for getting a customer's current plan
|
|
304
|
+
*
|
|
305
|
+
* @param config - Handler configuration options
|
|
306
|
+
* @returns Next.js route handler function
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```typescript
|
|
310
|
+
* // src/app/api/plans/current/[customerExternalId]/route.ts
|
|
311
|
+
* // GET /api/plans/current/customer-123
|
|
312
|
+
* import { createGetCurrentRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
313
|
+
*
|
|
314
|
+
* export const GET = createGetCurrentRoute();
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
export declare function createGetCurrentRoute(config?: BaseHandlerConfig): (request: any, context?: any) => Promise<any>;
|
|
242
318
|
export {};
|
|
@@ -10,6 +10,11 @@ exports.createPayInvoiceRoute = createPayInvoiceRoute;
|
|
|
10
10
|
exports.createProvisioningRoute = createProvisioningRoute;
|
|
11
11
|
exports.createSetupIntentRoute = createSetupIntentRoute;
|
|
12
12
|
exports.createGetPlanGroupByIdRoute = createGetPlanGroupByIdRoute;
|
|
13
|
+
exports.createGetGroupPlansRoute = createGetGroupPlansRoute;
|
|
14
|
+
exports.createSubscribeRoute = createSubscribeRoute;
|
|
15
|
+
exports.createUnsubscribeRoute = createUnsubscribeRoute;
|
|
16
|
+
exports.createUpgradeRoute = createUpgradeRoute;
|
|
17
|
+
exports.createGetCurrentRoute = createGetCurrentRoute;
|
|
13
18
|
const base_adapter_js_1 = require("./base-adapter.js");
|
|
14
19
|
const contacts_js_1 = require("../../controllers/contacts.js");
|
|
15
20
|
const invoices_js_1 = require("../../controllers/invoices.js");
|
|
@@ -274,3 +279,99 @@ function createGetPlanGroupByIdRoute(config = {}) {
|
|
|
274
279
|
const adaptedHandler = (0, base_adapter_js_1.nextjsAdapter)(handler);
|
|
275
280
|
return (request, context) => adaptedHandler(request, context, config);
|
|
276
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Create a Next.js API route handler for getting all plans in a plan group
|
|
284
|
+
*
|
|
285
|
+
* @param config - Handler configuration options
|
|
286
|
+
* @returns Next.js route handler function
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```typescript
|
|
290
|
+
* // src/app/api/plans/[planGroupId]/plans/route.ts
|
|
291
|
+
* import { createGetGroupPlansRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
292
|
+
*
|
|
293
|
+
* export const GET = createGetGroupPlansRoute();
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
function createGetGroupPlansRoute(config = {}) {
|
|
297
|
+
const handler = (0, plans_js_1.createGetGroupPlansHandler)();
|
|
298
|
+
const adaptedHandler = (0, base_adapter_js_1.nextjsAdapter)(handler);
|
|
299
|
+
return (request, context) => adaptedHandler(request, context, config);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Create a Next.js API route handler for subscribing a customer to a plan
|
|
303
|
+
*
|
|
304
|
+
* @param config - Handler configuration options
|
|
305
|
+
* @returns Next.js route handler function
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* // src/app/api/plans/[planId]/subscribe/route.ts
|
|
310
|
+
* import { createSubscribeRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
311
|
+
*
|
|
312
|
+
* export const POST = createSubscribeRoute();
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
function createSubscribeRoute(config = {}) {
|
|
316
|
+
const handler = (0, plans_js_1.createSubscribeHandler)();
|
|
317
|
+
const adaptedHandler = (0, base_adapter_js_1.nextjsAdapter)(handler);
|
|
318
|
+
return (request, context) => adaptedHandler(request, context, config);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Create a Next.js API route handler for unsubscribing a customer from a plan
|
|
322
|
+
*
|
|
323
|
+
* @param config - Handler configuration options
|
|
324
|
+
* @returns Next.js route handler function
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```typescript
|
|
328
|
+
* // src/app/api/plans/[planId]/unsubscribe/route.ts
|
|
329
|
+
* import { createUnsubscribeRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
330
|
+
*
|
|
331
|
+
* export const POST = createUnsubscribeRoute();
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
function createUnsubscribeRoute(config = {}) {
|
|
335
|
+
const handler = (0, plans_js_1.createUnsubscribeHandler)();
|
|
336
|
+
const adaptedHandler = (0, base_adapter_js_1.nextjsAdapter)(handler);
|
|
337
|
+
return (request, context) => adaptedHandler(request, context, config);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Create a Next.js API route handler for upgrading a customer's plan
|
|
341
|
+
*
|
|
342
|
+
* @param config - Handler configuration options
|
|
343
|
+
* @returns Next.js route handler function
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```typescript
|
|
347
|
+
* // src/app/api/plans/upgrade/route.ts
|
|
348
|
+
* import { createUpgradeRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
349
|
+
*
|
|
350
|
+
* export const POST = createUpgradeRoute();
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
function createUpgradeRoute(config = {}) {
|
|
354
|
+
const handler = (0, plans_js_1.createUpgradeHandler)();
|
|
355
|
+
const adaptedHandler = (0, base_adapter_js_1.nextjsAdapter)(handler);
|
|
356
|
+
return (request, context) => adaptedHandler(request, context, config);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Create a Next.js API route handler for getting a customer's current plan
|
|
360
|
+
*
|
|
361
|
+
* @param config - Handler configuration options
|
|
362
|
+
* @returns Next.js route handler function
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* ```typescript
|
|
366
|
+
* // src/app/api/plans/current/[customerExternalId]/route.ts
|
|
367
|
+
* // GET /api/plans/current/customer-123
|
|
368
|
+
* import { createGetCurrentRoute } from '@paid-ai/paid-node/integrations/nextjs';
|
|
369
|
+
*
|
|
370
|
+
* export const GET = createGetCurrentRoute();
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
function createGetCurrentRoute(config = {}) {
|
|
374
|
+
const handler = (0, plans_js_1.createGetCurrentHandler)();
|
|
375
|
+
const adaptedHandler = (0, base_adapter_js_1.nextjsAdapter)(handler);
|
|
376
|
+
return (request, context) => adaptedHandler(request, context, config);
|
|
377
|
+
}
|
|
@@ -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.js";
|
|
5
5
|
export { getCustomerInvoices, createCustomerInvoicesHandler, type CustomerInvoicesResult, } from "./invoices.js";
|
|
6
6
|
export { provisionNewUser, createProvisioningHandler, } from "./provision-users.js";
|
|
7
|
-
export { createGetPlanGroupByIdHandler, } from "./plans.js";
|
|
7
|
+
export { getPlanById, getPlanGroupById, createGetPlanGroupByIdHandler, getGroupPlans, createGetGroupPlansHandler, subscribe, createSubscribeHandler, unsubscribe, createUnsubscribeHandler, upgrade, createUpgradeHandler, getCurrent, createGetCurrentHandler, } from "./plans.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createGetPlanGroupByIdHandler = exports.createProvisioningHandler = exports.provisionNewUser = exports.createCustomerInvoicesHandler = exports.getCustomerInvoices = exports.createSetupIntentHandler = exports.createSetupIntent = exports.createActivateOrderSyncHandler = exports.activateOrderSync = exports.createPayInvoiceHandler = exports.payInvoice = exports.createOrdersHandler = exports.createOrderWithDefaults = exports.createOrder = exports.createContactsHandler = exports.createContactWithDefaults = exports.createContact = exports.createCustomersHandler = exports.createGetCustomerHandler = exports.getCustomer = exports.createCustomerWithDefaults = exports.createCustomer = void 0;
|
|
3
|
+
exports.createGetCurrentHandler = exports.getCurrent = exports.createUpgradeHandler = exports.upgrade = exports.createUnsubscribeHandler = exports.unsubscribe = exports.createSubscribeHandler = exports.subscribe = exports.createGetGroupPlansHandler = exports.getGroupPlans = exports.createGetPlanGroupByIdHandler = exports.getPlanGroupById = exports.getPlanById = exports.createProvisioningHandler = exports.provisionNewUser = exports.createCustomerInvoicesHandler = exports.getCustomerInvoices = exports.createSetupIntentHandler = exports.createSetupIntent = exports.createActivateOrderSyncHandler = exports.activateOrderSync = exports.createPayInvoiceHandler = exports.payInvoice = exports.createOrdersHandler = exports.createOrderWithDefaults = exports.createOrder = exports.createContactsHandler = exports.createContactWithDefaults = exports.createContact = exports.createCustomersHandler = exports.createGetCustomerHandler = exports.getCustomer = exports.createCustomerWithDefaults = exports.createCustomer = void 0;
|
|
4
4
|
var customers_js_1 = require("./customers.js");
|
|
5
5
|
Object.defineProperty(exports, "createCustomer", { enumerable: true, get: function () { return customers_js_1.createCustomer; } });
|
|
6
6
|
Object.defineProperty(exports, "createCustomerWithDefaults", { enumerable: true, get: function () { return customers_js_1.createCustomerWithDefaults; } });
|
|
@@ -29,4 +29,16 @@ var provision_users_js_1 = require("./provision-users.js");
|
|
|
29
29
|
Object.defineProperty(exports, "provisionNewUser", { enumerable: true, get: function () { return provision_users_js_1.provisionNewUser; } });
|
|
30
30
|
Object.defineProperty(exports, "createProvisioningHandler", { enumerable: true, get: function () { return provision_users_js_1.createProvisioningHandler; } });
|
|
31
31
|
var plans_js_1 = require("./plans.js");
|
|
32
|
+
Object.defineProperty(exports, "getPlanById", { enumerable: true, get: function () { return plans_js_1.getPlanById; } });
|
|
33
|
+
Object.defineProperty(exports, "getPlanGroupById", { enumerable: true, get: function () { return plans_js_1.getPlanGroupById; } });
|
|
32
34
|
Object.defineProperty(exports, "createGetPlanGroupByIdHandler", { enumerable: true, get: function () { return plans_js_1.createGetPlanGroupByIdHandler; } });
|
|
35
|
+
Object.defineProperty(exports, "getGroupPlans", { enumerable: true, get: function () { return plans_js_1.getGroupPlans; } });
|
|
36
|
+
Object.defineProperty(exports, "createGetGroupPlansHandler", { enumerable: true, get: function () { return plans_js_1.createGetGroupPlansHandler; } });
|
|
37
|
+
Object.defineProperty(exports, "subscribe", { enumerable: true, get: function () { return plans_js_1.subscribe; } });
|
|
38
|
+
Object.defineProperty(exports, "createSubscribeHandler", { enumerable: true, get: function () { return plans_js_1.createSubscribeHandler; } });
|
|
39
|
+
Object.defineProperty(exports, "unsubscribe", { enumerable: true, get: function () { return plans_js_1.unsubscribe; } });
|
|
40
|
+
Object.defineProperty(exports, "createUnsubscribeHandler", { enumerable: true, get: function () { return plans_js_1.createUnsubscribeHandler; } });
|
|
41
|
+
Object.defineProperty(exports, "upgrade", { enumerable: true, get: function () { return plans_js_1.upgrade; } });
|
|
42
|
+
Object.defineProperty(exports, "createUpgradeHandler", { enumerable: true, get: function () { return plans_js_1.createUpgradeHandler; } });
|
|
43
|
+
Object.defineProperty(exports, "getCurrent", { enumerable: true, get: function () { return plans_js_1.getCurrent; } });
|
|
44
|
+
Object.defineProperty(exports, "createGetCurrentHandler", { enumerable: true, get: function () { return plans_js_1.createGetCurrentHandler; } });
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { PaidClient } from "../../Client.js";
|
|
2
2
|
import type { PlanGroup } from "../../api/types/PlanGroup.js";
|
|
3
3
|
import type { Plan } from "../../api/types/Plan.js";
|
|
4
|
+
import type { PlanWithFeatures } from "../../api/types/PlanWithFeatures.js";
|
|
5
|
+
import type { Order } from "../../api/types/Order.js";
|
|
6
|
+
import type { CancelRenewalResponse } from "../../api/types/CancelRenewalResponse.js";
|
|
7
|
+
import type { ProrationUpgradeResponse } from "../../api/types/ProrationUpgradeResponse.js";
|
|
8
|
+
import type { PlansSubscribeRequest } from "../../api/resources/plans/client/requests/PlansSubscribeRequest.js";
|
|
9
|
+
import type { PlansUnsubscribeRequest } from "../../api/resources/plans/client/requests/PlansUnsubscribeRequest.js";
|
|
10
|
+
import type { PlansUpgradeRequest } from "../../api/resources/plans/client/requests/PlansUpgradeRequest.js";
|
|
11
|
+
import type { PlansGetCurrentRequest } from "../../api/resources/plans/client/requests/PlansGetCurrentRequest.js";
|
|
12
|
+
import type { PlansGetCurrentResponse } from "../../api/resources/plans/types/PlansGetCurrentResponse.js";
|
|
4
13
|
/**
|
|
5
14
|
* Get a plan by ID
|
|
6
15
|
*
|
|
@@ -48,3 +57,192 @@ export declare function getPlanGroupById(client: PaidClient, planGroupId: string
|
|
|
48
57
|
* ```
|
|
49
58
|
*/
|
|
50
59
|
export declare function createGetPlanGroupByIdHandler(): (request: any, response: any, config?: any) => Promise<any>;
|
|
60
|
+
/**
|
|
61
|
+
* Get all plans in a plan group
|
|
62
|
+
*
|
|
63
|
+
* @param client - PaidClient instance
|
|
64
|
+
* @param planGroupId - Plan group's ID
|
|
65
|
+
* @returns Array of plans with features
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const plans = await getGroupPlans(client, 'plan-group-123');
|
|
70
|
+
* console.log(plans.length);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function getGroupPlans(client: PaidClient, planGroupId: string): Promise<PlanWithFeatures[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Create a framework-agnostic handler for fetching plans in a plan group
|
|
76
|
+
*
|
|
77
|
+
* This handler can be used with any framework adapter.
|
|
78
|
+
* The plan group ID should be provided either in params or query string.
|
|
79
|
+
*
|
|
80
|
+
* @returns Handler function
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* // In Next.js route: /api/plans/[planGroupId]/plans/route.ts
|
|
85
|
+
* import { createGetGroupPlansHandler } from '@paid-ai/paid-node/integrations';
|
|
86
|
+
* import { nextjsAdapter } from '@paid-ai/paid-node/integrations/nextjs';
|
|
87
|
+
*
|
|
88
|
+
* const handler = createGetGroupPlansHandler();
|
|
89
|
+
* export const GET = nextjsAdapter(handler);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function createGetGroupPlansHandler(): (request: any, response: any, config?: any) => Promise<any>;
|
|
93
|
+
/**
|
|
94
|
+
* Subscribe a customer to a plan
|
|
95
|
+
*
|
|
96
|
+
* Creates a new order for a customer based on the specified plan, automatically converting plan products to order lines.
|
|
97
|
+
*
|
|
98
|
+
* @param client - PaidClient instance
|
|
99
|
+
* @param planId - Plan's ID
|
|
100
|
+
* @param request - Subscribe request with customer external ID and currency
|
|
101
|
+
* @returns Created order
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const order = await subscribe(client, 'plan-123', {
|
|
106
|
+
* customerExternalId: 'customer-123',
|
|
107
|
+
* currency: 'USD'
|
|
108
|
+
* });
|
|
109
|
+
* console.log(order.id);
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export declare function subscribe(client: PaidClient, planId: string, request: PlansSubscribeRequest): Promise<Order>;
|
|
113
|
+
/**
|
|
114
|
+
* Create a framework-agnostic handler for subscribing a customer to a plan
|
|
115
|
+
*
|
|
116
|
+
* This handler can be used with any framework adapter.
|
|
117
|
+
* The plan ID should be provided either in params or query string.
|
|
118
|
+
* The request body should contain customerExternalId and currency.
|
|
119
|
+
*
|
|
120
|
+
* @returns Handler function
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* // In Next.js route: /api/plans/[planId]/subscribe/route.ts
|
|
125
|
+
* import { createSubscribeHandler } from '@paid-ai/paid-node/integrations';
|
|
126
|
+
* import { nextjsAdapter } from '@paid-ai/paid-node/integrations/nextjs';
|
|
127
|
+
*
|
|
128
|
+
* const handler = createSubscribeHandler();
|
|
129
|
+
* export const POST = nextjsAdapter(handler);
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export declare function createSubscribeHandler(): (request: any, response: any, config?: any) => Promise<any>;
|
|
133
|
+
/**
|
|
134
|
+
* Unsubscribe a customer from a plan
|
|
135
|
+
*
|
|
136
|
+
* Cancels the renewal of an order associated with the specified plan. The order will remain active until the cancellation date.
|
|
137
|
+
*
|
|
138
|
+
* @param client - PaidClient instance
|
|
139
|
+
* @param planId - Plan's ID
|
|
140
|
+
* @param request - Unsubscribe request with customer external ID
|
|
141
|
+
* @returns Cancel renewal response
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* const response = await unsubscribe(client, 'plan-123', {
|
|
146
|
+
* customerExternalId: 'customer-123'
|
|
147
|
+
* });
|
|
148
|
+
* console.log(response.message);
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export declare function unsubscribe(client: PaidClient, planId: string, request: PlansUnsubscribeRequest): Promise<CancelRenewalResponse>;
|
|
152
|
+
/**
|
|
153
|
+
* Create a framework-agnostic handler for unsubscribing a customer from a plan
|
|
154
|
+
*
|
|
155
|
+
* This handler can be used with any framework adapter.
|
|
156
|
+
* The plan ID should be provided either in params or query string.
|
|
157
|
+
* The request body should contain customerExternalId.
|
|
158
|
+
*
|
|
159
|
+
* @returns Handler function
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* // In Next.js route: /api/plans/[planId]/unsubscribe/route.ts
|
|
164
|
+
* import { createUnsubscribeHandler } from '@paid-ai/paid-node/integrations';
|
|
165
|
+
* import { nextjsAdapter } from '@paid-ai/paid-node/integrations/nextjs';
|
|
166
|
+
*
|
|
167
|
+
* const handler = createUnsubscribeHandler();
|
|
168
|
+
* export const POST = nextjsAdapter(handler);
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export declare function createUnsubscribeHandler(): (request: any, response: any, config?: any) => Promise<any>;
|
|
172
|
+
/**
|
|
173
|
+
* Upgrade a customer from their current plan to a new plan
|
|
174
|
+
*
|
|
175
|
+
* Upgrades a customer from their current plan to a new plan with automatic proration calculation. This schedules a plan change and applies credits for the unused portion of the current billing period.
|
|
176
|
+
*
|
|
177
|
+
* @param client - PaidClient instance
|
|
178
|
+
* @param request - Upgrade request with customer external ID, old plan ID, and new plan ID
|
|
179
|
+
* @returns Proration upgrade response
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* const response = await upgrade(client, {
|
|
184
|
+
* customerExternalId: 'customer-123',
|
|
185
|
+
* oldPlanId: 'plan-123',
|
|
186
|
+
* newPlanId: 'plan-456'
|
|
187
|
+
* });
|
|
188
|
+
* console.log(response.order.id);
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export declare function upgrade(client: PaidClient, request: PlansUpgradeRequest): Promise<ProrationUpgradeResponse>;
|
|
192
|
+
/**
|
|
193
|
+
* Create a framework-agnostic handler for upgrading a customer's plan
|
|
194
|
+
*
|
|
195
|
+
* This handler can be used with any framework adapter.
|
|
196
|
+
* The request body should contain customerExternalId, oldPlanId, and newPlanId.
|
|
197
|
+
*
|
|
198
|
+
* @returns Handler function
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* // In Next.js route: /api/plans/upgrade/route.ts
|
|
203
|
+
* import { createUpgradeHandler } from '@paid-ai/paid-node/integrations';
|
|
204
|
+
* import { nextjsAdapter } from '@paid-ai/paid-node/integrations/nextjs';
|
|
205
|
+
*
|
|
206
|
+
* const handler = createUpgradeHandler();
|
|
207
|
+
* export const POST = nextjsAdapter(handler);
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
export declare function createUpgradeHandler(): (request: any, response: any, config?: any) => Promise<any>;
|
|
211
|
+
/**
|
|
212
|
+
* Get the currently active plan subscription for a customer
|
|
213
|
+
*
|
|
214
|
+
* Retrieves the currently active plan subscription for a customer by their external ID. Returns the plan details and subscription information.
|
|
215
|
+
*
|
|
216
|
+
* @param client - PaidClient instance
|
|
217
|
+
* @param request - Get current request with customer external ID
|
|
218
|
+
* @returns Current plan response
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* const response = await getCurrent(client, {
|
|
223
|
+
* customerExternalId: 'customer-123'
|
|
224
|
+
* });
|
|
225
|
+
* console.log(response.plan.id);
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export declare function getCurrent(client: PaidClient, request: PlansGetCurrentRequest): Promise<PlansGetCurrentResponse>;
|
|
229
|
+
/**
|
|
230
|
+
* Create a framework-agnostic handler for getting a customer's current plan
|
|
231
|
+
*
|
|
232
|
+
* This handler can be used with any framework adapter.
|
|
233
|
+
* The customerExternalId should be provided as a URL parameter.
|
|
234
|
+
*
|
|
235
|
+
* @returns Handler function
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* // In Next.js route: /api/plans/current/[customerExternalId]/route.ts
|
|
240
|
+
* // GET /api/plans/current/customer-123
|
|
241
|
+
* import { createGetCurrentHandler } from '@paid-ai/paid-node/integrations';
|
|
242
|
+
* import { nextjsAdapter } from '@paid-ai/paid-node/integrations/nextjs';
|
|
243
|
+
*
|
|
244
|
+
* const handler = createGetCurrentHandler();
|
|
245
|
+
* export const GET = nextjsAdapter(handler);
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
export declare function createGetCurrentHandler(): (request: any, response: any, config?: any) => Promise<any>;
|