Skip to content

Commit 26fcf54

Browse files
authored
Merge pull request #794 from Adyen/develop
Release 10.0.0
2 parents 7b72a28 + 1b0a89c commit 26fcf54

File tree

177 files changed

+3926
-964
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+3926
-964
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This is the officially supported NodeJS library for using Adyen's APIs.
1313
## Integration
1414
The Library supports all APIs under the following services:
1515

16-
* [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v67/overview): Our latest integration for accepting online payments. Current supported version: **v67**
16+
* [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v68/overview): Our latest integration for accepting online payments. Current supported version: **v68**
1717
* [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v64/overview): Our classic integration for online payments. Current supported version: **v64**
1818
* [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v49/overview): Endpoints for managing saved payment details. Current supported version: **v49**
1919
* [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v64/overview): Endpoints for sending funds to your customers. Current supported version: **v64**

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adyen/api-library",
3-
"version": "9.1.0",
3+
"version": "10.0.0",
44
"description": "The Adyen API Library for NodeJS enables you to work with Adyen APIs.",
55
"main": "lib/src/index.js",
66
"types": "lib/src/index.d.ts",
@@ -47,13 +47,13 @@
4747
"jest-ts-auto-mock": "^2.0.0",
4848
"kind-of": "^6.0.3",
4949
"minimist": ">=1.2.3",
50-
"nock": "13.1.3",
50+
"nock": "13.1.4",
5151
"release-it": "14.11.6",
5252
"ts-auto-mock": "^3.3.5",
5353
"ts-jest": "^27.0.4",
5454
"ts-loader": "8.0.10",
5555
"ttypescript": "^1.5.10",
56-
"typescript": "4.4.3"
56+
"typescript": "4.4.4"
5757
},
5858
"dependencies": {
5959
"https-proxy-agent": "5.0.0"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* ######
3+
* ######
4+
* ############ ####( ###### #####. ###### ############ ############
5+
* ############# #####( ###### #####. ###### ############# #############
6+
* ###### #####( ###### #####. ###### ##### ###### ##### ######
7+
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
8+
* ###### ###### #####( ###### #####. ###### ##### ##### ######
9+
* ############# ############# ############# ############# ##### ######
10+
* ############ ############ ############# ############ ##### ######
11+
* ######
12+
* #############
13+
* ############
14+
* Adyen NodeJS API Library
15+
* Copyright (c) 2020 Adyen B.V.
16+
* This file is open source and available under the MIT license.
17+
* See the LICENSE file for more info.
18+
*/
19+
20+
/* tslint:disable */
21+
export const sessionsSuccess = JSON.stringify({
22+
"amount": {
23+
"currency": "EUR",
24+
"value": 100
25+
},
26+
"countryCode": "NL",
27+
"expiresAt": "2021-10-08T17:28:56+02:00",
28+
"id": "CS841C62BF399F968C",
29+
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
30+
"reference": "YOUR_PAYMENT_REFERENCE",
31+
"returnUrl": "https://your-company.com/checkout?shopperOrder=12xy..",
32+
"sessionData": "Ab02b4c0!BQABAgAeRei/Zyr+UYwMcTlHkeYjwn143zTmCmDmWwBg+gZr8us16qqoeVFon6NexiKmZLurm05iRiLagbIIS8BtFzvtX5myx4m0N1vBJWZRDZKHP3g4cyXjEnTnK0CmNsX0bDeojkHU4qChCkn1jIux/rSSp2IIBqe1SfbGVRC9bM17Nj90fJPBxp5MFMw7HKpuvlRNj8CncKPAyPhd4pY+O3GKTiFoZKpx/kVKO7PnILEC07q4rqEzVjSW2U5ADcnR+mJ8V0YVn8Yy4KqNLn68GKMHXe2+NRvidA/UC72F72dOtV1bqxRr/0G6bCW7iuxve+M0IYZ3apHbgS1vWcvUaOI7n1u02M6SWsZDcKgsaT0PoxQkUvdU3ViG7f7Xtac8pjcOxAzhtug/B6Qx/zaTUIWBRKQM5Ga9T7Vo9s9I1Kgv3zuQqeN9OiUhB1mvoxfSPkKYTVjYooj4CELNy9+xuU8/TI+XqK24FIiTacvcJ8Vt0RCSWcE47AG4qiKPBFcBMwpUfz78ud/gu4uBHtt/bh5vJu5GG462tr5W3a/5CeGDX37sqTnrUGom86daTll+kbKo3rC4CH8+K245XNIvIVXLUGrci52lzm09ptPEh/Aj8uBGHLA4Cc0ILAi3rxI5nNcurgbAZiZ7QA3iBEih4euVXBZmKRIfY2U0ijEQLBo8mBDuOjj4GNFT2XrRVs2rwhldAEp7ImtleSI6IkFGMEFBQTEwM0NBNTM3RUFFRDg3QzI0REQ1MzkwOUI4MEE3OEE5MjNFMzgyM0Q2OERBQ0M5NEI5RkY4MzA1REMifWHVSkL3b2GTohsmKmsBVvRtOiDyOWBpV+mylCFs/EQuj7PFJBVjaLoIq1Prk4hZFhBzEf7SsQYHzfTr+BKFH+6fblTW4ObszU3YwF6ehRDaLYxv4sPdVPdguWcuxIvzRenzPlGWu78z6cj1ROHNE3uREUgmVYf9ERbMm8OKJ/uqS1pMPvCYcHIJ0IrXbloQhKaSZdJNmsjGFbfBW8Tr29foxKH280TjbauaZydPWsEuEUIyeWYFBMoozW7de/6RLrDhnQEn/We/6EmsL86QzG+JSkBFloTFo2kdttqA9dfK0l7U3HjtEXmNBFy13DTr5tJcYMz+IcTwe0PqPCgUR+MZDOpAOFc1uHdccok7sttiV4K4xTKkpThiCgrAqklNoD7UcctS5c7RaNQxrwHM5orI0vkGG2hzDXKOUNw4068u"
33+
});

src/__mocks__/notification/authorisationTrue.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"totalFraudScore": "10",
1212
"hmacSignature": "OzDjCMZIsdtDqrZ+cl\/FWC+WdESrorctXTzAzW33dXI=",
1313
"NAME2": " VALUE2 ",
14-
"fraudCheck-6-ShopperIpUsage": "10"
14+
"fraudCheck-6-ShopperIpUsage": "10",
15+
"paymentLinkId": "ABCDEFG"
1516
},
1617
"amount": {
1718
"currency": "EUR",

src/__tests__/checkout.spec.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {paymentSessionSuccess} from "../__mocks__/checkout/paymentSessionSucess"
2626
import {originKeysSuccess} from "../__mocks__/checkout/originkeysSuccess";
2727
import {paymentsResultMultibancoSuccess} from "../__mocks__/checkout/paymentsResultMultibancoSuccess";
2828
import {paymentsResultSuccess} from "../__mocks__/checkout/paymentsResultSucess";
29+
import {sessionsSuccess} from "../__mocks__/checkout/sessionsSuccess";
2930
import Client from "../client";
3031
import Checkout from "../services/checkout";
3132
import HttpClientException from "../httpClient/httpClientException";
@@ -46,6 +47,8 @@ import {
4647
PaymentResponse,
4748
PaymentSetupRequest,
4849
PaymentVerificationRequest,
50+
CreateCheckoutSessionRequest,
51+
CreateCheckoutSessionResponse
4952
} from "../typings/checkout/models";
5053

5154
const merchantAccount = process.env.ADYEN_MERCHANT!;
@@ -141,6 +144,16 @@ function createPaymentLinkRequest(): CreatePaymentLinkRequest {
141144
};
142145
}
143146

147+
function createSessionRequest(): CreateCheckoutSessionRequest {
148+
return {
149+
amount: createAmountObject("USD", 1000),
150+
countryCode: "NL",
151+
merchantAccount,
152+
reference,
153+
returnUrl: "https://your-company.com/...",
154+
};
155+
}
156+
144157
let client: Client;
145158
let checkout: Checkout;
146159
let scope: nock.Scope;
@@ -339,6 +352,7 @@ describe("Checkout", (): void => {
339352

340353
const orderResponse: CheckoutCreateOrderResponse = {
341354
expiresAt,
355+
amount: createAmountObject("USD", 500),
342356
orderData: "mocked_order_data",
343357
remainingAmount: {currency: "USD", value: 500} ,
344358
resultCode: CheckoutCreateOrderResponse.ResultCodeEnum.Success
@@ -361,6 +375,7 @@ describe("Checkout", (): void => {
361375

362376
const orderResponse: CheckoutCreateOrderResponse = {
363377
expiresAt,
378+
amount: createAmountObject("USD", 500),
364379
orderData: "mocked_order_data",
365380
remainingAmount: {currency: "USD", value: 500},
366381
resultCode: CheckoutCreateOrderResponse.ResultCodeEnum.Success
@@ -369,7 +384,7 @@ describe("Checkout", (): void => {
369384
.reply(200, orderResponse);
370385

371386
const createOrderResponse: CheckoutCreateOrderResponse = await checkout.orders(orderRequest);
372-
387+
373388
const orderCancelResponse: CheckoutCancelOrderResponse = {
374389
pspReference: "mocked_psp_ref",
375390
resultCode: CheckoutCancelOrderResponse.ResultCodeEnum.Received
@@ -386,4 +401,14 @@ describe("Checkout", (): void => {
386401
});
387402
expect(response).toBeTruthy();
388403
});
404+
405+
test.each([false, true])("should create a session. isMock: %p", async (isMock): Promise<void> => {
406+
!isMock && nock.restore();
407+
scope.post("/sessions")
408+
.reply(200, sessionsSuccess);
409+
410+
const sessionsRequest: CreateCheckoutSessionRequest = createSessionRequest();
411+
const sessionsResponse: CreateCheckoutSessionResponse = await checkout.sessions(sessionsRequest);
412+
expect(sessionsResponse.sessionData).toBeTruthy();
413+
});
389414
});

src/__tests__/notification.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe("Notification Test", function (): void {
3737
expect(NotificationEnum.Authorisation).toEqual(notificationRequestItem.eventCode);
3838
expect(notificationRequestItem.success === SuccessEnum.True).toBeTruthy();
3939
expect(notificationRequestItem.pspReference).toEqual("123456789");
40+
expect(notificationRequestItem.additionalData!.paymentLinkId).toEqual("ABCDEFG");
4041
} else {
4142
fail();
4243
}

src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Client {
5252
public static HPP_LIVE = "https://live.adyen.com/hpp";
5353
public static MARKETPAY_ENDPOINT_TEST = "https://cal-test.adyen.com/cal/services";
5454
public static MARKETPAY_ENDPOINT_LIVE = "https://cal-live.adyen.com/cal/services";
55-
public static CHECKOUT_API_VERSION = "v67";
55+
public static CHECKOUT_API_VERSION = "v68";
5656
public static API_VERSION = "v64";
5757
public static RECURRING_API_VERSION = "v49";
5858
public static MARKETPAY_ACCOUNT_API_VERSION = "v6";

src/services/checkout.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,19 @@ import {
4848
CheckoutCreateOrderRequest,
4949
CheckoutCreateOrderResponse,
5050
CheckoutCancelOrderRequest,
51-
CheckoutCancelOrderResponse
51+
CheckoutCancelOrderResponse,
52+
CreateCheckoutSessionRequest,
53+
CreateCheckoutSessionResponse,
54+
PaymentDonationRequest,
55+
DonationResponse
5256
} from "../typings/checkout/models";
5357

5458
import PaymentLinksId from "./resource/checkout/paymentLinksId";
5559
import PaymentMethodsBalance from "./resource/checkout/paymentMethodsBalance";
5660
import Orders from "./resource/checkout/orders";
5761
import OrdersCancel from "./resource/checkout/ordersCancel";
62+
import Sessions from "./resource/checkout/sessions";
63+
import Donations from "./resource/checkout/donations";
5864

5965
class Checkout extends ApiKeyAuthenticatedService {
6066
private readonly _payments: Payments;
@@ -68,6 +74,8 @@ class Checkout extends ApiKeyAuthenticatedService {
6874
private readonly _paymentMethodsBalance: PaymentMethodsBalance;
6975
private readonly _orders: Orders;
7076
private readonly _ordersCancel: OrdersCancel;
77+
private readonly _sessions: Sessions;
78+
private readonly _donations: Donations;
7179

7280
public constructor(client: Client) {
7381
super(client);
@@ -82,6 +90,8 @@ class Checkout extends ApiKeyAuthenticatedService {
8290
this._paymentMethodsBalance = new PaymentMethodsBalance(this);
8391
this._orders = new Orders(this);
8492
this._ordersCancel = new OrdersCancel(this);
93+
this._sessions = new Sessions(this);
94+
this._donations = new Donations(this);
8595
}
8696

8797
public payments(paymentsRequest: PaymentRequest, requestOptions?: IRequest.Options): Promise<PaymentResponse> {
@@ -177,6 +187,20 @@ class Checkout extends ApiKeyAuthenticatedService {
177187
ordersCancelRequest,
178188
);
179189
}
190+
191+
public sessions(checkoutSessionRequest: CreateCheckoutSessionRequest): Promise<CreateCheckoutSessionResponse> {
192+
return getJsonResponse<CreateCheckoutSessionRequest, CreateCheckoutSessionResponse>(
193+
this._sessions,
194+
checkoutSessionRequest,
195+
);
196+
}
197+
198+
public donations(donationRequest: PaymentDonationRequest): Promise<DonationResponse> {
199+
return getJsonResponse<PaymentDonationRequest, DonationResponse>(
200+
this._donations,
201+
donationRequest,
202+
);
203+
}
180204
}
181205

182206
export default Checkout;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* ######
3+
* ######
4+
* ############ ####( ###### #####. ###### ############ ############
5+
* ############# #####( ###### #####. ###### ############# #############
6+
* ###### #####( ###### #####. ###### ##### ###### ##### ######
7+
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
8+
* ###### ###### #####( ###### #####. ###### ##### ##### ######
9+
* ############# ############# ############# ############# ##### ######
10+
* ############ ############ ############# ############ ##### ######
11+
* ######
12+
* #############
13+
* ############
14+
* Adyen NodeJS API Library
15+
* Copyright (c) 2020 Adyen B.V.
16+
* This file is open source and available under the MIT license.
17+
* See the LICENSE file for more info.
18+
*/
19+
20+
import Client from "../../../client";
21+
import Service from "../../../service";
22+
import Resource from "../../resource";
23+
24+
class Donations extends Resource {
25+
public constructor(service: Service) {
26+
super(
27+
service,
28+
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/donations`,
29+
);
30+
}
31+
}
32+
33+
export default Donations;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* ######
3+
* ######
4+
* ############ ####( ###### #####. ###### ############ ############
5+
* ############# #####( ###### #####. ###### ############# #############
6+
* ###### #####( ###### #####. ###### ##### ###### ##### ######
7+
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
8+
* ###### ###### #####( ###### #####. ###### ##### ##### ######
9+
* ############# ############# ############# ############# ##### ######
10+
* ############ ############ ############# ############ ##### ######
11+
* ######
12+
* #############
13+
* ############
14+
* Adyen NodeJS API Library
15+
* Copyright (c) 2020 Adyen B.V.
16+
* This file is open source and available under the MIT license.
17+
* See the LICENSE file for more info.
18+
*/
19+
20+
import Client from "../../../client";
21+
import Service from "../../../service";
22+
import Resource from "../../resource";
23+
24+
class Sessions extends Resource {
25+
public constructor(service: Service) {
26+
super(
27+
service,
28+
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/sessions`,
29+
);
30+
}
31+
}
32+
33+
export default Sessions;

0 commit comments

Comments
 (0)