redsys-easy 3.1.0 → 4.0.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/README.md +94 -419
- package/lib/assets/card-brands.d.ts +26 -2
- package/lib/assets/countries.d.ts +29 -2
- package/lib/assets/currencies.d.ts +26 -2
- package/lib/assets/lang-codes.d.ts +29 -2
- package/lib/assets/transaction-types.d.ts +38 -3
- package/lib/client.d.ts +50 -0
- package/lib/crypto.d.ts +25 -0
- package/lib/errors.d.ts +61 -6
- package/lib/formatter-utils.d.ts +24 -0
- package/lib/formatters/input-params.d.ts +21 -0
- package/lib/formatters/output-params.d.ts +29 -0
- package/lib/formatters/types.d.ts +316 -0
- package/lib/index.d.ts +30 -56
- package/lib/index.esm.js +957 -746
- package/lib/index.js +990 -747
- package/lib/rest/3ds.d.ts +31 -0
- package/lib/rest/json-serialization.d.ts +2 -0
- package/lib/rest/json-sha256-signature.d.ts +3 -0
- package/lib/rest/json.d.ts +3 -0
- package/lib/rest/requests.d.ts +2 -0
- package/lib/soap/notification-serialization.d.ts +3 -0
- package/lib/soap/notification-signature.d.ts +3 -0
- package/lib/soap/notification.d.ts +4 -0
- package/lib/soap/utils.d.ts +43 -0
- package/lib/types/3ds-params.d.ts +345 -0
- package/lib/types/api.d.ts +69 -78
- package/lib/types/input-params.d.ts +176 -0
- package/lib/types/output-params.d.ts +158 -0
- package/lib/utils/codes.d.ts +13 -0
- package/lib/utils/misc.d.ts +24 -0
- package/package.json +63 -57
- package/CHANGELOG.md +0 -53
- package/lib/params-formatter.d.ts +0 -7
- package/lib/response-formatter.d.ts +0 -5
- package/lib/utils.d.ts +0 -39
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import type { TransactionType } from '../assets/transaction-types';
|
|
2
|
+
import type { CurrencyNum } from '../assets/currencies';
|
|
3
|
+
import type { LanguageNum } from '../assets/lang-codes';
|
|
4
|
+
import type { ThreeDSPreAuthInputParams, ThreeDSv1AuthDataInputParams, ThreeDSv2AuthDataInputParams, ThreeDSv1ChallengeResponseInputParams, ThreeDSv2ChallengeResponseInputParams, ThreeDSRedirectInputParams } from './3ds-params';
|
|
5
|
+
/**
|
|
6
|
+
* Common input parameters
|
|
7
|
+
*/
|
|
8
|
+
export interface BaseInputParams {
|
|
9
|
+
/** Transaction type */
|
|
10
|
+
DS_MERCHANT_TRANSACTIONTYPE: TransactionType;
|
|
11
|
+
/** Merchant code number */
|
|
12
|
+
DS_MERCHANT_MERCHANTCODE: string;
|
|
13
|
+
/** Order identifier */
|
|
14
|
+
DS_MERCHANT_ORDER: string;
|
|
15
|
+
/** Terminal number */
|
|
16
|
+
DS_MERCHANT_TERMINAL: string;
|
|
17
|
+
/** Stored payment method reference number */
|
|
18
|
+
DS_MERCHANT_IDENTIFIER?: string;
|
|
19
|
+
/** Merchant group number */
|
|
20
|
+
DS_MERCHANT_GROUP?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Amount designated as an integer in the smallest currency division
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* `'199'` (1.99 EUR)
|
|
26
|
+
*/
|
|
27
|
+
DS_MERCHANT_AMOUNT?: string;
|
|
28
|
+
/** Currency number, ISO-4217 */
|
|
29
|
+
DS_MERCHANT_CURRENCY?: CurrencyNum;
|
|
30
|
+
/** Card PAN, number */
|
|
31
|
+
DS_MERCHANT_PAN?: string;
|
|
32
|
+
/** Card expiry date, YYMM */
|
|
33
|
+
DS_MERCHANT_EXPIRYDATE?: string;
|
|
34
|
+
/** Card CVV2 code */
|
|
35
|
+
DS_MERCHANT_CVV2?: string;
|
|
36
|
+
/** PDS2 exemptions */
|
|
37
|
+
DS_MERCHANT_EXCEP_SCA?: string;
|
|
38
|
+
/** Merchant data */
|
|
39
|
+
DS_MERCHANT_MERCHANTDATA?: string;
|
|
40
|
+
/** Merchant name */
|
|
41
|
+
DS_MERCHANT_MERCHANTNAME?: string;
|
|
42
|
+
/** Product description */
|
|
43
|
+
DS_MERCHANT_PRODUCTDESCRIPTION?: string;
|
|
44
|
+
/** Cardholder name and surname */
|
|
45
|
+
DS_MERCHANT_TITULAR?: string;
|
|
46
|
+
/** Authorization transaction code, refunds */
|
|
47
|
+
DS_MERCHANT_AUTHORISATIONCODE?: string;
|
|
48
|
+
/** Transaction date, YYYY-MM-DD */
|
|
49
|
+
DS_MERCHANT_TRANSACTIONDATE?: string;
|
|
50
|
+
/** Direct payment */
|
|
51
|
+
DS_MERCHANT_DIRECTPAYMENT?: 'true' | 'moto';
|
|
52
|
+
/** INSITE operation identifier */
|
|
53
|
+
DS_MERCHANT_IDOPER?: string;
|
|
54
|
+
/** Tax code number */
|
|
55
|
+
DS_MERCHANT_TAX_REFERENCE?: string;
|
|
56
|
+
/** Online Travel Agency indicator */
|
|
57
|
+
DS_MERCHANT_OTA?: 'S';
|
|
58
|
+
/** Initial Credential On File transaction indicator */
|
|
59
|
+
DS_MERCHANT_COF_INI?: 'S' | 'N';
|
|
60
|
+
/** Credential On File transaction identifier */
|
|
61
|
+
DS_MERCHANT_COF_TXNID?: string;
|
|
62
|
+
/** Credential On File transaction type */
|
|
63
|
+
DS_MERCHANT_COF_TYPE?: 'I' | 'R' | 'H' | 'E' | 'D' | 'M' | 'N' | 'C';
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Input parameters for a redsys redirect request
|
|
67
|
+
*
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export interface RedirectInputParams extends BaseInputParams {
|
|
71
|
+
/** EMV3DS data in json format */
|
|
72
|
+
DS_MERCHANT_EMV3DS?: ThreeDSRedirectInputParams;
|
|
73
|
+
/** Notification url */
|
|
74
|
+
DS_MERCHANT_MERCHANTURL?: string;
|
|
75
|
+
/** Success redirection url */
|
|
76
|
+
DS_MERCHANT_URLOK?: string;
|
|
77
|
+
/** Failure redirection url */
|
|
78
|
+
DS_MERCHANT_URLKO?: string;
|
|
79
|
+
/** Language */
|
|
80
|
+
DS_MERCHANT_CONSUMERLANGUAGE?: LanguageNum;
|
|
81
|
+
/** Payment methods */
|
|
82
|
+
DS_MERCHANT_PAYMETHODS?: string;
|
|
83
|
+
/** Customization code number */
|
|
84
|
+
DS_MERCHANT_PERSOCODE?: string;
|
|
85
|
+
/** Obtain paypal address */
|
|
86
|
+
DS_MERCHANT_SHIPPINGADDRESSPYP?: 'S' | 'N';
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Common input parameters for redsys request
|
|
90
|
+
*
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
export interface RequestInputParams extends BaseInputParams {
|
|
94
|
+
/** xPay data, hex */
|
|
95
|
+
DS_XPAYDATA?: string;
|
|
96
|
+
/** xPay origin */
|
|
97
|
+
DS_XPAYORIGEN?: 'Google' | 'Apple';
|
|
98
|
+
/** xPay type */
|
|
99
|
+
DS_XPAYTYPE?: 'WEB' | 'InApp';
|
|
100
|
+
/** PUC identifier, number */
|
|
101
|
+
DS_ACQUIRER_IDENTIFIER?: string;
|
|
102
|
+
/** Matching data */
|
|
103
|
+
DS_MERCHANT_MATCHINGDATA?: string;
|
|
104
|
+
/** Customer phone, paygold */
|
|
105
|
+
DS_MERCHANT_CUSTOMER_MOBILE?: string;
|
|
106
|
+
/** Customer email address, paygold */
|
|
107
|
+
DS_MERCHANT_CUSTOMER_MAIL?: string;
|
|
108
|
+
/** Expiration date for paygold links, YYYY-MM-DD-hh:mm:ss.sss or number of minutes */
|
|
109
|
+
DS_MERCHANT_P2F_EXPIRYDATE?: string;
|
|
110
|
+
/**
|
|
111
|
+
* SMS text content, paygold
|
|
112
|
+
*
|
|
113
|
+
* Parameters: @URL@, @COMERCIO@, @IMPORTE@ and @MONEDA@
|
|
114
|
+
*/
|
|
115
|
+
DS_MERCHANT_CUSTOMER_SMS_TEXT?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Email text content, paygold
|
|
118
|
+
*
|
|
119
|
+
* Parameters: nombreComprador, direccionComprador and textoLibre1.
|
|
120
|
+
*/
|
|
121
|
+
DS_MERCHANT_P2F_XMLDATA?: string;
|
|
122
|
+
}
|
|
123
|
+
export interface CommonRestInputParams extends RequestInputParams {
|
|
124
|
+
/** MPI External parameters, json */
|
|
125
|
+
DS_MERCHANT_MPIEXTERNAL?: {
|
|
126
|
+
/** Authenticator identifier, base64 */
|
|
127
|
+
TXID: string;
|
|
128
|
+
/** CAVV, base64 */
|
|
129
|
+
CAVV: string;
|
|
130
|
+
/** ECI, number */
|
|
131
|
+
ECI: '5' | '6' | '7';
|
|
132
|
+
/** Eci, number */
|
|
133
|
+
Eci: string;
|
|
134
|
+
/** 3DSecure transaction identifier */
|
|
135
|
+
threeDSServerTransID: string;
|
|
136
|
+
/** DS identifier */
|
|
137
|
+
dsTransID: string;
|
|
138
|
+
/** CAVV, base64 */
|
|
139
|
+
authenticationValue: string;
|
|
140
|
+
/** 3DSecure version */
|
|
141
|
+
ProtocolVersion: '2.1.0';
|
|
142
|
+
/** Authentication Method */
|
|
143
|
+
authenticationMethod: string;
|
|
144
|
+
/** Authentication type */
|
|
145
|
+
authenticationType: string;
|
|
146
|
+
/** Authentication flow */
|
|
147
|
+
authenticationFlow: 'F' | 'C';
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Input parameters for a IniciaPeticion HTTP request
|
|
152
|
+
*
|
|
153
|
+
* @public
|
|
154
|
+
*/
|
|
155
|
+
export interface RestIniciaPeticionInputParams extends CommonRestInputParams {
|
|
156
|
+
/** EMV3DS data in json format */
|
|
157
|
+
DS_MERCHANT_EMV3DS?: ThreeDSPreAuthInputParams;
|
|
158
|
+
/** Dynamic Currency Conversion data, json */
|
|
159
|
+
DS_MERCHANT_DCC?: 'Y' | 'N';
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Input parameters for a TrataPeticion Peticion HTTP request
|
|
163
|
+
*
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
export interface RestTrataPeticionInputParams extends CommonRestInputParams {
|
|
167
|
+
/** EMV3DS data in json format */
|
|
168
|
+
DS_MERCHANT_EMV3DS?: ThreeDSv1AuthDataInputParams | ThreeDSv2AuthDataInputParams | ThreeDSv1ChallengeResponseInputParams | ThreeDSv2ChallengeResponseInputParams;
|
|
169
|
+
/** Dynamic Currency Conversion data, json */
|
|
170
|
+
DS_MERCHANT_DCC?: {
|
|
171
|
+
/** Card currency number, ISO-4217 */
|
|
172
|
+
monedaDCC: string;
|
|
173
|
+
/** Amount in card currency, decimal number */
|
|
174
|
+
importeDCC: string;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { TransactionType } from '../assets/transaction-types';
|
|
2
|
+
import type { CountryNum } from '../assets/countries';
|
|
3
|
+
import type { CardBrandNum } from '../assets/card-brands';
|
|
4
|
+
import type { CurrencyNum } from '../assets/currencies';
|
|
5
|
+
import type { LanguageNum } from '../assets/lang-codes';
|
|
6
|
+
import type { ThreeDSv1PreAuthOutputParams, ThreeDSv2PreAuthOutputParams, ThreeDSv1ChallengeOutputParams, ThreeDSv2ChallengeOutputParams } from './3ds-params';
|
|
7
|
+
/**
|
|
8
|
+
* Common output parameters
|
|
9
|
+
*/
|
|
10
|
+
export interface BaseOutputParams {
|
|
11
|
+
/** Order identifier */
|
|
12
|
+
Ds_Order: string;
|
|
13
|
+
/** Merchant code number */
|
|
14
|
+
Ds_MerchantCode: string;
|
|
15
|
+
/** Terminal number */
|
|
16
|
+
Ds_Terminal: string;
|
|
17
|
+
/** Transaction type */
|
|
18
|
+
Ds_TransactionType: TransactionType;
|
|
19
|
+
/** Secure payment indicator */
|
|
20
|
+
Ds_SecurePayment?: '0' | '1' | '2';
|
|
21
|
+
/** Card country */
|
|
22
|
+
Ds_Card_Country?: CountryNum;
|
|
23
|
+
/** Authorization transaction code, refunds */
|
|
24
|
+
Ds_AuthorisationCode?: string;
|
|
25
|
+
/** Card type */
|
|
26
|
+
Ds_Card_Type?: 'C' | 'D';
|
|
27
|
+
/** Merchant data */
|
|
28
|
+
Ds_MerchantData?: string;
|
|
29
|
+
/** Card brand */
|
|
30
|
+
Ds_Card_Brand?: CardBrandNum;
|
|
31
|
+
/** Card is under PSD2 */
|
|
32
|
+
Ds_Card_PSD2?: 'Y' | 'N';
|
|
33
|
+
/**
|
|
34
|
+
* PDS2 exemptions
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* `'LWV;TRA[30.0];COR;MIT;ATD;WHL'`
|
|
38
|
+
*/
|
|
39
|
+
Ds_Excep_SCA?: string;
|
|
40
|
+
/** Payment method number */
|
|
41
|
+
Ds_ProcessedPayMethod?: string;
|
|
42
|
+
/** Credential On File transaction identifier */
|
|
43
|
+
Ds_Merchant_Cof_Txnid?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Card number with some digits replaced with asterisks
|
|
46
|
+
* @deprecated
|
|
47
|
+
*/
|
|
48
|
+
Ds_CardNumber?: string;
|
|
49
|
+
/** Card number with some digits replaced with asterisks */
|
|
50
|
+
Ds_Card_Number?: string;
|
|
51
|
+
/** Card expiry date, YYmm */
|
|
52
|
+
Ds_ExpiryDate?: string;
|
|
53
|
+
/** Stored payment method reference number */
|
|
54
|
+
Ds_Merchant_Identifier?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Common output parameters of resolved requests or notifications
|
|
58
|
+
*/
|
|
59
|
+
export interface ResolvedTransactionTrait {
|
|
60
|
+
/**
|
|
61
|
+
* Amount designated as an integer in the smallest currency division
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* `'199'` (1.99 EUR)
|
|
65
|
+
*/
|
|
66
|
+
Ds_Amount: string;
|
|
67
|
+
/** Currency number, ISO-4217 */
|
|
68
|
+
Ds_Currency: CurrencyNum;
|
|
69
|
+
/** Response code */
|
|
70
|
+
Ds_Response: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Common output parameters of a all requests
|
|
74
|
+
*/
|
|
75
|
+
export interface RequestOutputParams extends BaseOutputParams {
|
|
76
|
+
/** Payment link, paygold */
|
|
77
|
+
Ds_UrlPago2Fases?: string;
|
|
78
|
+
/** Language */
|
|
79
|
+
Ds_Language?: LanguageNum;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Output parameters of a IniciaPeticion HTTP request
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
export interface RestIniciaPeticionOutputParams extends RequestOutputParams {
|
|
87
|
+
/** EMV3DS data in json format */
|
|
88
|
+
Ds_EMV3DS?: ThreeDSv1PreAuthOutputParams | ThreeDSv2PreAuthOutputParams;
|
|
89
|
+
/** Dynamic Currency Conversion data, json */
|
|
90
|
+
Ds_DCC?: {
|
|
91
|
+
InfoMonedaTarjeta: {
|
|
92
|
+
/** Card currency number, ISO-4217 */
|
|
93
|
+
monedaDCC: string;
|
|
94
|
+
/** Card currency name */
|
|
95
|
+
litMonedaDCC: string;
|
|
96
|
+
/** Card currency 3-letter code */
|
|
97
|
+
litMonedaRDCC: string;
|
|
98
|
+
/** Amount in card currency, decimal number */
|
|
99
|
+
importeDCC: string;
|
|
100
|
+
/** Exchange rate, decimal number */
|
|
101
|
+
cambioDCC: string;
|
|
102
|
+
/** Exchange date, YYYY-MM-DD */
|
|
103
|
+
fechaCambioDCC: string;
|
|
104
|
+
/** Markup, decimal number */
|
|
105
|
+
markUp: number;
|
|
106
|
+
};
|
|
107
|
+
InfoMonedaComercio: {
|
|
108
|
+
/** Currency number, ISO-4217 */
|
|
109
|
+
monedaCome: string;
|
|
110
|
+
/** Currency 3-letter code */
|
|
111
|
+
litMonedaCome: string;
|
|
112
|
+
/** Amount, decimal number */
|
|
113
|
+
importeCome: string;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Output parameters of a TrataPeticion HTTP request
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
export interface RestTrataPeticionOutputParams extends RequestOutputParams, Omit<ResolvedTransactionTrait, 'Ds_Response'> {
|
|
123
|
+
/** Response code */
|
|
124
|
+
Ds_Response?: ResolvedTransactionTrait['Ds_Response'];
|
|
125
|
+
/** EMV3DS data in json format */
|
|
126
|
+
Ds_EMV3DS?: ThreeDSv1ChallengeOutputParams | ThreeDSv2ChallengeOutputParams;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Common parameters for notifications
|
|
130
|
+
*/
|
|
131
|
+
export interface NotificationOutputParams extends BaseOutputParams, ResolvedTransactionTrait {
|
|
132
|
+
/** Language */
|
|
133
|
+
Ds_ConsumerLanguage?: LanguageNum;
|
|
134
|
+
/** Error code */
|
|
135
|
+
Ds_ErrorCode?: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Parameters of a redsys REST notification
|
|
139
|
+
*
|
|
140
|
+
* @public
|
|
141
|
+
*/
|
|
142
|
+
export interface RestNotificationOutputParams extends NotificationOutputParams {
|
|
143
|
+
/** Transaction date, DD/MM/YYYY */
|
|
144
|
+
Ds_Date: string;
|
|
145
|
+
/** Transaction time, hh:mm */
|
|
146
|
+
Ds_Hour: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Parameters of a redsys SOAP notification
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
export interface SoapNotificationOutputParams extends NotificationOutputParams {
|
|
154
|
+
/** Transaction date, DD/MM/YYYY */
|
|
155
|
+
Fecha: string;
|
|
156
|
+
/** Transaction time, hh:mm */
|
|
157
|
+
Hora: string;
|
|
158
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the message corresponding to a response code, in spanish
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare const getResponseCodeMessage: (code: string | number) => string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the message corresponding to a gateway error code
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const getSISErrorCodeMessage: (code: string) => string | undefined;
|
|
13
|
+
export declare const getHTTPErrorCodeMessage: (code: number) => string | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CommonRawRequestParams, CommonRawResponseParams } from '../types/api';
|
|
2
|
+
/**
|
|
3
|
+
* Generates a random order ID following redsys requirements
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare const randomTransactionId: () => string;
|
|
8
|
+
export declare const extractAndAssertOrderFromRequestParams: (requestParams: CommonRawRequestParams) => string;
|
|
9
|
+
export declare const extractAndAssertOrderFromResponseParams: (responseParams: CommonRawResponseParams) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Indicates if a response code signals success
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare const isResponseCodeOk: (responseCode: string) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Asserts that response has a code that indicates success
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare const assertSuccessfulResponseCode: (responseParams: {
|
|
22
|
+
Ds_Response?: string;
|
|
23
|
+
}) => void;
|
|
24
|
+
export declare const isStringNotEmpty: <T extends string>(str: T | undefined) => str is T;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redsys-easy",
|
|
3
3
|
"description": "Node JS interface for Redsys payment gateway",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.2",
|
|
5
5
|
"author": "Javier Garcia <javiertury@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -24,18 +24,6 @@
|
|
|
24
24
|
"main": "lib/index.js",
|
|
25
25
|
"module": "lib/index.esm.js",
|
|
26
26
|
"types": "lib/index.d.ts",
|
|
27
|
-
"scripts": {
|
|
28
|
-
"build:clean": "rimraf lib",
|
|
29
|
-
"build": "npm run build:clean; rollup -c rollup.config.js",
|
|
30
|
-
"prepublishOnly": "npm run build",
|
|
31
|
-
"release": "standard-version",
|
|
32
|
-
"lint": "eslint --ext js,ts .",
|
|
33
|
-
"test-unit": "jest ./test/unit/**/*.test.ts",
|
|
34
|
-
"test-integration": "jest ./test/integration/**/*.test.ts",
|
|
35
|
-
"test-code": "jest",
|
|
36
|
-
"test-types": "tsd",
|
|
37
|
-
"test": "npm run test-code && npm run test-types"
|
|
38
|
-
},
|
|
39
27
|
"files": [
|
|
40
28
|
"lib"
|
|
41
29
|
],
|
|
@@ -47,61 +35,63 @@
|
|
|
47
35
|
"lint-staged": {
|
|
48
36
|
"*.{js,ts}": "eslint"
|
|
49
37
|
},
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
54
|
-
}
|
|
38
|
+
"simple-git-hooks": {
|
|
39
|
+
"pre-commit": "pnpx lint-staged",
|
|
40
|
+
"commit-msg": "pnpx commitlint -e"
|
|
55
41
|
},
|
|
56
42
|
"dependencies": {
|
|
43
|
+
"@types/node-fetch": "^2.5.11",
|
|
57
44
|
"base64url": "^3.0.1",
|
|
58
|
-
"dayjs": "^1.
|
|
59
|
-
"
|
|
60
|
-
"
|
|
45
|
+
"dayjs": "^1.10.6",
|
|
46
|
+
"decimal.js": "^10.3.1",
|
|
47
|
+
"fast-xml-parser": "^4.0.0",
|
|
48
|
+
"node-fetch": "^2.6.1",
|
|
49
|
+
"tslib": "^2.3.0"
|
|
61
50
|
},
|
|
62
51
|
"devDependencies": {
|
|
63
|
-
"@commitlint/cli": "^
|
|
64
|
-
"@commitlint/config-conventional": "^
|
|
65
|
-
"@koa/router": "^
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"@types/
|
|
70
|
-
"@types/
|
|
71
|
-
"@types/
|
|
72
|
-
"@types/
|
|
73
|
-
"@types/
|
|
74
|
-
"@
|
|
75
|
-
"@typescript-eslint/
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"eslint
|
|
79
|
-
"eslint-
|
|
80
|
-
"eslint-plugin-
|
|
81
|
-
"eslint-plugin-
|
|
52
|
+
"@commitlint/cli": "^12.1.4",
|
|
53
|
+
"@commitlint/config-conventional": "^12.1.4",
|
|
54
|
+
"@koa/router": "^10.0.0",
|
|
55
|
+
"@microsoft/api-documenter": "^7.13.33",
|
|
56
|
+
"@microsoft/api-extractor": "^7.18.4",
|
|
57
|
+
"@rollup/plugin-node-resolve": "^13.0.2",
|
|
58
|
+
"@types/bluebird": "^3.5.36",
|
|
59
|
+
"@types/cheerio": "^0.22.30",
|
|
60
|
+
"@types/jest": "^26.0.24",
|
|
61
|
+
"@types/koa": "^2.13.4",
|
|
62
|
+
"@types/koa-bodyparser": "^4.3.2",
|
|
63
|
+
"@types/koa__router": "^8.0.7",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^4.28.3",
|
|
65
|
+
"@typescript-eslint/parser": "^4.28.3",
|
|
66
|
+
"cheerio": "^1.0.0-rc.10",
|
|
67
|
+
"eslint": "^7.30.0",
|
|
68
|
+
"eslint-config-standard-with-typescript": "^20.0.0",
|
|
69
|
+
"eslint-plugin-html": "^6.1.2",
|
|
70
|
+
"eslint-plugin-import": "^2.23.4",
|
|
71
|
+
"eslint-plugin-jest": "^24.3.6",
|
|
82
72
|
"eslint-plugin-node": "^11.1.0",
|
|
83
|
-
"eslint-plugin-promise": "^
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"jest": "^26.6.3",
|
|
87
|
-
"koa": "^2.13.0",
|
|
73
|
+
"eslint-plugin-promise": "^5.1.0",
|
|
74
|
+
"jest": "^27.0.6",
|
|
75
|
+
"koa": "^2.13.1",
|
|
88
76
|
"koa-bodyparser": "^4.3.0",
|
|
89
|
-
"lint-staged": "^
|
|
90
|
-
"
|
|
77
|
+
"lint-staged": "^11.0.1",
|
|
78
|
+
"markdown-magic": "^2.3.2",
|
|
91
79
|
"rimraf": "^3.0.2",
|
|
92
|
-
"rollup": "^2.
|
|
93
|
-
"rollup-plugin-typescript2": "^0.
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
80
|
+
"rollup": "^2.53.2",
|
|
81
|
+
"rollup-plugin-typescript2": "^0.30.0",
|
|
82
|
+
"simple-git-hooks": "^2.5.1",
|
|
83
|
+
"standard-version": "^9.3.1",
|
|
84
|
+
"ts-expect": "^1.3.0",
|
|
85
|
+
"ts-jest": "^27.0.3",
|
|
86
|
+
"typescript": "^4.3.5"
|
|
98
87
|
},
|
|
99
88
|
"jest": {
|
|
100
89
|
"preset": "ts-jest/presets/js-with-ts",
|
|
101
90
|
"testEnvironment": "node",
|
|
102
91
|
"testMatch": [
|
|
103
92
|
"<rootDir>/test/unit/**/*.test.ts",
|
|
104
|
-
"<rootDir>/test/integration/**/*.test.ts"
|
|
93
|
+
"<rootDir>/test/integration/**/*.test.ts",
|
|
94
|
+
"<rootDir>/src/**/*.test.ts"
|
|
105
95
|
],
|
|
106
96
|
"setupFilesAfterEnv": [
|
|
107
97
|
"./test/jest.setup.ts"
|
|
@@ -110,9 +100,25 @@
|
|
|
110
100
|
"ts-jest": {
|
|
111
101
|
"tsconfig": "./tsconfig.test.json"
|
|
112
102
|
}
|
|
103
|
+
},
|
|
104
|
+
"moduleNameMapper": {
|
|
105
|
+
"redsys-easy": "<rootDir>/src"
|
|
113
106
|
}
|
|
114
107
|
},
|
|
115
|
-
"
|
|
116
|
-
"
|
|
108
|
+
"scripts": {
|
|
109
|
+
"lint": "eslint --ext js,ts .",
|
|
110
|
+
"build:clean": "rimraf lib",
|
|
111
|
+
"build:code": "rollup -c rollup.config.js",
|
|
112
|
+
"build:api": "api-extractor run --local",
|
|
113
|
+
"build": "pnpm run build:clean && pnpm run lint && pnpm run build:code && pnpm run build:api",
|
|
114
|
+
"test:unit": "jest ./src/*.test.ts ./src/**/*.test.ts",
|
|
115
|
+
"test:integration": "jest ./test/integration/**/*.test.ts",
|
|
116
|
+
"test:code": "jest",
|
|
117
|
+
"test:readme": "tsc -p ./tsconfig.readme.json",
|
|
118
|
+
"test": "pnpm run test:code && pnpm run test:readme",
|
|
119
|
+
"docs:api": "api-documenter markdown --input-folder ./api/temp --output-folder ./docs",
|
|
120
|
+
"docs:readme": "md-magic --path ./README.md",
|
|
121
|
+
"docs": "pnpm run docs:api && pnpm run docs:readme",
|
|
122
|
+
"release": "pnpm run test && standard-version --dry-run && pnpm run docs && standard-version --commit-all"
|
|
117
123
|
}
|
|
118
|
-
}
|
|
124
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
-
|
|
5
|
-
## [3.1.0] (2020-12-03)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### Features
|
|
9
|
-
|
|
10
|
-
* typescript, rollup and tests ([a3f97ec](https://github.com/javiertury/redsys-easy/commit/a3f97ec81cd6140a25dff759d55f5cd74bb867d9))
|
|
11
|
-
- Generate CommonJS and ESM output
|
|
12
|
-
* tests for types ([a45d76f](https://github.com/javiertury/redsys-easy/commit/a45d76fa2610b0ac3d2418a76951ecb8e643f523))
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
### Bug Fixes
|
|
16
|
-
|
|
17
|
-
- Fill 3D Secure form in redirection test
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
## [3.0.1]
|
|
21
|
-
|
|
22
|
-
### Fixed
|
|
23
|
-
|
|
24
|
-
- Length of encrypted 3des message is now limited
|
|
25
|
-
|
|
26
|
-
## [3.0.0]
|
|
27
|
-
|
|
28
|
-
### Changed
|
|
29
|
-
|
|
30
|
-
- Removed internal parameters in the form of *paramInt*. User the new *raw* property instead.
|
|
31
|
-
- securePayment returns a boolean
|
|
32
|
-
- Parameter dateFrecuency renamed to dateFrequency
|
|
33
|
-
- Parameter CVV2 renamed to cvv
|
|
34
|
-
|
|
35
|
-
### Added
|
|
36
|
-
|
|
37
|
-
- A new parameter *raw* can be used to pass an object with redsys parameters that should not be formatted
|
|
38
|
-
- Updated currencies and error codes
|
|
39
|
-
- Add new formatted parameters, some related to paygold
|
|
40
|
-
- New transaction type PAYLINK
|
|
41
|
-
- Examples
|
|
42
|
-
|
|
43
|
-
## [2.0.0]
|
|
44
|
-
|
|
45
|
-
### Changed
|
|
46
|
-
|
|
47
|
-
- Monetary amounts are integers of smallest currency unit
|
|
48
|
-
- Some parameters are split into two: param and paramInt. param uses an ISO format while paramInt uses the internal redsys format. For inputs, paramInt has priority.
|
|
49
|
-
|
|
50
|
-
### Added
|
|
51
|
-
|
|
52
|
-
- Notification and web service response parameters are formatted
|
|
53
|
-
- Random transaction ID generator
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { FormattedResponse, RawResponseParams } from './types/api';
|
|
2
|
-
declare type ResponseFormatter = (obj: FormattedResponse, value: string) => void;
|
|
3
|
-
export declare const responseFormatters: Record<string, ResponseFormatter>;
|
|
4
|
-
export declare const formatResponse: (rawParams: RawResponseParams) => FormattedResponse;
|
|
5
|
-
export {};
|
package/lib/utils.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import TRANSACTION_TYPES from './assets/transaction-types';
|
|
3
|
-
/**
|
|
4
|
-
* Adds padding to a buffer.
|
|
5
|
-
*
|
|
6
|
-
* Rounds up the buffer length to the next block and uses 0 as padding.
|
|
7
|
-
*
|
|
8
|
-
* @params {buffer} buf - Input buffer
|
|
9
|
-
* @params {number} blocksize - Size of block
|
|
10
|
-
* @return {buffer}
|
|
11
|
-
*/
|
|
12
|
-
export declare const zeroPad: (buf: Buffer, blocksize: number) => Buffer;
|
|
13
|
-
/**
|
|
14
|
-
* Encrypt a message using 3DES
|
|
15
|
-
*
|
|
16
|
-
* @params {string} key - Key to encrypt message
|
|
17
|
-
* @params {string} message - Message to be encrypted
|
|
18
|
-
* @return {buffer}
|
|
19
|
-
*/
|
|
20
|
-
export declare const encrypt3DES: (key: string, message: string) => Buffer;
|
|
21
|
-
export declare const sha256Sign: (merchantKey: string, order: string, params: string) => string;
|
|
22
|
-
export { TRANSACTION_TYPES };
|
|
23
|
-
export declare const getResponseCodeMessage: (code: string | number) => string | null;
|
|
24
|
-
export declare const getSISErrorCodeMessage: (code: string) => string | undefined;
|
|
25
|
-
export declare const signedFieldsXMLResponse: string[];
|
|
26
|
-
export declare const unescapeXML: (str: string) => string;
|
|
27
|
-
export declare const escapeXML: (str: string) => string;
|
|
28
|
-
declare type SoapRequest = {
|
|
29
|
-
headers: Record<string, string>;
|
|
30
|
-
body?: string;
|
|
31
|
-
} | {
|
|
32
|
-
headers?: Record<string, string>;
|
|
33
|
-
body: string;
|
|
34
|
-
};
|
|
35
|
-
export declare const detectSoapVersion: (req: SoapRequest) => "1.2" | "1.1";
|
|
36
|
-
export declare const mimicSoapNotificationReceiver: (xml: string) => string;
|
|
37
|
-
export declare const mimicSoap11NotificationResponse: (answer: string) => string;
|
|
38
|
-
export declare const mimicSoap12NotificationResponse: (answer: string) => string;
|
|
39
|
-
export declare const randomTransactionId: () => string;
|