dodopayments 2.26.0 → 2.28.0

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 (52) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/client.d.mts +2 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +2 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs.map +1 -1
  8. package/internal/utils/env.js +2 -2
  9. package/internal/utils/env.js.map +1 -1
  10. package/internal/utils/env.mjs +2 -2
  11. package/internal/utils/env.mjs.map +1 -1
  12. package/package.json +1 -1
  13. package/resources/discounts.d.mts +15 -0
  14. package/resources/discounts.d.mts.map +1 -1
  15. package/resources/discounts.d.ts +15 -0
  16. package/resources/discounts.d.ts.map +1 -1
  17. package/resources/index.d.mts +1 -1
  18. package/resources/index.d.mts.map +1 -1
  19. package/resources/index.d.ts +1 -1
  20. package/resources/index.d.ts.map +1 -1
  21. package/resources/index.js.map +1 -1
  22. package/resources/index.mjs.map +1 -1
  23. package/resources/license-keys.d.mts +47 -21
  24. package/resources/license-keys.d.mts.map +1 -1
  25. package/resources/license-keys.d.ts +47 -21
  26. package/resources/license-keys.d.ts.map +1 -1
  27. package/resources/license-keys.js +13 -16
  28. package/resources/license-keys.js.map +1 -1
  29. package/resources/license-keys.mjs +13 -16
  30. package/resources/license-keys.mjs.map +1 -1
  31. package/resources/products/products.d.mts +132 -9
  32. package/resources/products/products.d.mts.map +1 -1
  33. package/resources/products/products.d.ts +132 -9
  34. package/resources/products/products.d.ts.map +1 -1
  35. package/resources/products/products.js.map +1 -1
  36. package/resources/products/products.mjs.map +1 -1
  37. package/resources/webhook-events.d.mts +28 -2
  38. package/resources/webhook-events.d.mts.map +1 -1
  39. package/resources/webhook-events.d.ts +28 -2
  40. package/resources/webhook-events.d.ts.map +1 -1
  41. package/src/client.ts +2 -0
  42. package/src/internal/utils/env.ts +2 -2
  43. package/src/resources/discounts.ts +12 -0
  44. package/src/resources/index.ts +1 -0
  45. package/src/resources/license-keys.ts +57 -20
  46. package/src/resources/products/products.ts +208 -9
  47. package/src/resources/webhook-events.ts +57 -2
  48. package/src/version.ts +1 -1
  49. package/version.d.mts +1 -1
  50. package/version.d.ts +1 -1
  51. package/version.js +1 -1
  52. package/version.mjs +1 -1
@@ -10,13 +10,13 @@ export declare class WebhookEvents extends APIResource {
10
10
  /**
11
11
  * Event types for Dodo events
12
12
  */
13
- export type WebhookEventType = 'payment.succeeded' | 'payment.failed' | 'payment.processing' | 'payment.cancelled' | 'refund.succeeded' | 'refund.failed' | 'dispute.opened' | 'dispute.expired' | 'dispute.accepted' | 'dispute.cancelled' | 'dispute.challenged' | 'dispute.won' | 'dispute.lost' | 'subscription.active' | 'subscription.renewed' | 'subscription.on_hold' | 'subscription.cancelled' | 'subscription.failed' | 'subscription.expired' | 'subscription.plan_changed' | 'subscription.updated' | 'license_key.created' | 'payout.not_initiated' | 'payout.on_hold' | 'payout.in_progress' | 'payout.failed' | 'payout.success' | 'credit.added' | 'credit.deducted' | 'credit.expired' | 'credit.rolled_over' | 'credit.rollover_forfeited' | 'credit.overage_charged' | 'credit.manual_adjustment' | 'credit.balance_low' | 'abandoned_checkout.detected' | 'abandoned_checkout.recovered' | 'dunning.started' | 'dunning.recovered' | 'acr.email' | 'dunning.email';
13
+ export type WebhookEventType = 'payment.succeeded' | 'payment.failed' | 'payment.processing' | 'payment.cancelled' | 'refund.succeeded' | 'refund.failed' | 'dispute.opened' | 'dispute.expired' | 'dispute.accepted' | 'dispute.cancelled' | 'dispute.challenged' | 'dispute.won' | 'dispute.lost' | 'subscription.active' | 'subscription.renewed' | 'subscription.on_hold' | 'subscription.cancelled' | 'subscription.failed' | 'subscription.expired' | 'subscription.plan_changed' | 'subscription.updated' | 'license_key.created' | 'payout.not_initiated' | 'payout.on_hold' | 'payout.in_progress' | 'payout.failed' | 'payout.success' | 'credit.added' | 'credit.deducted' | 'credit.expired' | 'credit.rolled_over' | 'credit.rollover_forfeited' | 'credit.overage_charged' | 'credit.manual_adjustment' | 'credit.balance_low' | 'abandoned_checkout.detected' | 'abandoned_checkout.recovered' | 'dunning.started' | 'dunning.recovered' | 'acr.email' | 'dunning.email' | 'entitlement_grant.created' | 'entitlement_grant.delivered' | 'entitlement_grant.failed' | 'entitlement_grant.revoked';
14
14
  export interface WebhookPayload {
15
15
  business_id: string;
16
16
  /**
17
17
  * The latest data at the time of delivery attempt
18
18
  */
19
- data: WebhookPayload.Payment | WebhookPayload.Subscription | WebhookPayload.Refund | WebhookPayload.Dispute | WebhookPayload.LicenseKey | WebhookPayload.CreditLedgerEntry | WebhookPayload.CreditBalanceLow | WebhookPayload.AbandonedCheckout | WebhookPayload.DunningAttempt;
19
+ data: WebhookPayload.Payment | WebhookPayload.Subscription | WebhookPayload.Refund | WebhookPayload.Dispute | WebhookPayload.LicenseKey | WebhookPayload.CreditLedgerEntry | WebhookPayload.CreditBalanceLow | WebhookPayload.AbandonedCheckout | WebhookPayload.DunningAttempt | WebhookPayload.EntitlementGrant;
20
20
  /**
21
21
  * The timestamp of when the event occurred (not necessarily the same of when it
22
22
  * was delivered)
@@ -81,6 +81,32 @@ export declare namespace WebhookPayload {
81
81
  trigger_state: 'on_hold' | 'cancelled';
82
82
  payment_id?: string | null;
83
83
  }
84
+ interface EntitlementGrant {
85
+ id: string;
86
+ business_id: string;
87
+ created_at: string;
88
+ customer_id: string;
89
+ entitlement_id: string;
90
+ external_id: string;
91
+ payload_type: 'EntitlementGrant';
92
+ status: 'Pending' | 'Delivered' | 'Failed' | 'Revoked';
93
+ updated_at: string;
94
+ delivered_at?: string | null;
95
+ error_code?: string | null;
96
+ error_message?: string | null;
97
+ license_key?: string | null;
98
+ license_key_activations_limit?: number | null;
99
+ license_key_activations_used?: number | null;
100
+ license_key_expires_at?: string | null;
101
+ license_key_status?: string | null;
102
+ metadata?: unknown;
103
+ oauth_expires_at?: string | null;
104
+ oauth_url?: string | null;
105
+ payment_id?: string | null;
106
+ revocation_reason?: string | null;
107
+ revoked_at?: string | null;
108
+ subscription_id?: string | null;
109
+ }
84
110
  }
85
111
  export declare namespace WebhookEvents {
86
112
  export { type WebhookEventType as WebhookEventType, type WebhookPayload as WebhookPayload };
@@ -1 +1 @@
1
- {"version":3,"file":"webhook-events.d.ts","sourceRoot":"","sources":["../src/resources/webhook-events.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,WAAW;OAChB,KAAK,cAAc;OACnB,KAAK,WAAW;OAChB,KAAK,UAAU;OACf,KAAK,gBAAgB;OACrB,KAAK,WAAW;AAEvB,qBAAa,aAAc,SAAQ,WAAW;CAAG;AAEjD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,mBAAmB,GACnB,gBAAgB,GAChB,oBAAoB,GACpB,mBAAmB,GACnB,kBAAkB,GAClB,eAAe,GACf,gBAAgB,GAChB,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,GACnB,oBAAoB,GACpB,aAAa,GACb,cAAc,GACd,qBAAqB,GACrB,sBAAsB,GACtB,sBAAsB,GACtB,wBAAwB,GACxB,qBAAqB,GACrB,sBAAsB,GACtB,2BAA2B,GAC3B,sBAAsB,GACtB,qBAAqB,GACrB,sBAAsB,GACtB,gBAAgB,GAChB,oBAAoB,GACpB,eAAe,GACf,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,oBAAoB,GACpB,2BAA2B,GAC3B,wBAAwB,GACxB,0BAA0B,GAC1B,oBAAoB,GACpB,6BAA6B,GAC7B,8BAA8B,GAC9B,iBAAiB,GACjB,mBAAmB,GACnB,WAAW,GACX,eAAe,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,IAAI,EACA,cAAc,CAAC,OAAO,GACtB,cAAc,CAAC,YAAY,GAC3B,cAAc,CAAC,MAAM,GACrB,cAAc,CAAC,OAAO,GACtB,cAAc,CAAC,UAAU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mB,CAAC;QAElC,UAAU,EAAE,MAAM,CAAC;QAEnB,MAAM,EAAE,WAAW,GAAG,YAAY,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;QAE7E,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACtC;IAED,UAAiB,cAAc;QAC7B,UAAU,EAAE,MAAM,CAAC;QAEnB,WAAW,EAAE,MAAM,CAAC;QAEpB,YAAY,EAAE,gBAAgB,CAAC;QAE/B,MAAM,EAAE,YAAY,GAAG,WAAW,GAAG,WAAW,CAAC;QAEjD,eAAe,EAAE,MAAM,CAAC;QAExB,aAAa,EAAE,SAAS,GAAG,WAAW,CAAC;QAEvC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC5B;CACF;AAED,MAAM,CAAC,OAAO,WAAW,aAAa,CAAC;IACrC,OAAO,EAAE,KAAK,gBAAgB,IAAI,gBAAgB,EAAE,KAAK,cAAc,IAAI,cAAc,EAAE,CAAC;CAC7F"}
1
+ {"version":3,"file":"webhook-events.d.ts","sourceRoot":"","sources":["../src/resources/webhook-events.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,WAAW;OAChB,KAAK,cAAc;OACnB,KAAK,WAAW;OAChB,KAAK,UAAU;OACf,KAAK,gBAAgB;OACrB,KAAK,WAAW;AAEvB,qBAAa,aAAc,SAAQ,WAAW;CAAG;AAEjD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,mBAAmB,GACnB,gBAAgB,GAChB,oBAAoB,GACpB,mBAAmB,GACnB,kBAAkB,GAClB,eAAe,GACf,gBAAgB,GAChB,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,GACnB,oBAAoB,GACpB,aAAa,GACb,cAAc,GACd,qBAAqB,GACrB,sBAAsB,GACtB,sBAAsB,GACtB,wBAAwB,GACxB,qBAAqB,GACrB,sBAAsB,GACtB,2BAA2B,GAC3B,sBAAsB,GACtB,qBAAqB,GACrB,sBAAsB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QAEpB,YAAY,EAAE,kBAAkB,CAAC;QAEjC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;QAEvD,UAAU,EAAE,MAAM,CAAC;QAEnB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE7B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE3B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE9B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE5B,6BAA6B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE9C,4BAA4B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE7C,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAEvC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAEnC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAEnB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAEjC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE1B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE3B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAElC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE3B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACjC;CACF;AAED,MAAM,CAAC,OAAO,WAAW,aAAa,CAAC;IACrC,OAAO,EAAE,KAAK,gBAAgB,IAAI,gBAAgB,EAAE,KAAK,cAAc,IAAI,cAAc,EAAE,CAAC;CAC7F"}
package/src/client.ts CHANGED
@@ -93,6 +93,7 @@ import {
93
93
  } from './resources/license-key-instances';
94
94
  import {
95
95
  LicenseKey,
96
+ LicenseKeyCreateParams,
96
97
  LicenseKeyListParams,
97
98
  LicenseKeyStatus,
98
99
  LicenseKeyUpdateParams,
@@ -1189,6 +1190,7 @@ export declare namespace DodoPayments {
1189
1190
  type LicenseKey as LicenseKey,
1190
1191
  type LicenseKeyStatus as LicenseKeyStatus,
1191
1192
  type LicenseKeysDefaultPageNumberPagination as LicenseKeysDefaultPageNumberPagination,
1193
+ type LicenseKeyCreateParams as LicenseKeyCreateParams,
1192
1194
  type LicenseKeyUpdateParams as LicenseKeyUpdateParams,
1193
1195
  type LicenseKeyListParams as LicenseKeyListParams,
1194
1196
  };
@@ -9,10 +9,10 @@
9
9
  */
10
10
  export const readEnv = (env: string): string | undefined => {
11
11
  if (typeof (globalThis as any).process !== 'undefined') {
12
- return (globalThis as any).process.env?.[env]?.trim() ?? undefined;
12
+ return (globalThis as any).process.env?.[env]?.trim() || undefined;
13
13
  }
14
14
  if (typeof (globalThis as any).Deno !== 'undefined') {
15
- return (globalThis as any).Deno.env?.get?.(env)?.trim();
15
+ return (globalThis as any).Deno.env?.get?.(env)?.trim() || undefined;
16
16
  }
17
17
  return undefined;
18
18
  };
@@ -99,6 +99,8 @@ export interface Discount {
99
99
  */
100
100
  discount_id: string;
101
101
 
102
+ metadata: { [key: string]: string };
103
+
102
104
  /**
103
105
  * Whether this discount should be preserved when a subscription changes plans.
104
106
  * Default: false (discount is removed on plan change)
@@ -176,6 +178,11 @@ export interface DiscountCreateParams {
176
178
  */
177
179
  expires_at?: string | null;
178
180
 
181
+ /**
182
+ * Additional metadata for the discount
183
+ */
184
+ metadata?: { [key: string]: string };
185
+
179
186
  name?: string | null;
180
187
 
181
188
  /**
@@ -221,6 +228,11 @@ export interface DiscountUpdateParams {
221
228
 
222
229
  expires_at?: string | null;
223
230
 
231
+ /**
232
+ * Additional metadata for the discount
233
+ */
234
+ metadata?: { [key: string]: string } | null;
235
+
224
236
  name?: string | null;
225
237
 
226
238
  /**
@@ -92,6 +92,7 @@ export {
92
92
  LicenseKeys,
93
93
  type LicenseKey,
94
94
  type LicenseKeyStatus,
95
+ type LicenseKeyCreateParams,
95
96
  type LicenseKeyUpdateParams,
96
97
  type LicenseKeyListParams,
97
98
  type LicenseKeysDefaultPageNumberPagination,
@@ -14,35 +14,33 @@ export class LicenseKeys extends APIResource {
14
14
  /**
15
15
  * @example
16
16
  * ```ts
17
- * const licenseKey = await client.licenseKeys.retrieve(
18
- * 'lic_123',
19
- * );
17
+ * const licenseKey = await client.licenseKeys.create({
18
+ * customer_id: 'customer_id',
19
+ * key: 'key',
20
+ * product_id: 'product_id',
21
+ * });
20
22
  * ```
21
23
  */
24
+ create(body: LicenseKeyCreateParams, options?: RequestOptions): APIPromise<LicenseKey> {
25
+ return this._client.post('/license_keys', { body, ...options });
26
+ }
27
+
28
+ /**
29
+ * @deprecated
30
+ */
22
31
  retrieve(id: string, options?: RequestOptions): APIPromise<LicenseKey> {
23
32
  return this._client.get(path`/license_keys/${id}`, options);
24
33
  }
25
34
 
26
35
  /**
27
- * @example
28
- * ```ts
29
- * const licenseKey = await client.licenseKeys.update(
30
- * 'lic_123',
31
- * );
32
- * ```
36
+ * @deprecated
33
37
  */
34
38
  update(id: string, body: LicenseKeyUpdateParams, options?: RequestOptions): APIPromise<LicenseKey> {
35
39
  return this._client.patch(path`/license_keys/${id}`, { body, ...options });
36
40
  }
37
41
 
38
42
  /**
39
- * @example
40
- * ```ts
41
- * // Automatically fetches more pages as needed.
42
- * for await (const licenseKey of client.licenseKeys.list()) {
43
- * // ...
44
- * }
45
- * ```
43
+ * @deprecated
46
44
  */
47
45
  list(
48
46
  query: LicenseKeyListParams | null | undefined = {},
@@ -89,14 +87,15 @@ export interface LicenseKey {
89
87
  key: string;
90
88
 
91
89
  /**
92
- * The unique identifier of the payment associated with the license key.
90
+ * The unique identifier of the product associated with the license key.
93
91
  */
94
- payment_id: string;
92
+ product_id: string;
95
93
 
96
94
  /**
97
- * The unique identifier of the product associated with the license key.
95
+ * The source of the license key - 'auto' for keys generated by
96
+ * payment/subscription flows, 'import' for merchant-imported keys.
98
97
  */
99
- product_id: string;
98
+ source: 'auto' | 'import';
100
99
 
101
100
  /**
102
101
  * The current status of the license key (e.g., active, inactive, expired).
@@ -113,6 +112,11 @@ export interface LicenseKey {
113
112
  */
114
113
  expires_at?: string | null;
115
114
 
115
+ /**
116
+ * The unique identifier of the payment associated with the license key, if any.
117
+ */
118
+ payment_id?: string | null;
119
+
116
120
  /**
117
121
  * The unique identifier of the subscription associated with the license key, if
118
122
  * any.
@@ -122,6 +126,33 @@ export interface LicenseKey {
122
126
 
123
127
  export type LicenseKeyStatus = 'active' | 'expired' | 'disabled';
124
128
 
129
+ export interface LicenseKeyCreateParams {
130
+ /**
131
+ * The customer this license key belongs to.
132
+ */
133
+ customer_id: string;
134
+
135
+ /**
136
+ * The license key string to import.
137
+ */
138
+ key: string;
139
+
140
+ /**
141
+ * The product this license key is for.
142
+ */
143
+ product_id: string;
144
+
145
+ /**
146
+ * Maximum number of activations allowed. Null means unlimited.
147
+ */
148
+ activations_limit?: number | null;
149
+
150
+ /**
151
+ * Expiration timestamp. Null means the key never expires.
152
+ */
153
+ expires_at?: string | null;
154
+ }
155
+
125
156
  export interface LicenseKeyUpdateParams {
126
157
  /**
127
158
  * The updated activation limit for the license key. Use `null` to remove the
@@ -163,6 +194,11 @@ export interface LicenseKeyListParams extends DefaultPageNumberPaginationParams
163
194
  */
164
195
  product_id?: string;
165
196
 
197
+ /**
198
+ * Filter by license key source
199
+ */
200
+ source?: 'auto' | 'import';
201
+
166
202
  /**
167
203
  * Filter by license key status
168
204
  */
@@ -174,6 +210,7 @@ export declare namespace LicenseKeys {
174
210
  type LicenseKey as LicenseKey,
175
211
  type LicenseKeyStatus as LicenseKeyStatus,
176
212
  type LicenseKeysDefaultPageNumberPagination as LicenseKeysDefaultPageNumberPagination,
213
+ type LicenseKeyCreateParams as LicenseKeyCreateParams,
177
214
  type LicenseKeyUpdateParams as LicenseKeyUpdateParams,
178
215
  type LicenseKeyListParams as LicenseKeyListParams,
179
216
  };
@@ -542,13 +542,18 @@ export interface Product {
542
542
  */
543
543
  credit_entitlements: Array<CreditEntitlementMappingResponse>;
544
544
 
545
+ /**
546
+ * Attached entitlements (integration-based access grants)
547
+ */
548
+ entitlements: Array<Product.Entitlement>;
549
+
545
550
  /**
546
551
  * Indicates if the product is recurring (e.g., subscriptions).
547
552
  */
548
553
  is_recurring: boolean;
549
554
 
550
555
  /**
551
- * Indicates whether the product requires a license key.
556
+ * @deprecated Indicates whether the product requires a license key.
552
557
  */
553
558
  license_key_enabled: boolean;
554
559
 
@@ -595,12 +600,12 @@ export interface Product {
595
600
  image?: string | null;
596
601
 
597
602
  /**
598
- * Message sent upon license key activation, if applicable.
603
+ * @deprecated Message sent upon license key activation, if applicable.
599
604
  */
600
605
  license_key_activation_message?: string | null;
601
606
 
602
607
  /**
603
- * Limit on the number of activations for the license key, if enabled.
608
+ * @deprecated Limit on the number of activations for the license key, if enabled.
604
609
  */
605
610
  license_key_activations_limit?: number | null;
606
611
 
@@ -620,6 +625,94 @@ export interface Product {
620
625
  product_collection_id?: string | null;
621
626
  }
622
627
 
628
+ export namespace Product {
629
+ /**
630
+ * Summary of an entitlement attached to a product
631
+ */
632
+ export interface Entitlement {
633
+ id: string;
634
+
635
+ /**
636
+ * Platform-specific configuration for an entitlement. Each variant uses unique
637
+ * field names so `#[serde(untagged)]` can disambiguate correctly.
638
+ */
639
+ integration_config:
640
+ | Entitlement.GitHubConfig
641
+ | Entitlement.DiscordConfig
642
+ | Entitlement.TelegramConfig
643
+ | Entitlement.FigmaConfig
644
+ | Entitlement.FramerConfig
645
+ | Entitlement.NotionConfig
646
+ | Entitlement.DigitalFilesConfig
647
+ | Entitlement.LicenseKeyConfig;
648
+
649
+ integration_type:
650
+ | 'discord'
651
+ | 'telegram'
652
+ | 'github'
653
+ | 'figma'
654
+ | 'framer'
655
+ | 'notion'
656
+ | 'digital_files'
657
+ | 'license_key';
658
+
659
+ name: string;
660
+
661
+ description?: string | null;
662
+ }
663
+
664
+ export namespace Entitlement {
665
+ export interface GitHubConfig {
666
+ /**
667
+ * One of: pull, push, admin, maintain, triage
668
+ */
669
+ permission: string;
670
+
671
+ target_id: string;
672
+ }
673
+
674
+ export interface DiscordConfig {
675
+ guild_id: string;
676
+
677
+ role_id?: string | null;
678
+ }
679
+
680
+ export interface TelegramConfig {
681
+ chat_id: string;
682
+ }
683
+
684
+ export interface FigmaConfig {
685
+ figma_file_id: string;
686
+ }
687
+
688
+ export interface FramerConfig {
689
+ framer_template_id: string;
690
+ }
691
+
692
+ export interface NotionConfig {
693
+ notion_template_id: string;
694
+ }
695
+
696
+ export interface DigitalFilesConfig {
697
+ digital_file_ids: Array<string>;
698
+
699
+ external_url?: string | null;
700
+
701
+ instructions?: string | null;
702
+ }
703
+
704
+ export interface LicenseKeyConfig {
705
+ activation_message?: string | null;
706
+
707
+ activations_limit?: number | null;
708
+
709
+ duration_count?: number | null;
710
+
711
+ duration_interval?: string | null;
712
+ }
713
+ }
714
+ }
715
+
623
716
  export interface ProductListResponse {
624
717
  /**
625
718
  * Unique identifier for the business to which the product belongs.
@@ -631,6 +724,11 @@ export interface ProductListResponse {
631
724
  */
632
725
  created_at: string;
633
726
 
727
+ /**
728
+ * Entitlements linked to this product
729
+ */
730
+ entitlements: Array<ProductListResponse.Entitlement>;
731
+
634
732
  /**
635
733
  * Indicates if the product is recurring (e.g., subscriptions).
636
734
  */
@@ -701,6 +799,94 @@ export interface ProductListResponse {
701
799
  tax_inclusive?: boolean | null;
702
800
  }
703
801
 
802
+ export namespace ProductListResponse {
803
+ /**
804
+ * Summary of an entitlement attached to a product
805
+ */
806
+ export interface Entitlement {
807
+ id: string;
808
+
809
+ /**
810
+ * Platform-specific configuration for an entitlement. Each variant uses unique
811
+ * field names so `#[serde(untagged)]` can disambiguate correctly.
812
+ */
813
+ integration_config:
814
+ | Entitlement.GitHubConfig
815
+ | Entitlement.DiscordConfig
816
+ | Entitlement.TelegramConfig
817
+ | Entitlement.FigmaConfig
818
+ | Entitlement.FramerConfig
819
+ | Entitlement.NotionConfig
820
+ | Entitlement.DigitalFilesConfig
821
+ | Entitlement.LicenseKeyConfig;
822
+
823
+ integration_type:
824
+ | 'discord'
825
+ | 'telegram'
826
+ | 'github'
827
+ | 'figma'
828
+ | 'framer'
829
+ | 'notion'
830
+ | 'digital_files'
831
+ | 'license_key';
832
+
833
+ name: string;
834
+
835
+ description?: string | null;
836
+ }
837
+
838
+ export namespace Entitlement {
839
+ export interface GitHubConfig {
840
+ /**
841
+ * One of: pull, push, admin, maintain, triage
842
+ */
843
+ permission: string;
844
+
845
+ target_id: string;
846
+ }
847
+
848
+ export interface DiscordConfig {
849
+ guild_id: string;
850
+
851
+ role_id?: string | null;
852
+ }
853
+
854
+ export interface TelegramConfig {
855
+ chat_id: string;
856
+ }
857
+
858
+ export interface FigmaConfig {
859
+ figma_file_id: string;
860
+ }
861
+
862
+ export interface FramerConfig {
863
+ framer_template_id: string;
864
+ }
865
+
866
+ export interface NotionConfig {
867
+ notion_template_id: string;
868
+ }
869
+
870
+ export interface DigitalFilesConfig {
871
+ digital_file_ids: Array<string>;
872
+
873
+ external_url?: string | null;
874
+
875
+ instructions?: string | null;
876
+ }
877
+
878
+ export interface LicenseKeyConfig {
879
+ activation_message?: string | null;
880
+
881
+ activations_limit?: number | null;
882
+
883
+ duration_count?: number | null;
884
+
885
+ duration_interval?: string | null;
886
+ }
887
+ }
888
+ }
889
+
704
890
  export interface ProductUpdateFilesResponse {
705
891
  file_id: string;
706
892
 
@@ -749,12 +935,18 @@ export interface ProductCreateParams {
749
935
  digital_product_delivery?: ProductCreateParams.DigitalProductDelivery | null;
750
936
 
751
937
  /**
752
- * Optional message displayed during license key activation
938
+ * Optional entitlement IDs to attach to this product (max 20)
939
+ */
940
+ entitlement_ids?: Array<string> | null;
941
+
942
+ /**
943
+ * @deprecated Optional message displayed during license key activation
753
944
  */
754
945
  license_key_activation_message?: string | null;
755
946
 
756
947
  /**
757
- * The number of times the license key can be activated. Must be 0 or greater
948
+ * @deprecated The number of times the license key can be activated. Must be 0 or
949
+ * greater
758
950
  */
759
951
  license_key_activations_limit?: number | null;
760
952
 
@@ -766,7 +958,8 @@ export interface ProductCreateParams {
766
958
  license_key_duration?: LicenseKeyDuration | null;
767
959
 
768
960
  /**
769
- * When true, generates and sends a license key to your customer. Defaults to false
961
+ * @deprecated When true, generates and sends a license key to your customer.
962
+ * Defaults to false
770
963
  */
771
964
  license_key_enabled?: boolean | null;
772
965
 
@@ -817,13 +1010,19 @@ export interface ProductUpdateParams {
817
1010
  */
818
1011
  digital_product_delivery?: ProductUpdateParams.DigitalProductDelivery | null;
819
1012
 
1013
+ /**
1014
+ * Entitlement IDs to attach (replaces all existing when present) Send empty array
1015
+ * to remove all, omit field to leave unchanged
1016
+ */
1017
+ entitlement_ids?: Array<string> | null;
1018
+
820
1019
  /**
821
1020
  * Product image id after its uploaded to S3
822
1021
  */
823
1022
  image_id?: string | null;
824
1023
 
825
1024
  /**
826
- * Message sent to the customer upon license key activation.
1025
+ * @deprecated Message sent to the customer upon license key activation.
827
1026
  *
828
1027
  * Only applicable if `license_key_enabled` is `true`. This message contains
829
1028
  * instructions for activating the license key.
@@ -831,7 +1030,7 @@ export interface ProductUpdateParams {
831
1030
  license_key_activation_message?: string | null;
832
1031
 
833
1032
  /**
834
- * Limit for the number of activations for the license key.
1033
+ * @deprecated Limit for the number of activations for the license key.
835
1034
  *
836
1035
  * Only applicable if `license_key_enabled` is `true`. Represents the maximum
837
1036
  * number of times the license key can be activated.
@@ -847,7 +1046,7 @@ export interface ProductUpdateParams {
847
1046
  license_key_duration?: LicenseKeyDuration | null;
848
1047
 
849
1048
  /**
850
- * Whether the product requires a license key.
1049
+ * @deprecated Whether the product requires a license key.
851
1050
  *
852
1051
  * If `true`, additional fields related to license key (duration, activations
853
1052
  * limit, activation message) become applicable.
@@ -54,7 +54,11 @@ export type WebhookEventType =
54
54
  | 'dunning.started'
55
55
  | 'dunning.recovered'
56
56
  | 'acr.email'
57
- | 'dunning.email';
57
+ | 'dunning.email'
58
+ | 'entitlement_grant.created'
59
+ | 'entitlement_grant.delivered'
60
+ | 'entitlement_grant.failed'
61
+ | 'entitlement_grant.revoked';
58
62
 
59
63
  export interface WebhookPayload {
60
64
  business_id: string;
@@ -71,7 +75,8 @@ export interface WebhookPayload {
71
75
  | WebhookPayload.CreditLedgerEntry
72
76
  | WebhookPayload.CreditBalanceLow
73
77
  | WebhookPayload.AbandonedCheckout
74
- | WebhookPayload.DunningAttempt;
78
+ | WebhookPayload.DunningAttempt
79
+ | WebhookPayload.EntitlementGrant;
75
80
 
76
81
  /**
77
82
  * The timestamp of when the event occurred (not necessarily the same of when it
@@ -167,6 +172,56 @@ export namespace WebhookPayload {
167
172
 
168
173
  payment_id?: string | null;
169
174
  }
175
+
176
+ export interface EntitlementGrant {
177
+ id: string;
178
+
179
+ business_id: string;
180
+
181
+ created_at: string;
182
+
183
+ customer_id: string;
184
+
185
+ entitlement_id: string;
186
+
187
+ external_id: string;
188
+
189
+ payload_type: 'EntitlementGrant';
190
+
191
+ status: 'Pending' | 'Delivered' | 'Failed' | 'Revoked';
192
+
193
+ updated_at: string;
194
+
195
+ delivered_at?: string | null;
196
+
197
+ error_code?: string | null;
198
+
199
+ error_message?: string | null;
200
+
201
+ license_key?: string | null;
202
+
203
+ license_key_activations_limit?: number | null;
204
+
205
+ license_key_activations_used?: number | null;
206
+
207
+ license_key_expires_at?: string | null;
208
+
209
+ license_key_status?: string | null;
210
+
211
+ metadata?: unknown;
212
+
213
+ oauth_expires_at?: string | null;
214
+
215
+ oauth_url?: string | null;
216
+
217
+ payment_id?: string | null;
218
+
219
+ revocation_reason?: string | null;
220
+
221
+ revoked_at?: string | null;
222
+
223
+ subscription_id?: string | null;
224
+ }
170
225
  }
171
226
 
172
227
  export declare namespace WebhookEvents {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '2.26.0'; // x-release-please-version
1
+ export const VERSION = '2.28.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.26.0";
1
+ export declare const VERSION = "2.28.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.26.0";
1
+ export declare const VERSION = "2.28.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '2.26.0'; // x-release-please-version
4
+ exports.VERSION = '2.28.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.26.0'; // x-release-please-version
1
+ export const VERSION = '2.28.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map