redsys-easy 4.0.2 → 5.0.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.
@@ -1,158 +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
- }
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
+ }
@@ -1,13 +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;
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;
@@ -1,24 +1,30 @@
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;
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 | number) => boolean;
16
+ /**
17
+ * Asserts that a response code indicates success
18
+ *
19
+ * @public
20
+ */
21
+ export declare const assertSuccessfulResponseCode: (responseCode: string | number | undefined) => void;
22
+ /**
23
+ * Asserts that response has a code indicating success
24
+ *
25
+ * @public
26
+ */
27
+ export declare const assertSuccessfulResponse: (responseParams: {
28
+ Ds_Response?: string;
29
+ }) => void;
30
+ 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.0.2",
4
+ "version": "5.0.0",
5
5
  "author": "Javier Garcia <javiertury@gmail.com>",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -36,54 +36,53 @@
36
36
  "*.{js,ts}": "eslint"
37
37
  },
38
38
  "simple-git-hooks": {
39
- "pre-commit": "pnpx lint-staged",
40
- "commit-msg": "pnpx commitlint -e"
39
+ "pre-commit": "pnpm exec lint-staged",
40
+ "commit-msg": "pnpm exec commitlint -e"
41
41
  },
42
42
  "dependencies": {
43
- "@types/node-fetch": "^2.5.11",
44
43
  "base64url": "^3.0.1",
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"
44
+ "dayjs": "^1.11.9",
45
+ "decimal.js": "^10.4.3",
46
+ "fast-xml-parser": "^4.2.7",
47
+ "tslib": "^2.6.1",
48
+ "undici": "^5.23.0"
50
49
  },
51
50
  "devDependencies": {
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",
51
+ "@commitlint/cli": "^17.6.7",
52
+ "@commitlint/config-conventional": "^17.6.7",
53
+ "@koa/router": "^12.0.0",
54
+ "@microsoft/api-documenter": "^7.22.32",
55
+ "@microsoft/api-extractor": "^7.36.3",
56
+ "@rollup/plugin-node-resolve": "^15.1.0",
57
+ "@types/cheerio": "^0.22.31",
58
+ "@types/jest": "^29.5.3",
59
+ "@types/koa": "^2.13.8",
60
+ "@types/koa-bodyparser": "^4.3.10",
61
+ "@types/koa__router": "^12.0.0",
62
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
63
+ "@typescript-eslint/parser": "^5.62.0",
64
+ "cheerio": "1.0.0-rc.12",
65
+ "eslint": "^8.46.0",
66
+ "eslint-config-prettier": "^8.10.0",
67
+ "eslint-config-standard-with-typescript": "^37.0.0",
68
+ "eslint-plugin-html": "^7.1.0",
69
+ "eslint-plugin-import": "^2.28.0",
70
+ "eslint-plugin-jest": "^27.2.3",
72
71
  "eslint-plugin-node": "^11.1.0",
73
- "eslint-plugin-promise": "^5.1.0",
74
- "jest": "^27.0.6",
75
- "koa": "^2.13.1",
76
- "koa-bodyparser": "^4.3.0",
77
- "lint-staged": "^11.0.1",
78
- "markdown-magic": "^2.3.2",
79
- "rimraf": "^3.0.2",
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",
72
+ "eslint-plugin-promise": "^6.1.1",
73
+ "jest": "^29.6.2",
74
+ "koa": "^2.14.2",
75
+ "koa-bodyparser": "^4.4.1",
76
+ "lint-staged": "^13.2.3",
77
+ "markdown-magic": "^2.6.1",
78
+ "rimraf": "^5.0.1",
79
+ "rollup": "^3.27.1",
80
+ "rollup-plugin-typescript2": "^0.35.0",
81
+ "simple-git-hooks": "^2.9.0",
82
+ "standard-version": "^9.5.0",
84
83
  "ts-expect": "^1.3.0",
85
- "ts-jest": "^27.0.3",
86
- "typescript": "^4.3.5"
84
+ "ts-jest": "^29.1.1",
85
+ "typescript": "^5.1.6"
87
86
  },
88
87
  "jest": {
89
88
  "preset": "ts-jest/presets/js-with-ts",
@@ -108,7 +107,7 @@
108
107
  "scripts": {
109
108
  "lint": "eslint --ext js,ts .",
110
109
  "build:clean": "rimraf lib",
111
- "build:code": "rollup -c rollup.config.js",
110
+ "build:code": "rollup -c rollup.config.mjs",
112
111
  "build:api": "api-extractor run --local",
113
112
  "build": "pnpm run build:clean && pnpm run lint && pnpm run build:code && pnpm run build:api",
114
113
  "test:unit": "jest ./src/*.test.ts ./src/**/*.test.ts",
@@ -119,6 +118,6 @@
119
118
  "docs:api": "api-documenter markdown --input-folder ./api/temp --output-folder ./docs",
120
119
  "docs:readme": "md-magic --path ./README.md",
121
120
  "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"
121
+ "release": "pnpm run test && standard-version --dry-run && pnpm run docs && git add docs CHANGELOG.md && standard-version --commit-all"
123
122
  }
124
123
  }