dodopayments 2.50.0 → 2.52.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 (73) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/client.d.mts +3 -0
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +3 -0
  5. package/client.d.ts.map +1 -1
  6. package/client.js +3 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +3 -0
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/balances.d.mts +2 -2
  12. package/resources/balances.d.mts.map +1 -1
  13. package/resources/balances.d.ts +2 -2
  14. package/resources/balances.d.ts.map +1 -1
  15. package/resources/checkout-sessions.d.mts +83 -3
  16. package/resources/checkout-sessions.d.mts.map +1 -1
  17. package/resources/checkout-sessions.d.ts +83 -3
  18. package/resources/checkout-sessions.d.ts.map +1 -1
  19. package/resources/customers/emails.d.mts +9 -7
  20. package/resources/customers/emails.d.mts.map +1 -1
  21. package/resources/customers/emails.d.ts +9 -7
  22. package/resources/customers/emails.d.ts.map +1 -1
  23. package/resources/discounts.d.mts +13 -9
  24. package/resources/discounts.d.mts.map +1 -1
  25. package/resources/discounts.d.ts +13 -9
  26. package/resources/discounts.d.ts.map +1 -1
  27. package/resources/index.d.mts +1 -0
  28. package/resources/index.d.mts.map +1 -1
  29. package/resources/index.d.ts +1 -0
  30. package/resources/index.d.ts.map +1 -1
  31. package/resources/index.js +3 -1
  32. package/resources/index.js.map +1 -1
  33. package/resources/index.mjs +1 -0
  34. package/resources/index.mjs.map +1 -1
  35. package/resources/moderation.d.mts +299 -0
  36. package/resources/moderation.d.mts.map +1 -0
  37. package/resources/moderation.d.ts +299 -0
  38. package/resources/moderation.d.ts.map +1 -0
  39. package/resources/moderation.js +41 -0
  40. package/resources/moderation.js.map +1 -0
  41. package/resources/moderation.mjs +37 -0
  42. package/resources/moderation.mjs.map +1 -0
  43. package/resources/payments.d.mts +27 -1
  44. package/resources/payments.d.mts.map +1 -1
  45. package/resources/payments.d.ts +27 -1
  46. package/resources/payments.d.ts.map +1 -1
  47. package/resources/payouts/breakup/breakup.d.mts +17 -1
  48. package/resources/payouts/breakup/breakup.d.mts.map +1 -1
  49. package/resources/payouts/breakup/breakup.d.ts +17 -1
  50. package/resources/payouts/breakup/breakup.d.ts.map +1 -1
  51. package/resources/payouts/breakup/breakup.js.map +1 -1
  52. package/resources/payouts/breakup/breakup.mjs.map +1 -1
  53. package/resources/payouts/breakup/details.d.mts +9 -8
  54. package/resources/payouts/breakup/details.d.mts.map +1 -1
  55. package/resources/payouts/breakup/details.d.ts +9 -8
  56. package/resources/payouts/breakup/details.d.ts.map +1 -1
  57. package/resources/payouts/breakup/details.js +4 -4
  58. package/resources/payouts/breakup/details.mjs +4 -4
  59. package/src/client.ts +25 -0
  60. package/src/resources/balances.ts +16 -2
  61. package/src/resources/checkout-sessions.ts +93 -3
  62. package/src/resources/customers/emails.ts +11 -8
  63. package/src/resources/discounts.ts +13 -9
  64. package/src/resources/index.ts +11 -0
  65. package/src/resources/moderation.ts +388 -0
  66. package/src/resources/payments.ts +31 -1
  67. package/src/resources/payouts/breakup/breakup.ts +17 -1
  68. package/src/resources/payouts/breakup/details.ts +9 -8
  69. package/src/version.ts +1 -1
  70. package/version.d.mts +1 -1
  71. package/version.d.ts +1 -1
  72. package/version.js +1 -1
  73. package/version.mjs +1 -1
@@ -0,0 +1,388 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { RequestOptions } from '../internal/request-options';
6
+
7
+ export class Moderation extends APIResource {
8
+ /**
9
+ * Screens text, an image, or both, and returns a verdict: `allow`, `flag` or
10
+ * `deny`. The API is fail-closed: do not generate when you get no verdict.
11
+ *
12
+ * **Pricing.** Dodo Payments charges $0.30 per 1000 billable screens and debits
13
+ * the fee from your balance. A billable screen is a live-mode screen that returns
14
+ * a verdict. Errors and test-mode screens are free.
15
+ *
16
+ * **429.** Honour `Retry-After` and retry. A 429 is a throughput limit, not a
17
+ * verdict.
18
+ *
19
+ * **Test mode** returns mock verdicts and never calls the model. The default
20
+ * verdict is `allow`. Put one of these strings in `text` to select another
21
+ * outcome: `dodo_mock_flag` (`flag`), `dodo_mock_deny` (`deny`),
22
+ * `dodo_mock_overloaded` (429) or `dodo_mock_not_ready` (503).
23
+ */
24
+ screen(body: ModerationScreenParams, options?: RequestOptions): APIPromise<ModerationScreenResponse> {
25
+ return this._client.post('/moderation/screen', { body, ...options });
26
+ }
27
+
28
+ /**
29
+ * Shows how many billable screens you made and how close you are to your next
30
+ * charge.
31
+ *
32
+ * **Billing.** A billable screen is a live-mode screen that returns a verdict.
33
+ * Dodo Payments charges $0.30 for each full block of 1000 billable screens and
34
+ * debits the fee from your balance. Each full block is charged within one hour.
35
+ * Screens that do not fill a block stay unbilled until they do. Errors and
36
+ * test-mode screens are free and are not counted.
37
+ */
38
+ retrieveUsage(options?: RequestOptions): APIPromise<ModerationRetrieveUsageResponse> {
39
+ return this._client.get('/moderation/usage', options);
40
+ }
41
+ }
42
+
43
+ /**
44
+ * A moderation category.
45
+ */
46
+ export type ModerationCategory =
47
+ | 'violent_crimes'
48
+ | 'sex_related_crimes'
49
+ | 'child_sexual_exploitation'
50
+ | 'suicide_and_self_harm'
51
+ | 'indiscriminate_weapons'
52
+ | 'intellectual_property'
53
+ | 'defamation'
54
+ | 'non_violent_crimes'
55
+ | 'hate'
56
+ | 'privacy'
57
+ | 'specialized_advice'
58
+ | 'sexual_content'
59
+ | 'non_consensual_intimate_imagery'
60
+ | 'minor_coded_language'
61
+ | 'real_person_likeness'
62
+ | 'living_artist_style'
63
+ | 'prompt_injection';
64
+
65
+ /**
66
+ * How each score in `categories` was measured.
67
+ */
68
+ export interface ModerationCategoryProvenance {
69
+ /**
70
+ * Child sexual exploitation.
71
+ */
72
+ child_sexual_exploitation: ModerationProvenance;
73
+
74
+ /**
75
+ * False depiction that is likely to injure the reputation of a real person.
76
+ */
77
+ defamation: ModerationProvenance;
78
+
79
+ /**
80
+ * Demeaning people because of a protected characteristic.
81
+ */
82
+ hate: ModerationProvenance;
83
+
84
+ /**
85
+ * Chemical, biological, radiological, nuclear or explosive weapons.
86
+ */
87
+ indiscriminate_weapons: ModerationProvenance;
88
+
89
+ /**
90
+ * Copyright or trademark infringement.
91
+ */
92
+ intellectual_property: ModerationProvenance;
93
+
94
+ /**
95
+ * Imitation of the signature style of a specific living artist.
96
+ */
97
+ living_artist_style: ModerationProvenance;
98
+
99
+ /**
100
+ * Age-coded language that suggests the subject is a minor.
101
+ */
102
+ minor_coded_language: ModerationProvenance;
103
+
104
+ /**
105
+ * Non-consensual intimate imagery: undressing, nudifying or sexualising a real
106
+ * person.
107
+ */
108
+ non_consensual_intimate_imagery: ModerationProvenance;
109
+
110
+ /**
111
+ * Non-violent crimes.
112
+ */
113
+ non_violent_crimes: ModerationProvenance;
114
+
115
+ /**
116
+ * Sensitive private information about a person.
117
+ */
118
+ privacy: ModerationProvenance;
119
+
120
+ /**
121
+ * An attempt to override or manipulate the instructions of the system.
122
+ */
123
+ prompt_injection: ModerationProvenance;
124
+
125
+ /**
126
+ * The likeness of a real, identifiable, named person.
127
+ */
128
+ real_person_likeness: ModerationProvenance;
129
+
130
+ /**
131
+ * Sex-related crimes.
132
+ */
133
+ sex_related_crimes: ModerationProvenance;
134
+
135
+ /**
136
+ * Sexually explicit or pornographic content.
137
+ */
138
+ sexual_content: ModerationProvenance;
139
+
140
+ /**
141
+ * Unqualified financial, medical, legal or electoral advice.
142
+ */
143
+ specialized_advice: ModerationProvenance;
144
+
145
+ /**
146
+ * Suicide and self-harm.
147
+ */
148
+ suicide_and_self_harm: ModerationProvenance;
149
+
150
+ /**
151
+ * Violent crimes.
152
+ */
153
+ violent_crimes: ModerationProvenance;
154
+ }
155
+
156
+ /**
157
+ * The probability, from 0 to 1, that the screen falls in each category.
158
+ */
159
+ export interface ModerationCategoryScores {
160
+ /**
161
+ * Child sexual exploitation.
162
+ */
163
+ child_sexual_exploitation: number;
164
+
165
+ /**
166
+ * False depiction that is likely to injure the reputation of a real person.
167
+ */
168
+ defamation: number;
169
+
170
+ /**
171
+ * Demeaning people because of a protected characteristic.
172
+ */
173
+ hate: number;
174
+
175
+ /**
176
+ * Chemical, biological, radiological, nuclear or explosive weapons.
177
+ */
178
+ indiscriminate_weapons: number;
179
+
180
+ /**
181
+ * Copyright or trademark infringement.
182
+ */
183
+ intellectual_property: number;
184
+
185
+ /**
186
+ * Imitation of the signature style of a specific living artist.
187
+ */
188
+ living_artist_style: number;
189
+
190
+ /**
191
+ * Age-coded language that suggests the subject is a minor.
192
+ */
193
+ minor_coded_language: number;
194
+
195
+ /**
196
+ * Non-consensual intimate imagery: undressing, nudifying or sexualising a real
197
+ * person.
198
+ */
199
+ non_consensual_intimate_imagery: number;
200
+
201
+ /**
202
+ * Non-violent crimes.
203
+ */
204
+ non_violent_crimes: number;
205
+
206
+ /**
207
+ * Sensitive private information about a person.
208
+ */
209
+ privacy: number;
210
+
211
+ /**
212
+ * An attempt to override or manipulate the instructions of the system.
213
+ */
214
+ prompt_injection: number;
215
+
216
+ /**
217
+ * The likeness of a real, identifiable, named person.
218
+ */
219
+ real_person_likeness: number;
220
+
221
+ /**
222
+ * Sex-related crimes.
223
+ */
224
+ sex_related_crimes: number;
225
+
226
+ /**
227
+ * Sexually explicit or pornographic content.
228
+ */
229
+ sexual_content: number;
230
+
231
+ /**
232
+ * Unqualified financial, medical, legal or electoral advice.
233
+ */
234
+ specialized_advice: number;
235
+
236
+ /**
237
+ * Suicide and self-harm.
238
+ */
239
+ suicide_and_self_harm: number;
240
+
241
+ /**
242
+ * Violent crimes.
243
+ */
244
+ violent_crimes: number;
245
+ }
246
+
247
+ /**
248
+ * The verdict. `allow` means the content passed. `deny` means block the content.
249
+ * `flag` means apply your own judgement. It is not a soft deny.
250
+ */
251
+ export type ModerationDecision = 'allow' | 'flag' | 'deny';
252
+
253
+ /**
254
+ * How a score was measured. `targeted` means a check for that one category
255
+ * measured it. `broad` means the general check that covers all categories measured
256
+ * it.
257
+ */
258
+ export type ModerationProvenance = 'targeted' | 'broad';
259
+
260
+ /**
261
+ * Your moderation usage.
262
+ */
263
+ export interface ModerationRetrieveUsageResponse {
264
+ /**
265
+ * Your billable screens per UTC day for the last 30 days, charged or not. A day
266
+ * with no screens is not in the list.
267
+ */
268
+ daily: Array<ModerationRetrieveUsageResponse.Daily>;
269
+
270
+ /**
271
+ * Billable screens still needed to fill the next block of 1000. A full block is
272
+ * charged within one hour, so this value is 1000 when your unbilled screens fill
273
+ * whole blocks.
274
+ */
275
+ screens_to_next_block: number;
276
+
277
+ /**
278
+ * Billable screens that Dodo Payments has not charged for yet.
279
+ */
280
+ unbilled_screens: number;
281
+ }
282
+
283
+ export namespace ModerationRetrieveUsageResponse {
284
+ export interface Daily {
285
+ /**
286
+ * The UTC day.
287
+ */
288
+ date: string;
289
+
290
+ /**
291
+ * Billable screens on that day.
292
+ */
293
+ screens: number;
294
+ }
295
+ }
296
+
297
+ /**
298
+ * The verdict of one screen.
299
+ */
300
+ export interface ModerationScreenResponse {
301
+ /**
302
+ * The probability, from 0 to 1, that the screen falls in each category.
303
+ */
304
+ categories: ModerationCategoryScores;
305
+
306
+ /**
307
+ * True when real-person likeness and sexual content together crossed their
308
+ * combined threshold, the pattern of a sexual deepfake.
309
+ */
310
+ compound_triggered: boolean;
311
+
312
+ /**
313
+ * The verdict. `allow` means the content passed. `deny` means block the content.
314
+ * `flag` means apply your own judgement. It is not a soft deny.
315
+ */
316
+ decision: ModerationDecision;
317
+
318
+ /**
319
+ * The time the screen took, in milliseconds.
320
+ */
321
+ latency_ms: number;
322
+
323
+ /**
324
+ * True when the text was also screened in a normalized form, with obfuscation such
325
+ * as invisible or look-alike characters removed.
326
+ */
327
+ normalized_applied: boolean;
328
+
329
+ /**
330
+ * Human-readable reasons for the decision. The wording can change, so do not parse
331
+ * it.
332
+ */
333
+ notes: Array<string>;
334
+
335
+ /**
336
+ * The number of yes/no questions the model answered for this screen.
337
+ */
338
+ passes: number;
339
+
340
+ /**
341
+ * How each score in `categories` was measured.
342
+ */
343
+ provenance: ModerationCategoryProvenance;
344
+
345
+ /**
346
+ * The `request_id` you sent, or null.
347
+ */
348
+ request_id: string | null;
349
+
350
+ /**
351
+ * The categories whose score crossed the threshold of the category. It can be
352
+ * empty on a `flag` from the general check. `notes` then gives the reason.
353
+ */
354
+ triggered: Array<ModerationCategory>;
355
+ }
356
+
357
+ export interface ModerationScreenParams {
358
+ /**
359
+ * The image to screen, as base64, with or without a `data:image/...;base64,`
360
+ * prefix. The formats are JPEG, PNG, WebP, GIF and BMP. The limit is 6991530
361
+ * base64 characters, and the decoded image must be at most 5 MiB.
362
+ */
363
+ image?: string | null;
364
+
365
+ /**
366
+ * Your identifier for this screen, up to 128 characters, with no control
367
+ * characters. The response returns it in `request_id`.
368
+ */
369
+ request_id?: string | null;
370
+
371
+ /**
372
+ * The text to screen, up to 8000 characters.
373
+ */
374
+ text?: string | null;
375
+ }
376
+
377
+ export declare namespace Moderation {
378
+ export {
379
+ type ModerationCategory as ModerationCategory,
380
+ type ModerationCategoryProvenance as ModerationCategoryProvenance,
381
+ type ModerationCategoryScores as ModerationCategoryScores,
382
+ type ModerationDecision as ModerationDecision,
383
+ type ModerationProvenance as ModerationProvenance,
384
+ type ModerationRetrieveUsageResponse as ModerationRetrieveUsageResponse,
385
+ type ModerationScreenResponse as ModerationScreenResponse,
386
+ type ModerationScreenParams as ModerationScreenParams,
387
+ };
388
+ }
@@ -329,6 +329,13 @@ export interface Payment {
329
329
  */
330
330
  disputes: Array<DisputesAPI.Dispute>;
331
331
 
332
+ /**
333
+ * True when one payment starts more than one subscription. Read this field to find
334
+ * the payment type. Do not read the length of `subscription_ids`. Do not read
335
+ * `subscription_id` for null.
336
+ */
337
+ is_multi_subscription: boolean;
338
+
332
339
  /**
333
340
  * Whether this payment was created solely to update a subscription's payment
334
341
  * method (a zero-/setup-amount charge). `false` for normal charges.
@@ -377,6 +384,13 @@ export interface Payment {
377
384
  */
378
385
  settlement_currency: MiscAPI.Currency;
379
386
 
387
+ /**
388
+ * Every subscription that this payment starts or charges, in a stable order. It is
389
+ * empty for a one-time payment. It holds the value of `subscription_id` when the
390
+ * payment names one subscription.
391
+ */
392
+ subscription_ids: Array<string>;
393
+
380
394
  /**
381
395
  * Total amount charged to the customer including tax, in the currency's smallest
382
396
  * unit (e.g. cents for USD, yen for JPY, fils for KWD — see the currency's decimal
@@ -496,7 +510,9 @@ export interface Payment {
496
510
  status?: IntentStatus | null;
497
511
 
498
512
  /**
499
- * Identifier of the subscription if payment is part of a subscription
513
+ * Identifier of the subscription if payment is part of a subscription. A
514
+ * multi-subscription payment leaves this null, because no single subscription owns
515
+ * the payment. Read `subscription_ids` for those.
500
516
  */
501
517
  subscription_id?: string | null;
502
518
 
@@ -748,6 +764,13 @@ export interface PaymentListResponse {
748
764
 
749
765
  has_license_key: boolean;
750
766
 
767
+ /**
768
+ * True when one payment starts more than one subscription. Read this field to find
769
+ * the payment type. Do not read the length of `subscription_ids`. Do not read
770
+ * `subscription_id` for null.
771
+ */
772
+ is_multi_subscription: boolean;
773
+
751
774
  /**
752
775
  * Arbitrary key-value metadata. Values can be string, integer, number, or boolean.
753
776
  */
@@ -761,6 +784,13 @@ export interface PaymentListResponse {
761
784
  */
762
785
  payment_provider: 'stripe' | 'adyen' | 'dodo';
763
786
 
787
+ /**
788
+ * Every subscription that this payment starts or charges, in a stable order. It is
789
+ * empty for a one-time payment. It holds the value of `subscription_id` when the
790
+ * payment names one subscription.
791
+ */
792
+ subscription_ids: Array<string>;
793
+
764
794
  total_amount: number;
765
795
 
766
796
  /**
@@ -38,11 +38,27 @@ export type BreakupRetrieveResponse = Array<BreakupRetrieveResponse.BreakupRetri
38
38
  export namespace BreakupRetrieveResponse {
39
39
  /**
40
40
  * Payout breakup aggregated by event type, with amounts in the payout's currency.
41
+ *
42
+ * The rows sum to the payout amount. The last row can be `unattributed`, which is
43
+ * not a ledger event type. It holds the payout amount less the entries that fund
44
+ * it, and it takes either sign:
45
+ *
46
+ * - Positive: the entries come to less than the payout, so the payout drew on the
47
+ * balance an earlier cycle left over. A cycle of refunds and disputes produces a
48
+ * large positive value.
49
+ * - Negative: the entries come to more than the payout, and the remainder funds a
50
+ * later payout. This is the common case, for two reasons. The walk that claims
51
+ * the entries stops at the first one that reaches its target, so it passes the
52
+ * target by part of an entry. The target is also the gross debit, which holds
53
+ * the payout fee, and the fee is not a line here.
54
+ *
55
+ * The row is absent when the two are equal.
41
56
  */
42
57
  export interface BreakupRetrieveResponseItem {
43
58
  /**
44
59
  * The type of balance ledger event (e.g., "payment", "refund", "dispute",
45
- * "payment_fees").
60
+ * "payment_fees"), or `unattributed` for the payout amount the entries do not
61
+ * account for.
46
62
  */
47
63
  event_type: string;
48
64
 
@@ -13,10 +13,10 @@ import { path } from '../../../internal/utils/path';
13
13
 
14
14
  export class Details extends APIResource {
15
15
  /**
16
- * Returns paginated individual balance ledger entries for a payout, with each
17
- * entry's amount pro-rated into the payout's currency. Supports pagination via
18
- * `page_size` (default 10, max 100) and `page_number` (default 0) query
19
- * parameters.
16
+ * Returns paginated individual balance ledger entries for a payout. Each entry is
17
+ * converted into the payout's currency at the rate the payout settled at. Supports
18
+ * pagination via `page_size` (default 10, max 100) and `page_number` (default 0)
19
+ * query parameters.
20
20
  *
21
21
  * @example
22
22
  * ```ts
@@ -64,8 +64,8 @@ export class Details extends APIResource {
64
64
  export type DetailListResponsesDefaultPageNumberPagination = DefaultPageNumberPagination<DetailListResponse>;
65
65
 
66
66
  /**
67
- * Individual balance ledger entry for a payout, with amounts pro-rated into the
68
- * payout's currency.
67
+ * Individual balance ledger entry for a payout, converted into the payout's
68
+ * currency.
69
69
  */
70
70
  export interface DetailListResponse {
71
71
  /**
@@ -97,8 +97,9 @@ export interface DetailListResponse {
97
97
 
98
98
  /**
99
99
  * Amount in the payout's currency, in that currency's smallest unit (cents for
100
- * USD, yen for JPY, fils for KWD). Uses cumulative rounding to ensure sum matches
101
- * payout total exactly.
100
+ * USD, yen for JPY, fils for KWD). The entry is converted at the rate the payout
101
+ * settled at. These amounts sum to the value of the entries, which can be less
102
+ * than the payout: the grouped breakup reports the difference as `unattributed`.
102
103
  */
103
104
  payout_currency_amount: number;
104
105
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '2.50.0'; // x-release-please-version
1
+ export const VERSION = '2.52.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.50.0";
1
+ export declare const VERSION = "2.52.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.50.0";
1
+ export declare const VERSION = "2.52.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.50.0'; // x-release-please-version
4
+ exports.VERSION = '2.52.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.50.0'; // x-release-please-version
1
+ export const VERSION = '2.52.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map