Skip to content

Commit

Permalink
Merge pull request #794 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 10.0.0
  • Loading branch information
maassenbas committed Oct 28, 2021
2 parents 7b72a28 + 1b0a89c commit 26fcf54
Show file tree
Hide file tree
Showing 177 changed files with 3,926 additions and 964 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This is the officially supported NodeJS library for using Adyen's APIs.
## Integration
The Library supports all APIs under the following services:

* [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v67/overview): Our latest integration for accepting online payments. Current supported version: **v67**
* [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v68/overview): Our latest integration for accepting online payments. Current supported version: **v68**
* [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v64/overview): Our classic integration for online payments. Current supported version: **v64**
* [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v49/overview): Endpoints for managing saved payment details. Current supported version: **v49**
* [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v64/overview): Endpoints for sending funds to your customers. Current supported version: **v64**
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adyen/api-library",
"version": "9.1.0",
"version": "10.0.0",
"description": "The Adyen API Library for NodeJS enables you to work with Adyen APIs.",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
Expand Down Expand Up @@ -47,13 +47,13 @@
"jest-ts-auto-mock": "^2.0.0",
"kind-of": "^6.0.3",
"minimist": ">=1.2.3",
"nock": "13.1.3",
"nock": "13.1.4",
"release-it": "14.11.6",
"ts-auto-mock": "^3.3.5",
"ts-jest": "^27.0.4",
"ts-loader": "8.0.10",
"ttypescript": "^1.5.10",
"typescript": "4.4.3"
"typescript": "4.4.4"
},
"dependencies": {
"https-proxy-agent": "5.0.0"
Expand Down
33 changes: 33 additions & 0 deletions src/__mocks__/checkout/sessionsSuccess.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
* Adyen NodeJS API Library
* Copyright (c) 2020 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/

/* tslint:disable */
export const sessionsSuccess = JSON.stringify({
"amount": {
"currency": "EUR",
"value": 100
},
"countryCode": "NL",
"expiresAt": "2021-10-08T17:28:56+02:00",
"id": "CS841C62BF399F968C",
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
"reference": "YOUR_PAYMENT_REFERENCE",
"returnUrl": "https://your-company.com/checkout?shopperOrder=12xy..",
"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"
});
3 changes: 2 additions & 1 deletion src/__mocks__/notification/authorisationTrue.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"totalFraudScore": "10",
"hmacSignature": "OzDjCMZIsdtDqrZ+cl\/FWC+WdESrorctXTzAzW33dXI=",
"NAME2": " VALUE2 ",
"fraudCheck-6-ShopperIpUsage": "10"
"fraudCheck-6-ShopperIpUsage": "10",
"paymentLinkId": "ABCDEFG"
},
"amount": {
"currency": "EUR",
Expand Down
27 changes: 26 additions & 1 deletion src/__tests__/checkout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {paymentSessionSuccess} from "../__mocks__/checkout/paymentSessionSucess"
import {originKeysSuccess} from "../__mocks__/checkout/originkeysSuccess";
import {paymentsResultMultibancoSuccess} from "../__mocks__/checkout/paymentsResultMultibancoSuccess";
import {paymentsResultSuccess} from "../__mocks__/checkout/paymentsResultSucess";
import {sessionsSuccess} from "../__mocks__/checkout/sessionsSuccess";
import Client from "../client";
import Checkout from "../services/checkout";
import HttpClientException from "../httpClient/httpClientException";
Expand All @@ -46,6 +47,8 @@ import {
PaymentResponse,
PaymentSetupRequest,
PaymentVerificationRequest,
CreateCheckoutSessionRequest,
CreateCheckoutSessionResponse
} from "../typings/checkout/models";

const merchantAccount = process.env.ADYEN_MERCHANT!;
Expand Down Expand Up @@ -141,6 +144,16 @@ function createPaymentLinkRequest(): CreatePaymentLinkRequest {
};
}

function createSessionRequest(): CreateCheckoutSessionRequest {
return {
amount: createAmountObject("USD", 1000),
countryCode: "NL",
merchantAccount,
reference,
returnUrl: "https://your-company.com/...",
};
}

let client: Client;
let checkout: Checkout;
let scope: nock.Scope;
Expand Down Expand Up @@ -339,6 +352,7 @@ describe("Checkout", (): void => {

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

const orderResponse: CheckoutCreateOrderResponse = {
expiresAt,
amount: createAmountObject("USD", 500),
orderData: "mocked_order_data",
remainingAmount: {currency: "USD", value: 500},
resultCode: CheckoutCreateOrderResponse.ResultCodeEnum.Success
Expand All @@ -369,7 +384,7 @@ describe("Checkout", (): void => {
.reply(200, orderResponse);

const createOrderResponse: CheckoutCreateOrderResponse = await checkout.orders(orderRequest);

const orderCancelResponse: CheckoutCancelOrderResponse = {
pspReference: "mocked_psp_ref",
resultCode: CheckoutCancelOrderResponse.ResultCodeEnum.Received
Expand All @@ -386,4 +401,14 @@ describe("Checkout", (): void => {
});
expect(response).toBeTruthy();
});

test.each([false, true])("should create a session. isMock: %p", async (isMock): Promise<void> => {
!isMock && nock.restore();
scope.post("/sessions")
.reply(200, sessionsSuccess);

const sessionsRequest: CreateCheckoutSessionRequest = createSessionRequest();
const sessionsResponse: CreateCheckoutSessionResponse = await checkout.sessions(sessionsRequest);
expect(sessionsResponse.sessionData).toBeTruthy();
});
});
1 change: 1 addition & 0 deletions src/__tests__/notification.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe("Notification Test", function (): void {
expect(NotificationEnum.Authorisation).toEqual(notificationRequestItem.eventCode);
expect(notificationRequestItem.success === SuccessEnum.True).toBeTruthy();
expect(notificationRequestItem.pspReference).toEqual("123456789");
expect(notificationRequestItem.additionalData!.paymentLinkId).toEqual("ABCDEFG");
} else {
fail();
}
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Client {
public static HPP_LIVE = "https://live.adyen.com/hpp";
public static MARKETPAY_ENDPOINT_TEST = "https://cal-test.adyen.com/cal/services";
public static MARKETPAY_ENDPOINT_LIVE = "https://cal-live.adyen.com/cal/services";
public static CHECKOUT_API_VERSION = "v67";
public static CHECKOUT_API_VERSION = "v68";
public static API_VERSION = "v64";
public static RECURRING_API_VERSION = "v49";
public static MARKETPAY_ACCOUNT_API_VERSION = "v6";
Expand Down
26 changes: 25 additions & 1 deletion src/services/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,19 @@ import {
CheckoutCreateOrderRequest,
CheckoutCreateOrderResponse,
CheckoutCancelOrderRequest,
CheckoutCancelOrderResponse
CheckoutCancelOrderResponse,
CreateCheckoutSessionRequest,
CreateCheckoutSessionResponse,
PaymentDonationRequest,
DonationResponse
} from "../typings/checkout/models";

import PaymentLinksId from "./resource/checkout/paymentLinksId";
import PaymentMethodsBalance from "./resource/checkout/paymentMethodsBalance";
import Orders from "./resource/checkout/orders";
import OrdersCancel from "./resource/checkout/ordersCancel";
import Sessions from "./resource/checkout/sessions";
import Donations from "./resource/checkout/donations";

class Checkout extends ApiKeyAuthenticatedService {
private readonly _payments: Payments;
Expand All @@ -68,6 +74,8 @@ class Checkout extends ApiKeyAuthenticatedService {
private readonly _paymentMethodsBalance: PaymentMethodsBalance;
private readonly _orders: Orders;
private readonly _ordersCancel: OrdersCancel;
private readonly _sessions: Sessions;
private readonly _donations: Donations;

public constructor(client: Client) {
super(client);
Expand All @@ -82,6 +90,8 @@ class Checkout extends ApiKeyAuthenticatedService {
this._paymentMethodsBalance = new PaymentMethodsBalance(this);
this._orders = new Orders(this);
this._ordersCancel = new OrdersCancel(this);
this._sessions = new Sessions(this);
this._donations = new Donations(this);
}

public payments(paymentsRequest: PaymentRequest, requestOptions?: IRequest.Options): Promise<PaymentResponse> {
Expand Down Expand Up @@ -177,6 +187,20 @@ class Checkout extends ApiKeyAuthenticatedService {
ordersCancelRequest,
);
}

public sessions(checkoutSessionRequest: CreateCheckoutSessionRequest): Promise<CreateCheckoutSessionResponse> {
return getJsonResponse<CreateCheckoutSessionRequest, CreateCheckoutSessionResponse>(
this._sessions,
checkoutSessionRequest,
);
}

public donations(donationRequest: PaymentDonationRequest): Promise<DonationResponse> {
return getJsonResponse<PaymentDonationRequest, DonationResponse>(
this._donations,
donationRequest,
);
}
}

export default Checkout;
33 changes: 33 additions & 0 deletions src/services/resource/checkout/donations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
* Adyen NodeJS API Library
* Copyright (c) 2020 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/

import Client from "../../../client";
import Service from "../../../service";
import Resource from "../../resource";

class Donations extends Resource {
public constructor(service: Service) {
super(
service,
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/donations`,
);
}
}

export default Donations;
33 changes: 33 additions & 0 deletions src/services/resource/checkout/sessions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
* Adyen NodeJS API Library
* Copyright (c) 2020 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/

import Client from "../../../client";
import Service from "../../../service";
import Resource from "../../resource";

class Sessions extends Resource {
public constructor(service: Service) {
super(
service,
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/sessions`,
);
}
}

export default Sessions;
6 changes: 4 additions & 2 deletions src/typings/checkout/accountInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@

/**
* Adyen Checkout API
* Adyen Checkout API provides a simple and flexible way to initiate and authorise online payments. You can use the same integration for payments made with cards (including 3D Secure), mobile wallets, and local payment methods (for example, iDEAL and Sofort). This API reference provides information on available endpoints and how to interact with them. To learn more about the API, visit [Checkout documentation](https://docs.adyen.com/online-payments). ## Authentication Each request to the Checkout API must be signed with an API key. For this, obtain an API Key from your Customer Area, as described in [How to get the API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key). Then set this key to the `X-API-Key` header value, for example: ``` curl -H \"Content-Type: application/json\" \\ -H \"X-API-Key: Your_Checkout_API_key\" \\ ... ``` Note that when going live, you need to generate a new API Key to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning Checkout API supports versioning of its endpoints through a version suffix in the endpoint URL. This suffix has the following format: \"vXX\", where XX is the version number. For example: ``` https://checkout-test.adyen.com/v67/payments ```
* Adyen Checkout API provides a simple and flexible way to initiate and authorise online payments. You can use the same integration for payments made with cards (including 3D Secure), mobile wallets, and local payment methods (for example, iDEAL and Sofort). This API reference provides information on available endpoints and how to interact with them. To learn more about the API, visit [Checkout documentation](https://docs.adyen.com/online-payments). ## Authentication Each request to the Checkout API must be signed with an API key. For this, obtain an API Key from your Customer Area, as described in [How to get the API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key). Then set this key to the `X-API-Key` header value, for example: ``` curl -H \"Content-Type: application/json\" \\ -H \"X-API-Key: Your_Checkout_API_key\" \\ ... ``` Note that when going live, you need to generate a new API Key to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning Checkout API supports versioning of its endpoints through a version suffix in the endpoint URL. This suffix has the following format: \"vXX\", where XX is the version number. For example: ``` https://checkout-test.adyen.com/v68/payments ```
*
* The version of the OpenAPI document: 67
* The version of the OpenAPI document: 68
* Contact: developer-experience@adyen.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/



export class AccountInfo {
/**
* Indicator for the length of time since this shopper account was created in the merchant\'s environment. Allowed values: * notApplicable * thisTransaction * lessThan30Days * from30To60Days * moreThan60Days
Expand Down

0 comments on commit 26fcf54

Please sign in to comment.