@stripe/extensibility-sdk 0.22.4 → 0.24.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/dist/api-surface.d.ts.map +1 -0
  2. package/dist/config-values/generate.cjs +1 -1
  3. package/dist/config-values/generate.d.ts +2 -2
  4. package/dist/config-values/generate.d.ts.map +1 -1
  5. package/dist/config-values/generate.js +1 -1
  6. package/dist/extensibility-sdk-alpha.d.ts +1290 -1
  7. package/dist/extensibility-sdk-beta.d.ts +1290 -1
  8. package/dist/extensibility-sdk-config-values-internal.d.ts +2 -2
  9. package/dist/extensibility-sdk-extensions-alpha.d.ts +95 -114
  10. package/dist/extensibility-sdk-extensions-beta.d.ts +95 -114
  11. package/dist/extensibility-sdk-extensions-internal.d.ts +106 -147
  12. package/dist/extensibility-sdk-extensions-public.d.ts +95 -114
  13. package/dist/extensibility-sdk-internal.d.ts +1301 -1
  14. package/dist/extensibility-sdk-public.d.ts +1290 -1
  15. package/dist/extensions/billing/bill/discount_calculation.d.ts +7 -10
  16. package/dist/extensions/billing/bill/discount_calculation.d.ts.map +1 -1
  17. package/dist/extensions/billing/customer_balance_application.d.ts +7 -9
  18. package/dist/extensions/billing/customer_balance_application.d.ts.map +1 -1
  19. package/dist/extensions/billing/invoice_collection_setting.d.ts +15 -19
  20. package/dist/extensions/billing/invoice_collection_setting.d.ts.map +1 -1
  21. package/dist/extensions/billing/prorations.d.ts +25 -34
  22. package/dist/extensions/billing/prorations.d.ts.map +1 -1
  23. package/dist/extensions/billing/recurring_billing_item_handling.d.ts +29 -47
  24. package/dist/extensions/billing/recurring_billing_item_handling.d.ts.map +1 -1
  25. package/dist/extensions/billing/types.d.ts +4 -4
  26. package/dist/extensions/core/workflows/custom_action.d.ts +7 -12
  27. package/dist/extensions/core/workflows/custom_action.d.ts.map +1 -1
  28. package/dist/extensions/extend/workflows/custom_action.d.ts +7 -12
  29. package/dist/extensions/extend/workflows/custom_action.d.ts.map +1 -1
  30. package/dist/extensions/index.cjs +0 -2
  31. package/dist/extensions/index.d.ts +6 -2
  32. package/dist/extensions/index.d.ts.map +1 -1
  33. package/dist/extensions/index.js +1 -2
  34. package/dist/index.cjs +2317 -0
  35. package/dist/index.d.ts +2 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +2320 -0
  38. package/dist/stdlib/decimal.d.ts +4 -40
  39. package/dist/stdlib/refs.d.ts +7 -21
  40. package/dist/stdlib/scalars.d.ts +16 -71
  41. package/dist/stdlib/type-utils.d.ts +1 -3
  42. package/dist/stdlib/types.d.ts +6 -6
  43. package/dist/tsconfig.build.tsbuildinfo +1 -1
  44. package/package.json +3 -11
  45. package/dist/extensibility-sdk-jsonschema-alpha.d.ts +0 -3
  46. package/dist/extensibility-sdk-jsonschema-beta.d.ts +0 -3
  47. package/dist/extensibility-sdk-jsonschema-internal.d.ts +0 -15
  48. package/dist/extensibility-sdk-jsonschema-public.d.ts +0 -3
  49. package/dist/jsonschema.cjs +0 -18
  50. package/dist/jsonschema.d.ts +0 -2
  51. package/dist/jsonschema.d.ts.map +0 -1
  52. package/dist/jsonschema.js +0 -0
@@ -4,7 +4,7 @@
4
4
  * Lean runtime for Stripe script extensions.
5
5
  *
6
6
  * - Standard library utilities (Decimal, Integer, Ref, etc.)
7
- * - Extension interfaces via `./extensions` subpath
7
+ * - Extension interfaces (Billing, Core, Extend namespaces, Context)
8
8
  *
9
9
  * @packageDocumentation
10
10
  */
@@ -55,6 +55,19 @@ declare const __positiveIntegerBrand: unique symbol;
55
55
  */
56
56
  export declare const __stripeType: unique symbol;
57
57
 
58
+ /** @public */
59
+ declare type AnyTimeRange = {
60
+ at: Date;
61
+ value: 'oneTime';
62
+ } | {
63
+ endDate: Date;
64
+ startDate: Date;
65
+ value: 'timeRange';
66
+ } | {
67
+ otherValue: string;
68
+ value: 'other';
69
+ };
70
+
58
71
  /**
59
72
  * Apply a strategy to a field array, transforming each field.
60
73
  * The strategy determines direction (proto→SDK, SDK→proto, or JSON→SDK).
@@ -124,6 +137,28 @@ export declare interface _ApplyStrategy {
124
137
  applyOneofField(typeName: string, oneof: _OneofFieldDescriptor, input: Record<string, unknown>, strategy: _ApplyStrategy, result: Record<string, unknown>, excludeWireKeys: Set<string>): void;
125
138
  }
126
139
 
140
+ declare namespace Bill {
141
+ export {
142
+ DiscountCalculation
143
+ }
144
+ }
145
+
146
+ declare namespace Billing {
147
+ export {
148
+ CustomerBalanceApplication,
149
+ InvoiceCollectionSetting,
150
+ Prorations,
151
+ RecurringBillingItemHandling,
152
+ Bill,
153
+ OneTime,
154
+ TimeRange,
155
+ AnyTimeRange,
156
+ Currency,
157
+ MonetaryAmount
158
+ }
159
+ }
160
+ export { Billing }
161
+
127
162
  /** The type of the opaque brand symbol used as a property key in SDK branded types. @public */
128
163
  export declare type BrandSymbol = typeof __brand;
129
164
 
@@ -173,9 +208,375 @@ export declare class _ConfigEnum implements _EnumSpec {
173
208
  toWire(value: string): null | string;
174
209
  }
175
210
 
211
+ /** @public */
212
+ export declare interface Context {
213
+ type: string;
214
+ id: string;
215
+ livemode: boolean;
216
+ stripeContext?: string;
217
+ clockTime?: string;
218
+ }
219
+
220
+ declare namespace Core {
221
+ export {
222
+ Workflows
223
+ }
224
+ }
225
+ export { Core }
226
+
176
227
  /** @public */
177
228
  export declare type Currency = 'aed' | 'afn' | 'all' | 'amd' | 'ang' | 'aoa' | 'apt' | 'arb' | 'ars' | 'aud' | 'avax' | 'awg' | 'azn' | 'bam' | 'bbd' | 'bdt' | 'bgn' | 'bhd' | 'bif' | 'bmd' | 'bnb' | 'bnd' | 'bob' | 'bov' | 'brl' | 'bsd' | 'btc' | 'btn' | 'buidl' | 'bwp' | 'byn' | 'byr' | 'bzd' | 'cad' | 'cdf' | 'celo' | 'che' | 'chf' | 'chw' | 'clf' | 'clp' | 'cny' | 'cop' | 'cou' | 'crc' | 'cuc' | 'cup' | 'cve' | 'czk' | 'dai' | 'djf' | 'dkk' | 'dop' | 'dzd' | 'eek' | 'egp' | 'ern' | 'etb' | 'eth' | 'eur' | 'eurc' | 'fjd' | 'fkp' | 'frxusd' | 'gbp' | 'gel' | 'ghc' | 'ghs' | 'gip' | 'gmd' | 'gnf' | 'gtq' | 'gyd' | 'hkd' | 'hnl' | 'hrk' | 'htg' | 'huf' | 'hype' | 'idr' | 'ils' | 'inr' | 'iqd' | 'irr' | 'isk' | 'jmd' | 'jod' | 'jpy' | 'kes' | 'kgs' | 'khr' | 'kmf' | 'kpw' | 'krw' | 'kwd' | 'kyd' | 'kzt' | 'lak' | 'lbp' | 'lkr' | 'lrd' | 'lsl' | 'ltl' | 'lvl' | 'lyd' | 'lzd' | 'm' | 'mad' | 'mdl' | 'mga' | 'mkd' | 'mmk' | 'mnt' | 'mop' | 'mro' | 'mru' | 'mur' | 'mvr' | 'mwk' | 'mxn' | 'mxv' | 'myr' | 'mzn' | 'nad' | 'ngn' | 'nio' | 'nok' | 'npr' | 'nzd' | 'omr' | 'pab' | 'pen' | 'pgk' | 'php' | 'pkr' | 'pln' | 'pol' | 'pyg' | 'pyusd' | 'qar' | 'rd' | 're' | 'ron' | 'rsd' | 'rub' | 'rwf' | 'sar' | 'sbd' | 'scr' | 'sdg' | 'sek' | 'sgd' | 'shp' | 'sle' | 'sll' | 'sol' | 'sos' | 'srd' | 'ssp' | 'std' | 'stn' | 'sui' | 'svc' | 'syp' | 'szl' | 'thb' | 'tjs' | 'tmt' | 'tnd' | 'top' | 'trx' | 'try' | 'ttd' | 'twd' | 'tzs' | 'uah' | 'ugx' | 'usd' | 'usdb' | 'usdc' | 'usdg' | 'usdp' | 'usdt' | 'usn' | 'ustb' | 'uyi' | 'uyu' | 'uzs' | 'vef' | 'ves' | 'vnd' | 'vuv' | 'wst' | 'xaf' | 'xcd' | 'xcg' | 'xeur' | 'xlm' | 'xof' | 'xpf' | 'xpl' | 'xusd' | 'yer' | 'zar' | 'zmk' | 'zmw' | 'zwd' | 'zwg' | 'zwl';
178
229
 
230
+ /** @public */
231
+ declare namespace CustomAction {
232
+ /**
233
+ * Response payload for GetFormState.
234
+ * @public
235
+ */
236
+ interface GetFormStateResponse {
237
+ /** Updated form field values. Use this to set defaults, clear dependent fields when a parent changes, or preserve matching values across schema changes. Only fields included here are updated. Omitted fields keep their current values. */
238
+ values: Record<string, unknown>;
239
+ /** Per-field configuration keyed by field name. */
240
+ config: Record<string, FormStateFieldConfig>;
241
+ }
242
+ /**
243
+ * Configuration for a single form field, returned by GetFormState.
244
+ * @public
245
+ */
246
+ interface FormStateFieldConfig {
247
+ /** Dropdown options for `dynamic_select` fields. */
248
+ options: SelectOption[];
249
+ /** JSON Schema for dynamic_schema fields. Defines the structure of a dynamic object field (for example, template merge variables). V0 limitation: must be a flat object with string properties only. */
250
+ schema: Record<string, unknown>;
251
+ /** Whether the field is disabled (non-interactive). */
252
+ disabled?: boolean;
253
+ /** Whether the field is hidden from the form. */
254
+ hidden?: boolean;
255
+ /** Warning message displayed on the field. You can still save the workflow. */
256
+ warning?: string;
257
+ /** Error message displayed on the field. Blocks saving the workflow. */
258
+ error?: string;
259
+ }
260
+ /**
261
+ * An option in a dynamic_select dropdown.
262
+ * @public
263
+ */
264
+ interface SelectOption {
265
+ value: string;
266
+ label: string;
267
+ }
268
+ /**
269
+ * Request payload for GetFormState, sent at configuration time.
270
+ * @public
271
+ */
272
+ interface GetFormStateRequest {
273
+ /** Current form field values. Contains all field values in the form, including fields the user has not yet interacted with (which might be null). */
274
+ values: Record<string, unknown>;
275
+ /** The name of the field that just changed, triggering this request. Empty on initial form load; set to the field name (for example, `audience_id`) when a user changes a value. */
276
+ changedField?: string;
277
+ }
278
+ /** @public */
279
+ type ExecuteCustomActionResponse = Record<string, never>;
280
+ /**
281
+ * **************************************************************************** DEPRECATED: This proto is deprecated and should no longer be used. Please use the following proto instead: ***************************************************************************** / /** Request payload for executing a custom action, provided at workflow runtime.
282
+ * @public
283
+ */
284
+ interface ExecuteCustomActionRequest {
285
+ /** Custom input data for the action, validated against the app's input_schema. Contains the field values configured by the user in the workflow builder. */
286
+ customInput: Record<string, unknown>;
287
+ }
288
+ /**
289
+ * @public
290
+ * @deprecated Platform dispatch handles wire/SDK conversion.
291
+ */
292
+ function prepareArgsExecute(proto: unknown): ExecuteCustomActionRequest;
293
+ /**
294
+ * @public
295
+ * @deprecated Platform dispatch handles wire/SDK conversion.
296
+ */
297
+ function prepareResultExecute(result: ExecuteCustomActionResponse): ExecuteCustomActionResponse;
298
+ /** @internal */
299
+ function $platformWrapExecute(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { execute(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
300
+ /**
301
+ * @public
302
+ * @deprecated Platform dispatch handles wire/SDK conversion.
303
+ */
304
+ function prepareArgsGetFormState(proto: unknown): GetFormStateRequest;
305
+ /**
306
+ * @public
307
+ * @deprecated Platform dispatch handles wire/SDK conversion.
308
+ */
309
+ function prepareResultGetFormState(result: GetFormStateResponse): GetFormStateResponse;
310
+ /** @internal */
311
+ function $platformWrapGetFormState(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { getFormState(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
312
+ /**
313
+ * Executes the custom action at workflow runtime. Called when a workflow triggers this action, with the configured input values.
314
+ * @public
315
+ */
316
+ type ExecuteFunction<Config> = (request: ExecuteCustomActionRequest, config: Config, context: Context) => ExecuteCustomActionResponse | PromiseLike<ExecuteCustomActionResponse>;
317
+ /**
318
+ * Returns the current form state for the action's configuration UI. Called at configuration time (not runtime) to power dynamic form behavior, including dropdown options, dynamic JSON schemas, field visibility, and validation.
319
+ * @public
320
+ */
321
+ type GetFormStateFunction<Config> = (request: GetFormStateRequest, config: Config, context: Context) => GetFormStateResponse | PromiseLike<GetFormStateResponse>;
322
+ }
323
+
324
+ /**
325
+ * @example
326
+ * ```ts
327
+ * import type { Core, Context } from '@stripe/extensibility-sdk';
328
+ *
329
+ * // eslint-disable-next-line @typescript-eslint/no-empty-object-type
330
+ * interface MyCustomActionConfig {}
331
+ *
332
+ * export default class MyCustomAction implements Core.Workflows
333
+ * .CustomAction<MyCustomActionConfig> {
334
+ * execute(
335
+ * _request: Core.Workflows.CustomAction.ExecuteCustomActionRequest,
336
+ * _config: MyCustomActionConfig,
337
+ * _context: Context
338
+ * ) {
339
+ * // TODO: implement your action logic here
340
+ *
341
+ * return {};
342
+ * }
343
+ *
344
+ * getFormState(
345
+ * _request: Core.Workflows.CustomAction.GetFormStateRequest,
346
+ * _config: MyCustomActionConfig,
347
+ * _context: Context
348
+ * ) {
349
+ * // TODO: implement your logic here
350
+ *
351
+ * return {
352
+ * values: {},
353
+ * config: {},
354
+ * };
355
+ * }
356
+ * }
357
+ *
358
+ * ```
359
+ * @public
360
+ */
361
+ declare interface CustomAction<Config> {
362
+ execute: CustomAction.ExecuteFunction<Config>;
363
+ getFormState?: CustomAction.GetFormStateFunction<Config>;
364
+ }
365
+
366
+ /** @public */
367
+ declare namespace CustomAction_2 {
368
+ /**
369
+ * Response payload for GetFormState.
370
+ * @public
371
+ */
372
+ interface GetFormStateResponse {
373
+ /** Updated form field values. Use this to set defaults, clear dependent fields when a parent changes, or preserve matching values across schema changes. Only fields included here are updated. Omitted fields keep their current values. */
374
+ values: Record<string, unknown>;
375
+ /** Per-field configuration keyed by field name. */
376
+ config: Record<string, FormStateFieldConfig>;
377
+ }
378
+ /**
379
+ * Configuration for a single form field, returned by GetFormState.
380
+ * @public
381
+ */
382
+ interface FormStateFieldConfig {
383
+ /** Dropdown options for `dynamic_select` fields. */
384
+ options: SelectOption[];
385
+ /** JSON Schema for dynamic_schema fields. Defines the structure of a dynamic object field (for example, template merge variables). V0 limitation: must be a flat object with string properties only. */
386
+ schema: Record<string, unknown>;
387
+ /** Whether the field is disabled (non-interactive). */
388
+ disabled?: boolean;
389
+ /** Whether the field is hidden from the form. */
390
+ hidden?: boolean;
391
+ /** Warning message displayed on the field. You can still save the workflow. */
392
+ warning?: string;
393
+ /** Error message displayed on the field. Blocks saving the workflow. */
394
+ error?: string;
395
+ }
396
+ /**
397
+ * An option in a dynamic_select dropdown.
398
+ * @public
399
+ */
400
+ interface SelectOption {
401
+ value: string;
402
+ label: string;
403
+ }
404
+ /**
405
+ * Request payload for GetFormState, sent at configuration time.
406
+ * @public
407
+ */
408
+ interface GetFormStateRequest {
409
+ /** Current form field values. Contains all field values in the form, including fields the user has not yet interacted with (which might be null). */
410
+ values: Record<string, unknown>;
411
+ /** The name of the field that just changed, triggering this request. Empty on initial form load; set to the field name (for example, `audience_id`) when a user changes a value. */
412
+ changedField?: string;
413
+ }
414
+ /** @public */
415
+ type ExecuteCustomActionResponse = Record<string, never>;
416
+ /**
417
+ * Request payload for executing a custom action, provided at workflow runtime.
418
+ * @public
419
+ */
420
+ interface ExecuteCustomActionRequest {
421
+ /** Custom input data for the action, validated against the app's input_schema. Contains the field values configured by the user in the workflow builder. */
422
+ customInput: Record<string, unknown>;
423
+ }
424
+ /**
425
+ * @public
426
+ * @deprecated Platform dispatch handles wire/SDK conversion.
427
+ */
428
+ function prepareArgsExecute(proto: unknown): ExecuteCustomActionRequest;
429
+ /**
430
+ * @public
431
+ * @deprecated Platform dispatch handles wire/SDK conversion.
432
+ */
433
+ function prepareResultExecute(result: ExecuteCustomActionResponse): ExecuteCustomActionResponse;
434
+ /** @internal */
435
+ function $platformWrapExecute(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { execute(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
436
+ /**
437
+ * @public
438
+ * @deprecated Platform dispatch handles wire/SDK conversion.
439
+ */
440
+ function prepareArgsGetFormState(proto: unknown): GetFormStateRequest;
441
+ /**
442
+ * @public
443
+ * @deprecated Platform dispatch handles wire/SDK conversion.
444
+ */
445
+ function prepareResultGetFormState(result: GetFormStateResponse): GetFormStateResponse;
446
+ /** @internal */
447
+ function $platformWrapGetFormState(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { getFormState(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
448
+ /**
449
+ * Executes the custom action at workflow runtime. Called when a workflow triggers this action, with the configured input values.
450
+ * @public
451
+ */
452
+ type ExecuteFunction<Config> = (request: ExecuteCustomActionRequest, config: Config, context: Context) => ExecuteCustomActionResponse | PromiseLike<ExecuteCustomActionResponse>;
453
+ /**
454
+ * Returns the current form state for the action's configuration UI. Called at configuration time (not runtime) to power dynamic form behavior, including dropdown options, dynamic JSON schemas, field visibility, and validation.
455
+ * @public
456
+ */
457
+ type GetFormStateFunction<Config> = (request: GetFormStateRequest, config: Config, context: Context) => GetFormStateResponse | PromiseLike<GetFormStateResponse>;
458
+ }
459
+
460
+ /**
461
+ * @example
462
+ * ```ts
463
+ * import type { Extend, Context } from '@stripe/extensibility-sdk';
464
+ *
465
+ * // eslint-disable-next-line @typescript-eslint/no-empty-object-type
466
+ * interface MyCustomActionConfig {}
467
+ *
468
+ * export default class MyCustomAction implements Extend.Workflows
469
+ * .CustomAction<MyCustomActionConfig> {
470
+ * execute(
471
+ * _request: Extend.Workflows.CustomAction.ExecuteCustomActionRequest,
472
+ * _config: MyCustomActionConfig,
473
+ * _context: Context
474
+ * ) {
475
+ * // TODO: implement your action logic here
476
+ *
477
+ * return {};
478
+ * }
479
+ *
480
+ * getFormState(
481
+ * _request: Extend.Workflows.CustomAction.GetFormStateRequest,
482
+ * _config: MyCustomActionConfig,
483
+ * _context: Context
484
+ * ) {
485
+ * // TODO: implement your logic here
486
+ *
487
+ * return {
488
+ * values: {},
489
+ * config: {},
490
+ * };
491
+ * }
492
+ * }
493
+ *
494
+ * ```
495
+ * @public
496
+ */
497
+ declare interface CustomAction_2<Config> {
498
+ execute: CustomAction_2.ExecuteFunction<Config>;
499
+ getFormState?: CustomAction_2.GetFormStateFunction<Config>;
500
+ }
501
+
502
+ /** @public */
503
+ declare namespace CustomerBalanceApplication {
504
+ /**
505
+ * The result of computing how much customer balance to apply to a bill.
506
+ * @public
507
+ */
508
+ interface CustomerBalanceApplicationResult {
509
+ /** The amount of customer balance to apply to this invoice. Positive values increase the invoice amount (applying a debit), negative values decrease it (applying a credit). Set to zero to apply no balance. */
510
+ appliedCustomerBalance: MonetaryAmount;
511
+ }
512
+ /**
513
+ * The bill details provided as input to the customer balance application extension.
514
+ * @public
515
+ */
516
+ interface CustomerBalanceApplicationInput {
517
+ /** The total amount of the invoice before applying any customer balance. */
518
+ totalAmount: MonetaryAmount;
519
+ /** The current customer balance available to apply. Positive values indicate debits (the customer owes money), negative values indicate credits. */
520
+ customerBalance: MonetaryAmount;
521
+ }
522
+ /**
523
+ * @public
524
+ * @deprecated Platform dispatch handles wire/SDK conversion.
525
+ */
526
+ function prepareArgsComputeAppliedCustomerBalance(proto: unknown): CustomerBalanceApplicationInput;
527
+ /**
528
+ * @public
529
+ * @deprecated Platform dispatch handles wire/SDK conversion.
530
+ */
531
+ function prepareResultComputeAppliedCustomerBalance(result: CustomerBalanceApplicationResult): CustomerBalanceApplicationResult;
532
+ /** @internal */
533
+ function $platformWrapComputeAppliedCustomerBalance(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { computeAppliedCustomerBalance(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
534
+ /**
535
+ * @public
536
+ * @deprecated Platform dispatch handles wire/SDK conversion.
537
+ */
538
+ const prepareArgs: typeof prepareArgsComputeAppliedCustomerBalance;
539
+ /**
540
+ * @public
541
+ * @deprecated Platform dispatch handles wire/SDK conversion.
542
+ */
543
+ const prepareResult: typeof prepareResultComputeAppliedCustomerBalance;
544
+ /**
545
+ * Determines how much of the customer's balance to apply toward a bill total. The script receives the invoice total and current customer balance, then returns how much of that balance to apply.
546
+ * @public
547
+ */
548
+ type ComputeAppliedCustomerBalanceFunction<Config> = (request: CustomerBalanceApplicationInput, config: Config, context: Context) => CustomerBalanceApplicationResult;
549
+ }
550
+
551
+ /**
552
+ * @example
553
+ * ```ts
554
+ * import type { Billing, Context } from '@stripe/extensibility-sdk';
555
+ *
556
+ * // eslint-disable-next-line @typescript-eslint/no-empty-object-type
557
+ * interface MyBalanceAppConfig {}
558
+ *
559
+ * export default class MyBalanceApp implements Billing.CustomerBalanceApplication<MyBalanceAppConfig> {
560
+ * computeAppliedCustomerBalance(
561
+ * request: Billing.CustomerBalanceApplication.CustomerBalanceApplicationInput,
562
+ * _config: MyBalanceAppConfig,
563
+ * _context: Context
564
+ * ) {
565
+ * // TODO: implement your customer balance logic here
566
+ *
567
+ * return {
568
+ * appliedCustomerBalance: request.customerBalance,
569
+ * };
570
+ * }
571
+ * }
572
+ *
573
+ * ```
574
+ * @public
575
+ */
576
+ declare interface CustomerBalanceApplication<Config> {
577
+ computeAppliedCustomerBalance: CustomerBalanceApplication.ComputeAppliedCustomerBalanceFunction<Config>;
578
+ }
579
+
179
580
  /**
180
581
  * Arbitrary-precision decimal type for billing calculations.
181
582
  *
@@ -417,6 +818,227 @@ export declare const DecimalRoundingPresets: Readonly<{
417
818
  */
418
819
  export declare const DEFAULT_DIV_PRECISION = 34;
419
820
 
821
+ /** @public */
822
+ declare namespace DiscountCalculation {
823
+ /** @public */
824
+ type BillingReason = 'automatic_pending_invoice_item_invoice' | 'manual' | 'quote_accept' | 'subscription_cancel' | 'subscription_create' | 'subscription_cycle' | 'subscription_threshold' | 'subscription_trial_ended' | 'subscription_update' | 'subscription' | 'upcoming';
825
+ /** @public */
826
+ type PricingTierMode = 'graduated' | 'volume';
827
+ /** @public */
828
+ type PriceType = 'one_time' | 'recurring';
829
+ /** @public */
830
+ type PricingScheme = 'per_unit' | 'tiered';
831
+ /** @public */
832
+ type UsageType = 'licensed' | 'metered';
833
+ /** @public */
834
+ type RecurringPriceInterval = 'day' | 'month' | 'week' | 'year';
835
+ /**
836
+ * The result of a discount calculation.
837
+ * @public
838
+ */
839
+ interface DiscountResult {
840
+ /** The computed discount to apply. */
841
+ discount: Discount;
842
+ }
843
+ /**
844
+ * A discount to apply to a discountable item.
845
+ * @public
846
+ */
847
+ interface Discount {
848
+ /** The discount amount to subtract from the discountable item. */
849
+ amount: MonetaryAmount;
850
+ }
851
+ /**
852
+ * An item eligible for discount calculation, containing its line items and billing context.
853
+ * @public
854
+ */
855
+ interface DiscountableItem {
856
+ /** The individual line items that make up the discountable item. */
857
+ lineItems: DiscountableLineItem[];
858
+ /** The total gross amount of the discountable item before any discounts. */
859
+ grossAmount: MonetaryAmount;
860
+ /** The customer associated with the discountable item. */
861
+ customer?: Customer;
862
+ /** The reason this item is being billed. */
863
+ billingReason?: BillingReason;
864
+ /** The subscription associated with the discountable item. */
865
+ subscription?: Subscription;
866
+ }
867
+ /**
868
+ * The subscription associated with the discountable item.
869
+ * @public
870
+ */
871
+ interface Subscription {
872
+ /** The unique identifier of the subscription. */
873
+ id: string;
874
+ /** The Unix timestamp of the billing cycle anchor. */
875
+ billingCycleAnchor?: number;
876
+ /** The structured billing cycle anchor configuration. */
877
+ billingCycleAnchorConfig?: BillingCycleAnchorConfig;
878
+ /** Custom key-value pairs attached to the subscription. */
879
+ metadata: Record<string, string>;
880
+ }
881
+ /**
882
+ * Configuration for the billing cycle anchor, specifying when recurring billing periods start.
883
+ * @public
884
+ */
885
+ interface BillingCycleAnchorConfig {
886
+ /** The month component of the billing cycle anchor. */
887
+ month: number;
888
+ /** The day of the month for the billing cycle anchor. */
889
+ dayOfMonth: number;
890
+ /** The hour component of the billing cycle anchor. */
891
+ hour: number;
892
+ /** The minute component of the billing cycle anchor. */
893
+ minute: number;
894
+ /** The second component of the billing cycle anchor. */
895
+ second: number;
896
+ }
897
+ /**
898
+ * The customer associated with the discountable item.
899
+ * @public
900
+ */
901
+ interface Customer {
902
+ /** The unique identifier of the customer. */
903
+ id: string;
904
+ /** Custom key-value pairs attached to the customer. */
905
+ metadata: Record<string, string>;
906
+ }
907
+ /**
908
+ * A single line item within a discountable item.
909
+ * @public
910
+ */
911
+ interface DiscountableLineItem {
912
+ /** The subtotal amount of this line item. */
913
+ subtotal: MonetaryAmount;
914
+ /** The quantity of this line item. */
915
+ quantity?: Decimal;
916
+ /** The billing period this line item covers. */
917
+ period: AnyTimeRange;
918
+ /** The price information for this line item. */
919
+ price?: Price;
920
+ }
921
+ /**
922
+ * The price associated with a line item.
923
+ * @public
924
+ */
925
+ interface Price {
926
+ /** The unique identifier for the price. */
927
+ id: string;
928
+ /** The product this price belongs to. */
929
+ product?: Product;
930
+ /** The recurring pricing configuration, if applicable. */
931
+ recurring?: RecurringPrice;
932
+ /** The billing scheme, either per-unit or tiered. */
933
+ billingScheme?: PricingScheme;
934
+ /** The pricing tiers, applicable for tiered billing schemes. */
935
+ tiers: PriceTier[];
936
+ /** The price type, either one-time or recurring. */
937
+ type?: PriceType;
938
+ /** The tiering mode, either graduated or volume. */
939
+ tiersMode?: PricingTierMode;
940
+ /** Key-value metadata attached to the price. */
941
+ metadata: Record<string, string>;
942
+ /** The unit amount of the price. */
943
+ unitAmount?: Decimal;
944
+ }
945
+ /**
946
+ * A tier within a tiered pricing structure.
947
+ * @public
948
+ */
949
+ interface PriceTier {
950
+ /** The flat fee charged for this tier. */
951
+ flatAmount?: Decimal;
952
+ /** The per-unit price for this tier. */
953
+ unitAmount?: Decimal;
954
+ /** The upper bound of the tier range. */
955
+ upTo?: Decimal;
956
+ }
957
+ /**
958
+ * The recurring pricing configuration for a price.
959
+ * @public
960
+ */
961
+ interface RecurringPrice {
962
+ /** The billing interval for the recurring price. */
963
+ interval: RecurringPriceInterval;
964
+ /** The number of intervals between each billing cycle. */
965
+ intervalCount: number;
966
+ /** The usage type, either licensed or metered. */
967
+ usageType?: UsageType;
968
+ /** The identifier of the meter tracking usage for this price. */
969
+ meter?: string;
970
+ }
971
+ /**
972
+ * The product associated with a price.
973
+ * @public
974
+ */
975
+ interface Product {
976
+ /** The unique identifier of the product. */
977
+ id: string;
978
+ /** The name of the product. */
979
+ name: string;
980
+ /** Custom key-value pairs attached to the product. */
981
+ metadata: Record<string, string>;
982
+ }
983
+ /**
984
+ * @public
985
+ * @deprecated Platform dispatch handles wire/SDK conversion.
986
+ */
987
+ function prepareArgsComputeDiscounts(proto: unknown): DiscountableItem;
988
+ /**
989
+ * @public
990
+ * @deprecated Platform dispatch handles wire/SDK conversion.
991
+ */
992
+ function prepareResultComputeDiscounts(result: DiscountResult): DiscountResult;
993
+ /** @internal */
994
+ function $platformWrapComputeDiscounts(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { computeDiscounts(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
995
+ /**
996
+ * @public
997
+ * @deprecated Platform dispatch handles wire/SDK conversion.
998
+ */
999
+ const prepareArgs: typeof prepareArgsComputeDiscounts;
1000
+ /**
1001
+ * @public
1002
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1003
+ */
1004
+ const prepareResult: typeof prepareResultComputeDiscounts;
1005
+ /**
1006
+ * Computes discount amounts for a discountable item and returns a discount result.
1007
+ * @public
1008
+ */
1009
+ type ComputeDiscountsFunction<Config> = (request: DiscountableItem, config: Config, context: Context) => DiscountResult;
1010
+ }
1011
+
1012
+ /**
1013
+ * @example
1014
+ * ```ts
1015
+ * import type { Billing, Context } from '@stripe/extensibility-sdk';
1016
+ *
1017
+ * // eslint-disable-next-line @typescript-eslint/no-empty-object-type
1018
+ * interface MyDiscountCalculationConfig {}
1019
+ *
1020
+ * export default class MyDiscountCalculation implements Billing.Bill
1021
+ * .DiscountCalculation<MyDiscountCalculationConfig> {
1022
+ * computeDiscounts(
1023
+ * request: Billing.Bill.DiscountCalculation.DiscountableItem,
1024
+ * _config: MyDiscountCalculationConfig,
1025
+ * _context: Context
1026
+ * ) {
1027
+ * // TODO: implement your discount logic here
1028
+ *
1029
+ * return {
1030
+ * discount: { amount: request.grossAmount },
1031
+ * };
1032
+ * }
1033
+ * }
1034
+ *
1035
+ * ```
1036
+ * @public
1037
+ */
1038
+ declare interface DiscountCalculation<Config> {
1039
+ computeDiscounts: DiscountCalculation.ComputeDiscountsFunction<Config>;
1040
+ }
1041
+
420
1042
  /**
421
1043
  * Common interface for enum conversion specs. `fromWire` converts an
422
1044
  * incoming wire string to an SDK value; `toWire` does the reverse.
@@ -437,6 +1059,13 @@ export declare interface _EnumSpec {
437
1059
  toWire(value: string): null | string;
438
1060
  }
439
1061
 
1062
+ declare namespace Extend {
1063
+ export {
1064
+ Workflows_2 as Workflows
1065
+ }
1066
+ }
1067
+ export { Extend }
1068
+
440
1069
  /**
441
1070
  * Extracts the string literal type of the `object` property from T.
442
1071
  *
@@ -503,6 +1132,118 @@ export declare const Integer: {
503
1132
  */
504
1133
  export declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
505
1134
 
1135
+ /** @public */
1136
+ declare namespace InvoiceCollectionSetting {
1137
+ /** @public */
1138
+ type ParentType = 'billing_cadence' | 'contract' | 'quote' | 'standalone' | 'subscription_schedule' | 'subscription';
1139
+ /** @public */
1140
+ type PaymentMethodType = 'ach_credit_transfer' | 'ach_debit' | 'affirm' | 'afterpay_clearpay' | 'alipay' | 'au_becs_debit' | 'bacs_debit' | 'bancontact' | 'boleto' | 'card' | 'cashapp' | 'eps' | 'fpx' | 'giropay' | 'grabpay' | 'ideal' | 'klarna' | 'konbini' | 'link' | 'multibanco' | 'oxxo' | 'p24' | 'paynow' | 'paypal' | 'promptpay' | 'sepa_credit_transfer' | 'sepa_debit' | 'sofort' | 'us_bank_account' | 'wechat_pay';
1141
+ /** @public */
1142
+ type CollectionMethod = 'charge_automatically' | 'send_invoice';
1143
+ /**
1144
+ * The result of the invoice collection settings override extension.
1145
+ * @public
1146
+ */
1147
+ interface InvoiceCollectionResponse {
1148
+ /** Override the auto-advancement setting. Set to false to keep the invoice in draft. Return null to use the default. */
1149
+ autoAdvance?: boolean;
1150
+ }
1151
+ /** @public */
1152
+ type InvoiceCollectionRequest = ({
1153
+ customer: Customer;
1154
+ payer: 'customer';
1155
+ } | {
1156
+ otherPayer: string;
1157
+ payer: 'other';
1158
+ }) & {
1159
+ collectionSettings: CollectionSettings;
1160
+ parent: Parent;
1161
+ };
1162
+ /** @public */
1163
+ interface Customer {
1164
+ id: string;
1165
+ metadata: Record<string, string>;
1166
+ }
1167
+ /**
1168
+ * The parent resource that triggered the invoice creation.
1169
+ * @public
1170
+ */
1171
+ interface Parent {
1172
+ /** The type of parent resource (for example, subscription or contract). */
1173
+ type: ParentType;
1174
+ /** Custom key-value pairs attached to the parent resource. */
1175
+ metadata: Record<string, string>;
1176
+ }
1177
+ /**
1178
+ * The collection settings for an invoice.
1179
+ * @public
1180
+ */
1181
+ interface CollectionSettings {
1182
+ /** Whether the invoice automatically advances through its lifecycle. */
1183
+ autoAdvance: boolean;
1184
+ /** The payment collection method: charge_automatically or send_invoice. */
1185
+ collectionMethod: CollectionMethod;
1186
+ /** The delay before the invoice is finalized, in hours. */
1187
+ finalizationGracePeriod: number;
1188
+ /** The payment methods configured for this invoice. */
1189
+ paymentMethods: PaymentMethodType[];
1190
+ }
1191
+ /**
1192
+ * @public
1193
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1194
+ */
1195
+ function prepareArgsCollectionOverride(proto: unknown): InvoiceCollectionRequest;
1196
+ /**
1197
+ * @public
1198
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1199
+ */
1200
+ function prepareResultCollectionOverride(result: InvoiceCollectionResponse): InvoiceCollectionResponse;
1201
+ /** @internal */
1202
+ function $platformWrapCollectionOverride(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { collectionOverride(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
1203
+ /**
1204
+ * @public
1205
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1206
+ */
1207
+ const prepareArgs: typeof prepareArgsCollectionOverride;
1208
+ /**
1209
+ * @public
1210
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1211
+ */
1212
+ const prepareResult: typeof prepareResultCollectionOverride;
1213
+ /**
1214
+ * Overrides invoice collection settings before a draft invoice is created.
1215
+ * @public
1216
+ */
1217
+ type CollectionOverrideFunction<Config> = (request: InvoiceCollectionRequest, config: Config, context: Context) => InvoiceCollectionResponse;
1218
+ }
1219
+
1220
+ /**
1221
+ * @example
1222
+ * ```ts
1223
+ * import type { Billing, Context } from '@stripe/extensibility-sdk';
1224
+ *
1225
+ * // eslint-disable-next-line @typescript-eslint/no-empty-object-type
1226
+ * interface MyInvoiceCollectionSettingConfig {}
1227
+ *
1228
+ * export default class MyInvoiceCollectionSetting implements Billing.InvoiceCollectionSetting<MyInvoiceCollectionSettingConfig> {
1229
+ * collectionOverride(
1230
+ * _request: Billing.InvoiceCollectionSetting.InvoiceCollectionRequest,
1231
+ * _config: MyInvoiceCollectionSettingConfig,
1232
+ * _context: Context
1233
+ * ) {
1234
+ * // TODO: implement your collection setting logic here
1235
+ *
1236
+ * return {};
1237
+ * }
1238
+ * }
1239
+ *
1240
+ * ```
1241
+ * @public
1242
+ */
1243
+ declare interface InvoiceCollectionSetting<Config> {
1244
+ collectionOverride: InvoiceCollectionSetting.CollectionOverrideFunction<Config>;
1245
+ }
1246
+
506
1247
  /**
507
1248
  * Check whether a value is a `Decimal` instance.
508
1249
  *
@@ -591,6 +1332,25 @@ export declare interface _OneofFieldDescriptor {
591
1332
  branches: _OneofBranchDescriptor[];
592
1333
  }
593
1334
 
1335
+ /**
1336
+ * Represents a one-time event occurring at a specific date.
1337
+ * @public
1338
+ */
1339
+ declare interface OneTime {
1340
+ /** The date and time of the event. */
1341
+ at: Date;
1342
+ }
1343
+
1344
+ /**
1345
+ * Represents a percentage number value (0-100).
1346
+ * @format percent
1347
+ * @public
1348
+ */
1349
+ export declare interface Percent {
1350
+ /** The percentage value. */
1351
+ value: number;
1352
+ }
1353
+
594
1354
  /**
595
1355
  * A branded non-negative integer — a `number` guaranteed to be an integer ≥ 0.
596
1356
  *
@@ -620,6 +1380,217 @@ export declare const PositiveInteger: {
620
1380
  is: (value: number) => value is PositiveInteger;
621
1381
  };
622
1382
 
1383
+ /** @public */
1384
+ declare namespace Prorations {
1385
+ /** @public */
1386
+ type PricingTierMode = 'graduated' | 'volume';
1387
+ /** @public */
1388
+ type RecurringPriceInterval = 'day' | 'month' | 'week' | 'year';
1389
+ /** @public */
1390
+ type PriceType = 'one_time' | 'recurring';
1391
+ /** @public */
1392
+ type PricingScheme = 'per_unit' | 'tiered';
1393
+ /** @public */
1394
+ type UsageType = 'licensed' | 'metered';
1395
+ /** @public */
1396
+ type ItemType = 'credit' | 'debit';
1397
+ /**
1398
+ * The result of the prorations extension.
1399
+ * @public
1400
+ */
1401
+ interface ProrateItemsResult {
1402
+ /** The items with computed proration factors. */
1403
+ items: ItemWithProration[];
1404
+ }
1405
+ /**
1406
+ * An item with a computed proration factor.
1407
+ * @public
1408
+ */
1409
+ interface ItemWithProration {
1410
+ /** The unique identifier of the item, matching a key from the input. */
1411
+ key: string;
1412
+ /** The computed proration factor. Positive for charges, negative for credits. */
1413
+ prorationFactor: Decimal;
1414
+ /** The displayed period for the invoice line item. */
1415
+ lineItemPeriod: TimeRange;
1416
+ }
1417
+ /**
1418
+ * The input to the prorations extension.
1419
+ * @public
1420
+ */
1421
+ interface ProrateItemsInput {
1422
+ /** The list of items that can have their proration factor and line item period modified. */
1423
+ items: ProratableItem[];
1424
+ }
1425
+ /** @public */
1426
+ type ProratableItem = ({
1427
+ customPricingUnitOverageRate: CustomPricingUnitOverageRate;
1428
+ priceKind: 'customPricingUnitOverageRate';
1429
+ } | {
1430
+ licenseFee: LicenseFee;
1431
+ priceKind: 'licenseFee';
1432
+ } | {
1433
+ otherPriceKind: string;
1434
+ priceKind: 'other';
1435
+ } | {
1436
+ price: Price;
1437
+ priceKind: 'price';
1438
+ } | {
1439
+ priceKind: 'rateCardRate';
1440
+ rateCardRate: RateCardRate;
1441
+ }) & {
1442
+ correspondingDebit?: PreviousDebit;
1443
+ currentProrationFactor: Decimal;
1444
+ isProration: boolean;
1445
+ key: string;
1446
+ priceIntervalDuration: number;
1447
+ servicePeriod: TimeRange;
1448
+ type: ItemType;
1449
+ };
1450
+ /**
1451
+ * Information about a previous debit that a credit item offsets.
1452
+ * @public
1453
+ */
1454
+ interface PreviousDebit {
1455
+ /** The service period of the corresponding debit. */
1456
+ servicePeriod: TimeRange;
1457
+ }
1458
+ /** @public */
1459
+ interface CustomPricingUnitOverageRate {
1460
+ id: string;
1461
+ metadata: Record<string, string>;
1462
+ rateCard: RateCard;
1463
+ customPricingUnit: string;
1464
+ unitAmount: Decimal;
1465
+ }
1466
+ /** @public */
1467
+ interface RateCard {
1468
+ id: string;
1469
+ currency: Currency;
1470
+ }
1471
+ /** @public */
1472
+ interface RateCardRate {
1473
+ id: string;
1474
+ metadata: Record<string, string>;
1475
+ rateCard: RateCard;
1476
+ tieringMode?: PricingTierMode;
1477
+ tiers: RateCardRateTier[];
1478
+ unitAmount?: Decimal;
1479
+ }
1480
+ /** @public */
1481
+ interface RateCardRateTier {
1482
+ flatAmount?: Decimal;
1483
+ unitAmount?: Decimal;
1484
+ upTo?: Decimal;
1485
+ }
1486
+ /** @public */
1487
+ interface LicenseFee {
1488
+ id: string;
1489
+ lookupKey?: string;
1490
+ metadata: Record<string, string>;
1491
+ serviceInterval: RecurringPriceInterval;
1492
+ serviceIntervalCount: number;
1493
+ tieringMode?: PricingTierMode;
1494
+ tiers: LicenseFeeTier[];
1495
+ currency: Currency;
1496
+ unitAmount?: Decimal;
1497
+ }
1498
+ /** @public */
1499
+ interface LicenseFeeTier {
1500
+ flatAmount?: Decimal;
1501
+ unitAmount?: Decimal;
1502
+ upTo?: Decimal;
1503
+ }
1504
+ /** @public */
1505
+ interface Price {
1506
+ id: string;
1507
+ product: Product;
1508
+ recurring?: RecurringPrice;
1509
+ billingScheme: PricingScheme;
1510
+ tiers: PriceTier[];
1511
+ type: PriceType;
1512
+ tiersMode?: PricingTierMode;
1513
+ metadata: Record<string, string>;
1514
+ currency: Currency;
1515
+ unitAmount?: Decimal;
1516
+ }
1517
+ /** @public */
1518
+ interface PriceTier {
1519
+ flatAmount?: Decimal;
1520
+ unitAmount?: Decimal;
1521
+ upTo?: number;
1522
+ }
1523
+ /** @public */
1524
+ interface RecurringPrice {
1525
+ interval: RecurringPriceInterval;
1526
+ intervalCount: number;
1527
+ usageType?: UsageType;
1528
+ meter?: string;
1529
+ }
1530
+ /** @public */
1531
+ interface Product {
1532
+ id: string;
1533
+ name: string;
1534
+ metadata: Record<string, string>;
1535
+ }
1536
+ /**
1537
+ * @public
1538
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1539
+ */
1540
+ function prepareArgsProrateItems(proto: unknown): ProrateItemsInput;
1541
+ /**
1542
+ * @public
1543
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1544
+ */
1545
+ function prepareResultProrateItems(result: ProrateItemsResult): ProrateItemsResult;
1546
+ /** @internal */
1547
+ function $platformWrapProrateItems(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { prorateItems(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
1548
+ /**
1549
+ * @public
1550
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1551
+ */
1552
+ const prepareArgs: typeof prepareArgsProrateItems;
1553
+ /**
1554
+ * @public
1555
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1556
+ */
1557
+ const prepareResult: typeof prepareResultProrateItems;
1558
+ /**
1559
+ * Calculates prorated amounts for subscription items when changes occur mid-billing period. The script receives the invoice items, then returns computed proration factors for each item.
1560
+ * @public
1561
+ */
1562
+ type ProrateItemsFunction<Config> = (request: ProrateItemsInput, config: Config, context: Context) => ProrateItemsResult;
1563
+ }
1564
+
1565
+ /**
1566
+ * @example
1567
+ * ```ts
1568
+ * import type { Billing, Context } from '@stripe/extensibility-sdk';
1569
+ *
1570
+ * // eslint-disable-next-line @typescript-eslint/no-empty-object-type
1571
+ * interface MyProrationsConfig {}
1572
+ *
1573
+ * export default class MyProrations implements Billing.Prorations<MyProrationsConfig> {
1574
+ * prorateItems(
1575
+ * _request: Billing.Prorations.ProrateItemsInput,
1576
+ * _config: MyProrationsConfig,
1577
+ * _context: Context
1578
+ * ) {
1579
+ * // TODO: implement your proration logic here
1580
+ *
1581
+ * return {
1582
+ * items: [],
1583
+ * };
1584
+ * }
1585
+ * }
1586
+ *
1587
+ * ```
1588
+ * @public
1589
+ */
1590
+ declare interface Prorations<Config> {
1591
+ prorateItems: Prorations.ProrateItemsFunction<Config>;
1592
+ }
1593
+
623
1594
  /**
624
1595
  * Bidirectional enum spec for proto-backed enums. Accepts a single
625
1596
  * `fromProto` map and derives the inverse; throws if the map is not
@@ -663,6 +1634,312 @@ export declare interface _ProtoWireToTypeStrategy extends _ApplyStrategy {
663
1634
  readonly _brand: 'ProtoWireToType';
664
1635
  }
665
1636
 
1637
+ /** @public */
1638
+ declare namespace RecurringBillingItemHandling {
1639
+ /** @public */
1640
+ type PricingTierMode = 'graduated' | 'volume';
1641
+ /** @public */
1642
+ type RecurringPriceInterval = 'day' | 'month' | 'week' | 'year';
1643
+ /** @public */
1644
+ type PriceType = 'one_time' | 'recurring';
1645
+ /** @public */
1646
+ type PricingScheme = 'per_unit' | 'tiered';
1647
+ /** @public */
1648
+ type UsageType = 'licensed' | 'metered';
1649
+ /** @public */
1650
+ type ItemType = 'credit' | 'debit';
1651
+ /**
1652
+ * The result of the group items extension.
1653
+ * @public
1654
+ */
1655
+ interface GroupItemsResult {
1656
+ /** The groups of items, each corresponding to a separate invoice. */
1657
+ groups: ItemGroup[];
1658
+ }
1659
+ /**
1660
+ * A group of items to place on a single invoice.
1661
+ * @public
1662
+ */
1663
+ interface ItemGroup {
1664
+ /** The items in this group. */
1665
+ items: GroupedItem[];
1666
+ /** Whether this group sets the latest invoice reference on the subscription. */
1667
+ setsLatestInvoice: boolean;
1668
+ }
1669
+ /**
1670
+ * An item assigned to a group.
1671
+ * @public
1672
+ */
1673
+ interface GroupedItem {
1674
+ /** The unique identifier of the item, matching a key from the input. */
1675
+ key: string;
1676
+ }
1677
+ /**
1678
+ * The input to the group items extension.
1679
+ * @public
1680
+ */
1681
+ interface GroupItemsInput {
1682
+ /** The list of items to group across invoices. */
1683
+ items: Item[];
1684
+ }
1685
+ /** @public */
1686
+ type Item = ({
1687
+ customPricingUnitOverageRate: CustomPricingUnitOverageRate;
1688
+ priceKind: 'customPricingUnitOverageRate';
1689
+ } | {
1690
+ licenseFee: LicenseFee;
1691
+ priceKind: 'licenseFee';
1692
+ } | {
1693
+ otherPriceKind: string;
1694
+ priceKind: 'other';
1695
+ } | {
1696
+ price: Price;
1697
+ priceKind: 'price';
1698
+ } | {
1699
+ priceKind: 'rateCardRate';
1700
+ rateCardRate: RateCardRate;
1701
+ }) & {
1702
+ isProration: boolean;
1703
+ key: string;
1704
+ prorationFactor: Decimal;
1705
+ servicePeriod: AnyTimeRange;
1706
+ type: ItemType;
1707
+ };
1708
+ /** @public */
1709
+ interface CustomPricingUnitOverageRate {
1710
+ id: string;
1711
+ metadata: Record<string, string>;
1712
+ rateCard: RateCard;
1713
+ customPricingUnit: string;
1714
+ unitAmount: Decimal;
1715
+ }
1716
+ /** @public */
1717
+ interface RateCard {
1718
+ id: string;
1719
+ currency: Currency;
1720
+ }
1721
+ /** @public */
1722
+ interface RateCardRate {
1723
+ id: string;
1724
+ metadata: Record<string, string>;
1725
+ rateCard: RateCard;
1726
+ tieringMode?: PricingTierMode;
1727
+ tiers: RateCardRateTier[];
1728
+ unitAmount?: Decimal;
1729
+ }
1730
+ /** @public */
1731
+ interface RateCardRateTier {
1732
+ flatAmount?: Decimal;
1733
+ unitAmount?: Decimal;
1734
+ upTo?: Decimal;
1735
+ }
1736
+ /** @public */
1737
+ interface LicenseFee {
1738
+ id: string;
1739
+ lookupKey?: string;
1740
+ metadata: Record<string, string>;
1741
+ serviceInterval: RecurringPriceInterval;
1742
+ serviceIntervalCount: number;
1743
+ tieringMode?: PricingTierMode;
1744
+ tiers: LicenseFeeTier[];
1745
+ currency: Currency;
1746
+ unitAmount?: Decimal;
1747
+ }
1748
+ /** @public */
1749
+ interface LicenseFeeTier {
1750
+ flatAmount?: Decimal;
1751
+ unitAmount?: Decimal;
1752
+ upTo?: Decimal;
1753
+ }
1754
+ /** @public */
1755
+ interface Price {
1756
+ id: string;
1757
+ product: Product;
1758
+ recurring?: RecurringPrice;
1759
+ billingScheme: PricingScheme;
1760
+ tiers: PriceTier[];
1761
+ type: PriceType;
1762
+ tiersMode?: PricingTierMode;
1763
+ metadata: Record<string, string>;
1764
+ currency: Currency;
1765
+ unitAmount?: Decimal;
1766
+ }
1767
+ /** @public */
1768
+ interface PriceTier {
1769
+ flatAmount?: Decimal;
1770
+ unitAmount?: Decimal;
1771
+ upTo?: number;
1772
+ }
1773
+ /** @public */
1774
+ interface RecurringPrice {
1775
+ interval: RecurringPriceInterval;
1776
+ intervalCount: number;
1777
+ usageType?: UsageType;
1778
+ meter?: string;
1779
+ }
1780
+ /** @public */
1781
+ interface Product {
1782
+ id: string;
1783
+ name: string;
1784
+ metadata: Record<string, string>;
1785
+ }
1786
+ /**
1787
+ * The result of the filter items extension.
1788
+ * @public
1789
+ */
1790
+ interface FilterItemsResult {
1791
+ /** The items to include on the invoice. */
1792
+ items: ItemToInvoice[];
1793
+ }
1794
+ /**
1795
+ * An item selected for inclusion on the invoice.
1796
+ * @public
1797
+ */
1798
+ interface ItemToInvoice {
1799
+ /** The unique identifier of the item, matching a key from the input. */
1800
+ key: string;
1801
+ }
1802
+ /**
1803
+ * The input to the filter items extension.
1804
+ * @public
1805
+ */
1806
+ interface FilterItemsInput {
1807
+ /** The list of items to evaluate for inclusion on the invoice. */
1808
+ items: Item[];
1809
+ }
1810
+ /**
1811
+ * The result of the before item creation extension.
1812
+ * @public
1813
+ */
1814
+ interface BeforeItemCreationResult {
1815
+ /** The items with their creation strategies. */
1816
+ items: ItemWithCreationStrategy[];
1817
+ }
1818
+ /** @public */
1819
+ type ItemWithCreationStrategy = ({
1820
+ creationStrategy: 'other';
1821
+ otherCreationStrategy: string;
1822
+ } | { creationStrategy: 'doNotCreate' } | { creationStrategy: 'invoice' }) & { key: string };
1823
+ /** @public */
1824
+ type Invoice = Record<string, never>;
1825
+ /** @public */
1826
+ type DoNotCreate = Record<string, never>;
1827
+ /**
1828
+ * The input to the before item creation extension.
1829
+ * @public
1830
+ */
1831
+ interface BeforeItemCreationInput {
1832
+ /** The list of items to evaluate for creation. */
1833
+ items: Item[];
1834
+ }
1835
+ /**
1836
+ * @public
1837
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1838
+ */
1839
+ function prepareArgsBeforeItemCreation(proto: unknown): BeforeItemCreationInput;
1840
+ /**
1841
+ * @public
1842
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1843
+ */
1844
+ function prepareResultBeforeItemCreation(result: BeforeItemCreationResult): BeforeItemCreationResult;
1845
+ /** @internal */
1846
+ function $platformWrapBeforeItemCreation(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { beforeItemCreation(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
1847
+ /**
1848
+ * @public
1849
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1850
+ */
1851
+ function prepareArgsFilterItems(proto: unknown): FilterItemsInput;
1852
+ /**
1853
+ * @public
1854
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1855
+ */
1856
+ function prepareResultFilterItems(result: FilterItemsResult): FilterItemsResult;
1857
+ /** @internal */
1858
+ function $platformWrapFilterItems(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { filterItems(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
1859
+ /**
1860
+ * @public
1861
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1862
+ */
1863
+ function prepareArgsGroupItems(proto: unknown): GroupItemsInput;
1864
+ /**
1865
+ * @public
1866
+ * @deprecated Platform dispatch handles wire/SDK conversion.
1867
+ */
1868
+ function prepareResultGroupItems(result: GroupItemsResult): GroupItemsResult;
1869
+ /** @internal */
1870
+ function $platformWrapGroupItems(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { groupItems(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
1871
+ /**
1872
+ * Runs before invoice items are created. Decides whether each item should be created or skipped.
1873
+ * @public
1874
+ */
1875
+ type BeforeItemCreationFunction<Config> = (request: BeforeItemCreationInput, config: Config, context: Context) => BeforeItemCreationResult;
1876
+ /**
1877
+ * Runs before invoices are created. Decides which items to include on the invoice. Items not included are deferred as pending invoice items.
1878
+ * @public
1879
+ */
1880
+ type FilterItemsFunction<Config> = (request: FilterItemsInput, config: Config, context: Context) => FilterItemsResult;
1881
+ /**
1882
+ * Runs before invoices are created. Decides how items are grouped across one or more invoices.
1883
+ * @public
1884
+ */
1885
+ type GroupItemsFunction<Config> = (request: GroupItemsInput, config: Config, context: Context) => GroupItemsResult;
1886
+ }
1887
+
1888
+ /**
1889
+ * @example
1890
+ * ```ts
1891
+ * import type { Billing, Context } from '@stripe/extensibility-sdk';
1892
+ *
1893
+ * // eslint-disable-next-line @typescript-eslint/no-empty-object-type
1894
+ * interface MyRecurringBillingItemHandlingConfig {}
1895
+ *
1896
+ * export default class MyRecurringBillingItemHandling implements Billing.RecurringBillingItemHandling<MyRecurringBillingItemHandlingConfig> {
1897
+ * beforeItemCreation(
1898
+ * _request: Billing.RecurringBillingItemHandling.BeforeItemCreationInput,
1899
+ * _config: MyRecurringBillingItemHandlingConfig,
1900
+ * _context: Context
1901
+ * ) {
1902
+ * // TODO: implement your before-item-creation logic here
1903
+ *
1904
+ * return {
1905
+ * items: [],
1906
+ * };
1907
+ * }
1908
+ *
1909
+ * filterItems(
1910
+ * _request: Billing.RecurringBillingItemHandling.FilterItemsInput,
1911
+ * _config: MyRecurringBillingItemHandlingConfig,
1912
+ * _context: Context
1913
+ * ) {
1914
+ * // TODO: implement your filter-items logic here
1915
+ *
1916
+ * return {
1917
+ * items: [],
1918
+ * };
1919
+ * }
1920
+ *
1921
+ * groupItems(
1922
+ * _request: Billing.RecurringBillingItemHandling.GroupItemsInput,
1923
+ * _config: MyRecurringBillingItemHandlingConfig,
1924
+ * _context: Context
1925
+ * ) {
1926
+ * // TODO: implement your group-items logic here
1927
+ *
1928
+ * return {
1929
+ * groups: [],
1930
+ * };
1931
+ * }
1932
+ * }
1933
+ *
1934
+ * ```
1935
+ * @public
1936
+ */
1937
+ declare interface RecurringBillingItemHandling<Config> {
1938
+ beforeItemCreation: RecurringBillingItemHandling.BeforeItemCreationFunction<Config>;
1939
+ filterItems: RecurringBillingItemHandling.FilterItemsFunction<Config>;
1940
+ groupItems: RecurringBillingItemHandling.GroupItemsFunction<Config>;
1941
+ }
1942
+
666
1943
  /**
667
1944
  * Object reference — a typed pointer to another API resource.
668
1945
  *
@@ -756,6 +2033,17 @@ export declare const StreetAddress: { create: (address: string) => StreetAddress
756
2033
  /** The type of the opaque Stripe type-tag symbol used in SDK scalar types. @public */
757
2034
  export declare type StripeTypeSymbol = typeof __stripeType;
758
2035
 
2036
+ /**
2037
+ * Represents a time period with start and end dates.
2038
+ * @public
2039
+ */
2040
+ declare interface TimeRange {
2041
+ /** The beginning date of the range. */
2042
+ startDate: Date;
2043
+ /** The ending date of the range. */
2044
+ endDate: Date;
2045
+ }
2046
+
759
2047
  /** A branded string representing an ISO 8601 datetime. @public */
760
2048
  export declare type Timestamp = {
761
2049
  readonly [__brand]: 'Timestamp';
@@ -912,4 +2200,16 @@ export declare class WireWriteError extends Error {
912
2200
  name: string;
913
2201
  }
914
2202
 
2203
+ declare namespace Workflows {
2204
+ export {
2205
+ CustomAction
2206
+ }
2207
+ }
2208
+
2209
+ declare namespace Workflows_2 {
2210
+ export {
2211
+ CustomAction_2 as CustomAction
2212
+ }
2213
+ }
2214
+
915
2215
  export { }