@stripe/extensibility-sdk 1.1.0 → 1.3.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.
- package/README.md +17 -15
- package/dist/config-values/generate.cjs +1 -1
- package/dist/config-values/generate.d.ts +1 -1
- package/dist/config-values/generate.d.ts.map +1 -1
- package/dist/config-values/generate.js +1 -1
- package/dist/extensibility-sdk-alpha.d.ts +29 -157
- package/dist/extensibility-sdk-beta.d.ts +29 -157
- package/dist/extensibility-sdk-config-values-internal.d.ts +1 -1
- package/dist/extensibility-sdk-extensions-alpha.d.ts +7 -157
- package/dist/extensibility-sdk-extensions-beta.d.ts +7 -157
- package/dist/extensibility-sdk-extensions-billing-bill-discount_calculation-alpha.d.ts +631 -0
- package/dist/extensibility-sdk-extensions-billing-bill-discount_calculation-beta.d.ts +631 -0
- package/dist/extensibility-sdk-extensions-billing-bill-discount_calculation-internal.d.ts +666 -0
- package/dist/extensibility-sdk-extensions-billing-bill-discount_calculation-public.d.ts +631 -0
- package/dist/extensibility-sdk-extensions-billing-customer_balance_application-alpha.d.ts +475 -0
- package/dist/extensibility-sdk-extensions-billing-customer_balance_application-beta.d.ts +475 -0
- package/dist/extensibility-sdk-extensions-billing-customer_balance_application-internal.d.ts +510 -0
- package/dist/extensibility-sdk-extensions-billing-customer_balance_application-public.d.ts +475 -0
- package/dist/extensibility-sdk-extensions-billing-invoice_collection_options-alpha.d.ts +110 -0
- package/dist/extensibility-sdk-extensions-billing-invoice_collection_options-beta.d.ts +110 -0
- package/dist/extensibility-sdk-extensions-billing-invoice_collection_options-internal.d.ts +123 -0
- package/dist/extensibility-sdk-extensions-billing-invoice_collection_options-public.d.ts +110 -0
- package/dist/extensibility-sdk-extensions-billing-prorations-alpha.d.ts +607 -0
- package/dist/extensibility-sdk-extensions-billing-prorations-beta.d.ts +607 -0
- package/dist/extensibility-sdk-extensions-billing-prorations-internal.d.ts +642 -0
- package/dist/extensibility-sdk-extensions-billing-prorations-public.d.ts +607 -0
- package/dist/extensibility-sdk-extensions-billing-recurring_billing_item_handling-alpha.d.ts +735 -0
- package/dist/extensibility-sdk-extensions-billing-recurring_billing_item_handling-beta.d.ts +735 -0
- package/dist/extensibility-sdk-extensions-billing-recurring_billing_item_handling-internal.d.ts +772 -0
- package/dist/extensibility-sdk-extensions-billing-recurring_billing_item_handling-public.d.ts +735 -0
- package/dist/extensibility-sdk-extensions-core-workflows-custom_action-alpha.d.ts +126 -0
- package/dist/extensibility-sdk-extensions-core-workflows-custom_action-beta.d.ts +126 -0
- package/dist/extensibility-sdk-extensions-core-workflows-custom_action-internal.d.ts +140 -0
- package/dist/extensibility-sdk-extensions-core-workflows-custom_action-public.d.ts +126 -0
- package/dist/extensibility-sdk-extensions-extend-workflows-custom_action-alpha.d.ts +126 -0
- package/dist/extensibility-sdk-extensions-extend-workflows-custom_action-beta.d.ts +126 -0
- package/dist/extensibility-sdk-extensions-extend-workflows-custom_action-internal.d.ts +140 -0
- package/dist/extensibility-sdk-extensions-extend-workflows-custom_action-public.d.ts +126 -0
- package/dist/extensibility-sdk-extensions-internal.d.ts +7 -157
- package/dist/extensibility-sdk-extensions-public.d.ts +7 -157
- package/dist/extensibility-sdk-internal-internal.d.ts +2 -2
- package/dist/extensibility-sdk-internal.d.ts +145 -162
- package/dist/extensibility-sdk-public.d.ts +29 -157
- package/dist/extensibility-sdk-stdlib-alpha.d.ts +593 -0
- package/dist/extensibility-sdk-stdlib-beta.d.ts +593 -0
- package/dist/extensibility-sdk-stdlib-internal.d.ts +1096 -0
- package/dist/extensibility-sdk-stdlib-public.d.ts +593 -0
- package/dist/extensions/billing/bill/discount_calculation.cjs +437 -0
- package/dist/extensions/billing/bill/discount_calculation.d.ts +0 -20
- package/dist/extensions/billing/bill/discount_calculation.d.ts.map +1 -1
- package/dist/extensions/billing/bill/discount_calculation.js +430 -0
- package/dist/extensions/billing/customer_balance_application.cjs +297 -0
- package/dist/extensions/billing/customer_balance_application.d.ts +0 -20
- package/dist/extensions/billing/customer_balance_application.d.ts.map +1 -1
- package/dist/extensions/billing/customer_balance_application.js +284 -0
- package/dist/extensions/billing/invoice_collection_options.cjs +166 -0
- package/dist/extensions/billing/invoice_collection_options.d.ts +4 -24
- package/dist/extensions/billing/invoice_collection_options.d.ts.map +1 -1
- package/dist/extensions/billing/invoice_collection_options.js +155 -0
- package/dist/extensions/billing/prorations.cjs +501 -0
- package/dist/extensions/billing/prorations.d.ts +0 -20
- package/dist/extensions/billing/prorations.d.ts.map +1 -1
- package/dist/extensions/billing/prorations.js +492 -0
- package/dist/extensions/billing/recurring_billing_item_handling.cjs +639 -0
- package/dist/extensions/billing/recurring_billing_item_handling.d.ts +0 -30
- package/dist/extensions/billing/recurring_billing_item_handling.d.ts.map +1 -1
- package/dist/extensions/billing/recurring_billing_item_handling.js +632 -0
- package/dist/extensions/core/workflows/custom_action.cjs +124 -0
- package/dist/extensions/core/workflows/custom_action.d.ts +1 -21
- package/dist/extensions/core/workflows/custom_action.d.ts.map +1 -1
- package/dist/extensions/core/workflows/custom_action.js +111 -0
- package/dist/extensions/extend/workflows/custom_action.cjs +124 -0
- package/dist/extensions/extend/workflows/custom_action.d.ts +1 -21
- package/dist/extensions/extend/workflows/custom_action.d.ts.map +1 -1
- package/dist/extensions/extend/workflows/custom_action.js +111 -0
- package/dist/extensions/index.cjs +27 -265
- package/dist/extensions/index.js +27 -265
- package/dist/extensions/registry.d.ts +2 -2
- package/dist/extensions/registry.d.ts.map +1 -1
- package/dist/index.cjs +452 -2390
- package/dist/index.js +479 -2286
- package/dist/internal.cjs +22 -54
- package/dist/internal.js +22 -54
- package/dist/stdlib/generated.d.ts +1 -1
- package/dist/stdlib/generated.d.ts.map +1 -1
- package/dist/stdlib/index.cjs +2003 -0
- package/dist/stdlib/index.d.ts +2 -2
- package/dist/stdlib/index.d.ts.map +1 -1
- package/dist/stdlib/index.js +1943 -0
- package/dist/stdlib/transform-strategies.d.ts +46 -6
- package/dist/stdlib/transform-strategies.d.ts.map +1 -1
- package/dist/stdlib/types.d.ts +82 -0
- package/dist/stdlib/types.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +65 -1
- package/dist/stdlib/extension-method.d.ts +0 -27
- package/dist/stdlib/extension-method.d.ts.map +0 -1
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import { __integerBrand } from '@formspec/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Opaque brand key used as a property key in SDK branded types.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* You do not need to use this directly — it is already embedded in
|
|
8
|
+
* branded values returned by factory functions like {@link (Integer:type)}.from().
|
|
9
|
+
*
|
|
10
|
+
* String-literal const (not `unique symbol`) so that independent
|
|
11
|
+
* declaration rollups (root vs subpath) produce structurally compatible
|
|
12
|
+
* branded types.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
declare const __brand: '__brand';
|
|
17
|
+
|
|
18
|
+
/* Excluded from this release type: __decimalBrand */
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Distinct brand key for PositiveInteger so an Integer is not assignable to
|
|
22
|
+
* PositiveInteger without going through the guard. PositiveInteger is a
|
|
23
|
+
* subtype of Integer (it carries both brands), so it can be used wherever
|
|
24
|
+
* Integer is expected.
|
|
25
|
+
*
|
|
26
|
+
* String-literal const (not `unique symbol`) so that independent
|
|
27
|
+
* declaration rollups (root vs subpath) produce structurally compatible
|
|
28
|
+
* branded types.
|
|
29
|
+
*
|
|
30
|
+
* For internal use only — may be removed in a future release.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
declare const __positiveIntegerBrand: '__positiveIntegerBrand';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Opaque type-tag key used by SDK scalar types to carry Stripe type metadata.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* You do not need to use this directly — it is already embedded in
|
|
41
|
+
* branded values returned by factory functions like {@link (Integer:type)}.from().
|
|
42
|
+
*
|
|
43
|
+
* String-literal const (not `unique symbol`) so that independent
|
|
44
|
+
* declaration rollups (root vs subpath) produce structurally compatible
|
|
45
|
+
* branded types.
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
declare const __stripeType: '__stripeType';
|
|
50
|
+
|
|
51
|
+
/* Excluded from this release type: _ConfigApplicationContext */
|
|
52
|
+
|
|
53
|
+
/** @public */
|
|
54
|
+
declare interface Context {
|
|
55
|
+
type: string;
|
|
56
|
+
id: string;
|
|
57
|
+
livemode: boolean;
|
|
58
|
+
stripeContext?: string;
|
|
59
|
+
clockTime?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** @public */
|
|
63
|
+
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' | 'mon' | 'mop' | 'mro' | 'mru' | 'mur' | 'mvr' | 'mwk' | 'mxn' | 'mxv' | 'myr' | 'mzn' | 'nad' | 'ngn' | 'nio' | 'nok' | 'npr' | 'nzd' | 'omr' | 'open_usd' | 'ord' | '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' | 'usdsui' | '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';
|
|
64
|
+
|
|
65
|
+
/** @public */
|
|
66
|
+
export declare namespace CustomerBalanceApplication {
|
|
67
|
+
/**
|
|
68
|
+
* The result of computing how much customer balance to apply to a bill.
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export interface CustomerBalanceApplicationResult {
|
|
72
|
+
/** 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. */
|
|
73
|
+
appliedCustomerBalance: MonetaryAmount;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The bill details provided as input to the customer balance application extension.
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export interface CustomerBalanceApplicationInput {
|
|
80
|
+
/** The total amount of the invoice before applying any customer balance. */
|
|
81
|
+
totalAmount: MonetaryAmount;
|
|
82
|
+
/** The current customer balance available to apply. Positive values indicate debits (the customer owes money), negative values indicate credits. */
|
|
83
|
+
customerBalance: MonetaryAmount;
|
|
84
|
+
}
|
|
85
|
+
/* Excluded from this release type: $platformWrapComputeAppliedCustomerBalance */
|
|
86
|
+
/**
|
|
87
|
+
* 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.
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
export type ComputeAppliedCustomerBalanceFunction<Config> = (request: CustomerBalanceApplicationInput, config: Config, context: Context) => CustomerBalanceApplicationResult;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
97
|
+
*
|
|
98
|
+
* // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
99
|
+
* interface MyBalanceAppConfig {}
|
|
100
|
+
*
|
|
101
|
+
* export default class MyBalanceApp implements Billing.CustomerBalanceApplication<MyBalanceAppConfig> {
|
|
102
|
+
* computeAppliedCustomerBalance(
|
|
103
|
+
* request: Billing.CustomerBalanceApplication.CustomerBalanceApplicationInput,
|
|
104
|
+
* _config: MyBalanceAppConfig,
|
|
105
|
+
* _context: Context
|
|
106
|
+
* ) {
|
|
107
|
+
* // TODO: implement your customer balance logic here
|
|
108
|
+
*
|
|
109
|
+
* return {
|
|
110
|
+
* appliedCustomerBalance: request.customerBalance,
|
|
111
|
+
* };
|
|
112
|
+
* }
|
|
113
|
+
* }
|
|
114
|
+
*
|
|
115
|
+
* ```
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
export declare interface CustomerBalanceApplication<Config> {
|
|
119
|
+
computeAppliedCustomerBalance: CustomerBalanceApplication.ComputeAppliedCustomerBalanceFunction<Config>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Arbitrary-precision decimal type for billing calculations.
|
|
124
|
+
*
|
|
125
|
+
* @remarks
|
|
126
|
+
* `Decimal` values are created by the {@link (Decimal:variable) | Decimal companion object}
|
|
127
|
+
* and store values as `coefficient × 10^exponent` using `BigInt`. They avoid
|
|
128
|
+
* every common binary floating-point pitfall — `Decimal.from('0.1').add(Decimal.from('0.2'))`
|
|
129
|
+
* is exactly `0.3`.
|
|
130
|
+
*
|
|
131
|
+
* Instances are immutable (frozen) and all arithmetic returns a new
|
|
132
|
+
* `Decimal`. The public type carries two brand symbols so the type system
|
|
133
|
+
* prevents accidental assignment from plain `number`, `string`, or
|
|
134
|
+
* `bigint`.
|
|
135
|
+
*
|
|
136
|
+
* Create values via the companion object:
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* import { Decimal, RoundDirection } from '@stripe/extensibility-sdk';
|
|
141
|
+
*
|
|
142
|
+
* const price = Decimal.from('19.99');
|
|
143
|
+
* const tax = price.mul(Decimal.from('0.0825'));
|
|
144
|
+
* const total = price.add(tax);
|
|
145
|
+
*
|
|
146
|
+
* console.log(total.toFixed(2, 'half-up')); // "21.64"
|
|
147
|
+
* console.log(JSON.stringify({ total })); // '{"total":"21.639175"}'
|
|
148
|
+
* console.log(total.toFixed(2, 'half-even')); // "21.64"
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
declare interface Decimal {
|
|
154
|
+
/* Excluded from this release type: __brand */
|
|
155
|
+
/* Excluded from this release type: __decimalBrand */
|
|
156
|
+
/* Excluded from this release type: __stripeType */
|
|
157
|
+
/**
|
|
158
|
+
* Return the sum of this value and `other`.
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
add(other: DecimalLike): Decimal;
|
|
162
|
+
/**
|
|
163
|
+
* Return the difference of this value and `other`.
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
sub(other: DecimalLike): Decimal;
|
|
167
|
+
/**
|
|
168
|
+
* Return the product of this value and `other`.
|
|
169
|
+
* @public
|
|
170
|
+
*/
|
|
171
|
+
mul(other: DecimalLike): Decimal;
|
|
172
|
+
/**
|
|
173
|
+
* Return the quotient of this value divided by `other`.
|
|
174
|
+
* @public
|
|
175
|
+
*/
|
|
176
|
+
div(other: DecimalLike, precision: number, direction: RoundDirection): Decimal;
|
|
177
|
+
/**
|
|
178
|
+
* Three-way comparison: returns `-1`, `0`, or `1`.
|
|
179
|
+
* @public
|
|
180
|
+
*/
|
|
181
|
+
cmp(other: DecimalLike): -1 | 0 | 1;
|
|
182
|
+
/**
|
|
183
|
+
* Return `true` if this value is numerically equal to `other`.
|
|
184
|
+
* @public
|
|
185
|
+
*/
|
|
186
|
+
eq(other: DecimalLike): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Return `true` if this value is strictly less than `other`.
|
|
189
|
+
* @public
|
|
190
|
+
*/
|
|
191
|
+
lt(other: DecimalLike): boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Return `true` if this value is less than or equal to `other`.
|
|
194
|
+
* @public
|
|
195
|
+
*/
|
|
196
|
+
lte(other: DecimalLike): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Return `true` if this value is strictly greater than `other`.
|
|
199
|
+
* @public
|
|
200
|
+
*/
|
|
201
|
+
gt(other: DecimalLike): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Return `true` if this value is greater than or equal to `other`.
|
|
204
|
+
* @public
|
|
205
|
+
*/
|
|
206
|
+
gte(other: DecimalLike): boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Return `true` if this value is exactly zero.
|
|
209
|
+
* @public
|
|
210
|
+
*/
|
|
211
|
+
isZero(): boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Return `true` if this value is strictly less than zero.
|
|
214
|
+
* @public
|
|
215
|
+
*/
|
|
216
|
+
isNegative(): boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Return `true` if this value is strictly greater than zero.
|
|
219
|
+
* @public
|
|
220
|
+
*/
|
|
221
|
+
isPositive(): boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Return the additive inverse of this value.
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
neg(): Decimal;
|
|
227
|
+
/**
|
|
228
|
+
* Return the absolute value.
|
|
229
|
+
* @public
|
|
230
|
+
*/
|
|
231
|
+
abs(): Decimal;
|
|
232
|
+
/**
|
|
233
|
+
* Round this value to the specified precision.
|
|
234
|
+
* @public
|
|
235
|
+
*/
|
|
236
|
+
round(direction: RoundDirection, options: DecimalRoundingOptions | keyof typeof DecimalRoundingPresets): Decimal;
|
|
237
|
+
/**
|
|
238
|
+
* Return the canonical string representation.
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
241
|
+
toString(): string;
|
|
242
|
+
/**
|
|
243
|
+
* Return the JSON-serializable string representation.
|
|
244
|
+
* @public
|
|
245
|
+
*/
|
|
246
|
+
toJSON(): string;
|
|
247
|
+
/**
|
|
248
|
+
* Convert to a JavaScript `number` (lossy).
|
|
249
|
+
* @public
|
|
250
|
+
*/
|
|
251
|
+
toNumber(): number;
|
|
252
|
+
/**
|
|
253
|
+
* Format as a fixed-point string with exactly `decimalPlaces` digits.
|
|
254
|
+
* @public
|
|
255
|
+
*/
|
|
256
|
+
toFixed(decimalPlaces: number, direction: RoundDirection): string;
|
|
257
|
+
/**
|
|
258
|
+
* Convert to an {@link (Integer:type)} by rounding.
|
|
259
|
+
* @public
|
|
260
|
+
*/
|
|
261
|
+
toInteger(direction: RoundDirection): Integer;
|
|
262
|
+
/**
|
|
263
|
+
* Rejects implicit coercion; explicit `String(d)` and template literals still work.
|
|
264
|
+
* @public
|
|
265
|
+
*/
|
|
266
|
+
[Symbol.toPrimitive](hint: 'default' | 'number' | 'string'): string;
|
|
267
|
+
/**
|
|
268
|
+
* Returns the string representation; invoked by the JavaScript engine as a fallback coercion path.
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
valueOf(): string;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Companion object for creating `Decimal` instances.
|
|
276
|
+
*
|
|
277
|
+
* @public
|
|
278
|
+
*/
|
|
279
|
+
declare const Decimal: DecimalCompanion;
|
|
280
|
+
|
|
281
|
+
/** @public */
|
|
282
|
+
declare interface DecimalCompanion {
|
|
283
|
+
/** Type guard: narrows `unknown` to `Decimal`. @public */
|
|
284
|
+
is(value: unknown): value is Decimal;
|
|
285
|
+
/** Assertion guard: throws if not a `Decimal`. @public */
|
|
286
|
+
assert(value: unknown): asserts value is Decimal;
|
|
287
|
+
/** Create a Decimal from a {@link DecimalLike} value. @public */
|
|
288
|
+
from(value: DecimalLike): Decimal;
|
|
289
|
+
/** The Decimal value `0`. @public */
|
|
290
|
+
readonly zero: Decimal;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Values that can be coerced to a `Decimal` via `Decimal.from()`.
|
|
295
|
+
*
|
|
296
|
+
* @remarks
|
|
297
|
+
* This union is accepted by `Decimal.from()` and by all arithmetic and
|
|
298
|
+
* comparison methods on `Decimal` instances. Non-Decimal values are
|
|
299
|
+
* coerced via `Decimal.from()` before the operation.
|
|
300
|
+
*
|
|
301
|
+
* @public
|
|
302
|
+
*/
|
|
303
|
+
declare type DecimalLike = bigint | Decimal | Integer | number | string;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Precision specification for `Decimal.round()`.
|
|
307
|
+
*
|
|
308
|
+
* @remarks
|
|
309
|
+
* Two modes are supported:
|
|
310
|
+
* - `"decimal-places"` — round to a fixed number of digits after the decimal point.
|
|
311
|
+
* - `"significant-figures"` — round to a fixed number of significant digits.
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```ts
|
|
315
|
+
* // Round to 2 decimal places
|
|
316
|
+
* amount.round('half-even', { mode: 'decimal-places', value: 2 });
|
|
317
|
+
*
|
|
318
|
+
* // Round to 4 significant figures
|
|
319
|
+
* amount.round('half-up', { mode: 'significant-figures', value: 4 });
|
|
320
|
+
* ```
|
|
321
|
+
*
|
|
322
|
+
* @public
|
|
323
|
+
*/
|
|
324
|
+
declare interface DecimalRoundingOptions {
|
|
325
|
+
/** Whether to count digits from the decimal point (`"decimal-places"`) or from the most significant digit (`"significant-figures"`). */
|
|
326
|
+
mode: 'decimal-places' | 'significant-figures';
|
|
327
|
+
/**
|
|
328
|
+
* The number of digits to retain. Interpreted as decimal places when
|
|
329
|
+
* `mode` is `"decimal-places"`, or as significant figures when `mode`
|
|
330
|
+
* is `"significant-figures"`.
|
|
331
|
+
* @public
|
|
332
|
+
*/
|
|
333
|
+
value: number;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Built-in rounding presets keyed by semantic name.
|
|
338
|
+
*
|
|
339
|
+
* @remarks
|
|
340
|
+
* Stripe defines the full set of supported preset names accepted by
|
|
341
|
+
* `Decimal.round()`.
|
|
342
|
+
*
|
|
343
|
+
* | Preset | Equivalent DecimalRoundingOptions |
|
|
344
|
+
* | ------------------- | ----------------------------------------------------- |
|
|
345
|
+
* | `"ubb-usage-count"` | `{ mode: "significant-figures", value: 15 }` |
|
|
346
|
+
* | `"v1-api"` | `{ mode: "decimal-places", value: 12 }` |
|
|
347
|
+
*
|
|
348
|
+
* @public
|
|
349
|
+
*/
|
|
350
|
+
declare const DecimalRoundingPresets: Readonly<{
|
|
351
|
+
'ubb-usage-count': Readonly<{
|
|
352
|
+
mode: "significant-figures";
|
|
353
|
+
value: number;
|
|
354
|
+
}>;
|
|
355
|
+
'v1-api': Readonly<{
|
|
356
|
+
mode: "decimal-places";
|
|
357
|
+
value: number;
|
|
358
|
+
}>;
|
|
359
|
+
}>;
|
|
360
|
+
|
|
361
|
+
/** A branded integer — a `number` guaranteed to satisfy `Number.isInteger`. @public */
|
|
362
|
+
declare type Integer = {
|
|
363
|
+
readonly [__integerBrand]: true;
|
|
364
|
+
readonly [__stripeType]: 'int';
|
|
365
|
+
} & number;
|
|
366
|
+
|
|
367
|
+
/** Factory, type guard, and utilities for {@link (Integer:type)} branded values. @public */
|
|
368
|
+
declare const Integer: IntegerCompanion;
|
|
369
|
+
|
|
370
|
+
/** @public */
|
|
371
|
+
declare interface IntegerCompanion {
|
|
372
|
+
/** The Integer value `0`. @public */
|
|
373
|
+
readonly zero: Integer;
|
|
374
|
+
/** Type guard: narrows `unknown` to {@link (Integer:type)}. @public */
|
|
375
|
+
is(value: unknown): value is Integer;
|
|
376
|
+
/** Assertion guard: throws if not an {@link (Integer:type)}. @public */
|
|
377
|
+
assert(value: unknown): asserts value is Integer;
|
|
378
|
+
/** Coerce a value to {@link (Integer:type)} by rounding. @public */
|
|
379
|
+
from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): Integer;
|
|
380
|
+
/** Lossless conversion to `Decimal`. @public */
|
|
381
|
+
toDecimal(value: Integer): Decimal;
|
|
382
|
+
/** Type guard: narrows {@link (Integer:type)} to {@link (PositiveInteger:type)}. @public */
|
|
383
|
+
isPositive(value: Integer): value is PositiveInteger;
|
|
384
|
+
/** Assertion guard: throws if the Integer is negative. @public */
|
|
385
|
+
assertIsPositive(value: Integer): asserts value is PositiveInteger;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Rounding directions for coercing a number to an integer.
|
|
390
|
+
*
|
|
391
|
+
* A focused subset of {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3:
|
|
392
|
+
*
|
|
393
|
+
* | Direction | Behavior | Examples (→ integer) |
|
|
394
|
+
* | -------------- | ---------------------------- | ------------------------------ |
|
|
395
|
+
* | `'ceil'` | Toward +∞ | 1.1→2, -1.1→-1 |
|
|
396
|
+
* | `'floor'` | Toward -∞ | 1.9→1, -1.1→-2 |
|
|
397
|
+
* | `'round-down'` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
|
|
398
|
+
* | `'round-up'` | Away from zero | 1.1→2, -1.1→-2 |
|
|
399
|
+
* | `'half-up'` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
|
|
400
|
+
*
|
|
401
|
+
* @public
|
|
402
|
+
*/
|
|
403
|
+
declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Represents a monetary value with amount and currency.
|
|
407
|
+
* @format monetary-amount
|
|
408
|
+
* @public
|
|
409
|
+
*/
|
|
410
|
+
declare interface MonetaryAmount {
|
|
411
|
+
/** The numerical value. */
|
|
412
|
+
amount: Decimal;
|
|
413
|
+
/** The currency code. */
|
|
414
|
+
currency: Currency;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* A branded non-negative integer — a `number` guaranteed to be an integer ≥ 0.
|
|
419
|
+
*
|
|
420
|
+
* This is a subtype of {@link (Integer:type)}: every non-negative integer is an
|
|
421
|
+
* integer, so `PositiveInteger` values are assignable to `Integer` contexts.
|
|
422
|
+
* The reverse is not true — an `Integer` cannot be assigned where a
|
|
423
|
+
* `PositiveInteger` is expected without going through the `PositiveInteger.is()`
|
|
424
|
+
* type guard or `PositiveInteger.from()` factory.
|
|
425
|
+
*
|
|
426
|
+
* @remarks
|
|
427
|
+
* Despite the name, this type includes zero (`>= 0`, not `> 0`).
|
|
428
|
+
* The schema-level constraint `@minimum 0` should be added to fields
|
|
429
|
+
* typed as `PositiveInteger` to ensure the non-negativity invariant
|
|
430
|
+
* is enforced at validation time.
|
|
431
|
+
*
|
|
432
|
+
* @public
|
|
433
|
+
*/
|
|
434
|
+
declare type PositiveInteger = {
|
|
435
|
+
readonly [__integerBrand]: true;
|
|
436
|
+
readonly [__positiveIntegerBrand]: true;
|
|
437
|
+
readonly [__stripeType]: 'int';
|
|
438
|
+
} & number;
|
|
439
|
+
|
|
440
|
+
/** Factory, type guard, and utilities for {@link (PositiveInteger:type)} branded values. @public */
|
|
441
|
+
declare const PositiveInteger: PositiveIntegerCompanion;
|
|
442
|
+
|
|
443
|
+
/** @public */
|
|
444
|
+
declare interface PositiveIntegerCompanion {
|
|
445
|
+
/** Type guard: narrows `unknown` to {@link (PositiveInteger:type)}. @public */
|
|
446
|
+
is(value: unknown): value is PositiveInteger;
|
|
447
|
+
/** Assertion guard: throws if not a {@link (PositiveInteger:type)}. @public */
|
|
448
|
+
assert(value: unknown): asserts value is PositiveInteger;
|
|
449
|
+
/** Coerce a value to {@link (PositiveInteger:type)} by rounding. Throws if negative. @public */
|
|
450
|
+
from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): PositiveInteger;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Rounding direction for Decimal operations.
|
|
455
|
+
*
|
|
456
|
+
* @remarks
|
|
457
|
+
* Seven modes corresponding to
|
|
458
|
+
* {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3
|
|
459
|
+
* rounding-direction attributes:
|
|
460
|
+
*
|
|
461
|
+
* | Direction | IEEE 754 name | Behavior | Examples (→ integer) |
|
|
462
|
+
* | -------------- | ----------------------- | --------------------------------- | ------------------------------------- |
|
|
463
|
+
* | `'ceil'` | `roundTowardPositive` | Toward +∞ | 1.1→2, -1.1→-1 |
|
|
464
|
+
* | `'floor'` | `roundTowardNegative` | Toward -∞ | 1.9→1, -1.1→-2 |
|
|
465
|
+
* | `'round-down'` | `roundTowardZero` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
|
|
466
|
+
* | `'round-up'` | — | Away from zero | 1.1→2, -1.1→-2 |
|
|
467
|
+
* | `'half-up'` | `roundTiesToAway` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
|
|
468
|
+
* | `'half-down'` | — | Nearest; ties toward zero | 0.5→0, -0.5→0, 1.6→2 |
|
|
469
|
+
* | `'half-even'` | `roundTiesToEven` | Nearest; ties to even (banker's) | 0.5→0, 1.5→2, 2.5→2, 3.5→4 |
|
|
470
|
+
*
|
|
471
|
+
* @public
|
|
472
|
+
*/
|
|
473
|
+
declare type RoundDirection = 'ceil' | 'floor' | 'half-down' | 'half-even' | 'half-up' | 'round-down' | 'round-up';
|
|
474
|
+
|
|
475
|
+
export { }
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/* Excluded from this release type: _ConfigApplicationContext */
|
|
2
|
+
|
|
3
|
+
/** @public */
|
|
4
|
+
declare interface Context {
|
|
5
|
+
type: string;
|
|
6
|
+
id: string;
|
|
7
|
+
livemode: boolean;
|
|
8
|
+
stripeContext?: string;
|
|
9
|
+
clockTime?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** @public */
|
|
13
|
+
export declare namespace InvoiceCollectionOptions {
|
|
14
|
+
/** @public */
|
|
15
|
+
export type PaymentMethodType = 'ach_credit_transfer' | 'ach_debit' | 'affirm' | 'afterpay_clearpay' | 'alipay' | 'au_becs_debit' | 'bacs_debit' | 'bancontact' | 'blik' | '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';
|
|
16
|
+
/** @public */
|
|
17
|
+
export type CollectionMethod = 'charge_automatically' | 'send_invoice';
|
|
18
|
+
/**
|
|
19
|
+
* The result of the invoice collection options override extension.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export interface InvoiceCollectionOptionsResult {
|
|
23
|
+
/** Override the auto-advancement setting. Set to false to keep the invoice in draft. */
|
|
24
|
+
autoAdvance: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** @public */
|
|
27
|
+
export type InvoiceCollectionOptionsInput = ({
|
|
28
|
+
customer: Customer;
|
|
29
|
+
payer: 'customer';
|
|
30
|
+
} | {
|
|
31
|
+
otherPayer: string;
|
|
32
|
+
payer: 'other';
|
|
33
|
+
} | { payer?: never }) & ({
|
|
34
|
+
invoiceParentType: 'other';
|
|
35
|
+
otherInvoiceParentType: string;
|
|
36
|
+
} | {
|
|
37
|
+
invoiceParentType: 'subscription';
|
|
38
|
+
subscription: SubscriptionParent;
|
|
39
|
+
} | { invoiceParentType: 'cadence' } | { invoiceParentType: 'contract' } | { invoiceParentType: 'quote' } | { invoiceParentType: 'schedule' } | { invoiceParentType?: never }) & { collectionOptions: CollectionOptions };
|
|
40
|
+
/** @public */
|
|
41
|
+
export interface Customer {
|
|
42
|
+
id: string;
|
|
43
|
+
metadata: Record<string, string>;
|
|
44
|
+
}
|
|
45
|
+
/** @public */
|
|
46
|
+
export type ContractParent = Record<string, never>;
|
|
47
|
+
/**
|
|
48
|
+
* The Subscription that triggered the invoice creation.
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export interface SubscriptionParent {
|
|
52
|
+
/** The unique identifier for the subscription. */
|
|
53
|
+
id: string;
|
|
54
|
+
/** The metadata of the subscription. */
|
|
55
|
+
metadata: Record<string, string>;
|
|
56
|
+
}
|
|
57
|
+
/** @public */
|
|
58
|
+
export type ScheduleParent = Record<string, never>;
|
|
59
|
+
/** @public */
|
|
60
|
+
export type QuoteParent = Record<string, never>;
|
|
61
|
+
/** @public */
|
|
62
|
+
export type CadenceParent = Record<string, never>;
|
|
63
|
+
/**
|
|
64
|
+
* The collection options for an invoice.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
export interface CollectionOptions {
|
|
68
|
+
/** Whether the invoice automatically advances through its lifecycle. */
|
|
69
|
+
autoAdvance: boolean;
|
|
70
|
+
/** The payment collection method: charge_automatically or send_invoice. */
|
|
71
|
+
collectionMethod: CollectionMethod;
|
|
72
|
+
/** The payment methods configured for this invoice. */
|
|
73
|
+
paymentMethods: PaymentMethodType[];
|
|
74
|
+
}
|
|
75
|
+
/* Excluded from this release type: $platformWrapOverrideOptions */
|
|
76
|
+
/**
|
|
77
|
+
* Overrides invoice collection options before a draft invoice is created.
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export type OverrideOptionsFunction<Config> = (request: InvoiceCollectionOptionsInput, config: Config, context: Context) => InvoiceCollectionOptionsResult;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
87
|
+
*
|
|
88
|
+
* // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
89
|
+
* interface MyInvoiceCollectionOptionsConfig {}
|
|
90
|
+
*
|
|
91
|
+
* export default class MyInvoiceCollectionOptions implements Billing.InvoiceCollectionOptions<MyInvoiceCollectionOptionsConfig> {
|
|
92
|
+
* overrideOptions(
|
|
93
|
+
* request: Billing.InvoiceCollectionOptions.InvoiceCollectionOptionsInput,
|
|
94
|
+
* _config: MyInvoiceCollectionOptionsConfig,
|
|
95
|
+
* _context: Context
|
|
96
|
+
* ) {
|
|
97
|
+
* // TODO: implement your collection setting logic here
|
|
98
|
+
*
|
|
99
|
+
* return { autoAdvance: request.collectionOptions.autoAdvance };
|
|
100
|
+
* }
|
|
101
|
+
* }
|
|
102
|
+
*
|
|
103
|
+
* ```
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
export declare interface InvoiceCollectionOptions<Config> {
|
|
107
|
+
overrideOptions: InvoiceCollectionOptions.OverrideOptionsFunction<Config>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { }
|