@paygentic/sdk 0.7.1 → 0.7.3

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 (256) hide show
  1. package/README.md +17 -3
  2. package/dist/commonjs/funcs/customersCreateCustomerPaymentMethod.d.ts +19 -0
  3. package/dist/commonjs/funcs/customersCreateCustomerPaymentMethod.d.ts.map +1 -0
  4. package/dist/commonjs/funcs/customersCreateCustomerPaymentMethod.js +125 -0
  5. package/dist/commonjs/funcs/customersCreateCustomerPaymentMethod.js.map +1 -0
  6. package/dist/commonjs/funcs/customersListCustomerPaymentMethods.d.ts +18 -0
  7. package/dist/commonjs/funcs/customersListCustomerPaymentMethods.d.ts.map +1 -0
  8. package/dist/commonjs/funcs/customersListCustomerPaymentMethods.js +123 -0
  9. package/dist/commonjs/funcs/customersListCustomerPaymentMethods.js.map +1 -0
  10. package/dist/commonjs/funcs/invoicesV2List.js +1 -0
  11. package/dist/commonjs/funcs/invoicesV2List.js.map +1 -1
  12. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.d.ts +18 -0
  13. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.d.ts.map +1 -0
  14. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.js +127 -0
  15. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.js.map +1 -0
  16. package/dist/commonjs/funcs/profitabilityGetProfitability.d.ts +19 -0
  17. package/dist/commonjs/funcs/profitabilityGetProfitability.d.ts.map +1 -0
  18. package/dist/commonjs/funcs/profitabilityGetProfitability.js +127 -0
  19. package/dist/commonjs/funcs/profitabilityGetProfitability.js.map +1 -0
  20. package/dist/commonjs/lib/config.d.ts +2 -2
  21. package/dist/commonjs/lib/config.js +2 -2
  22. package/dist/commonjs/models/index.d.ts +6 -0
  23. package/dist/commonjs/models/index.d.ts.map +1 -1
  24. package/dist/commonjs/models/index.js +6 -0
  25. package/dist/commonjs/models/index.js.map +1 -1
  26. package/dist/commonjs/models/offsetpagination.d.ts +4 -4
  27. package/dist/commonjs/models/offsetpagination.d.ts.map +1 -1
  28. package/dist/commonjs/models/offsetpagination.js +3 -3
  29. package/dist/commonjs/models/offsetpagination.js.map +1 -1
  30. package/dist/commonjs/models/operations/createcustomerpaymentmethod.d.ts +44 -0
  31. package/dist/commonjs/models/operations/createcustomerpaymentmethod.d.ts.map +1 -0
  32. package/dist/commonjs/models/operations/createcustomerpaymentmethod.js +65 -0
  33. package/dist/commonjs/models/operations/createcustomerpaymentmethod.js.map +1 -0
  34. package/dist/commonjs/models/operations/createplan.d.ts +5 -0
  35. package/dist/commonjs/models/operations/createplan.d.ts.map +1 -1
  36. package/dist/commonjs/models/operations/createplan.js +2 -0
  37. package/dist/commonjs/models/operations/createplan.js.map +1 -1
  38. package/dist/commonjs/models/operations/getprofitability.d.ts +55 -0
  39. package/dist/commonjs/models/operations/getprofitability.d.ts.map +1 -0
  40. package/dist/commonjs/models/operations/getprofitability.js +64 -0
  41. package/dist/commonjs/models/operations/getprofitability.js.map +1 -0
  42. package/dist/commonjs/models/operations/getrevenue.d.ts +4 -4
  43. package/dist/commonjs/models/operations/getrevenue.d.ts.map +1 -1
  44. package/dist/commonjs/models/operations/getrevenue.js +4 -5
  45. package/dist/commonjs/models/operations/getrevenue.js.map +1 -1
  46. package/dist/commonjs/models/operations/index.d.ts +4 -0
  47. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  48. package/dist/commonjs/models/operations/index.js +4 -0
  49. package/dist/commonjs/models/operations/index.js.map +1 -1
  50. package/dist/commonjs/models/operations/listcustomerpaymentmethods.d.ts +35 -0
  51. package/dist/commonjs/models/operations/listcustomerpaymentmethods.d.ts.map +1 -0
  52. package/dist/commonjs/models/operations/listcustomerpaymentmethods.js +65 -0
  53. package/dist/commonjs/models/operations/listcustomerpaymentmethods.js.map +1 -0
  54. package/dist/commonjs/models/operations/listinvoices.d.ts +9 -0
  55. package/dist/commonjs/models/operations/listinvoices.d.ts.map +1 -1
  56. package/dist/commonjs/models/operations/listinvoices.js +2 -0
  57. package/dist/commonjs/models/operations/listinvoices.js.map +1 -1
  58. package/dist/commonjs/models/operations/listpaymentsessions.d.ts +36 -10
  59. package/dist/commonjs/models/operations/listpaymentsessions.d.ts.map +1 -1
  60. package/dist/commonjs/models/operations/listpaymentsessions.js +19 -4
  61. package/dist/commonjs/models/operations/listpaymentsessions.js.map +1 -1
  62. package/dist/commonjs/models/operations/updateplan.d.ts +5 -0
  63. package/dist/commonjs/models/operations/updateplan.d.ts.map +1 -1
  64. package/dist/commonjs/models/operations/updateplan.js +2 -0
  65. package/dist/commonjs/models/operations/updateplan.js.map +1 -1
  66. package/dist/commonjs/models/paymentmethod.d.ts +30 -0
  67. package/dist/commonjs/models/paymentmethod.d.ts.map +1 -0
  68. package/dist/commonjs/models/paymentmethod.js +62 -0
  69. package/dist/commonjs/models/paymentmethod.js.map +1 -0
  70. package/dist/commonjs/models/paymentsession.d.ts +53 -0
  71. package/dist/commonjs/models/paymentsession.d.ts.map +1 -0
  72. package/dist/commonjs/models/paymentsession.js +81 -0
  73. package/dist/commonjs/models/paymentsession.js.map +1 -0
  74. package/dist/commonjs/models/plan.d.ts +4 -0
  75. package/dist/commonjs/models/plan.d.ts.map +1 -1
  76. package/dist/commonjs/models/plan.js +1 -0
  77. package/dist/commonjs/models/plan.js.map +1 -1
  78. package/dist/commonjs/models/profitabilityrow.d.ts +38 -0
  79. package/dist/commonjs/models/profitabilityrow.d.ts.map +1 -0
  80. package/dist/commonjs/models/profitabilityrow.js +57 -0
  81. package/dist/commonjs/models/profitabilityrow.js.map +1 -0
  82. package/dist/commonjs/models/profitabilitysummaryresponse.d.ts +26 -0
  83. package/dist/commonjs/models/profitabilitysummaryresponse.d.ts.map +1 -0
  84. package/dist/commonjs/models/profitabilitysummaryresponse.js +54 -0
  85. package/dist/commonjs/models/profitabilitysummaryresponse.js.map +1 -0
  86. package/dist/commonjs/models/profitabilitytrend.d.ts +17 -0
  87. package/dist/commonjs/models/profitabilitytrend.d.ts.map +1 -0
  88. package/dist/commonjs/models/profitabilitytrend.js +51 -0
  89. package/dist/commonjs/models/profitabilitytrend.js.map +1 -0
  90. package/dist/commonjs/models/purchasegrantresponse.d.ts +4 -4
  91. package/dist/commonjs/models/purchasegrantresponse.d.ts.map +1 -1
  92. package/dist/commonjs/models/purchasegrantresponse.js +6 -6
  93. package/dist/commonjs/models/purchasegrantresponse.js.map +1 -1
  94. package/dist/commonjs/models/schemaspaymentsession.d.ts +68 -0
  95. package/dist/commonjs/models/schemaspaymentsession.d.ts.map +1 -0
  96. package/dist/commonjs/models/schemaspaymentsession.js +78 -0
  97. package/dist/commonjs/models/schemaspaymentsession.js.map +1 -0
  98. package/dist/commonjs/sdk/customers.d.ts +14 -0
  99. package/dist/commonjs/sdk/customers.d.ts.map +1 -1
  100. package/dist/commonjs/sdk/customers.js +20 -0
  101. package/dist/commonjs/sdk/customers.js.map +1 -1
  102. package/dist/commonjs/sdk/paymentsessions.d.ts +12 -0
  103. package/dist/commonjs/sdk/paymentsessions.d.ts.map +1 -0
  104. package/dist/commonjs/sdk/paymentsessions.js +22 -0
  105. package/dist/commonjs/sdk/paymentsessions.js.map +1 -0
  106. package/dist/commonjs/sdk/profitability.d.ts +13 -0
  107. package/dist/commonjs/sdk/profitability.d.ts.map +1 -0
  108. package/dist/commonjs/sdk/profitability.js +22 -0
  109. package/dist/commonjs/sdk/profitability.js.map +1 -0
  110. package/dist/commonjs/sdk/sdk.d.ts +6 -0
  111. package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
  112. package/dist/commonjs/sdk/sdk.js +8 -0
  113. package/dist/commonjs/sdk/sdk.js.map +1 -1
  114. package/dist/esm/funcs/customersCreateCustomerPaymentMethod.d.ts +19 -0
  115. package/dist/esm/funcs/customersCreateCustomerPaymentMethod.d.ts.map +1 -0
  116. package/dist/esm/funcs/customersCreateCustomerPaymentMethod.js +89 -0
  117. package/dist/esm/funcs/customersCreateCustomerPaymentMethod.js.map +1 -0
  118. package/dist/esm/funcs/customersListCustomerPaymentMethods.d.ts +18 -0
  119. package/dist/esm/funcs/customersListCustomerPaymentMethods.d.ts.map +1 -0
  120. package/dist/esm/funcs/customersListCustomerPaymentMethods.js +87 -0
  121. package/dist/esm/funcs/customersListCustomerPaymentMethods.js.map +1 -0
  122. package/dist/esm/funcs/invoicesV2List.js +1 -0
  123. package/dist/esm/funcs/invoicesV2List.js.map +1 -1
  124. package/dist/esm/funcs/paymentSessionsListPaymentSessions.d.ts +18 -0
  125. package/dist/esm/funcs/paymentSessionsListPaymentSessions.d.ts.map +1 -0
  126. package/dist/esm/funcs/paymentSessionsListPaymentSessions.js +91 -0
  127. package/dist/esm/funcs/paymentSessionsListPaymentSessions.js.map +1 -0
  128. package/dist/esm/funcs/profitabilityGetProfitability.d.ts +19 -0
  129. package/dist/esm/funcs/profitabilityGetProfitability.d.ts.map +1 -0
  130. package/dist/esm/funcs/profitabilityGetProfitability.js +91 -0
  131. package/dist/esm/funcs/profitabilityGetProfitability.js.map +1 -0
  132. package/dist/esm/lib/config.d.ts +2 -2
  133. package/dist/esm/lib/config.js +2 -2
  134. package/dist/esm/models/index.d.ts +6 -0
  135. package/dist/esm/models/index.d.ts.map +1 -1
  136. package/dist/esm/models/index.js +6 -0
  137. package/dist/esm/models/index.js.map +1 -1
  138. package/dist/esm/models/offsetpagination.d.ts +4 -4
  139. package/dist/esm/models/offsetpagination.d.ts.map +1 -1
  140. package/dist/esm/models/offsetpagination.js +3 -3
  141. package/dist/esm/models/offsetpagination.js.map +1 -1
  142. package/dist/esm/models/operations/createcustomerpaymentmethod.d.ts +44 -0
  143. package/dist/esm/models/operations/createcustomerpaymentmethod.d.ts.map +1 -0
  144. package/dist/esm/models/operations/createcustomerpaymentmethod.js +27 -0
  145. package/dist/esm/models/operations/createcustomerpaymentmethod.js.map +1 -0
  146. package/dist/esm/models/operations/createplan.d.ts +5 -0
  147. package/dist/esm/models/operations/createplan.d.ts.map +1 -1
  148. package/dist/esm/models/operations/createplan.js +2 -0
  149. package/dist/esm/models/operations/createplan.js.map +1 -1
  150. package/dist/esm/models/operations/getprofitability.d.ts +55 -0
  151. package/dist/esm/models/operations/getprofitability.d.ts.map +1 -0
  152. package/dist/esm/models/operations/getprofitability.js +27 -0
  153. package/dist/esm/models/operations/getprofitability.js.map +1 -0
  154. package/dist/esm/models/operations/getrevenue.d.ts +4 -4
  155. package/dist/esm/models/operations/getrevenue.d.ts.map +1 -1
  156. package/dist/esm/models/operations/getrevenue.js +3 -4
  157. package/dist/esm/models/operations/getrevenue.js.map +1 -1
  158. package/dist/esm/models/operations/index.d.ts +4 -0
  159. package/dist/esm/models/operations/index.d.ts.map +1 -1
  160. package/dist/esm/models/operations/index.js +4 -0
  161. package/dist/esm/models/operations/index.js.map +1 -1
  162. package/dist/esm/models/operations/listcustomerpaymentmethods.d.ts +35 -0
  163. package/dist/esm/models/operations/listcustomerpaymentmethods.d.ts.map +1 -0
  164. package/dist/esm/models/operations/listcustomerpaymentmethods.js +27 -0
  165. package/dist/esm/models/operations/listcustomerpaymentmethods.js.map +1 -0
  166. package/dist/esm/models/operations/listinvoices.d.ts +9 -0
  167. package/dist/esm/models/operations/listinvoices.d.ts.map +1 -1
  168. package/dist/esm/models/operations/listinvoices.js +2 -0
  169. package/dist/esm/models/operations/listinvoices.js.map +1 -1
  170. package/dist/esm/models/operations/listpaymentsessions.d.ts +36 -10
  171. package/dist/esm/models/operations/listpaymentsessions.d.ts.map +1 -1
  172. package/dist/esm/models/operations/listpaymentsessions.js +18 -3
  173. package/dist/esm/models/operations/listpaymentsessions.js.map +1 -1
  174. package/dist/esm/models/operations/updateplan.d.ts +5 -0
  175. package/dist/esm/models/operations/updateplan.d.ts.map +1 -1
  176. package/dist/esm/models/operations/updateplan.js +2 -0
  177. package/dist/esm/models/operations/updateplan.js.map +1 -1
  178. package/dist/esm/models/paymentmethod.d.ts +30 -0
  179. package/dist/esm/models/paymentmethod.d.ts.map +1 -0
  180. package/dist/esm/models/paymentmethod.js +25 -0
  181. package/dist/esm/models/paymentmethod.js.map +1 -0
  182. package/dist/esm/models/paymentsession.d.ts +53 -0
  183. package/dist/esm/models/paymentsession.d.ts.map +1 -0
  184. package/dist/esm/models/paymentsession.js +44 -0
  185. package/dist/esm/models/paymentsession.js.map +1 -0
  186. package/dist/esm/models/plan.d.ts +4 -0
  187. package/dist/esm/models/plan.d.ts.map +1 -1
  188. package/dist/esm/models/plan.js +1 -0
  189. package/dist/esm/models/plan.js.map +1 -1
  190. package/dist/esm/models/profitabilityrow.d.ts +38 -0
  191. package/dist/esm/models/profitabilityrow.d.ts.map +1 -0
  192. package/dist/esm/models/profitabilityrow.js +20 -0
  193. package/dist/esm/models/profitabilityrow.js.map +1 -0
  194. package/dist/esm/models/profitabilitysummaryresponse.d.ts +26 -0
  195. package/dist/esm/models/profitabilitysummaryresponse.d.ts.map +1 -0
  196. package/dist/esm/models/profitabilitysummaryresponse.js +17 -0
  197. package/dist/esm/models/profitabilitysummaryresponse.js.map +1 -0
  198. package/dist/esm/models/profitabilitytrend.d.ts +17 -0
  199. package/dist/esm/models/profitabilitytrend.d.ts.map +1 -0
  200. package/dist/esm/models/profitabilitytrend.js +14 -0
  201. package/dist/esm/models/profitabilitytrend.js.map +1 -0
  202. package/dist/esm/models/purchasegrantresponse.d.ts +4 -4
  203. package/dist/esm/models/purchasegrantresponse.d.ts.map +1 -1
  204. package/dist/esm/models/purchasegrantresponse.js +4 -4
  205. package/dist/esm/models/purchasegrantresponse.js.map +1 -1
  206. package/dist/esm/models/schemaspaymentsession.d.ts +68 -0
  207. package/dist/esm/models/schemaspaymentsession.d.ts.map +1 -0
  208. package/dist/esm/models/schemaspaymentsession.js +41 -0
  209. package/dist/esm/models/schemaspaymentsession.js.map +1 -0
  210. package/dist/esm/sdk/customers.d.ts +14 -0
  211. package/dist/esm/sdk/customers.d.ts.map +1 -1
  212. package/dist/esm/sdk/customers.js +20 -0
  213. package/dist/esm/sdk/customers.js.map +1 -1
  214. package/dist/esm/sdk/paymentsessions.d.ts +12 -0
  215. package/dist/esm/sdk/paymentsessions.d.ts.map +1 -0
  216. package/dist/esm/sdk/paymentsessions.js +18 -0
  217. package/dist/esm/sdk/paymentsessions.js.map +1 -0
  218. package/dist/esm/sdk/profitability.d.ts +13 -0
  219. package/dist/esm/sdk/profitability.d.ts.map +1 -0
  220. package/dist/esm/sdk/profitability.js +18 -0
  221. package/dist/esm/sdk/profitability.js.map +1 -0
  222. package/dist/esm/sdk/sdk.d.ts +6 -0
  223. package/dist/esm/sdk/sdk.d.ts.map +1 -1
  224. package/dist/esm/sdk/sdk.js +8 -0
  225. package/dist/esm/sdk/sdk.js.map +1 -1
  226. package/jsr.json +1 -1
  227. package/package.json +1 -1
  228. package/src/funcs/customersCreateCustomerPaymentMethod.ts +182 -0
  229. package/src/funcs/customersListCustomerPaymentMethods.ts +176 -0
  230. package/src/funcs/invoicesV2List.ts +1 -0
  231. package/src/funcs/paymentSessionsListPaymentSessions.ts +183 -0
  232. package/src/funcs/profitabilityGetProfitability.ts +184 -0
  233. package/src/lib/config.ts +2 -2
  234. package/src/models/index.ts +6 -0
  235. package/src/models/offsetpagination.ts +7 -7
  236. package/src/models/operations/createcustomerpaymentmethod.ts +90 -0
  237. package/src/models/operations/createplan.ts +7 -0
  238. package/src/models/operations/getprofitability.ts +85 -0
  239. package/src/models/operations/getrevenue.ts +7 -6
  240. package/src/models/operations/index.ts +4 -0
  241. package/src/models/operations/listcustomerpaymentmethods.ts +82 -0
  242. package/src/models/operations/listinvoices.ts +11 -0
  243. package/src/models/operations/listpaymentsessions.ts +43 -12
  244. package/src/models/operations/updateplan.ts +7 -0
  245. package/src/models/paymentmethod.ts +62 -0
  246. package/src/models/paymentsession.ts +96 -0
  247. package/src/models/plan.ts +7 -0
  248. package/src/models/profitabilityrow.ts +68 -0
  249. package/src/models/profitabilitysummaryresponse.ts +53 -0
  250. package/src/models/profitabilitytrend.ts +39 -0
  251. package/src/models/purchasegrantresponse.ts +12 -9
  252. package/src/models/schemaspaymentsession.ts +113 -0
  253. package/src/sdk/customers.ts +36 -0
  254. package/src/sdk/paymentsessions.ts +27 -0
  255. package/src/sdk/profitability.ts +28 -0
  256. package/src/sdk/sdk.ts +12 -0
@@ -0,0 +1,96 @@
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: "paymentSession",
13
+ } as const;
14
+ export type PaymentSessionObject = ClosedEnum<typeof PaymentSessionObject>;
15
+
16
+ export const Mode = {
17
+ Payment: "payment",
18
+ Setup: "setup",
19
+ } as const;
20
+ export type Mode = ClosedEnum<typeof Mode>;
21
+
22
+ export const PaymentSessionStatus = {
23
+ Pending: "pending",
24
+ Processing: "processing",
25
+ Completed: "completed",
26
+ Failed: "failed",
27
+ Expired: "expired",
28
+ Cancelled: "cancelled",
29
+ } as const;
30
+ export type PaymentSessionStatus = ClosedEnum<typeof PaymentSessionStatus>;
31
+
32
+ export type PaymentSession = {
33
+ object: PaymentSessionObject;
34
+ /**
35
+ * Payment session identifier (e.g. `ps_...`).
36
+ */
37
+ id: string;
38
+ mode: Mode;
39
+ status: PaymentSessionStatus;
40
+ /**
41
+ * Hosted page URL. Redirect the customer here, or load it inside an iframe — when iframed, the page reports outcomes via `postMessage` (`payment_success` / `payment_error`) to the parent window.
42
+ */
43
+ url: string;
44
+ successRedirectUrl?: string | null | undefined;
45
+ failureRedirectUrl?: string | null | undefined;
46
+ metadata?: { [k: string]: any } | undefined;
47
+ expiresAt: Date;
48
+ completedAt?: Date | null | undefined;
49
+ createdAt: Date;
50
+ };
51
+
52
+ /** @internal */
53
+ export const PaymentSessionObject$inboundSchema: z.ZodNativeEnum<
54
+ typeof PaymentSessionObject
55
+ > = z.nativeEnum(PaymentSessionObject);
56
+
57
+ /** @internal */
58
+ export const Mode$inboundSchema: z.ZodNativeEnum<typeof Mode> = z.nativeEnum(
59
+ Mode,
60
+ );
61
+
62
+ /** @internal */
63
+ export const PaymentSessionStatus$inboundSchema: z.ZodNativeEnum<
64
+ typeof PaymentSessionStatus
65
+ > = z.nativeEnum(PaymentSessionStatus);
66
+
67
+ /** @internal */
68
+ export const PaymentSession$inboundSchema: z.ZodType<
69
+ PaymentSession,
70
+ z.ZodTypeDef,
71
+ unknown
72
+ > = z.object({
73
+ object: PaymentSessionObject$inboundSchema,
74
+ id: z.string(),
75
+ mode: Mode$inboundSchema,
76
+ status: PaymentSessionStatus$inboundSchema,
77
+ url: z.string(),
78
+ successRedirectUrl: z.nullable(z.string()).optional(),
79
+ failureRedirectUrl: z.nullable(z.string()).optional(),
80
+ metadata: z.record(z.any()).optional(),
81
+ expiresAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
82
+ completedAt: z.nullable(
83
+ z.string().datetime({ offset: true }).transform(v => new Date(v)),
84
+ ).optional(),
85
+ createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
86
+ });
87
+
88
+ export function paymentSessionFromJSON(
89
+ jsonString: string,
90
+ ): SafeParseResult<PaymentSession, SDKValidationError> {
91
+ return safeParse(
92
+ jsonString,
93
+ (x) => PaymentSession$inboundSchema.parse(JSON.parse(x)),
94
+ `Failed to parse 'PaymentSession' from JSON`,
95
+ );
96
+ }
@@ -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,113 @@
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 SchemasPaymentSessionObject = {
12
+ PaymentSession: "payment_session",
13
+ } as const;
14
+ export type SchemasPaymentSessionObject = ClosedEnum<
15
+ typeof SchemasPaymentSessionObject
16
+ >;
17
+
18
+ /**
19
+ * Lifecycle status of the session.
20
+ */
21
+ export const SchemasPaymentSessionStatus = {
22
+ Pending: "pending",
23
+ Processing: "processing",
24
+ Completed: "completed",
25
+ Failed: "failed",
26
+ Expired: "expired",
27
+ Cancelled: "cancelled",
28
+ } as const;
29
+ /**
30
+ * Lifecycle status of the session.
31
+ */
32
+ export type SchemasPaymentSessionStatus = ClosedEnum<
33
+ typeof SchemasPaymentSessionStatus
34
+ >;
35
+
36
+ export type SchemasPaymentSession = {
37
+ object: SchemasPaymentSessionObject;
38
+ /**
39
+ * Payment session ID (ps_*).
40
+ */
41
+ id: string;
42
+ /**
43
+ * Type of entity the session pays for (invoice, subscription, payment, topup).
44
+ */
45
+ entityType: string;
46
+ /**
47
+ * ID of the entity the session pays for.
48
+ */
49
+ entityId: string;
50
+ /**
51
+ * Amount in decimal dollars.
52
+ */
53
+ amount: string;
54
+ /**
55
+ * ISO 4217 currency code.
56
+ */
57
+ currency: string;
58
+ /**
59
+ * Lifecycle status of the session.
60
+ */
61
+ status: SchemasPaymentSessionStatus;
62
+ /**
63
+ * Stripe Connect account ID (acct_*) when the session is routed to a connected account.
64
+ */
65
+ merchantPaymentAccountId?: string | null | undefined;
66
+ /**
67
+ * Timestamp the session reached terminal completion. Null until the session completes.
68
+ */
69
+ completedAt?: Date | null | undefined;
70
+ createdAt: Date;
71
+ updatedAt: Date;
72
+ };
73
+
74
+ /** @internal */
75
+ export const SchemasPaymentSessionObject$inboundSchema: z.ZodNativeEnum<
76
+ typeof SchemasPaymentSessionObject
77
+ > = z.nativeEnum(SchemasPaymentSessionObject);
78
+
79
+ /** @internal */
80
+ export const SchemasPaymentSessionStatus$inboundSchema: z.ZodNativeEnum<
81
+ typeof SchemasPaymentSessionStatus
82
+ > = z.nativeEnum(SchemasPaymentSessionStatus);
83
+
84
+ /** @internal */
85
+ export const SchemasPaymentSession$inboundSchema: z.ZodType<
86
+ SchemasPaymentSession,
87
+ z.ZodTypeDef,
88
+ unknown
89
+ > = z.object({
90
+ object: SchemasPaymentSessionObject$inboundSchema,
91
+ id: z.string(),
92
+ entityType: z.string(),
93
+ entityId: z.string(),
94
+ amount: z.string(),
95
+ currency: z.string(),
96
+ status: SchemasPaymentSessionStatus$inboundSchema,
97
+ merchantPaymentAccountId: z.nullable(z.string()).optional(),
98
+ completedAt: z.nullable(
99
+ z.string().datetime({ offset: true }).transform(v => new Date(v)),
100
+ ).optional(),
101
+ createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
102
+ updatedAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
103
+ });
104
+
105
+ export function schemasPaymentSessionFromJSON(
106
+ jsonString: string,
107
+ ): SafeParseResult<SchemasPaymentSession, SDKValidationError> {
108
+ return safeParse(
109
+ jsonString,
110
+ (x) => SchemasPaymentSession$inboundSchema.parse(JSON.parse(x)),
111
+ `Failed to parse 'SchemasPaymentSession' from JSON`,
112
+ );
113
+ }
@@ -3,9 +3,11 @@
3
3
  */
4
4
 
5
5
  import { customersCreate } from "../funcs/customersCreate.js";
6
+ import { customersCreateCustomerPaymentMethod } from "../funcs/customersCreateCustomerPaymentMethod.js";
6
7
  import { customersDelete } from "../funcs/customersDelete.js";
7
8
  import { customersGet } from "../funcs/customersGet.js";
8
9
  import { customersList } from "../funcs/customersList.js";
10
+ import { customersListCustomerPaymentMethods } from "../funcs/customersListCustomerPaymentMethods.js";
9
11
  import { customersUpdate } from "../funcs/customersUpdate.js";
10
12
  import { ClientSDK, RequestOptions } from "../lib/sdks.js";
11
13
  import * as models from "../models/index.js";
@@ -85,4 +87,38 @@ export class Customers extends ClientSDK {
85
87
  options,
86
88
  ));
87
89
  }
90
+
91
+ /**
92
+ * List payment methods
93
+ *
94
+ * @remarks
95
+ * List off-session payment methods saved for this customer.
96
+ */
97
+ async listCustomerPaymentMethods(
98
+ request: operations.ListCustomerPaymentMethodsRequest,
99
+ options?: RequestOptions,
100
+ ): Promise<operations.ListCustomerPaymentMethodsResponse> {
101
+ return unwrapAsync(customersListCustomerPaymentMethods(
102
+ this,
103
+ request,
104
+ options,
105
+ ));
106
+ }
107
+
108
+ /**
109
+ * Set up a payment method
110
+ *
111
+ * @remarks
112
+ * Create a payment session that captures a new off-session payment method for this customer without charging. The response contains a hosted-page URL — redirect the customer to it, or load it inside an iframe (when iframed, the page reports outcomes via `postMessage` to the parent window).
113
+ */
114
+ async createCustomerPaymentMethod(
115
+ request: operations.CreateCustomerPaymentMethodRequest,
116
+ options?: RequestOptions,
117
+ ): Promise<models.PaymentSession> {
118
+ return unwrapAsync(customersCreateCustomerPaymentMethod(
119
+ this,
120
+ request,
121
+ options,
122
+ ));
123
+ }
88
124
  }
@@ -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));