@m2c/checkout 0.1.1 → 0.1.2
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/dist/validate.d.ts +1 -0
- package/dist/validate.js +8 -0
- package/package.json +1 -1
package/dist/validate.d.ts
CHANGED
package/dist/validate.js
CHANGED
|
@@ -3,6 +3,11 @@ import { M2CCheckoutError } from './errors.js';
|
|
|
3
3
|
// contract violation fails client-side with a clear message instead of a
|
|
4
4
|
// round-trip and a generic 400.
|
|
5
5
|
export const MAX_TRANSACTION_VALUE = 5000000000;
|
|
6
|
+
// Smallest positive value the server keeps: it rounds major units to micro-units
|
|
7
|
+
// (1e-6) internally, so a positive value below one micro-unit becomes 0 at the
|
|
8
|
+
// storage boundary and is rejected. Mirror that floor instead of taking the
|
|
9
|
+
// round-trip for a generic 400.
|
|
10
|
+
export const MIN_TRANSACTION_VALUE = 0.000001;
|
|
6
11
|
const MAX_RETURN_URL_BYTES = 2048;
|
|
7
12
|
const MAX_CHECKOUT_URL_BYTES = 4096;
|
|
8
13
|
const MAX_DESCRIPTION_BYTES = 256;
|
|
@@ -48,6 +53,9 @@ export function assertTransactionValue(value) {
|
|
|
48
53
|
if (value <= 0) {
|
|
49
54
|
throw invalid('transactionValue must be greater than 0');
|
|
50
55
|
}
|
|
56
|
+
if (value < MIN_TRANSACTION_VALUE) {
|
|
57
|
+
throw invalid(`transactionValue must be at least ${MIN_TRANSACTION_VALUE}`);
|
|
58
|
+
}
|
|
51
59
|
if (value > MAX_TRANSACTION_VALUE) {
|
|
52
60
|
throw invalid(`transactionValue must be at most ${MAX_TRANSACTION_VALUE} major units`);
|
|
53
61
|
}
|
package/package.json
CHANGED