@p2pdotme/sdk 1.2.15 → 1.2.17
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/country.cjs +393 -42
- package/dist/country.cjs.map +1 -1
- package/dist/country.d.cts +130 -25
- package/dist/country.d.ts +130 -25
- package/dist/country.mjs +375 -42
- package/dist/country.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/qr-parsers.cjs +121 -8
- package/dist/qr-parsers.cjs.map +1 -1
- package/dist/qr-parsers.d.cts +8 -1
- package/dist/qr-parsers.d.ts +8 -1
- package/dist/qr-parsers.mjs +120 -8
- package/dist/qr-parsers.mjs.map +1 -1
- package/package.json +1 -1
package/dist/country.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ type CurrencyCode = (typeof CURRENCY)[keyof typeof CURRENCY];
|
|
|
29
29
|
*/
|
|
30
30
|
declare const CURRENCY_CODES: [CurrencyCode, ...CurrencyCode[]];
|
|
31
31
|
|
|
32
|
+
/** Joins an optional QR payload with typed fields (`qr||phone|cci`). */
|
|
33
|
+
declare const PACKED_PAYMENT_ID_SEP = "||";
|
|
32
34
|
interface PaymentIdFieldConfig {
|
|
33
35
|
readonly key: string;
|
|
34
36
|
readonly label: string;
|
|
@@ -36,6 +38,11 @@ interface PaymentIdFieldConfig {
|
|
|
36
38
|
readonly displayLabel: string | null;
|
|
37
39
|
readonly validate: (value: string) => boolean;
|
|
38
40
|
readonly validationErrorMessage: string;
|
|
41
|
+
/**
|
|
42
|
+
* When true, an empty value is allowed. If every field is optional, at least
|
|
43
|
+
* one field must still be filled (see `validatePaymentIdFields`).
|
|
44
|
+
*/
|
|
45
|
+
readonly optional?: boolean;
|
|
39
46
|
}
|
|
40
47
|
interface CountryOption {
|
|
41
48
|
readonly country: string;
|
|
@@ -57,14 +64,97 @@ interface CountryOption {
|
|
|
57
64
|
readonly isAlpha: boolean;
|
|
58
65
|
readonly disabled: boolean;
|
|
59
66
|
readonly disabledPaymentTypes: readonly string[];
|
|
67
|
+
/**
|
|
68
|
+
* Merchant/seller provides payment details by uploading a QR image.
|
|
69
|
+
* Distinct from PAY, where the buyer scans a QR. Default: false.
|
|
70
|
+
*/
|
|
71
|
+
readonly uploadPaymentQR?: boolean;
|
|
72
|
+
/** Structural check for a standalone QR payload (no `||` pack). */
|
|
73
|
+
readonly validateQr?: (payload: string) => boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Fill catalog fields from a validated QR (e.g. Yape/Plin phone in EMVCo).
|
|
76
|
+
* Only used when the typed fallback did not already set the key.
|
|
77
|
+
*/
|
|
78
|
+
readonly hydrateFieldsFromQr?: (qr: string) => Partial<Record<string, string>>;
|
|
60
79
|
}
|
|
61
80
|
|
|
62
81
|
/** All supported countries with their currency metadata, payment methods, and display config. */
|
|
63
82
|
declare const COUNTRY_OPTIONS: readonly CountryOption[];
|
|
83
|
+
declare function getCountryOption(currency: CurrencyCode | null | undefined): CountryOption | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the merchant/seller provides payment details by uploading a QR image.
|
|
86
|
+
* Distinct from PAY (`disabledPaymentTypes`), where the buyer scans a QR.
|
|
87
|
+
*/
|
|
88
|
+
declare function uploadsPaymentQR(currency: CurrencyCode | null | undefined): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Whether a stored payment ID may include a QR payload (`qr||fields` or
|
|
91
|
+
* standalone QR). Derived from `validateQr` — no extra flag.
|
|
92
|
+
*/
|
|
93
|
+
declare function usesPackedPaymentId(currency: CurrencyCode | null | undefined): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Apps mount the catalog form (PackedPaymentInput): QR upload and/or
|
|
96
|
+
* more than one typed field.
|
|
97
|
+
*/
|
|
98
|
+
declare function usesCatalogPaymentForm(currency: CurrencyCode | null | undefined): boolean;
|
|
64
99
|
|
|
65
100
|
/** Payment ID field configuration for each supported currency. */
|
|
66
101
|
declare const PAYMENT_ID_FIELDS: Record<CurrencyCode, PaymentIdFieldConfig[]>;
|
|
67
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Yape/Plin EMVCo: country PE, currency 604, CRC-16/CCITT-FALSE.
|
|
105
|
+
* CRC is required on upload so we never persist a truncated screenshot.
|
|
106
|
+
* (PAY render in the merchant is looser; that path does not use this.)
|
|
107
|
+
*/
|
|
108
|
+
declare function validatePeruvianQr(payload: string): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Suiche 7B / Pago Móvil collection QR: `base64?merchantId=NNNN&…`.
|
|
111
|
+
* The base64 is bank AES — we cannot decode phone/RIF from it, only the
|
|
112
|
+
* envelope. Reject packed `||` IDs so a stored compound string is never
|
|
113
|
+
* treated as a QR. Scan & Pay uses the looser `isPagoMovilQr` envelope.
|
|
114
|
+
*/
|
|
115
|
+
declare function validateVenezuelanQr(payload: string): boolean;
|
|
116
|
+
|
|
117
|
+
/** Validates a 20-digit Peruvian CCI (spaces ignored). */
|
|
118
|
+
declare function validatePeruvianCci(value: string): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Validates a Yape/Plin phone: `9` + 8 digits, optional `+51` / `51` prefix.
|
|
121
|
+
*/
|
|
122
|
+
declare function validatePeruvianPhone(value: string): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Validates a Peruvian payment key for the legacy single-field path.
|
|
125
|
+
* Accepts either a 20-digit CCI or a Yape/Plin phone number.
|
|
126
|
+
*/
|
|
127
|
+
declare function validatePeruvianPaymentKey(value: string): boolean;
|
|
128
|
+
type PeruvianPaymentIdParts = {
|
|
129
|
+
qr: string | null;
|
|
130
|
+
phone: string | null;
|
|
131
|
+
cci: string | null;
|
|
132
|
+
};
|
|
133
|
+
/** QR payload and/or CCI and/or Yape/Plin phone. */
|
|
134
|
+
declare function validatePeruvianPaymentId(value: string): boolean;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Validates Venezuelan phone number for Pago Movil.
|
|
138
|
+
* Format: 04XX-XXXXXXX (11 digits starting with 04).
|
|
139
|
+
*/
|
|
140
|
+
declare function validateVenezuelanPhoneNumber(phoneNumber: string): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Validates Venezuelan Cédula/RIF for Pago Móvil.
|
|
143
|
+
* Format: prefix (V|E|J|G|R|P) followed by digits.
|
|
144
|
+
* Includes natural persons (V), foreigners (E), companies (J), government (G),
|
|
145
|
+
* residual (R), and passport-linked accounts (P).
|
|
146
|
+
*/
|
|
147
|
+
declare function validateVenezuelanRif(rif: string): boolean;
|
|
148
|
+
type VenezuelanPaymentIdParts = {
|
|
149
|
+
qr: string | null;
|
|
150
|
+
compound: string | null;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Accepts a Suiche 7B QR payload, the typed `phone|rif|bank` fallback,
|
|
154
|
+
* or both packed as `qr||phone|rif|bank`.
|
|
155
|
+
*/
|
|
156
|
+
declare function validateVenezuelanPaymentId(value: string): boolean;
|
|
157
|
+
|
|
68
158
|
/**
|
|
69
159
|
* Validates Argentine payment IDs (CBU, CVU, or Alias).
|
|
70
160
|
* CBU/CVU: 22 digits with checksum. Alias: 6-20 alphanumeric characters.
|
|
@@ -139,18 +229,6 @@ declare function validateNigerianAccountNumber(accountNumber: string): boolean;
|
|
|
139
229
|
*/
|
|
140
230
|
declare function validateNigerianAccountName(accountName: string): boolean;
|
|
141
231
|
|
|
142
|
-
/**
|
|
143
|
-
* Validates a Peruvian payment key for the SELL text-key path.
|
|
144
|
-
* Accepts either a 20-digit CCI (Código de Cuenta Interbancario, spaces ignored)
|
|
145
|
-
* or a Yape/Plin phone number (optional `+51`/`51` prefix, then `9` + 8 digits).
|
|
146
|
-
*/
|
|
147
|
-
declare function validatePeruvianPaymentKey(value: string): boolean;
|
|
148
|
-
/**
|
|
149
|
-
* Validates a Yape/Plin EMVCo QR payload: parseable TLV, country (tag 58) `PE`,
|
|
150
|
-
* currency (tag 53) `604` (PEN), and a matching CRC-16/CCITT-FALSE (tag 63).
|
|
151
|
-
*/
|
|
152
|
-
declare function validatePeruvianQr(payload: string): boolean;
|
|
153
|
-
|
|
154
232
|
/**
|
|
155
233
|
* Validates a Philippine mobile number for InstaPay (GCash / Maya).
|
|
156
234
|
* Mobile numbers are 10 digits starting with 9, and are commonly written
|
|
@@ -158,25 +236,52 @@ declare function validatePeruvianQr(payload: string): boolean;
|
|
|
158
236
|
*/
|
|
159
237
|
declare function validatePhilippinePhoneNumber(phoneNumber: string): boolean;
|
|
160
238
|
|
|
161
|
-
/**
|
|
162
|
-
* Validates Venezuelan phone number for Pago Movil.
|
|
163
|
-
* Format: 04XX-XXXXXXX (11 digits starting with 04).
|
|
164
|
-
*/
|
|
165
|
-
declare function validateVenezuelanPhoneNumber(phoneNumber: string): boolean;
|
|
166
|
-
/**
|
|
167
|
-
* Validates Venezuelan Cédula. Format: "V" followed by digits.
|
|
168
|
-
* Only natural-person cédulas (V) are accepted; legal-entity RIFs are not.
|
|
169
|
-
*/
|
|
170
|
-
declare function validateVenezuelanRif(rif: string): boolean;
|
|
171
|
-
|
|
172
239
|
/** Serializes multiple fields into a pipe-separated string. */
|
|
173
240
|
declare function serializeCompoundPaymentId(...fields: string[]): string;
|
|
174
241
|
/** Deserializes a pipe-separated payment ID into its component fields. */
|
|
175
242
|
declare function deserializeCompoundPaymentId(paymentId: string): string[];
|
|
176
243
|
/**
|
|
177
244
|
* Formats a compound payment ID for display using optional labels.
|
|
178
|
-
*
|
|
245
|
+
* Empty parts (optional fields left blank) are omitted.
|
|
179
246
|
*/
|
|
180
247
|
declare function formatCompoundPaymentIdForDisplay(paymentId: string, labels: (string | null)[]): string;
|
|
248
|
+
/**
|
|
249
|
+
* Validates a stored payment ID against `PAYMENT_ID_FIELDS`.
|
|
250
|
+
* Optional fields may be empty; if every field is optional, at least one must
|
|
251
|
+
* be filled. A legacy single token (no `|`) matches any one field's validator.
|
|
252
|
+
*/
|
|
253
|
+
declare function validatePaymentIdFields(fields: readonly PaymentIdFieldConfig[], paymentId: string): boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Splits a stored payment ID into per-field values for form hydration.
|
|
256
|
+
* A legacy single token is assigned to the first field whose validator matches.
|
|
257
|
+
*/
|
|
258
|
+
declare function assignPaymentIdToFieldValues(fields: readonly PaymentIdFieldConfig[], paymentId: string): Record<string, string>;
|
|
259
|
+
declare function unpackPackedPaymentId(paymentId: string): {
|
|
260
|
+
qr: string;
|
|
261
|
+
rest: string;
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* QR blob from a stored payment ID, or `null` if none / invalid.
|
|
265
|
+
*/
|
|
266
|
+
declare function getStoredQrPayload(currency: CurrencyCode | null | undefined, paymentId: string | null | undefined): string | null;
|
|
267
|
+
/**
|
|
268
|
+
* Builds a stored payment ID: optional validated QR packed with catalog fields.
|
|
269
|
+
*/
|
|
270
|
+
declare function packStoredPaymentId(currency: CurrencyCode, qr: string | null | undefined, fieldValues: Record<string, string>): string;
|
|
271
|
+
/**
|
|
272
|
+
* Validates a stored payment ID: optional packed QR, then catalog fields.
|
|
273
|
+
* QR-only is valid when the country exposes `validateQr`.
|
|
274
|
+
*/
|
|
275
|
+
declare function validateStoredPaymentId(currency: CurrencyCode, paymentId: string): boolean;
|
|
276
|
+
/**
|
|
277
|
+
* Typed-field values for form hydration. Packed QR prefix is stripped.
|
|
278
|
+
* `hydrateFieldsFromQr` fills keys the typed fallback left empty (PEN phone).
|
|
279
|
+
*/
|
|
280
|
+
declare function assignStoredPaymentIdToFieldValues(currency: CurrencyCode, paymentId: string): Record<string, string>;
|
|
281
|
+
/**
|
|
282
|
+
* Human-readable stored ID: labeled typed fields, never the raw QR blob.
|
|
283
|
+
* QR-only returns an empty string so the caller can substitute a label.
|
|
284
|
+
*/
|
|
285
|
+
declare function formatStoredPaymentIdForDisplay(currency: CurrencyCode, paymentId: string): string;
|
|
181
286
|
|
|
182
|
-
export { COUNTRY_OPTIONS, CURRENCY, CURRENCY_CODES, type CountryOption, type CurrencyCode, PAYMENT_ID_FIELDS, type PaymentIdFieldConfig, deserializeCompoundPaymentId, formatCompoundPaymentIdForDisplay, serializeCompoundPaymentId, validateArgentinePaymentId, validateColombianPaymentId, validateCubanCardNumber, validateCubanPhoneNumber, validateEcuadorianAccountName, validateEcuadorianAccountNumber, validateEcuadorianCedula, validateIndonesianPhoneNumber, validateMexicanPaymentId, validateNigerianAccountName, validateNigerianAccountNumber, validatePIXId, validatePeruvianPaymentKey, validatePeruvianQr, validatePhilippinePhoneNumber, validateRevolutId, validateUPIId, validateVenezuelanPhoneNumber, validateVenezuelanRif };
|
|
287
|
+
export { COUNTRY_OPTIONS, CURRENCY, CURRENCY_CODES, type CountryOption, type CurrencyCode, PACKED_PAYMENT_ID_SEP, PAYMENT_ID_FIELDS, type PaymentIdFieldConfig, type PeruvianPaymentIdParts, type VenezuelanPaymentIdParts, assignPaymentIdToFieldValues, assignStoredPaymentIdToFieldValues, deserializeCompoundPaymentId, formatCompoundPaymentIdForDisplay, formatStoredPaymentIdForDisplay, getCountryOption, getStoredQrPayload, packStoredPaymentId, serializeCompoundPaymentId, unpackPackedPaymentId, uploadsPaymentQR, usesCatalogPaymentForm, usesPackedPaymentId, validateArgentinePaymentId, validateColombianPaymentId, validateCubanCardNumber, validateCubanPhoneNumber, validateEcuadorianAccountName, validateEcuadorianAccountNumber, validateEcuadorianCedula, validateIndonesianPhoneNumber, validateMexicanPaymentId, validateNigerianAccountName, validateNigerianAccountNumber, validatePIXId, validatePaymentIdFields, validatePeruvianCci, validatePeruvianPaymentId, validatePeruvianPaymentKey, validatePeruvianPhone, validatePeruvianQr, validatePhilippinePhoneNumber, validateRevolutId, validateStoredPaymentId, validateUPIId, validateVenezuelanPaymentId, validateVenezuelanPhoneNumber, validateVenezuelanQr, validateVenezuelanRif };
|