@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.
Files changed (193) hide show
  1. package/README.md +13 -3
  2. package/dist/commonjs/funcs/invoicesV2List.js +1 -0
  3. package/dist/commonjs/funcs/invoicesV2List.js.map +1 -1
  4. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.d.ts +18 -0
  5. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.d.ts.map +1 -0
  6. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.js +127 -0
  7. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.js.map +1 -0
  8. package/dist/commonjs/funcs/profitabilityGetProfitability.d.ts +19 -0
  9. package/dist/commonjs/funcs/profitabilityGetProfitability.d.ts.map +1 -0
  10. package/dist/commonjs/funcs/profitabilityGetProfitability.js +127 -0
  11. package/dist/commonjs/funcs/profitabilityGetProfitability.js.map +1 -0
  12. package/dist/commonjs/lib/config.d.ts +2 -2
  13. package/dist/commonjs/lib/config.js +2 -2
  14. package/dist/commonjs/models/index.d.ts +4 -0
  15. package/dist/commonjs/models/index.d.ts.map +1 -1
  16. package/dist/commonjs/models/index.js +4 -0
  17. package/dist/commonjs/models/index.js.map +1 -1
  18. package/dist/commonjs/models/offsetpagination.d.ts +4 -4
  19. package/dist/commonjs/models/offsetpagination.d.ts.map +1 -1
  20. package/dist/commonjs/models/offsetpagination.js +3 -3
  21. package/dist/commonjs/models/offsetpagination.js.map +1 -1
  22. package/dist/commonjs/models/operations/createplan.d.ts +5 -0
  23. package/dist/commonjs/models/operations/createplan.d.ts.map +1 -1
  24. package/dist/commonjs/models/operations/createplan.js +2 -0
  25. package/dist/commonjs/models/operations/createplan.js.map +1 -1
  26. package/dist/commonjs/models/operations/getprofitability.d.ts +55 -0
  27. package/dist/commonjs/models/operations/getprofitability.d.ts.map +1 -0
  28. package/dist/commonjs/models/operations/getprofitability.js +64 -0
  29. package/dist/commonjs/models/operations/getprofitability.js.map +1 -0
  30. package/dist/commonjs/models/operations/getrevenue.d.ts +4 -4
  31. package/dist/commonjs/models/operations/getrevenue.d.ts.map +1 -1
  32. package/dist/commonjs/models/operations/getrevenue.js +4 -5
  33. package/dist/commonjs/models/operations/getrevenue.js.map +1 -1
  34. package/dist/commonjs/models/operations/index.d.ts +2 -0
  35. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  36. package/dist/commonjs/models/operations/index.js +2 -0
  37. package/dist/commonjs/models/operations/index.js.map +1 -1
  38. package/dist/commonjs/models/operations/listinvoices.d.ts +9 -0
  39. package/dist/commonjs/models/operations/listinvoices.d.ts.map +1 -1
  40. package/dist/commonjs/models/operations/listinvoices.js +2 -0
  41. package/dist/commonjs/models/operations/listinvoices.js.map +1 -1
  42. package/dist/commonjs/models/operations/listpaymentsessions.d.ts +36 -10
  43. package/dist/commonjs/models/operations/listpaymentsessions.d.ts.map +1 -1
  44. package/dist/commonjs/models/operations/listpaymentsessions.js +19 -4
  45. package/dist/commonjs/models/operations/listpaymentsessions.js.map +1 -1
  46. package/dist/commonjs/models/operations/updateplan.d.ts +5 -0
  47. package/dist/commonjs/models/operations/updateplan.d.ts.map +1 -1
  48. package/dist/commonjs/models/operations/updateplan.js +2 -0
  49. package/dist/commonjs/models/operations/updateplan.js.map +1 -1
  50. package/dist/commonjs/models/paymentsession.d.ts +68 -0
  51. package/dist/commonjs/models/paymentsession.d.ts.map +1 -0
  52. package/dist/commonjs/models/paymentsession.js +78 -0
  53. package/dist/commonjs/models/paymentsession.js.map +1 -0
  54. package/dist/commonjs/models/plan.d.ts +4 -0
  55. package/dist/commonjs/models/plan.d.ts.map +1 -1
  56. package/dist/commonjs/models/plan.js +1 -0
  57. package/dist/commonjs/models/plan.js.map +1 -1
  58. package/dist/commonjs/models/profitabilityrow.d.ts +38 -0
  59. package/dist/commonjs/models/profitabilityrow.d.ts.map +1 -0
  60. package/dist/commonjs/models/profitabilityrow.js +57 -0
  61. package/dist/commonjs/models/profitabilityrow.js.map +1 -0
  62. package/dist/commonjs/models/profitabilitysummaryresponse.d.ts +26 -0
  63. package/dist/commonjs/models/profitabilitysummaryresponse.d.ts.map +1 -0
  64. package/dist/commonjs/models/profitabilitysummaryresponse.js +54 -0
  65. package/dist/commonjs/models/profitabilitysummaryresponse.js.map +1 -0
  66. package/dist/commonjs/models/profitabilitytrend.d.ts +17 -0
  67. package/dist/commonjs/models/profitabilitytrend.d.ts.map +1 -0
  68. package/dist/commonjs/models/profitabilitytrend.js +51 -0
  69. package/dist/commonjs/models/profitabilitytrend.js.map +1 -0
  70. package/dist/commonjs/models/purchasegrantresponse.d.ts +4 -4
  71. package/dist/commonjs/models/purchasegrantresponse.d.ts.map +1 -1
  72. package/dist/commonjs/models/purchasegrantresponse.js +6 -6
  73. package/dist/commonjs/models/purchasegrantresponse.js.map +1 -1
  74. package/dist/commonjs/sdk/paymentsessions.d.ts +12 -0
  75. package/dist/commonjs/sdk/paymentsessions.d.ts.map +1 -0
  76. package/dist/commonjs/sdk/paymentsessions.js +22 -0
  77. package/dist/commonjs/sdk/paymentsessions.js.map +1 -0
  78. package/dist/commonjs/sdk/profitability.d.ts +13 -0
  79. package/dist/commonjs/sdk/profitability.d.ts.map +1 -0
  80. package/dist/commonjs/sdk/profitability.js +22 -0
  81. package/dist/commonjs/sdk/profitability.js.map +1 -0
  82. package/dist/commonjs/sdk/sdk.d.ts +6 -0
  83. package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
  84. package/dist/commonjs/sdk/sdk.js +8 -0
  85. package/dist/commonjs/sdk/sdk.js.map +1 -1
  86. package/dist/esm/funcs/invoicesV2List.js +1 -0
  87. package/dist/esm/funcs/invoicesV2List.js.map +1 -1
  88. package/dist/esm/funcs/paymentSessionsListPaymentSessions.d.ts +18 -0
  89. package/dist/esm/funcs/paymentSessionsListPaymentSessions.d.ts.map +1 -0
  90. package/dist/esm/funcs/paymentSessionsListPaymentSessions.js +91 -0
  91. package/dist/esm/funcs/paymentSessionsListPaymentSessions.js.map +1 -0
  92. package/dist/esm/funcs/profitabilityGetProfitability.d.ts +19 -0
  93. package/dist/esm/funcs/profitabilityGetProfitability.d.ts.map +1 -0
  94. package/dist/esm/funcs/profitabilityGetProfitability.js +91 -0
  95. package/dist/esm/funcs/profitabilityGetProfitability.js.map +1 -0
  96. package/dist/esm/lib/config.d.ts +2 -2
  97. package/dist/esm/lib/config.js +2 -2
  98. package/dist/esm/models/index.d.ts +4 -0
  99. package/dist/esm/models/index.d.ts.map +1 -1
  100. package/dist/esm/models/index.js +4 -0
  101. package/dist/esm/models/index.js.map +1 -1
  102. package/dist/esm/models/offsetpagination.d.ts +4 -4
  103. package/dist/esm/models/offsetpagination.d.ts.map +1 -1
  104. package/dist/esm/models/offsetpagination.js +3 -3
  105. package/dist/esm/models/offsetpagination.js.map +1 -1
  106. package/dist/esm/models/operations/createplan.d.ts +5 -0
  107. package/dist/esm/models/operations/createplan.d.ts.map +1 -1
  108. package/dist/esm/models/operations/createplan.js +2 -0
  109. package/dist/esm/models/operations/createplan.js.map +1 -1
  110. package/dist/esm/models/operations/getprofitability.d.ts +55 -0
  111. package/dist/esm/models/operations/getprofitability.d.ts.map +1 -0
  112. package/dist/esm/models/operations/getprofitability.js +27 -0
  113. package/dist/esm/models/operations/getprofitability.js.map +1 -0
  114. package/dist/esm/models/operations/getrevenue.d.ts +4 -4
  115. package/dist/esm/models/operations/getrevenue.d.ts.map +1 -1
  116. package/dist/esm/models/operations/getrevenue.js +3 -4
  117. package/dist/esm/models/operations/getrevenue.js.map +1 -1
  118. package/dist/esm/models/operations/index.d.ts +2 -0
  119. package/dist/esm/models/operations/index.d.ts.map +1 -1
  120. package/dist/esm/models/operations/index.js +2 -0
  121. package/dist/esm/models/operations/index.js.map +1 -1
  122. package/dist/esm/models/operations/listinvoices.d.ts +9 -0
  123. package/dist/esm/models/operations/listinvoices.d.ts.map +1 -1
  124. package/dist/esm/models/operations/listinvoices.js +2 -0
  125. package/dist/esm/models/operations/listinvoices.js.map +1 -1
  126. package/dist/esm/models/operations/listpaymentsessions.d.ts +36 -10
  127. package/dist/esm/models/operations/listpaymentsessions.d.ts.map +1 -1
  128. package/dist/esm/models/operations/listpaymentsessions.js +18 -3
  129. package/dist/esm/models/operations/listpaymentsessions.js.map +1 -1
  130. package/dist/esm/models/operations/updateplan.d.ts +5 -0
  131. package/dist/esm/models/operations/updateplan.d.ts.map +1 -1
  132. package/dist/esm/models/operations/updateplan.js +2 -0
  133. package/dist/esm/models/operations/updateplan.js.map +1 -1
  134. package/dist/esm/models/paymentsession.d.ts +68 -0
  135. package/dist/esm/models/paymentsession.d.ts.map +1 -0
  136. package/dist/esm/models/paymentsession.js +41 -0
  137. package/dist/esm/models/paymentsession.js.map +1 -0
  138. package/dist/esm/models/plan.d.ts +4 -0
  139. package/dist/esm/models/plan.d.ts.map +1 -1
  140. package/dist/esm/models/plan.js +1 -0
  141. package/dist/esm/models/plan.js.map +1 -1
  142. package/dist/esm/models/profitabilityrow.d.ts +38 -0
  143. package/dist/esm/models/profitabilityrow.d.ts.map +1 -0
  144. package/dist/esm/models/profitabilityrow.js +20 -0
  145. package/dist/esm/models/profitabilityrow.js.map +1 -0
  146. package/dist/esm/models/profitabilitysummaryresponse.d.ts +26 -0
  147. package/dist/esm/models/profitabilitysummaryresponse.d.ts.map +1 -0
  148. package/dist/esm/models/profitabilitysummaryresponse.js +17 -0
  149. package/dist/esm/models/profitabilitysummaryresponse.js.map +1 -0
  150. package/dist/esm/models/profitabilitytrend.d.ts +17 -0
  151. package/dist/esm/models/profitabilitytrend.d.ts.map +1 -0
  152. package/dist/esm/models/profitabilitytrend.js +14 -0
  153. package/dist/esm/models/profitabilitytrend.js.map +1 -0
  154. package/dist/esm/models/purchasegrantresponse.d.ts +4 -4
  155. package/dist/esm/models/purchasegrantresponse.d.ts.map +1 -1
  156. package/dist/esm/models/purchasegrantresponse.js +4 -4
  157. package/dist/esm/models/purchasegrantresponse.js.map +1 -1
  158. package/dist/esm/sdk/paymentsessions.d.ts +12 -0
  159. package/dist/esm/sdk/paymentsessions.d.ts.map +1 -0
  160. package/dist/esm/sdk/paymentsessions.js +18 -0
  161. package/dist/esm/sdk/paymentsessions.js.map +1 -0
  162. package/dist/esm/sdk/profitability.d.ts +13 -0
  163. package/dist/esm/sdk/profitability.d.ts.map +1 -0
  164. package/dist/esm/sdk/profitability.js +18 -0
  165. package/dist/esm/sdk/profitability.js.map +1 -0
  166. package/dist/esm/sdk/sdk.d.ts +6 -0
  167. package/dist/esm/sdk/sdk.d.ts.map +1 -1
  168. package/dist/esm/sdk/sdk.js +8 -0
  169. package/dist/esm/sdk/sdk.js.map +1 -1
  170. package/jsr.json +1 -1
  171. package/package.json +1 -1
  172. package/src/funcs/invoicesV2List.ts +1 -0
  173. package/src/funcs/paymentSessionsListPaymentSessions.ts +183 -0
  174. package/src/funcs/profitabilityGetProfitability.ts +184 -0
  175. package/src/lib/config.ts +2 -2
  176. package/src/models/index.ts +4 -0
  177. package/src/models/offsetpagination.ts +7 -7
  178. package/src/models/operations/createplan.ts +7 -0
  179. package/src/models/operations/getprofitability.ts +85 -0
  180. package/src/models/operations/getrevenue.ts +7 -6
  181. package/src/models/operations/index.ts +2 -0
  182. package/src/models/operations/listinvoices.ts +11 -0
  183. package/src/models/operations/listpaymentsessions.ts +43 -12
  184. package/src/models/operations/updateplan.ts +7 -0
  185. package/src/models/paymentsession.ts +109 -0
  186. package/src/models/plan.ts +7 -0
  187. package/src/models/profitabilityrow.ts +68 -0
  188. package/src/models/profitabilitysummaryresponse.ts +53 -0
  189. package/src/models/profitabilitytrend.ts +39 -0
  190. package/src/models/purchasegrantresponse.ts +12 -9
  191. package/src/sdk/paymentsessions.ts +27 -0
  192. package/src/sdk/profitability.ts +28 -0
  193. 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 by payment status.
50
+ * Filter to sessions linked to this subscription (its own activation session plus all of its invoices' sessions).
36
51
  */
37
- status?: ListPaymentSessionsStatus | undefined;
52
+ subscriptionId?: string | undefined;
38
53
  /**
39
- * Filter by customer ID.
54
+ * Filter to sessions linked to a payment for this customer.
40
55
  */
41
56
  customerId?: string | undefined;
42
57
  /**
43
- * Number of payments to return.
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 payments to skip.
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 payments
83
+ * List of payment sessions
61
84
  */
62
85
  export type ListPaymentSessionsResponse = {
63
86
  object: ListPaymentSessionsObject;
64
- data: Array<models.Payment>;
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
- status?: string | undefined;
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
- status: ListPaymentSessionsStatus$outboundSchema.optional(),
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.Payment$inboundSchema),
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
+ }
@@ -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 PaymentSession = {
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<PaymentSession>;
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 PaymentSession$inboundSchema: z.ZodType<
68
- PaymentSession,
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 paymentSessionFromJSON(
79
+ export function purchaseGrantResponsePaymentSessionFromJSON(
80
80
  jsonString: string,
81
- ): SafeParseResult<PaymentSession, SDKValidationError> {
81
+ ): SafeParseResult<PurchaseGrantResponsePaymentSession, SDKValidationError> {
82
82
  return safeParse(
83
83
  jsonString,
84
- (x) => PaymentSession$inboundSchema.parse(JSON.parse(x)),
85
- `Failed to parse 'PaymentSession' from JSON`,
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(z.lazy(() => PaymentSession$inboundSchema)),
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));