redsys-easy 5.1.0 → 5.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/lib/formatters/types.d.ts +17 -17
- package/lib/index.esm.js +16 -4
- package/lib/index.js +16 -4
- package/lib/types/output-params.d.ts +22 -22
- package/lib/utils/misc.d.ts +6 -0
- package/package.json +1 -1
|
@@ -186,31 +186,31 @@ export interface BaseFormatterOutput<RawOutputParams extends BaseOutputParams> {
|
|
|
186
186
|
/**
|
|
187
187
|
* @see {@link RestTrataPeticionOutputParams.Ds_SecurePayment}
|
|
188
188
|
*/
|
|
189
|
-
securePayment?: boolean
|
|
189
|
+
securePayment?: boolean;
|
|
190
190
|
/**
|
|
191
191
|
* @see {@link RestTrataPeticionOutputParams.Ds_Card_Country}
|
|
192
192
|
*/
|
|
193
|
-
cardCountry?: Country
|
|
193
|
+
cardCountry?: Country;
|
|
194
194
|
/**
|
|
195
195
|
* @see {@link RestTrataPeticionOutputParams.Ds_Card_Brand}
|
|
196
196
|
*/
|
|
197
|
-
cardBrand?: CardBrand
|
|
197
|
+
cardBrand?: CardBrand;
|
|
198
198
|
/**
|
|
199
199
|
* @see {@link RestTrataPeticionOutputParams.Ds_Card_PSD2}
|
|
200
200
|
*/
|
|
201
|
-
cardPSD2?: boolean
|
|
201
|
+
cardPSD2?: boolean;
|
|
202
202
|
/**
|
|
203
203
|
* @see {@link RestTrataPeticionOutputParams.Ds_MerchantData}
|
|
204
204
|
*/
|
|
205
|
-
merchantData?: string
|
|
205
|
+
merchantData?: string;
|
|
206
206
|
/**
|
|
207
207
|
* @see {@link RestTrataPeticionOutputParams.Ds_AuthorisationCode}
|
|
208
208
|
*/
|
|
209
|
-
authorisationCode?: string
|
|
209
|
+
authorisationCode?: string;
|
|
210
210
|
/**
|
|
211
211
|
* @see {@link RestTrataPeticionOutputParams.Ds_Card_Type}
|
|
212
212
|
*/
|
|
213
|
-
cardType?: BaseOutputParams['Ds_Card_Type']
|
|
213
|
+
cardType?: BaseOutputParams['Ds_Card_Type'];
|
|
214
214
|
raw: RawOutputParams;
|
|
215
215
|
}
|
|
216
216
|
export interface ResolvedTransactionTraitFormatterOutput {
|
|
@@ -254,39 +254,39 @@ export interface NotificationFormatterOutput<RawOutputParams extends Notificatio
|
|
|
254
254
|
/**
|
|
255
255
|
* @see {@link RestNotificationOutputParams.Ds_ConsumerLanguage}
|
|
256
256
|
*/
|
|
257
|
-
lang?: Language
|
|
257
|
+
lang?: Language;
|
|
258
258
|
}
|
|
259
259
|
export interface RequestFormatterOutput<RawOutputParams extends RequestOutputParams> extends BaseFormatterOutput<RawOutputParams> {
|
|
260
260
|
/**
|
|
261
261
|
* @see {@link RestTrataPeticionOutputParams.Ds_Merchant_Identifier}
|
|
262
262
|
*/
|
|
263
|
-
identifier?: string
|
|
263
|
+
identifier?: string;
|
|
264
264
|
/**
|
|
265
265
|
* @see {@link RestTrataPeticionOutputParams.Ds_Card_Number}
|
|
266
266
|
*/
|
|
267
|
-
cardNumber?: string
|
|
267
|
+
cardNumber?: string;
|
|
268
268
|
/**
|
|
269
269
|
* @see {@link RestTrataPeticionOutputParams.Ds_UrlPago2Fases}
|
|
270
270
|
*/
|
|
271
|
-
payURL?: string
|
|
271
|
+
payURL?: string;
|
|
272
272
|
/**
|
|
273
273
|
* Card expiry year, YY
|
|
274
274
|
*
|
|
275
275
|
* @remarks
|
|
276
276
|
* @see {@link RestTrataPeticionOutputParams.Ds_ExpiryDate}
|
|
277
277
|
*/
|
|
278
|
-
expiryYear?: string
|
|
278
|
+
expiryYear?: string;
|
|
279
279
|
/**
|
|
280
280
|
* Card expiry month, MM
|
|
281
281
|
*
|
|
282
282
|
* @remarks
|
|
283
283
|
* @see {@link RestTrataPeticionOutputParams.Ds_ExpiryDate}
|
|
284
284
|
*/
|
|
285
|
-
expiryMonth?: string
|
|
285
|
+
expiryMonth?: string;
|
|
286
286
|
/**
|
|
287
287
|
* @see {@link RestTrataPeticionOutputParams.Ds_Language}
|
|
288
288
|
*/
|
|
289
|
-
lang?: Language
|
|
289
|
+
lang?: Language;
|
|
290
290
|
}
|
|
291
291
|
/**
|
|
292
292
|
* Ouput parameters for the REST iniciaPeticion output formatter
|
|
@@ -297,7 +297,7 @@ export interface RestIniciaPeticionFormatterOutput<RawOutputParams extends RestI
|
|
|
297
297
|
/**
|
|
298
298
|
* @see {@link RestIniciaPeticionOutputParams.Ds_EMV3DS}
|
|
299
299
|
*/
|
|
300
|
-
emv3ds?: RestIniciaPeticionOutputParams['Ds_EMV3DS']
|
|
300
|
+
emv3ds?: RestIniciaPeticionOutputParams['Ds_EMV3DS'];
|
|
301
301
|
}
|
|
302
302
|
/**
|
|
303
303
|
* Ouput parameters for the REST trataPeticion output formatter
|
|
@@ -308,9 +308,9 @@ export interface RestTrataPeticionFormatterOutput<RawOutputParams extends RestTr
|
|
|
308
308
|
/**
|
|
309
309
|
* @see {@link RestTrataPeticionOutputParams.Ds_Response}
|
|
310
310
|
*/
|
|
311
|
-
response?: number
|
|
311
|
+
response?: number;
|
|
312
312
|
/**
|
|
313
313
|
* @see {@link RestTrataPeticionOutputParams.Ds_EMV3DS}
|
|
314
314
|
*/
|
|
315
|
-
emv3ds?: RestTrataPeticionOutputParams['Ds_EMV3DS']
|
|
315
|
+
emv3ds?: RestTrataPeticionOutputParams['Ds_EMV3DS'];
|
|
316
316
|
}
|
package/lib/index.esm.js
CHANGED
|
@@ -2081,6 +2081,16 @@ const assertSuccessfulResponse = (responseParams) => {
|
|
|
2081
2081
|
}
|
|
2082
2082
|
};
|
|
2083
2083
|
const isStringNotEmpty = (str) => str != null && str.length > 0;
|
|
2084
|
+
/**
|
|
2085
|
+
* Map over maybe monad
|
|
2086
|
+
*
|
|
2087
|
+
* If value is defined apply function and return output, otherwise return undefined.
|
|
2088
|
+
*/
|
|
2089
|
+
const mapMaybeMonad = (value, fn) => {
|
|
2090
|
+
return value !== undefined
|
|
2091
|
+
? fn(value)
|
|
2092
|
+
: undefined;
|
|
2093
|
+
};
|
|
2084
2094
|
|
|
2085
2095
|
const sha256VerifyJSONResponse = (merchantKey, response, responseParams) => {
|
|
2086
2096
|
if (response.Ds_SignatureVersion !== 'HMAC_SHA256_V1') {
|
|
@@ -3358,10 +3368,10 @@ const baseOutputFormatter = (raw) => {
|
|
|
3358
3368
|
? { securePayment: rawSecurePayment === '1' || rawSecurePayment === '2' }
|
|
3359
3369
|
: undefined),
|
|
3360
3370
|
...(isStringNotEmpty(rawCardCountry)
|
|
3361
|
-
?
|
|
3371
|
+
? mapMaybeMonad(formatCountry(rawCardCountry), cardCountry => ({ cardCountry }))
|
|
3362
3372
|
: undefined),
|
|
3363
3373
|
...(isStringNotEmpty(rawCardBrand)
|
|
3364
|
-
?
|
|
3374
|
+
? mapMaybeMonad(formatCardBrand(rawCardBrand), cardBrand => ({ cardBrand }))
|
|
3365
3375
|
: undefined),
|
|
3366
3376
|
...(isStringNotEmpty(rawCardPSD2)
|
|
3367
3377
|
? { cardPSD2: rawCardPSD2 === 'Y' }
|
|
@@ -3399,7 +3409,7 @@ const notificationOutputFormatter = (raw) => {
|
|
|
3399
3409
|
...formatPrice(raw),
|
|
3400
3410
|
response: formatResponse(rawResponse),
|
|
3401
3411
|
...(isStringNotEmpty(rawConsumerLanguage)
|
|
3402
|
-
?
|
|
3412
|
+
? mapMaybeMonad(formatLang(rawConsumerLanguage), lang => ({ lang }))
|
|
3403
3413
|
: undefined)
|
|
3404
3414
|
};
|
|
3405
3415
|
};
|
|
@@ -3451,7 +3461,9 @@ const requestOutputFormatter = (raw) => {
|
|
|
3451
3461
|
expiryMonth: rawExpiryDate.slice(2, 4)
|
|
3452
3462
|
}
|
|
3453
3463
|
: undefined),
|
|
3454
|
-
...(isStringNotEmpty(rawLang)
|
|
3464
|
+
...(isStringNotEmpty(rawLang)
|
|
3465
|
+
? mapMaybeMonad(formatLang(rawLang), lang => ({ lang }))
|
|
3466
|
+
: undefined)
|
|
3455
3467
|
};
|
|
3456
3468
|
};
|
|
3457
3469
|
/**
|
package/lib/index.js
CHANGED
|
@@ -2083,6 +2083,16 @@ const assertSuccessfulResponse = (responseParams) => {
|
|
|
2083
2083
|
}
|
|
2084
2084
|
};
|
|
2085
2085
|
const isStringNotEmpty = (str) => str != null && str.length > 0;
|
|
2086
|
+
/**
|
|
2087
|
+
* Map over maybe monad
|
|
2088
|
+
*
|
|
2089
|
+
* If value is defined apply function and return output, otherwise return undefined.
|
|
2090
|
+
*/
|
|
2091
|
+
const mapMaybeMonad = (value, fn) => {
|
|
2092
|
+
return value !== undefined
|
|
2093
|
+
? fn(value)
|
|
2094
|
+
: undefined;
|
|
2095
|
+
};
|
|
2086
2096
|
|
|
2087
2097
|
const sha256VerifyJSONResponse = (merchantKey, response, responseParams) => {
|
|
2088
2098
|
if (response.Ds_SignatureVersion !== 'HMAC_SHA256_V1') {
|
|
@@ -3360,10 +3370,10 @@ const baseOutputFormatter = (raw) => {
|
|
|
3360
3370
|
? { securePayment: rawSecurePayment === '1' || rawSecurePayment === '2' }
|
|
3361
3371
|
: undefined),
|
|
3362
3372
|
...(isStringNotEmpty(rawCardCountry)
|
|
3363
|
-
?
|
|
3373
|
+
? mapMaybeMonad(formatCountry(rawCardCountry), cardCountry => ({ cardCountry }))
|
|
3364
3374
|
: undefined),
|
|
3365
3375
|
...(isStringNotEmpty(rawCardBrand)
|
|
3366
|
-
?
|
|
3376
|
+
? mapMaybeMonad(formatCardBrand(rawCardBrand), cardBrand => ({ cardBrand }))
|
|
3367
3377
|
: undefined),
|
|
3368
3378
|
...(isStringNotEmpty(rawCardPSD2)
|
|
3369
3379
|
? { cardPSD2: rawCardPSD2 === 'Y' }
|
|
@@ -3401,7 +3411,7 @@ const notificationOutputFormatter = (raw) => {
|
|
|
3401
3411
|
...formatPrice(raw),
|
|
3402
3412
|
response: formatResponse(rawResponse),
|
|
3403
3413
|
...(isStringNotEmpty(rawConsumerLanguage)
|
|
3404
|
-
?
|
|
3414
|
+
? mapMaybeMonad(formatLang(rawConsumerLanguage), lang => ({ lang }))
|
|
3405
3415
|
: undefined)
|
|
3406
3416
|
};
|
|
3407
3417
|
};
|
|
@@ -3453,7 +3463,9 @@ const requestOutputFormatter = (raw) => {
|
|
|
3453
3463
|
expiryMonth: rawExpiryDate.slice(2, 4)
|
|
3454
3464
|
}
|
|
3455
3465
|
: undefined),
|
|
3456
|
-
...(isStringNotEmpty(rawLang)
|
|
3466
|
+
...(isStringNotEmpty(rawLang)
|
|
3467
|
+
? mapMaybeMonad(formatLang(rawLang), lang => ({ lang }))
|
|
3468
|
+
: undefined)
|
|
3457
3469
|
};
|
|
3458
3470
|
};
|
|
3459
3471
|
/**
|
|
@@ -17,41 +17,41 @@ export interface BaseOutputParams {
|
|
|
17
17
|
/** Transaction type */
|
|
18
18
|
Ds_TransactionType: TransactionType;
|
|
19
19
|
/** Secure payment indicator */
|
|
20
|
-
Ds_SecurePayment?: '0' | '1' | '2'
|
|
20
|
+
Ds_SecurePayment?: '0' | '1' | '2';
|
|
21
21
|
/** Card country */
|
|
22
|
-
Ds_Card_Country?: CountryNum
|
|
22
|
+
Ds_Card_Country?: CountryNum;
|
|
23
23
|
/** Authorization transaction code, refunds */
|
|
24
|
-
Ds_AuthorisationCode?: string
|
|
24
|
+
Ds_AuthorisationCode?: string;
|
|
25
25
|
/** Card type */
|
|
26
|
-
Ds_Card_Type?: 'C' | 'D'
|
|
26
|
+
Ds_Card_Type?: 'C' | 'D';
|
|
27
27
|
/** Merchant data */
|
|
28
|
-
Ds_MerchantData?: string
|
|
28
|
+
Ds_MerchantData?: string;
|
|
29
29
|
/** Card brand */
|
|
30
|
-
Ds_Card_Brand?: CardBrandNum
|
|
30
|
+
Ds_Card_Brand?: CardBrandNum;
|
|
31
31
|
/** Card is under PSD2 */
|
|
32
|
-
Ds_Card_PSD2?: 'Y' | 'N'
|
|
32
|
+
Ds_Card_PSD2?: 'Y' | 'N';
|
|
33
33
|
/**
|
|
34
34
|
* PDS2 exemptions
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* `'LWV;TRA[30.0];COR;MIT;ATD;WHL'`
|
|
38
38
|
*/
|
|
39
|
-
Ds_Excep_SCA?: string
|
|
39
|
+
Ds_Excep_SCA?: string;
|
|
40
40
|
/** Payment method number */
|
|
41
|
-
Ds_ProcessedPayMethod?: string
|
|
41
|
+
Ds_ProcessedPayMethod?: string;
|
|
42
42
|
/** Credential On File transaction identifier */
|
|
43
|
-
Ds_Merchant_Cof_Txnid?: string
|
|
43
|
+
Ds_Merchant_Cof_Txnid?: string;
|
|
44
44
|
/**
|
|
45
45
|
* Card number with some digits replaced with asterisks
|
|
46
46
|
* @deprecated
|
|
47
47
|
*/
|
|
48
|
-
Ds_CardNumber?: string
|
|
48
|
+
Ds_CardNumber?: string;
|
|
49
49
|
/** Card number with some digits replaced with asterisks */
|
|
50
|
-
Ds_Card_Number?: string
|
|
50
|
+
Ds_Card_Number?: string;
|
|
51
51
|
/** Card expiry date, YYmm */
|
|
52
|
-
Ds_ExpiryDate?: string
|
|
52
|
+
Ds_ExpiryDate?: string;
|
|
53
53
|
/** Stored payment method reference number */
|
|
54
|
-
Ds_Merchant_Identifier?: string
|
|
54
|
+
Ds_Merchant_Identifier?: string;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Common output parameters of resolved requests or notifications
|
|
@@ -74,9 +74,9 @@ export interface ResolvedTransactionTrait {
|
|
|
74
74
|
*/
|
|
75
75
|
export interface RequestOutputParams extends BaseOutputParams {
|
|
76
76
|
/** Payment link, paygold */
|
|
77
|
-
Ds_UrlPago2Fases?: string
|
|
77
|
+
Ds_UrlPago2Fases?: string;
|
|
78
78
|
/** Language */
|
|
79
|
-
Ds_Language?: LanguageNum
|
|
79
|
+
Ds_Language?: LanguageNum;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Output parameters of a IniciaPeticion HTTP request
|
|
@@ -85,7 +85,7 @@ export interface RequestOutputParams extends BaseOutputParams {
|
|
|
85
85
|
*/
|
|
86
86
|
export interface RestIniciaPeticionOutputParams extends RequestOutputParams {
|
|
87
87
|
/** EMV3DS data in json format */
|
|
88
|
-
Ds_EMV3DS?: ThreeDSv1PreAuthOutputParams | ThreeDSv2PreAuthOutputParams
|
|
88
|
+
Ds_EMV3DS?: ThreeDSv1PreAuthOutputParams | ThreeDSv2PreAuthOutputParams;
|
|
89
89
|
/** Dynamic Currency Conversion data, json */
|
|
90
90
|
Ds_DCC?: {
|
|
91
91
|
InfoMonedaTarjeta: {
|
|
@@ -112,7 +112,7 @@ export interface RestIniciaPeticionOutputParams extends RequestOutputParams {
|
|
|
112
112
|
/** Amount, decimal number */
|
|
113
113
|
importeCome: string;
|
|
114
114
|
};
|
|
115
|
-
}
|
|
115
|
+
};
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* Output parameters of a TrataPeticion HTTP request
|
|
@@ -121,18 +121,18 @@ export interface RestIniciaPeticionOutputParams extends RequestOutputParams {
|
|
|
121
121
|
*/
|
|
122
122
|
export interface RestTrataPeticionOutputParams extends RequestOutputParams, Omit<ResolvedTransactionTrait, 'Ds_Response'> {
|
|
123
123
|
/** Response code */
|
|
124
|
-
Ds_Response?: ResolvedTransactionTrait['Ds_Response']
|
|
124
|
+
Ds_Response?: ResolvedTransactionTrait['Ds_Response'];
|
|
125
125
|
/** EMV3DS data in json format */
|
|
126
|
-
Ds_EMV3DS?: ThreeDSv1ChallengeOutputParams | ThreeDSv2ChallengeOutputParams
|
|
126
|
+
Ds_EMV3DS?: ThreeDSv1ChallengeOutputParams | ThreeDSv2ChallengeOutputParams;
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Common parameters for notifications
|
|
130
130
|
*/
|
|
131
131
|
export interface NotificationOutputParams extends BaseOutputParams, ResolvedTransactionTrait {
|
|
132
132
|
/** Language */
|
|
133
|
-
Ds_ConsumerLanguage?: LanguageNum
|
|
133
|
+
Ds_ConsumerLanguage?: LanguageNum;
|
|
134
134
|
/** Error code */
|
|
135
|
-
Ds_ErrorCode?: string
|
|
135
|
+
Ds_ErrorCode?: string;
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
138
|
* Parameters of a redsys REST notification
|
package/lib/utils/misc.d.ts
CHANGED
|
@@ -28,3 +28,9 @@ export declare const assertSuccessfulResponse: (responseParams: {
|
|
|
28
28
|
Ds_Response?: string | undefined;
|
|
29
29
|
}) => void;
|
|
30
30
|
export declare const isStringNotEmpty: <T extends string>(str: T | undefined) => str is T;
|
|
31
|
+
/**
|
|
32
|
+
* Map over maybe monad
|
|
33
|
+
*
|
|
34
|
+
* If value is defined apply function and return output, otherwise return undefined.
|
|
35
|
+
*/
|
|
36
|
+
export declare const mapMaybeMonad: <V, Out>(value: V | undefined, fn: (value: V) => Out) => Out | undefined;
|