@paygentic/sdk 0.7.7 → 0.7.9

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 (78) hide show
  1. package/dist/commonjs/funcs/entitlementsGrantsPurchase.d.ts +1 -1
  2. package/dist/commonjs/funcs/entitlementsGrantsPurchase.js +1 -1
  3. package/dist/commonjs/lib/config.d.ts +2 -2
  4. package/dist/commonjs/lib/config.js +2 -2
  5. package/dist/commonjs/models/index.d.ts +1 -0
  6. package/dist/commonjs/models/index.d.ts.map +1 -1
  7. package/dist/commonjs/models/index.js +1 -0
  8. package/dist/commonjs/models/index.js.map +1 -1
  9. package/dist/commonjs/models/invoice.d.ts +4 -0
  10. package/dist/commonjs/models/invoice.d.ts.map +1 -1
  11. package/dist/commonjs/models/invoice.js +1 -0
  12. package/dist/commonjs/models/invoice.js.map +1 -1
  13. package/dist/commonjs/models/operations/createsubscription.d.ts +15 -0
  14. package/dist/commonjs/models/operations/createsubscription.d.ts.map +1 -1
  15. package/dist/commonjs/models/operations/createsubscription.js +3 -0
  16. package/dist/commonjs/models/operations/createsubscription.js.map +1 -1
  17. package/dist/commonjs/models/operations/listsubscriptions.d.ts +9 -0
  18. package/dist/commonjs/models/operations/listsubscriptions.d.ts.map +1 -1
  19. package/dist/commonjs/models/operations/listsubscriptions.js.map +1 -1
  20. package/dist/commonjs/models/operations/updatesubscription.d.ts +5 -0
  21. package/dist/commonjs/models/operations/updatesubscription.d.ts.map +1 -1
  22. package/dist/commonjs/models/operations/updatesubscription.js +1 -0
  23. package/dist/commonjs/models/operations/updatesubscription.js.map +1 -1
  24. package/dist/commonjs/models/subscription.d.ts +11 -0
  25. package/dist/commonjs/models/subscription.d.ts.map +1 -1
  26. package/dist/commonjs/models/subscription.js +3 -0
  27. package/dist/commonjs/models/subscription.js.map +1 -1
  28. package/dist/commonjs/models/subscriptionmetadata.d.ts +13 -0
  29. package/dist/commonjs/models/subscriptionmetadata.d.ts.map +1 -0
  30. package/dist/commonjs/models/subscriptionmetadata.js +54 -0
  31. package/dist/commonjs/models/subscriptionmetadata.js.map +1 -0
  32. package/dist/commonjs/sdk/grants.d.ts +1 -1
  33. package/dist/commonjs/sdk/grants.js +1 -1
  34. package/dist/esm/funcs/entitlementsGrantsPurchase.d.ts +1 -1
  35. package/dist/esm/funcs/entitlementsGrantsPurchase.js +1 -1
  36. package/dist/esm/lib/config.d.ts +2 -2
  37. package/dist/esm/lib/config.js +2 -2
  38. package/dist/esm/models/index.d.ts +1 -0
  39. package/dist/esm/models/index.d.ts.map +1 -1
  40. package/dist/esm/models/index.js +1 -0
  41. package/dist/esm/models/index.js.map +1 -1
  42. package/dist/esm/models/invoice.d.ts +4 -0
  43. package/dist/esm/models/invoice.d.ts.map +1 -1
  44. package/dist/esm/models/invoice.js +1 -0
  45. package/dist/esm/models/invoice.js.map +1 -1
  46. package/dist/esm/models/operations/createsubscription.d.ts +15 -0
  47. package/dist/esm/models/operations/createsubscription.d.ts.map +1 -1
  48. package/dist/esm/models/operations/createsubscription.js +3 -0
  49. package/dist/esm/models/operations/createsubscription.js.map +1 -1
  50. package/dist/esm/models/operations/listsubscriptions.d.ts +9 -0
  51. package/dist/esm/models/operations/listsubscriptions.d.ts.map +1 -1
  52. package/dist/esm/models/operations/listsubscriptions.js.map +1 -1
  53. package/dist/esm/models/operations/updatesubscription.d.ts +5 -0
  54. package/dist/esm/models/operations/updatesubscription.d.ts.map +1 -1
  55. package/dist/esm/models/operations/updatesubscription.js +1 -0
  56. package/dist/esm/models/operations/updatesubscription.js.map +1 -1
  57. package/dist/esm/models/subscription.d.ts +11 -0
  58. package/dist/esm/models/subscription.d.ts.map +1 -1
  59. package/dist/esm/models/subscription.js +3 -0
  60. package/dist/esm/models/subscription.js.map +1 -1
  61. package/dist/esm/models/subscriptionmetadata.d.ts +13 -0
  62. package/dist/esm/models/subscriptionmetadata.d.ts.map +1 -0
  63. package/dist/esm/models/subscriptionmetadata.js +16 -0
  64. package/dist/esm/models/subscriptionmetadata.js.map +1 -0
  65. package/dist/esm/sdk/grants.d.ts +1 -1
  66. package/dist/esm/sdk/grants.js +1 -1
  67. package/jsr.json +1 -1
  68. package/package.json +1 -1
  69. package/src/funcs/entitlementsGrantsPurchase.ts +1 -1
  70. package/src/lib/config.ts +2 -2
  71. package/src/models/index.ts +1 -0
  72. package/src/models/invoice.ts +7 -0
  73. package/src/models/operations/createsubscription.ts +13 -0
  74. package/src/models/operations/listsubscriptions.ts +9 -0
  75. package/src/models/operations/updatesubscription.ts +6 -0
  76. package/src/models/subscription.ts +14 -0
  77. package/src/models/subscriptionmetadata.ts +43 -0
  78. package/src/sdk/grants.ts +1 -1
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import * as z from "zod/v3";
6
+ import * as models from "../index.js";
6
7
 
7
8
  /**
8
9
  * Address is required for tax calculation. Must include: country (ISO 3166-1 alpha-2) and zipCode. The state/region field is required and validated for US/CA addresses only (custom validation in API logic). Postal code format is not validated but will be normalized.
@@ -104,10 +105,18 @@ export type CreateSubscriptionRequest = {
104
105
  * Override plan setting for number of days before renewal to send the reminder. Only used if renewalReminderEnabled is true (or inherited from plan). Set to null to use plan default.
105
106
  */
106
107
  renewalReminderDays?: number | null | undefined;
108
+ /**
109
+ * Payment term in days ("Net X") applied to every invoice the subscription generates: invoice dueAt = invoice issue date + paymentTermDays. Defaults to 0 ("due on issue"). A non-zero value is only valid alongside bankTransferOnly=true.
110
+ */
111
+ paymentTermDays?: number | undefined;
107
112
  /**
108
113
  * Number of minutes until the payment session expires. Defaults to 240 minutes (4 hours) if not provided.
109
114
  */
110
115
  sessionExpiryMinutes?: number | undefined;
116
+ /**
117
+ * Free-form merchant metadata to attach to the subscription. Values must be strings, numbers, or booleans.
118
+ */
119
+ metadata?: { [k: string]: models.SubscriptionMetadata } | undefined;
111
120
  };
112
121
 
113
122
  /** @internal */
@@ -200,7 +209,9 @@ export type CreateSubscriptionRequest$Outbound = {
200
209
  testClockId?: string | undefined;
201
210
  renewalReminderEnabled?: boolean | null | undefined;
202
211
  renewalReminderDays?: number | null | undefined;
212
+ paymentTermDays?: number | undefined;
203
213
  sessionExpiryMinutes?: number | undefined;
214
+ metadata?: { [k: string]: models.SubscriptionMetadata$Outbound } | undefined;
204
215
  };
205
216
 
206
217
  /** @internal */
@@ -223,7 +234,9 @@ export const CreateSubscriptionRequest$outboundSchema: z.ZodType<
223
234
  testClockId: z.string().optional(),
224
235
  renewalReminderEnabled: z.nullable(z.boolean()).optional(),
225
236
  renewalReminderDays: z.nullable(z.number().int()).optional(),
237
+ paymentTermDays: z.number().int().optional(),
226
238
  sessionExpiryMinutes: z.number().optional(),
239
+ metadata: z.record(models.SubscriptionMetadata$outboundSchema).optional(),
227
240
  });
228
241
 
229
242
  export function createSubscriptionRequestToJSON(
@@ -30,12 +30,21 @@ export const Include = {
30
30
  export type Include = ClosedEnum<typeof Include>;
31
31
 
32
32
  export type ListSubscriptionsRequest = {
33
+ /**
34
+ * Return subscriptions for this consumer organization. May be combined with `merchantId` to scope to a single consumer/merchant pair. Cannot be combined with `customerId`.
35
+ */
33
36
  consumerId?: string | undefined;
37
+ /**
38
+ * Return subscriptions for this customer. Cannot be combined with `consumerId` or `merchantId`.
39
+ */
34
40
  customerId?: string | undefined;
35
41
  /**
36
42
  * Number of subscriptions to return
37
43
  */
38
44
  limit?: string | undefined;
45
+ /**
46
+ * Return subscriptions for this merchant organization. May be combined with `consumerId` to scope to a single consumer/merchant pair. Cannot be combined with `customerId`.
47
+ */
39
48
  merchantId?: string | undefined;
40
49
  /**
41
50
  * Number of subscriptions to skip
@@ -46,6 +46,10 @@ export type UpdateSubscriptionRequestBody = {
46
46
  * Override plan setting for number of days before renewal to send the reminder. Set to null to use plan default.
47
47
  */
48
48
  renewalReminderDays?: number | null | undefined;
49
+ /**
50
+ * Payment term in days ("Net X") applied to subsequently generated invoices: invoice dueAt = invoice issue date + paymentTermDays. A non-zero value is only valid alongside bankTransferOnly=true. Set 0 for "due on issue". Already-issued invoices keep their snapshotted dueAt.
51
+ */
52
+ paymentTermDays?: number | undefined;
49
53
  };
50
54
 
51
55
  export type UpdateSubscriptionRequest = {
@@ -70,6 +74,7 @@ export type UpdateSubscriptionRequestBody$Outbound = {
70
74
  minimumAccountBalance?: string | undefined;
71
75
  renewalReminderEnabled?: boolean | null | undefined;
72
76
  renewalReminderDays?: number | null | undefined;
77
+ paymentTermDays?: number | undefined;
73
78
  };
74
79
 
75
80
  /** @internal */
@@ -88,6 +93,7 @@ export const UpdateSubscriptionRequestBody$outboundSchema: z.ZodType<
88
93
  minimumAccountBalance: z.string().optional(),
89
94
  renewalReminderEnabled: z.nullable(z.boolean()).optional(),
90
95
  renewalReminderDays: z.nullable(z.number().int()).optional(),
96
+ paymentTermDays: z.number().int().optional(),
91
97
  });
92
98
 
93
99
  export function updateSubscriptionRequestBodyToJSON(
@@ -7,6 +7,10 @@ import { safeParse } from "../lib/schemas.js";
7
7
  import { ClosedEnum } from "../types/enums.js";
8
8
  import { Result as SafeParseResult } from "../types/fp.js";
9
9
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
10
+ import {
11
+ SubscriptionMetadata,
12
+ SubscriptionMetadata$inboundSchema,
13
+ } from "./subscriptionmetadata.js";
10
14
 
11
15
  export const SubscriptionObject = {
12
16
  Subscription: "subscription",
@@ -193,10 +197,18 @@ export type Subscription = {
193
197
  * Number of days before renewal to send the reminder. Null means use plan default.
194
198
  */
195
199
  renewalReminderDays?: number | null | undefined;
200
+ /**
201
+ * Payment term in days ("Net X") snapshotted onto every invoice the subscription generates (invoice dueAt = invoice issue date + paymentTermDays). Defaults to 0 ("due on issue"); a non-zero value is only set on bankTransferOnly subscriptions.
202
+ */
203
+ paymentTermDays: number;
196
204
  /**
197
205
  * Subscription-level auto-approval override. Null means plan default is used.
198
206
  */
199
207
  autoApprove?: boolean | null | undefined;
208
+ /**
209
+ * Free-form merchant metadata to attach to the subscription. Values must be strings, numbers, or booleans.
210
+ */
211
+ metadata?: { [k: string]: SubscriptionMetadata } | undefined;
200
212
  /**
201
213
  * Customer details with merchant and consumer information. Only included when include=customer is specified in the list query.
202
214
  */
@@ -420,7 +432,9 @@ export const Subscription$inboundSchema: z.ZodType<
420
432
  walletId: z.string().optional(),
421
433
  renewalReminderEnabled: z.nullable(z.boolean()).optional(),
422
434
  renewalReminderDays: z.nullable(z.number().int()).optional(),
435
+ paymentTermDays: z.number().int(),
423
436
  autoApprove: z.nullable(z.boolean()).optional(),
437
+ metadata: z.record(SubscriptionMetadata$inboundSchema).optional(),
424
438
  customer: z.lazy(() => SubscriptionCustomer$inboundSchema).optional(),
425
439
  });
426
440
 
@@ -0,0 +1,43 @@
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 SubscriptionMetadata = string | number | boolean;
11
+
12
+ /** @internal */
13
+ export const SubscriptionMetadata$inboundSchema: z.ZodType<
14
+ SubscriptionMetadata,
15
+ z.ZodTypeDef,
16
+ unknown
17
+ > = z.union([z.string(), z.number(), z.boolean()]);
18
+ /** @internal */
19
+ export type SubscriptionMetadata$Outbound = string | number | boolean;
20
+
21
+ /** @internal */
22
+ export const SubscriptionMetadata$outboundSchema: z.ZodType<
23
+ SubscriptionMetadata$Outbound,
24
+ z.ZodTypeDef,
25
+ SubscriptionMetadata
26
+ > = z.union([z.string(), z.number(), z.boolean()]);
27
+
28
+ export function subscriptionMetadataToJSON(
29
+ subscriptionMetadata: SubscriptionMetadata,
30
+ ): string {
31
+ return JSON.stringify(
32
+ SubscriptionMetadata$outboundSchema.parse(subscriptionMetadata),
33
+ );
34
+ }
35
+ export function subscriptionMetadataFromJSON(
36
+ jsonString: string,
37
+ ): SafeParseResult<SubscriptionMetadata, SDKValidationError> {
38
+ return safeParse(
39
+ jsonString,
40
+ (x) => SubscriptionMetadata$inboundSchema.parse(JSON.parse(x)),
41
+ `Failed to parse 'SubscriptionMetadata' from JSON`,
42
+ );
43
+ }
package/src/sdk/grants.ts CHANGED
@@ -53,7 +53,7 @@ export class Grants extends ClientSDK {
53
53
  * @remarks
54
54
  * Create an ad-hoc invoice with a payment session for a grant purchase. The customer pays via the returned payment URL; the grant is created automatically on payment completion. If payment expires, the invoice is cancelled and no grant is created.
55
55
  *
56
- * After the consumer completes payment, the grant is created automatically. To confirm payment completion, poll `GET /v2/invoices/{invoiceId}` using the `invoiceId` from the response and check for `status === "PAID"`. Recommended polling interval: 2 seconds, timeout: 60 seconds.
56
+ * To confirm payment completion, subscribe to the `invoice.paid.v0` webhook. The payload includes the original `invoiceId` and the created `grantId`, so you can correlate the purchase response with downstream fulfilment without an extra fetch. As a fallback if you cannot consume webhooks, poll `GET /v2/invoices/{invoiceId}` (interval 2s, timeout 60s) and check for `status === "PAID"`.
57
57
  */
58
58
  async purchase(
59
59
  request: operations.PurchaseEntitlementGrantRequest,