Skip to content

Commit bd8fa55

Browse files
authored
Merge pull request #225 from Adyen/develop
Release v2.2.1
2 parents 04747ce + 6d9b176 commit bd8fa55

15 files changed

+2344
-1552
lines changed

package-lock.json

Lines changed: 1611 additions & 891 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adyen/api-library",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"description": "The Adyen API Library for NodeJS enables you to work with Adyen APIs.",
55
"main": "dist/lib/src/index.js",
66
"types": "dist/lib/src/index.d.ts",
@@ -38,24 +38,22 @@
3838
"author": "Ricardo Ambrogi",
3939
"license": "MIT",
4040
"devDependencies": {
41-
"@babel/core": "7.7.7",
42-
"@babel/plugin-proposal-class-properties": "7.7.4",
43-
"@babel/plugin-proposal-object-rest-spread": "7.7.7",
44-
"@babel/plugin-transform-runtime": "7.7.6",
45-
"@babel/plugin-transform-typescript": "7.7.4",
46-
"@babel/preset-env": "7.7.7",
47-
"@babel/preset-typescript": "7.7.7",
48-
"@babel/runtime": "7.7.7",
49-
"@types/jest": "24.0.25",
41+
"@babel/core": "7.8.3",
42+
"@babel/plugin-proposal-class-properties": "7.8.3",
43+
"@babel/plugin-proposal-object-rest-spread": "7.8.3",
44+
"@babel/plugin-transform-runtime": "7.8.3",
45+
"@babel/plugin-transform-typescript": "7.8.3",
46+
"@babel/preset-env": "7.8.3",
47+
"@babel/preset-typescript": "7.8.3",
48+
"@babel/runtime": "7.8.3",
5049
"@types/nock": "10.0.3",
51-
"@types/node": "13.1.4",
52-
"@typescript-eslint/eslint-plugin": "2.15.0",
53-
"@typescript-eslint/parser": "2.15.0",
50+
"@typescript-eslint/eslint-plugin": "2.16.0",
51+
"@typescript-eslint/parser": "2.16.0",
5452
"babel-loader": "8.0.6",
5553
"coveralls": "3.0.9",
5654
"eslint": "6.8.0",
5755
"jest": "24.9.0",
58-
"nock": "11.7.1",
56+
"nock": "11.7.2",
5957
"release-it": "12.4.3",
6058
"ts-jest": "24.3.0",
6159
"ts-loader": "6.2.1",
@@ -64,6 +62,8 @@
6462
"webpack-cli": "3.3.10"
6563
},
6664
"dependencies": {
65+
"@types/node": "13.1.7",
66+
"@types/jest": "24.0.25",
6767
"https-proxy-agent": "4.0.0"
6868
}
6969
}

src/__tests__/checkout.spec.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,16 @@ describe("Checkout", (): void => {
180180
});
181181

182182
it("should have payment session success", async (): Promise<void> => {
183-
const client: Client = createMockClientFromResponse();
184183
scope.post("/paymentSession")
185184
.reply(200, paymentSessionSuccess);
186-
const checkout: Checkout = new Checkout(client);
187185
const paymentSessionRequest: ICheckout.PaymentSetupRequest = createPaymentSessionRequest();
188186
const paymentSessionResponse = await checkout.paymentSession(paymentSessionRequest);
189187
expect(paymentSessionResponse.paymentSession).not.toBeUndefined();
190188
});
191189

192190
it("should have payments result", async (): Promise<void> => {
193-
const client = createMockClientFromResponse();
194191
scope.post("/payments/result")
195192
.reply(200, paymentsResultSuccess);
196-
const checkout = new Checkout(client);
197193
const paymentResultRequest: ICheckout.PaymentVerificationRequest = {
198194
payload: "This is a test payload",
199195
};
@@ -202,22 +198,20 @@ describe("Checkout", (): void => {
202198
});
203199

204200
it("should have missing identifier on live", async (): Promise<void> => {
205-
const client = createMockClientFromResponse();
206201
client.setEnvironment("LIVE");
207202
try {
208203
new Checkout(client);
204+
fail();
209205
} catch (e) {
210206
expect(e.message).toEqual("Please provide your unique live url prefix on the setEnvironment() call on the Client or provide checkoutEndpoint in your config object.");
211207
}
212208
});
213209

214210

215211
it("should succeed on multibanco payment", async (): Promise<void> => {
216-
const client: Client = createMockClientFromResponse();
217212
scope.post("/payments")
218213
.reply(200, paymentsResultMultibancoSuccess);
219214

220-
const checkout: Checkout = new Checkout(client);
221215
const paymentsRequest: ICheckout.PaymentRequest = createPaymentsCheckoutRequest();
222216
const paymentsResponse: ICheckout.PaymentResponse = await checkout.payments(paymentsRequest);
223217
expect(paymentsResponse.pspReference).toEqual("8111111111111111");

src/__tests__/hmacValidator.spec.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,30 @@ const notificationRequestItem: NotificationRequestItem = {
1919
};
2020

2121
describe("HMAC Validator", function (): void {
22+
let hmacValidator: HmacValidator;
23+
beforeEach(() => {
24+
hmacValidator = new HmacValidator();
25+
});
26+
2227
it("should get correct data", function (): void {
23-
const hmacValidator = new HmacValidator();
2428
const dataToSign = hmacValidator.getDataToSign({merchantAccount: "ACC", currencyCode: "EUR"});
2529
expect(dataToSign).toEqual("currencyCode:merchantAccount:EUR:ACC");
2630
});
2731
it("should get correct data with escaped characters", function (): void {
28-
const hmacValidator = new HmacValidator();
2932
const dataToSign = hmacValidator.getDataToSign({currencyCode: "EUR", merchantAccount: "ACC:\\", sessionValidity: "2019-09-21T11:45:24.637Z"});
3033
expect(dataToSign).toEqual("currencyCode:merchantAccount:sessionValidity:EUR:ACC\\:\\\\:2019-09-21T11\\:45\\:24.637Z");
3134
});
3235
it("should encrypt correctly", function (): void {
3336
const data = "countryCode:currencyCode:merchantAccount:merchantReference:paymentAmount:sessionValidity:skinCode:NL:EUR:MagentoMerchantTest2:TEST-PAYMENT-2017-02-01-14\\:02\\:05:199:2017-02-02T14\\:02\\:05+01\\:00:PKz2KML1";
34-
const key = "DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00";
35-
const hmacValidator = new HmacValidator();
36-
const encrypted = hmacValidator.calculateHmac(data, key);
37+
const encrypted = hmacValidator.calculateHmac(data, "DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00");
3738
expect(encrypted).toEqual("34oR8T1whkQWTv9P+SzKyp8zhusf9n0dpqrm9nsqSJs=");
3839
});
3940
it("should get correct data to sign", function (): void {
40-
const hmacValidator = new HmacValidator();
4141
const data = hmacValidator.getDataToSign(notificationRequestItem);
4242
expect(data).toEqual("pspReference:originalReference:merchantAccount:reference:1000:EUR:EVENT:true");
4343
});
4444

4545
it("should have valid hmac", function (): void {
46-
const hmacValidator = new HmacValidator();
4746
const encrypted = hmacValidator.calculateHmac(notificationRequestItem, key);
4847
expect(expectedSign).toEqual(encrypted);
4948
expect(hmacValidator.validateHMAC(notificationRequestItem, key)).toBeTruthy();
@@ -54,7 +53,6 @@ describe("HMAC Validator", function (): void {
5453
...notificationRequestItem,
5554
additionalData: { [ApiConstants.HMAC_SIGNATURE]: "notValidSign" }
5655
};
57-
const hmacValidator = new HmacValidator();
5856
const result = hmacValidator.validateHMAC(invalidNotification, key);
5957
expect(result).toBeFalsy();
6058
});

src/helpers/getJsonResponse.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import Resource from "../services/resource";
2323
import HttpClientException from "../httpClient/httpClientException";
2424
import ApiException from "../services/exception/apiException";
25+
import {IRequest} from "../typings/requestOptions";
2526

2627
async function getJsonResponse<T>(resource: Resource, jsonRequest: T | string, requestOptions?: IRequest.Options): Promise<string>;
2728
async function getJsonResponse<T, R>(resource: Resource, jsonRequest: T | string, requestOptions?: IRequest.Options): Promise<R>;

src/httpClient/clientInterface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { AgentOptions } from "https";
2222
import HttpClientException from "./httpClientException";
2323
import ApiException from "../services/exception/apiException";
2424
import {Config} from "../index";
25+
import {IRequest} from "../typings/requestOptions";
2526

2627
interface ClientInterface {
2728
request(

src/httpClient/httpURLConnectionClient.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {ApiError} from "../typings/apiError";
3333
import ApiException from "../services/exception/apiException";
3434
import ClientInterface from "./clientInterface";
3535
import {ApiConstants} from "../constants/apiConstants";
36+
import {IRequest} from "../typings/requestOptions";
3637

3738
class HttpURLConnectionClient implements ClientInterface {
3839
private static CHARSET = "utf-8";

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* See the LICENSE file for more info.
2020
*/
2121

22+
import "./typings";
23+
2224
export { default as Client } from "./client";
2325
export { default as Config } from "./config";
2426
export * from "./services/";

src/services/checkout.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import PaymentSession from "./resource/checkout/paymentSession";
2929
import PaymentsResult from "./resource/checkout/paymentsResult";
3030
import PaymentLinks from "./resource/checkout/paymentLinks";
3131
import setApplicationInfo from "../helpers/setApplicationInfo";
32+
import {IRequest} from "../typings/requestOptions";
3233

3334
class Checkout extends ApiKeyAuthenticatedService {
3435
private readonly _payments: Payments;

src/services/modification.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import Refund from "./resource/modification/refund";
2929
import TechnicalCancel from "./resource/modification/technicalCancel";
3030
import setApplicationInfo from "../helpers/setApplicationInfo";
3131
import {ApplicationInfo} from "../typings/applicationInfo";
32+
import {IRequest} from "../typings/requestOptions";
3233

3334
interface AppInfo { applicationInfo?: ApplicationInfo }
3435
type GenericRequest<T> = T & AppInfo;

0 commit comments

Comments
 (0)