@amboras-dev/money 0.1.0 → 0.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 +25 -10
- package/dist/ai.cjs +12 -13
- package/dist/ai.d.cts +5 -9
- package/dist/ai.d.ts +5 -9
- package/dist/ai.js +12 -13
- package/dist/{allocate-D7tm_t_o.cjs → allocate-AusholrC.cjs} +3 -4
- package/dist/{allocate-CdnhvAda.js → allocate-BBRfdaSC.js} +3 -4
- package/dist/{amount-DHtvZSSm.cjs → amount-CwFzcxUl.cjs} +29 -12
- package/dist/{amount-D7dj76nH.js → amount-DHFOK2Yd.js} +29 -12
- package/dist/{arithmetic-C-Q_aI49.js → arithmetic-C97-YafD.js} +4 -5
- package/dist/{arithmetic-Bq-8mSal.cjs → arithmetic-D8A6IeZ0.cjs} +4 -5
- package/dist/billing.cjs +5 -8
- package/dist/billing.d.cts +1 -9
- package/dist/billing.d.ts +1 -9
- package/dist/billing.js +5 -8
- package/dist/commerce.cjs +15 -23
- package/dist/commerce.d.cts +2 -16
- package/dist/commerce.d.ts +2 -16
- package/dist/commerce.js +15 -23
- package/dist/{format-BnA1aLJk.cjs → format-92fzvTXY.cjs} +21 -6
- package/dist/{format-BdB7LEIp.js → format-BJC513u4.js} +16 -7
- package/dist/fx.cjs +12 -18
- package/dist/fx.d.cts +5 -15
- package/dist/fx.d.ts +5 -15
- package/dist/fx.js +12 -18
- package/dist/index.cjs +13 -12
- package/dist/index.d.cts +28 -22
- package/dist/index.d.ts +28 -22
- package/dist/index.js +11 -13
- package/dist/input.cjs +7 -10
- package/dist/input.d.cts +9 -16
- package/dist/input.d.ts +9 -16
- package/dist/input.js +7 -10
- package/dist/{iso-minor--gQWI1f2.cjs → iso-minor-DyNjT9A1.cjs} +2 -3
- package/dist/{iso-minor-CtaiIifs.js → iso-minor-odkY-e6I.js} +2 -3
- package/dist/{medusa-OJ2TJOxt.cjs → medusa-CzVK0bth.cjs} +24 -4
- package/dist/{medusa-DuQ3-KoD.d.cts → medusa-DofdvIgQ.d.cts} +11 -4
- package/dist/{medusa-RwqxaDGq.d.ts → medusa-DrbYmD2Y.d.ts} +11 -4
- package/dist/{medusa-CmxCni-G.js → medusa-pKGlImn9.js} +19 -5
- package/dist/{money-CbhsT0fB.d.cts → money-BkMeYDEW.d.cts} +19 -9
- package/dist/{money-CbhsT0fB.d.ts → money-BkMeYDEW.d.ts} +19 -9
- package/dist/{money-CIgELekG.js → money-BxbAw7BP.js} +25 -21
- package/dist/{money-D5-vlv0h.cjs → money-DWBjuuEK.cjs} +42 -20
- package/dist/{number-text-C82oh6JB.js → number-text-Bj-gZXiF.js} +3 -4
- package/dist/{number-text-BpvN6NAo.cjs → number-text-CWuVwrlg.cjs} +3 -4
- package/dist/{own-oP9DXFWv.cjs → own-C5imDkyB.cjs} +1 -2
- package/dist/{own-D7544D3k.js → own-DHxqIYqL.js} +1 -2
- package/dist/{percent-CKVI_c-m.js → percent-CB3Ixjc_.js} +2 -3
- package/dist/{percent-Dt8vNIAW.cjs → percent-DABHiSBs.cjs} +2 -3
- package/dist/{rate-CmeTGNex.d.ts → rate-BvvZUdSu.d.ts} +1 -3
- package/dist/{rate-toyS3EMf.d.cts → rate-CEakW3ia.d.cts} +1 -3
- package/dist/{rate-DGPfB_jc.cjs → rate-CEjWTATc.cjs} +3 -4
- package/dist/{rate-lLPViBuM.js → rate-D6S2_wgZ.js} +3 -4
- package/dist/{reporting-5xby-Zas.d.ts → reporting-DFNyDBdi.d.cts} +2 -4
- package/dist/{reporting-DEM97DhQ.d.cts → reporting-jIBILvnr.d.ts} +2 -4
- package/dist/{retail-BwcFJcVN.d.ts → retail-B04CjW3b.d.ts} +1 -3
- package/dist/{retail-DTk2XAMM.cjs → retail-CYGPU4ea.cjs} +4 -5
- package/dist/{retail-Mqd-sPMF.d.cts → retail-CmEyJQOH.d.cts} +1 -3
- package/dist/{retail-BsvpNv1F.js → retail-DXgs11ov.js} +4 -5
- package/dist/{rounding-oZ832yTD.cjs → rounding-4QKTRbMQ.cjs} +2 -3
- package/dist/{rounding-CVAPEfq_.js → rounding-CA1PVP3b.js} +2 -3
- package/dist/sql.cjs +9 -15
- package/dist/sql.d.cts +2 -12
- package/dist/sql.d.ts +2 -12
- package/dist/sql.js +9 -15
- package/dist/testing.cjs +72675 -12
- package/dist/testing.d.cts +46 -11
- package/dist/testing.d.ts +46 -11
- package/dist/testing.js +72674 -13
- package/dist/{wire-CI3Sm1iC.js → wire-B4QU8O3W.js} +584 -114
- package/dist/wire-CVNicirK.d.ts +428 -0
- package/dist/wire-CtNJmWVP.d.cts +428 -0
- package/dist/{wire-DQZ6fA3c.cjs → wire-u2tmHY0Y.cjs} +649 -113
- package/dist/wire.cjs +12 -1
- package/dist/wire.d.cts +2 -2
- package/dist/wire.d.ts +2 -2
- package/dist/wire.js +1 -2
- package/package.json +4 -3
- package/dist/wire-Cd4Q1Jmm.d.ts +0 -269
- package/dist/wire-hWuixv3w.d.cts +0 -269
package/dist/wire-hWuixv3w.d.cts
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
import { R as RoundingMode, a as StoredAmount, h as CurrencyCode, r as Money, y as FractionDigits } from "./money-CbhsT0fB.cjs";
|
|
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. In order: the currency must pass the PSP's Medusa amount
|
|
106
|
-
* facade (`wire_unsupported` with the facade's message: Razorpay only its exponent table, Paystack
|
|
107
|
-
* no zero-decimal code but XOF, MoMo, Payoo and VNPay only VND; every other PSP scales any
|
|
108
|
-
* currency, so call `assertPspCurrency` for eligibility); the amount must be positive
|
|
109
|
-
* (`wire_refused` `[<Tag>] Invalid <label>: <amount>`, zero allowed with `allowZero`); Stripe,
|
|
110
|
-
* Adyen and Razorpay on a pre-cutover payment send the stored integer as is (Razorpay refuses
|
|
111
|
-
* unless its factor is 1; MoMo and Paystack encode ignore the convention, as today); the
|
|
112
|
-
* whole-unit rules refuse fractions of a dong (MoMo, Payoo, VNPay) or a franc (Paystack XOF);
|
|
113
|
-
* then ISO minor `half-up(S / wireFactor)` (Razorpay three-decimal floored to steps of 10), or
|
|
114
|
-
* major units exactly at the PSP's wire digits, half-up, as fixed-point text (a number for
|
|
115
|
-
* Airwallex and Payoo). A positive amount whose wire rounds to zero is refused (`wire_refused`).
|
|
116
|
-
* This is package policy, safer than Medusa today: Medusa puts 0 on the wire at initiate for
|
|
117
|
-
* Stripe and Adyen, and for Razorpay, PayPal and Airwallex everywhere; it refuses at refund and
|
|
118
|
-
* capture for Stripe and Adyen, and in Mollie, iyzico and Authorize.Net; Razorpay and Paystack
|
|
119
|
-
* read a zero refund as a full one. Otherwise byte-identical to Medusa's codecs for every Money.
|
|
120
|
-
*/
|
|
121
|
-
declare function encodeWire<P extends EncodeGatedPsp>(psp: P, m: Money, options: EncodeWireOptions & {
|
|
122
|
-
convention: Convention;
|
|
123
|
-
}): WireAmount<P>;
|
|
124
|
-
declare function encodeWire<P extends Exclude<PspId, EncodeGatedPsp>>(psp: P, m: Money, options?: EncodeWireOptions): WireAmount<P>;
|
|
125
|
-
/**
|
|
126
|
-
* A PSP wire amount as Money: ISO minor `half-up(w x wireFactor)` (pre-cutover: `half-up(w)`, the
|
|
127
|
-
* PSP already held storage units), major `half-up(w x storageScale)`. `wire` is a finite number
|
|
128
|
-
* or strict decimal text (`/^-?\d+(\.\d+)?$/`: no `''`, exponent or hex), else `amount_invalid`.
|
|
129
|
-
* Signed, except VNPay, where anything but a positive whole number is no amount (`amount_invalid`).
|
|
130
|
-
* The currency is required (`currency_missing`), must be known (`currency_invalid`), must not be
|
|
131
|
-
* provider-only (Adyen CNH: `wire_unsupported`), and must pass the PSP's Medusa inbound gate
|
|
132
|
-
* (`wire_unsupported` with its message: Razorpay only its exponent table, Paystack no
|
|
133
|
-
* zero-decimal code but XOF, MoMo, Payoo and VNPay only VND). Other PSPs read any currency (a PSP
|
|
134
|
-
* may report a settlement currency).
|
|
135
|
-
*/
|
|
136
|
-
declare function decodeWire<P extends GatedPsp>(psp: P, wire: unknown, currency: string, convention: Convention): Money;
|
|
137
|
-
declare function decodeWire<P extends Exclude<PspId, GatedPsp>>(psp: P, wire: unknown, currency: string): Money;
|
|
138
|
-
interface TryDecodeWireOptions {
|
|
139
|
-
/** Required for gated PSPs (Stripe, Adyen, Razorpay, Paystack, MoMo): without it the result is undefined. */
|
|
140
|
-
convention?: Convention;
|
|
141
|
-
/** Accept a negative wire amount (balance transactions, reversals). Default false; never for VNPay. */
|
|
142
|
-
allowNegative?: boolean;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* `decodeWire` that never throws: undefined wherever it would throw (null, undefined, `''`,
|
|
146
|
-
* whitespace, unparseable or unsafe input, a missing, unknown or provider-only currency, one the
|
|
147
|
-
* PSP's inbound gate refuses, VNPay's "no amount", an unknown PSP, a gated PSP without
|
|
148
|
-
* `convention`: no hidden default) and for a negative amount unless `allowNegative`.
|
|
149
|
-
*/
|
|
150
|
-
declare function tryDecodeWire(psp: PspId, wire: unknown, currency: unknown, options?: TryDecodeWireOptions): Money | undefined;
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region src/wire/compare.d.ts
|
|
153
|
-
interface SameWireAmountOptions {
|
|
154
|
-
/** Required for gated PSPs (Stripe, Adyen, Razorpay, Paystack, MoMo); without it the answer is false. */
|
|
155
|
-
convention?: Convention;
|
|
156
|
-
/**
|
|
157
|
-
* Also accept the ISO-digit spelling held by a session created before the PSP digit tables
|
|
158
|
-
* (PayPal, Mollie, Airwallex HUF/TWD...).
|
|
159
|
-
*/
|
|
160
|
-
acceptLegacyIsoDigits?: boolean;
|
|
161
|
-
/** When given, it must be the same currency as `expected` (any case). */
|
|
162
|
-
reportedCurrency?: unknown;
|
|
163
|
-
/** Paystack fee pass-through: the amount the buyer was asked for. */
|
|
164
|
-
requested?: unknown;
|
|
165
|
-
/**
|
|
166
|
-
* `'exact'` (default), or `'requested-exact-collected-covers'`: `requested` is exactly the
|
|
167
|
-
* expected amount and the collected `reported` covers it.
|
|
168
|
-
*/
|
|
169
|
-
policy?: 'exact' | 'requested-exact-collected-covers';
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Whether a PSP-reported amount is `expected`. The expected wire is `encodeWire(psp, expected,
|
|
173
|
-
* { convention, allowZero: true })` (a refusal means false); the reported one must decode
|
|
174
|
-
* (`tryDecodeWire`: strict, never `''` or an exponent, no negatives) to the same stored amount,
|
|
175
|
-
* so `'44.00'` matches a sent `'44'`. Never throws.
|
|
176
|
-
*/
|
|
177
|
-
declare function sameWireAmount(psp: PspId, reported: unknown, expected: Money, options?: SameWireAmountOptions): boolean;
|
|
178
|
-
/**
|
|
179
|
-
* One unit of the PSP's last wire digit, as Money: for ISO-minor PSPs `decodeWire(psp, 1)` (the
|
|
180
|
-
* factor on an iso-minor-v2 payment, 1 storage unit on a pre-cutover one; gated PSPs need the
|
|
181
|
-
* convention), for major PSPs `10^-wireDigits` major. The tolerance for `excessOver`.
|
|
182
|
-
*/
|
|
183
|
-
declare function oneWireUnit(psp: PspId, currency: string, convention?: Convention): Money;
|
|
184
|
-
/** The wire amount as it goes into Redis skip keys and idempotency keys: `String(wire)`, byte for byte. */
|
|
185
|
-
declare function wireKeyPart(wire: number | string): string;
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/data/destinations.d.ts
|
|
188
|
-
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';
|
|
189
|
-
//#endregion
|
|
190
|
-
//#region src/wire/destinations.d.ts
|
|
191
|
-
interface DestinationValue {
|
|
192
|
-
readonly value: number | string;
|
|
193
|
-
readonly currency: string;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* `m` as `dest` wants it: major units at the display digits (half-up) as a number or text per
|
|
197
|
-
* destination (`as` overrides), or integer "cents" for Shopify AJAX and Omnisend `viewed product`;
|
|
198
|
-
* the currency upper- or lower-case per destination. Undefined when the destination must not get
|
|
199
|
-
* this amount (Meta: not positive; GA4, Google Ads, TikTok, Snapchat, Pinterest and marketing:
|
|
200
|
-
* negative). Throws `wire_unsupported` for a currency the destination's unit is not defined for.
|
|
201
|
-
*/
|
|
202
|
-
declare function destinationAmount(dest: DestinationId, m: Money, options?: {
|
|
203
|
-
as?: 'number' | 'string';
|
|
204
|
-
}): DestinationValue | undefined;
|
|
205
|
-
/** A shopping-feed price: `'12.345 KWD'`, `'1200 JPY'`, `'19.99 USD'` (display digits, half-up). */
|
|
206
|
-
declare function feedPrice(m: Money): string;
|
|
207
|
-
/** Google micros (major x 10^6) as integer text, exactly: USD 1999 gives `'19990000'`. */
|
|
208
|
-
declare function googleMicros(m: Money): string;
|
|
209
|
-
interface EventMoney {
|
|
210
|
-
readonly value: number;
|
|
211
|
-
readonly currency: string;
|
|
212
|
-
}
|
|
213
|
-
/** First-party analytics money: the stored integer and the lower-case code (the ClickHouse `Int64` contract). */
|
|
214
|
-
declare function eventMoney(m: Money): EventMoney;
|
|
215
|
-
//#endregion
|
|
216
|
-
//#region src/wire/provider-amount.d.ts
|
|
217
|
-
interface ProviderAmountOptions {
|
|
218
|
-
/** Accept a negative amount (refunds, credits). Default false. */
|
|
219
|
-
allowNegative?: boolean;
|
|
220
|
-
/** Default `'.'`; `'auto'` decides from the text (see the core separator engine). */
|
|
221
|
-
decimalSeparator?: '.' | ',' | 'auto';
|
|
222
|
-
/** Read the first number and ignore the rest (`'22.67 + KDV'`). Default false. */
|
|
223
|
-
allowTrailingText?: boolean;
|
|
224
|
-
/** Rounding to the currency's storage digits (and the 'auto' whole-unit rounding). Default `'half-up'`. */
|
|
225
|
-
rounding?: RoundingMode;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* A provider's major-unit amount (finite number, or text read by the separator engine, which
|
|
229
|
-
* strips the currency's symbol and code) as Money, rounded once to the storage digits. Null on
|
|
230
|
-
* anything invalid (empty, unparseable, non-finite, negative without `allowNegative`, too large,
|
|
231
|
-
* unknown currency), never 0.
|
|
232
|
-
*/
|
|
233
|
-
declare function parseProviderAmount(value: unknown, currency: string, options?: ProviderAmountOptions): Money | null;
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region src/wire/providers.d.ts
|
|
236
|
-
/** RBI e-mandate cap Razorpay token registrations carry as `max_amount`: INR 15,000 (1,500,000 paise = stored). */
|
|
237
|
-
declare const RAZORPAY_AFA_FREE_CAP: Money;
|
|
238
|
-
/**
|
|
239
|
-
* The symbolic charge a saved-card setup makes: Paystack one major unit, Razorpay one INR (any
|
|
240
|
-
* other currency is `wire_unsupported`), Mollie one smallest wire unit (`'0.01'`, `'1'` for ISK
|
|
241
|
-
* and JPY), Adyen zero. Vault charges are always new, so the iso-minor-v2 convention applies.
|
|
242
|
-
*/
|
|
243
|
-
declare function verificationCharge(psp: 'paystack' | 'razorpay' | 'mollie' | 'adyen', currency: string): {
|
|
244
|
-
wire: number | string;
|
|
245
|
-
money: Money;
|
|
246
|
-
};
|
|
247
|
-
/**
|
|
248
|
-
* iyzico's price spelling, on the text (no float): canonical decimal (no trailing fraction zeros),
|
|
249
|
-
* then `'.0'` when there is no `.` (`'10.50'` gives `'10.5'`, `'10.00'` gives `'10.0'`). Text that
|
|
250
|
-
* is not a plain decimal throws `parse`.
|
|
251
|
-
*/
|
|
252
|
-
declare function iyzicoPrice(wire: string): string;
|
|
253
|
-
//#endregion
|
|
254
|
-
//#region src/wire/slot.d.ts
|
|
255
|
-
interface SlotMoney {
|
|
256
|
-
readonly amount: StoredAmount;
|
|
257
|
-
/** Lower-case, as Medusa spells it. */
|
|
258
|
-
readonly currency_code: string;
|
|
259
|
-
}
|
|
260
|
-
/** `m` for a slot context's `money` key. */
|
|
261
|
-
declare function slotMoney(m: Money): SlotMoney;
|
|
262
|
-
/**
|
|
263
|
-
* The money a slot context carries: `context.money` when it is valid, else the legacy
|
|
264
|
-
* `total ?? price` with the first known of `currency_code`, `currency`, read leniently (numbers, numeric text,
|
|
265
|
-
* Medusa BigNumber shapes). Undefined when the amount or the currency is missing or unreadable.
|
|
266
|
-
*/
|
|
267
|
-
declare function readSlotMoney(context: unknown): SlotMoney | undefined;
|
|
268
|
-
//#endregion
|
|
269
|
-
export { tryDecodeWire as A, EncodeGatedPsp as B, decodeWire as C, pspMinimumAmount as D, pspDefaultCurrency as E, PRE_CUTOVER as F, PSP_IDS as G, IsoMinorPsp as H, WIRE_SCALE_ISO_MINOR_V2 as I, AuthorizeNetAmounts as J, PspId as K, WIRE_SCALE_KEY as L, wireBreakdown as M, Convention as N, pspSupportsCurrency as O, ISO_MINOR_V2 as P, WIRE_SCALE_MARKER as R, assertPspCurrency as S, pspCurrencies as T, MajorNumberPsp as U, GatedPsp as V, MajorStringPsp as W, jsonDecimalLiteral as X, authorizeNetReversibleAmount as Y, oneWireUnit as _, iyzicoPrice as a, EncodeWireOptions as b, parseProviderAmount as c, destinationAmount as d, eventMoney as f, SameWireAmountOptions as g, DestinationId as h, RAZORPAY_AFA_FREE_CAP as i, wireFactor as j, pspWireDigits as k, DestinationValue as l, googleMicros as m, readSlotMoney as n, verificationCharge as o, feedPrice as p, WireAmount as q, slotMoney as r, ProviderAmountOptions as s, SlotMoney as t, EventMoney as u, sameWireAmount as v, encodeWire as w, TryDecodeWireOptions as x, wireKeyPart as y, conventionOf as z };
|