mirror of
https://github.com/jlengrand/adyen-node-api-library.git
synced 2026-04-17 08:01:20 +00:00
Compare commits
96 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
409f1fd405 | ||
|
|
b81e4a4e41 | ||
|
|
5594ff573c | ||
|
|
fff61d8eb7 | ||
|
|
15eddcbac2 | ||
|
|
0288acd7a3 | ||
|
|
98b55e9438 | ||
|
|
fae77fc1ca | ||
|
|
36f5d7e920 | ||
|
|
ff993a2e8d | ||
|
|
e5f60ecfed | ||
|
|
0d95a73f41 | ||
|
|
5ebf1966f2 | ||
|
|
63e6e1979c | ||
|
|
7231957e37 | ||
|
|
074a9d708d | ||
|
|
c0d6257573 | ||
|
|
8e3cb93756 | ||
|
|
427427619d | ||
|
|
2463523aaf | ||
|
|
0128f5f89a | ||
|
|
3799f21851 | ||
|
|
1bd4829b7a | ||
|
|
eb6577bb7c | ||
|
|
b7e14948ad | ||
|
|
b70dc70070 | ||
|
|
97f9a5a3bc | ||
|
|
68822e485a | ||
|
|
1ff792277a | ||
|
|
097a6c423b | ||
|
|
842fe1a50b | ||
|
|
11728b3db5 | ||
|
|
c171f7b674 | ||
|
|
431297593f | ||
|
|
0af9e8b589 | ||
|
|
71fd431c46 | ||
|
|
170685f6c4 | ||
|
|
f6a1716714 | ||
|
|
b3dc185851 | ||
|
|
57e3dccb11 | ||
|
|
9a194e7752 | ||
|
|
7e76d1b4c8 | ||
|
|
e5b8b70ecd | ||
|
|
90f0e664b9 | ||
|
|
f87c525cf8 | ||
|
|
61ef73c0d1 | ||
|
|
d89f0974a5 | ||
|
|
282fc30e28 | ||
|
|
8c635a7855 | ||
|
|
edbdd6cc7d | ||
|
|
2f5408d436 | ||
|
|
3ea6181d91 | ||
|
|
5d02fc148b | ||
|
|
8acd312ab0 | ||
|
|
f1e3848439 | ||
|
|
dd56326255 | ||
|
|
0d6406694b | ||
|
|
5742a463ae | ||
|
|
7c49bc466b | ||
|
|
ffa63e8204 | ||
|
|
91f38e0272 | ||
|
|
7cd93d6512 | ||
|
|
0facfe2419 | ||
|
|
37f6085d24 | ||
|
|
437c062788 | ||
|
|
780fb5bbf1 | ||
|
|
db6716a85a | ||
|
|
9e6c216aae | ||
|
|
7d3b2731f6 | ||
|
|
b1fd794054 | ||
|
|
af80b86594 | ||
|
|
fc5010078b | ||
|
|
5385ca5bb6 | ||
|
|
87f87d0181 | ||
|
|
42b71d41a2 | ||
|
|
ec0e711fd8 | ||
|
|
a61f51d43b | ||
|
|
5b8c2b2ff8 | ||
|
|
c30f290aef | ||
|
|
20874e0be1 | ||
|
|
e397e82837 | ||
|
|
b2e376f9ef | ||
|
|
db64524183 | ||
|
|
a838223d85 | ||
|
|
22b3304de8 | ||
|
|
cbdbf2e06c | ||
|
|
ea3cdc0ea1 | ||
|
|
a9a159dea1 | ||
|
|
72fde9df1e | ||
|
|
0f6df1f986 | ||
|
|
892e9c86a3 | ||
|
|
ac658aaa18 | ||
|
|
e0bade95d3 | ||
|
|
f4c62229ff | ||
|
|
07065c35cf | ||
|
|
b2b28a015f |
36
.eslintrc.js
Normal file
36
.eslintrc.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
parser: "@typescript-eslint/parser",
|
||||
plugins: ["@typescript-eslint"],
|
||||
env: {
|
||||
es6: true,
|
||||
node: true
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 6,
|
||||
sourceType: "module",
|
||||
ecmaFeatures: {
|
||||
modules: true
|
||||
},
|
||||
project: path.resolve(__dirname, "./tsconfig.json"),
|
||||
tsconfigRootDir: __dirname
|
||||
},
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
rules: {
|
||||
quotes: ["error", "double"],
|
||||
semi: ["error", "always"]
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ["*.ts"],
|
||||
rules: {
|
||||
"no-dupe-class-members": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"modules": true
|
||||
},
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"rules": {
|
||||
"quotes": ["error", "double"],
|
||||
"semi": ["error", "always"]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts"],
|
||||
"rules": {
|
||||
"no-dupe-class-members": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* @KadoBOT @msilvagarcia @cyattilakiss @rkewlani @Aleffio
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,6 +10,5 @@ node_modules
|
||||
.npm/
|
||||
.ssh/
|
||||
.viminfo
|
||||
local/
|
||||
coverage/
|
||||
dist/
|
||||
|
||||
12
.release-it.json
Normal file
12
.release-it.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"git": {
|
||||
"tagName": "v${version}",
|
||||
"changelog": "npx auto-changelog --stdout --commit-limit false -u"
|
||||
},
|
||||
"github": {
|
||||
"release": true
|
||||
},
|
||||
"hooks": {
|
||||
"after:bump": "npx auto-changelog -p"
|
||||
}
|
||||
}
|
||||
19
.sonarcloud.properties
Normal file
19
.sonarcloud.properties
Normal file
@@ -0,0 +1,19 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Copyright Contributors to the ODPi Egeria project.
|
||||
|
||||
# Path to sources
|
||||
#sonar.sources=.
|
||||
sonar.exclusions=src/__mocks__/*
|
||||
sonar.exclusions=src/typings/*
|
||||
#sonar.inclusions=
|
||||
|
||||
# Path to tests
|
||||
#sonar.tests=
|
||||
#sonar.test.exclusions=
|
||||
#sonar.test.inclusions=
|
||||
|
||||
# Source encoding
|
||||
#sonar.sourceEncoding=UTF-8
|
||||
|
||||
# Exclusions for copy-paste detection
|
||||
#sonar.cpd.exclusions=
|
||||
@@ -4,6 +4,7 @@
|
||||
[](https://www.npmjs.com/package/@adyen/api-library)
|
||||

|
||||
[](https://www.npmjs.com/package/@adyen/api-library)
|
||||
[](https://sonarcloud.io/dashboard?id=Adyen_adyen-node-api-library)
|
||||
|
||||
The Adyen API Library for NodeJS enables you to work with Adyen APIs and Hosted Payment Pages.
|
||||
|
||||
@@ -92,7 +93,3 @@ If you have any problems, questions or suggestions, create an issue here or send
|
||||
## Licence
|
||||
|
||||
MIT license. For more information, see the LICENSE file.
|
||||
|
||||
## Other
|
||||
|
||||
You can find examples inside the `examples` folder in this repo.
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
const TerminalAPI = require("./terminalApi");
|
||||
const terminalAPI = new TerminalAPI();
|
||||
|
||||
const asyncPayment = async () => {
|
||||
console.log("Starting transaction...");
|
||||
const sentRequest = await terminalAPI.paymentRequestAsync();
|
||||
|
||||
console.log("Request sent. Waiting to retrieve status...");
|
||||
setTimeout(async () => {
|
||||
console.log("Retrieving status...");
|
||||
const statusResponse = await terminalAPI.transactionStatusRequestSync(sentRequest);
|
||||
|
||||
const {TransactionStatusResponse} = statusResponse.SaleToPOIResponse;
|
||||
if (TransactionStatusResponse && TransactionStatusResponse.Response.Result === 'Success') {
|
||||
console.log("Response [result:%s data:%s]",
|
||||
statusResponse.SaleToPOIResponse.TransactionStatusResponse.RepeatedMessageResponse.RepeatedResponseMessageBody.PaymentResponse.Response.Result,
|
||||
statusResponse.SaleToPOIResponse.TransactionStatusResponse.RepeatedMessageResponse.RepeatedResponseMessageBody.PaymentResponse.Response.AdditionalResponse
|
||||
);
|
||||
} else {
|
||||
console.log("Response [result:%s]", statusResponse.SaleToPOIResponse.TransactionStatusResponse.Response.Result)
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
const TerminalAPI = require("./terminalApi");
|
||||
const terminalAPI = new TerminalAPI();
|
||||
|
||||
const localPayment = async () => {
|
||||
const paymentsResponse = await terminalAPI.paymentRequestLocal();
|
||||
|
||||
console.log("Response [result:%s data:%s]",
|
||||
paymentsResponse.SaleToPOIResponse.PaymentResponse.Response.Result,
|
||||
paymentsResponse.SaleToPOIResponse.PaymentResponse.Response.AdditionalResponse
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
const TerminalAPI = require("./terminalApi");
|
||||
const terminalAPI = new TerminalAPI();
|
||||
|
||||
const syncPayment = async () => {
|
||||
console.log("Starting transaction...");
|
||||
const paymentsResponse = await terminalAPI.paymentRequestSync();
|
||||
|
||||
console.log("Response [result:%s data:%s]",
|
||||
paymentsResponse.SaleToPOIResponse.PaymentResponse.Response.Result,
|
||||
paymentsResponse.SaleToPOIResponse.PaymentResponse.Response.AdditionalResponse
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
const {Client, Config, TerminalCloudAPI, TerminalLocalAPI} = require("../../src");
|
||||
|
||||
class TerminalApi {
|
||||
terminalCloudAPI;
|
||||
terminalLocalAPI;
|
||||
|
||||
constructor() {
|
||||
const merchantAccount = "[MERCHANT ACCOUNT]";
|
||||
const xApiKey = "[X_API_KEY]";
|
||||
|
||||
const config = new Config();
|
||||
config.merchantAccount = merchantAccount;
|
||||
config.apiKey = xApiKey; // alternatively you can authenticate with your username + password
|
||||
// config.username = "[USERNAME]"
|
||||
// config.password = "[PASSWORD]"
|
||||
|
||||
|
||||
const client = new Client({config});
|
||||
client.setEnvironment("[LIVE | TEST]");
|
||||
|
||||
this.terminalCloudAPI = new TerminalCloudAPI(client);
|
||||
|
||||
const localConfig = new Config();
|
||||
localConfig.merchantAccount = merchantAccount;
|
||||
localConfig.apiKey = xApiKey; // or username + password
|
||||
localConfig.terminalApiLocalEndpoint = "[PROTOCOL]//[TERMINAL_IP]:[PORT]";
|
||||
|
||||
const localClient = new Client({config: localConfig});
|
||||
this.terminalLocalAPI = new TerminalLocalAPI(localClient);
|
||||
}
|
||||
|
||||
async paymentRequestLocal() {
|
||||
const paymentsRequest = this.createPaymentRequest();
|
||||
const securityKey = {
|
||||
keyVersion: 1,
|
||||
adyenCryptoVersion: 1,
|
||||
keyIdentifier: "[CRYPTO_KEY_IDENTIFIER]",
|
||||
passphrase: "[CRYPTO_KEY_PASSPHRASE]"
|
||||
};
|
||||
return this.terminalLocalAPI.request(paymentsRequest, securityKey);
|
||||
}
|
||||
|
||||
paymentRequestSync() {
|
||||
const paymentsRequest = this.createPaymentRequest();
|
||||
|
||||
console.log(`Payment [poiId:${paymentsRequest.SaleToPOIRequest.MessageHeader.POIID} serviceId:${paymentsRequest.SaleToPOIRequest.MessageHeader.ServiceID} saleId:${paymentsRequest.SaleToPOIRequest.MessageHeader.SaleID} amount:${paymentsRequest.SaleToPOIRequest.PaymentRequest.PaymentTransaction.AmountsReq.RequestedAmount} ${paymentsRequest.SaleToPOIRequest.PaymentRequest.PaymentTransaction.AmountsReq.Currency}]`)
|
||||
|
||||
return this.terminalCloudAPI.sync(paymentsRequest);
|
||||
}
|
||||
|
||||
async paymentRequestAsync() {
|
||||
const paymentsRequest = this.createPaymentRequest();
|
||||
|
||||
console.log(`Payment [poiId:${paymentsRequest.SaleToPOIRequest.MessageHeader.POIID} serviceId:${paymentsRequest.SaleToPOIRequest.MessageHeader.ServiceID} saleId:${paymentsRequest.SaleToPOIRequest.MessageHeader.SaleID} amount:${paymentsRequest.SaleToPOIRequest.PaymentRequest.PaymentTransaction.AmountsReq.RequestedAmount} ${paymentsRequest.SaleToPOIRequest.PaymentRequest.PaymentTransaction.AmountsReq.Currency}]`);
|
||||
|
||||
const response = await this.terminalCloudAPI.async(paymentsRequest);
|
||||
|
||||
return response === "ok" ? paymentsRequest : undefined;
|
||||
}
|
||||
|
||||
createPaymentRequest() {
|
||||
const saleToPOIRequest = {};
|
||||
|
||||
const messageHeader = this.createMessageHeader("Payment");
|
||||
saleToPOIRequest.MessageHeader = messageHeader;
|
||||
|
||||
const paymentRequest = {};
|
||||
|
||||
const saleData = {};
|
||||
const transactionIdentification = {};
|
||||
transactionIdentification.TransactionID = "[TRANSACTION_ID]";
|
||||
transactionIdentification.TimeStamp = new Date().toISOString();
|
||||
saleData.SaleTransactionID = transactionIdentification;
|
||||
|
||||
const paymentTransation = {};
|
||||
const amountsReq = {};
|
||||
amountsReq.Currency = "EUR";
|
||||
amountsReq.RequestedAmount = 1;
|
||||
paymentTransation.AmountsReq = amountsReq;
|
||||
|
||||
paymentRequest.SaleData = saleData;
|
||||
paymentRequest.PaymentTransaction = paymentTransation;
|
||||
|
||||
saleToPOIRequest.PaymentRequest = paymentRequest;
|
||||
|
||||
const terminalApiRequest = {};
|
||||
terminalApiRequest.SaleToPOIRequest = saleToPOIRequest;
|
||||
|
||||
return terminalApiRequest;
|
||||
}
|
||||
|
||||
createMessageHeader(messageCategoryType) {
|
||||
const id = new Date().getTime() % 1000000000;
|
||||
|
||||
const messageHeader = {};
|
||||
messageHeader.ProtocolVersion = "3.0";
|
||||
messageHeader.MessageClass = "Service";
|
||||
messageHeader.MessageCategory = messageCategoryType;
|
||||
messageHeader.MessageType = "Request";
|
||||
messageHeader.SaleID = id.toString();
|
||||
messageHeader.ServiceID = id.toString();
|
||||
messageHeader.POIID = "[POI_ID]";
|
||||
|
||||
return messageHeader;
|
||||
}
|
||||
|
||||
createTransactionStatusRequest(paymentRequest) {
|
||||
const saleToPOIRequest = {};
|
||||
|
||||
const messageHeader = this.createMessageHeader("TransactionStatus");
|
||||
saleToPOIRequest.MessageHeader = messageHeader;
|
||||
|
||||
const transactionStatusRequest = {};
|
||||
const messageReference = {};
|
||||
messageReference.MessageCategory = "Payment";
|
||||
messageReference.SaleID = paymentRequest.SaleToPOIRequest.MessageHeader.SaleID;
|
||||
messageReference.ServiceID = paymentRequest.SaleToPOIRequest.MessageHeader.ServiceID;
|
||||
|
||||
transactionStatusRequest.MessageReference = messageReference;
|
||||
|
||||
saleToPOIRequest.TransactionStatusRequest = transactionStatusRequest;
|
||||
|
||||
const terminalAPIRequest = {};
|
||||
terminalAPIRequest.SaleToPOIRequest = saleToPOIRequest;
|
||||
|
||||
return terminalAPIRequest;
|
||||
}
|
||||
|
||||
transactionStatusRequestSync(terminalAPIRequest) {
|
||||
const transactionStatusRequest = this.createTransactionStatusRequest(terminalAPIRequest);
|
||||
return this.terminalCloudAPI.sync(transactionStatusRequest);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TerminalApi;
|
||||
10098
package-lock.json
generated
Normal file
10098
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
44
package.json
44
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@adyen/api-library",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.6",
|
||||
"description": "The Adyen API Library for NodeJS enables you to work with Adyen APIs and Hosted Payment Pages.",
|
||||
"main": "dist/lib/src/index.js",
|
||||
"types": "dist/lib/src/index.d.ts",
|
||||
@@ -32,34 +32,36 @@
|
||||
"test": "jest",
|
||||
"preversion": "npm test",
|
||||
"version": "npm run build && git add -A dist",
|
||||
"postversion": "git push && git push --tags && rm -rf build/temp"
|
||||
"postversion": "git push && git push --tags && rm -rf build/temp",
|
||||
"release": "release-it --no-npm.publish"
|
||||
},
|
||||
"author": "Ricardo Ambrogi",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.5.5",
|
||||
"@babel/core": "7.6.4",
|
||||
"@babel/plugin-proposal-class-properties": "7.5.5",
|
||||
"@babel/plugin-proposal-object-rest-spread": "7.5.5",
|
||||
"@babel/plugin-transform-runtime": "7.5.5",
|
||||
"@babel/preset-env": "7.5.5",
|
||||
"@babel/preset-typescript": "7.3.3",
|
||||
"@babel/runtime": "7.5.5",
|
||||
"@types/jest": "24.0.16",
|
||||
"@babel/plugin-proposal-object-rest-spread": "7.6.2",
|
||||
"@babel/plugin-transform-runtime": "7.6.2",
|
||||
"@babel/preset-env": "7.6.3",
|
||||
"@babel/preset-typescript": "7.6.0",
|
||||
"@babel/runtime": "7.6.3",
|
||||
"@types/jest": "24.0.19",
|
||||
"@types/nock": "10.0.3",
|
||||
"@types/node": "11.13.18",
|
||||
"@typescript-eslint/eslint-plugin": "1.13.0",
|
||||
"@typescript-eslint/parser": "1.13.0",
|
||||
"@types/node": "11.13.22",
|
||||
"@typescript-eslint/eslint-plugin": "2.5.0",
|
||||
"@typescript-eslint/parser": "2.5.0",
|
||||
"babel-loader": "8.0.6",
|
||||
"coveralls": "3.0.5",
|
||||
"eslint": "6.1.0",
|
||||
"jest": "24.8.0",
|
||||
"nock": "11.0.0-beta.31",
|
||||
"ts-loader": "6.0.4",
|
||||
"typescript": "3.5.3",
|
||||
"webpack": "4.39.1",
|
||||
"webpack-cli": "3.3.6"
|
||||
"coveralls": "3.0.7",
|
||||
"eslint": "6.5.1",
|
||||
"jest": "24.9.0",
|
||||
"nock": "11.4.0",
|
||||
"release-it": "12.4.3",
|
||||
"ts-loader": "6.2.0",
|
||||
"typescript": "3.6.4",
|
||||
"webpack": "4.41.2",
|
||||
"webpack-cli": "3.3.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"https-proxy-agent": "2.2.2"
|
||||
"https-proxy-agent": "3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
import nock from "nock";
|
||||
import { createMockClientFromResponse } from "../__mocks__/base";
|
||||
import BinLookup from "../service/binLookup";
|
||||
import BinLookup from "../services/binLookup";
|
||||
import {CostEstimateRequest, ThreeDSAvailabilityRequest} from "../typings/binLookup";
|
||||
import Client from "../client";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
@@ -76,7 +76,7 @@ describe("Bin Lookup", function (): void {
|
||||
};
|
||||
|
||||
scope.post("/get3dsAvailability")
|
||||
.reply(403);
|
||||
.reply(403, JSON.stringify({status: 403, message: "fail", errorCode: "171"}));
|
||||
|
||||
try {
|
||||
await binLookup.get3dsAvailability(threeDSAvailabilityRequest as unknown as ThreeDSAvailabilityRequest);
|
||||
|
||||
86
src/__tests__/checkServerIdentity.spec.ts
Normal file
86
src/__tests__/checkServerIdentity.spec.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
|
||||
import checkServerIdentity from "../helpers/checkServerIdentity";
|
||||
import {PeerCertificate} from "tls";
|
||||
|
||||
const createMockedCertificate = (CN: string): PeerCertificate => ({
|
||||
subjectaltname: "Adyen B.V",
|
||||
infoAccess: {mock: ["any"]},
|
||||
subject:
|
||||
{
|
||||
C: "AB",
|
||||
ST: "AB",
|
||||
L: "City",
|
||||
O: "Company Name",
|
||||
OU: "Mocked Value",
|
||||
CN,
|
||||
},
|
||||
issuer:
|
||||
{
|
||||
C: "AB",
|
||||
ST: "AB",
|
||||
L: "City",
|
||||
O: "Issuer Name",
|
||||
OU: "Issuer",
|
||||
CN: "Issuer CN",
|
||||
},
|
||||
modulus: "ABC123",
|
||||
exponent: "01010101",
|
||||
valid_from: "Nov 19 15:03:32 2018 GMT",
|
||||
valid_to: "Nov 11 15:03:32 2048 GMT",
|
||||
fingerprint: "MOCKED_FINGERPRINT",
|
||||
ext_key_usage: ["1.2.3.4.5.6.7.8"],
|
||||
serialNumber: "1000",
|
||||
raw: Buffer.from("test")
|
||||
});
|
||||
|
||||
describe("Certificate Server Identiy", function () {
|
||||
test.each([
|
||||
["legacy-terminal-certificate", "live"],
|
||||
["legacy-terminal-certificate", "test"],
|
||||
["P400-3123123", "live"],
|
||||
["P400-3123123", "test"],
|
||||
["MODEL-SN", "live"],
|
||||
["MODEL-SN", "test"],
|
||||
])("it should be valid: %s.%s", (prefix, environment) => {
|
||||
const cn = `${prefix}.${environment}.terminal.adyen.com`;
|
||||
const mockedCertificate = createMockedCertificate(cn);
|
||||
expect(checkServerIdentity("any", mockedCertificate)).toBeUndefined();
|
||||
});
|
||||
|
||||
test.each([
|
||||
"INVALID.adyen.com",
|
||||
"terminal.INVALID.com",
|
||||
"terminal.adyen.org",
|
||||
"google.com",
|
||||
"",
|
||||
])("it should fail because invalid domain: %s", (domain) => {
|
||||
const cn = `P400-123123.live.${domain}`;
|
||||
const mockedCertificate = createMockedCertificate(cn);
|
||||
expect(checkServerIdentity("any", mockedCertificate) instanceof Error).toBeTruthy();
|
||||
});
|
||||
|
||||
test.each([
|
||||
"liive", "teest", "lve", "tst", "ANY", "invalid",
|
||||
])("it should fail because invalid environment: %s", (environment) => {
|
||||
const cn = `P400-123123.${environment}.terminal.adyen.com`;
|
||||
const mockedCertificate = createMockedCertificate(cn);
|
||||
expect(checkServerIdentity("any", mockedCertificate) instanceof Error).toBeTruthy();
|
||||
});
|
||||
|
||||
test.each([
|
||||
"legacyy-terminal-certificate", "legacy-terminaal-certificate",
|
||||
"legacy-terminal-certificatee", "P400-", "-123123", "P400--123123", "P400123123",
|
||||
"ANY-ANY-ANY", "ANY", ""
|
||||
])("it should fail because invalid prefix: %s", (prefix) => {
|
||||
const cn = `${prefix}.test.terminal.adyen.com`;
|
||||
const mockedCertificate = createMockedCertificate(cn);
|
||||
expect(checkServerIdentity("any", mockedCertificate) instanceof Error).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should fail if no first part on CN", function () {
|
||||
const cn = "live.terminal.adyen.com";
|
||||
const mockedCertificate = createMockedCertificate(cn);
|
||||
expect(checkServerIdentity("any", mockedCertificate) instanceof Error).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -29,7 +29,7 @@ import {paymentsResultMultibancoSuccess} from "../__mocks__/checkout/paymentsRes
|
||||
import {paymentsResultSuccess} from "../__mocks__/checkout/paymentsResultSucess";
|
||||
import Client from "../client";
|
||||
import { TYPE_SCHEME } from "../typings/constants/apiConstants";
|
||||
import Checkout from "../service/checkout";
|
||||
import Checkout from "../services/checkout";
|
||||
import {
|
||||
Amount,
|
||||
DetailsRequest,
|
||||
@@ -57,7 +57,7 @@ function createPaymentsDetailsRequest(): DetailsRequest {
|
||||
};
|
||||
}
|
||||
|
||||
function createPaymentsCheckoutRequest(): PaymentRequest {
|
||||
export function createPaymentsCheckoutRequest(): PaymentRequest {
|
||||
const paymentMethodDetails = {
|
||||
cvc: "737",
|
||||
expiryMonth: "10",
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
import nock from "nock";
|
||||
import { createMockClientFromResponse } from "../__mocks__/base";
|
||||
import {originKeysSuccess} from "../__mocks__/checkoutUtility/originkeysSuccess";
|
||||
import CheckoutUtility from "../service/checkoutUtility";
|
||||
import CheckoutUtility from "../services/checkoutUtility";
|
||||
import {CheckoutUtilityRequest} from "../typings/checkoutUtility";
|
||||
import Client from "../client";
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ describe("HMAC Validator", function (): void {
|
||||
});
|
||||
it("should get correct data with escaped characters", function (): void {
|
||||
const hmacValidator = new HmacValidator();
|
||||
const dataToSign = hmacValidator.getDataToSign({currencyCode: "EUR", merchantAccount: "ACC:\\"});
|
||||
expect(dataToSign).toEqual("currencyCode:merchantAccount:EUR:ACC\\:\\\\");
|
||||
const dataToSign = hmacValidator.getDataToSign({currencyCode: "EUR", merchantAccount: "ACC:\\", sessionValidity: "2019-09-21T11:45:24.637Z"});
|
||||
expect(dataToSign).toEqual("currencyCode:merchantAccount:sessionValidity:EUR:ACC\\:\\\\:2019-09-21T11\\:45\\:24.637Z");
|
||||
});
|
||||
it("should encrypt correctly", function (): void {
|
||||
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";
|
||||
|
||||
@@ -1,42 +1,51 @@
|
||||
import nock from "nock";
|
||||
import nock, {Interceptor} from "nock";
|
||||
import Client from "../client";
|
||||
import Checkout from "../service/checkout";
|
||||
import ApiException from "../service/exception/apiException";
|
||||
import Checkout from "../services/checkout";
|
||||
import ApiException from "../services/exception/apiException";
|
||||
import {createPaymentsCheckoutRequest} from "./checkout.spec";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
import {Environment} from "../typings/enums/environment";
|
||||
|
||||
beforeEach((): void => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
type errorType = "HttpClientException" | "ApiException";
|
||||
type testOptions = { errorType: errorType; errorMessageContains?: string; errorMessageEquals?: string };
|
||||
|
||||
const getResponse = async ({apiKey , environment }: { apiKey: string; environment: Environment}, cb: (scope: Interceptor) => testOptions) => {
|
||||
const client = new Client({ apiKey, environment });
|
||||
const checkout = new Checkout(client);
|
||||
|
||||
const scope = nock(`${client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}`)
|
||||
.post("/payments");
|
||||
const { errorMessageContains, errorMessageEquals, errorType } = cb(scope);
|
||||
const ErrorException = errorType === "ApiException" ? ApiException : HttpClientException;
|
||||
|
||||
try {
|
||||
await checkout.payments(createPaymentsCheckoutRequest());
|
||||
fail("request should fail");
|
||||
} catch (e) {
|
||||
expect(e instanceof ErrorException).toBeTruthy();
|
||||
if(errorMessageEquals) expect(e.message).toEqual(errorMessageEquals);
|
||||
if(errorMessageContains) expect(e.message.toLowerCase()).toContain(errorMessageContains);
|
||||
}
|
||||
};
|
||||
|
||||
describe("HTTP Client", function (): void {
|
||||
it("should return ApiException when no API Key is provided", async (): Promise<void> => {
|
||||
const client = new Client({apiKey: "", environment: "TEST"});
|
||||
const checkout = new Checkout(client);
|
||||
it.each`
|
||||
apiKey | environment | withError | args | errorType | contains | equals
|
||||
${""} | ${"TEST"} | ${true} | ${["mocked_error_response"]} | ${"ApiException"} | ${"x-api-key"} | ${""}
|
||||
${"MOCKED_API_KEY"} | ${"TEST"} | ${true} | ${["some_error"]} | ${"ApiException"} | ${""} | ${"some_error"}
|
||||
${"API_KEY"} | ${"TEST"} | ${false} | ${[401, { status: 401, message: "Invalid Request", errorCode: "171", errorType: "validationError"}]} | ${"HttpClientException"} | ${""} | ${"HTTP Exception: 401. null: Invalid Request"}
|
||||
${"API_KEY"} | ${"TEST"} | ${false} | ${[401, {}]} | ${"HttpClientException"} | ${""} | ${"HTTP Exception: 401. null"}
|
||||
${"API_KEY"} | ${"TEST"} | ${false} | ${[401, "fail"]} | ${"HttpClientException"} | ${""} | ${"HTTP Exception: 401. null"}
|
||||
`("Should return $errorType, $contains, $equals", async ({ apiKey, environment, withError, args, errorType, contains, equals }) => {
|
||||
await getResponse({ apiKey, environment }, (scope) => {
|
||||
if (withError) scope.replyWithError(args[0]);
|
||||
else scope.reply(args[0], args[1]);
|
||||
|
||||
nock(`${client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}`)
|
||||
.post("/payments")
|
||||
.replyWithError();
|
||||
|
||||
try {
|
||||
await checkout.payments({});
|
||||
} catch (e) {
|
||||
expect(e instanceof ApiException);
|
||||
expect(e.message).toContain("x-api-key");
|
||||
}
|
||||
});
|
||||
|
||||
it("should return ApiException on request error", async (): Promise<void> => {
|
||||
const client = new Client({apiKey: "API_KEY", environment: "TEST"});
|
||||
const checkout = new Checkout(client);
|
||||
|
||||
nock(`${client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}`)
|
||||
.post("/payments")
|
||||
.replyWithError({message: "error_message", statusCode: 500});
|
||||
|
||||
try {
|
||||
await checkout.payments({});
|
||||
} catch (e) {
|
||||
expect(e instanceof ApiException);
|
||||
expect(e.message).toEqual("error_message");
|
||||
}
|
||||
return { errorType, errorMessageContains: contains, errorMessageEquals: equals };
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,10 +1,10 @@
|
||||
import nock from "nock";
|
||||
import { createMockClientFromResponse } from "../__mocks__/base";
|
||||
import Payout from "../service/payout";
|
||||
import Payout from "../services/payout";
|
||||
import {
|
||||
ModifyRequest,
|
||||
StoreDetailAndSubmitRequest,
|
||||
StoreDetailRequest, SubmitRequest
|
||||
StoreDetailRequest, SubmitRequest, PayoutRequest
|
||||
} from "../typings/payout";
|
||||
import { FRAUD_MANUAL_REVIEW, FRAUD_RESULT_TYPE } from "../typings/constants/apiConstants";
|
||||
import Client from "../client";
|
||||
@@ -65,6 +65,17 @@ const mockStoreDetailAndSubmitRequest = (merchantAccount: string): StoreDetailAn
|
||||
...(mockStoreDetailRequest(merchantAccount)),
|
||||
});
|
||||
|
||||
const mockPayoutRequest = (merchantAccount: string): PayoutRequest => ({
|
||||
...amountAndReference,
|
||||
...defaultData,
|
||||
card: {
|
||||
expiryMonth: "10",
|
||||
expiryYear: "2020",
|
||||
holderName: "John Smith",
|
||||
number: "4111111111111111",
|
||||
},
|
||||
merchantAccount,
|
||||
});
|
||||
|
||||
let client: Client;
|
||||
let payout: Payout;
|
||||
@@ -142,4 +153,17 @@ describe("PayoutTest", function (): void {
|
||||
expect(result.response).toEqual("[payout-confirm-received]");
|
||||
expect(result.pspReference).toEqual("8815131762537886");
|
||||
});
|
||||
|
||||
it("should succeed on payout", async function (): Promise<void> {
|
||||
scope.post("/payout").reply(200, {
|
||||
pspReference: "8815131762537886",
|
||||
resultCode: "Received",
|
||||
});
|
||||
|
||||
const request = mockPayoutRequest("MOCKED_MERCHANT_ACC");
|
||||
const result = await payout.payout(request);
|
||||
|
||||
expect(result.resultCode).toEqual("Received");
|
||||
expect(result.pspReference).toEqual("8815131762537886");
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,7 @@ import nock from "nock";
|
||||
import { createMockClientFromResponse } from "../__mocks__/base";
|
||||
import { disableSuccess } from "../__mocks__/recurring/disableSuccess";
|
||||
import { listRecurringDetailsSuccess } from "../__mocks__/recurring/listRecurringDetailsSuccess";
|
||||
import Recurring from "../service/recurring";
|
||||
import Recurring from "../services/recurring";
|
||||
import { DisableRequest, RecurringDetailsRequest } from "../typings/recurring";
|
||||
import Client from "../client";
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import {createMockClientFromResponse, createTerminalAPIPaymentRequest} from "../
|
||||
import {asyncRes} from "../__mocks__/terminalApi/async";
|
||||
import {syncRes} from "../__mocks__/terminalApi/sync";
|
||||
import Client from "../client";
|
||||
import TerminalCloudAPI from "../service/terminalCloudAPI";
|
||||
import {Convert, TerminalApiRequest, TerminalApiResponse} from "../typings/terminal";
|
||||
import TerminalCloudAPI from "../services/terminalCloudAPI";
|
||||
import {Convert, TerminalApiResponse} from "../typings/terminal";
|
||||
|
||||
|
||||
let client: Client;
|
||||
@@ -21,7 +21,7 @@ describe("Terminal Cloud API", (): void => {
|
||||
it("should make an async payment request", async (): Promise<void> => {
|
||||
scope.post("/async").reply(200, asyncRes);
|
||||
|
||||
const terminalAPIPaymentRequest: TerminalApiRequest = createTerminalAPIPaymentRequest() as TerminalApiRequest;
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||
|
||||
const requestResponse: string = await terminalCloudAPI.async(terminalAPIPaymentRequest);
|
||||
|
||||
@@ -32,7 +32,7 @@ describe("Terminal Cloud API", (): void => {
|
||||
const response = Convert.toTerminalApiResponse(syncRes);
|
||||
scope.post("/sync").reply(200, response);
|
||||
|
||||
const terminalAPIPaymentRequest: TerminalApiRequest = createTerminalAPIPaymentRequest() as TerminalApiRequest;
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||
const terminalAPIResponse: TerminalApiResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest);
|
||||
|
||||
expect(terminalAPIResponse).toEqual(response);
|
||||
|
||||
@@ -2,9 +2,9 @@ import nock from "nock";
|
||||
import {createMockClientFromResponse, createTerminalAPIPaymentRequest} from "../__mocks__/base";
|
||||
import {localEncRes, localSecuredRes, wrongEncRes} from "../__mocks__/terminalApi/local";
|
||||
import Client from "../client";
|
||||
import TerminalLocalAPI from "../service/terminalLocalAPI";
|
||||
import {Convert, SecurityKey, TerminalApiRequest, TerminalApiResponse} from "../typings/terminal";
|
||||
import NexoCryptoException from "../service/exception/nexoCryptoException";
|
||||
import TerminalLocalAPI from "../services/terminalLocalAPI";
|
||||
import {Convert, SecurityKey, TerminalApiResponse} from "../typings/terminal";
|
||||
import NexoCryptoException from "../services/exception/nexoCryptoException";
|
||||
|
||||
let client: Client;
|
||||
let terminalLocalAPI: TerminalLocalAPI;
|
||||
@@ -22,7 +22,7 @@ describe("Terminal Local API", (): void => {
|
||||
const response = Convert.toTerminalApiResponse(localSecuredRes);
|
||||
|
||||
scope.post("/").reply(200, securedResponse);
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest() as TerminalApiRequest;
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||
|
||||
const securityKey: SecurityKey = {
|
||||
adyenCryptoVersion: 1,
|
||||
@@ -41,7 +41,7 @@ describe("Terminal Local API", (): void => {
|
||||
const securedResponse = Convert.toTerminalApiSecuredResponse(wrongEncRes);
|
||||
|
||||
scope.post("/").reply(200, securedResponse);
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest() as TerminalApiRequest;
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||
|
||||
const securityKey: SecurityKey = {
|
||||
adyenCryptoVersion: 1,
|
||||
|
||||
@@ -48,29 +48,29 @@ interface ClientParameters {
|
||||
}
|
||||
|
||||
class Client {
|
||||
public static ENDPOINT_TEST: string = "https://pal-test.adyen.com";
|
||||
public static ENDPOINT_LIVE: string = "https://pal-live.adyen.com";
|
||||
public static ENDPOINT_LIVE_SUFFIX: string = "-pal-live.adyenpayments.com";
|
||||
public static HPP_TEST: string = "https://test.adyen.com/hpp";
|
||||
public static HPP_LIVE: string = "https://live.adyen.com/hpp";
|
||||
public static MARKETPAY_ENDPOINT_TEST: string = "https://cal-test.adyen.com/cal/services";
|
||||
public static MARKETPAY_ENDPOINT_LIVE: string = "https://cal-live.adyen.com/cal/services";
|
||||
public static API_VERSION: string = "v49";
|
||||
public static RECURRING_API_VERSION: string = "v30";
|
||||
public static MARKETPAY_ACCOUNT_API_VERSION: string = "v4";
|
||||
public static MARKETPAY_FUND_API_VERSION: string = "v3";
|
||||
public static MARKETPAY_NOTIFICATION_API_VERSION: string = "v1";
|
||||
public static LIB_NAME: string = "adyen-node-api-library";
|
||||
public static ENDPOINT_TEST = "https://pal-test.adyen.com";
|
||||
public static ENDPOINT_LIVE = "https://pal-live.adyen.com";
|
||||
public static ENDPOINT_LIVE_SUFFIX = "-pal-live.adyenpayments.com";
|
||||
public static HPP_TEST = "https://test.adyen.com/hpp";
|
||||
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 API_VERSION = "v49";
|
||||
public static RECURRING_API_VERSION = "v30";
|
||||
public static MARKETPAY_ACCOUNT_API_VERSION = "v4";
|
||||
public static MARKETPAY_FUND_API_VERSION = "v3";
|
||||
public static MARKETPAY_NOTIFICATION_API_VERSION = "v1";
|
||||
public static LIB_NAME = "adyen-node-api-library";
|
||||
public static LIB_VERSION: string = version;
|
||||
public static CHECKOUT_ENDPOINT_TEST: string = "https://checkout-test.adyen.com/checkout";
|
||||
public static CHECKOUT_ENDPOINT_LIVE_SUFFIX: string = "-checkout-live.adyenpayments.com/checkout";
|
||||
public static CHECKOUT_API_VERSION: string = "v49";
|
||||
public static CHECKOUT_ENDPOINT_TEST = "https://checkout-test.adyen.com/checkout";
|
||||
public static CHECKOUT_ENDPOINT_LIVE_SUFFIX = "-checkout-live.adyenpayments.com/checkout";
|
||||
public static CHECKOUT_API_VERSION = "v49";
|
||||
public static BIN_LOOKUP_PAL_SUFFIX = "/pal/servlet/BinLookup/";
|
||||
public static BIN_LOOKUP_API_VERSION = "v40";
|
||||
public static CHECKOUT_UTILITY_API_VERSION: string = "v1";
|
||||
public static TERMINAL_API_ENDPOINT_TEST: string = "https://terminal-api-test.adyen.com";
|
||||
public static TERMINAL_API_ENDPOINT_LIVE: string = "https://terminal-api-live.adyen.com";
|
||||
public static ENDPOINT_PROTOCOL: string = "https://";
|
||||
public static CHECKOUT_UTILITY_API_VERSION = "v1";
|
||||
public static TERMINAL_API_ENDPOINT_TEST = "https://terminal-api-test.adyen.com";
|
||||
public static TERMINAL_API_ENDPOINT_LIVE = "https://terminal-api-live.adyen.com";
|
||||
public static ENDPOINT_PROTOCOL = "https://";
|
||||
|
||||
private _httpClient!: ClientInterface;
|
||||
public config: Config;
|
||||
|
||||
10
src/helpers/checkServerIdentity.ts
Normal file
10
src/helpers/checkServerIdentity.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import {PeerCertificate} from "tls";
|
||||
|
||||
export default function checkServerIdentity(host: string, cert: PeerCertificate): Error | undefined {
|
||||
const { subject: { CN }} = cert;
|
||||
const re = /^(([a-zA-Z0-9]+-[a-zA-Z0-9]+)|legacy-terminal-certificate)\.(live|test)\.terminal\.adyen\.com$/;
|
||||
const isValid = re.test(CN);
|
||||
const error = new Error("Couldn't verify certificate");
|
||||
|
||||
return isValid ? undefined : error;
|
||||
}
|
||||
@@ -19,8 +19,10 @@
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
import Resource from "../service/resource";
|
||||
import Resource from "../services/resource";
|
||||
import { RequestOptions } from "../typings/requestOptions";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
import ApiException from "../services/exception/apiException";
|
||||
|
||||
async function getJsonResponse<T>(resource: Resource, jsonRequest: T | string, requestOptions?: RequestOptions): Promise<string>;
|
||||
async function getJsonResponse<T, R>(resource: Resource, jsonRequest: T | string, requestOptions?: RequestOptions): Promise<R>;
|
||||
@@ -29,11 +31,11 @@ async function getJsonResponse<T, R>(
|
||||
resource: Resource,
|
||||
jsonRequest: T | string,
|
||||
requestOptions: RequestOptions = {},
|
||||
): Promise<R | string> {
|
||||
): Promise<R | string | HttpClientException | ApiException> {
|
||||
const request = typeof jsonRequest === "string" ? jsonRequest : JSON.stringify(jsonRequest);
|
||||
const response = await resource.request(request, requestOptions);
|
||||
try {
|
||||
return JSON.parse(response);
|
||||
return typeof response === "string" ? JSON.parse(response) : response;
|
||||
} catch (e) {
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -22,15 +22,17 @@
|
||||
import {IncomingHttpHeaders, IncomingMessage} from "http";
|
||||
|
||||
class HttpClientException implements Error {
|
||||
public statusCode: number = 0;
|
||||
public statusCode = 500;
|
||||
public errorCode: string | undefined;
|
||||
public responseHeaders: IncomingHttpHeaders | undefined;
|
||||
public readonly message: string;
|
||||
public readonly name: string;
|
||||
public responseBody: IncomingMessage | undefined;
|
||||
|
||||
public constructor(message: string, statusCode?: number, responseHeaders?: IncomingHttpHeaders, responseBody?: IncomingMessage) {
|
||||
public constructor(message: string, statusCode?: number, errorCode?: string, responseHeaders?: IncomingHttpHeaders, responseBody?: IncomingMessage) {
|
||||
this.name = "HttpClientException";
|
||||
this.message = message;
|
||||
if(errorCode) this.errorCode = errorCode;
|
||||
if(statusCode) this.statusCode = statusCode;
|
||||
if(responseHeaders) this.responseHeaders = responseHeaders;
|
||||
if(responseBody) this.responseBody = responseBody;
|
||||
|
||||
@@ -39,16 +39,19 @@ import {
|
||||
import { RequestOptions } from "../typings/requestOptions";
|
||||
import ClientInterface from "../typings/httpClient/clientInterface";
|
||||
import HttpClientException from "./httpClientException";
|
||||
import checkServerIdentity from "../helpers/checkServerIdentity";
|
||||
import {ApiError} from "../typings/apiError";
|
||||
import ApiException from "../services/exception/apiException";
|
||||
|
||||
class HttpURLConnectionClient implements ClientInterface {
|
||||
private static CHARSET: string = "utf-8";
|
||||
private static CHARSET = "utf-8";
|
||||
public proxy?: AgentOptions;
|
||||
private agentOptions!: AgentOptions;
|
||||
|
||||
public request(
|
||||
endpoint: string, json: string, config: Config, isApiRequired: boolean,
|
||||
requestOptions: RequestOptions,
|
||||
): Promise<string> {
|
||||
): Promise<string | HttpClientException | ApiException> {
|
||||
requestOptions.headers = {};
|
||||
requestOptions.timeout = config.connectionTimeoutMillis;
|
||||
|
||||
@@ -58,7 +61,11 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
|
||||
const apiKey = config.apiKey;
|
||||
|
||||
if (isApiRequired || apiKey) {
|
||||
if (isApiRequired && !apiKey) {
|
||||
return Promise.reject(new ApiException("Invalid X-API-Key was used", 401));
|
||||
}
|
||||
|
||||
if (apiKey) {
|
||||
requestOptions.headers[API_KEY] = apiKey;
|
||||
} else {
|
||||
const authString = `${config.username}:${config.password}`;
|
||||
@@ -73,7 +80,7 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
return this.doPostRequest(httpConnection, json);
|
||||
}
|
||||
|
||||
public post(endpoint: string, postParameters: [string, string][], config: Config): Promise<string> {
|
||||
public post(endpoint: string, postParameters: [string, string][], config: Config): Promise<HttpClientException | string> {
|
||||
const postQuery: string = this.getQuery(postParameters);
|
||||
const connectionRequest: ClientRequest = this.createRequest(endpoint, {}, config.applicationName);
|
||||
return this.doPostRequest(connectionRequest, postQuery);
|
||||
@@ -97,8 +104,7 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
|
||||
if (this.proxy && this.proxy.host) {
|
||||
const { host, port, ...options } = this.proxy;
|
||||
const agent = new HttpsProxyAgent({ host, port: port || 443, ...options });
|
||||
requestOptions.agent = agent;
|
||||
requestOptions.agent = new HttpsProxyAgent({ host, port: port || 443, ...options });
|
||||
} else {
|
||||
requestOptions.agent = new Agent(this.agentOptions);
|
||||
}
|
||||
@@ -115,22 +121,46 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
return params.map(([key, value]): string => `${key}=${value}`).join("&");
|
||||
}
|
||||
|
||||
private doPostRequest(connectionRequest: ClientRequest, json: string): Promise<string> {
|
||||
private doPostRequest(connectionRequest: ClientRequest, json: string): Promise<HttpClientException | string> {
|
||||
return new Promise((resolve, reject): void => {
|
||||
connectionRequest.flushHeaders();
|
||||
|
||||
connectionRequest.on("response", (res: IncomingMessage): void => {
|
||||
let resData = "";
|
||||
if (res.statusCode && res.statusCode !== 200) {
|
||||
const exception = new HttpClientException(
|
||||
`HTTP Exception: ${res.statusCode}. ${res.statusMessage}`,
|
||||
res.statusCode,
|
||||
res.headers,
|
||||
res,
|
||||
);
|
||||
reject(exception);
|
||||
}
|
||||
const getException = (): HttpClientException => new HttpClientException(
|
||||
`HTTP Exception: ${res.statusCode}. ${res.statusMessage}`,
|
||||
res.statusCode,
|
||||
undefined,
|
||||
res.headers,
|
||||
res,
|
||||
);
|
||||
let exception: HttpClientException | Error = getException();
|
||||
|
||||
res.on("data", (data): void => {
|
||||
if (res.statusCode && res.statusCode !== 200) {
|
||||
try {
|
||||
const formattedData: ApiError = JSON.parse(data.toString() as string);
|
||||
const isApiError = "status" in formattedData;
|
||||
const isRequestError = "errors" in formattedData;
|
||||
|
||||
if (isApiError) {
|
||||
exception = new HttpClientException(
|
||||
`HTTP Exception: ${formattedData.status}. ${res.statusMessage}: ${formattedData.message}`,
|
||||
formattedData.status,
|
||||
formattedData.errorCode,
|
||||
res.headers,
|
||||
res,
|
||||
);
|
||||
} else if (isRequestError) {
|
||||
exception = new Error(data);
|
||||
}
|
||||
} catch (e) {
|
||||
reject(exception);
|
||||
} finally {
|
||||
reject(exception);
|
||||
}
|
||||
}
|
||||
|
||||
resData += data;
|
||||
});
|
||||
|
||||
@@ -147,25 +177,23 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
connectionRequest.on("timeout", (): void => {
|
||||
connectionRequest.abort();
|
||||
});
|
||||
connectionRequest.on("error", reject);
|
||||
connectionRequest.on("error", (e) => reject(new ApiException(e.message)));
|
||||
connectionRequest.write(Buffer.from(json));
|
||||
connectionRequest.end();
|
||||
});
|
||||
}
|
||||
|
||||
private installCertificateVerifier(terminalCertificatePath: string): void {
|
||||
private installCertificateVerifier(terminalCertificatePath: string): void | Promise<HttpClientException> {
|
||||
try {
|
||||
const certificateInput = fs.readFileSync(terminalCertificatePath);
|
||||
|
||||
this.agentOptions = {
|
||||
ca: certificateInput,
|
||||
checkServerIdentity: (): undefined => {
|
||||
return undefined;
|
||||
},
|
||||
checkServerIdentity,
|
||||
};
|
||||
|
||||
} catch (e) {
|
||||
throw new HttpClientException(`Error loading certificate from path: ${e.message}`);
|
||||
return Promise.reject(new HttpClientException(`Error loading certificate from path: ${e.message}`));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,6 @@
|
||||
|
||||
export { default as Client } from "./client";
|
||||
export { default as Config } from "./config";
|
||||
export * from "./service/";
|
||||
export { default as utils } from "./utils";
|
||||
export * from "./services/";
|
||||
export { hmacValidator } from "./utils";
|
||||
export { default as HttpURLConnectionClient } from "./httpClient/httpURLConnectionClient";
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
import {Cipher, createCipheriv, createDecipheriv, createHmac, randomBytes} from "crypto";
|
||||
import NexoCryptoException from "../service/exception/nexoCryptoException";
|
||||
import NexoCryptoException from "../services/exception/nexoCryptoException";
|
||||
import {NEXO_IV_LENGTH} from "../typings/constants/nexoConstants";
|
||||
import {
|
||||
MessageHeader,
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
import Client from "./client";
|
||||
|
||||
class Service {
|
||||
public apiKeyRequired: boolean = false;
|
||||
public apiKeyRequired = false;
|
||||
public client: Client;
|
||||
|
||||
protected constructor(client: Client) {
|
||||
|
||||
@@ -27,7 +27,7 @@ class ApiException implements Error {
|
||||
public readonly message: string;
|
||||
public readonly name: string;
|
||||
|
||||
public constructor(message: string, statusCode: number) {
|
||||
public constructor(message: string, statusCode = 500) {
|
||||
this.name = "ApiException";
|
||||
this.message = message;
|
||||
this.statusCode = statusCode;
|
||||
@@ -24,12 +24,13 @@ import DeclineThirdParty from "./resource/payout/declineThirdParty";
|
||||
import StoreDetail from "./resource/payout/storeDetail";
|
||||
import SubmitThirdParty from "./resource/payout/submitThirdParty";
|
||||
import ConfirmThirdParty from "./resource/payout/confirmThirdParty";
|
||||
import PayoutResource from "./resource/payout/payout";
|
||||
import StoreDetailAndSubmitThirdParty from "./resource/payout/storeDetailAndSubmitThirdParty";
|
||||
import {
|
||||
ModifyRequest,
|
||||
ModifyResponse,
|
||||
StoreDetailAndSubmitRequest,
|
||||
StoreDetailAndSubmitResponse, StoreDetailRequest, StoreDetailResponse, SubmitRequest, SubmitResponse
|
||||
StoreDetailAndSubmitResponse, StoreDetailRequest, StoreDetailResponse, SubmitRequest, SubmitResponse, PayoutRequest, PayoutResponse
|
||||
} from "../typings/payout";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
|
||||
@@ -39,6 +40,7 @@ class Payout extends Service {
|
||||
private readonly _declineThirdParty: DeclineThirdParty;
|
||||
private readonly _storeDetail: StoreDetail;
|
||||
private readonly _submitThirdParty: SubmitThirdParty;
|
||||
private readonly _payout: PayoutResource;
|
||||
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
@@ -48,6 +50,7 @@ class Payout extends Service {
|
||||
this._declineThirdParty = new DeclineThirdParty(this);
|
||||
this._storeDetail = new StoreDetail(this);
|
||||
this._submitThirdParty = new SubmitThirdParty(this);
|
||||
this._payout = new PayoutResource(this);
|
||||
}
|
||||
|
||||
public storeDetailAndSubmitThirdParty(request: StoreDetailAndSubmitRequest): Promise<StoreDetailAndSubmitResponse> {
|
||||
@@ -84,6 +87,13 @@ class Payout extends Service {
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public payout(request: PayoutRequest): Promise<PayoutResponse> {
|
||||
return getJsonResponse<PayoutRequest, PayoutResponse>(
|
||||
this._payout,
|
||||
request
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Payout;
|
||||
@@ -23,6 +23,7 @@ import Config from "../config";
|
||||
import ClientInterface from "../typings/httpClient/clientInterface";
|
||||
import Service from "../service";
|
||||
import { RequestOptions } from "../typings/requestOptions";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
import ApiException from "./exception/apiException";
|
||||
|
||||
abstract class Resource {
|
||||
@@ -34,28 +35,16 @@ abstract class Resource {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
public request(json: string, requestOptions?: RequestOptions): Promise<string> {
|
||||
public request(json: string, requestOptions?: RequestOptions): Promise<string | HttpClientException | ApiException> {
|
||||
const clientInterface: ClientInterface = this.service.client.httpClient;
|
||||
const config: Config = this.service.client.config;
|
||||
|
||||
try {
|
||||
return clientInterface.request(
|
||||
this.endpoint,
|
||||
json, config,
|
||||
this.service.apiKeyRequired,
|
||||
requestOptions,
|
||||
);
|
||||
} catch (e) {
|
||||
const apiException: ApiException = new ApiException(e.message, e.statusCode);
|
||||
|
||||
try {
|
||||
apiException.error = e.responseBody;
|
||||
} catch (err) {
|
||||
throw new ApiException("Invalid response or an invalid X-API-Key key was used", err.statusCode);
|
||||
}
|
||||
|
||||
throw apiException;
|
||||
}
|
||||
return clientInterface.request(
|
||||
this.endpoint,
|
||||
json, config,
|
||||
this.service.apiKeyRequired,
|
||||
requestOptions,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
34
src/services/resource/payout/payout.ts
Normal file
34
src/services/resource/payout/payout.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
import Resource from "../../resource";
|
||||
import Service from "../../../service";
|
||||
import Client from "../../../client";
|
||||
|
||||
class Payout extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.endpoint}/pal/servlet/Payout/${Client.API_VERSION}/payout`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Payout;
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
import Service from "../../../../service";
|
||||
import Resource from "../../../resource";
|
||||
import Resource from "../../../../services/resource";
|
||||
|
||||
class LocalRequest extends Resource {
|
||||
public constructor(service: Service) {
|
||||
@@ -38,4 +38,4 @@ export interface ShopperInteractionDevice {
|
||||
os?: string;
|
||||
osVersion?: string;
|
||||
locale?: string;
|
||||
}
|
||||
}
|
||||
33
src/typings/binLookup/binDetail.ts
Normal file
33
src/typings/binLookup/binDetail.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Adyen BinLookup API
|
||||
* The BIN Lookup API provides endpoints for retrieving information, such as cost estimates, and 3D Secure supported version based on a given BIN.
|
||||
*
|
||||
* The version of the OpenAPI document: 50
|
||||
* Contact: support@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 BinDetail {
|
||||
/**
|
||||
* The country where the card was issued.
|
||||
*/
|
||||
'issuerCountry'?: string;
|
||||
|
||||
static discriminator: string | undefined = undefined;
|
||||
|
||||
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
|
||||
{
|
||||
"name": "issuerCountry",
|
||||
"baseName": "issuerCountry",
|
||||
"type": "string"
|
||||
} ];
|
||||
|
||||
static getAttributeTypeMap() {
|
||||
return BinDetail.attributeTypeMap;
|
||||
}
|
||||
}
|
||||
|
||||
64
src/typings/checkout/applicationInfo.ts
Normal file
64
src/typings/checkout/applicationInfo.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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 One-Click and 3D Secure), mobile wallets, and local payment methods (e.g. 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/checkout). ## 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/user-management/how-to-get-the-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/v50/payments ```
|
||||
*
|
||||
* The version of the OpenAPI document: 50
|
||||
* Contact: support@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.
|
||||
*/
|
||||
|
||||
import { CommonField } from './commonField';
|
||||
import { ExternalPlatform } from './externalPlatform';
|
||||
import { MerchantDevice } from './merchantDevice';
|
||||
import { ShopperInteractionDevice } from './shopperInteractionDevice';
|
||||
|
||||
export class ApplicationInfo {
|
||||
'adyenLibrary'?: CommonField;
|
||||
'adyenPaymentSource'?: CommonField;
|
||||
'externalPlatform'?: ExternalPlatform;
|
||||
'merchantApplication'?: CommonField;
|
||||
'merchantDevice'?: MerchantDevice;
|
||||
'shopperInteractionDevice'?: ShopperInteractionDevice;
|
||||
|
||||
static discriminator: string | undefined = undefined;
|
||||
|
||||
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
|
||||
{
|
||||
"name": "adyenLibrary",
|
||||
"baseName": "adyenLibrary",
|
||||
"type": "CommonField"
|
||||
},
|
||||
{
|
||||
"name": "adyenPaymentSource",
|
||||
"baseName": "adyenPaymentSource",
|
||||
"type": "CommonField"
|
||||
},
|
||||
{
|
||||
"name": "externalPlatform",
|
||||
"baseName": "externalPlatform",
|
||||
"type": "ExternalPlatform"
|
||||
},
|
||||
{
|
||||
"name": "merchantApplication",
|
||||
"baseName": "merchantApplication",
|
||||
"type": "CommonField"
|
||||
},
|
||||
{
|
||||
"name": "merchantDevice",
|
||||
"baseName": "merchantDevice",
|
||||
"type": "MerchantDevice"
|
||||
},
|
||||
{
|
||||
"name": "shopperInteractionDevice",
|
||||
"baseName": "shopperInteractionDevice",
|
||||
"type": "ShopperInteractionDevice"
|
||||
} ];
|
||||
|
||||
static getAttributeTypeMap() {
|
||||
return ApplicationInfo.attributeTypeMap;
|
||||
}
|
||||
}
|
||||
|
||||
42
src/typings/checkout/commonField.ts
Normal file
42
src/typings/checkout/commonField.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 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 One-Click and 3D Secure), mobile wallets, and local payment methods (e.g. 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/checkout). ## 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/user-management/how-to-get-the-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/v50/payments ```
|
||||
*
|
||||
* The version of the OpenAPI document: 50
|
||||
* Contact: support@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 CommonField {
|
||||
/**
|
||||
* Name of the field. For example, Name of External Platform.
|
||||
*/
|
||||
'name'?: string;
|
||||
/**
|
||||
* Version of the field. For example, Version of External Platform.
|
||||
*/
|
||||
'version'?: string;
|
||||
|
||||
static discriminator: string | undefined = undefined;
|
||||
|
||||
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
|
||||
{
|
||||
"name": "name",
|
||||
"baseName": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "version",
|
||||
"baseName": "version",
|
||||
"type": "string"
|
||||
} ];
|
||||
|
||||
static getAttributeTypeMap() {
|
||||
return CommonField.attributeTypeMap;
|
||||
}
|
||||
}
|
||||
|
||||
51
src/typings/checkout/externalPlatform.ts
Normal file
51
src/typings/checkout/externalPlatform.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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 One-Click and 3D Secure), mobile wallets, and local payment methods (e.g. 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/checkout). ## 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/user-management/how-to-get-the-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/v50/payments ```
|
||||
*
|
||||
* The version of the OpenAPI document: 50
|
||||
* Contact: support@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 ExternalPlatform {
|
||||
/**
|
||||
* External platform integrator.
|
||||
*/
|
||||
'integrator'?: string;
|
||||
/**
|
||||
* Name of the field. For example, Name of External Platform.
|
||||
*/
|
||||
'name'?: string;
|
||||
/**
|
||||
* Version of the field. For example, Version of External Platform.
|
||||
*/
|
||||
'version'?: string;
|
||||
|
||||
static discriminator: string | undefined = undefined;
|
||||
|
||||
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
|
||||
{
|
||||
"name": "integrator",
|
||||
"baseName": "integrator",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"baseName": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "version",
|
||||
"baseName": "version",
|
||||
"type": "string"
|
||||
} ];
|
||||
|
||||
static getAttributeTypeMap() {
|
||||
return ExternalPlatform.attributeTypeMap;
|
||||
}
|
||||
}
|
||||
|
||||
51
src/typings/checkout/merchantDevice.ts
Normal file
51
src/typings/checkout/merchantDevice.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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 One-Click and 3D Secure), mobile wallets, and local payment methods (e.g. 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/checkout). ## 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/user-management/how-to-get-the-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/v50/payments ```
|
||||
*
|
||||
* The version of the OpenAPI document: 50
|
||||
* Contact: support@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 MerchantDevice {
|
||||
/**
|
||||
* Operating system running on the merchant device.
|
||||
*/
|
||||
'os'?: string;
|
||||
/**
|
||||
* Version of the operating system on the merchant device.
|
||||
*/
|
||||
'osVersion'?: string;
|
||||
/**
|
||||
* Merchant device reference.
|
||||
*/
|
||||
'reference'?: string;
|
||||
|
||||
static discriminator: string | undefined = undefined;
|
||||
|
||||
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
|
||||
{
|
||||
"name": "os",
|
||||
"baseName": "os",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "osVersion",
|
||||
"baseName": "osVersion",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "reference",
|
||||
"baseName": "reference",
|
||||
"type": "string"
|
||||
} ];
|
||||
|
||||
static getAttributeTypeMap() {
|
||||
return MerchantDevice.attributeTypeMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
|
||||
|
||||
/**
|
||||
* Adyen Checkout Service
|
||||
* 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 One-Click and 3D Secure), mobile wallets, and local payment methods (e.g. 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/checkout). ## 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/user-management/how-to-get-the-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/v46/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 One-Click and 3D Secure), mobile wallets, and local payment methods (e.g. 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/checkout). ## 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/user-management/how-to-get-the-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/v49/payments ```
|
||||
*
|
||||
* OpenAPI spec version: 46
|
||||
* OpenAPI spec version: 49
|
||||
* Contact: support@adyen.com
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
@@ -14,7 +12,11 @@
|
||||
import { PaymentMethodGroup } from './paymentMethodGroup';
|
||||
|
||||
|
||||
export interface PaymentMethod {
|
||||
export interface PaymentMethod {
|
||||
/**
|
||||
* List of possible brands. For example: visa, mc.
|
||||
*/
|
||||
brands?: Array<string>;
|
||||
/**
|
||||
* The configuration of the payment method.
|
||||
*/
|
||||
@@ -24,6 +26,10 @@ export interface PaymentMethod {
|
||||
*/
|
||||
details?: Array<InputDetail>;
|
||||
group?: PaymentMethodGroup;
|
||||
/**
|
||||
* All input details to be provided to complete the payment with this payment method.
|
||||
*/
|
||||
inputDetails?: Array<InputDetail>;
|
||||
/**
|
||||
* The displayable name of this payment method.
|
||||
*/
|
||||
|
||||
51
src/typings/checkout/shopperInteractionDevice.ts
Normal file
51
src/typings/checkout/shopperInteractionDevice.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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 One-Click and 3D Secure), mobile wallets, and local payment methods (e.g. 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/checkout). ## 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/user-management/how-to-get-the-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/v50/payments ```
|
||||
*
|
||||
* The version of the OpenAPI document: 50
|
||||
* Contact: support@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 ShopperInteractionDevice {
|
||||
/**
|
||||
* Locale on the shopper interaction device.
|
||||
*/
|
||||
'locale'?: string;
|
||||
/**
|
||||
* Operating system running on the shopper interaction device.
|
||||
*/
|
||||
'os'?: string;
|
||||
/**
|
||||
* Version of the operating system on the shopper interaction device.
|
||||
*/
|
||||
'osVersion'?: string;
|
||||
|
||||
static discriminator: string | undefined = undefined;
|
||||
|
||||
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
|
||||
{
|
||||
"name": "locale",
|
||||
"baseName": "locale",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "os",
|
||||
"baseName": "os",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "osVersion",
|
||||
"baseName": "osVersion",
|
||||
"type": "string"
|
||||
} ];
|
||||
|
||||
static getAttributeTypeMap() {
|
||||
return ShopperInteractionDevice.attributeTypeMap;
|
||||
}
|
||||
}
|
||||
|
||||
114
src/typings/checkout/storedPaymentMethod.ts
Normal file
114
src/typings/checkout/storedPaymentMethod.ts
Normal file
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* 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 One-Click and 3D Secure), mobile wallets, and local payment methods (e.g. 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/checkout). ## 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/user-management/how-to-get-the-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/v50/payments ```
|
||||
*
|
||||
* The version of the OpenAPI document: 50
|
||||
* Contact: support@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 StoredPaymentMethod {
|
||||
/**
|
||||
* The brand of the card.
|
||||
*/
|
||||
'brand'?: string;
|
||||
/**
|
||||
* The month the card expires.
|
||||
*/
|
||||
'expiryMonth'?: string;
|
||||
/**
|
||||
* The year the card expires.
|
||||
*/
|
||||
'expiryYear'?: string;
|
||||
/**
|
||||
* The unique payment method code.
|
||||
*/
|
||||
'holderName'?: string;
|
||||
/**
|
||||
* A unique identifier of this stored payment method.
|
||||
*/
|
||||
'id'?: string;
|
||||
/**
|
||||
* The last four digits of the PAN.
|
||||
*/
|
||||
'lastFour'?: string;
|
||||
/**
|
||||
* The display name of the stored payment method.
|
||||
*/
|
||||
'name'?: string;
|
||||
/**
|
||||
* The shopper’s email address.
|
||||
*/
|
||||
'shopperEmail'?: string;
|
||||
/**
|
||||
* The supported shopper interactions for this stored payment method.
|
||||
*/
|
||||
'supportedShopperInteractions'?: Array<string>;
|
||||
/**
|
||||
* The type of payment method.
|
||||
*/
|
||||
'type'?: string;
|
||||
|
||||
static discriminator: string | undefined = undefined;
|
||||
|
||||
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
|
||||
{
|
||||
"name": "brand",
|
||||
"baseName": "brand",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "expiryMonth",
|
||||
"baseName": "expiryMonth",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "expiryYear",
|
||||
"baseName": "expiryYear",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "holderName",
|
||||
"baseName": "holderName",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
"baseName": "id",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "lastFour",
|
||||
"baseName": "lastFour",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"baseName": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "shopperEmail",
|
||||
"baseName": "shopperEmail",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "supportedShopperInteractions",
|
||||
"baseName": "supportedShopperInteractions",
|
||||
"type": "Array<string>"
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"baseName": "type",
|
||||
"type": "string"
|
||||
} ];
|
||||
|
||||
static getAttributeTypeMap() {
|
||||
return StoredPaymentMethod.attributeTypeMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,11 @@ export interface ThreeDS2RequestData {
|
||||
*/
|
||||
deviceChannel: string;
|
||||
deviceRenderOptions?: DeviceRenderOptions;
|
||||
/**
|
||||
* Required for [authentication-only integration](https://docs.adyen.com/checkout/3d-secure/native-3ds2/authentication-only). The merchant name that the issuer presents to the shopper if they get a challenge. We recommend to use the same value that you will use in the authorization. Maximum length is 40 characters.
|
||||
* Optional for a [full 3D Secure 2 integration](https://docs.adyen.com/checkout/3d-secure/native-3ds2/api-integration). Use this field if you are enrolled for 3D Secure 2 with us and want to override the merchant name already configured on your account.
|
||||
*/
|
||||
merchantName?: string;
|
||||
/**
|
||||
* The `messageVersion` value indicating the 3D Secure 2 protocol version.
|
||||
*/
|
||||
|
||||
@@ -21,12 +21,14 @@
|
||||
import Config from "../../config";
|
||||
import { RequestOptions } from "../requestOptions";
|
||||
import { AgentOptions } from "https";
|
||||
import HttpClientException from "../../httpClient/httpClientException";
|
||||
import ApiException from "../../services/exception/apiException";
|
||||
|
||||
interface ClientInterface {
|
||||
request(
|
||||
endpoint: string, json: string, config: Config, isApiKeyRequired: boolean, requestOptions?: RequestOptions,
|
||||
): Promise<string>;
|
||||
post(endpoint: string, postParameters: [string, string][], config: Config): Promise<string>;
|
||||
): Promise<string | HttpClientException | ApiException>;
|
||||
post(endpoint: string, postParameters: [string, string][], config: Config): Promise<HttpClientException | string>;
|
||||
proxy?: AgentOptions;
|
||||
}
|
||||
|
||||
|
||||
@@ -226,4 +226,4 @@ const typeMap: any = {
|
||||
{ json: "currency", js: "currency", typ: "" },
|
||||
{ json: "value", js: "value", typ: 0 },
|
||||
], false),
|
||||
};
|
||||
};
|
||||
64
src/typings/payments/applicationInfo.ts
Normal file
64
src/typings/payments/applicationInfo.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Adyen Payment API
|
||||
* A set of API endpoints that allow you to initiate, settle, and modify payments on the Adyen payments platform. You can use the API to accept card payments (including One-Click and 3D Secure), bank transfers, ewallets, and many other payment methods. To learn more about the API, visit [Classic integration](https://docs.adyen.com/classic-integration). ## Authentication To connect to the Payments API, you must use your basic authentication credentials. For this, create your web service user, as described in [How to get the WS user password](https://docs.adyen.com/user-management/how-to-get-the-web-service-ws-user-password). Then use its credentials to authenticate your request, for example: ``` curl -U \"ws@Company.YourCompany\":\"YourWsPassword\" \\ -H \"Content-Type: application/json\" \\ ... ``` Note that when going live, you need to generate new web service user credentials to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning Payments 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://pal-test.adyen.com/pal/servlet/Payment/v50/authorise ```
|
||||
*
|
||||
* The version of the OpenAPI document: 50
|
||||
* Contact: support@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.
|
||||
*/
|
||||
|
||||
import { CommonField } from './commonField';
|
||||
import { ExternalPlatform } from './externalPlatform';
|
||||
import { MerchantDevice } from './merchantDevice';
|
||||
import { ShopperInteractionDevice } from './shopperInteractionDevice';
|
||||
|
||||
export class ApplicationInfo {
|
||||
'adyenLibrary'?: CommonField;
|
||||
'adyenPaymentSource'?: CommonField;
|
||||
'externalPlatform'?: ExternalPlatform;
|
||||
'merchantApplication'?: CommonField;
|
||||
'merchantDevice'?: MerchantDevice;
|
||||
'shopperInteractionDevice'?: ShopperInteractionDevice;
|
||||
|
||||
static discriminator: string | undefined = undefined;
|
||||
|
||||
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
|
||||
{
|
||||
"name": "adyenLibrary",
|
||||
"baseName": "adyenLibrary",
|
||||
"type": "CommonField"
|
||||
},
|
||||
{
|
||||
"name": "adyenPaymentSource",
|
||||
"baseName": "adyenPaymentSource",
|
||||
"type": "CommonField"
|
||||
},
|
||||
{
|
||||
"name": "externalPlatform",
|
||||
"baseName": "externalPlatform",
|
||||
"type": "ExternalPlatform"
|
||||
},
|
||||
{
|
||||
"name": "merchantApplication",
|
||||
"baseName": "merchantApplication",
|
||||
"type": "CommonField"
|
||||
},
|
||||
{
|
||||
"name": "merchantDevice",
|
||||
"baseName": "merchantDevice",
|
||||
"type": "MerchantDevice"
|
||||
},
|
||||
{
|
||||
"name": "shopperInteractionDevice",
|
||||
"baseName": "shopperInteractionDevice",
|
||||
"type": "ShopperInteractionDevice"
|
||||
} ];
|
||||
|
||||
static getAttributeTypeMap() {
|
||||
return ApplicationInfo.attributeTypeMap;
|
||||
}
|
||||
}
|
||||
|
||||
42
src/typings/payments/commonField.ts
Normal file
42
src/typings/payments/commonField.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Adyen Payment API
|
||||
* A set of API endpoints that allow you to initiate, settle, and modify payments on the Adyen payments platform. You can use the API to accept card payments (including One-Click and 3D Secure), bank transfers, ewallets, and many other payment methods. To learn more about the API, visit [Classic integration](https://docs.adyen.com/classic-integration). ## Authentication To connect to the Payments API, you must use your basic authentication credentials. For this, create your web service user, as described in [How to get the WS user password](https://docs.adyen.com/user-management/how-to-get-the-web-service-ws-user-password). Then use its credentials to authenticate your request, for example: ``` curl -U \"ws@Company.YourCompany\":\"YourWsPassword\" \\ -H \"Content-Type: application/json\" \\ ... ``` Note that when going live, you need to generate new web service user credentials to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning Payments 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://pal-test.adyen.com/pal/servlet/Payment/v50/authorise ```
|
||||
*
|
||||
* The version of the OpenAPI document: 50
|
||||
* Contact: support@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 CommonField {
|
||||
/**
|
||||
* Name of the field. For example, Name of External Platform.
|
||||
*/
|
||||
'name'?: string;
|
||||
/**
|
||||
* Version of the field. For example, Version of External Platform.
|
||||
*/
|
||||
'version'?: string;
|
||||
|
||||
static discriminator: string | undefined = undefined;
|
||||
|
||||
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
|
||||
{
|
||||
"name": "name",
|
||||
"baseName": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "version",
|
||||
"baseName": "version",
|
||||
"type": "string"
|
||||
} ];
|
||||
|
||||
static getAttributeTypeMap() {
|
||||
return CommonField.attributeTypeMap;
|
||||
}
|
||||
}
|
||||
|
||||
51
src/typings/payments/externalPlatform.ts
Normal file
51
src/typings/payments/externalPlatform.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Adyen Payment API
|
||||
* A set of API endpoints that allow you to initiate, settle, and modify payments on the Adyen payments platform. You can use the API to accept card payments (including One-Click and 3D Secure), bank transfers, ewallets, and many other payment methods. To learn more about the API, visit [Classic integration](https://docs.adyen.com/classic-integration). ## Authentication To connect to the Payments API, you must use your basic authentication credentials. For this, create your web service user, as described in [How to get the WS user password](https://docs.adyen.com/user-management/how-to-get-the-web-service-ws-user-password). Then use its credentials to authenticate your request, for example: ``` curl -U \"ws@Company.YourCompany\":\"YourWsPassword\" \\ -H \"Content-Type: application/json\" \\ ... ``` Note that when going live, you need to generate new web service user credentials to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning Payments 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://pal-test.adyen.com/pal/servlet/Payment/v50/authorise ```
|
||||
*
|
||||
* The version of the OpenAPI document: 50
|
||||
* Contact: support@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 ExternalPlatform {
|
||||
/**
|
||||
* External platform integrator.
|
||||
*/
|
||||
'integrator'?: string;
|
||||
/**
|
||||
* Name of the field. For example, Name of External Platform.
|
||||
*/
|
||||
'name'?: string;
|
||||
/**
|
||||
* Version of the field. For example, Version of External Platform.
|
||||
*/
|
||||
'version'?: string;
|
||||
|
||||
static discriminator: string | undefined = undefined;
|
||||
|
||||
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
|
||||
{
|
||||
"name": "integrator",
|
||||
"baseName": "integrator",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"baseName": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "version",
|
||||
"baseName": "version",
|
||||
"type": "string"
|
||||
} ];
|
||||
|
||||
static getAttributeTypeMap() {
|
||||
return ExternalPlatform.attributeTypeMap;
|
||||
}
|
||||
}
|
||||
|
||||
51
src/typings/payments/merchantDevice.ts
Normal file
51
src/typings/payments/merchantDevice.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Adyen Payment API
|
||||
* A set of API endpoints that allow you to initiate, settle, and modify payments on the Adyen payments platform. You can use the API to accept card payments (including One-Click and 3D Secure), bank transfers, ewallets, and many other payment methods. To learn more about the API, visit [Classic integration](https://docs.adyen.com/classic-integration). ## Authentication To connect to the Payments API, you must use your basic authentication credentials. For this, create your web service user, as described in [How to get the WS user password](https://docs.adyen.com/user-management/how-to-get-the-web-service-ws-user-password). Then use its credentials to authenticate your request, for example: ``` curl -U \"ws@Company.YourCompany\":\"YourWsPassword\" \\ -H \"Content-Type: application/json\" \\ ... ``` Note that when going live, you need to generate new web service user credentials to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning Payments 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://pal-test.adyen.com/pal/servlet/Payment/v50/authorise ```
|
||||
*
|
||||
* The version of the OpenAPI document: 50
|
||||
* Contact: support@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 MerchantDevice {
|
||||
/**
|
||||
* Operating system running on the merchant device.
|
||||
*/
|
||||
'os'?: string;
|
||||
/**
|
||||
* Version of the operating system on the merchant device.
|
||||
*/
|
||||
'osVersion'?: string;
|
||||
/**
|
||||
* Merchant device reference.
|
||||
*/
|
||||
'reference'?: string;
|
||||
|
||||
static discriminator: string | undefined = undefined;
|
||||
|
||||
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
|
||||
{
|
||||
"name": "os",
|
||||
"baseName": "os",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "osVersion",
|
||||
"baseName": "osVersion",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "reference",
|
||||
"baseName": "reference",
|
||||
"type": "string"
|
||||
} ];
|
||||
|
||||
static getAttributeTypeMap() {
|
||||
return MerchantDevice.attributeTypeMap;
|
||||
}
|
||||
}
|
||||
|
||||
51
src/typings/payments/shopperInteractionDevice.ts
Normal file
51
src/typings/payments/shopperInteractionDevice.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Adyen Payment API
|
||||
* A set of API endpoints that allow you to initiate, settle, and modify payments on the Adyen payments platform. You can use the API to accept card payments (including One-Click and 3D Secure), bank transfers, ewallets, and many other payment methods. To learn more about the API, visit [Classic integration](https://docs.adyen.com/classic-integration). ## Authentication To connect to the Payments API, you must use your basic authentication credentials. For this, create your web service user, as described in [How to get the WS user password](https://docs.adyen.com/user-management/how-to-get-the-web-service-ws-user-password). Then use its credentials to authenticate your request, for example: ``` curl -U \"ws@Company.YourCompany\":\"YourWsPassword\" \\ -H \"Content-Type: application/json\" \\ ... ``` Note that when going live, you need to generate new web service user credentials to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning Payments 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://pal-test.adyen.com/pal/servlet/Payment/v50/authorise ```
|
||||
*
|
||||
* The version of the OpenAPI document: 50
|
||||
* Contact: support@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 ShopperInteractionDevice {
|
||||
/**
|
||||
* Locale on the shopper interaction device.
|
||||
*/
|
||||
'locale'?: string;
|
||||
/**
|
||||
* Operating system running on the shopper interaction device.
|
||||
*/
|
||||
'os'?: string;
|
||||
/**
|
||||
* Version of the operating system on the shopper interaction device.
|
||||
*/
|
||||
'osVersion'?: string;
|
||||
|
||||
static discriminator: string | undefined = undefined;
|
||||
|
||||
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
|
||||
{
|
||||
"name": "locale",
|
||||
"baseName": "locale",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "os",
|
||||
"baseName": "os",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "osVersion",
|
||||
"baseName": "osVersion",
|
||||
"type": "string"
|
||||
} ];
|
||||
|
||||
static getAttributeTypeMap() {
|
||||
return ShopperInteractionDevice.attributeTypeMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5529,4 +5529,4 @@ const typeMap: any = {
|
||||
"PrinterReceipt",
|
||||
"PrinterVoucher",
|
||||
],
|
||||
};
|
||||
};
|
||||
@@ -42,7 +42,7 @@ class HmacValidator {
|
||||
const keys: string[] = [];
|
||||
const values: string[] = [];
|
||||
const replacer = (str: string): string =>
|
||||
str.replace("\\", "\\\\").replace(":", "\\:");
|
||||
str.replace(/\\/g, "\\\\").replace(/:/g, "\\:");
|
||||
Object.entries(notificationRequestItem).sort().forEach(([key, value]): void => {
|
||||
keys.push(replacer(key));
|
||||
values.push(replacer(value));
|
||||
@@ -53,4 +53,4 @@ class HmacValidator {
|
||||
}
|
||||
}
|
||||
|
||||
export default HmacValidator;
|
||||
export default HmacValidator;
|
||||
|
||||
@@ -19,12 +19,6 @@
|
||||
"strict": true,
|
||||
"noUnusedLocals": true
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"**/__mocks__/*",
|
||||
"**/__tests__/*"
|
||||
]
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user