@paygentic/sdk 0.7.1 → 0.7.2
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 +13 -3
- package/dist/commonjs/funcs/invoicesV2List.js +1 -0
- package/dist/commonjs/funcs/invoicesV2List.js.map +1 -1
- package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.d.ts +18 -0
- package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.d.ts.map +1 -0
- package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.js +127 -0
- package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.js.map +1 -0
- package/dist/commonjs/funcs/profitabilityGetProfitability.d.ts +19 -0
- package/dist/commonjs/funcs/profitabilityGetProfitability.d.ts.map +1 -0
- package/dist/commonjs/funcs/profitabilityGetProfitability.js +127 -0
- package/dist/commonjs/funcs/profitabilityGetProfitability.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/models/index.d.ts +4 -0
- package/dist/commonjs/models/index.d.ts.map +1 -1
- package/dist/commonjs/models/index.js +4 -0
- package/dist/commonjs/models/index.js.map +1 -1
- package/dist/commonjs/models/offsetpagination.d.ts +4 -4
- package/dist/commonjs/models/offsetpagination.d.ts.map +1 -1
- package/dist/commonjs/models/offsetpagination.js +3 -3
- package/dist/commonjs/models/offsetpagination.js.map +1 -1
- package/dist/commonjs/models/operations/createplan.d.ts +5 -0
- package/dist/commonjs/models/operations/createplan.d.ts.map +1 -1
- package/dist/commonjs/models/operations/createplan.js +2 -0
- package/dist/commonjs/models/operations/createplan.js.map +1 -1
- package/dist/commonjs/models/operations/getprofitability.d.ts +55 -0
- package/dist/commonjs/models/operations/getprofitability.d.ts.map +1 -0
- package/dist/commonjs/models/operations/getprofitability.js +64 -0
- package/dist/commonjs/models/operations/getprofitability.js.map +1 -0
- package/dist/commonjs/models/operations/getrevenue.d.ts +4 -4
- package/dist/commonjs/models/operations/getrevenue.d.ts.map +1 -1
- package/dist/commonjs/models/operations/getrevenue.js +4 -5
- package/dist/commonjs/models/operations/getrevenue.js.map +1 -1
- package/dist/commonjs/models/operations/index.d.ts +2 -0
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +2 -0
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/models/operations/listinvoices.d.ts +9 -0
- package/dist/commonjs/models/operations/listinvoices.d.ts.map +1 -1
- package/dist/commonjs/models/operations/listinvoices.js +2 -0
- package/dist/commonjs/models/operations/listinvoices.js.map +1 -1
- package/dist/commonjs/models/operations/listpaymentsessions.d.ts +36 -10
- package/dist/commonjs/models/operations/listpaymentsessions.d.ts.map +1 -1
- package/dist/commonjs/models/operations/listpaymentsessions.js +19 -4
- package/dist/commonjs/models/operations/listpaymentsessions.js.map +1 -1
- package/dist/commonjs/models/operations/updateplan.d.ts +5 -0
- package/dist/commonjs/models/operations/updateplan.d.ts.map +1 -1
- package/dist/commonjs/models/operations/updateplan.js +2 -0
- package/dist/commonjs/models/operations/updateplan.js.map +1 -1
- package/dist/commonjs/models/paymentsession.d.ts +68 -0
- package/dist/commonjs/models/paymentsession.d.ts.map +1 -0
- package/dist/commonjs/models/paymentsession.js +78 -0
- package/dist/commonjs/models/paymentsession.js.map +1 -0
- package/dist/commonjs/models/plan.d.ts +4 -0
- package/dist/commonjs/models/plan.d.ts.map +1 -1
- package/dist/commonjs/models/plan.js +1 -0
- package/dist/commonjs/models/plan.js.map +1 -1
- package/dist/commonjs/models/profitabilityrow.d.ts +38 -0
- package/dist/commonjs/models/profitabilityrow.d.ts.map +1 -0
- package/dist/commonjs/models/profitabilityrow.js +57 -0
- package/dist/commonjs/models/profitabilityrow.js.map +1 -0
- package/dist/commonjs/models/profitabilitysummaryresponse.d.ts +26 -0
- package/dist/commonjs/models/profitabilitysummaryresponse.d.ts.map +1 -0
- package/dist/commonjs/models/profitabilitysummaryresponse.js +54 -0
- package/dist/commonjs/models/profitabilitysummaryresponse.js.map +1 -0
- package/dist/commonjs/models/profitabilitytrend.d.ts +17 -0
- package/dist/commonjs/models/profitabilitytrend.d.ts.map +1 -0
- package/dist/commonjs/models/profitabilitytrend.js +51 -0
- package/dist/commonjs/models/profitabilitytrend.js.map +1 -0
- package/dist/commonjs/models/purchasegrantresponse.d.ts +4 -4
- package/dist/commonjs/models/purchasegrantresponse.d.ts.map +1 -1
- package/dist/commonjs/models/purchasegrantresponse.js +6 -6
- package/dist/commonjs/models/purchasegrantresponse.js.map +1 -1
- package/dist/commonjs/sdk/paymentsessions.d.ts +12 -0
- package/dist/commonjs/sdk/paymentsessions.d.ts.map +1 -0
- package/dist/commonjs/sdk/paymentsessions.js +22 -0
- package/dist/commonjs/sdk/paymentsessions.js.map +1 -0
- package/dist/commonjs/sdk/profitability.d.ts +13 -0
- package/dist/commonjs/sdk/profitability.d.ts.map +1 -0
- package/dist/commonjs/sdk/profitability.js +22 -0
- package/dist/commonjs/sdk/profitability.js.map +1 -0
- package/dist/commonjs/sdk/sdk.d.ts +6 -0
- package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
- package/dist/commonjs/sdk/sdk.js +8 -0
- package/dist/commonjs/sdk/sdk.js.map +1 -1
- package/dist/esm/funcs/invoicesV2List.js +1 -0
- package/dist/esm/funcs/invoicesV2List.js.map +1 -1
- package/dist/esm/funcs/paymentSessionsListPaymentSessions.d.ts +18 -0
- package/dist/esm/funcs/paymentSessionsListPaymentSessions.d.ts.map +1 -0
- package/dist/esm/funcs/paymentSessionsListPaymentSessions.js +91 -0
- package/dist/esm/funcs/paymentSessionsListPaymentSessions.js.map +1 -0
- package/dist/esm/funcs/profitabilityGetProfitability.d.ts +19 -0
- package/dist/esm/funcs/profitabilityGetProfitability.d.ts.map +1 -0
- package/dist/esm/funcs/profitabilityGetProfitability.js +91 -0
- package/dist/esm/funcs/profitabilityGetProfitability.js.map +1 -0
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/models/index.d.ts +4 -0
- package/dist/esm/models/index.d.ts.map +1 -1
- package/dist/esm/models/index.js +4 -0
- package/dist/esm/models/index.js.map +1 -1
- package/dist/esm/models/offsetpagination.d.ts +4 -4
- package/dist/esm/models/offsetpagination.d.ts.map +1 -1
- package/dist/esm/models/offsetpagination.js +3 -3
- package/dist/esm/models/offsetpagination.js.map +1 -1
- package/dist/esm/models/operations/createplan.d.ts +5 -0
- package/dist/esm/models/operations/createplan.d.ts.map +1 -1
- package/dist/esm/models/operations/createplan.js +2 -0
- package/dist/esm/models/operations/createplan.js.map +1 -1
- package/dist/esm/models/operations/getprofitability.d.ts +55 -0
- package/dist/esm/models/operations/getprofitability.d.ts.map +1 -0
- package/dist/esm/models/operations/getprofitability.js +27 -0
- package/dist/esm/models/operations/getprofitability.js.map +1 -0
- package/dist/esm/models/operations/getrevenue.d.ts +4 -4
- package/dist/esm/models/operations/getrevenue.d.ts.map +1 -1
- package/dist/esm/models/operations/getrevenue.js +3 -4
- package/dist/esm/models/operations/getrevenue.js.map +1 -1
- package/dist/esm/models/operations/index.d.ts +2 -0
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +2 -0
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/models/operations/listinvoices.d.ts +9 -0
- package/dist/esm/models/operations/listinvoices.d.ts.map +1 -1
- package/dist/esm/models/operations/listinvoices.js +2 -0
- package/dist/esm/models/operations/listinvoices.js.map +1 -1
- package/dist/esm/models/operations/listpaymentsessions.d.ts +36 -10
- package/dist/esm/models/operations/listpaymentsessions.d.ts.map +1 -1
- package/dist/esm/models/operations/listpaymentsessions.js +18 -3
- package/dist/esm/models/operations/listpaymentsessions.js.map +1 -1
- package/dist/esm/models/operations/updateplan.d.ts +5 -0
- package/dist/esm/models/operations/updateplan.d.ts.map +1 -1
- package/dist/esm/models/operations/updateplan.js +2 -0
- package/dist/esm/models/operations/updateplan.js.map +1 -1
- package/dist/esm/models/paymentsession.d.ts +68 -0
- package/dist/esm/models/paymentsession.d.ts.map +1 -0
- package/dist/esm/models/paymentsession.js +41 -0
- package/dist/esm/models/paymentsession.js.map +1 -0
- package/dist/esm/models/plan.d.ts +4 -0
- package/dist/esm/models/plan.d.ts.map +1 -1
- package/dist/esm/models/plan.js +1 -0
- package/dist/esm/models/plan.js.map +1 -1
- package/dist/esm/models/profitabilityrow.d.ts +38 -0
- package/dist/esm/models/profitabilityrow.d.ts.map +1 -0
- package/dist/esm/models/profitabilityrow.js +20 -0
- package/dist/esm/models/profitabilityrow.js.map +1 -0
- package/dist/esm/models/profitabilitysummaryresponse.d.ts +26 -0
- package/dist/esm/models/profitabilitysummaryresponse.d.ts.map +1 -0
- package/dist/esm/models/profitabilitysummaryresponse.js +17 -0
- package/dist/esm/models/profitabilitysummaryresponse.js.map +1 -0
- package/dist/esm/models/profitabilitytrend.d.ts +17 -0
- package/dist/esm/models/profitabilitytrend.d.ts.map +1 -0
- package/dist/esm/models/profitabilitytrend.js +14 -0
- package/dist/esm/models/profitabilitytrend.js.map +1 -0
- package/dist/esm/models/purchasegrantresponse.d.ts +4 -4
- package/dist/esm/models/purchasegrantresponse.d.ts.map +1 -1
- package/dist/esm/models/purchasegrantresponse.js +4 -4
- package/dist/esm/models/purchasegrantresponse.js.map +1 -1
- package/dist/esm/sdk/paymentsessions.d.ts +12 -0
- package/dist/esm/sdk/paymentsessions.d.ts.map +1 -0
- package/dist/esm/sdk/paymentsessions.js +18 -0
- package/dist/esm/sdk/paymentsessions.js.map +1 -0
- package/dist/esm/sdk/profitability.d.ts +13 -0
- package/dist/esm/sdk/profitability.d.ts.map +1 -0
- package/dist/esm/sdk/profitability.js +18 -0
- package/dist/esm/sdk/profitability.js.map +1 -0
- package/dist/esm/sdk/sdk.d.ts +6 -0
- package/dist/esm/sdk/sdk.d.ts.map +1 -1
- package/dist/esm/sdk/sdk.js +8 -0
- package/dist/esm/sdk/sdk.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/funcs/invoicesV2List.ts +1 -0
- package/src/funcs/paymentSessionsListPaymentSessions.ts +183 -0
- package/src/funcs/profitabilityGetProfitability.ts +184 -0
- package/src/lib/config.ts +2 -2
- package/src/models/index.ts +4 -0
- package/src/models/offsetpagination.ts +7 -7
- package/src/models/operations/createplan.ts +7 -0
- package/src/models/operations/getprofitability.ts +85 -0
- package/src/models/operations/getrevenue.ts +7 -6
- package/src/models/operations/index.ts +2 -0
- package/src/models/operations/listinvoices.ts +11 -0
- package/src/models/operations/listpaymentsessions.ts +43 -12
- package/src/models/operations/updateplan.ts +7 -0
- package/src/models/paymentsession.ts +109 -0
- package/src/models/plan.ts +7 -0
- package/src/models/profitabilityrow.ts +68 -0
- package/src/models/profitabilitysummaryresponse.ts +53 -0
- package/src/models/profitabilitytrend.ts +39 -0
- package/src/models/purchasegrantresponse.ts +12 -9
- package/src/sdk/paymentsessions.ts +27 -0
- package/src/sdk/profitability.ts +28 -0
- package/src/sdk/sdk.ts +12 -0
|
@@ -10,41 +10,64 @@ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
|
10
10
|
import * as models from "../index.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Filter by payment status.
|
|
13
|
+
* Filter by payment session status.
|
|
14
14
|
*/
|
|
15
15
|
export const ListPaymentSessionsStatus = {
|
|
16
16
|
Pending: "pending",
|
|
17
17
|
Processing: "processing",
|
|
18
18
|
Completed: "completed",
|
|
19
|
+
Failed: "failed",
|
|
19
20
|
Expired: "expired",
|
|
20
21
|
Cancelled: "cancelled",
|
|
21
22
|
} as const;
|
|
22
23
|
/**
|
|
23
|
-
* Filter by payment status.
|
|
24
|
+
* Filter by payment session status.
|
|
24
25
|
*/
|
|
25
26
|
export type ListPaymentSessionsStatus = ClosedEnum<
|
|
26
27
|
typeof ListPaymentSessionsStatus
|
|
27
28
|
>;
|
|
28
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Filter by the kind of entity the session pays for.
|
|
32
|
+
*/
|
|
33
|
+
export const EntityType = {
|
|
34
|
+
Invoice: "invoice",
|
|
35
|
+
Subscription: "subscription",
|
|
36
|
+
Payment: "payment",
|
|
37
|
+
Topup: "topup",
|
|
38
|
+
} as const;
|
|
39
|
+
/**
|
|
40
|
+
* Filter by the kind of entity the session pays for.
|
|
41
|
+
*/
|
|
42
|
+
export type EntityType = ClosedEnum<typeof EntityType>;
|
|
43
|
+
|
|
29
44
|
export type ListPaymentSessionsRequest = {
|
|
30
45
|
/**
|
|
31
46
|
* Merchant organization ID. Required when using an API key that is not scoped to a single merchant.
|
|
32
47
|
*/
|
|
33
48
|
merchantId?: string | undefined;
|
|
34
49
|
/**
|
|
35
|
-
* Filter
|
|
50
|
+
* Filter to sessions linked to this subscription (its own activation session plus all of its invoices' sessions).
|
|
36
51
|
*/
|
|
37
|
-
|
|
52
|
+
subscriptionId?: string | undefined;
|
|
38
53
|
/**
|
|
39
|
-
* Filter
|
|
54
|
+
* Filter to sessions linked to a payment for this customer.
|
|
40
55
|
*/
|
|
41
56
|
customerId?: string | undefined;
|
|
42
57
|
/**
|
|
43
|
-
*
|
|
58
|
+
* Filter by payment session status.
|
|
59
|
+
*/
|
|
60
|
+
status?: ListPaymentSessionsStatus | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Filter by the kind of entity the session pays for.
|
|
63
|
+
*/
|
|
64
|
+
entityType?: EntityType | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Number of sessions to return.
|
|
44
67
|
*/
|
|
45
68
|
limit?: number | undefined;
|
|
46
69
|
/**
|
|
47
|
-
* Number of
|
|
70
|
+
* Number of sessions to skip.
|
|
48
71
|
*/
|
|
49
72
|
offset?: number | undefined;
|
|
50
73
|
};
|
|
@@ -57,11 +80,11 @@ export type ListPaymentSessionsObject = ClosedEnum<
|
|
|
57
80
|
>;
|
|
58
81
|
|
|
59
82
|
/**
|
|
60
|
-
* List of
|
|
83
|
+
* List of payment sessions
|
|
61
84
|
*/
|
|
62
85
|
export type ListPaymentSessionsResponse = {
|
|
63
86
|
object: ListPaymentSessionsObject;
|
|
64
|
-
data: Array<models.
|
|
87
|
+
data: Array<models.PaymentSession>;
|
|
65
88
|
/**
|
|
66
89
|
* Offset-based pagination response.
|
|
67
90
|
*/
|
|
@@ -73,11 +96,17 @@ export const ListPaymentSessionsStatus$outboundSchema: z.ZodNativeEnum<
|
|
|
73
96
|
typeof ListPaymentSessionsStatus
|
|
74
97
|
> = z.nativeEnum(ListPaymentSessionsStatus);
|
|
75
98
|
|
|
99
|
+
/** @internal */
|
|
100
|
+
export const EntityType$outboundSchema: z.ZodNativeEnum<typeof EntityType> = z
|
|
101
|
+
.nativeEnum(EntityType);
|
|
102
|
+
|
|
76
103
|
/** @internal */
|
|
77
104
|
export type ListPaymentSessionsRequest$Outbound = {
|
|
78
105
|
merchantId?: string | undefined;
|
|
79
|
-
|
|
106
|
+
subscriptionId?: string | undefined;
|
|
80
107
|
customerId?: string | undefined;
|
|
108
|
+
status?: string | undefined;
|
|
109
|
+
entityType?: string | undefined;
|
|
81
110
|
limit: number;
|
|
82
111
|
offset: number;
|
|
83
112
|
};
|
|
@@ -89,8 +118,10 @@ export const ListPaymentSessionsRequest$outboundSchema: z.ZodType<
|
|
|
89
118
|
ListPaymentSessionsRequest
|
|
90
119
|
> = z.object({
|
|
91
120
|
merchantId: z.string().optional(),
|
|
92
|
-
|
|
121
|
+
subscriptionId: z.string().optional(),
|
|
93
122
|
customerId: z.string().optional(),
|
|
123
|
+
status: ListPaymentSessionsStatus$outboundSchema.optional(),
|
|
124
|
+
entityType: EntityType$outboundSchema.optional(),
|
|
94
125
|
limit: z.number().int().default(10),
|
|
95
126
|
offset: z.number().int().default(0),
|
|
96
127
|
});
|
|
@@ -115,7 +146,7 @@ export const ListPaymentSessionsResponse$inboundSchema: z.ZodType<
|
|
|
115
146
|
unknown
|
|
116
147
|
> = z.object({
|
|
117
148
|
object: ListPaymentSessionsObject$inboundSchema,
|
|
118
|
-
data: z.array(models.
|
|
149
|
+
data: z.array(models.PaymentSession$inboundSchema),
|
|
119
150
|
pagination: models.OffsetPagination$inboundSchema,
|
|
120
151
|
});
|
|
121
152
|
|
|
@@ -94,6 +94,10 @@ export type UpdatePlanRequestBody = {
|
|
|
94
94
|
* Number of days before renewal to send the reminder email
|
|
95
95
|
*/
|
|
96
96
|
renewalReminderDays?: number | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* ISO 8601 datetime reference point for billing period alignment. Must be in the past or present. Set to null to clear the anchor and revert to start-time-based anchoring.
|
|
99
|
+
*/
|
|
100
|
+
billingAnchor?: Date | null | undefined;
|
|
97
101
|
};
|
|
98
102
|
|
|
99
103
|
export type UpdatePlanRequest = {
|
|
@@ -132,6 +136,7 @@ export type UpdatePlanRequestBody$Outbound = {
|
|
|
132
136
|
taxBehavior?: string | undefined;
|
|
133
137
|
renewalReminderEnabled?: boolean | undefined;
|
|
134
138
|
renewalReminderDays?: number | undefined;
|
|
139
|
+
billingAnchor?: string | null | undefined;
|
|
135
140
|
};
|
|
136
141
|
|
|
137
142
|
/** @internal */
|
|
@@ -151,6 +156,8 @@ export const UpdatePlanRequestBody$outboundSchema: z.ZodType<
|
|
|
151
156
|
taxBehavior: UpdatePlanTaxBehavior$outboundSchema.optional(),
|
|
152
157
|
renewalReminderEnabled: z.boolean().optional(),
|
|
153
158
|
renewalReminderDays: z.number().int().optional(),
|
|
159
|
+
billingAnchor: z.nullable(z.date().transform(v => v.toISOString()))
|
|
160
|
+
.optional(),
|
|
154
161
|
});
|
|
155
162
|
|
|
156
163
|
export function updatePlanRequestBodyToJSON(
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
|
+
import { ClosedEnum } from "../types/enums.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
9
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
10
|
+
|
|
11
|
+
export const PaymentSessionObject = {
|
|
12
|
+
PaymentSession: "payment_session",
|
|
13
|
+
} as const;
|
|
14
|
+
export type PaymentSessionObject = ClosedEnum<typeof PaymentSessionObject>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Lifecycle status of the session.
|
|
18
|
+
*/
|
|
19
|
+
export const PaymentSessionStatus = {
|
|
20
|
+
Pending: "pending",
|
|
21
|
+
Processing: "processing",
|
|
22
|
+
Completed: "completed",
|
|
23
|
+
Failed: "failed",
|
|
24
|
+
Expired: "expired",
|
|
25
|
+
Cancelled: "cancelled",
|
|
26
|
+
} as const;
|
|
27
|
+
/**
|
|
28
|
+
* Lifecycle status of the session.
|
|
29
|
+
*/
|
|
30
|
+
export type PaymentSessionStatus = ClosedEnum<typeof PaymentSessionStatus>;
|
|
31
|
+
|
|
32
|
+
export type PaymentSession = {
|
|
33
|
+
object: PaymentSessionObject;
|
|
34
|
+
/**
|
|
35
|
+
* Payment session ID (ps_*).
|
|
36
|
+
*/
|
|
37
|
+
id: string;
|
|
38
|
+
/**
|
|
39
|
+
* Type of entity the session pays for (invoice, subscription, payment, topup).
|
|
40
|
+
*/
|
|
41
|
+
entityType: string;
|
|
42
|
+
/**
|
|
43
|
+
* ID of the entity the session pays for.
|
|
44
|
+
*/
|
|
45
|
+
entityId: string;
|
|
46
|
+
/**
|
|
47
|
+
* Amount in decimal dollars.
|
|
48
|
+
*/
|
|
49
|
+
amount: string;
|
|
50
|
+
/**
|
|
51
|
+
* ISO 4217 currency code.
|
|
52
|
+
*/
|
|
53
|
+
currency: string;
|
|
54
|
+
/**
|
|
55
|
+
* Lifecycle status of the session.
|
|
56
|
+
*/
|
|
57
|
+
status: PaymentSessionStatus;
|
|
58
|
+
/**
|
|
59
|
+
* Stripe Connect account ID (acct_*) when the session is routed to a connected account.
|
|
60
|
+
*/
|
|
61
|
+
merchantPaymentAccountId?: string | null | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Timestamp the session reached terminal completion. Null until the session completes.
|
|
64
|
+
*/
|
|
65
|
+
completedAt?: Date | null | undefined;
|
|
66
|
+
createdAt: Date;
|
|
67
|
+
updatedAt: Date;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** @internal */
|
|
71
|
+
export const PaymentSessionObject$inboundSchema: z.ZodNativeEnum<
|
|
72
|
+
typeof PaymentSessionObject
|
|
73
|
+
> = z.nativeEnum(PaymentSessionObject);
|
|
74
|
+
|
|
75
|
+
/** @internal */
|
|
76
|
+
export const PaymentSessionStatus$inboundSchema: z.ZodNativeEnum<
|
|
77
|
+
typeof PaymentSessionStatus
|
|
78
|
+
> = z.nativeEnum(PaymentSessionStatus);
|
|
79
|
+
|
|
80
|
+
/** @internal */
|
|
81
|
+
export const PaymentSession$inboundSchema: z.ZodType<
|
|
82
|
+
PaymentSession,
|
|
83
|
+
z.ZodTypeDef,
|
|
84
|
+
unknown
|
|
85
|
+
> = z.object({
|
|
86
|
+
object: PaymentSessionObject$inboundSchema,
|
|
87
|
+
id: z.string(),
|
|
88
|
+
entityType: z.string(),
|
|
89
|
+
entityId: z.string(),
|
|
90
|
+
amount: z.string(),
|
|
91
|
+
currency: z.string(),
|
|
92
|
+
status: PaymentSessionStatus$inboundSchema,
|
|
93
|
+
merchantPaymentAccountId: z.nullable(z.string()).optional(),
|
|
94
|
+
completedAt: z.nullable(
|
|
95
|
+
z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
96
|
+
).optional(),
|
|
97
|
+
createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
98
|
+
updatedAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export function paymentSessionFromJSON(
|
|
102
|
+
jsonString: string,
|
|
103
|
+
): SafeParseResult<PaymentSession, SDKValidationError> {
|
|
104
|
+
return safeParse(
|
|
105
|
+
jsonString,
|
|
106
|
+
(x) => PaymentSession$inboundSchema.parse(JSON.parse(x)),
|
|
107
|
+
`Failed to parse 'PaymentSession' from JSON`,
|
|
108
|
+
);
|
|
109
|
+
}
|
package/src/models/plan.ts
CHANGED
|
@@ -106,6 +106,10 @@ export type Plan = {
|
|
|
106
106
|
* Billing engine version. Managed by Paygentic support.
|
|
107
107
|
*/
|
|
108
108
|
billingVersion?: number | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* ISO 8601 datetime reference point for billing period alignment. Must be in the past or present at the time of creation or update. When set, all subscriptions created under this plan align their first billing period to the next recurrence of this anchor. Null means each subscription uses its own start time (hour-rounded) as the anchor.
|
|
111
|
+
*/
|
|
112
|
+
billingAnchor?: Date | null | undefined;
|
|
109
113
|
};
|
|
110
114
|
|
|
111
115
|
/** @internal */
|
|
@@ -175,6 +179,9 @@ export const Plan$inboundSchema: z.ZodType<Plan, z.ZodTypeDef, unknown> = z
|
|
|
175
179
|
renewalReminderEnabled: z.boolean().optional(),
|
|
176
180
|
renewalReminderDays: z.number().int().optional(),
|
|
177
181
|
billingVersion: z.number().int().optional(),
|
|
182
|
+
billingAnchor: z.nullable(
|
|
183
|
+
z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
184
|
+
).optional(),
|
|
178
185
|
});
|
|
179
186
|
|
|
180
187
|
export function planFromJSON(
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
9
|
+
import {
|
|
10
|
+
ProfitabilityTrend,
|
|
11
|
+
ProfitabilityTrend$inboundSchema,
|
|
12
|
+
} from "./profitabilitytrend.js";
|
|
13
|
+
|
|
14
|
+
export type ProfitabilityRow = {
|
|
15
|
+
/**
|
|
16
|
+
* Customer ID, or the literal 'other' for the overflow row.
|
|
17
|
+
*/
|
|
18
|
+
customerId: string;
|
|
19
|
+
/**
|
|
20
|
+
* Display name for the row. 'Other' for the overflow row.
|
|
21
|
+
*/
|
|
22
|
+
customerName: string;
|
|
23
|
+
/**
|
|
24
|
+
* Net revenue (paid + outstanding) in unit currency, with two decimals.
|
|
25
|
+
*/
|
|
26
|
+
netRevenue: string;
|
|
27
|
+
/**
|
|
28
|
+
* Aggregated cost in unit currency, with two decimals.
|
|
29
|
+
*/
|
|
30
|
+
totalCost: string;
|
|
31
|
+
/**
|
|
32
|
+
* Profit (revenue − cost) in unit currency, with two decimals. May be negative.
|
|
33
|
+
*/
|
|
34
|
+
profit: string;
|
|
35
|
+
/**
|
|
36
|
+
* Margin percent (profit / revenue × 100), with two decimals. Null when revenue is zero.
|
|
37
|
+
*/
|
|
38
|
+
marginPct: string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Per-customer revenue trend over the period. Null for the 'Other' row and when there's insufficient data.
|
|
41
|
+
*/
|
|
42
|
+
trend: ProfitabilityTrend | null;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** @internal */
|
|
46
|
+
export const ProfitabilityRow$inboundSchema: z.ZodType<
|
|
47
|
+
ProfitabilityRow,
|
|
48
|
+
z.ZodTypeDef,
|
|
49
|
+
unknown
|
|
50
|
+
> = z.object({
|
|
51
|
+
customerId: z.string(),
|
|
52
|
+
customerName: z.string(),
|
|
53
|
+
netRevenue: z.string(),
|
|
54
|
+
totalCost: z.string(),
|
|
55
|
+
profit: z.string(),
|
|
56
|
+
marginPct: z.nullable(z.string()),
|
|
57
|
+
trend: z.nullable(ProfitabilityTrend$inboundSchema),
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export function profitabilityRowFromJSON(
|
|
61
|
+
jsonString: string,
|
|
62
|
+
): SafeParseResult<ProfitabilityRow, SDKValidationError> {
|
|
63
|
+
return safeParse(
|
|
64
|
+
jsonString,
|
|
65
|
+
(x) => ProfitabilityRow$inboundSchema.parse(JSON.parse(x)),
|
|
66
|
+
`Failed to parse 'ProfitabilityRow' from JSON`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
9
|
+
import {
|
|
10
|
+
ProfitabilityRow,
|
|
11
|
+
ProfitabilityRow$inboundSchema,
|
|
12
|
+
} from "./profitabilityrow.js";
|
|
13
|
+
|
|
14
|
+
export type ProfitabilitySummaryResponse = {
|
|
15
|
+
/**
|
|
16
|
+
* Object type identifier
|
|
17
|
+
*/
|
|
18
|
+
object: "profitability_summary";
|
|
19
|
+
/**
|
|
20
|
+
* ISO 4217 currency code applied to revenue and cost values
|
|
21
|
+
*/
|
|
22
|
+
currency: string;
|
|
23
|
+
/**
|
|
24
|
+
* Top-N customer rows by profit descending, optionally followed by a single 'Other' row when more than topN customers contributed.
|
|
25
|
+
*/
|
|
26
|
+
rows: Array<ProfitabilityRow>;
|
|
27
|
+
/**
|
|
28
|
+
* Non-fatal warnings collected during cost discovery (e.g. an individual cost query failed). Empty array on a clean run.
|
|
29
|
+
*/
|
|
30
|
+
warnings?: Array<string> | undefined;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** @internal */
|
|
34
|
+
export const ProfitabilitySummaryResponse$inboundSchema: z.ZodType<
|
|
35
|
+
ProfitabilitySummaryResponse,
|
|
36
|
+
z.ZodTypeDef,
|
|
37
|
+
unknown
|
|
38
|
+
> = z.object({
|
|
39
|
+
object: z.literal("profitability_summary"),
|
|
40
|
+
currency: z.string(),
|
|
41
|
+
rows: z.array(ProfitabilityRow$inboundSchema),
|
|
42
|
+
warnings: z.array(z.string()).optional(),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export function profitabilitySummaryResponseFromJSON(
|
|
46
|
+
jsonString: string,
|
|
47
|
+
): SafeParseResult<ProfitabilitySummaryResponse, SDKValidationError> {
|
|
48
|
+
return safeParse(
|
|
49
|
+
jsonString,
|
|
50
|
+
(x) => ProfitabilitySummaryResponse$inboundSchema.parse(JSON.parse(x)),
|
|
51
|
+
`Failed to parse 'ProfitabilitySummaryResponse' from JSON`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
9
|
+
|
|
10
|
+
export type ProfitabilityTrend = {
|
|
11
|
+
/**
|
|
12
|
+
* Revenue values per time bucket, oldest first, in unit currency with two decimals.
|
|
13
|
+
*/
|
|
14
|
+
values: Array<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Period-over-period % change (current half vs prior half). Null when prior is zero.
|
|
17
|
+
*/
|
|
18
|
+
periodChange: number | null;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** @internal */
|
|
22
|
+
export const ProfitabilityTrend$inboundSchema: z.ZodType<
|
|
23
|
+
ProfitabilityTrend,
|
|
24
|
+
z.ZodTypeDef,
|
|
25
|
+
unknown
|
|
26
|
+
> = z.object({
|
|
27
|
+
values: z.array(z.string()),
|
|
28
|
+
periodChange: z.nullable(z.number()),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export function profitabilityTrendFromJSON(
|
|
32
|
+
jsonString: string,
|
|
33
|
+
): SafeParseResult<ProfitabilityTrend, SDKValidationError> {
|
|
34
|
+
return safeParse(
|
|
35
|
+
jsonString,
|
|
36
|
+
(x) => ProfitabilityTrend$inboundSchema.parse(JSON.parse(x)),
|
|
37
|
+
`Failed to parse 'ProfitabilityTrend' from JSON`,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -15,7 +15,7 @@ export type PurchaseGrantResponseObject = ClosedEnum<
|
|
|
15
15
|
typeof PurchaseGrantResponseObject
|
|
16
16
|
>;
|
|
17
17
|
|
|
18
|
-
export type
|
|
18
|
+
export type PurchaseGrantResponsePaymentSession = {
|
|
19
19
|
/**
|
|
20
20
|
* The Stripe checkout URL for the customer to complete payment.
|
|
21
21
|
*/
|
|
@@ -55,7 +55,7 @@ export type PurchaseGrantResponse = {
|
|
|
55
55
|
/**
|
|
56
56
|
* Payment session(s) for the customer to complete the purchase.
|
|
57
57
|
*/
|
|
58
|
-
paymentSessions: Array<
|
|
58
|
+
paymentSessions: Array<PurchaseGrantResponsePaymentSession>;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
/** @internal */
|
|
@@ -64,8 +64,8 @@ export const PurchaseGrantResponseObject$inboundSchema: z.ZodNativeEnum<
|
|
|
64
64
|
> = z.nativeEnum(PurchaseGrantResponseObject);
|
|
65
65
|
|
|
66
66
|
/** @internal */
|
|
67
|
-
export const
|
|
68
|
-
|
|
67
|
+
export const PurchaseGrantResponsePaymentSession$inboundSchema: z.ZodType<
|
|
68
|
+
PurchaseGrantResponsePaymentSession,
|
|
69
69
|
z.ZodTypeDef,
|
|
70
70
|
unknown
|
|
71
71
|
> = z.object({
|
|
@@ -76,13 +76,14 @@ export const PaymentSession$inboundSchema: z.ZodType<
|
|
|
76
76
|
amount: z.number().optional(),
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
export function
|
|
79
|
+
export function purchaseGrantResponsePaymentSessionFromJSON(
|
|
80
80
|
jsonString: string,
|
|
81
|
-
): SafeParseResult<
|
|
81
|
+
): SafeParseResult<PurchaseGrantResponsePaymentSession, SDKValidationError> {
|
|
82
82
|
return safeParse(
|
|
83
83
|
jsonString,
|
|
84
|
-
(x) =>
|
|
85
|
-
|
|
84
|
+
(x) =>
|
|
85
|
+
PurchaseGrantResponsePaymentSession$inboundSchema.parse(JSON.parse(x)),
|
|
86
|
+
`Failed to parse 'PurchaseGrantResponsePaymentSession' from JSON`,
|
|
86
87
|
);
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -98,7 +99,9 @@ export const PurchaseGrantResponse$inboundSchema: z.ZodType<
|
|
|
98
99
|
grantAmount: z.number().int(),
|
|
99
100
|
price: z.string(),
|
|
100
101
|
currency: z.string(),
|
|
101
|
-
paymentSessions: z.array(
|
|
102
|
+
paymentSessions: z.array(
|
|
103
|
+
z.lazy(() => PurchaseGrantResponsePaymentSession$inboundSchema),
|
|
104
|
+
),
|
|
102
105
|
});
|
|
103
106
|
|
|
104
107
|
export function purchaseGrantResponseFromJSON(
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { paymentSessionsListPaymentSessions } from "../funcs/paymentSessionsListPaymentSessions.js";
|
|
6
|
+
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
7
|
+
import * as operations from "../models/operations/index.js";
|
|
8
|
+
import { unwrapAsync } from "../types/fp.js";
|
|
9
|
+
|
|
10
|
+
export class PaymentSessions extends ClientSDK {
|
|
11
|
+
/**
|
|
12
|
+
* List
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* List payment sessions for the authenticated merchant with optional filters. Supports filtering by subscriptionId, customerId, status, and entityType. When subscriptionId is provided the result includes both the subscription's own activation session (entityType='subscription') and any session attached to invoices for that subscription (entityType='invoice').
|
|
16
|
+
*/
|
|
17
|
+
async listPaymentSessions(
|
|
18
|
+
request?: operations.ListPaymentSessionsRequest | undefined,
|
|
19
|
+
options?: RequestOptions,
|
|
20
|
+
): Promise<operations.ListPaymentSessionsResponse> {
|
|
21
|
+
return unwrapAsync(paymentSessionsListPaymentSessions(
|
|
22
|
+
this,
|
|
23
|
+
request,
|
|
24
|
+
options,
|
|
25
|
+
));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { profitabilityGetProfitability } from "../funcs/profitabilityGetProfitability.js";
|
|
6
|
+
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
7
|
+
import * as models from "../models/index.js";
|
|
8
|
+
import * as operations from "../models/operations/index.js";
|
|
9
|
+
import { unwrapAsync } from "../types/fp.js";
|
|
10
|
+
|
|
11
|
+
export class Profitability extends ClientSDK {
|
|
12
|
+
/**
|
|
13
|
+
* Get profitability summary
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Returns a per-customer profitability summary for a merchant over a date range. Each row aggregates revenue (from issued + paid invoices), cost (from metered cost discovery), profit, and margin. Customers are ranked by profit descending and capped at topN; the remainder is rolled into a single self-consistent 'Other' row whose revenue, cost, and profit reflect the same set of customers. Rows are inner-joined against the merchant's customer list, so orphaned meter subjects from deleted or unknown customers are dropped.
|
|
17
|
+
*/
|
|
18
|
+
async getProfitability(
|
|
19
|
+
request: operations.GetProfitabilityRequest,
|
|
20
|
+
options?: RequestOptions,
|
|
21
|
+
): Promise<models.ProfitabilitySummaryResponse> {
|
|
22
|
+
return unwrapAsync(profitabilityGetProfitability(
|
|
23
|
+
this,
|
|
24
|
+
request,
|
|
25
|
+
options,
|
|
26
|
+
));
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/sdk/sdk.ts
CHANGED
|
@@ -12,9 +12,11 @@ import { Features } from "./features.js";
|
|
|
12
12
|
import { Fees } from "./fees.js";
|
|
13
13
|
import { InvoicesV2 } from "./invoicesv2.js";
|
|
14
14
|
import { Payments } from "./payments.js";
|
|
15
|
+
import { PaymentSessions } from "./paymentsessions.js";
|
|
15
16
|
import { Plans } from "./plans.js";
|
|
16
17
|
import { Prices } from "./prices.js";
|
|
17
18
|
import { Products } from "./products.js";
|
|
19
|
+
import { Profitability } from "./profitability.js";
|
|
18
20
|
import { Revenue } from "./revenue.js";
|
|
19
21
|
import { Sources } from "./sources.js";
|
|
20
22
|
import { Subscriptions } from "./subscriptions.js";
|
|
@@ -87,6 +89,11 @@ export class Paygentic extends ClientSDK {
|
|
|
87
89
|
return (this._payments ??= new Payments(this._options));
|
|
88
90
|
}
|
|
89
91
|
|
|
92
|
+
private _paymentSessions?: PaymentSessions;
|
|
93
|
+
get paymentSessions(): PaymentSessions {
|
|
94
|
+
return (this._paymentSessions ??= new PaymentSessions(this._options));
|
|
95
|
+
}
|
|
96
|
+
|
|
90
97
|
private _events?: Events;
|
|
91
98
|
get events(): Events {
|
|
92
99
|
return (this._events ??= new Events(this._options));
|
|
@@ -102,6 +109,11 @@ export class Paygentic extends ClientSDK {
|
|
|
102
109
|
return (this._revenue ??= new Revenue(this._options));
|
|
103
110
|
}
|
|
104
111
|
|
|
112
|
+
private _profitability?: Profitability;
|
|
113
|
+
get profitability(): Profitability {
|
|
114
|
+
return (this._profitability ??= new Profitability(this._options));
|
|
115
|
+
}
|
|
116
|
+
|
|
105
117
|
private _testClocks?: TestClocks;
|
|
106
118
|
get testClocks(): TestClocks {
|
|
107
119
|
return (this._testClocks ??= new TestClocks(this._options));
|