Skip to content

Commit 45ebfa0

Browse files
authored
Merge pull request #1565 from Adyen/add-openbanking-api
Add Open Banking API
2 parents 2a3b217 + 25a1d47 commit 45ebfa0

26 files changed

+1692
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This library supports the following:
2424
| [Legal Entity Management API](https://docs.adyen.com/api-explorer/legalentity/3/overview) | v3 | Manage legal entities that contain information required for verification. | [LegalEntityManagement](/src/services/legalEntityManagement/index.ts) |
2525
| [Local/Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/terminal-api-reference) | - | Our point-of-sale integration. | [TerminalLocalAPI](/src/services/terminalLocalAPI.ts) or [TerminalCloudAPI](/src/services/terminalCloudAPI.ts) |
2626
| [Management API](https://docs.adyen.com/api-explorer/Management/3/overview) | v3 | Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. | [Management](/src/services/management/index.ts) |
27+
| [Open Banking API](https://docs.adyen.com/api-explorer/open-banking/1/overview) | v1 | The Open Banking API provides secure endpoints to share financial data and services with third parties. | [Open Banking](/src/services/openbanking/index.ts) |
2728
| [Payments API](https://docs.adyen.com/api-explorer/Payment/68/overview) | v68 | Our classic integration for online payments. | [ClassicIntegrationAPI](/src/services/paymentApi.ts) |
2829
| [Payouts API](https://docs.adyen.com/api-explorer/Payout/68/overview) | v68 | Endpoints for sending funds to your customers. | [Payout](/src/services/payout/index.ts) |
2930
| [Platforms APIs](https://docs.adyen.com/platforms/api) | - | Set of APIs when using Adyen for Platforms. This API is used for the classic integration. | [Platforms](/src/services/platforms.ts) |

src/__tests__/openBanking.spec.ts

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import nock from "nock";
2+
import Client from "../client";
3+
import { createClient } from "../__mocks__/base";
4+
import { AccountVerificationApi } from "../services/openBanking/accountVerificationApi";
5+
import {
6+
AccountType,
7+
AccountVerificationCountry,
8+
AccountVerificationReportResponse,
9+
AccountVerificationRoutesRequest,
10+
AccountVerificationRoutesResponse,
11+
PartyRole,
12+
} from "../typings/openBanking/models";
13+
14+
let client: Client;
15+
let accountVerificationApi: AccountVerificationApi;
16+
let scope: nock.Scope;
17+
18+
beforeEach((): void => {
19+
if (!nock.isActive()) {
20+
nock.activate();
21+
}
22+
client = createClient();
23+
scope = nock("https://obgateway-test.adyen.com/obgateway/v1");
24+
accountVerificationApi = new AccountVerificationApi(client);
25+
});
26+
27+
afterEach(() => {
28+
nock.cleanAll();
29+
});
30+
31+
describe("Open Banking", (): void => {
32+
it("should create account verification routes", async (): Promise<void> => {
33+
const request: AccountVerificationRoutesRequest = {
34+
country: AccountVerificationCountry.Nl,
35+
locale: "en-US",
36+
state: "11a1e60a-18b0-4dda-9258-e0ae29e1e2a3",
37+
redirectUrl: "https://merchanturl.example.org/redirect/url",
38+
};
39+
40+
const mockResponse: AccountVerificationRoutesResponse = {
41+
routes: [
42+
{
43+
provider: {
44+
name: "Tink",
45+
logoURL: "https://obgateway.adyen.com/obgateway/static/provider/images/tink-logo.svg",
46+
},
47+
link: "https://obgateway.adyen.com/obgateway/provider/outgoing/tink/redirect/13ec4802-c987-4f8c-8909-9a75ff567256",
48+
},
49+
],
50+
};
51+
52+
scope.post("/accountVerification/routes")
53+
.reply(200, mockResponse);
54+
55+
const response = await accountVerificationApi.createAccountVerificationRoutes(request);
56+
57+
expect(response.routes.length).toBe(1);
58+
expect(response.routes[0].link).toEqual("https://obgateway.adyen.com/obgateway/provider/outgoing/tink/redirect/13ec4802-c987-4f8c-8909-9a75ff567256");
59+
});
60+
61+
it("should get account verification report", async (): Promise<void> => {
62+
const code = "some_code";
63+
const mockResponse: AccountVerificationReportResponse = {
64+
id: "69ee9452ef824fe092f1417f37535755",
65+
country: AccountVerificationCountry.Es,
66+
accounts: [
67+
{
68+
accountId: "ed5080e4f485430290475d246534c8fd",
69+
accountType: AccountType.Current,
70+
accountName: "Checking Account 1",
71+
accountNumber: "ES1376230223254275408743",
72+
currency: "EUR",
73+
identifiers: {
74+
iban: {
75+
iban: "ES1376230223254275408743",
76+
bban: "76230223254275408743",
77+
bic: "BIC001"
78+
},
79+
},
80+
parties: [
81+
{
82+
identity: {
83+
fullLegalName: "Alberta Bobbeth Charleson",
84+
name: "Alberta Bobbeth Charleson",
85+
},
86+
role: PartyRole.Holder,
87+
},
88+
],
89+
bankName: "Tink Demo Bank",
90+
},
91+
],
92+
};
93+
94+
scope.get(`/accountVerification/reports/${code}`)
95+
.reply(200, mockResponse);
96+
97+
const response = await accountVerificationApi.getAccountVerificationReport(code);
98+
99+
expect(response.id).toEqual("69ee9452ef824fe092f1417f37535755");
100+
expect(response.country).toEqual(AccountVerificationCountry.Es);
101+
expect(response.accounts.length).toBe(1);
102+
103+
});
104+
});
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* The version of the OpenAPI document: v1
3+
*
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech
7+
* Do not edit this class manually.
8+
*/
9+
10+
11+
import getJsonResponse from "../../helpers/getJsonResponse";
12+
import Service from "../../service";
13+
import Client from "../../client";
14+
import { IRequest } from "../../typings/requestOptions";
15+
import Resource from "../resource";
16+
17+
import { ObjectSerializer } from "../../typings/openBanking/objectSerializer";
18+
import { AccountVerificationReportResponse } from "../../typings/openBanking/models";
19+
import { AccountVerificationRoutesRequest } from "../../typings/openBanking/models";
20+
import { AccountVerificationRoutesResponse } from "../../typings/openBanking/models";
21+
22+
/**
23+
* API handler for AccountVerificationApi
24+
*/
25+
export class AccountVerificationApi extends Service {
26+
27+
private readonly API_BASEPATH: string = "https://obgateway-test.adyen.com/obgateway/v1";
28+
private baseUrl: string;
29+
30+
public constructor(client: Client){
31+
super(client);
32+
this.baseUrl = this.createBaseUrl(this.API_BASEPATH);
33+
}
34+
35+
/**
36+
* @summary Create routes for account verification
37+
* @param accountVerificationRoutesRequest {@link AccountVerificationRoutesRequest }
38+
* @param requestOptions {@link IRequest.Options }
39+
* @return {@link AccountVerificationRoutesResponse }
40+
*/
41+
public async createAccountVerificationRoutes(accountVerificationRoutesRequest: AccountVerificationRoutesRequest, requestOptions?: IRequest.Options): Promise<AccountVerificationRoutesResponse> {
42+
const endpoint = `${this.baseUrl}/accountVerification/routes`;
43+
const resource = new Resource(this, endpoint);
44+
45+
const request: AccountVerificationRoutesRequest = ObjectSerializer.serialize(accountVerificationRoutesRequest, "AccountVerificationRoutesRequest");
46+
const response = await getJsonResponse<AccountVerificationRoutesRequest, AccountVerificationRoutesResponse>(
47+
resource,
48+
request,
49+
{ ...requestOptions, method: "POST" }
50+
);
51+
52+
return ObjectSerializer.deserialize(response, "AccountVerificationRoutesResponse");
53+
}
54+
55+
/**
56+
* @summary Get account verification report
57+
* @param code {@link string } The unique code you receive after a successful open banking flow that is included as a query parameter in the &#x60;redirectUrl&#x60; callback.
58+
* @param requestOptions {@link IRequest.Options }
59+
* @return {@link AccountVerificationReportResponse }
60+
*/
61+
public async getAccountVerificationReport(code: string, requestOptions?: IRequest.Options): Promise<AccountVerificationReportResponse> {
62+
const endpoint = `${this.baseUrl}/accountVerification/reports/{code}`
63+
.replace("{" + "code" + "}", encodeURIComponent(String(code)));
64+
const resource = new Resource(this, endpoint);
65+
66+
const response = await getJsonResponse<string, AccountVerificationReportResponse>(
67+
resource,
68+
"",
69+
{ ...requestOptions, method: "GET" }
70+
);
71+
72+
return ObjectSerializer.deserialize(response, "AccountVerificationReportResponse");
73+
}
74+
75+
}

src/services/openBanking/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* The version of the OpenAPI document: v1
3+
*
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech
7+
* Do not edit this class manually.
8+
*/
9+
10+
import { AccountVerificationApi } from "./accountVerificationApi";
11+
12+
import Service from "../../service";
13+
import Client from "../../client";
14+
15+
export default class OpenBankingAPI extends Service {
16+
17+
public constructor(client: Client) {
18+
super(client);
19+
}
20+
21+
public get AccountVerificationApi() {
22+
return new AccountVerificationApi(this.client);
23+
}
24+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* The version of the OpenAPI document: v1
3+
*
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech
7+
* Do not edit this class manually.
8+
*/
9+
10+
11+
export class ACHAccountIdentifier {
12+
/**
13+
* The account number of the bank account.
14+
*/
15+
"accountNumber": string;
16+
/**
17+
* The [routing number](https://en.wikipedia.org/wiki/ABA_routing_transit_number), without separators or whitespace.
18+
*/
19+
"routingNumber": string;
20+
21+
static readonly discriminator: string | undefined = undefined;
22+
23+
static readonly mapping: {[index: string]: string} | undefined = undefined;
24+
25+
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
26+
{
27+
"name": "accountNumber",
28+
"baseName": "accountNumber",
29+
"type": "string",
30+
"format": ""
31+
},
32+
{
33+
"name": "routingNumber",
34+
"baseName": "routingNumber",
35+
"type": "string",
36+
"format": ""
37+
} ];
38+
39+
static getAttributeTypeMap() {
40+
return ACHAccountIdentifier.attributeTypeMap;
41+
}
42+
43+
public constructor() {
44+
}
45+
}
46+
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* The version of the OpenAPI document: v1
3+
*
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech
7+
* Do not edit this class manually.
8+
*/
9+
10+
import { ACHAccountIdentifier } from "./aCHAccountIdentifier";
11+
import { BACSAccountIdentifier } from "./bACSAccountIdentifier";
12+
import { BSBAccountIdentifier } from "./bSBAccountIdentifier";
13+
import { EFTAccountIdentifier } from "./eFTAccountIdentifier";
14+
import { IBANAccountIdentifier } from "./iBANAccountIdentifier";
15+
import { RIXAccountIdentifier } from "./rIXAccountIdentifier";
16+
17+
18+
export class AccountIdentifiers {
19+
"ach"?: ACHAccountIdentifier | null;
20+
"bacs"?: BACSAccountIdentifier | null;
21+
"bsb"?: BSBAccountIdentifier | null;
22+
"eft"?: EFTAccountIdentifier | null;
23+
"iban"?: IBANAccountIdentifier | null;
24+
"rix"?: RIXAccountIdentifier | null;
25+
26+
static readonly discriminator: string | undefined = undefined;
27+
28+
static readonly mapping: {[index: string]: string} | undefined = undefined;
29+
30+
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
31+
{
32+
"name": "ach",
33+
"baseName": "ach",
34+
"type": "ACHAccountIdentifier | null",
35+
"format": ""
36+
},
37+
{
38+
"name": "bacs",
39+
"baseName": "bacs",
40+
"type": "BACSAccountIdentifier | null",
41+
"format": ""
42+
},
43+
{
44+
"name": "bsb",
45+
"baseName": "bsb",
46+
"type": "BSBAccountIdentifier | null",
47+
"format": ""
48+
},
49+
{
50+
"name": "eft",
51+
"baseName": "eft",
52+
"type": "EFTAccountIdentifier | null",
53+
"format": ""
54+
},
55+
{
56+
"name": "iban",
57+
"baseName": "iban",
58+
"type": "IBANAccountIdentifier | null",
59+
"format": ""
60+
},
61+
{
62+
"name": "rix",
63+
"baseName": "rix",
64+
"type": "RIXAccountIdentifier | null",
65+
"format": ""
66+
} ];
67+
68+
static getAttributeTypeMap() {
69+
return AccountIdentifiers.attributeTypeMap;
70+
}
71+
72+
public constructor() {
73+
}
74+
}
75+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* The version of the OpenAPI document: v1
3+
*
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech
7+
* Do not edit this class manually.
8+
*/
9+
10+
import { Identity } from "./identity";
11+
import { PartyRole } from "./partyRole";
12+
13+
14+
export class AccountParty {
15+
"identity": Identity;
16+
"role": PartyRole;
17+
18+
static readonly discriminator: string | undefined = undefined;
19+
20+
static readonly mapping: {[index: string]: string} | undefined = undefined;
21+
22+
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
23+
{
24+
"name": "identity",
25+
"baseName": "identity",
26+
"type": "Identity",
27+
"format": ""
28+
},
29+
{
30+
"name": "role",
31+
"baseName": "role",
32+
"type": "PartyRole",
33+
"format": ""
34+
} ];
35+
36+
static getAttributeTypeMap() {
37+
return AccountParty.attributeTypeMap;
38+
}
39+
40+
public constructor() {
41+
}
42+
}
43+
44+
export namespace AccountParty {
45+
}

0 commit comments

Comments
 (0)