@amboras-dev/money 0.0.0-stage → 0.2.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 +401 -2
- package/dist/ai.cjs +185 -0
- package/dist/ai.d.cts +97 -0
- package/dist/ai.d.ts +97 -0
- package/dist/ai.js +175 -0
- package/dist/allocate-CZRg4TOP.cjs +222 -0
- package/dist/allocate-X7_jAtOj.js +199 -0
- package/dist/amount-BV0O-aN8.cjs +241 -0
- package/dist/amount-BoYBMgK9.js +200 -0
- package/dist/arithmetic-BhNwisjb.js +132 -0
- package/dist/arithmetic-DjT4Kzgt.cjs +233 -0
- package/dist/billing.cjs +184 -0
- package/dist/billing.d.cts +81 -0
- package/dist/billing.d.ts +81 -0
- package/dist/billing.js +175 -0
- package/dist/commerce.cjs +536 -0
- package/dist/commerce.d.cts +293 -0
- package/dist/commerce.d.ts +293 -0
- package/dist/commerce.js +516 -0
- package/dist/format-BdPnijvn.js +99 -0
- package/dist/format-DLhno7eX.cjs +128 -0
- package/dist/fx.cjs +407 -0
- package/dist/fx.d.cts +157 -0
- package/dist/fx.d.ts +157 -0
- package/dist/fx.js +374 -0
- package/dist/index.cjs +352 -0
- package/dist/index.d.cts +300 -0
- package/dist/index.d.ts +300 -0
- package/dist/index.js +276 -0
- package/dist/input.cjs +163 -0
- package/dist/input.d.cts +203 -0
- package/dist/input.d.ts +203 -0
- package/dist/input.js +153 -0
- package/dist/iso-minor-CqkWDxHS.js +48 -0
- package/dist/iso-minor-wSwJN57T.cjs +65 -0
- package/dist/medusa-4K8N1pUc.d.cts +87 -0
- package/dist/medusa-DBXJXXvF.d.ts +87 -0
- package/dist/medusa-DqJY1qpj.js +116 -0
- package/dist/medusa-lRY9xlsf.cjs +175 -0
- package/dist/money-B-3aFjNJ.d.cts +248 -0
- package/dist/money-B-3aFjNJ.d.ts +248 -0
- package/dist/money-B3wH_Z4S.cjs +3990 -0
- package/dist/money-WhnGiI00.js +3583 -0
- package/dist/number-text-BWu67jUq.cjs +145 -0
- package/dist/number-text-DE-q4jO5.js +134 -0
- package/dist/own-D7544D3k.js +4 -0
- package/dist/own-oP9DXFWv.cjs +9 -0
- package/dist/percent-C0InC2t2.cjs +43 -0
- package/dist/percent-D1VB9xXG.js +20 -0
- package/dist/rate-CVeMii4a.cjs +217 -0
- package/dist/rate-DBPiYgT1.d.ts +63 -0
- package/dist/rate-DicStBue.js +152 -0
- package/dist/rate-tqK8ijG0.d.cts +63 -0
- package/dist/reporting-CG-ai2sM.d.cts +31 -0
- package/dist/reporting-tpGJbqYp.d.ts +31 -0
- package/dist/retail-1mu888J1.js +69 -0
- package/dist/retail-C_BPLvMj.d.cts +31 -0
- package/dist/retail-Cml8YSKg.cjs +86 -0
- package/dist/retail-DRUTTQoJ.d.ts +31 -0
- package/dist/rounding-DHBtNCHG.cjs +79 -0
- package/dist/rounding-g9rvye0k.js +50 -0
- package/dist/sql.cjs +290 -0
- package/dist/sql.d.cts +147 -0
- package/dist/sql.d.ts +147 -0
- package/dist/sql.js +271 -0
- package/dist/testing.cjs +61995 -0
- package/dist/testing.d.cts +125 -0
- package/dist/testing.d.ts +125 -0
- package/dist/testing.js +61986 -0
- package/dist/wire-Bhuut8cW.cjs +2097 -0
- package/dist/wire-CaUN9Vf_.d.ts +309 -0
- package/dist/wire-sW0yzqth.js +1888 -0
- package/dist/wire-xjYXv4go.d.cts +309 -0
- package/dist/wire.cjs +37 -0
- package/dist/wire.d.cts +2 -0
- package/dist/wire.d.ts +2 -0
- package/dist/wire.js +2 -0
- package/package.json +158 -3
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { b as FractionDigits, g as CurrencyCode, i as Money, o as StoredAmount, t as FractionalMoney, z as RoundingMode } from "./money-B-3aFjNJ.js";
|
|
2
|
+
//#region src/wire/anet.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The first `"<field>": <decimal>` (quoted or not) in a raw JSON body, verbatim: `JSON.parse`
|
|
5
|
+
* would turn the gateway's `43.00` into `43`. The value is the whole JSON token, held to
|
|
6
|
+
* `parseDecimal`'s `'plain'` grammar (`1e3` or `"43.10abc"` is not a decimal literal).
|
|
7
|
+
* Undefined when absent; there is no lossy fallback.
|
|
8
|
+
*/
|
|
9
|
+
declare function jsonDecimalLiteral(rawBody: string, field: string): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* What an unsettled Authorize.Net transaction can still be reversed for: the settle amount when
|
|
12
|
+
* present and above zero (exact), else `authAmount ?? settleAmount` (settle is `'0.00'`, not
|
|
13
|
+
* absent, for voided or unsettled transactions). Undefined when both are absent.
|
|
14
|
+
*/
|
|
15
|
+
interface AuthorizeNetAmounts {
|
|
16
|
+
settleAmount?: string | null;
|
|
17
|
+
authAmount?: string | null;
|
|
18
|
+
}
|
|
19
|
+
declare function authorizeNetReversibleAmount(details: AuthorizeNetAmounts): string | undefined;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/wire/descriptors.d.ts
|
|
22
|
+
type PspId = 'stripe' | 'adyen' | 'razorpay' | 'paystack' | 'momo' | 'vnpay' | 'paypal' | 'mollie' | 'airwallex' | 'iyzico' | 'authorize-net' | 'payoo';
|
|
23
|
+
/** ISO minor units, marker-gated decode: a payment created before the cutover holds storage units at the PSP. */
|
|
24
|
+
type GatedPsp = 'stripe' | 'adyen' | 'razorpay' | 'paystack' | 'momo';
|
|
25
|
+
/** Gated PSPs whose encode is gated too; MoMo and Paystack always encode ISO minor units. */
|
|
26
|
+
type EncodeGatedPsp = 'stripe' | 'adyen' | 'razorpay';
|
|
27
|
+
type IsoMinorPsp = GatedPsp | 'vnpay';
|
|
28
|
+
type MajorStringPsp = 'paypal' | 'mollie' | 'iyzico' | 'authorize-net';
|
|
29
|
+
type MajorNumberPsp = 'airwallex' | 'payoo';
|
|
30
|
+
/** What a PSP receives: major-unit text for PayPal, Mollie, iyzico and Authorize.Net, a number for the rest. */
|
|
31
|
+
type WireAmount<P extends PspId> = P extends MajorStringPsp ? string : number;
|
|
32
|
+
/** Every PSP id, in a stable order. */
|
|
33
|
+
declare const PSP_IDS: readonly PspId[];
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/wire/marker.d.ts
|
|
36
|
+
declare const WIRE_SCALE_KEY = "amboras_wire_scale";
|
|
37
|
+
declare const WIRE_SCALE_ISO_MINOR_V2 = "iso-minor-v2";
|
|
38
|
+
declare const WIRE_SCALE_MARKER: Readonly<{
|
|
39
|
+
amboras_wire_scale: 'iso-minor-v2';
|
|
40
|
+
}>;
|
|
41
|
+
/** Which convention a payment was created under. Use the two singletons; build one with `conventionOf`. */
|
|
42
|
+
type Convention = {
|
|
43
|
+
readonly kind: 'iso-minor-v2';
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: 'pre-cutover';
|
|
46
|
+
};
|
|
47
|
+
declare const ISO_MINOR_V2: Convention;
|
|
48
|
+
declare const PRE_CUTOVER: Convention;
|
|
49
|
+
/**
|
|
50
|
+
* `ISO_MINOR_V2` iff ANY record is a non-null object whose `amboras_wire_scale` is strictly
|
|
51
|
+
* `'iso-minor-v2'` (a Stripe charge OR its PaymentIntent); else `PRE_CUTOVER`. Reads already
|
|
52
|
+
* fetched records only: it never queries (FORCE RLS would hide the row and the marker with it).
|
|
53
|
+
*/
|
|
54
|
+
declare function conventionOf(...records: unknown[]): Convention;
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/wire/breakdown.d.ts
|
|
57
|
+
/**
|
|
58
|
+
* `total` and its `parts` (same currency, non-negative, adding up to `total`) as integer wire
|
|
59
|
+
* amounts whose sum is exactly `encodeWire(psp, total)`: the wire total split by largest
|
|
60
|
+
* remainder over the stored parts. Throws `currency_mismatch`, `amount_invalid` (parts that do not
|
|
61
|
+
* add up, or a negative part) or whatever `encodeWire` refuses.
|
|
62
|
+
*/
|
|
63
|
+
declare function wireBreakdown(psp: IsoMinorPsp, total: Money, parts: Readonly<Record<string, Money>>, convention: Convention): {
|
|
64
|
+
total: number;
|
|
65
|
+
parts: Record<string, number>;
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/wire/codec.d.ts
|
|
69
|
+
/** Whether `psp` takes `currency` (any case, historic codes included). Never throws for a bad code. */
|
|
70
|
+
declare function pspSupportsCurrency(psp: PspId, currency: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Every currency `psp` takes. Provider-only codes a PSP table lists (Adyen offshore CNH) are left
|
|
73
|
+
* out: they are not ISO 4217 currencies, no store sells in them and no Money can carry them.
|
|
74
|
+
*/
|
|
75
|
+
declare function pspCurrencies(psp: PspId): ReadonlySet<CurrencyCode>;
|
|
76
|
+
/**
|
|
77
|
+
* `currency` as a CurrencyCode `psp` takes. Empty throws `currency_missing` (`[<Tag>] Cannot
|
|
78
|
+
* scale an amount without a currency code; ...`); anything the PSP does not take throws
|
|
79
|
+
* `wire_unsupported` with the provider's own message.
|
|
80
|
+
*/
|
|
81
|
+
declare function assertPspCurrency(psp: PspId, currency: unknown): CurrencyCode;
|
|
82
|
+
/** `'VND'` for the single-currency providers (MoMo, Payoo, VNPay), else null. */
|
|
83
|
+
declare function pspDefaultCurrency(psp: PspId): CurrencyCode | null;
|
|
84
|
+
/**
|
|
85
|
+
* Stored units per wire unit for an ISO-minor PSP: the PSP's override (Stripe ISK/UGX, Adyen
|
|
86
|
+
* ISK/CLP, Razorpay MGA, Paystack XOF, VNPay VND give 1; Adyen IDR/CVE give 100), else
|
|
87
|
+
* `storageScale / 10^storageDigits` (100 for a zero-decimal currency, else 1).
|
|
88
|
+
*/
|
|
89
|
+
declare function wireFactor(psp: IsoMinorPsp, currency: string): 1 | 100;
|
|
90
|
+
/**
|
|
91
|
+
* Fraction digits of `psp`'s wire amount: its digit table, else (ISO-minor PSPs) the digits
|
|
92
|
+
* its factor implies, else (iyzico, Authorize.Net, Payoo) the display digits. Null when the
|
|
93
|
+
* PSP does not take the currency.
|
|
94
|
+
*/
|
|
95
|
+
declare function pspWireDigits(psp: PspId, currency: string): FractionDigits | null;
|
|
96
|
+
/** The PSP's minimum charge in `currency` (Paystack USD 2.00), or null when it has none. */
|
|
97
|
+
declare function pspMinimumAmount(psp: PspId, currency: string): Money | null;
|
|
98
|
+
interface EncodeWireOptions {
|
|
99
|
+
/** Names the amount in refusals: `[<Tag>] Invalid <label>: <amount>`. Default `'amount'`; refunds pass `'refund amount'`. */
|
|
100
|
+
label?: string;
|
|
101
|
+
/** Allow a zero amount (verification, comparisons). Negative amounts are always refused. */
|
|
102
|
+
allowZero?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A stored amount as `psp` receives it. `m` is a Money or a FractionalMoney (Medusa's unrounded
|
|
106
|
+
* session totals, 107.8175). In order: the currency must pass the PSP's Medusa amount facade
|
|
107
|
+
* (`wire_unsupported` with the facade's message: Razorpay only its exponent table, Paystack no
|
|
108
|
+
* zero-decimal code but XOF, MoMo, Payoo and VNPay only VND; every other PSP scales any currency,
|
|
109
|
+
* so call `assertPspCurrency` for eligibility); the amount must be positive (`wire_refused`
|
|
110
|
+
* `[<Tag>] Invalid <label>: <amount>`, zero allowed with `allowZero`); Stripe and Adyen round a
|
|
111
|
+
* fractional amount half-up to a whole storage unit first; Stripe, Adyen and Razorpay on a
|
|
112
|
+
* pre-cutover payment send the stored integer as is (Razorpay refuses unless its factor is 1, and
|
|
113
|
+
* refuses a fractional amount, which has no stored integer; MoMo and Paystack encode ignore the
|
|
114
|
+
* convention, as today); the whole-unit rules refuse fractions of a dong (MoMo, Payoo, VNPay) or a
|
|
115
|
+
* franc (Paystack XOF), naming the amount as held; then, rounding once and exactly, ISO minor
|
|
116
|
+
* `half-up(S / wireFactor)` (Razorpay three-decimal floored to steps of 10), or major units at the
|
|
117
|
+
* PSP's wire digits, half-up, as fixed-point text (a number for Airwallex and Payoo). A positive
|
|
118
|
+
* amount whose wire rounds to zero is refused (`wire_refused`), with `allowZero` too.
|
|
119
|
+
* This is package policy, safer than Medusa today: Medusa puts 0 on the wire at initiate for
|
|
120
|
+
* Stripe and Adyen, and for Razorpay, PayPal and Airwallex everywhere; it refuses at refund and
|
|
121
|
+
* capture for Stripe and Adyen, and in Mollie, iyzico and Authorize.Net; Razorpay and Paystack
|
|
122
|
+
* read a zero refund as a full one. Otherwise byte-identical to Medusa's codecs for every Money.
|
|
123
|
+
*/
|
|
124
|
+
declare function encodeWire<P extends EncodeGatedPsp>(psp: P, m: Money | FractionalMoney, options: EncodeWireOptions & {
|
|
125
|
+
convention: Convention;
|
|
126
|
+
}): WireAmount<P>;
|
|
127
|
+
declare function encodeWire<P extends Exclude<PspId, EncodeGatedPsp>>(psp: P, m: Money | FractionalMoney, options?: EncodeWireOptions): WireAmount<P>;
|
|
128
|
+
/**
|
|
129
|
+
* A PSP wire amount as Money: ISO minor `half-up(w x wireFactor)` (pre-cutover: `half-up(w)`, the
|
|
130
|
+
* PSP already held storage units), major `half-up(w x storageScale)`. `wire` is a finite number
|
|
131
|
+
* or strict decimal text (`/^-?\d+(\.\d+)?$/`: no `''`, exponent or hex), else `amount_invalid`.
|
|
132
|
+
* Signed, except VNPay, where anything but a positive whole number is no amount (`amount_invalid`).
|
|
133
|
+
* The currency is required (`currency_missing`), must be known (`currency_invalid`), must not be
|
|
134
|
+
* provider-only (Adyen CNH: `wire_unsupported`), and must pass the PSP's Medusa inbound gate
|
|
135
|
+
* (`wire_unsupported` with its message: Razorpay only its exponent table, Paystack no
|
|
136
|
+
* zero-decimal code but XOF, MoMo, Payoo and VNPay only VND). Other PSPs read any currency (a PSP
|
|
137
|
+
* may report a settlement currency).
|
|
138
|
+
*/
|
|
139
|
+
declare function decodeWire<P extends GatedPsp>(psp: P, wire: unknown, currency: string, convention: Convention): Money;
|
|
140
|
+
declare function decodeWire<P extends Exclude<PspId, GatedPsp>>(psp: P, wire: unknown, currency: string): Money;
|
|
141
|
+
interface TryDecodeWireOptions {
|
|
142
|
+
/** Required for gated PSPs (Stripe, Adyen, Razorpay, Paystack, MoMo): without it the result is undefined. */
|
|
143
|
+
convention?: Convention;
|
|
144
|
+
/** Accept a negative wire amount (balance transactions, reversals). Default false; never for VNPay. */
|
|
145
|
+
allowNegative?: boolean;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* `decodeWire` that never throws: undefined wherever it would throw (null, undefined, `''`,
|
|
149
|
+
* whitespace, unparseable or unsafe input, a missing, unknown or provider-only currency, one the
|
|
150
|
+
* PSP's inbound gate refuses, VNPay's "no amount", an unknown PSP, a gated PSP without
|
|
151
|
+
* `convention`: no hidden default) and for a negative amount unless `allowNegative`.
|
|
152
|
+
*/
|
|
153
|
+
declare function tryDecodeWire(psp: PspId, wire: unknown, currency: unknown, options?: TryDecodeWireOptions): Money | undefined;
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/wire/compare.d.ts
|
|
156
|
+
interface SameWireAmountOptions {
|
|
157
|
+
/** Required for gated PSPs (Stripe, Adyen, Razorpay, Paystack, MoMo); without it the answer is false. */
|
|
158
|
+
convention?: Convention;
|
|
159
|
+
/**
|
|
160
|
+
* Also accept the ISO-digit spelling held by a session created before the PSP digit tables
|
|
161
|
+
* (PayPal, Mollie, Airwallex HUF/TWD...): the expected amount in major units at its display
|
|
162
|
+
* digits, half-up (HUF 44.50 went as `'45'`). Major-unit PSPs only.
|
|
163
|
+
*/
|
|
164
|
+
acceptLegacyIsoDigits?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* The PSP only ever reports decimal text (Mollie, PayPal): a reported (or `requested`) value
|
|
167
|
+
* that is not a string is not its amount, whatever number it holds.
|
|
168
|
+
*/
|
|
169
|
+
textOnly?: boolean;
|
|
170
|
+
/** When given, it must be the same currency as `expected` (any case). */
|
|
171
|
+
reportedCurrency?: unknown;
|
|
172
|
+
/** Paystack fee pass-through: the amount the buyer was asked for. */
|
|
173
|
+
requested?: unknown;
|
|
174
|
+
/**
|
|
175
|
+
* `'exact'` (default), or `'requested-exact-collected-covers'`: `requested` is exactly the
|
|
176
|
+
* expected amount and the collected `reported` covers it.
|
|
177
|
+
*/
|
|
178
|
+
policy?: 'exact' | 'requested-exact-collected-covers';
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Whether a PSP-reported amount is `expected`, a Money or a FractionalMoney (Medusa's unrounded
|
|
182
|
+
* session total). The expected wire is `encodeWire(psp, expected, { convention, allowZero: true })`
|
|
183
|
+
* (a refusal means false); the reported one must decode exactly (strict like `tryDecodeWire`:
|
|
184
|
+
* never `''` or an exponent, no negatives, and never a fraction of a storage unit) to the same
|
|
185
|
+
* stored amount, so `'44.00'` matches a sent `'44'` and Airwallex `43.004` does not match `43`.
|
|
186
|
+
* Never throws.
|
|
187
|
+
*/
|
|
188
|
+
declare function sameWireAmount(psp: PspId, reported: unknown, expected: Money | FractionalMoney, options?: SameWireAmountOptions): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* One unit of the PSP's last wire digit, as Money: for ISO-minor PSPs `decodeWire(psp, 1)` (the
|
|
191
|
+
* factor on an iso-minor-v2 payment, 1 storage unit on a pre-cutover one; gated PSPs need the
|
|
192
|
+
* convention), for major PSPs `10^-wireDigits` major. The tolerance for `excessOver`.
|
|
193
|
+
*/
|
|
194
|
+
declare function oneWireUnit(psp: PspId, currency: string, convention?: Convention): Money;
|
|
195
|
+
/** The wire amount as it goes into Redis skip keys and idempotency keys: `String(wire)`, byte for byte. */
|
|
196
|
+
declare function wireKeyPart(wire: number | string): string;
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region src/data/destinations.d.ts
|
|
199
|
+
type DestinationId = 'meta' | 'ga4' | 'google-ads' | 'tiktok' | 'snapchat' | 'pinterest' | 'klaviyo' | 'omnisend' | 'omnisend-viewed-product' | 'mailchimp' | 'goaffpro' | 'profitmetrics' | 'pixi' | 'flow' | 'sendcloud' | 'shipstation' | 'shiprocket' | 'shipbob' | 'printful' | 'ahamove' | 'amazon-mcf' | 'skydropx' | 'royal-mail' | 'sevdesk' | 'shopify-ajax';
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/wire/destinations.d.ts
|
|
202
|
+
interface DestinationValue {
|
|
203
|
+
readonly value: number | string;
|
|
204
|
+
readonly currency: string;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* `m` as `dest` wants it: major units at the display digits (half-up) as a number or text per
|
|
208
|
+
* destination (`as` overrides), or integer "cents" for Shopify AJAX and Omnisend `viewed product`;
|
|
209
|
+
* the currency upper- or lower-case per destination. Undefined when the destination must not get
|
|
210
|
+
* this amount (Meta: not positive; GA4, Google Ads, TikTok, Snapchat, Pinterest and marketing:
|
|
211
|
+
* negative). Throws `wire_unsupported` for a currency the destination's unit is not defined for.
|
|
212
|
+
*/
|
|
213
|
+
declare function destinationAmount(dest: DestinationId, m: Money, options?: {
|
|
214
|
+
as?: 'number' | 'string';
|
|
215
|
+
}): DestinationValue | undefined;
|
|
216
|
+
/** A shopping-feed price: `'12.345 KWD'`, `'1200 JPY'`, `'19.99 USD'` (display digits, half-up). */
|
|
217
|
+
declare function feedPrice(m: Money): string;
|
|
218
|
+
/** Google micros (major x 10^6) as integer text, exactly: USD 1999 gives `'19990000'`. */
|
|
219
|
+
declare function googleMicros(m: Money): string;
|
|
220
|
+
interface EventMoney {
|
|
221
|
+
readonly value: number;
|
|
222
|
+
readonly currency: string;
|
|
223
|
+
}
|
|
224
|
+
/** First-party analytics money: the stored integer and the lower-case code (the ClickHouse `Int64` contract). */
|
|
225
|
+
declare function eventMoney(m: Money): EventMoney;
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region src/wire/presentment.d.ts
|
|
228
|
+
interface PspPresentment {
|
|
229
|
+
/** Every currency some account of the PSP can present: the union over account countries. */
|
|
230
|
+
readonly currencies: ReadonlySet<CurrencyCode>;
|
|
231
|
+
/** Currencies only accounts registered in these countries can present (Stripe KWD: AE; PayPal BRL: BR). */
|
|
232
|
+
readonly currencyRequiresAccountCountry: ReadonlyMap<CurrencyCode, ReadonlySet<string>>;
|
|
233
|
+
/** Account countries limited to these currencies (Airwallex cards on a US or MX account). */
|
|
234
|
+
readonly accountCountryAllowsOnly: ReadonlyMap<string, ReadonlySet<CurrencyCode>>;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The PSP's presentment rules, as data: the union of currencies some account can charge, the
|
|
238
|
+
* currencies that need an account in particular countries, and the account countries limited to
|
|
239
|
+
* a list. For capability declarations that hold the rules themselves; `pspPresentmentCurrencies`
|
|
240
|
+
* applies them to one account. Fresh collections on every call. An unknown PSP throws
|
|
241
|
+
* `wire_unsupported`.
|
|
242
|
+
*/
|
|
243
|
+
declare function pspPresentment(psp: PspId): PspPresentment;
|
|
244
|
+
/**
|
|
245
|
+
* The currencies `psp` lets an account present (charge buyers in). Without `accountCountry`, the
|
|
246
|
+
* union over every account country; with it (ISO 3166 alpha-2, any case), only what an account
|
|
247
|
+
* registered there can charge: Stripe's three-decimal five need a UAE account, PayPal's BRL, CNY
|
|
248
|
+
* and MYR an in-country one, Airwallex cards on a US account take its documented 76 and on an MX
|
|
249
|
+
* account MXN only. Not `pspCurrencies`, which is what the codec scales and the facade lets
|
|
250
|
+
* through (Stripe's adds every two-decimal ISO code it accepts on the wire).
|
|
251
|
+
*/
|
|
252
|
+
declare function pspPresentmentCurrencies(psp: PspId, options?: {
|
|
253
|
+
accountCountry?: string;
|
|
254
|
+
}): ReadonlySet<CurrencyCode>;
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/wire/provider-amount.d.ts
|
|
257
|
+
interface ProviderAmountOptions {
|
|
258
|
+
/** Accept a negative amount (refunds, credits). Default false. */
|
|
259
|
+
allowNegative?: boolean;
|
|
260
|
+
/** Default `'.'`; `'auto'` decides from the text (see the core separator engine). */
|
|
261
|
+
decimalSeparator?: '.' | ',' | 'auto';
|
|
262
|
+
/** Read the first number and ignore the rest (`'22.67 + KDV'`). Default false. */
|
|
263
|
+
allowTrailingText?: boolean;
|
|
264
|
+
/** Rounding to the currency's storage digits (and the 'auto' whole-unit rounding). Default `'half-up'`. */
|
|
265
|
+
rounding?: RoundingMode;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* A provider's major-unit amount (finite number, or text read by the separator engine, which
|
|
269
|
+
* strips the currency's symbol and code) as Money, rounded once to the storage digits. Null on
|
|
270
|
+
* anything invalid (empty, unparseable, non-finite, negative without `allowNegative`, too large,
|
|
271
|
+
* unknown currency), never 0.
|
|
272
|
+
*/
|
|
273
|
+
declare function parseProviderAmount(value: unknown, currency: string, options?: ProviderAmountOptions): Money | null;
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/wire/providers.d.ts
|
|
276
|
+
/** RBI e-mandate cap Razorpay token registrations carry as `max_amount`: INR 15,000 (1,500,000 paise = stored). */
|
|
277
|
+
declare const RAZORPAY_AFA_FREE_CAP: Money;
|
|
278
|
+
/**
|
|
279
|
+
* The symbolic charge a saved-card setup makes: Paystack one major unit, Razorpay one INR (any
|
|
280
|
+
* other currency is `wire_unsupported`), Mollie one smallest wire unit (`'0.01'`, `'1'` for ISK
|
|
281
|
+
* and JPY), Adyen zero. Vault charges are always new, so the iso-minor-v2 convention applies.
|
|
282
|
+
*/
|
|
283
|
+
declare function verificationCharge(psp: 'paystack' | 'razorpay' | 'mollie' | 'adyen', currency: string): {
|
|
284
|
+
wire: number | string;
|
|
285
|
+
money: Money;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* iyzico's price spelling, on the text (no float): canonical decimal (no trailing fraction zeros),
|
|
289
|
+
* then `'.0'` when there is no `.` (`'10.50'` gives `'10.5'`, `'10.00'` gives `'10.0'`). Text that
|
|
290
|
+
* is not a plain decimal throws `parse`.
|
|
291
|
+
*/
|
|
292
|
+
declare function iyzicoPrice(wire: string): string;
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region src/wire/slot.d.ts
|
|
295
|
+
interface SlotMoney {
|
|
296
|
+
readonly amount: StoredAmount;
|
|
297
|
+
/** Lower-case, as Medusa spells it. */
|
|
298
|
+
readonly currency_code: string;
|
|
299
|
+
}
|
|
300
|
+
/** `m` for a slot context's `money` key. */
|
|
301
|
+
declare function slotMoney(m: Money): SlotMoney;
|
|
302
|
+
/**
|
|
303
|
+
* The money a slot context carries: `context.money` when it is valid, else the legacy
|
|
304
|
+
* `total ?? price` with the first known of `currency_code`, `currency`, read leniently (numbers, numeric text,
|
|
305
|
+
* Medusa BigNumber shapes). Undefined when the amount or the currency is missing or unreadable.
|
|
306
|
+
*/
|
|
307
|
+
declare function readSlotMoney(context: unknown): SlotMoney | undefined;
|
|
308
|
+
//#endregion
|
|
309
|
+
export { jsonDecimalLiteral as $, pspMinimumAmount as A, WIRE_SCALE_KEY as B, EncodeWireOptions as C, encodeWire as D, decodeWire as E, wireBreakdown as F, IsoMinorPsp as G, conventionOf as H, Convention as I, PSP_IDS as J, MajorNumberPsp as K, ISO_MINOR_V2 as L, pspWireDigits as M, tryDecodeWire as N, pspCurrencies as O, wireFactor as P, authorizeNetReversibleAmount as Q, PRE_CUTOVER as R, wireKeyPart as S, assertPspCurrency as T, EncodeGatedPsp as U, WIRE_SCALE_MARKER as V, GatedPsp as W, WireAmount as X, PspId as Y, AuthorizeNetAmounts as Z, googleMicros as _, iyzicoPrice as a, oneWireUnit as b, parseProviderAmount as c, pspPresentmentCurrencies as d, DestinationValue as f, feedPrice as g, eventMoney as h, RAZORPAY_AFA_FREE_CAP as i, pspSupportsCurrency as j, pspDefaultCurrency as k, PspPresentment as l, destinationAmount as m, readSlotMoney as n, verificationCharge as o, EventMoney as p, MajorStringPsp as q, slotMoney as r, ProviderAmountOptions as s, SlotMoney as t, pspPresentment as u, DestinationId as v, TryDecodeWireOptions as w, sameWireAmount as x, SameWireAmountOptions as y, WIRE_SCALE_ISO_MINOR_V2 as z };
|