@paygentic/sdk 0.6.16 → 0.6.18

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 (134) hide show
  1. package/README.md +7 -3
  2. package/dist/commonjs/funcs/invoicesV2CreateLineItem.d.ts +19 -0
  3. package/dist/commonjs/funcs/invoicesV2CreateLineItem.d.ts.map +1 -0
  4. package/dist/commonjs/funcs/invoicesV2CreateLineItem.js +122 -0
  5. package/dist/commonjs/funcs/invoicesV2CreateLineItem.js.map +1 -0
  6. package/dist/commonjs/funcs/invoicesV2ListLineItems.d.ts +19 -0
  7. package/dist/commonjs/funcs/invoicesV2ListLineItems.d.ts.map +1 -0
  8. package/dist/commonjs/funcs/invoicesV2ListLineItems.js +126 -0
  9. package/dist/commonjs/funcs/invoicesV2ListLineItems.js.map +1 -0
  10. package/dist/commonjs/lib/config.d.ts +3 -3
  11. package/dist/commonjs/lib/config.js +3 -3
  12. package/dist/commonjs/models/createmanuallineitemrequest.d.ts +65 -0
  13. package/dist/commonjs/models/createmanuallineitemrequest.d.ts.map +1 -0
  14. package/dist/commonjs/models/createmanuallineitemrequest.js +59 -0
  15. package/dist/commonjs/models/createmanuallineitemrequest.js.map +1 -0
  16. package/dist/commonjs/models/index.d.ts +4 -0
  17. package/dist/commonjs/models/index.d.ts.map +1 -1
  18. package/dist/commonjs/models/index.js +4 -0
  19. package/dist/commonjs/models/index.js.map +1 -1
  20. package/dist/commonjs/models/invoicelineitem.d.ts +4 -4
  21. package/dist/commonjs/models/invoicelineitem.d.ts.map +1 -1
  22. package/dist/commonjs/models/invoicelineitem.js +4 -4
  23. package/dist/commonjs/models/invoicelineitem.js.map +1 -1
  24. package/dist/commonjs/models/lineitem.d.ts +146 -0
  25. package/dist/commonjs/models/lineitem.d.ts.map +1 -0
  26. package/dist/commonjs/models/lineitem.js +101 -0
  27. package/dist/commonjs/models/lineitem.js.map +1 -0
  28. package/dist/commonjs/models/lineitemsresponse.d.ts +37 -0
  29. package/dist/commonjs/models/lineitemsresponse.d.ts.map +1 -0
  30. package/dist/commonjs/models/lineitemsresponse.js +63 -0
  31. package/dist/commonjs/models/lineitemsresponse.js.map +1 -0
  32. package/dist/commonjs/models/lineitemssummary.d.ts +21 -0
  33. package/dist/commonjs/models/lineitemssummary.d.ts.map +1 -0
  34. package/dist/commonjs/models/lineitemssummary.js +52 -0
  35. package/dist/commonjs/models/lineitemssummary.js.map +1 -0
  36. package/dist/commonjs/models/operations/createlineitem.d.ts +18 -0
  37. package/dist/commonjs/models/operations/createlineitem.d.ts.map +1 -0
  38. package/dist/commonjs/models/operations/createlineitem.js +57 -0
  39. package/dist/commonjs/models/operations/createlineitem.js.map +1 -0
  40. package/dist/commonjs/models/operations/index.d.ts +2 -0
  41. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  42. package/dist/commonjs/models/operations/index.js +2 -0
  43. package/dist/commonjs/models/operations/index.js.map +1 -1
  44. package/dist/commonjs/models/operations/listlineitems.d.ts +49 -0
  45. package/dist/commonjs/models/operations/listlineitems.d.ts.map +1 -0
  46. package/dist/commonjs/models/operations/listlineitems.js +62 -0
  47. package/dist/commonjs/models/operations/listlineitems.js.map +1 -0
  48. package/dist/commonjs/models/payment.d.ts +4 -4
  49. package/dist/commonjs/models/payment.d.ts.map +1 -1
  50. package/dist/commonjs/models/payment.js +6 -6
  51. package/dist/commonjs/models/payment.js.map +1 -1
  52. package/dist/commonjs/models/subscription.d.ts +39 -27
  53. package/dist/commonjs/models/subscription.d.ts.map +1 -1
  54. package/dist/commonjs/models/subscription.js +32 -18
  55. package/dist/commonjs/models/subscription.js.map +1 -1
  56. package/dist/commonjs/sdk/invoicesv2.d.ts +14 -0
  57. package/dist/commonjs/sdk/invoicesv2.d.ts.map +1 -1
  58. package/dist/commonjs/sdk/invoicesv2.js +20 -0
  59. package/dist/commonjs/sdk/invoicesv2.js.map +1 -1
  60. package/dist/esm/funcs/invoicesV2CreateLineItem.d.ts +19 -0
  61. package/dist/esm/funcs/invoicesV2CreateLineItem.d.ts.map +1 -0
  62. package/dist/esm/funcs/invoicesV2CreateLineItem.js +86 -0
  63. package/dist/esm/funcs/invoicesV2CreateLineItem.js.map +1 -0
  64. package/dist/esm/funcs/invoicesV2ListLineItems.d.ts +19 -0
  65. package/dist/esm/funcs/invoicesV2ListLineItems.d.ts.map +1 -0
  66. package/dist/esm/funcs/invoicesV2ListLineItems.js +90 -0
  67. package/dist/esm/funcs/invoicesV2ListLineItems.js.map +1 -0
  68. package/dist/esm/lib/config.d.ts +3 -3
  69. package/dist/esm/lib/config.js +3 -3
  70. package/dist/esm/models/createmanuallineitemrequest.d.ts +65 -0
  71. package/dist/esm/models/createmanuallineitemrequest.d.ts.map +1 -0
  72. package/dist/esm/models/createmanuallineitemrequest.js +22 -0
  73. package/dist/esm/models/createmanuallineitemrequest.js.map +1 -0
  74. package/dist/esm/models/index.d.ts +4 -0
  75. package/dist/esm/models/index.d.ts.map +1 -1
  76. package/dist/esm/models/index.js +4 -0
  77. package/dist/esm/models/index.js.map +1 -1
  78. package/dist/esm/models/invoicelineitem.d.ts +4 -4
  79. package/dist/esm/models/invoicelineitem.d.ts.map +1 -1
  80. package/dist/esm/models/invoicelineitem.js +3 -3
  81. package/dist/esm/models/invoicelineitem.js.map +1 -1
  82. package/dist/esm/models/lineitem.d.ts +146 -0
  83. package/dist/esm/models/lineitem.d.ts.map +1 -0
  84. package/dist/esm/models/lineitem.js +64 -0
  85. package/dist/esm/models/lineitem.js.map +1 -0
  86. package/dist/esm/models/lineitemsresponse.d.ts +37 -0
  87. package/dist/esm/models/lineitemsresponse.d.ts.map +1 -0
  88. package/dist/esm/models/lineitemsresponse.js +26 -0
  89. package/dist/esm/models/lineitemsresponse.js.map +1 -0
  90. package/dist/esm/models/lineitemssummary.d.ts +21 -0
  91. package/dist/esm/models/lineitemssummary.d.ts.map +1 -0
  92. package/dist/esm/models/lineitemssummary.js +15 -0
  93. package/dist/esm/models/lineitemssummary.js.map +1 -0
  94. package/dist/esm/models/operations/createlineitem.d.ts +18 -0
  95. package/dist/esm/models/operations/createlineitem.d.ts.map +1 -0
  96. package/dist/esm/models/operations/createlineitem.js +20 -0
  97. package/dist/esm/models/operations/createlineitem.js.map +1 -0
  98. package/dist/esm/models/operations/index.d.ts +2 -0
  99. package/dist/esm/models/operations/index.d.ts.map +1 -1
  100. package/dist/esm/models/operations/index.js +2 -0
  101. package/dist/esm/models/operations/index.js.map +1 -1
  102. package/dist/esm/models/operations/listlineitems.d.ts +49 -0
  103. package/dist/esm/models/operations/listlineitems.d.ts.map +1 -0
  104. package/dist/esm/models/operations/listlineitems.js +25 -0
  105. package/dist/esm/models/operations/listlineitems.js.map +1 -0
  106. package/dist/esm/models/payment.d.ts +4 -4
  107. package/dist/esm/models/payment.d.ts.map +1 -1
  108. package/dist/esm/models/payment.js +4 -4
  109. package/dist/esm/models/payment.js.map +1 -1
  110. package/dist/esm/models/subscription.d.ts +39 -27
  111. package/dist/esm/models/subscription.d.ts.map +1 -1
  112. package/dist/esm/models/subscription.js +28 -16
  113. package/dist/esm/models/subscription.js.map +1 -1
  114. package/dist/esm/sdk/invoicesv2.d.ts +14 -0
  115. package/dist/esm/sdk/invoicesv2.d.ts.map +1 -1
  116. package/dist/esm/sdk/invoicesv2.js +20 -0
  117. package/dist/esm/sdk/invoicesv2.js.map +1 -1
  118. package/jsr.json +1 -1
  119. package/package.json +1 -1
  120. package/src/funcs/invoicesV2CreateLineItem.ts +182 -0
  121. package/src/funcs/invoicesV2ListLineItems.ts +184 -0
  122. package/src/lib/config.ts +3 -3
  123. package/src/models/createmanuallineitemrequest.ts +96 -0
  124. package/src/models/index.ts +4 -0
  125. package/src/models/invoicelineitem.ts +9 -6
  126. package/src/models/lineitem.ts +205 -0
  127. package/src/models/lineitemsresponse.ts +70 -0
  128. package/src/models/lineitemssummary.ts +44 -0
  129. package/src/models/operations/createlineitem.ts +45 -0
  130. package/src/models/operations/index.ts +2 -0
  131. package/src/models/operations/listlineitems.ts +76 -0
  132. package/src/models/payment.ts +9 -9
  133. package/src/models/subscription.ts +89 -41
  134. package/src/sdk/invoicesv2.ts +36 -0
@@ -13,6 +13,24 @@ export const SubscriptionObject = {
13
13
  } as const;
14
14
  export type SubscriptionObject = ClosedEnum<typeof SubscriptionObject>;
15
15
 
16
+ /**
17
+ * Zero-amount Invoice 0 that completed synchronously to PAID
18
+ */
19
+ export type PaymentPaid = {
20
+ /**
21
+ * The Invoice 0 id
22
+ */
23
+ invoiceId: string;
24
+ /**
25
+ * Payment amount ('0' for zero-amount subscriptions)
26
+ */
27
+ amount: string;
28
+ /**
29
+ * Payment status
30
+ */
31
+ status: "paid";
32
+ };
33
+
16
34
  /**
17
35
  * Breakdown of payment amount
18
36
  */
@@ -22,26 +40,12 @@ export type Breakdown = {
22
40
  */
23
41
  upfrontCharges: string;
24
42
  /**
25
- * Wallet charge amount in decimal dollar format. This is the calculated difference between the minimum account balance requirement and the customer's current balance. If the customer already has sufficient balance, this will be '0.00'. Sample values: '200.00' equals $200.00 charge, '0.00' means no charge needed
43
+ * Wallet charge amount in decimal dollar format.
26
44
  */
27
45
  walletCharge: string;
28
46
  };
29
47
 
30
- /**
31
- * Payment status
32
- */
33
- export const StatusPending = {
34
- Pending: "pending",
35
- } as const;
36
- /**
37
- * Payment status
38
- */
39
- export type StatusPending = ClosedEnum<typeof StatusPending>;
40
-
41
- /**
42
- * Payment session details when upfront payment is required
43
- */
44
- export type SubscriptionPayment = {
48
+ export type PaymentPending = {
45
49
  /**
46
50
  * Total payment amount in decimal dollar format. Sample values: '250.00' equals $250.00, '99.99' equals $99.99
47
51
  */
@@ -51,7 +55,7 @@ export type SubscriptionPayment = {
51
55
  */
52
56
  breakdown: Breakdown;
53
57
  /**
54
- * Checkout page URL for customer payment completion. Sample values: 'https://checkout.paygentic.com/session/ps_abc123', 'https://pay.example.com/checkout/xyz789'
58
+ * Checkout page URL for customer payment completion.
55
59
  */
56
60
  checkoutUrl: string;
57
61
  /**
@@ -59,21 +63,26 @@ export type SubscriptionPayment = {
59
63
  */
60
64
  invoiceId?: string | undefined;
61
65
  /**
62
- * Payment session identifier for upfront payment processing. Sample values: 'ps_abc123xyz', 'ps_789def456'
66
+ * Payment session identifier for upfront payment processing.
63
67
  */
64
68
  paymentSessionId: string;
65
69
  /**
66
70
  * Payment status
67
71
  */
68
- status: StatusPending;
72
+ status: "pending";
69
73
  };
70
74
 
71
- export const SubscriptionStatus = {
75
+ /**
76
+ * Payment session details when upfront payment is required, or confirmation of a zero-amount paid invoice
77
+ */
78
+ export type PaymentUnion = PaymentPending | PaymentPaid;
79
+
80
+ export const SubscriptionStatusEnum = {
72
81
  PendingPayment: "pending_payment",
73
82
  Active: "active",
74
83
  Terminated: "terminated",
75
84
  } as const;
76
- export type SubscriptionStatus = ClosedEnum<typeof SubscriptionStatus>;
85
+ export type SubscriptionStatusEnum = ClosedEnum<typeof SubscriptionStatusEnum>;
77
86
 
78
87
  export type Subscription = {
79
88
  id: string;
@@ -95,9 +104,9 @@ export type Subscription = {
95
104
  taxExempt: boolean;
96
105
  name: string;
97
106
  /**
98
- * Payment session details when upfront payment is required
107
+ * Payment session details when upfront payment is required, or confirmation of a zero-amount paid invoice
99
108
  */
100
- payment?: SubscriptionPayment | undefined;
109
+ payment?: PaymentPending | PaymentPaid | undefined;
101
110
  planId: string;
102
111
  /**
103
112
  * @deprecated Use minimumAccountBalance instead. Minimum required wallet balance in atomic units. Sample values: '200000000000' equals $200.00 minimum, '1000000000000' equals $1000.00 minimum
@@ -108,7 +117,7 @@ export type Subscription = {
108
117
  */
109
118
  minimumAccountBalance?: string | undefined;
110
119
  startedAt: Date;
111
- status: SubscriptionStatus;
120
+ status: SubscriptionStatusEnum;
112
121
  terminatedAt?: Date | undefined;
113
122
  /**
114
123
  * ID of who terminated the subscription (customer ID or merchant ID)
@@ -142,6 +151,27 @@ export const SubscriptionObject$inboundSchema: z.ZodNativeEnum<
142
151
  typeof SubscriptionObject
143
152
  > = z.nativeEnum(SubscriptionObject);
144
153
 
154
+ /** @internal */
155
+ export const PaymentPaid$inboundSchema: z.ZodType<
156
+ PaymentPaid,
157
+ z.ZodTypeDef,
158
+ unknown
159
+ > = z.object({
160
+ invoiceId: z.string(),
161
+ amount: z.string(),
162
+ status: z.literal("paid"),
163
+ });
164
+
165
+ export function paymentPaidFromJSON(
166
+ jsonString: string,
167
+ ): SafeParseResult<PaymentPaid, SDKValidationError> {
168
+ return safeParse(
169
+ jsonString,
170
+ (x) => PaymentPaid$inboundSchema.parse(JSON.parse(x)),
171
+ `Failed to parse 'PaymentPaid' from JSON`,
172
+ );
173
+ }
174
+
145
175
  /** @internal */
146
176
  export const Breakdown$inboundSchema: z.ZodType<
147
177
  Breakdown,
@@ -163,13 +193,8 @@ export function breakdownFromJSON(
163
193
  }
164
194
 
165
195
  /** @internal */
166
- export const StatusPending$inboundSchema: z.ZodNativeEnum<
167
- typeof StatusPending
168
- > = z.nativeEnum(StatusPending);
169
-
170
- /** @internal */
171
- export const SubscriptionPayment$inboundSchema: z.ZodType<
172
- SubscriptionPayment,
196
+ export const PaymentPending$inboundSchema: z.ZodType<
197
+ PaymentPending,
173
198
  z.ZodTypeDef,
174
199
  unknown
175
200
  > = z.object({
@@ -178,23 +203,43 @@ export const SubscriptionPayment$inboundSchema: z.ZodType<
178
203
  checkoutUrl: z.string(),
179
204
  invoiceId: z.string().optional(),
180
205
  paymentSessionId: z.string(),
181
- status: StatusPending$inboundSchema,
206
+ status: z.literal("pending"),
182
207
  });
183
208
 
184
- export function subscriptionPaymentFromJSON(
209
+ export function paymentPendingFromJSON(
210
+ jsonString: string,
211
+ ): SafeParseResult<PaymentPending, SDKValidationError> {
212
+ return safeParse(
213
+ jsonString,
214
+ (x) => PaymentPending$inboundSchema.parse(JSON.parse(x)),
215
+ `Failed to parse 'PaymentPending' from JSON`,
216
+ );
217
+ }
218
+
219
+ /** @internal */
220
+ export const PaymentUnion$inboundSchema: z.ZodType<
221
+ PaymentUnion,
222
+ z.ZodTypeDef,
223
+ unknown
224
+ > = z.union([
225
+ z.lazy(() => PaymentPending$inboundSchema),
226
+ z.lazy(() => PaymentPaid$inboundSchema),
227
+ ]);
228
+
229
+ export function paymentUnionFromJSON(
185
230
  jsonString: string,
186
- ): SafeParseResult<SubscriptionPayment, SDKValidationError> {
231
+ ): SafeParseResult<PaymentUnion, SDKValidationError> {
187
232
  return safeParse(
188
233
  jsonString,
189
- (x) => SubscriptionPayment$inboundSchema.parse(JSON.parse(x)),
190
- `Failed to parse 'SubscriptionPayment' from JSON`,
234
+ (x) => PaymentUnion$inboundSchema.parse(JSON.parse(x)),
235
+ `Failed to parse 'PaymentUnion' from JSON`,
191
236
  );
192
237
  }
193
238
 
194
239
  /** @internal */
195
- export const SubscriptionStatus$inboundSchema: z.ZodNativeEnum<
196
- typeof SubscriptionStatus
197
- > = z.nativeEnum(SubscriptionStatus);
240
+ export const SubscriptionStatusEnum$inboundSchema: z.ZodNativeEnum<
241
+ typeof SubscriptionStatusEnum
242
+ > = z.nativeEnum(SubscriptionStatusEnum);
198
243
 
199
244
  /** @internal */
200
245
  export const Subscription$inboundSchema: z.ZodType<
@@ -212,12 +257,15 @@ export const Subscription$inboundSchema: z.ZodType<
212
257
  estimatedTaxRate: z.number().optional(),
213
258
  taxExempt: z.boolean().default(false),
214
259
  name: z.string(),
215
- payment: z.lazy(() => SubscriptionPayment$inboundSchema).optional(),
260
+ payment: z.union([
261
+ z.lazy(() => PaymentPending$inboundSchema),
262
+ z.lazy(() => PaymentPaid$inboundSchema),
263
+ ]).optional(),
216
264
  planId: z.string(),
217
265
  prefundAmount: z.string().optional(),
218
266
  minimumAccountBalance: z.string().optional(),
219
267
  startedAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
220
- status: SubscriptionStatus$inboundSchema,
268
+ status: SubscriptionStatusEnum$inboundSchema,
221
269
  terminatedAt: z.string().datetime({ offset: true }).transform(v =>
222
270
  new Date(v)
223
271
  ).optional(),
@@ -2,9 +2,11 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
4
 
5
+ import { invoicesV2CreateLineItem } from "../funcs/invoicesV2CreateLineItem.js";
5
6
  import { invoicesV2Get } from "../funcs/invoicesV2Get.js";
6
7
  import { invoicesV2GetLineItems } from "../funcs/invoicesV2GetLineItems.js";
7
8
  import { invoicesV2List } from "../funcs/invoicesV2List.js";
9
+ import { invoicesV2ListLineItems } from "../funcs/invoicesV2ListLineItems.js";
8
10
  import { ClientSDK, RequestOptions } from "../lib/sdks.js";
9
11
  import * as models from "../models/index.js";
10
12
  import * as operations from "../models/operations/index.js";
@@ -28,6 +30,40 @@ export class InvoicesV2 extends ClientSDK {
28
30
  ));
29
31
  }
30
32
 
33
+ /**
34
+ * List Line Items
35
+ *
36
+ * @remarks
37
+ * List pending and invoiced line items for a subscription from the billing database. Returns exact fee amounts and estimated metered charges.
38
+ */
39
+ async listLineItems(
40
+ request?: operations.ListLineItemsRequest | undefined,
41
+ options?: RequestOptions,
42
+ ): Promise<models.LineItemsResponse> {
43
+ return unwrapAsync(invoicesV2ListLineItems(
44
+ this,
45
+ request,
46
+ options,
47
+ ));
48
+ }
49
+
50
+ /**
51
+ * Create Manual Line Item
52
+ *
53
+ * @remarks
54
+ * Create a manual line item for a billing v1 subscription. Manual line items are ad-hoc charges or credits that flow through the same collection pipeline as auto-generated items. Exactly one of subscriptionId or invoiceId must be provided.
55
+ */
56
+ async createLineItem(
57
+ request: operations.CreateLineItemRequest,
58
+ options?: RequestOptions,
59
+ ): Promise<models.LineItem> {
60
+ return unwrapAsync(invoicesV2CreateLineItem(
61
+ this,
62
+ request,
63
+ options,
64
+ ));
65
+ }
66
+
31
67
  /**
32
68
  * Get
33
69
  *