mirror of
https://github.com/jlengrand/adyen-node-api-library.git
synced 2026-03-10 08:01:20 +00:00
11
.github/dependabot.yml
vendored
11
.github/dependabot.yml
vendored
@@ -7,9 +7,8 @@ updates:
|
||||
time: "04:00"
|
||||
open-pull-requests-limit: 10
|
||||
reviewers:
|
||||
- zaiddreakh
|
||||
maassenbas
|
||||
msilvagarcia
|
||||
AlexandrosMor
|
||||
peterojo
|
||||
wboereboom
|
||||
- "zaiddreakh"
|
||||
- "maassenbas"
|
||||
- "AlexandrosMor"
|
||||
- "peterojo"
|
||||
- "wboereboom"
|
||||
8
.github/workflows/codeql-analysis.yml
vendored
8
.github/workflows/codeql-analysis.yml
vendored
@@ -18,10 +18,10 @@ jobs:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
fetch-depth: 2
|
||||
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
uses: github/codeql-action/init@v2
|
||||
# Override language selection by uncommenting this and choosing your languages
|
||||
# with:
|
||||
# languages: go, javascript, csharp, python, cpp, java
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
@@ -43,4 +43,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
||||
6
.github/workflows/coveralls.yml
vendored
6
.github/workflows/coveralls.yml
vendored
@@ -1,4 +1,4 @@
|
||||
on: ["push", "pull_request"]
|
||||
on: ["pull_request"]
|
||||
|
||||
name: Coveralls
|
||||
|
||||
@@ -11,10 +11,10 @@ jobs:
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Use Node.js 12.x
|
||||
- name: Use Node.js 16.x
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
node-version: 16.x
|
||||
|
||||
- name: npm install, npm test:coverage
|
||||
run: |
|
||||
|
||||
24
.github/workflows/models.yml
vendored
Normal file
24
.github/workflows/models.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
name: Node.js Models
|
||||
|
||||
on: [ workflow_dispatch ]
|
||||
|
||||
jobs:
|
||||
generate:
|
||||
runs-on: ubuntu-latest
|
||||
name: Generate Models
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Generate models
|
||||
run: make models
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v4
|
||||
with:
|
||||
token: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
|
||||
committer: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
|
||||
author: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
|
||||
base: develop
|
||||
branch: automation/models
|
||||
title: Update models
|
||||
body: OpenAPI spec or templates produced new models.
|
||||
add-paths: |
|
||||
src/typings
|
||||
2
.github/workflows/nodejs.yml
vendored
2
.github/workflows/nodejs.yml
vendored
@@ -1,6 +1,6 @@
|
||||
name: Node.js CI
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
4
.github/workflows/npmpublish.yml
vendored
4
.github/workflows/npmpublish.yml
vendored
@@ -1,7 +1,9 @@
|
||||
name: Node.js Package
|
||||
|
||||
on:
|
||||
workflow_dispatch
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
publish-npm:
|
||||
|
||||
2
.github/workflows/sonarcloud.yml
vendored
2
.github/workflows/sonarcloud.yml
vendored
@@ -1,6 +1,6 @@
|
||||
name: "Sonarcloud Analysis"
|
||||
|
||||
on: ["push", "pull_request"]
|
||||
on: ["pull_request"]
|
||||
|
||||
jobs:
|
||||
sonarcloud-analysis:
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -12,4 +12,5 @@ node_modules
|
||||
.viminfo
|
||||
coverage/
|
||||
.env
|
||||
lib/
|
||||
lib/
|
||||
build/
|
||||
46
Makefile
Normal file
46
Makefile
Normal file
@@ -0,0 +1,46 @@
|
||||
generator:=typescript-node
|
||||
openapi-generator-cli:=docker run --user $(shell id -u):$(shell id -g) --rm -v ${PWD}:/local -w /local openapitools/openapi-generator-cli:v5.4.0
|
||||
services:=binlookup checkout storedValue terminalManagement payments recurring payouts management balancePlatform platformsAccount platformsFund platformsNotificationConfiguration platformsHostedOnboardingPage
|
||||
|
||||
# Generate models (for each service)
|
||||
models: $(services)
|
||||
|
||||
binlookup: spec=BinLookupService-v52
|
||||
checkout: spec=CheckoutService-v69
|
||||
storedValue: spec=StoredValueService-v46
|
||||
terminalManagement: spec=TfmAPIService-v1
|
||||
payments: spec=PaymentService-v68
|
||||
recurring: spec=RecurringService-v68
|
||||
payouts: spec=PayoutService-v68
|
||||
management: spec=ManagementService-v1
|
||||
balancePlatform: spec=BalancePlatformService-v2
|
||||
platformsAccount: spec=AccountService-v6
|
||||
platformsFund: spec=FundService-v6
|
||||
platformsNotificationConfiguration: spec=NotificationConfigurationService-v6
|
||||
platformsHostedOnboardingPage: spec=HopService-v6
|
||||
|
||||
$(services): build/spec
|
||||
rm -rf src/typings/$@ build/model
|
||||
$(openapi-generator-cli) generate \
|
||||
-i build/spec/json/$(spec).json \
|
||||
-g $(generator) \
|
||||
-t templates/typescript \
|
||||
-o build \
|
||||
--global-property models,supportingFiles
|
||||
mv build/model src/typings/$@
|
||||
|
||||
# Checkout spec (and patch version)
|
||||
build/spec:
|
||||
git clone https://github.com/Adyen/adyen-openapi.git build/spec
|
||||
sed -i 's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json
|
||||
|
||||
# Extract templates (copy them for modifications)
|
||||
templates:
|
||||
$(openapi-generator-cli) author template -g $(generator) -o build/templates/typescript
|
||||
|
||||
# Discard generated artifacts and changed models
|
||||
clean:
|
||||
git checkout src/typings
|
||||
git clean -f -d src/typings
|
||||
|
||||
.PHONY: templates models $(services)
|
||||
17
README.md
17
README.md
@@ -13,16 +13,21 @@ This is the officially supported NodeJS library for using Adyen's APIs.
|
||||
## Integration
|
||||
The Library supports all APIs under the following services:
|
||||
|
||||
* [BIN lookup API](https://docs.adyen.com/api-explorer/#/BinLookup/v50/overview): The BIN Lookup API provides endpoints for retrieving information based on a given BIN. Current supported version: **v52**
|
||||
* [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v69/overview): Our latest integration for accepting online payments. Current supported version: **v69**
|
||||
* [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v64/overview): Our classic integration for online payments. Current supported version: **v64**
|
||||
* [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v49/overview): Endpoints for managing saved payment details. Current supported version: **v49**
|
||||
* [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v64/overview): Endpoints for sending funds to your customers. Current supported version: **v64**
|
||||
* [Platforms APIs](https://docs.adyen.com/platforms/api): Set of APIs when using Adyen for Platforms.
|
||||
* [Configuration API](https://docs.adyen.com/api-explorer/#/balanceplatform/v2/overview): The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. Current supported verison: **v2**
|
||||
* [Local/Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/terminal-api-reference): Our point-of-sale integration.
|
||||
* [Management API](https://docs.adyen.com/api-explorer/#/ManagementService/v1/overview): Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. Current supported version **v1**
|
||||
* [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v68/overview): Our classic integration for online payments. Current supported version: **v68**
|
||||
* [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v64/overview): Endpoints for sending funds to your customers. Current supported version: **v68**
|
||||
* [Platforms APIs](https://docs.adyen.com/platforms/api): Set of APIs when using Adyen for Platforms. This API is used for the classic integration.
|
||||
* [Account API](https://docs.adyen.com/api-explorer/#/Account/v6/overview) Current supported version: **v6**
|
||||
* [Fund API](https://docs.adyen.com/api-explorer/#/Fund/v6/overview) Current supported version: **v6**
|
||||
* [Hosted onboarding API](https://docs.adyen.com/api-explorer/#/Hop/v6/overview): Current supported version: **v6**
|
||||
* [Notification Configuration API](https://docs.adyen.com/api-explorer/#/NotificationConfigurationService/v6/overview) Current supported version: **v6**
|
||||
* [Local/Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/terminal-api-reference): Our point-of-sale integration.
|
||||
* [BIN lookup API](https://docs.adyen.com/api-explorer/#/BinLookup/v50/overview): The BIN Lookup API provides endpoints for retrieving information based on a given BIN. Current supported version: **v50**
|
||||
* [POS Terminal Management API](https://docs.adyen.com/api-explorer/#/postfmapi/v1/overview): Endpoints for managing your point-of-sale payment terminals. Current supported version **v1**
|
||||
* [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v68/overview): Endpoints for managing saved payment details. Current supported version: **v68**
|
||||
* [Stored Value API](https://docs.adyen.com/payment-methods/gift-cards/stored-value-api): Manage both online and point-of-sale gift cards and other stored-value cards. Current supported version: **v46**
|
||||
|
||||
In addition it supports the following type collections:
|
||||
|
||||
|
||||
14
package.json
14
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@adyen/api-library",
|
||||
"version": "11.0.0",
|
||||
"version": "12.0.0",
|
||||
"description": "The Adyen API Library for NodeJS enables you to work with Adyen APIs.",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
@@ -37,23 +37,23 @@
|
||||
"devDependencies": {
|
||||
"@types/jest": "27.5.0",
|
||||
"@types/nock": "11.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.33.0",
|
||||
"@typescript-eslint/parser": "4.33.0",
|
||||
"@typescript-eslint/eslint-plugin": "5.35.1",
|
||||
"@typescript-eslint/parser": "5.35.1",
|
||||
"acorn": "^8.0.1",
|
||||
"coveralls": "3.1.1",
|
||||
"dotenv": "^16.0.0",
|
||||
"eslint": "7.32.0",
|
||||
"eslint": "8.22.0",
|
||||
"jest": "^27.0.6",
|
||||
"jest-ts-auto-mock": "^2.0.0",
|
||||
"kind-of": "^6.0.3",
|
||||
"minimist": ">=1.2.3",
|
||||
"nock": "13.2.6",
|
||||
"release-it": "15.0.0",
|
||||
"nock": "13.2.9",
|
||||
"release-it": "15.4.0",
|
||||
"ts-auto-mock": "^3.3.5",
|
||||
"ts-jest": "^27.0.4",
|
||||
"ts-loader": "8.0.10",
|
||||
"ttypescript": "^1.5.10",
|
||||
"typescript": "4.7.3"
|
||||
"typescript": "4.7.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"https-proxy-agent": "5.0.1"
|
||||
|
||||
@@ -44,7 +44,11 @@ export const createClient = (apiKey = process.env.ADYEN_API_KEY): Client => {
|
||||
config.checkoutEndpoint = Client.CHECKOUT_ENDPOINT_TEST;
|
||||
config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_TEST;
|
||||
config.apiKey = apiKey;
|
||||
config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_TEST;
|
||||
config.paymentEndpoint = Client.PAYMENT_API_ENDPOINT_TEST;
|
||||
config.storedValueEndpoint = Client.STOREDVALUE_API_ENDPOINT_TEST;
|
||||
config.terminalManagementEndpoint = Client.TERMINAL_MANAGEMENT_API_ENDPOINT_TEST;
|
||||
config.managementEndpoint = Client.MANAGEMENT_API_ENDPOINT_TEST;
|
||||
config.balancePlatformEndpoint = Client.BALANCE_PLATFORM_API_ENDPOINT_TEST;
|
||||
|
||||
return new Client({ config });
|
||||
};
|
||||
@@ -112,7 +116,8 @@ const getReversalRequest = (poiTransaction: TransactionIdentification): Reversal
|
||||
TimeStamp: poiTransaction.TimeStamp
|
||||
},
|
||||
},
|
||||
ReversalReason: ReversalReasonType.MerchantCancel
|
||||
ReversalReason: ReversalReasonType.MerchantCancel,
|
||||
SaleData: saleData
|
||||
});
|
||||
|
||||
const getSaleToPOIRequest = (messageHeader: MessageHeader, request: Partial<SaleToPOIRequest>): SaleToPOIRequest => ({
|
||||
|
||||
225
src/__mocks__/management/requests.ts
Normal file
225
src/__mocks__/management/requests.ts
Normal file
@@ -0,0 +1,225 @@
|
||||
export const createMerchantRequest = {
|
||||
"companyId": "YOUR_COMPANY_ACCOUNT",
|
||||
"legalEntityId": "YOUR_LEGAL_ENTITY_ID",
|
||||
"businessLineId": "YOUR_BUSINESS_LINE_ID",
|
||||
"description": "YOUR_DESCRIPTION",
|
||||
"reference": "YOUR_OWN_REFERENCE"
|
||||
};
|
||||
|
||||
export const allowedOrigin = {
|
||||
"_links": { "self": { "href": "string" } },
|
||||
"domain": "string",
|
||||
"id": "string"
|
||||
};
|
||||
|
||||
export const createMerchantApiCredentialRequest = {
|
||||
"roles": [
|
||||
"Checkout webservice role"
|
||||
],
|
||||
"allowedOrigins": [
|
||||
"https://www.mystore.com"
|
||||
]
|
||||
};
|
||||
|
||||
export const updateMerchantApiCredentialRequest = {
|
||||
"active": false,
|
||||
"allowedOrigins": ["string"],
|
||||
"description": "string",
|
||||
"roles": ["string"]
|
||||
};
|
||||
|
||||
export const paymentMethodSetupInfo = {
|
||||
"type": "visa",
|
||||
"currencies": [
|
||||
"USD"
|
||||
],
|
||||
"countries": [
|
||||
"US"
|
||||
]
|
||||
};
|
||||
|
||||
export const updatePaymentMethodInfo = {
|
||||
"countries": ["string"],
|
||||
"currencies": ["string"],
|
||||
"enabled": false
|
||||
};
|
||||
|
||||
export const payoutSettingsRequest = {
|
||||
"enabled": false,
|
||||
"enabledFromDate": "string",
|
||||
"transferInstrumentId": "string"
|
||||
};
|
||||
|
||||
export const updatePayoutSettingsRequest = { "enabled": false };
|
||||
|
||||
export const shippingLocation = {
|
||||
"name": "YOUR_MERCHANT_ACCOUNT Barcelona depot",
|
||||
"address": {
|
||||
"companyName": "YOUR_COMPANY",
|
||||
"streetAddress": "El quinto pino 42",
|
||||
"postalCode": "08012",
|
||||
"city": "Barcelona",
|
||||
"stateOrProvince": "",
|
||||
"country": "ES"
|
||||
},
|
||||
"contact": {
|
||||
"firstName": "Rita",
|
||||
"lastName": "Perengano",
|
||||
"phoneNumber": "+34 93 1234567",
|
||||
"email": "Rita.Perengano@company.com"
|
||||
}
|
||||
};
|
||||
|
||||
export const terminalOrderRequest = {
|
||||
"shippingLocation": "S2-73536B20665526704F30792642212044452F714622375D477270",
|
||||
"items": [
|
||||
{
|
||||
"id": "TBOX-V400m-684-EU",
|
||||
"name": "V400m Package",
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"id": "PART-287001-EU",
|
||||
"name": "Bluetooth Charging Base - V400m",
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"id": "PART-620222-EU",
|
||||
"name": "Receipt Roll",
|
||||
"quantity": 20
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export const logo = {
|
||||
"data": ""
|
||||
};
|
||||
|
||||
export const terminalSettings = {
|
||||
"wifiProfiles": {
|
||||
"profiles": [
|
||||
{
|
||||
"authType": "wpa-eap",
|
||||
"autoWifi": false,
|
||||
"bssType": "infra",
|
||||
"channel": 0,
|
||||
"defaultProfile": true,
|
||||
"eap": "peap",
|
||||
"eapCaCert": {
|
||||
"data": "MD1rKS05M2JqRVFNQ...RTtLH1tLWo=",
|
||||
"name": "eap-peap-ca.pem"
|
||||
},
|
||||
"eapIdentity": "admin",
|
||||
"eapIntermediateCert": {
|
||||
"data": "PD3tUS1CRDdJTiGDR...EFoLS0tLQg=",
|
||||
"name": "eap-peap-client.pem"
|
||||
},
|
||||
"eapPwd": "EAP_PEAP_PASSWORD",
|
||||
"hiddenSsid": false,
|
||||
"name": "Profile-eap-peap-1",
|
||||
"ssid": "your-network",
|
||||
"wsec": "ccmp"
|
||||
},
|
||||
{
|
||||
"authType": "wpa-psk",
|
||||
"autoWifi": false,
|
||||
"bssType": "infra",
|
||||
"channel": 0,
|
||||
"defaultProfile": false,
|
||||
"hiddenSsid": false,
|
||||
"name": "Profile-guest-wifi",
|
||||
"psk": "WIFI_PASSWORD",
|
||||
"ssid": "your-network",
|
||||
"wsec": "ccmp"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"band": "2.4GHz",
|
||||
"roaming": true,
|
||||
"timeout": 5
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const createMerchantUserRequest = {
|
||||
"name": {
|
||||
"firstName": "John",
|
||||
"lastName": "Smith"
|
||||
},
|
||||
"username": "johnsmith",
|
||||
"email": "john.smith@example.com",
|
||||
"timeZoneCode": "Europe/Amsterdam",
|
||||
"roles": [
|
||||
"Merchant standard role"
|
||||
],
|
||||
"associatedMerchantAccounts": [
|
||||
"YOUR_MERCHANT_ACCOUNT"
|
||||
]
|
||||
};
|
||||
|
||||
export const updateMerchantUserRequest = {
|
||||
"accountGroups": ["string"],
|
||||
"active": false,
|
||||
"email": "string",
|
||||
"name": {
|
||||
"firstName": "string",
|
||||
"lastName": "string"
|
||||
},
|
||||
"roles": ["string"],
|
||||
"timeZoneCode": "string"
|
||||
};
|
||||
|
||||
export const createMerchantWebhookRequest = {
|
||||
"acceptsExpiredCertificate": false,
|
||||
"acceptsSelfSignedCertificate": false,
|
||||
"acceptsUntrustedRootCertificate": false,
|
||||
"active": false,
|
||||
"additionalSettings": {
|
||||
"includeEventCodes": ["string"],
|
||||
"properties": { "sample": false }
|
||||
},
|
||||
"communicationFormat": "HTTP",
|
||||
"description": "string",
|
||||
"networkType": "LOCAL",
|
||||
"password": "string",
|
||||
"populateSoapActionHeader": false,
|
||||
"sslVersion": "HTTP",
|
||||
"type": "string",
|
||||
"url": "string",
|
||||
"username": "string"
|
||||
};
|
||||
|
||||
export const updateMerchantWebhookRequest = {
|
||||
"acceptsExpiredCertificate": false,
|
||||
"acceptsSelfSignedCertificate": false,
|
||||
"acceptsUntrustedRootCertificate": false,
|
||||
"active": false,
|
||||
"additionalSettings": {
|
||||
"includeEventCodes": ["string"],
|
||||
"properties": { "sample": false }
|
||||
},
|
||||
"communicationFormat": "HTTP",
|
||||
"description": "string",
|
||||
"networkType": "LOCAL",
|
||||
"password": "string",
|
||||
"populateSoapActionHeader": false,
|
||||
"sslVersion": "HTTP",
|
||||
"url": "string",
|
||||
"username": "string"
|
||||
};
|
||||
|
||||
export const testWebhookRequest = {
|
||||
"notification": {
|
||||
"amount": {
|
||||
"currency": "string",
|
||||
"value": 0
|
||||
},
|
||||
"eventCode": "string",
|
||||
"eventDate": "string",
|
||||
"merchantReference": "string",
|
||||
"paymentMethod": "string",
|
||||
"reason": "string",
|
||||
"success": false
|
||||
},
|
||||
"types": ["string"]
|
||||
};
|
||||
1506
src/__mocks__/management/responses.ts
Normal file
1506
src/__mocks__/management/responses.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -21,59 +21,55 @@ export const listRecurringDetailsSuccess = {
|
||||
"creationDate": "2017-03-01T11:53:11+01:00",
|
||||
"details": [
|
||||
{
|
||||
"RecurringDetail": {
|
||||
"acquirer": "TestPmmAcquirer",
|
||||
"acquirerAccount": "TestPmmAcquirerAccount",
|
||||
"additionalData": {
|
||||
"cardBin": "411111"
|
||||
},
|
||||
"alias": "cardAlias",
|
||||
"aliasType": "Default",
|
||||
"card": {
|
||||
"expiryMonth": "8",
|
||||
"expiryYear": "2018",
|
||||
"holderName": "Holder",
|
||||
"number": "1111"
|
||||
},
|
||||
"contractTypes": [
|
||||
"ONECLICK"
|
||||
],
|
||||
"creationDate": "2017-03-07T09:43:33+01:00",
|
||||
"firstPspReference": "8524888762135795",
|
||||
"paymentMethodVariant": "visa",
|
||||
"recurringDetailReference": "recurringReference",
|
||||
"variant": "visa"
|
||||
}
|
||||
"acquirer": "TestPmmAcquirer",
|
||||
"acquirerAccount": "TestPmmAcquirerAccount",
|
||||
"additionalData": {
|
||||
"cardBin": "411111"
|
||||
},
|
||||
"alias": "cardAlias",
|
||||
"aliasType": "Default",
|
||||
"card": {
|
||||
"expiryMonth": "8",
|
||||
"expiryYear": "2018",
|
||||
"holderName": "Holder",
|
||||
"number": "1111"
|
||||
},
|
||||
"contractTypes": [
|
||||
"ONECLICK"
|
||||
],
|
||||
"creationDate": "2017-03-07T09:43:33+01:00",
|
||||
"firstPspReference": "8524888762135795",
|
||||
"paymentMethodVariant": "visa",
|
||||
"recurringDetailReference": "recurringReference",
|
||||
"variant": "visa"
|
||||
},
|
||||
{
|
||||
"RecurringDetail": {
|
||||
"acquirer": "PayPalSandbox",
|
||||
"acquirerAccount": "TestPmmAcquirerAccount",
|
||||
"billingAddress": {
|
||||
"city": "City",
|
||||
"country": "NL",
|
||||
"houseNumberOrName": "1",
|
||||
"postalCode": "2312aa",
|
||||
"stateOrProvince": "NA",
|
||||
"street": "Street"
|
||||
"acquirer": "PayPalSandbox",
|
||||
"acquirerAccount": "TestPmmAcquirerAccount",
|
||||
"billingAddress": {
|
||||
"city": "City",
|
||||
"country": "NL",
|
||||
"houseNumberOrName": "1",
|
||||
"postalCode": "2312aa",
|
||||
"stateOrProvince": "NA",
|
||||
"street": "Street"
|
||||
},
|
||||
"contractTypes": [
|
||||
"RECURRING"
|
||||
],
|
||||
"creationDate": "2017-10-10T08:50:02+02:00",
|
||||
"firstPspReference": "8515076181707110",
|
||||
"paymentMethodVariant": "paypal",
|
||||
"recurringDetailReference": "8315076181982020",
|
||||
"tokenDetails": {
|
||||
"tokenData": {
|
||||
"EmailId": "tedtest@test.nl",
|
||||
"PayPal.PayerId": "H95EPL8B2KFE6",
|
||||
"BillingAgreementId": "B-7MA42752FE774625C"
|
||||
},
|
||||
"contractTypes": [
|
||||
"RECURRING"
|
||||
],
|
||||
"creationDate": "2017-10-10T08:50:02+02:00",
|
||||
"firstPspReference": "8515076181707110",
|
||||
"paymentMethodVariant": "paypal",
|
||||
"recurringDetailReference": "8315076181982020",
|
||||
"tokenDetails": {
|
||||
"tokenData": {
|
||||
"EmailId": "tedtest@test.nl",
|
||||
"PayPal.PayerId": "H95EPL8B2KFE6",
|
||||
"BillingAgreementId": "B-7MA42752FE774625C"
|
||||
},
|
||||
"tokenDataType": "PayPal"
|
||||
},
|
||||
"variant": "paypal"
|
||||
}
|
||||
"tokenDataType": "PayPal"
|
||||
},
|
||||
"variant": "paypal"
|
||||
}
|
||||
],
|
||||
"shopperReference": "test-123",
|
||||
|
||||
894
src/__tests__/balancePlatform.spec.ts
Normal file
894
src/__tests__/balancePlatform.spec.ts
Normal file
@@ -0,0 +1,894 @@
|
||||
import nock from "nock";
|
||||
import Client from "../client";
|
||||
import { createClient } from "../__mocks__/base";
|
||||
import BalancePlatform from "../services/balancePlatform";
|
||||
import * as models from "../typings/balancePlatform/models";
|
||||
import { AccountHolderUpdate } from "../services/balancePlaftform/accountHolders";
|
||||
import { SweepConfigurationV2Create, SweepConfigurationV2Update } from "../services/balancePlaftform/balanceAccounts";
|
||||
import { TransactionRuleInfoUpdate } from "../services/balancePlaftform/transactionRules";
|
||||
|
||||
let client: Client;
|
||||
let balancePlatform: BalancePlatform;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
client = createClient();
|
||||
scope = nock(`${client.config.balancePlatformEndpoint}/${Client.BALANCE_PLATFORM_API_VERSION}`);
|
||||
balancePlatform = new BalancePlatform(client);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
describe("Balance Platform", (): void => {
|
||||
const balanceAccountId = "BA32272223222B59CZ3T52DKZ";
|
||||
const sweepId = "SWPC4227C224555B5FTD2NT2JV4WN5";
|
||||
const paymentInstrumentId = "PI32272223222B5CMD3MQ3HXX";
|
||||
const paymentInstrumentGroupId = "PG3227C223222B5CMD3FJFKGZ";
|
||||
const transactionRuleId = "TR3227C223222B5FCB756DV9H";
|
||||
|
||||
describe("AccountHolders", (): void => {
|
||||
it("should support POST /accountHolders", async (): Promise<void> => {
|
||||
scope.post("/accountHolders")
|
||||
.reply(200, {
|
||||
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||
"contactDetails": {
|
||||
"email": "s.hopper@example.com",
|
||||
"phone": {
|
||||
"number": "+315551231234",
|
||||
"type": "Mobile"
|
||||
},
|
||||
"address": {
|
||||
"city": "Amsterdam",
|
||||
"country": "NL",
|
||||
"street": "Brannan Street",
|
||||
"houseNumberOrName": "274",
|
||||
"postalCode": "1020CD"
|
||||
}
|
||||
},
|
||||
"description": "S.Hopper - Staff 123",
|
||||
"legalEntityId": "LE322KT223222D5FJ7THR293F",
|
||||
"id": "AH3227C223222B5CMD2SXFKGT",
|
||||
"status": "active"
|
||||
});
|
||||
const request: models.AccountHolderInfo = {
|
||||
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||
"description": "S.Hopper - Staff 123",
|
||||
"legalEntityId": "LE322KT223222D5FJ7THR293F",
|
||||
"contactDetails": {
|
||||
"email": "s.hopper@example.com",
|
||||
"phone": {
|
||||
"number": "+315551231234",
|
||||
"type": models.Phone.TypeEnum.Mobile
|
||||
},
|
||||
"address": {
|
||||
"city": "Amsterdam",
|
||||
"country": "NL",
|
||||
"street": "Brannan Street",
|
||||
"houseNumberOrName": "274",
|
||||
"postalCode": "1020CD"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const response: models.AccountHolder = await balancePlatform.AccountHolders.create(request);
|
||||
|
||||
expect(response.id).toBe("AH3227C223222B5CMD2SXFKGT");
|
||||
expect(response.legalEntityId).toBe("LE322KT223222D5FJ7THR293F");
|
||||
});
|
||||
|
||||
it("should support GET /accountHolders/{id}", async (): Promise<void> => {
|
||||
scope.get("/accountHolders/AH32272223222B5CM4MWJ892H")
|
||||
.reply(200, {
|
||||
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||
"contactDetails": {
|
||||
"address": {
|
||||
"city": "Amsterdam",
|
||||
"country": "NL",
|
||||
"houseNumberOrName": "274",
|
||||
"postalCode": "1020CD",
|
||||
"street": "Brannan Street"
|
||||
},
|
||||
"email": "s.hopper@example.com",
|
||||
"phone": {
|
||||
"number": "+315551231234",
|
||||
"type": "Mobile"
|
||||
}
|
||||
},
|
||||
"description": "S.Hopper - Staff 123",
|
||||
"id": "AH32272223222B5CM4MWJ892H",
|
||||
"status": "Active"
|
||||
});
|
||||
|
||||
const response: models.AccountHolder = await balancePlatform.AccountHolders.retrieve("AH32272223222B5CM4MWJ892H");
|
||||
|
||||
expect(response.id).toBe("AH32272223222B5CM4MWJ892H");
|
||||
expect(response.balancePlatform).toBe("YOUR_BALANCE_PLATFORM");
|
||||
});
|
||||
|
||||
it("should support PATCH /accountHolders/{id}", async (): Promise<void> => {
|
||||
scope.patch("/accountHolders/AH32272223222B5CM4MWJ892H")
|
||||
.reply(200, {
|
||||
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||
"contactDetails": {
|
||||
"address": {
|
||||
"city": "Amsterdam",
|
||||
"country": "NL",
|
||||
"houseNumberOrName": "274",
|
||||
"postalCode": "1020CD",
|
||||
"street": "Brannan Street"
|
||||
},
|
||||
"email": "s.hopper@example.com",
|
||||
"phone": {
|
||||
"number": "+315551231234",
|
||||
"type": "Mobile"
|
||||
}
|
||||
},
|
||||
"description": "S.Hopper - Staff 123",
|
||||
"id": "AH32272223222B5CM4MWJ892H",
|
||||
"status": "Suspended"
|
||||
});
|
||||
const request: AccountHolderUpdate = {
|
||||
status: models.AccountHolder.StatusEnum.Suspended,
|
||||
legalEntityId: "LE322KT223222D5FJ7THR293F",
|
||||
};
|
||||
|
||||
const response: models.AccountHolder = await balancePlatform.AccountHolders.update("AH32272223222B5CM4MWJ892H", request);
|
||||
|
||||
expect(response.status).toBe("Suspended");
|
||||
});
|
||||
|
||||
it("should support GET /accountHolders/{id}/balanceAccounts", async (): Promise<void> => {
|
||||
scope.get("/accountHolders/AH32272223222B5CM4MWJ892H/balanceAccounts?limit=5&offset=10")
|
||||
.reply(200, {
|
||||
"balanceAccounts": [
|
||||
{
|
||||
"accountHolderId": "AH32272223222B59K6ZKBBFNQ",
|
||||
"defaultCurrencyCode": "EUR",
|
||||
"id": "BA32272223222B59K6ZXHBFN6",
|
||||
"status": "Active"
|
||||
},
|
||||
{
|
||||
"accountHolderId": "AH32272223222B59K6ZKBBFNQ",
|
||||
"defaultCurrencyCode": "EUR",
|
||||
"id": "BA32272223222B59K72CKBFNJ",
|
||||
"status": "Active"
|
||||
},
|
||||
{
|
||||
"accountHolderId": "AH32272223222B59K6ZKBBFNQ",
|
||||
"defaultCurrencyCode": "EUR",
|
||||
"id": "BA32272223222B5BRR27B2M7G",
|
||||
"status": "Active"
|
||||
}
|
||||
],
|
||||
"hasNext": true,
|
||||
"hasPrevious": false
|
||||
});
|
||||
|
||||
const response: models.PaginatedBalanceAccountsResponse = await balancePlatform.AccountHolders.listBalanceAccounts("AH32272223222B5CM4MWJ892H", {
|
||||
params: {
|
||||
"limit": "5",
|
||||
"offset": "10"
|
||||
}
|
||||
});
|
||||
|
||||
expect(response.balanceAccounts[0].id).toBe("BA32272223222B59K6ZXHBFN6");
|
||||
});
|
||||
});
|
||||
|
||||
describe("BalanceAccounts", (): void => {
|
||||
it("should support POST /balanceAccounts", async (): Promise<void> => {
|
||||
scope.post("/balanceAccounts")
|
||||
.reply(200, {
|
||||
"accountHolderId": "AH32272223222B59K6ZKBBFNQ",
|
||||
"defaultCurrencyCode": "EUR",
|
||||
"reference": "S.Hopper - Main balance account",
|
||||
"balances": [
|
||||
{
|
||||
"available": 0,
|
||||
"balance": 0,
|
||||
"currency": "EUR",
|
||||
"reserved": 0
|
||||
}
|
||||
],
|
||||
"id": balanceAccountId,
|
||||
"status": "active"
|
||||
});
|
||||
const request: models.BalanceAccountInfo = {
|
||||
"accountHolderId": "AH32272223222B59K6ZKBBFNQ",
|
||||
"description": "S.Hopper - Main balance account"
|
||||
};
|
||||
|
||||
const response: models.BalanceAccount = await balancePlatform.BalanceAccounts.create(request);
|
||||
|
||||
expect(response.id).toBe(balanceAccountId);
|
||||
});
|
||||
|
||||
it("should support GET /balanceAccounts/{balanceAccountId}/sweeps", async (): Promise<void> => {
|
||||
scope.get(`/balanceAccounts/${balanceAccountId}/sweeps?limit=5&offset=10`)
|
||||
.reply(200, {
|
||||
"hasNext": false,
|
||||
"hasPrevious": false,
|
||||
"sweeps": [
|
||||
{
|
||||
"id": sweepId,
|
||||
"schedule": {
|
||||
"type": "daily"
|
||||
},
|
||||
"status": "active",
|
||||
"targetAmount": {
|
||||
"currency": "EUR",
|
||||
"value": 0
|
||||
},
|
||||
"triggerAmount": {
|
||||
"currency": "EUR",
|
||||
"value": 0
|
||||
},
|
||||
"type": "push",
|
||||
"counterparty": {
|
||||
"balanceAccountId": "BA32272223222B5FTD2KR6TJD"
|
||||
},
|
||||
"currency": "EUR"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const response: models.BalanceSweepConfigurationsResponse = await balancePlatform.BalanceAccounts.listSweeps(balanceAccountId, {
|
||||
params: {
|
||||
"limit": "5",
|
||||
"offset": "10"
|
||||
}
|
||||
});
|
||||
|
||||
expect(response.hasNext).toBeFalsy();
|
||||
expect(response.sweeps.length).toBe(1);
|
||||
});
|
||||
|
||||
it("should support POST /balanceAccounts/{balanceAccountId}/sweeps", async (): Promise<void> => {
|
||||
scope.post(`/balanceAccounts/${balanceAccountId}/sweeps`)
|
||||
.reply(200, {
|
||||
"id": sweepId,
|
||||
"counterparty": {
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||
},
|
||||
"triggerAmount": {
|
||||
"currency": "EUR",
|
||||
"value": 50000
|
||||
},
|
||||
"currency": "EUR",
|
||||
"schedule": {
|
||||
"type": "balance"
|
||||
},
|
||||
"type": "pull",
|
||||
"status": "active"
|
||||
});
|
||||
const request: SweepConfigurationV2Create = {
|
||||
"counterparty": {
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||
},
|
||||
"triggerAmount": {
|
||||
"currency": "EUR",
|
||||
"value": 50000
|
||||
},
|
||||
"currency": "EUR",
|
||||
"schedule": {
|
||||
"type": models.SweepSchedule.TypeEnum.Balance
|
||||
},
|
||||
"type": models.SweepConfigurationV2.TypeEnum.Pull,
|
||||
"status": models.SweepConfigurationV2.StatusEnum.Active
|
||||
};
|
||||
|
||||
const response: models.SweepConfigurationV2 = await balancePlatform.BalanceAccounts.createSweep(balanceAccountId, request);
|
||||
|
||||
expect(response.id).toBe(sweepId);
|
||||
expect(response.triggerAmount!.value).toBe(50000);
|
||||
});
|
||||
|
||||
it("should support DELETE /balanceAccounts/{balanceAccountId}/sweeps/{sweepId}", async (): Promise<void> => {
|
||||
scope.delete(`/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`).reply(204);
|
||||
|
||||
await balancePlatform.BalanceAccounts.deleteSweep(balanceAccountId, sweepId);
|
||||
});
|
||||
|
||||
it("should support GET /balanceAccounts/{balanceAccountId}/sweeps/{sweepId}", async (): Promise<void> => {
|
||||
scope.get(`/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`)
|
||||
.reply(200, {
|
||||
"id": sweepId,
|
||||
"schedule": {
|
||||
"type": "daily"
|
||||
},
|
||||
"status": "active",
|
||||
"targetAmount": {
|
||||
"currency": "EUR",
|
||||
"value": 0
|
||||
},
|
||||
"triggerAmount": {
|
||||
"currency": "EUR",
|
||||
"value": 0
|
||||
},
|
||||
"type": "push",
|
||||
"counterparty": {
|
||||
"balanceAccountId": "BA32272223222B5FTD2KR6TJD"
|
||||
},
|
||||
"currency": "EUR"
|
||||
});
|
||||
|
||||
const response: models.SweepConfigurationV2 = await balancePlatform.BalanceAccounts.retrieveSweep(balanceAccountId, sweepId);
|
||||
|
||||
expect(response.id).toBe(sweepId);
|
||||
expect(response.status).toBe("active");
|
||||
});
|
||||
|
||||
it("should support PATCH /balanceAccounts/{balanceAccountId}/sweeps/{sweepId}", async (): Promise<void> => {
|
||||
scope.patch(`/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`)
|
||||
.reply(200, {
|
||||
"id": sweepId,
|
||||
"counterparty": {
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||
},
|
||||
"triggerAmount": {
|
||||
"currency": "EUR",
|
||||
"value": 50000
|
||||
},
|
||||
"currency": "EUR",
|
||||
"schedule": {
|
||||
"type": "balance"
|
||||
},
|
||||
"type": "pull",
|
||||
"status": "inactive"
|
||||
});
|
||||
const request: SweepConfigurationV2Update = {
|
||||
"status": models.SweepConfigurationV2.StatusEnum.Inactive
|
||||
};
|
||||
|
||||
const response: models.SweepConfigurationV2 = await balancePlatform.BalanceAccounts.updateSweep(balanceAccountId, sweepId, request);
|
||||
|
||||
expect(response.status).toBe("inactive");
|
||||
});
|
||||
|
||||
it("should support GET /balanceAccounts/{id}", async (): Promise<void> => {
|
||||
scope.get(`/balanceAccounts/${balanceAccountId}`)
|
||||
.reply(200, {
|
||||
"accountHolderId": "AH32272223222B59K6RTQBFNZ",
|
||||
"defaultCurrencyCode": "EUR",
|
||||
"balances": [
|
||||
{
|
||||
"available": 0,
|
||||
"balance": 0,
|
||||
"currency": "EUR",
|
||||
"reserved": 0
|
||||
}
|
||||
],
|
||||
"id": balanceAccountId,
|
||||
"status": "Active"
|
||||
});
|
||||
|
||||
const response: models.BalanceAccount = await balancePlatform.BalanceAccounts.retrieve(balanceAccountId);
|
||||
|
||||
expect(response.id).toBe(balanceAccountId);
|
||||
expect(response.status).toBe("Active");
|
||||
});
|
||||
|
||||
it("should support PATCH /balanceAccounts/{id}", async (): Promise<void> => {
|
||||
scope.patch(`/balanceAccounts/${balanceAccountId}`)
|
||||
.reply(200, {
|
||||
"accountHolderId": "string",
|
||||
"balances": [
|
||||
{
|
||||
"available": 0,
|
||||
"balance": 0,
|
||||
"currency": "string",
|
||||
"reserved": 0
|
||||
}
|
||||
],
|
||||
"defaultCurrencyCode": "string",
|
||||
"description": "Testing",
|
||||
"id": "string",
|
||||
"reference": "string",
|
||||
"status": "active",
|
||||
"timeZone": "Europe/Amsterdam"
|
||||
});
|
||||
const request: models.BalanceAccountUpdateRequest = {
|
||||
"description": "Testing",
|
||||
"status": models.BalanceAccountUpdateRequest.StatusEnum.Active,
|
||||
"timeZone": "Europe/Amsterdam"
|
||||
};
|
||||
|
||||
const response: models.BalanceAccount = await balancePlatform.BalanceAccounts.update(balanceAccountId, request);
|
||||
|
||||
expect(response.status).toBe("active");
|
||||
expect(response.timeZone).toBe("Europe/Amsterdam");
|
||||
});
|
||||
|
||||
it("should support GET /balanceAccounts/{id}/paymentInstruments", async (): Promise<void> => {
|
||||
scope.get(`/balanceAccounts/${balanceAccountId}/paymentInstruments?limit=3&offset=6`)
|
||||
.reply(200, {
|
||||
"hasNext": "true",
|
||||
"hasPrevious": "false",
|
||||
"paymentInstruments": [
|
||||
{
|
||||
"balanceAccountId": balanceAccountId,
|
||||
"issuingCountryCode": "GB",
|
||||
"status": "Active",
|
||||
"type": "card",
|
||||
"card": {
|
||||
"brandVariant": "mc",
|
||||
"cardholderName": "name",
|
||||
"formFactor": "virtual",
|
||||
"bin": "555544",
|
||||
"expiration": {
|
||||
"month": "12",
|
||||
"year": "2022"
|
||||
},
|
||||
"lastFour": "2357",
|
||||
"number": "************2357"
|
||||
},
|
||||
"id": "PI32272223222B59M5TM658DT"
|
||||
},
|
||||
{
|
||||
"balanceAccountId": balanceAccountId,
|
||||
"issuingCountryCode": "GB",
|
||||
"status": "Active",
|
||||
"type": "card",
|
||||
"card": {
|
||||
"brandVariant": "mc",
|
||||
"cardholderName": "name",
|
||||
"formFactor": "virtual",
|
||||
"bin": "555544",
|
||||
"expiration": {
|
||||
"month": "01",
|
||||
"year": "2023"
|
||||
},
|
||||
"lastFour": "8331",
|
||||
"number": "************8331"
|
||||
},
|
||||
"id": "PI32272223222B59PXDGQDLSF"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const response: models.PaginatedPaymentInstrumentsResponse = await balancePlatform.BalanceAccounts.listPaymentInstruments(balanceAccountId, {
|
||||
params: {
|
||||
limit: "3",
|
||||
offset: "6",
|
||||
}
|
||||
});
|
||||
|
||||
expect(response.paymentInstruments.length).toBe(2);
|
||||
expect(response.paymentInstruments[0].id).toBe("PI32272223222B59M5TM658DT");
|
||||
});
|
||||
});
|
||||
|
||||
describe("General", (): void => {
|
||||
it("should support GET /balancePlatforms/{id}", async (): Promise<void> => {
|
||||
scope.get(`/balancePlatforms/${balanceAccountId}`)
|
||||
.reply(200, {
|
||||
"id": balanceAccountId,
|
||||
"status": "Active"
|
||||
});
|
||||
|
||||
const response: models.BalancePlatform = await balancePlatform.General.retrieve(balanceAccountId);
|
||||
|
||||
expect(response.id).toBe(balanceAccountId);
|
||||
expect(response.status).toBe("Active");
|
||||
});
|
||||
|
||||
it("should support GET /balancePlatforms/{id}/accountHolders", async (): Promise<void> => {
|
||||
scope.get(`/balancePlatforms/${balanceAccountId}/accountHolders`)
|
||||
.reply(200, {
|
||||
"accountHolders": [
|
||||
{
|
||||
"contactDetails": {
|
||||
"address": {
|
||||
"city": "Amsterdam",
|
||||
"country": "NL",
|
||||
"houseNumberOrName": "6",
|
||||
"postalCode": "12336750",
|
||||
"street": "Simon Carmiggeltstraat"
|
||||
}
|
||||
},
|
||||
"description": "J. Doe",
|
||||
"id": "AH32272223222B59DDWSCCMP7",
|
||||
"status": "Active"
|
||||
},
|
||||
{
|
||||
"contactDetails": {
|
||||
"address": {
|
||||
"city": "Amsterdam",
|
||||
"country": "NL",
|
||||
"houseNumberOrName": "11",
|
||||
"postalCode": "12336750",
|
||||
"street": "Simon Carmiggeltstraat"
|
||||
}
|
||||
},
|
||||
"description": "S. Hopper",
|
||||
"id": "AH32272223222B59DJ7QBCMPN",
|
||||
"status": "Active"
|
||||
}
|
||||
],
|
||||
"hasNext": "true",
|
||||
"hasPrevious": "false"
|
||||
});
|
||||
|
||||
const response: models.PaginatedAccountHoldersResponse = await balancePlatform.General.listAccountHolders(balanceAccountId);
|
||||
|
||||
expect(response.accountHolders.length).toBe(2);
|
||||
expect(response.accountHolders[0].id).toBe("AH32272223222B59DDWSCCMP7");
|
||||
});
|
||||
});
|
||||
|
||||
describe("PaymentInstruments", (): void => {
|
||||
it("should support POST /paymentInstruments", async (): Promise<void> => {
|
||||
scope.post("/paymentInstruments")
|
||||
.reply(200, {
|
||||
"balanceAccountId": balanceAccountId,
|
||||
"description": "S. Hopper - Main card",
|
||||
"issuingCountryCode": "GB",
|
||||
"status": "Active",
|
||||
"type": "card",
|
||||
"card": {
|
||||
"brand": "mc",
|
||||
"brandVariant": "mcdebit",
|
||||
"cardholderName": "Simon Hopper",
|
||||
"formFactor": "virtual",
|
||||
"bin": "555544",
|
||||
"cvc": "873",
|
||||
"expiration": {
|
||||
"month": "01",
|
||||
"year": "2024"
|
||||
},
|
||||
"lastFour": "3548"
|
||||
},
|
||||
"id": paymentInstrumentId
|
||||
});
|
||||
const request: models.PaymentInstrumentInfo = {
|
||||
"type": models.PaymentInstrumentInfo.TypeEnum.Card,
|
||||
"issuingCountryCode": "NL",
|
||||
"balanceAccountId": balanceAccountId,
|
||||
"status": models.PaymentInstrumentInfo.StatusEnum.Inactive,
|
||||
"card": {
|
||||
"formFactor": models.CardInfo.FormFactorEnum.Physical,
|
||||
"brand": "mc",
|
||||
"brandVariant": "mcdebit",
|
||||
"cardholderName": "Sam Hopper",
|
||||
"deliveryContact": {
|
||||
"address": {
|
||||
"city": "Amsterdam",
|
||||
"country": "NL",
|
||||
"stateOrProvince": "NH",
|
||||
"line1": "Simon Carmiggeltstraat",
|
||||
"line2": "6-50",
|
||||
"postalCode": "1011DJ"
|
||||
},
|
||||
"name": {
|
||||
"firstName": "Sam",
|
||||
"lastName": "Hopper"
|
||||
}
|
||||
},
|
||||
"configuration": {
|
||||
"configurationProfileId": "YOUR_CONFIGURATION_PROFILE_ID"
|
||||
},
|
||||
},
|
||||
"description": "S.Hopper - Main card"
|
||||
};
|
||||
|
||||
const response: models.PaymentInstrument = await balancePlatform.PaymentInstruments.create(request);
|
||||
|
||||
expect(response.id).toBe(paymentInstrumentId);
|
||||
expect(response.balanceAccountId).toBe(balanceAccountId);
|
||||
});
|
||||
|
||||
it("should support GET /paymentInstruments/{id}", async (): Promise<void> => {
|
||||
scope.get(`/paymentInstruments/${paymentInstrumentId}`)
|
||||
.reply(200, {
|
||||
"balanceAccountId": balanceAccountId,
|
||||
"description": "S. Hopper - Main card",
|
||||
"issuingCountryCode": "GB",
|
||||
"status": "active",
|
||||
"type": "card",
|
||||
"card": {
|
||||
"brand": "mc",
|
||||
"brandVariant": "mcdebit",
|
||||
"cardholderName": "Simon Hopper",
|
||||
"formFactor": "virtual",
|
||||
"bin": "555544",
|
||||
"expiration": {
|
||||
"month": "01",
|
||||
"year": "2024"
|
||||
},
|
||||
"lastFour": "3548",
|
||||
"number": "************3548"
|
||||
},
|
||||
"id": paymentInstrumentId
|
||||
});
|
||||
|
||||
const response: models.PaymentInstrument = await balancePlatform.PaymentInstruments.retrieve(paymentInstrumentId);
|
||||
|
||||
expect(response.id).toBe(paymentInstrumentId);
|
||||
expect(response.status).toBe("active");
|
||||
});
|
||||
|
||||
it("should support PATCH /paymentInstruments/{id}", async (): Promise<void> => {
|
||||
scope.patch(`/paymentInstruments/${paymentInstrumentId}`)
|
||||
.reply(200, {
|
||||
"balanceAccountId": "BA32272223222B5CM82WL892M",
|
||||
"description": "S. Hopper - Main card",
|
||||
"issuingCountryCode": "GB",
|
||||
"status": "inactive",
|
||||
"type": "card",
|
||||
"card": {
|
||||
"brand": "mc",
|
||||
"brandVariant": "mcdebit",
|
||||
"cardholderName": "Simon Hopper",
|
||||
"formFactor": "virtual",
|
||||
"bin": "555544",
|
||||
"expiration": {
|
||||
"month": "01",
|
||||
"year": "2024"
|
||||
},
|
||||
"lastFour": "5785",
|
||||
"number": "************5785"
|
||||
},
|
||||
"id": paymentInstrumentId
|
||||
});
|
||||
const request: models.PaymentInstrumentUpdateRequest = {
|
||||
"balanceAccountId": "BA32272223222B5CM82WL892M"
|
||||
};
|
||||
|
||||
const response: models.PaymentInstrument = await balancePlatform.PaymentInstruments.update(paymentInstrumentId, request);
|
||||
|
||||
expect(response.id).toBe(paymentInstrumentId);
|
||||
expect(response.balanceAccountId).toBe("BA32272223222B5CM82WL892M");
|
||||
});
|
||||
|
||||
it("should support GET /paymentInstruments/{id}/transactionRules", async (): Promise<void> => {
|
||||
scope.get(`/paymentInstruments/${paymentInstrumentId}/transactionRules`)
|
||||
.reply(200, {
|
||||
"transactionRules": [
|
||||
{
|
||||
"description": "Allow 5 transactions per month",
|
||||
"interval": {
|
||||
"type": "monthly"
|
||||
},
|
||||
"maxTransactions": 5,
|
||||
"paymentInstrumentGroupId": paymentInstrumentGroupId,
|
||||
"reference": "myRule12345",
|
||||
"startDate": "2021-01-25T12:46:35.476629Z",
|
||||
"status": "active",
|
||||
"type": "velocity",
|
||||
"id": "TR32272223222B5CMDGMC9F4F"
|
||||
},
|
||||
{
|
||||
"amount": {
|
||||
"currency": "EUR",
|
||||
"value": 10000
|
||||
},
|
||||
"description": "Allow up to 100 EUR per month",
|
||||
"interval": {
|
||||
"type": "monthly"
|
||||
},
|
||||
"paymentInstrumentGroupId": paymentInstrumentGroupId,
|
||||
"reference": "myRule16378",
|
||||
"startDate": "2021-01-25T12:46:35.476629Z",
|
||||
"status": "active",
|
||||
"type": "velocity",
|
||||
"id": "TR32272223222B5CMDGT89F4F"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const response: models.TransactionRulesResponse = await balancePlatform.PaymentInstruments.listTransactionRules(paymentInstrumentId);
|
||||
|
||||
expect(response.transactionRules!.length).toBe(2);
|
||||
expect(response.transactionRules![0].id).toBe("TR32272223222B5CMDGMC9F4F");
|
||||
});
|
||||
});
|
||||
|
||||
describe("PaymentInstrumentGroups", (): void => {
|
||||
it("should support POST /paymentInstrumentGroups", async (): Promise<void> => {
|
||||
scope.post("/paymentInstrumentGroups")
|
||||
.reply(200, {
|
||||
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||
"txVariant": "mc",
|
||||
"id": paymentInstrumentGroupId
|
||||
});
|
||||
const request: models.PaymentInstrumentGroupInfo = {
|
||||
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||
"txVariant": "mc"
|
||||
};
|
||||
|
||||
const response: models.PaymentInstrumentGroup = await balancePlatform.PaymentInstrumentGroups.create(request);
|
||||
|
||||
expect(response.id).toBe(paymentInstrumentGroupId);
|
||||
expect(response.txVariant).toBe("mc");
|
||||
});
|
||||
|
||||
it("should support GET /paymentInstrumentGroups/{id}", async (): Promise<void> => {
|
||||
scope.get(`/paymentInstrumentGroups/${paymentInstrumentGroupId}`)
|
||||
.reply(200, {
|
||||
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||
"txVariant": "mc",
|
||||
"id": paymentInstrumentGroupId
|
||||
});
|
||||
|
||||
const response: models.PaymentInstrumentGroup = await balancePlatform.PaymentInstrumentGroups.retrieve(paymentInstrumentGroupId);
|
||||
|
||||
expect(response.id).toBe(paymentInstrumentGroupId);
|
||||
expect(response.txVariant).toBe("mc");
|
||||
});
|
||||
|
||||
it("should support GET /paymentInstrumentGroups/{id}/transactionRules", async (): Promise<void> => {
|
||||
scope.get(`/paymentInstrumentGroups/${paymentInstrumentGroupId}/transactionRules`)
|
||||
.reply(200, {
|
||||
"transactionRules": [
|
||||
{
|
||||
"description": "Allow 5 transactions per month",
|
||||
"interval": {
|
||||
"type": "monthly"
|
||||
},
|
||||
"maxTransactions": 5,
|
||||
"paymentInstrumentGroupId": paymentInstrumentGroupId,
|
||||
"reference": "myRule12345",
|
||||
"startDate": "2021-01-25T12:46:35.476629Z",
|
||||
"status": "active",
|
||||
"type": "velocity",
|
||||
"id": "TR32272223222B5CMDGMC9F4F"
|
||||
},
|
||||
{
|
||||
"amount": {
|
||||
"currency": "EUR",
|
||||
"value": 10000
|
||||
},
|
||||
"description": "Allow up to 100 EUR per month",
|
||||
"interval": {
|
||||
"type": "monthly"
|
||||
},
|
||||
"paymentInstrumentGroupId": paymentInstrumentGroupId,
|
||||
"reference": "myRule16378",
|
||||
"startDate": "2021-01-25T12:46:35.476629Z",
|
||||
"status": "active",
|
||||
"type": "velocity",
|
||||
"id": "TR32272223222B5CMDGT89F4F"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const response: models.TransactionRulesResponse = await balancePlatform.PaymentInstrumentGroups.listTransactionRules(paymentInstrumentGroupId);
|
||||
|
||||
expect(response.transactionRules!.length).toBe(2);
|
||||
expect(response.transactionRules![0].id).toBe("TR32272223222B5CMDGMC9F4F");
|
||||
});
|
||||
});
|
||||
|
||||
describe("TransactionRules", (): void => {
|
||||
it("should support POST /transactionRules", async (): Promise<void> => {
|
||||
scope.post("/transactionRules")
|
||||
.reply(200, {
|
||||
"description": "Allow only point-of-sale transactions",
|
||||
"entityKey": {
|
||||
"entityReference": "PI3227C223222B5BPCMFXD2XG",
|
||||
"entityType": "paymentInstrument"
|
||||
},
|
||||
"interval": {
|
||||
"timeZone": "UTC",
|
||||
"type": "perTransaction"
|
||||
},
|
||||
"outcomeType": "hardBlock",
|
||||
"reference": "YOUR_REFERENCE_4F7346",
|
||||
"requestType": "authorization",
|
||||
"ruleRestrictions": {
|
||||
"processingTypes": {
|
||||
"operation": "noneMatch",
|
||||
"value": [
|
||||
"pos"
|
||||
]
|
||||
}
|
||||
},
|
||||
"startDate": "2022-03-23T15:05:11.979433+01:00",
|
||||
"status": "active",
|
||||
"type": "blockList",
|
||||
"id": transactionRuleId
|
||||
});
|
||||
const request: models.TransactionRuleInfo = {
|
||||
"description": "Allow only point-of-sale transactions",
|
||||
"reference": "YOUR_REFERENCE_4F7346",
|
||||
"entityKey": {
|
||||
"entityType": "paymentInstrument",
|
||||
"entityReference": "PI3227C223222B5BPCMFXD2XG"
|
||||
},
|
||||
"status": models.TransactionRuleInfo.StatusEnum.Active,
|
||||
"interval": {
|
||||
"type": models.TransactionRuleInterval.TypeEnum.PerTransaction
|
||||
},
|
||||
"ruleRestrictions": {
|
||||
"processingTypes": {
|
||||
"operation": "noneMatch",
|
||||
"value": [
|
||||
models.ProcessingTypesRestriction.ValueEnum.Pos
|
||||
]
|
||||
}
|
||||
},
|
||||
"type": models.TransactionRuleInfo.TypeEnum.BlockList
|
||||
};
|
||||
|
||||
const response: models.TransactionRule = await balancePlatform.TransactionRules.create(request);
|
||||
|
||||
expect(response.id).toBe(transactionRuleId);
|
||||
expect(response.status).toBe("active");
|
||||
});
|
||||
|
||||
it("should support GET /transactionRules/{transactionRuleId}", async (): Promise<void> => {
|
||||
scope.get(`/transactionRules/${transactionRuleId}`)
|
||||
.reply(200, {
|
||||
"transactionRule": {
|
||||
"description": "Allow 5 transactions per month",
|
||||
"interval": {
|
||||
"type": "monthly"
|
||||
},
|
||||
"maxTransactions": 5,
|
||||
"paymentInstrumentId": "PI3227C223222B59KGTXP884R",
|
||||
"reference": "myRule12345",
|
||||
"startDate": "2021-01-25T12:46:35.476629Z",
|
||||
"status": "active",
|
||||
"type": "velocity",
|
||||
"id": transactionRuleId
|
||||
}
|
||||
});
|
||||
|
||||
const response: models.TransactionRuleResponse = await balancePlatform.TransactionRules.retrieve(transactionRuleId);
|
||||
|
||||
expect(response.transactionRule!.id).toBe(transactionRuleId);
|
||||
expect(response.transactionRule!.type).toBe("velocity");
|
||||
});
|
||||
|
||||
it("should support PATCH /transactionRules/{transactionRuleId}", async (): Promise<void> => {
|
||||
scope.patch(`/transactionRules/${transactionRuleId}`)
|
||||
.reply(200, {
|
||||
"description": "Allow 5 transactions per month",
|
||||
"interval": {
|
||||
"type": "monthly"
|
||||
},
|
||||
"reference": "myRule12345",
|
||||
"startDate": "2021-01-21T12:46:35.476629Z",
|
||||
"status": "inactive",
|
||||
"type": "velocity",
|
||||
"id": transactionRuleId
|
||||
});
|
||||
const request: TransactionRuleInfoUpdate = {
|
||||
"status": models.TransactionRuleInfo.StatusEnum.Inactive
|
||||
};
|
||||
|
||||
const response: models.TransactionRule = await balancePlatform.TransactionRules.update(transactionRuleId, request);
|
||||
|
||||
expect(response.status).toBe("inactive");
|
||||
expect(response.reference).toBe("myRule12345");
|
||||
});
|
||||
|
||||
it("should support DELETE /transactionRules/{transactionRuleId}", async (): Promise<void> => {
|
||||
scope.delete(`/transactionRules/${transactionRuleId}`)
|
||||
.reply(200, {
|
||||
"amount": {
|
||||
"currency": "EUR",
|
||||
"value": 10000
|
||||
},
|
||||
"description": "Allow up to 100 EUR per month",
|
||||
"interval": {
|
||||
"type": "monthly"
|
||||
},
|
||||
"paymentInstrumentGroupId": "PG3227C223222B5CMD3FJFKGZ",
|
||||
"reference": "myRule16378",
|
||||
"startDate": "2021-01-25T12:46:35.476629Z",
|
||||
"type": "velocity",
|
||||
"id": transactionRuleId
|
||||
});
|
||||
|
||||
const response: models.TransactionRule = await balancePlatform.TransactionRules.delete(transactionRuleId);
|
||||
|
||||
expect(response.id).toBe(transactionRuleId);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,26 +1,13 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
import nock from "nock";
|
||||
import { createClient } from "../__mocks__/base";
|
||||
import BinLookup from "../services/binLookup";
|
||||
import Client from "../client";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
import {
|
||||
ThreeDSAvailabilityRequest,
|
||||
ThreeDSAvailabilityResponse,
|
||||
CostEstimateRequest,
|
||||
} from "../typings/binlookup/models";
|
||||
|
||||
const threeDSAvailabilitySuccess = {
|
||||
binDetails: {
|
||||
@@ -49,9 +36,8 @@ afterEach((): void => {
|
||||
});
|
||||
|
||||
describe("Bin Lookup", function (): void {
|
||||
test.each([false, true])("should succeed on get 3ds availability. isMock: %p", async function (isMock): Promise<void> {
|
||||
!isMock && nock.restore();
|
||||
const threeDSAvailabilityRequest: IBinLookup.ThreeDSAvailabilityRequest = {
|
||||
test("should succeed on get 3ds availability", async function (): Promise<void> {
|
||||
const threeDSAvailabilityRequest: ThreeDSAvailabilityRequest = {
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
brands: ["randomBrand"],
|
||||
cardNumber: "4111111111111111"
|
||||
@@ -62,7 +48,7 @@ describe("Bin Lookup", function (): void {
|
||||
|
||||
const response = await binLookup.get3dsAvailability(threeDSAvailabilityRequest);
|
||||
|
||||
expect(response).toEqual<IBinLookup.ThreeDSAvailabilityResponse>(threeDSAvailabilitySuccess);
|
||||
expect(response).toEqual<ThreeDSAvailabilityResponse>(threeDSAvailabilitySuccess);
|
||||
});
|
||||
|
||||
test.each([false, true])("should fail with invalid merchant. isMock: %p", async function (isMock): Promise<void> {
|
||||
@@ -77,9 +63,9 @@ describe("Bin Lookup", function (): void {
|
||||
.reply(403, JSON.stringify({status: 403, message: "fail", errorCode: "171"}));
|
||||
|
||||
try {
|
||||
await binLookup.get3dsAvailability(threeDSAvailabilityRequest as unknown as IBinLookup.ThreeDSAvailabilityRequest);
|
||||
await binLookup.get3dsAvailability(threeDSAvailabilityRequest as unknown as ThreeDSAvailabilityRequest);
|
||||
fail("Expected request to fail");
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
expect(e instanceof HttpClientException).toBeTruthy();
|
||||
}
|
||||
});
|
||||
@@ -103,7 +89,7 @@ describe("Bin Lookup", function (): void {
|
||||
resultCode: "Unsupported",
|
||||
surchargeType: "ZERO"
|
||||
};
|
||||
const costEstimateRequest: IBinLookup.CostEstimateRequest = {
|
||||
const costEstimateRequest: CostEstimateRequest = {
|
||||
amount: { currency: "EUR", value: 1000 },
|
||||
assumptions: {
|
||||
assumeLevel3Data: true,
|
||||
@@ -116,7 +102,7 @@ describe("Bin Lookup", function (): void {
|
||||
mcc: "7411",
|
||||
enrolledIn3DSecure: true
|
||||
},
|
||||
shopperInteraction: "Ecommerce"
|
||||
shopperInteraction: CostEstimateRequest.ShopperInteractionEnum.Ecommerce,
|
||||
};
|
||||
|
||||
scope.post("/getCostEstimate")
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2021 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
import nock from "nock";
|
||||
import {createClient} from "../__mocks__/base";
|
||||
import {paymentMethodsSuccess} from "../__mocks__/checkout/paymentMethodsSuccess";
|
||||
@@ -48,7 +29,9 @@ import {
|
||||
PaymentSetupRequest,
|
||||
PaymentVerificationRequest,
|
||||
CreateCheckoutSessionRequest,
|
||||
CreateCheckoutSessionResponse
|
||||
CreateCheckoutSessionResponse,
|
||||
CardDetailsRequest,
|
||||
CardDetailsResponse
|
||||
} from "../typings/checkout/models";
|
||||
|
||||
const merchantAccount = process.env.ADYEN_MERCHANT!;
|
||||
@@ -172,6 +155,86 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe("Checkout", (): void => {
|
||||
test("should add idempotency key to request headers", async (): Promise<void> => {
|
||||
const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest();
|
||||
scope.post("/payments")
|
||||
.reply(200, paymentsSuccess)
|
||||
.matchHeader("Idempotency-Key", "testKey");
|
||||
await checkout.payments(paymentsRequest, {idempotencyKey: "testKey"});
|
||||
|
||||
const paymentMethodsRequest: PaymentMethodsRequest = {merchantAccount};
|
||||
scope.post("/paymentMethods")
|
||||
.reply(200, paymentMethodsSuccess)
|
||||
.matchHeader("Idempotency-Key", "testKey");
|
||||
await checkout.paymentMethods(paymentMethodsRequest, {idempotencyKey: "testKey"});
|
||||
|
||||
const expiresAt = "2019-12-17T10:05:29Z";
|
||||
const paymentLinkSuccess: PaymentLinkResponse = getPaymentLinkSuccess(expiresAt);
|
||||
scope.post("/paymentLinks")
|
||||
.reply(200, paymentLinkSuccess)
|
||||
.matchHeader("Idempotency-Key", "testKey");
|
||||
await checkout.paymentLinks(createPaymentLinkRequest(), {idempotencyKey: "testKey"});
|
||||
|
||||
scope.patch("/paymentLinks/321")
|
||||
.reply(200, { ...paymentLinkSuccess, status: "expired" })
|
||||
.matchHeader("Idempotency-Key", "testKey");
|
||||
await checkout.updatePaymentLinks("321", "expired", {idempotencyKey: "testKey"});
|
||||
|
||||
scope.get("/paymentLinks/123")
|
||||
.reply(200, paymentLinkSuccess)
|
||||
.matchHeader("Idempotency-Key", "testKey");
|
||||
await checkout.getPaymentLinks("123", {idempotencyKey: "testKey"});
|
||||
|
||||
scope.post("/payments/details")
|
||||
.reply(200, paymentDetailsSuccess)
|
||||
.matchHeader("Idempotency-Key", "testKey");
|
||||
await checkout.paymentsDetails(createPaymentsDetailsRequest(), {idempotencyKey: "testKey"});
|
||||
|
||||
scope.post("/paymentSession")
|
||||
.reply(200, paymentSessionSuccess)
|
||||
.matchHeader("Idempotency-Key", "testKey");
|
||||
const paymentSessionRequest: PaymentSetupRequest = createPaymentSessionRequest();
|
||||
await checkout.paymentSession(paymentSessionRequest, {idempotencyKey: "testKey"});
|
||||
|
||||
scope.post("/payments/result")
|
||||
.reply(200, paymentsResultSuccess)
|
||||
.matchHeader("Idempotency-Key", "testKey");
|
||||
const paymentResultRequest: PaymentVerificationRequest = {
|
||||
payload: "This is a test payload",
|
||||
};
|
||||
await checkout.paymentResult(paymentResultRequest, {idempotencyKey: "testKey"});
|
||||
|
||||
const orderRequest: CheckoutCreateOrderRequest = {
|
||||
amount: createAmountObject("USD", 1000),
|
||||
merchantAccount,
|
||||
reference
|
||||
};
|
||||
scope.post("/orders")
|
||||
.reply(200, {})
|
||||
.matchHeader("Idempotency-Key", "testKey");
|
||||
await checkout.orders(orderRequest, {idempotencyKey: "testKey"});
|
||||
|
||||
scope.post("/orders/cancel")
|
||||
.reply(200, {})
|
||||
.matchHeader("Idempotency-Key", "testKey");
|
||||
await checkout.ordersCancel({
|
||||
order: {
|
||||
orderData: "mock_data",
|
||||
pspReference: "mock_pspref"
|
||||
},
|
||||
merchantAccount
|
||||
}, {idempotencyKey: "testKey"});
|
||||
|
||||
scope.post("/sessions")
|
||||
.reply(200, sessionsSuccess)
|
||||
.matchHeader("Idempotency-Key", "testKey");
|
||||
|
||||
const sessionsRequest: CreateCheckoutSessionRequest = createSessionRequest();
|
||||
await checkout.sessions(sessionsRequest, {idempotencyKey: "testKey"});
|
||||
|
||||
});
|
||||
|
||||
|
||||
test.each([false, true])("should make a payment. isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/payments")
|
||||
@@ -190,7 +253,7 @@ describe("Checkout", (): void => {
|
||||
|
||||
const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest();
|
||||
await checkout.payments(paymentsRequest);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
expect(e instanceof HttpClientException).toBeTruthy();
|
||||
}
|
||||
});
|
||||
@@ -284,8 +347,13 @@ describe("Checkout", (): void => {
|
||||
try {
|
||||
new Checkout(client);
|
||||
fail();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
expect(e.message).toEqual("Please provide your unique live url prefix on the setEnvironment() call on the Client or provide checkoutEndpoint in your config object.");
|
||||
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -410,5 +478,26 @@ describe("Checkout", (): void => {
|
||||
const sessionsRequest: CreateCheckoutSessionRequest = createSessionRequest();
|
||||
const sessionsResponse: CreateCheckoutSessionResponse = await checkout.sessions(sessionsRequest);
|
||||
expect(sessionsResponse.sessionData).toBeTruthy();
|
||||
expect(sessionsResponse.expiresAt).toBeInstanceOf(Date);
|
||||
expect(sessionsResponse.expiresAt.getFullYear()).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test("Should get card details", async (): Promise<void> => {
|
||||
scope.post("/cardDetails")
|
||||
.reply(200, {
|
||||
"brands": [
|
||||
{
|
||||
"supported": true,
|
||||
"type": "visa"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const cardDetailsRequest: CardDetailsRequest = {
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"cardNumber": "411111"
|
||||
};
|
||||
const cardDetailsReponse: CardDetailsResponse = await checkout.cardDetails(cardDetailsRequest);
|
||||
expect(cardDetailsReponse?.brands?.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
309
src/__tests__/classicIntegration.spec.ts
Normal file
309
src/__tests__/classicIntegration.spec.ts
Normal file
@@ -0,0 +1,309 @@
|
||||
import nock from "nock";
|
||||
import {createClient} from "../__mocks__/base";
|
||||
import Client from "../client";
|
||||
import ClassicIntegration from "../services/classicIntegration";
|
||||
import { PaymentRequest } from "../typings/payments/paymentRequest";
|
||||
import { PaymentResult } from "../typings/payments/paymentResult";
|
||||
import { PaymentRequest3d } from "../typings/payments/paymentRequest3d";
|
||||
import { PaymentRequest3ds2 } from "../typings/payments/paymentRequest3ds2";
|
||||
import { AuthenticationResultRequest } from "../typings/payments/authenticationResultRequest";
|
||||
import { AuthenticationResultResponse } from "../typings/payments/authenticationResultResponse";
|
||||
import { ThreeDS2ResultRequest } from "../typings/payments/threeDS2ResultRequest";
|
||||
import { ThreeDS2ResultResponse } from "../typings/payments/threeDS2ResultResponse";
|
||||
import { ModificationResult } from "../typings/payments/modificationResult";
|
||||
import { CaptureRequest } from "../typings/payments/captureRequest";
|
||||
import { CancelRequest } from "../typings/payments/cancelRequest";
|
||||
import { RefundRequest } from "../typings/payments/refundRequest";
|
||||
import { CancelOrRefundRequest } from "../typings/payments/cancelOrRefundRequest";
|
||||
import { TechnicalCancelRequest } from "../typings/payments/technicalCancelRequest";
|
||||
import { AdjustAuthorisationRequest } from "../typings/payments/adjustAuthorisationRequest";
|
||||
import { DonationRequest } from "../typings/payments/donationRequest";
|
||||
import { VoidPendingRefundRequest } from "../typings/payments/voidPendingRefundRequest";
|
||||
|
||||
let client: Client;
|
||||
let classicIntegration: ClassicIntegration;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
client = createClient();
|
||||
scope = nock(`${client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}`);
|
||||
classicIntegration = new ClassicIntegration(client);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
describe("Classic Integration", (): void => {
|
||||
test("Should authorise payment", async (): Promise<void> => {
|
||||
scope.post("/authorise")
|
||||
.reply(200, {
|
||||
"additionalData": {
|
||||
"scaExemptionRequested": "transactionRiskAnalysis",
|
||||
"checkout.cardAddedBrand": "visa"
|
||||
},
|
||||
"pspReference": "JVBXGSDM53RZNN82",
|
||||
"resultCode": "Authorised",
|
||||
"authCode": "011381"
|
||||
}
|
||||
);
|
||||
const paymentRequest: PaymentRequest = {
|
||||
"card": {
|
||||
"number": "4111111111111111",
|
||||
"expiryMonth": "03",
|
||||
"expiryYear": "2030",
|
||||
"cvc": "737",
|
||||
"holderName": "John Smith"
|
||||
},
|
||||
"amount": {
|
||||
"value": 1500,
|
||||
"currency": "EUR"
|
||||
},
|
||||
"reference": "YOUR_REFERENCE",
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||
};
|
||||
|
||||
const paymentResult: PaymentResult = await classicIntegration.authorise(paymentRequest);
|
||||
expect(paymentResult.pspReference).toEqual("JVBXGSDM53RZNN82");
|
||||
});
|
||||
|
||||
test("Should complete 3DS authorisation", async (): Promise<void> => {
|
||||
scope.post("/authorise3d")
|
||||
.reply(200, {
|
||||
"additionalData": {
|
||||
"scaExemptionRequested": "transactionRiskAnalysis",
|
||||
"checkout.cardAddedBrand": "visa"
|
||||
},
|
||||
"pspReference": "JVBXGSDM53RZNN82",
|
||||
"resultCode": "Authorised",
|
||||
"authCode": "011381"
|
||||
}
|
||||
);
|
||||
const paymentRequest: PaymentRequest3d = {
|
||||
"md": "31h..........vOXek7w",
|
||||
"paResponse": "eNqtmF........wGVA4Ch",
|
||||
"shopperIP": "61.294.12.12",
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||
};
|
||||
|
||||
const paymentResult: PaymentResult = await classicIntegration.authorise3d(paymentRequest);
|
||||
expect(paymentResult.pspReference).toEqual("JVBXGSDM53RZNN82");
|
||||
});
|
||||
|
||||
test("Should complete 3DS2 authorisation", async (): Promise<void> => {
|
||||
scope.post("/authorise3ds2")
|
||||
.reply(200, {
|
||||
"additionalData": {
|
||||
"scaExemptionRequested": "transactionRiskAnalysis",
|
||||
"checkout.cardAddedBrand": "visa"
|
||||
},
|
||||
"pspReference": "JVBXGSDM53RZNN82",
|
||||
"resultCode": "Authorised",
|
||||
"authCode": "011381"
|
||||
}
|
||||
);
|
||||
const paymentRequest: PaymentRequest3ds2 = {
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"amount": {
|
||||
"value": 1500,
|
||||
"currency": "EUR"
|
||||
},
|
||||
"reference": "YOUR_REFERENCE",
|
||||
"threeDS2RequestData": {
|
||||
"threeDSCompInd": "Y",
|
||||
"deviceChannel": "testDeviceChannel"
|
||||
},
|
||||
"threeDS2Token": "— - BINARY DATA - -"
|
||||
};
|
||||
|
||||
const paymentResult: PaymentResult = await classicIntegration.authorise3ds2(paymentRequest);
|
||||
expect(paymentResult.pspReference).toEqual("JVBXGSDM53RZNN82");
|
||||
});
|
||||
|
||||
test("Should get auth result after 3DS authentication", async (): Promise<void> => {
|
||||
scope.post("/getAuthenticationResult").reply(200, {
|
||||
"threeDS2Result": { "authenticationValue": "THREEDS2RESULT"}
|
||||
});
|
||||
|
||||
const getAuthenticationResultrequest: AuthenticationResultRequest = {
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"pspReference": "9935272408535455"
|
||||
};
|
||||
|
||||
const getAuthenticationResultResponse: AuthenticationResultResponse = await classicIntegration.getAuthenticationResult(getAuthenticationResultrequest);
|
||||
expect(getAuthenticationResultResponse?.threeDS2Result?.authenticationValue).toEqual("THREEDS2RESULT");
|
||||
});
|
||||
|
||||
test("Should retrieve 3DS2 result", async (): Promise<void> => {
|
||||
scope.post("/retrieve3ds2Result").reply(200, {
|
||||
"threeDS2Result": { "authenticationValue": "THREEDS2RESULT"}
|
||||
});
|
||||
const retrieve3ds2ResultRequest: ThreeDS2ResultRequest = {
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"pspReference": "9935272408535455"
|
||||
};
|
||||
|
||||
const retrieve3ds2ResultResponse: ThreeDS2ResultResponse = await classicIntegration.retrieve3ds2Result(retrieve3ds2ResultRequest);
|
||||
expect(retrieve3ds2ResultResponse?.threeDS2Result?.authenticationValue).toEqual("THREEDS2RESULT");
|
||||
});
|
||||
|
||||
test("Should succesfully send Capture request", async (): Promise<void> => {
|
||||
scope.post("/capture")
|
||||
.reply(200, {
|
||||
"pspReference": "YOUR_REFERENCE",
|
||||
"response": "[capture-received]"
|
||||
});
|
||||
|
||||
const modificationRequest: CaptureRequest = {
|
||||
"originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||
"modificationAmount": {
|
||||
"value": 500,
|
||||
"currency": "EUR"
|
||||
},
|
||||
"reference": "YourModificationReference",
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||
};
|
||||
|
||||
const modificationResult: ModificationResult = await classicIntegration.capture(modificationRequest);
|
||||
expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.CaptureReceived);
|
||||
});
|
||||
|
||||
test("Should succesfully send Cancel request", async (): Promise<void> => {
|
||||
scope.post("/cancel")
|
||||
.reply(200, {
|
||||
"pspReference": "YOUR_REFERENCE",
|
||||
"response": "[cancel-received]"
|
||||
});
|
||||
|
||||
const modificationRequest: CancelRequest = {
|
||||
"originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||
"reference": "YourModificationReference",
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||
};
|
||||
|
||||
const modificationResult: ModificationResult = await classicIntegration.cancel(modificationRequest);
|
||||
expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.CancelReceived);
|
||||
});
|
||||
|
||||
test("Should succesfully send Refund request", async (): Promise<void> => {
|
||||
scope.post("/refund")
|
||||
.reply(200, {
|
||||
"pspReference": "YOUR_REFERENCE",
|
||||
"response": "[refund-received]"
|
||||
});
|
||||
|
||||
const modificationRequest: RefundRequest = {
|
||||
"originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||
"modificationAmount": {
|
||||
"value": 500,
|
||||
"currency": "EUR"
|
||||
},
|
||||
"reference": "YourModificationReference",
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||
};
|
||||
|
||||
const modificationResult: ModificationResult = await classicIntegration.refund(modificationRequest);
|
||||
expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.RefundReceived);
|
||||
});
|
||||
|
||||
test("Should succesfully send CancelOrRefund request", async (): Promise<void> => {
|
||||
scope.post("/cancelOrRefund")
|
||||
.reply(200, {
|
||||
"pspReference": "YOUR_REFERENCE",
|
||||
"response": "[cancelOrRefund-received]"
|
||||
});
|
||||
|
||||
const modificationRequest: CancelOrRefundRequest = {
|
||||
"originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||
"reference": "YourModificationReference",
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||
};
|
||||
|
||||
const modificationResult: ModificationResult = await classicIntegration.cancelOrRefund(modificationRequest);
|
||||
expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.CancelOrRefundReceived);
|
||||
});
|
||||
|
||||
test("Should succesfully send TechnicalCancel request", async (): Promise<void> => {
|
||||
scope.post("/technicalCancel")
|
||||
.reply(200, {
|
||||
"pspReference": "YOUR_REFERENCE",
|
||||
"response": "[technical-cancel-received]"
|
||||
});
|
||||
|
||||
const modificationRequest: TechnicalCancelRequest = {
|
||||
"originalMerchantReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||
"modificationAmount": {
|
||||
"value": 500,
|
||||
"currency": "EUR"
|
||||
},
|
||||
"reference": "YourModificationReference",
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||
};
|
||||
|
||||
const modificationResult: ModificationResult = await classicIntegration.technicalCancel(modificationRequest);
|
||||
expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.TechnicalCancelReceived);
|
||||
});
|
||||
|
||||
test("Should succesfully send AdjustAuthorisation request", async (): Promise<void> => {
|
||||
scope.post("/adjustAuthorisation")
|
||||
.reply(200, {
|
||||
"pspReference": "YOUR_REFERENCE",
|
||||
"response": "[adjustAuthorisation-received]"
|
||||
});
|
||||
|
||||
const modificationRequest: AdjustAuthorisationRequest = {
|
||||
"originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||
"modificationAmount": {
|
||||
"value": 500,
|
||||
"currency": "EUR"
|
||||
},
|
||||
"reference": "YourModificationReference",
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||
};
|
||||
|
||||
const modificationResult: ModificationResult = await classicIntegration.adjustAuthorisation(modificationRequest);
|
||||
expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.AdjustAuthorisationReceived);
|
||||
});
|
||||
|
||||
test("Should succesfully send Donate request", async (): Promise<void> => {
|
||||
scope.post("/donate")
|
||||
.reply(200, {
|
||||
"pspReference": "YOUR_REFERENCE",
|
||||
"response": "[donation-received]"
|
||||
});
|
||||
|
||||
const modificationRequest: DonationRequest = {
|
||||
"originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||
"modificationAmount": {
|
||||
"value": 500,
|
||||
"currency": "EUR"
|
||||
},
|
||||
"reference": "YOUR_DONATION_REFERENCE",
|
||||
"donationAccount": "AdyenGivingDemo",
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||
};
|
||||
|
||||
const modificationResult: ModificationResult = await classicIntegration.donate(modificationRequest);
|
||||
expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.DonationReceived);
|
||||
});
|
||||
|
||||
test("Should succesfully send VoidPendingRefund request", async (): Promise<void> => {
|
||||
scope.post("/voidPendingRefund")
|
||||
.reply(200, {
|
||||
"pspReference": "YOUR_REFERENCE",
|
||||
"response": "[voidPendingRefund-received]"
|
||||
});
|
||||
|
||||
const modificationRequest: VoidPendingRefundRequest = {
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"tenderReference": "5Iw8001176969533005",
|
||||
"uniqueTerminalId": "VX820-123456789"
|
||||
};
|
||||
|
||||
const modificationResult: ModificationResult = await classicIntegration.voidPendingRefund(modificationRequest);
|
||||
expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.VoidPendingRefundReceived);
|
||||
});
|
||||
});
|
||||
@@ -101,8 +101,12 @@ describe("HMAC Validator", function (): void {
|
||||
};
|
||||
try {
|
||||
hmacValidator.validateHMAC(notificationRequestItemNoAdditionalData, key);
|
||||
} catch(error: any) {
|
||||
expect(error.message).toEqual(`Missing ${ApiConstants.HMAC_SIGNATURE}`);
|
||||
} catch(error) {
|
||||
if(error instanceof Error) {
|
||||
expect(error.message).toEqual(`Missing ${ApiConstants.HMAC_SIGNATURE}`);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -43,10 +43,14 @@ const getResponse = async ({apiKey , environment }: { apiKey: string; environmen
|
||||
try {
|
||||
await checkout.payments(createPaymentsCheckoutRequest());
|
||||
fail("request should fail");
|
||||
} catch (e: any) {
|
||||
expect(e instanceof ErrorException).toBeTruthy();
|
||||
if (errorMessageEquals) expect(e.message).toEqual(errorMessageEquals);
|
||||
if (errorMessageContains) expect(e.message.toLowerCase()).toContain(errorMessageContains);
|
||||
} catch (e) {
|
||||
if(e instanceof ErrorException){
|
||||
if (errorMessageEquals) expect(e.message).toEqual(errorMessageEquals);
|
||||
if (errorMessageContains) expect(e.message.toLowerCase()).toContain(errorMessageContains);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
667
src/__tests__/management.spec.ts
Normal file
667
src/__tests__/management.spec.ts
Normal file
@@ -0,0 +1,667 @@
|
||||
import nock from "nock";
|
||||
import Client from "../client";
|
||||
import { createClient } from "../__mocks__/base";
|
||||
import { Management } from "../services";
|
||||
import { AllowedOrigin, AllowedOriginsResponse, MeApiCredential } from "../typings/management/models";
|
||||
import * as models from "../typings/management/models";
|
||||
import * as requests from "../__mocks__/management/requests";
|
||||
import * as responses from "../__mocks__/management/responses";
|
||||
|
||||
let client: Client;
|
||||
let management: Management;
|
||||
let scope: nock.Scope;
|
||||
|
||||
const merchantId = "merchantId";
|
||||
const apiCredentialId = "apiCredentialId";
|
||||
const originId = "originId";
|
||||
const paymentMethodId = "paymentMethodId";
|
||||
const payoutSettingsId = "payoutSettingsId";
|
||||
const orderId = "orderId";
|
||||
const userId = "userId";
|
||||
const webhookId = "webhookId";
|
||||
|
||||
beforeEach((): void => {
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
client = createClient();
|
||||
scope = nock(`${client.config.managementEndpoint}/${Client.MANAGEMENT_API_VERSION}`);
|
||||
management = new Management(client);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
describe("Management", (): void => {
|
||||
describe("Me", (): void => {
|
||||
test("Should get API credential details based on the API Key used in the request", async (): Promise<void> => {
|
||||
scope.get("/me")
|
||||
.reply(200, {
|
||||
"id": "S2-6262224667",
|
||||
"username": "ws_123456@Company.Test",
|
||||
"clientKey": "test_UCP6BO23234FFEFE33E4GWX63",
|
||||
"allowedIpAddresses": [],
|
||||
"roles": [
|
||||
"Management API - Users read and write",
|
||||
"Management API - Accounts read",
|
||||
"Trigger webhook notifications",
|
||||
"Management API - Payout Account Settings Read And Write",
|
||||
"Manage LegalEntities via API",
|
||||
"Manage associated partner accounts via API",
|
||||
"PSP Pos initial configuration",
|
||||
|
||||
],
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://management-test.adyen.com/v1/me"
|
||||
},
|
||||
"allowedOrigins": {
|
||||
"href": "https://management-test.adyen.com/v1/me/allowedOrigins"
|
||||
}
|
||||
},
|
||||
"companyName": "Test",
|
||||
"active": true,
|
||||
});
|
||||
const meResponse: MeApiCredential = await management.Me.retrieve();
|
||||
expect(meResponse.id).toEqual("S2-6262224667");
|
||||
});
|
||||
|
||||
test("Should add an allowed origin to the list of allowed origins", async (): Promise<void> => {
|
||||
scope.post("/me/allowedOrigins")
|
||||
.reply(200, {
|
||||
"id": "S2-45597C41735B6D75433E2B396553453ertcdt347675B4E3B413B4C4571522A6B2921",
|
||||
"domain": "https://www.us.mystore.com",
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://management-test.adyen.com/v1/me/allowedOrigins/S2-45597C41735B6D75433E2B396553453ertcdt347675B4E3B413B4C4571522A6B2921"
|
||||
}
|
||||
}
|
||||
});
|
||||
const allowedOriginRequest: AllowedOrigin = {
|
||||
"domain": "https://www.us.mystore.com"
|
||||
};
|
||||
|
||||
const allowedOriginsResponse: AllowedOrigin = await management.Me.createAllowedOrigin(allowedOriginRequest);
|
||||
expect(allowedOriginsResponse.domain).toEqual("https://www.us.mystore.com");
|
||||
});
|
||||
|
||||
test("Should get the list of allowed origins of a API credential based on the API key used in the request", async (): Promise<void> => {
|
||||
scope.get("/me/allowedOrigins")
|
||||
.reply(200, {
|
||||
"data": [
|
||||
{
|
||||
"id": "S2-45597C41735B6D75433E2B396553453ertcdt347675B4E3B413B4C4571522A6B2921",
|
||||
"domain": "https://www.us.mystore.com",
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://management-test.adyen.com/v1/me/allowedOrigins/S2-45597C41735B6D75433E2B396553453ertcdt347675B4E3B413B4C4571522A6B2921"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const allowedOriginsResponse: AllowedOriginsResponse = await management.Me.retrieveAllowedOrigins();
|
||||
expect(allowedOriginsResponse.data?.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
test("Should retrieve the details of the allowed origin specified in the path", async () => {
|
||||
scope.get("/me/allowedOrigins/S2-123123123123123")
|
||||
.reply(200, {
|
||||
"id": "S2-123123123123123",
|
||||
"domain": "https://www.us.mystore.com",
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://management-test.adyen.com/v1/me/allowedOrigins/S2-123123123123123"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const allowedOriginResponse: AllowedOrigin = await management.Me.retrieveAllowedOrigin("S2-123123123123123");
|
||||
expect(allowedOriginResponse.id).toEqual("S2-123123123123123");
|
||||
});
|
||||
|
||||
test("Should remove the allowed origin specified in the path", async () => {
|
||||
scope.delete("/me/allowedOrigins/S2-123123123123123").reply(204, {});
|
||||
const allowedOriginResponse: Record<string, unknown> = await management.Me.deleteAllowerdOrigin("S2-123123123123123");
|
||||
expect(scope.isDone()).toBe(true);
|
||||
expect(Object.entries(allowedOriginResponse).length).toBe(0);
|
||||
});
|
||||
|
||||
describe("MerchantAccount", (): void => {
|
||||
it("should support GET /merchants", async (): Promise<void> => {
|
||||
scope.get("/merchants?pageNumber=1&pageSize=1")
|
||||
.reply(200, responses.listMerchantResponse);
|
||||
|
||||
const response: models.ListMerchantResponse = await management.MerchantAccount.list({
|
||||
params: {
|
||||
"pageNumber": "1",
|
||||
"pageSize": "1"
|
||||
}
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support POST /merchants", async (): Promise<void> => {
|
||||
scope.post("/merchants")
|
||||
.reply(200, responses.createMerchantResponse);
|
||||
|
||||
const response: models.CreateMerchantResponse = await management.MerchantAccount.create(requests.createMerchantRequest);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support GET /merchants/{merchantId}", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}`)
|
||||
.reply(200, responses.merchant);
|
||||
|
||||
const response: models.Merchant = await management.MerchantAccount.retrieve(merchantId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support POST /merchants/{merchantId}/activate", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/activate`)
|
||||
.reply(200, responses.requestActivationResponse);
|
||||
|
||||
const response: models.RequestActivationResponse = await management.MerchantAccount.activate(merchantId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("MerchantAllowedOrigins", (): void => {
|
||||
it("should support GET /merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins`)
|
||||
.reply(200, responses.allowedOriginsResponse);
|
||||
|
||||
const response: models.AllowedOriginsResponse = await management.MerchantAllowedOrigins.list(merchantId, apiCredentialId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support POST /merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins`)
|
||||
.reply(200, responses.allowedOriginsResponse);
|
||||
|
||||
const response: models.AllowedOriginsResponse = await management.MerchantAllowedOrigins.create(merchantId, apiCredentialId, requests.allowedOrigin);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support DELETE /merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}", async (): Promise<void> => {
|
||||
scope.delete(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins/${originId}`)
|
||||
.reply(204);
|
||||
|
||||
await management.MerchantAllowedOrigins.delete(merchantId, apiCredentialId, originId);
|
||||
});
|
||||
|
||||
it("should support GET /merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins/${originId}`)
|
||||
.reply(200, responses.allowedOrigin);
|
||||
|
||||
const response: models.AllowedOrigin = await management.MerchantAllowedOrigins.retrieve(merchantId, apiCredentialId, originId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("MerchantApiCredentials", (): void => {
|
||||
it("should support GET /merchants/{merchantId}/apiCredentials", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/apiCredentials?pageNumber=1&pageSize=1`)
|
||||
.reply(200, responses.listMerchantApiCredentialsResponse);
|
||||
|
||||
const response: models.ListMerchantApiCredentialsResponse = await management.MerchantApiCredentials.list(merchantId, {
|
||||
params: {
|
||||
"pageNumber": "1",
|
||||
"pageSize": "1"
|
||||
}
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support POST /merchants/{merchantId}/apiCredentials", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/apiCredentials`)
|
||||
.reply(200, responses.createApiCredentialResponse);
|
||||
|
||||
const response: models.CreateApiCredentialResponse = await management.MerchantApiCredentials.create(merchantId, requests.createMerchantApiCredentialRequest);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support GET /merchants/{merchantId}/apiCredentials/{apiCredentialId}", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}`)
|
||||
.reply(200, responses.apiCredential);
|
||||
|
||||
const response: models.ApiCredential = await management.MerchantApiCredentials.retrieve(merchantId, apiCredentialId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support PATCH /merchants/{merchantId}/apiCredentials/{apiCredentialId}", async (): Promise<void> => {
|
||||
scope.patch(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}`)
|
||||
.reply(200, responses.apiCredential);
|
||||
|
||||
const response: models.ApiCredential = await management.MerchantApiCredentials.update(merchantId, apiCredentialId, requests.updateMerchantApiCredentialRequest);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("MerchantApiKey", (): void => {
|
||||
it("should support POST /merchants/{merchantId}/apiCredentials/{apiCredentialId}/generateApiKey", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/generateApiKey`)
|
||||
.reply(200, responses.generateApiKeyResponse);
|
||||
|
||||
const response: models.GenerateApiKeyResponse = await management.MerchantApiKey.create(merchantId, apiCredentialId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("MerchantClientKey", (): void => {
|
||||
it("should support POST /merchants/{merchantId}/apiCredentials/{apiCredentialId}/generateClientKey", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/generateClientKey`)
|
||||
.reply(200, responses.generateClientKeyResponse);
|
||||
|
||||
const response: models.GenerateClientKeyResponse = await management.MerchantClientKey.create(merchantId, apiCredentialId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("MerchantPaymentMethods", (): void => {
|
||||
it("should support GET /merchants/{merchantId}/paymentMethodSettings", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/paymentMethodSettings?storeId=1&businessLineId=1&pageNumber=1&pageSize=1`)
|
||||
.reply(200, responses.paymentMethodResponse);
|
||||
|
||||
const response: models.PaymentMethodResponse = await management.MerchantPaymentMethods.listPaymentMethodSettings(merchantId, {
|
||||
params: {
|
||||
"storeId": "1",
|
||||
"businessLineId": "1",
|
||||
"pageSize": "1",
|
||||
"pageNumber": "1"
|
||||
}
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support POST /merchants/{merchantId}/paymentMethodSettings", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/paymentMethodSettings`)
|
||||
.reply(200, responses.paymentMethod);
|
||||
|
||||
const response: models.PaymentMethod = await management.MerchantPaymentMethods.create(merchantId, {
|
||||
...requests.paymentMethodSetupInfo,
|
||||
type: models.PaymentMethodSetupInfo.TypeEnum.Ideal
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support GET /merchants/{merchantId}/paymentMethodSettings/{paymentMethodId}", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/paymentMethodSettings/${paymentMethodId}`)
|
||||
.reply(200, responses.paymentMethod);
|
||||
|
||||
const response: models.PaymentMethod = await management.MerchantPaymentMethods.retrieve(merchantId, paymentMethodId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support PATCH /merchants/{merchantId}/paymentMethodSettings/{paymentMethodId}", async (): Promise<void> => {
|
||||
scope.patch(`/merchants/${merchantId}/paymentMethodSettings/${paymentMethodId}`)
|
||||
.reply(200, responses.paymentMethod);
|
||||
|
||||
const response: models.PaymentMethod = await management.MerchantPaymentMethods.update(merchantId, paymentMethodId, requests.updatePaymentMethodInfo);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("MerchantPayoutSettings", (): void => {
|
||||
it("should support GET /merchants/{merchantId}/payoutSettings", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/payoutSettings`)
|
||||
.reply(200, responses.payoutSettingsResponse);
|
||||
|
||||
const response: models.PayoutSettingsResponse = await management.MerchantPayoutSettings.listPayoutSettings(merchantId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support POST /merchants/{merchantId}/payoutSettings", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/payoutSettings`)
|
||||
.reply(200, responses.payoutSettings);
|
||||
|
||||
const response: models.PayoutSettings = await management.MerchantPayoutSettings.create(merchantId, requests.payoutSettingsRequest);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support DELETE /merchants/{merchantId}/payoutSettings/{payoutSettingsId}", async (): Promise<void> => {
|
||||
scope.delete(`/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`)
|
||||
.reply(200);
|
||||
|
||||
await management.MerchantPayoutSettings.delete(merchantId, payoutSettingsId);
|
||||
});
|
||||
|
||||
it("should support GET /merchants/{merchantId}/payoutSettings/{payoutSettingsId}", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`)
|
||||
.reply(200, responses.payoutSettings);
|
||||
|
||||
const response: models.PayoutSettings = await management.MerchantPayoutSettings.retrieve(merchantId, payoutSettingsId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support PATCH /merchants/{merchantId}/payoutSettings/{payoutSettingsId}", async (): Promise<void> => {
|
||||
scope.patch(`/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`)
|
||||
.reply(200, responses.payoutSettings);
|
||||
|
||||
const response: models.PayoutSettings = await management.MerchantPayoutSettings.update(merchantId, payoutSettingsId, requests.updatePayoutSettingsRequest);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("MerchantTerminalOrders", (): void => {
|
||||
it("should support GET /merchants/{merchantId}/billingEntities", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/billingEntities?name=bill`)
|
||||
.reply(200, responses.billingEntitiesResponse);
|
||||
|
||||
const response: models.BillingEntitiesResponse = await management.MerchantTerminalOrders.listBillingEntities(merchantId, {
|
||||
params: {
|
||||
"name": "bill"
|
||||
}
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support GET /merchants/{merchantId}/shippingLocations", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/shippingLocations?name=1&offset=1&limit=1`)
|
||||
.reply(200, responses.shippingLocationsResponse);
|
||||
|
||||
const response: models.ShippingLocationsResponse = await management.MerchantTerminalOrders.listShippingLocations(merchantId, {
|
||||
params: {
|
||||
"name": "1",
|
||||
"offset": "1",
|
||||
"limit": "1"
|
||||
}
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support POST /merchants/{merchantId}/shippingLocations", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/shippingLocations`)
|
||||
.reply(200, responses.shippingLocation);
|
||||
|
||||
const response: models.ShippingLocation = await management.MerchantTerminalOrders.createShippingLocation(merchantId, requests.shippingLocation);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support GET /merchants/{merchantId}/terminalModels", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/terminalModels`)
|
||||
.reply(200, responses.terminalModelsResponse);
|
||||
|
||||
const response: models.TerminalModelsResponse = await management.MerchantTerminalOrders.listTerminalModels(merchantId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support GET /merchants/{merchantId}/terminalOrders", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/terminalOrders?customerOrderReference=1&status=1&offset=1&limit=1`)
|
||||
.reply(200, responses.terminalOrdersResponse);
|
||||
|
||||
const response: models.TerminalOrdersResponse = await management.MerchantTerminalOrders.listTerminalOrders(merchantId, {
|
||||
params: {
|
||||
"customerOrderReference": "1",
|
||||
"status": "1",
|
||||
"offset": "1",
|
||||
"limit": "1"
|
||||
}
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support POST /merchants/{merchantId}/terminalOrders", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/terminalOrders`)
|
||||
.reply(200, responses.terminalOrder);
|
||||
|
||||
const response: models.TerminalOrder = await management.MerchantTerminalOrders.create(merchantId, requests.terminalOrderRequest);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support GET /merchants/{merchantId}/terminalOrders/{orderId}", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/terminalOrders/${orderId}`)
|
||||
.reply(200, responses.terminalOrder);
|
||||
|
||||
const response: models.TerminalOrder = await management.MerchantTerminalOrders.retrieve(merchantId, orderId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support PATCH /merchants/{merchantId}/terminalOrders/{orderId}", async (): Promise<void> => {
|
||||
scope.patch(`/merchants/${merchantId}/terminalOrders/${orderId}`)
|
||||
.reply(200, responses.terminalOrder);
|
||||
|
||||
const response: models.TerminalOrder = await management.MerchantTerminalOrders.update(merchantId, orderId, requests.terminalOrderRequest);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support POST /merchants/{merchantId}/terminalOrders/{orderId}/cancel", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/terminalOrders/${orderId}/cancel`)
|
||||
.reply(200, responses.terminalOrder);
|
||||
|
||||
const response: models.TerminalOrder = await management.MerchantTerminalOrders.cancel(merchantId, orderId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support GET /merchants/{merchantId}/terminalProducts", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/terminalProducts?country=1&terminalModelId=1&offset=1&limit=1`)
|
||||
.reply(200, responses.terminalProductsResponse);
|
||||
|
||||
const response: models.TerminalProductsResponse = await management.MerchantTerminalOrders.listTerminalProducts(merchantId, {
|
||||
params: {
|
||||
"country": "1",
|
||||
"terminalModelId": "1",
|
||||
"offset": "1",
|
||||
"limit": "1"
|
||||
}
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("MerchantTerminalSettings", (): void => {
|
||||
it("should support GET /merchants/{merchantId}/terminalLogos", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/terminalLogos?model=1`)
|
||||
.reply(200, responses.logo);
|
||||
|
||||
const response: models.Logo = await management.MerchantTerminalSettings.retrieveLogo(merchantId, {
|
||||
params: {
|
||||
"model": "1"
|
||||
}
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support PATCH /merchants/{merchantId}/terminalLogos", async (): Promise<void> => {
|
||||
scope.patch(`/merchants/${merchantId}/terminalLogos?model=1`)
|
||||
.reply(200, responses.logo);
|
||||
|
||||
const response: models.Logo = await management.MerchantTerminalSettings.updateLogo(merchantId, requests.logo, {
|
||||
params: {
|
||||
"model": "1"
|
||||
}
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support GET /merchants/{merchantId}/terminalSettings", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/terminalSettings`)
|
||||
.reply(200, responses.terminalSettings);
|
||||
|
||||
const response: models.TerminalSettings = await management.MerchantTerminalSettings.retrieve(merchantId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support PATCH /merchants/{merchantId}/terminalSettings", async (): Promise<void> => {
|
||||
scope.patch(`/merchants/${merchantId}/terminalSettings`)
|
||||
.reply(200, responses.terminalSettings);
|
||||
|
||||
const response: models.TerminalSettings = await management.MerchantTerminalSettings.update(merchantId, requests.terminalSettings);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("MerchantUsers", (): void => {
|
||||
it("should support GET /merchants/{merchantId}/users", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/users?pageNumber=1&pageSize=1`)
|
||||
.reply(200, responses.listMerchantUsersResponse);
|
||||
|
||||
const response: models.ListMerchantUsersResponse = await management.MerchantUsers.list(merchantId, {
|
||||
params: {
|
||||
"pageNumber": "1",
|
||||
"pageSize": "1"
|
||||
}
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support POST /merchants/{merchantId}/users", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/users`)
|
||||
.reply(200, responses.createUserResponse);
|
||||
|
||||
const response: models.CreateUserResponse = await management.MerchantUsers.create(merchantId, requests.createMerchantUserRequest);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support GET /merchants/{merchantId}/users/{userId}", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/users/${userId}`)
|
||||
.reply(200, responses.user);
|
||||
|
||||
const response: models.User = await management.MerchantUsers.retrieve(merchantId, userId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support PATCH /merchants/{merchantId}/users/{userId}", async (): Promise<void> => {
|
||||
scope.patch(`/merchants/${merchantId}/users/${userId}`)
|
||||
.reply(200, responses.user);
|
||||
|
||||
const response: models.User = await management.MerchantUsers.update(merchantId, userId, requests.updateMerchantUserRequest);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("MerchantWebhooks", (): void => {
|
||||
it("should support GET /merchants/{merchantId}/webhooks", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/webhooks?pageNumber=1&pageSize=1`)
|
||||
.reply(200, responses.listWebhooksResponse);
|
||||
|
||||
const response: models.ListWebhooksResponse = await management.MerchantWebhooks.list(merchantId, {
|
||||
params: {
|
||||
"pageNumber": "1",
|
||||
"pageSize": "1"
|
||||
}
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support POST /merchants/{merchantId}/webhooks", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/webhooks`)
|
||||
.reply(200, responses.webhook);
|
||||
|
||||
const response: models.Webhook = await management.MerchantWebhooks.create(merchantId, {
|
||||
...requests.createMerchantWebhookRequest,
|
||||
communicationFormat: models.CreateMerchantWebhookRequest.CommunicationFormatEnum.Json,
|
||||
networkType: models.CreateMerchantWebhookRequest.NetworkTypeEnum.Public,
|
||||
sslVersion: models.CreateMerchantWebhookRequest.SslVersionEnum.Tls
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support DELETE /merchants/{merchantId}/webhooks/{webhookId}", async (): Promise<void> => {
|
||||
scope.delete(`/merchants/${merchantId}/webhooks/${webhookId}`)
|
||||
.reply(204);
|
||||
|
||||
await management.MerchantWebhooks.delete(merchantId, webhookId);
|
||||
});
|
||||
|
||||
it("should support GET /merchants/{merchantId}/webhooks/{webhookId}", async (): Promise<void> => {
|
||||
scope.get(`/merchants/${merchantId}/webhooks/${webhookId}`)
|
||||
.reply(200, responses.webhook);
|
||||
|
||||
const response: models.Webhook = await management.MerchantWebhooks.retrieve(merchantId, webhookId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support PATCH /merchants/{merchantId}/webhooks/{webhookId}", async (): Promise<void> => {
|
||||
scope.patch(`/merchants/${merchantId}/webhooks/${webhookId}`)
|
||||
.reply(200, responses.webhook);
|
||||
|
||||
const response: models.Webhook = await management.MerchantWebhooks.update(merchantId, webhookId, {
|
||||
...requests.updateMerchantWebhookRequest,
|
||||
communicationFormat: models.CreateMerchantWebhookRequest.CommunicationFormatEnum.Soap,
|
||||
networkType: models.CreateMerchantWebhookRequest.NetworkTypeEnum.Local,
|
||||
sslVersion: models.CreateMerchantWebhookRequest.SslVersionEnum.Sslv3
|
||||
});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support POST /merchants/{merchantId}/webhooks/{webhookId}/generateHmac", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/webhooks/${webhookId}/generateHmac`)
|
||||
.reply(200, responses.generateHmacKeyResponse);
|
||||
|
||||
const response: models.GenerateHmacKeyResponse = await management.MerchantWebhooks.generateHmac(merchantId, webhookId);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should support POST /merchants/{merchantId}/webhooks/{webhookId}/test", async (): Promise<void> => {
|
||||
scope.post(`/merchants/${merchantId}/webhooks/${webhookId}/test`)
|
||||
.reply(200, responses.testWebhookResponse);
|
||||
|
||||
const testWebhookRequest: models.TestWebhookRequest = {
|
||||
"notification": {
|
||||
"amount": {
|
||||
"currency": "string",
|
||||
"value": 0
|
||||
},
|
||||
"eventCode": "string",
|
||||
"eventDate": new Date(2022, 6, 15),
|
||||
"merchantReference": "string",
|
||||
"paymentMethod": "string",
|
||||
"reason": "string",
|
||||
"success": false
|
||||
},
|
||||
"types": ["string"]
|
||||
};
|
||||
const response: models.TestWebhookResponse = await management.MerchantWebhooks.test(merchantId, webhookId, testWebhookRequest);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,25 +1,6 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2021 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
import nock from "nock";
|
||||
import {createClient} from "../__mocks__/base";
|
||||
import Modification from "../services/modification";
|
||||
import Checkout from "../services/checkout";
|
||||
import Client from "../client";
|
||||
import {
|
||||
CreatePaymentAmountUpdateRequest,
|
||||
@@ -32,6 +13,7 @@ import {
|
||||
PaymentCaptureResource, PaymentRefundResource, PaymentReversalResource,
|
||||
StandalonePaymentCancelResource
|
||||
} from "../typings/checkout/models";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
|
||||
const invalidModificationResult = {
|
||||
"status": 422,
|
||||
@@ -168,7 +150,7 @@ const createReversalsResponse = (): PaymentReversalResource => {
|
||||
|
||||
|
||||
let client: Client;
|
||||
let modification: Modification;
|
||||
let checkout: Checkout;
|
||||
let scope: nock.Scope;
|
||||
const paymentPspReference = "863620292981235A";
|
||||
const invalidPaymentPspReference = "invalid_psp_reference";
|
||||
@@ -179,7 +161,7 @@ beforeEach((): void => {
|
||||
nock.activate();
|
||||
}
|
||||
client = createClient();
|
||||
modification = new Modification(client);
|
||||
checkout = new Checkout(client);
|
||||
scope = nock(`${client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}`);
|
||||
});
|
||||
|
||||
@@ -194,10 +176,14 @@ describe("Modification", (): void => {
|
||||
scope.post(`/payments/${paymentPspReference}/amountUpdates`)
|
||||
.reply(200, createAmountUpdateResponse());
|
||||
try {
|
||||
const result = await modification.amountUpdates(paymentPspReference, request);
|
||||
const result = await checkout.amountUpdates(paymentPspReference, request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
if(e.message) fail(e.message);
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
if(e.message) fail(e.message);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -209,10 +195,14 @@ describe("Modification", (): void => {
|
||||
.reply(422, invalidModificationResult);
|
||||
|
||||
try {
|
||||
await modification.amountUpdates(invalidPaymentPspReference, request);
|
||||
} catch (e: any) {
|
||||
expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
await checkout.amountUpdates(invalidPaymentPspReference, request);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -222,10 +212,14 @@ describe("Modification", (): void => {
|
||||
scope.post(`/payments/${paymentPspReference}/cancels`)
|
||||
.reply(200, createCancelsResponse());
|
||||
try {
|
||||
const result = await modification.cancels(paymentPspReference, request);
|
||||
const result = await checkout.cancels(paymentPspReference, request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
if(e.message) fail(e.message);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -236,10 +230,14 @@ describe("Modification", (): void => {
|
||||
scope.post(`/payments/${invalidPaymentPspReference}/cancels`)
|
||||
.reply(422, invalidModificationResult);
|
||||
try {
|
||||
await modification.cancels(invalidPaymentPspReference, request);
|
||||
} catch (e: any) {
|
||||
expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
await checkout.cancels(invalidPaymentPspReference, request);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -249,10 +247,14 @@ describe("Modification", (): void => {
|
||||
scope.post("/cancels")
|
||||
.reply(200, createStandaloneCancelsResponse());
|
||||
try {
|
||||
const result = await modification.cancelsStandalone(request);
|
||||
const result = await checkout.cancelsStandalone(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
if(e.message) fail(e.message);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -262,10 +264,14 @@ describe("Modification", (): void => {
|
||||
scope.post(`/payments/${paymentPspReference}/captures`)
|
||||
.reply(200, createCapturesResponse());
|
||||
try {
|
||||
const result = await modification.captures(paymentPspReference, request);
|
||||
const result = await checkout.captures(paymentPspReference, request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
if(e.message) fail(e.message);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -276,10 +282,14 @@ describe("Modification", (): void => {
|
||||
scope.post(`/payments/${invalidPaymentPspReference}/captures`)
|
||||
.reply(422, invalidModificationResult);
|
||||
try {
|
||||
await modification.captures(invalidPaymentPspReference, request);
|
||||
} catch (e: any) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
if(e.message) expect(e.message).toContain("Original pspReference required for this operation");
|
||||
await checkout.captures(invalidPaymentPspReference, request);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -289,10 +299,14 @@ describe("Modification", (): void => {
|
||||
scope.post(`/payments/${paymentPspReference}/refunds`)
|
||||
.reply(200, createRefundsResponse());
|
||||
try {
|
||||
const result = await modification.refunds(paymentPspReference, request);
|
||||
const result = await checkout.refunds(paymentPspReference, request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
if(e.message) fail(e.message);
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
if(e.message) fail(e.message);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -303,10 +317,14 @@ describe("Modification", (): void => {
|
||||
scope.post(`/payments/${invalidPaymentPspReference}/refunds`)
|
||||
.reply(422, invalidModificationResult);
|
||||
try {
|
||||
await modification.refunds(invalidPaymentPspReference, request);
|
||||
} catch (e: any) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
await checkout.refunds(invalidPaymentPspReference, request);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -316,10 +334,14 @@ describe("Modification", (): void => {
|
||||
scope.post(`/payments/${paymentPspReference}/reversals`)
|
||||
.reply(200, createReversalsResponse());
|
||||
try {
|
||||
const result = await modification.reversals(paymentPspReference, request);
|
||||
const result = await checkout.reversals(paymentPspReference, request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
if(e.message) fail(e.message);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -330,10 +352,14 @@ describe("Modification", (): void => {
|
||||
scope.post(`/payments/${invalidPaymentPspReference}/reversals`)
|
||||
.reply(422, invalidModificationResult);
|
||||
try {
|
||||
await modification.reversals(invalidPaymentPspReference, request);
|
||||
} catch (e: any) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
await checkout.reversals(invalidPaymentPspReference, request);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,27 +1,15 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
import nock from "nock";
|
||||
import { createClient } from "../__mocks__/base";
|
||||
import Payout from "../services/payout";
|
||||
import Client from "../client";
|
||||
import StoreDetailRequest = IPayouts.StoreDetailRequest;
|
||||
import {
|
||||
ModifyRequest,
|
||||
PayoutRequest,
|
||||
Recurring,
|
||||
StoreDetailAndSubmitRequest,
|
||||
StoreDetailRequest,
|
||||
SubmitRequest
|
||||
} from "../typings/payouts/models";
|
||||
import { ApiConstants } from "../constants/apiConstants";
|
||||
|
||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
||||
@@ -50,13 +38,13 @@ const amountAndReference = {
|
||||
};
|
||||
|
||||
const defaultData = {
|
||||
dateOfBirth: (new Date()).toISOString(),
|
||||
dateOfBirth: new Date(),
|
||||
nationality: "NL",
|
||||
shopperEmail: "johndoe@email.com",
|
||||
shopperReference: "shopperReference",
|
||||
};
|
||||
|
||||
const mockStoreDetailRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): IPayouts.StoreDetailRequest => ({
|
||||
const mockStoreDetailRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): StoreDetailRequest => ({
|
||||
...defaultData,
|
||||
card: {
|
||||
cvc: "737",
|
||||
@@ -65,29 +53,29 @@ const mockStoreDetailRequest = (merchantAccount: string = process.env.ADYEN_MERC
|
||||
number: "4111111111111111",
|
||||
holderName: "John Smith"
|
||||
},
|
||||
entityType: "Company",
|
||||
entityType: StoreDetailRequest.EntityTypeEnum.Company,
|
||||
recurring: {
|
||||
contract: "PAYOUT"
|
||||
contract: Recurring.ContractEnum.Payout,
|
||||
},
|
||||
merchantAccount,
|
||||
});
|
||||
|
||||
const mockSubmitRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): IPayouts.SubmitRequest => ({
|
||||
const mockSubmitRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): SubmitRequest => ({
|
||||
selectedRecurringDetailReference: "LATEST",
|
||||
recurring: {
|
||||
contract: "PAYOUT"
|
||||
contract: Recurring.ContractEnum.Payout
|
||||
},
|
||||
...defaultData,
|
||||
...amountAndReference,
|
||||
merchantAccount,
|
||||
});
|
||||
|
||||
const mockStoreDetailAndSubmitRequest = (merchantAccount?: string): IPayouts.StoreDetailAndSubmitRequest => ({
|
||||
const mockStoreDetailAndSubmitRequest = (merchantAccount?: string): StoreDetailAndSubmitRequest => ({
|
||||
...amountAndReference,
|
||||
...(mockStoreDetailRequest(merchantAccount)),
|
||||
});
|
||||
});
|
||||
|
||||
const mockPayoutRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): IPayouts.PayoutRequest => ({
|
||||
const mockPayoutRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): PayoutRequest => ({
|
||||
...amountAndReference,
|
||||
...defaultData,
|
||||
card: {
|
||||
@@ -124,7 +112,7 @@ describe("PayoutTest", function (): void {
|
||||
test.each([isCI, true])("should succeed on store detail and submit third party, isMock: %p", async function (isMock): Promise<void> {
|
||||
!isMock && nock.restore();
|
||||
payout = new Payout(clientStore);
|
||||
const request: IPayouts.StoreDetailAndSubmitRequest = mockStoreDetailAndSubmitRequest();
|
||||
const request: StoreDetailAndSubmitRequest = mockStoreDetailAndSubmitRequest();
|
||||
scope.post("/storeDetailAndSubmitThirdParty").reply(200, storeDetailAndSubmitThirdParty);
|
||||
|
||||
const result = await payout.storeDetailAndSubmitThirdParty(request);
|
||||
@@ -158,7 +146,7 @@ describe("PayoutTest", function (): void {
|
||||
response: "[payout-confirm-received]"
|
||||
});
|
||||
|
||||
const request: IPayouts.ModifyRequest = {
|
||||
const request: ModifyRequest = {
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
originalReference: storeResult.pspReference
|
||||
};
|
||||
@@ -173,7 +161,7 @@ describe("PayoutTest", function (): void {
|
||||
payout = new Payout(clientStore);
|
||||
scope.post("/submitThirdParty").reply(200, storeDetailAndSubmitThirdParty);
|
||||
|
||||
const request: IPayouts.SubmitRequest = mockSubmitRequest();
|
||||
const request: SubmitRequest = mockSubmitRequest();
|
||||
const result = await payout.submitThirdparty(request);
|
||||
|
||||
expect(result.resultCode).toEqual("[payout-submit-received]");
|
||||
@@ -193,7 +181,7 @@ describe("PayoutTest", function (): void {
|
||||
const storeResult = await payout.storeDetail(storeRequest);
|
||||
|
||||
payout = new Payout(clientReview);
|
||||
const request: IPayouts.ModifyRequest = {
|
||||
const request: ModifyRequest = {
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
originalReference: storeResult.pspReference
|
||||
};
|
||||
@@ -221,4 +209,4 @@ describe("PayoutTest", function (): void {
|
||||
expect(result.resultCode).toEqual("Received");
|
||||
expect(result.pspReference).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,10 +26,11 @@ import { Client, Platforms } from "../index";
|
||||
import * as A from "../typings/platformsAccount/models";
|
||||
import F = IPlatformsFund;
|
||||
import N = IPlatformsNotificationConfiguration;
|
||||
import H = IPlatformsHostedOnboardingPage;
|
||||
import AccountHolderDetails = A.AccountHolderDetails;
|
||||
import NotificationConfigurationDetails = N.NotificationConfigurationDetails;
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
import { GetOnboardingUrlRequest, GetOnboardingUrlResponse, GetPciUrlRequest, GetPciUrlResponse } from "../typings/platformsHostedOnboardingPage/models";
|
||||
import { DebitAccountHolderRequest, DebitAccountHolderResponse } from "../typings/platformsFund/models";
|
||||
|
||||
let client: Client;
|
||||
let platforms: Platforms;
|
||||
@@ -138,6 +139,7 @@ describe("Platforms Test", function () {
|
||||
["refundFundsTransfer", createMock<F.RefundFundsTransferRequest>(), createMock<F.RefundFundsTransferResponse>()],
|
||||
["setupBeneficiary", createMock<F.SetupBeneficiaryRequest>(), createMock<F.SetupBeneficiaryResponse>()],
|
||||
["refundNotPaidOutTransfers", createMock<F.RefundNotPaidOutTransfersRequest>(), createMock<F.RefundNotPaidOutTransfersResponse>()],
|
||||
["debitAccountHolder", createMock<DebitAccountHolderRequest>(), createMock<DebitAccountHolderResponse>()],
|
||||
];
|
||||
test.each(cases)(
|
||||
"should %p",
|
||||
@@ -175,7 +177,8 @@ describe("Platforms Test", function () {
|
||||
|
||||
describe("Hop", function () {
|
||||
const cases = [
|
||||
["getOnboardingUrl", createMock<H.GetOnboardingUrlRequest>(), createMock<H.GetOnboardingUrlResponse>()]
|
||||
["getOnboardingUrl", createMock<GetOnboardingUrlRequest>(), createMock<GetOnboardingUrlResponse>()],
|
||||
["getPciQuestionnaireUrl", createMock<GetPciUrlRequest>(), createMock<GetPciUrlResponse>()],
|
||||
];
|
||||
test.each(cases)(
|
||||
"should %p",
|
||||
@@ -244,8 +247,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
nock.restore();
|
||||
try {
|
||||
expect(accountHolder.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
it("should get account holder", async function() {
|
||||
@@ -255,8 +262,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountHolderCode: accountHolder.accountHolderCode,
|
||||
});
|
||||
expect(result.accountHolderDetails.email).toEqual("random_email@example.com");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -273,8 +284,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
}
|
||||
});
|
||||
expect(result.accountHolderDetails!.address?.country).toEqual("BE");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -287,8 +302,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
tier: 2
|
||||
});
|
||||
expect(result.resultCode).toEqual("Success");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -296,8 +315,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
nock.restore();
|
||||
try {
|
||||
expect(account.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -314,8 +337,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
}
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -335,8 +362,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountHolderCode: account.accountHolderCode,
|
||||
});
|
||||
expect(result.documentDetails![0].filename).toEqual("IDCardFront.png");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -347,8 +378,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountCode: accountToClose.accountCode
|
||||
});
|
||||
expect(result.status).toEqual("Closed");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -359,8 +394,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountHolderCode: accountHolderToSuspend.accountHolderCode,
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -369,8 +408,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
try {
|
||||
const result = await platforms.Account.unSuspendAccountHolder({ accountHolderCode: accountHolderToUnSuspend.accountHolderCode });
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -383,8 +426,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
stateType: A.UpdateAccountHolderStateRequest.StateTypeEnum.Payout
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -395,8 +442,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountHolderCode: accountHolderToClose.accountHolderCode
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -409,9 +460,13 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
year: 2020
|
||||
});
|
||||
expect(result.content).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
}
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -423,8 +478,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountHolderCode: generateRandomCode()
|
||||
});
|
||||
expect(result.balancePerAccount![0].detailBalance).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -435,8 +494,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountHolderCode: generateRandomCode()
|
||||
});
|
||||
expect(result.accountTransactionLists![0].transactions).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -453,8 +516,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
transferCode: "SUBSCRIPTION"
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -468,8 +535,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
const result = await platforms.NotificationConfiguration.getNotificationConfigurationList({});
|
||||
const resultStr = JSON.stringify(result);
|
||||
expect(resultStr.includes("pspReference")).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -483,8 +554,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
}
|
||||
});
|
||||
expect(result.configurationDetails.active).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -496,8 +571,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
notificationId: configurationID
|
||||
});
|
||||
expect(result.configurationDetails.notifyURL).toEqual("https://www.adyen.com/notification-handler");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -522,8 +601,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
});
|
||||
const accountHolderVerification = result.configurationDetails.eventConfigs.filter(event => event.eventType === "ACCOUNT_HOLDER_VERIFICATION")[0];
|
||||
expect(accountHolderVerification.includeMode).toEqual("EXCLUDE");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -534,9 +617,13 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
try {
|
||||
const result = await platforms.NotificationConfiguration.deleteNotificationConfigurations({notificationIds});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
}
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
import nock from "nock";
|
||||
import { createClient } from "../__mocks__/base";
|
||||
import { disableSuccess } from "../__mocks__/recurring/disableSuccess";
|
||||
@@ -44,7 +25,6 @@ const createRecurringDetailsRequest = (): RecurringDetailsRequest => {
|
||||
shopperReference: "shopperReference",
|
||||
};
|
||||
};
|
||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
||||
|
||||
let client: Client;
|
||||
let recurring: RecurringService;
|
||||
@@ -66,7 +46,7 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe("Recurring", (): void => {
|
||||
test("should list recurring details ", async (): Promise<void> => {
|
||||
test("should list recurring details", async (): Promise<void> => {
|
||||
scope.post("/listRecurringDetails")
|
||||
.reply(200, listRecurringDetailsSuccess);
|
||||
const request = createRecurringDetailsRequest();
|
||||
@@ -74,11 +54,10 @@ describe("Recurring", (): void => {
|
||||
const result = await recurring.listRecurringDetails(request);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
expect(result.details?.[0].RecurringDetail.recurringDetailReference).toBe('recurringReference');
|
||||
expect(result.details?.[0].recurringDetailReference).toBe("recurringReference");
|
||||
});
|
||||
|
||||
test.each([isCI, true])("should disable, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
test("should disable", async (): Promise<void> => {
|
||||
scope.post("/payments")
|
||||
.reply(200, paymentsSuccess);
|
||||
|
||||
@@ -97,13 +76,12 @@ describe("Recurring", (): void => {
|
||||
try {
|
||||
const result = await recurring.disable(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
});
|
||||
|
||||
test.each([isCI, true])("should send pre-debit Notification, isMock %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
test("should send pre-debit Notification", async (): Promise<void> => {
|
||||
scope.post("/notifyShopper")
|
||||
.reply(200, notifyShopperSuccess);
|
||||
|
||||
@@ -123,15 +101,13 @@ describe("Recurring", (): void => {
|
||||
try {
|
||||
const result = await recurring.notifyShopper(notifyShopperRequest);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// TODO: register account for AccountUpdater and unmock test
|
||||
test.each([true])("should schedule account updater, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
test("should schedule account updater", async (): Promise<void> => {
|
||||
const scheduleAccountUpdaterSuccess: ScheduleAccountUpdaterResult = {
|
||||
pspReference: "mocked_psp",
|
||||
result: "SUCCESS"
|
||||
@@ -154,8 +130,8 @@ describe("Recurring", (): void => {
|
||||
try {
|
||||
const result = await recurring.scheduleAccountUpdater(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
267
src/__tests__/storedValue.spec.ts
Normal file
267
src/__tests__/storedValue.spec.ts
Normal file
@@ -0,0 +1,267 @@
|
||||
import nock from "nock";
|
||||
import Client from "../client";
|
||||
import {createClient} from "../__mocks__/base";
|
||||
import {StoredValue} from "../services";
|
||||
import { StoredValueIssueRequest,
|
||||
StoredValueIssueResponse,
|
||||
StoredValueStatusChangeRequest,
|
||||
StoredValueStatusChangeResponse,
|
||||
StoredValueLoadRequest,
|
||||
StoredValueLoadResponse,
|
||||
StoredValueBalanceCheckRequest,
|
||||
StoredValueBalanceCheckResponse,
|
||||
StoredValueBalanceMergeRequest,
|
||||
StoredValueBalanceMergeResponse,
|
||||
StoredValueVoidRequest,
|
||||
StoredValueVoidResponse
|
||||
} from "../typings/storedValue/models";
|
||||
|
||||
|
||||
let client: Client;
|
||||
let storedValue: StoredValue;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
client = createClient();
|
||||
scope = nock(`${client.config.storedValueEndpoint}/${Client.STOREDVALUE_API_VERSION}`);
|
||||
storedValue = new StoredValue(client);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
describe("StoredValue", (): void => {
|
||||
test("Should issue Givex card", async (): Promise<void> => {
|
||||
scope.post("/issue")
|
||||
.reply(200, {
|
||||
"currentBalance": {
|
||||
"currency": "EUR",
|
||||
"value": 1000
|
||||
},
|
||||
"pspReference": "851564651069192J",
|
||||
"resultCode": "Success",
|
||||
"paymentMethod": {
|
||||
"number": "7219627091701347",
|
||||
"securityCode": "0140",
|
||||
"type": "givex"
|
||||
}
|
||||
});
|
||||
const issueRequest: StoredValueIssueRequest = {
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"store": "YOUR_STORE_ID",
|
||||
"paymentMethod": {
|
||||
"type": "givex"
|
||||
},
|
||||
"amount": {
|
||||
"currency": "EUR",
|
||||
"value": 1000
|
||||
},
|
||||
"reference": "YOUR_REFERENCE"
|
||||
};
|
||||
|
||||
const issueResponse: StoredValueIssueResponse = await storedValue.issue(issueRequest);
|
||||
expect(issueResponse.pspReference).toEqual("851564651069192J");
|
||||
|
||||
});
|
||||
|
||||
test("Should issue virtual Fiserv card", async (): Promise<void> => {
|
||||
scope.post("/issue")
|
||||
.reply(200, {
|
||||
"currentBalance": {
|
||||
"currency": "EUR",
|
||||
"value": 1000
|
||||
},
|
||||
"pspReference": "851564651069192J",
|
||||
"resultCode": "Success",
|
||||
"paymentMethod": {
|
||||
"number": "7219627091701347",
|
||||
"securityCode": "0140",
|
||||
"type": "givex"
|
||||
}
|
||||
});
|
||||
const issueRequest: StoredValueIssueRequest = {
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"store": "YOUR_STORE_ID",
|
||||
"paymentMethod": {
|
||||
"type": "valuelink"
|
||||
},
|
||||
// "giftCardPromoCode": "1324",
|
||||
"reference": "YOUR_REFERENCE"
|
||||
};
|
||||
|
||||
const issueResponse: StoredValueIssueResponse = await storedValue.issue(issueRequest);
|
||||
expect(issueResponse.pspReference).toEqual("851564651069192J");
|
||||
|
||||
});
|
||||
|
||||
test("Should activate card", async (): Promise<void> => {
|
||||
scope.post("/changeStatus")
|
||||
.reply(200, {
|
||||
"currentBalance": {
|
||||
"currency": "USD",
|
||||
"value": 1000
|
||||
},
|
||||
"pspReference": "851564652149588K",
|
||||
"resultCode": "Success"
|
||||
});
|
||||
|
||||
const statusRequest: StoredValueStatusChangeRequest = {
|
||||
"status": StoredValueStatusChangeRequest.StatusEnum.Active,
|
||||
"amount": {
|
||||
"currency": "USD",
|
||||
"value": 1000
|
||||
},
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"store":"YOUR_STORE_ID",
|
||||
"paymentMethod": {
|
||||
"type": "svs",
|
||||
"number": "6006491286999921374",
|
||||
"securityCode": "1111"
|
||||
},
|
||||
"reference": "YOUR_REFERENCE"
|
||||
};
|
||||
|
||||
const changeStatusResponse: StoredValueStatusChangeResponse = await storedValue.changeStatus(statusRequest);
|
||||
expect(changeStatusResponse.pspReference).toEqual("851564652149588K");
|
||||
});
|
||||
|
||||
test("Should deactivate card", async (): Promise<void> => {
|
||||
scope.post("/changeStatus")
|
||||
.reply(200, {
|
||||
"currentBalance": {
|
||||
"currency": "USD",
|
||||
"value": 1000
|
||||
},
|
||||
"pspReference": "851564652149588K",
|
||||
"resultCode": "Success"
|
||||
});
|
||||
|
||||
const statusRequest: StoredValueStatusChangeRequest = {
|
||||
"status": StoredValueStatusChangeRequest.StatusEnum.Inactive,
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"store":"YOUR_STORE_ID",
|
||||
"paymentMethod": {
|
||||
"type": "givex",
|
||||
},
|
||||
"recurringDetailReference": "7219627091701347",
|
||||
"shopperReference": "YOUR_UNIQUE_SHOPPER_ID_P3fW3k9D2tvXFu6l",
|
||||
"shopperInteraction": StoredValueStatusChangeRequest.ShopperInteractionEnum.Ecommerce,
|
||||
"reference": "YOUR_REFERENCE"
|
||||
};
|
||||
|
||||
const changeStatusResponse: StoredValueStatusChangeResponse = await storedValue.changeStatus(statusRequest);
|
||||
expect(changeStatusResponse.pspReference).toEqual("851564652149588K");
|
||||
});
|
||||
|
||||
test("Should load funds to card", async (): Promise<void> => {
|
||||
scope.post("/load")
|
||||
.reply(200, {
|
||||
"currentBalance": {
|
||||
"currency": "USD",
|
||||
"value": 30000
|
||||
},
|
||||
"pspReference": "851564654294247B",
|
||||
"resultCode": "Success"
|
||||
});
|
||||
|
||||
const loadRequest: StoredValueLoadRequest = {
|
||||
"amount": {
|
||||
"currency": "USD",
|
||||
"value": 2000
|
||||
},
|
||||
"loadType": StoredValueLoadRequest.LoadTypeEnum.MerchandiseReturn,
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"store":"YOUR_STORE_ID",
|
||||
"paymentMethod": {
|
||||
"type": "svs",
|
||||
"number": "6006491286999921374",
|
||||
"securityCode": "1111"
|
||||
},
|
||||
"reference": "YOUR_REFERENCE"
|
||||
};
|
||||
|
||||
const loadResponse: StoredValueLoadResponse = await storedValue.load(loadRequest);
|
||||
expect(loadResponse.pspReference).toEqual("851564654294247B");
|
||||
});
|
||||
|
||||
test("Should check remaining balance of card", async (): Promise<void> => {
|
||||
scope.post("/checkBalance")
|
||||
.reply(200, {
|
||||
"currentBalance": {
|
||||
"currency": "EUR",
|
||||
"value": 5600
|
||||
},
|
||||
"pspReference": "881564657480267D",
|
||||
"resultCode": "Success"
|
||||
});
|
||||
|
||||
const checkBalanceRequest: StoredValueBalanceCheckRequest = {
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"store":"YOUR_STORE_ID",
|
||||
"paymentMethod": {
|
||||
"type": "svs",
|
||||
"number": "603628672882001915092",
|
||||
"securityCode": "5754"
|
||||
},
|
||||
"reference": "YOUR_REFERENCE"
|
||||
};
|
||||
|
||||
const checkBalanceResponse: StoredValueBalanceCheckResponse = await storedValue.checkBalance(checkBalanceRequest);
|
||||
expect(checkBalanceResponse.pspReference).toEqual("881564657480267D");
|
||||
});
|
||||
|
||||
test("Should transfer full value from one card to another", async (): Promise<void> => {
|
||||
scope.post("/mergeBalance")
|
||||
.reply(200, {
|
||||
"currentBalance": {
|
||||
"currency": "EUR",
|
||||
"value": 5600
|
||||
},
|
||||
"pspReference": "881564657480267D",
|
||||
"resultCode": "Success"
|
||||
});
|
||||
|
||||
const mergeBalanceRequest: StoredValueBalanceMergeRequest = {
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"store":"YOUR_STORE_ID",
|
||||
"sourcePaymentMethod": {
|
||||
"number": "7777182708544835",
|
||||
"securityCode": "2329"
|
||||
},
|
||||
"paymentMethod": {
|
||||
"type": "valuelink",
|
||||
"number": "8888182708544836",
|
||||
"securityCode": "2330"
|
||||
},
|
||||
"reference": "YOUR_REFERENCE"
|
||||
};
|
||||
|
||||
const mergeBalanceResponse: StoredValueBalanceMergeResponse = await storedValue.mergebalance(mergeBalanceRequest);
|
||||
expect(mergeBalanceResponse.pspReference).toEqual("881564657480267D");
|
||||
});
|
||||
|
||||
test("Should undo transaction on card", async (): Promise<void> => {
|
||||
scope.post("/voidTransaction")
|
||||
.reply(200, {
|
||||
"currentBalance": {
|
||||
"currency": "EUR",
|
||||
"value": 120000
|
||||
},
|
||||
"pspReference": "851564673300692A",
|
||||
"resultCode": "Success"
|
||||
});
|
||||
|
||||
const voidTransactionRequest: StoredValueVoidRequest = {
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"originalReference": "851564654294247B",
|
||||
"reference": "YOUR_REFERENCE"
|
||||
};
|
||||
|
||||
const voidTransactionResponse: StoredValueVoidResponse = await storedValue.voidTransaction(voidTransactionRequest);
|
||||
expect(voidTransactionResponse.pspReference).toEqual("851564673300692A");
|
||||
});
|
||||
});
|
||||
@@ -23,7 +23,7 @@ import { asyncRes } from "../__mocks__/terminalApi/async";
|
||||
import { syncRefund, syncRes, syncResEventNotification } from "../__mocks__/terminalApi/sync";
|
||||
import Client from "../client";
|
||||
import TerminalCloudAPI from "../services/terminalCloudAPI";
|
||||
import { TerminalApiResponse } from "../typings/terminal/models";
|
||||
import { SaleToAcquirerData, TerminalApiResponse } from "../typings/terminal/models";
|
||||
|
||||
let client: Client;
|
||||
let terminalCloudAPI: TerminalCloudAPI;
|
||||
@@ -46,7 +46,7 @@ afterEach((): void => {
|
||||
|
||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
||||
describe("Terminal Cloud API", (): void => {
|
||||
test.each([isCI, true])("should make an async payment request, isMock: %p", async (isMock): Promise<void> => {
|
||||
test.each([isCI])("should make an async payment request, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/async").reply(200, asyncRes);
|
||||
|
||||
@@ -57,7 +57,7 @@ describe("Terminal Cloud API", (): void => {
|
||||
expect(requestResponse).toEqual("ok");
|
||||
});
|
||||
|
||||
test.each([isCI, true])("should make a sync payment request, isMock: %p", async (isMock): Promise<void> => {
|
||||
test.each([isCI])("should make a sync payment request, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/sync").reply(200, syncRes);
|
||||
|
||||
@@ -68,7 +68,7 @@ describe("Terminal Cloud API", (): void => {
|
||||
expect(terminalAPIResponse.SaleToPOIResponse?.MessageHeader).toBeDefined();
|
||||
});
|
||||
|
||||
test.each([isCI, true])("should return event notification if response contains it, isMock: %p", async (isMock): Promise<void> => {
|
||||
test.each([isCI])("should return event notification if response contains it, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||
@@ -79,23 +79,26 @@ describe("Terminal Cloud API", (): void => {
|
||||
expect(terminalAPIResponse.SaleToPOIRequest?.EventNotification).toBeDefined();
|
||||
});
|
||||
|
||||
test.each([isCI, true])("should make an async refund request, isMock: %p", async (isMock): Promise<void> => {
|
||||
test.each([isCI])("should make an async refund request, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/sync").reply(200, syncRes);
|
||||
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||
const terminalAPIResponse: TerminalApiResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest);
|
||||
|
||||
const pOITransactionId = terminalAPIResponse.SaleToPOIResponse!.PaymentResponse!.POIData!.POITransactionID;
|
||||
expect(pOITransactionId).toBeTruthy();
|
||||
|
||||
scope.post("/sync").reply(200, syncRefund);
|
||||
|
||||
const pOITransactionId = terminalAPIResponse.SaleToPOIResponse?.PaymentResponse?.POIData!.POITransactionID;
|
||||
if(pOITransactionId) {
|
||||
const terminalAPIRefundRequest = createTerminalAPIRefundRequest(pOITransactionId);
|
||||
const terminalAPIRefundResponse = await terminalCloudAPI.sync(terminalAPIRefundRequest);
|
||||
const terminalAPIRefundRequest = createTerminalAPIRefundRequest(pOITransactionId);
|
||||
const id = Math.floor(Math.random() * Math.floor(10000000)).toString();
|
||||
terminalAPIRefundRequest.SaleToPOIRequest.MessageHeader.ServiceID = id;
|
||||
const saleToAcquirerData: SaleToAcquirerData = new SaleToAcquirerData();
|
||||
saleToAcquirerData.currency = "EUR";
|
||||
terminalAPIRefundRequest.SaleToPOIRequest.ReversalRequest!.SaleData!.SaleToAcquirerData = saleToAcquirerData;
|
||||
const terminalAPIRefundResponse = await terminalCloudAPI.sync(terminalAPIRefundRequest);
|
||||
|
||||
expect(terminalAPIRefundResponse.SaleToPOIResponse?.ReversalResponse).toBeDefined();
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
});
|
||||
expect(terminalAPIRefundResponse.SaleToPOIResponse?.ReversalResponse?.Response.Result).toBe("Success");
|
||||
}, 20000);
|
||||
});
|
||||
|
||||
@@ -79,9 +79,13 @@ describe("Terminal Local API", (): void => {
|
||||
|
||||
try {
|
||||
await terminalLocalAPI.request(terminalAPIPaymentRequest, securityKey);
|
||||
} catch (e: any) {
|
||||
expect(e instanceof NexoCryptoException);
|
||||
expect(e.message).toEqual("Hmac validation failed");
|
||||
} catch (e) {
|
||||
if(e instanceof NexoCryptoException) {
|
||||
expect(e.message).toEqual("Hmac validation failed");
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
157
src/__tests__/terminalManagement.spec.ts
Normal file
157
src/__tests__/terminalManagement.spec.ts
Normal file
@@ -0,0 +1,157 @@
|
||||
import nock from "nock";
|
||||
import Client from "../client";
|
||||
import { createClient } from "../__mocks__/base";
|
||||
import TerminalManagement from "../services/terminalManagement";
|
||||
import {
|
||||
AssignTerminalsRequest,
|
||||
AssignTerminalsResponse,
|
||||
FindTerminalRequest,
|
||||
FindTerminalResponse,
|
||||
GetStoresUnderAccountRequest,
|
||||
GetStoresUnderAccountResponse,
|
||||
GetTerminalDetailsRequest,
|
||||
GetTerminalDetailsResponse,
|
||||
GetTerminalsUnderAccountRequest,
|
||||
GetTerminalsUnderAccountResponse
|
||||
} from "../typings/terminalManagement/models";
|
||||
|
||||
let client: Client;
|
||||
let terminalManagement: TerminalManagement;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
client = createClient();
|
||||
scope = nock(`${client.config.terminalManagementEndpoint}/${Client.TERMINAL_MANAGEMENT_API_VERSION}`);
|
||||
terminalManagement = new TerminalManagement(client);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
describe("POS Terminal Management API", (): void => {
|
||||
test("Should support /assignTerminals", async (): Promise<void> => {
|
||||
scope.post("/assignTerminals")
|
||||
.reply(200, {
|
||||
"results": {
|
||||
"P400Plus-275479597": "RemoveConfigScheduled"
|
||||
}
|
||||
});
|
||||
const request: AssignTerminalsRequest = {
|
||||
"companyAccount": "YOUR_COMPANY_ACCOUNT",
|
||||
"terminals": [
|
||||
"P400Plus-275479597"
|
||||
]
|
||||
};
|
||||
|
||||
const response: AssignTerminalsResponse = await terminalManagement.assignTerminals(request);
|
||||
|
||||
expect(response.results["P400Plus-275479597"]).toEqual("RemoveConfigScheduled");
|
||||
});
|
||||
|
||||
test("Should support /findTerminal", async (): Promise<void> => {
|
||||
scope.post("/findTerminal")
|
||||
.reply(200, {
|
||||
"companyAccount": "YOUR_COMPANY_ACCOUNT",
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"merchantInventory": false,
|
||||
"terminal": "P400Plus-275479597"
|
||||
});
|
||||
const request: FindTerminalRequest = {
|
||||
"terminal": "P400Plus-275479597"
|
||||
};
|
||||
|
||||
const response: FindTerminalResponse = await terminalManagement.findTerminal(request);
|
||||
|
||||
expect(response.terminal).toEqual("P400Plus-275479597");
|
||||
});
|
||||
|
||||
test("Should support /getStoresUnderAccount", async (): Promise<void> => {
|
||||
scope.post("/getStoresUnderAccount")
|
||||
.reply(200, {
|
||||
"stores": [
|
||||
{
|
||||
"store": "YOUR_STORE",
|
||||
"description": "YOUR_STORE",
|
||||
"address": {
|
||||
"city": "The City",
|
||||
"countryCode": "NL",
|
||||
"postalCode": "1234",
|
||||
"streetAddress": "The Street"
|
||||
},
|
||||
"status": "Active",
|
||||
"merchantAccountCode": "YOUR_MERCHANT_ACCOUNT"
|
||||
}
|
||||
]
|
||||
});
|
||||
const request: GetStoresUnderAccountRequest = {
|
||||
"companyAccount": "YOUR_COMPANY_ACCOUNT"
|
||||
};
|
||||
|
||||
const response: GetStoresUnderAccountResponse = await terminalManagement.getStoresUnderAccount(request);
|
||||
|
||||
expect(response.stores).toHaveLength(1);
|
||||
expect(response.stores![0].status).toEqual("Active");
|
||||
expect(response.stores![0].address?.countryCode).toEqual("NL");
|
||||
});
|
||||
|
||||
test("Should support /getTerminalDetails", async (): Promise<void> => {
|
||||
scope.post("/getTerminalDetails")
|
||||
.reply(200, {
|
||||
"companyAccount": "YOUR_COMPANY_ACCOUNT",
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"merchantInventory": false,
|
||||
"terminal": "P400Plus-275479597",
|
||||
"deviceModel": "P400Plus",
|
||||
"serialNumber": "275-479-597",
|
||||
"permanentTerminalId": "75479597",
|
||||
"terminalStatus": "ReAssignToInventoryPending",
|
||||
"firmwareVersion": "Verifone_VOS 1.57.6",
|
||||
"country": "NETHERLANDS",
|
||||
"dhcpEnabled": false
|
||||
});
|
||||
const request: GetTerminalDetailsRequest = {
|
||||
"terminal": "P400Plus-275479597"
|
||||
};
|
||||
|
||||
const response: GetTerminalDetailsResponse = await terminalManagement.getTerminalDetails(request);
|
||||
|
||||
expect(response.deviceModel).toBe("P400Plus");
|
||||
});
|
||||
|
||||
|
||||
test("Should support /getTerminalsUnderAccount", async (): Promise<void> => {
|
||||
scope.post("/getTerminalsUnderAccount")
|
||||
.reply(200, {
|
||||
"companyAccount": "YOUR_COMPANY_ACCOUNT",
|
||||
"merchantAccounts": [
|
||||
{
|
||||
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||
"inStoreTerminals": [
|
||||
"P400Plus-275479597"
|
||||
],
|
||||
"stores": [
|
||||
{
|
||||
"store": "YOUR_STORE",
|
||||
"inStoreTerminals": [
|
||||
"M400-401972715"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
const request: GetTerminalsUnderAccountRequest = {
|
||||
"companyAccount": "YOUR_COMPANY_ACCOUNT"
|
||||
};
|
||||
|
||||
const response: GetTerminalsUnderAccountResponse = await terminalManagement.getTerminalsUnderAccount(request);
|
||||
|
||||
expect(response.merchantAccounts).toHaveLength(1);
|
||||
expect(response.merchantAccounts![0].stores).toHaveLength(1);
|
||||
expect(response.merchantAccounts![0].stores![0].inStoreTerminals).toEqual(["M400-401972715"]);
|
||||
});
|
||||
});
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
import Config from "./config";
|
||||
import HttpURLConnectionClient from "./httpClient/httpURLConnectionClient";
|
||||
import { version } from "../package.json";
|
||||
@@ -53,13 +34,17 @@ class Client {
|
||||
public static MARKETPAY_ENDPOINT_TEST = "https://cal-test.adyen.com/cal/services";
|
||||
public static MARKETPAY_ENDPOINT_LIVE = "https://cal-live.adyen.com/cal/services";
|
||||
public static CHECKOUT_API_VERSION = "v69";
|
||||
public static API_VERSION = "v64";
|
||||
public static RECURRING_API_VERSION = "v49";
|
||||
public static API_VERSION = "v68";
|
||||
public static RECURRING_API_VERSION = "v68";
|
||||
public static MARKETPAY_ACCOUNT_API_VERSION = "v6";
|
||||
public static MARKETPAY_FUND_API_VERSION = "v6";
|
||||
public static MARKETPAY_HOP_API_VERSION = "v6";
|
||||
public static MARKETPAY_NOTIFICATION_API_VERSION = "v5";
|
||||
public static MARKETPAY_NOTIFICATION_CONFIGURATION_API_VERSION = "v6";
|
||||
public static PAYMENT_API_VERSION = "v68";
|
||||
public static STOREDVALUE_API_VERSION = "v46";
|
||||
public static TERMINAL_MANAGEMENT_API_VERSION = "v1";
|
||||
public static MANAGEMENT_API_VERSION = "v1";
|
||||
public static LIB_NAME = "adyen-node-api-library";
|
||||
public static LIB_VERSION: string = version;
|
||||
public static CHECKOUT_ENDPOINT_TEST = "https://checkout-test.adyen.com/checkout";
|
||||
@@ -69,6 +54,17 @@ class Client {
|
||||
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://";
|
||||
public static PAYMENT_API_ENDPOINT_TEST = "https://pal-test.adyen.com/pal/servlet/Payment";
|
||||
public static PAYMENT_API_ENDPOINT_LIVE = "https://pal-live.adyen.com/pal/servlet/Payment";
|
||||
public static STOREDVALUE_API_ENDPOINT_TEST = "https://pal-test.adyen.com/pal/servlet/StoredValue";
|
||||
public static STOREDVALUE_API_ENDPOINT_LIVE = "https://pal-live.adyen.com/pal/servlet/StoredValue";
|
||||
public static TERMINAL_MANAGEMENT_API_ENDPOINT_TEST = "https://postfmapi-test.adyen.com/postfmapi/terminal";
|
||||
public static TERMINAL_MANAGEMENT_API_ENDPOINT_LIVE = "https://postfmapi-live.adyen.com/postfmapi/terminal";
|
||||
public static MANAGEMENT_API_ENDPOINT_TEST = "https://management-test.adyen.com";
|
||||
public static MANAGEMENT_API_ENDPOINT_LIVE = "https://management-live.adyen.com";
|
||||
public static BALANCE_PLATFORM_API_VERSION = "v2";
|
||||
public static BALANCE_PLATFORM_API_ENDPOINT_TEST = "https://balanceplatform-api-test.adyen.com/bcl";
|
||||
public static BALANCE_PLATFORM_API_ENDPOINT_LIVE = "https://balanceplatform-api-live.adyen.com/bcl";
|
||||
|
||||
private _httpClient!: ClientInterface;
|
||||
public config: Config;
|
||||
@@ -107,11 +103,22 @@ class Client {
|
||||
this.config.hppEndpoint = Client.HPP_TEST;
|
||||
this.config.checkoutEndpoint = Client.CHECKOUT_ENDPOINT_TEST;
|
||||
this.config.terminalApiCloudEndpoint = Client.TERMINAL_API_ENDPOINT_TEST;
|
||||
this.config.paymentEndpoint = Client.PAYMENT_API_ENDPOINT_TEST;
|
||||
this.config.storedValueEndpoint = Client.STOREDVALUE_API_ENDPOINT_TEST;
|
||||
this.config.terminalManagementEndpoint = Client.TERMINAL_MANAGEMENT_API_ENDPOINT_TEST;
|
||||
this.config.managementEndpoint = Client.MANAGEMENT_API_ENDPOINT_TEST;
|
||||
this.config.balancePlatformEndpoint = Client.BALANCE_PLATFORM_API_ENDPOINT_TEST;
|
||||
} else if (environment === "LIVE") {
|
||||
this.config.endpoint = Client.ENDPOINT_LIVE;
|
||||
this.config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_LIVE;
|
||||
this.config.hppEndpoint = Client.HPP_LIVE;
|
||||
this.config.terminalApiCloudEndpoint = Client.TERMINAL_API_ENDPOINT_LIVE;
|
||||
this.config.paymentEndpoint = Client.PAYMENT_API_ENDPOINT_LIVE;
|
||||
this.config.storedValueEndpoint = Client.STOREDVALUE_API_ENDPOINT_LIVE;
|
||||
this.config.terminalManagementEndpoint = Client.TERMINAL_MANAGEMENT_API_ENDPOINT_LIVE;
|
||||
this.config.managementEndpoint = Client.MANAGEMENT_API_ENDPOINT_LIVE;
|
||||
this.config.balancePlatformEndpoint = Client.BALANCE_PLATFORM_API_ENDPOINT_LIVE;
|
||||
|
||||
if (liveEndpointUrlPrefix) {
|
||||
this.config.endpoint =
|
||||
`${Client.ENDPOINT_PROTOCOL}${liveEndpointUrlPrefix}${Client.ENDPOINT_LIVE_SUFFIX}`;
|
||||
|
||||
@@ -34,6 +34,11 @@ interface ConfigConstructor {
|
||||
checkoutEndpoint?: string;
|
||||
terminalApiCloudEndpoint?: string;
|
||||
terminalApiLocalEndpoint?: string;
|
||||
paymentEndpoint?: string;
|
||||
storedValueEndpoint?: string;
|
||||
terminalManagementEndpoint?: string;
|
||||
managementEndpoint?: string;
|
||||
balancePlatformEndpoint?: string;
|
||||
}
|
||||
|
||||
class Config {
|
||||
@@ -58,6 +63,12 @@ class Config {
|
||||
public terminalApiCloudEndpoint?: string;
|
||||
public terminalApiLocalEndpoint?: string;
|
||||
|
||||
public paymentEndpoint?: string;
|
||||
public storedValueEndpoint?: string;
|
||||
public terminalManagementEndpoint?: string;
|
||||
public managementEndpoint?: string;
|
||||
public balancePlatformEndpoint?: string;
|
||||
|
||||
public constructor(options: ConfigConstructor = {}) {
|
||||
if (options.username) this.username = options.username;
|
||||
if (options.password) this.password = options.password;
|
||||
@@ -76,6 +87,11 @@ class Config {
|
||||
if (options.checkoutEndpoint) this._checkoutEndpoint = options.checkoutEndpoint;
|
||||
if (options.terminalApiCloudEndpoint) this.terminalApiCloudEndpoint = options.terminalApiCloudEndpoint;
|
||||
if (options.terminalApiLocalEndpoint) this.terminalApiLocalEndpoint = options.terminalApiLocalEndpoint;
|
||||
if (options.paymentEndpoint) this.paymentEndpoint = options.paymentEndpoint;
|
||||
if (options.storedValueEndpoint) this.storedValueEndpoint = options.storedValueEndpoint;
|
||||
if (options.terminalManagementEndpoint) this.terminalManagementEndpoint = options.terminalManagementEndpoint;
|
||||
if (options.managementEndpoint) this.managementEndpoint = options.managementEndpoint;
|
||||
if (options.balancePlatformEndpoint) this.balancePlatformEndpoint = options.balancePlatformEndpoint;
|
||||
}
|
||||
|
||||
public set checkoutEndpoint(checkoutEndpoint: string | undefined) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import { Agent, AgentOptions, request as httpsRequest } from "https";
|
||||
import { HttpsProxyAgent } from "https-proxy-agent";
|
||||
|
||||
import * as fs from "fs";
|
||||
import { URL } from "url";
|
||||
import { URL, URLSearchParams } from "url";
|
||||
import Client from "../client";
|
||||
import Config from "../config";
|
||||
import HttpClientException from "./httpClientException";
|
||||
@@ -87,6 +87,10 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
requestOptions.port = url.port;
|
||||
requestOptions.path = url.pathname;
|
||||
|
||||
if (requestOptions.params) {
|
||||
requestOptions.path += "?" + new URLSearchParams(requestOptions.params).toString();
|
||||
}
|
||||
|
||||
if (requestOptions && requestOptions.idempotencyKey) {
|
||||
requestOptions.headers[ApiConstants.IDEMPOTENCY_KEY] = requestOptions.idempotencyKey;
|
||||
delete requestOptions.idempotencyKey;
|
||||
@@ -195,8 +199,9 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
checkServerIdentity,
|
||||
};
|
||||
|
||||
} catch (e: any) {
|
||||
return Promise.reject(new HttpClientException({ message: `Error loading certificate from path: ${e.message}` }));
|
||||
} catch (e) {
|
||||
const message = e instanceof Error ? e.message: "undefined";
|
||||
return Promise.reject(new HttpClientException({ message: `Error loading certificate from path: ${message}` }));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
52
src/services/balancePlaftform/accountHolders.ts
Normal file
52
src/services/balancePlaftform/accountHolders.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { AccountHolder, AccountHolderInfo, ObjectSerializer, PaginatedBalanceAccountsResponse } from "../../typings/balancePlatform/models";
|
||||
import { IRequest } from "../../typings/requestOptions";
|
||||
import BalancePlatformResource from "../resource/balancePlaftformResource";
|
||||
|
||||
// @TODO PW-7013: make this change at the spec level?
|
||||
export type AccountHolderUpdate = Omit<AccountHolder, "id">;
|
||||
|
||||
class AccountHolders extends Service {
|
||||
public async create(request: AccountHolderInfo): Promise<AccountHolder> {
|
||||
const resource = new BalancePlatformResource(this, "/accountHolders");
|
||||
const response = await getJsonResponse<AccountHolderInfo, AccountHolder>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "AccountHolder");
|
||||
}
|
||||
|
||||
public async retrieve(id: string): Promise<AccountHolder> {
|
||||
const resource = new BalancePlatformResource(this, `/accountHolders/${id}`);
|
||||
const response = await getJsonResponse<string, AccountHolder>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "AccountHolder");
|
||||
}
|
||||
|
||||
public async update(id: string, request: AccountHolderUpdate): Promise<AccountHolder> {
|
||||
const resource = new BalancePlatformResource(this, `/accountHolders/${id}`);
|
||||
const response = await getJsonResponse<AccountHolderUpdate, AccountHolder>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "AccountHolder");
|
||||
}
|
||||
|
||||
public async listBalanceAccounts(id: string, requestOptions?: IRequest.Options): Promise<PaginatedBalanceAccountsResponse> {
|
||||
const resource = new BalancePlatformResource(this, `/accountHolders/${id}/balanceAccounts`);
|
||||
const response = await getJsonResponse<string, PaginatedBalanceAccountsResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaginatedBalanceAccountsResponse");
|
||||
}
|
||||
}
|
||||
|
||||
export default AccountHolders;
|
||||
103
src/services/balancePlaftform/balanceAccounts.ts
Normal file
103
src/services/balancePlaftform/balanceAccounts.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { BalanceAccount, BalanceAccountInfo, BalanceAccountUpdateRequest, BalanceSweepConfigurationsResponse, ObjectSerializer, PaginatedPaymentInstrumentsResponse, SweepConfigurationV2 } from "../../typings/balancePlatform/models";
|
||||
import { IRequest } from "../../typings/requestOptions";
|
||||
import BalancePlatformResource from "../resource/balancePlaftformResource";
|
||||
|
||||
// @TODO PW-7013: make this change at the spec level?
|
||||
export type SweepConfigurationV2Create = Omit<SweepConfigurationV2, "id">;
|
||||
export type SweepConfigurationV2Update = Partial<SweepConfigurationV2>;
|
||||
|
||||
class BalanceAccounts extends Service {
|
||||
public async create(request: BalanceAccountInfo): Promise<BalanceAccount> {
|
||||
const resource = new BalancePlatformResource(this, "/balanceAccounts");
|
||||
const response = await getJsonResponse<BalanceAccountInfo, BalanceAccount>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "BalanceAccount");
|
||||
}
|
||||
|
||||
public async listSweeps(balanceAccountId: string, requestOptions?: IRequest.Options): Promise<BalanceSweepConfigurationsResponse> {
|
||||
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps`);
|
||||
const response = await getJsonResponse<string, BalanceSweepConfigurationsResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "BalanceSweepConfigurationsResponse");
|
||||
}
|
||||
|
||||
public async createSweep(balanceAccountId: string, request: SweepConfigurationV2Create): Promise<SweepConfigurationV2> {
|
||||
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps`);
|
||||
const response = await getJsonResponse<SweepConfigurationV2Create, SweepConfigurationV2>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "SweepConfigurationV2");
|
||||
}
|
||||
|
||||
public async deleteSweep(balanceAccountId: string, sweepId: string): Promise<void> {
|
||||
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`);
|
||||
await getJsonResponse<string, string>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "DELETE" }
|
||||
);
|
||||
}
|
||||
|
||||
public async retrieveSweep(balanceAccountId: string, sweepId: string): Promise<SweepConfigurationV2> {
|
||||
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`);
|
||||
const response = await getJsonResponse<string, SweepConfigurationV2>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "SweepConfigurationV2");
|
||||
}
|
||||
|
||||
public async updateSweep(balanceAccountId: string, sweepId: string, request: SweepConfigurationV2Update): Promise<SweepConfigurationV2> {
|
||||
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`);
|
||||
const response = await getJsonResponse<SweepConfigurationV2Update, SweepConfigurationV2>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "SweepConfigurationV2");
|
||||
}
|
||||
|
||||
public async retrieve(id: string): Promise<BalanceAccount> {
|
||||
const resource = new BalancePlatformResource(this, `/balanceAccounts/${id}`);
|
||||
const response = await getJsonResponse<string, BalanceAccount>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "BalanceAccount");
|
||||
}
|
||||
|
||||
public async update(id: string, request: BalanceAccountUpdateRequest): Promise<BalanceAccount> {
|
||||
const resource = new BalancePlatformResource(this, `/balanceAccounts/${id}`);
|
||||
const response = await getJsonResponse<BalanceAccountUpdateRequest, BalanceAccount>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "BalanceAccount");
|
||||
}
|
||||
|
||||
public async listPaymentInstruments(id: string, requestOptions?: IRequest.Options): Promise<PaginatedPaymentInstrumentsResponse> {
|
||||
const resource = new BalancePlatformResource(this, `/balanceAccounts/${id}/paymentInstruments`);
|
||||
const response = await getJsonResponse<string, PaginatedPaymentInstrumentsResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaginatedPaymentInstrumentsResponse");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default BalanceAccounts;
|
||||
29
src/services/balancePlaftform/general.ts
Normal file
29
src/services/balancePlaftform/general.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { BalancePlatform, ObjectSerializer, PaginatedAccountHoldersResponse } from "../../typings/balancePlatform/models";
|
||||
import { IRequest } from "../../typings/requestOptions";
|
||||
import BalancePlatformResource from "../resource/balancePlaftformResource";
|
||||
|
||||
class General extends Service {
|
||||
public async retrieve(id: string): Promise<BalancePlatform> {
|
||||
const resource = new BalancePlatformResource(this, `/balancePlatforms/${id}`);
|
||||
const response = await getJsonResponse<string, BalancePlatform>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "BalancePlatform");
|
||||
}
|
||||
|
||||
public async listAccountHolders(id: string, requestOptions?: IRequest.Options): Promise<PaginatedAccountHoldersResponse> {
|
||||
const resource = new BalancePlatformResource(this, `/balancePlatforms/${id}/accountHolders`);
|
||||
const response = await getJsonResponse<string, PaginatedAccountHoldersResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaginatedAccountHoldersResponse");
|
||||
}
|
||||
}
|
||||
|
||||
export default General;
|
||||
39
src/services/balancePlaftform/paymentInstrumentGroups.ts
Normal file
39
src/services/balancePlaftform/paymentInstrumentGroups.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { ObjectSerializer, PaymentInstrumentGroup, PaymentInstrumentGroupInfo, TransactionRulesResponse } from "../../typings/balancePlatform/models";
|
||||
import BalancePlatformResource from "../resource/balancePlaftformResource";
|
||||
|
||||
class PaymentInstrumentGroups extends Service {
|
||||
public async create(request: PaymentInstrumentGroupInfo): Promise<PaymentInstrumentGroup> {
|
||||
const resource = new BalancePlatformResource(this, "/paymentInstrumentGroups");
|
||||
const response = await getJsonResponse<PaymentInstrumentGroupInfo, PaymentInstrumentGroup>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentInstrumentGroup");
|
||||
}
|
||||
|
||||
public async retrieve(id: string): Promise<PaymentInstrumentGroup> {
|
||||
const resource = new BalancePlatformResource(this, `/paymentInstrumentGroups/${id}`);
|
||||
const response = await getJsonResponse<string, PaymentInstrumentGroup>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentInstrumentGroup");
|
||||
}
|
||||
|
||||
public async listTransactionRules(id: string): Promise<TransactionRulesResponse> {
|
||||
const resource = new BalancePlatformResource(this, `/paymentInstrumentGroups/${id}/transactionRules`);
|
||||
const response = await getJsonResponse<string, TransactionRulesResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TransactionRulesResponse");
|
||||
}
|
||||
}
|
||||
|
||||
export default PaymentInstrumentGroups;
|
||||
|
||||
48
src/services/balancePlaftform/paymentInstruments.ts
Normal file
48
src/services/balancePlaftform/paymentInstruments.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { ObjectSerializer, PaymentInstrument, PaymentInstrumentInfo, PaymentInstrumentUpdateRequest, TransactionRulesResponse } from "../../typings/balancePlatform/models";
|
||||
import BalancePlatformResource from "../resource/balancePlaftformResource";
|
||||
|
||||
class PaymentInstruments extends Service {
|
||||
public async create(request: PaymentInstrumentInfo): Promise<PaymentInstrument> {
|
||||
const resource = new BalancePlatformResource(this, "/paymentInstruments");
|
||||
const response = await getJsonResponse<PaymentInstrumentInfo, PaymentInstrument>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentInstrument");
|
||||
}
|
||||
|
||||
public async retrieve(id: string): Promise<PaymentInstrument> {
|
||||
const resource = new BalancePlatformResource(this, `/paymentInstruments/${id}`);
|
||||
const response = await getJsonResponse<string, PaymentInstrument>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentInstrument");
|
||||
}
|
||||
|
||||
public async update(id: string, request: PaymentInstrumentUpdateRequest): Promise<PaymentInstrument> {
|
||||
const resource = new BalancePlatformResource(this, `/paymentInstruments/${id}`);
|
||||
const response = await getJsonResponse<PaymentInstrumentUpdateRequest, PaymentInstrument>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentInstrument");
|
||||
}
|
||||
|
||||
public async listTransactionRules(id: string): Promise<TransactionRulesResponse> {
|
||||
const resource = new BalancePlatformResource(this, `/paymentInstruments/${id}/transactionRules`);
|
||||
const response = await getJsonResponse<string, TransactionRulesResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TransactionRulesResponse");
|
||||
}
|
||||
}
|
||||
|
||||
export default PaymentInstruments;
|
||||
50
src/services/balancePlaftform/transactionRules.ts
Normal file
50
src/services/balancePlaftform/transactionRules.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { ObjectSerializer, TransactionRule, TransactionRuleInfo, TransactionRuleResponse } from "../../typings/balancePlatform/models";
|
||||
import BalancePlatformResource from "../resource/balancePlaftformResource";
|
||||
|
||||
// @TODO PW-7013: make this change at the spec level?
|
||||
export type TransactionRuleInfoUpdate = Partial<TransactionRuleInfo>;
|
||||
|
||||
class TransactionRules extends Service {
|
||||
public async create(request: TransactionRuleInfo): Promise<TransactionRule> {
|
||||
const resource = new BalancePlatformResource(this, "/transactionRules");
|
||||
const response = await getJsonResponse<TransactionRuleInfo, TransactionRule>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TransactionRule");
|
||||
}
|
||||
public async retrieve(transactionRuleId: string): Promise<TransactionRuleResponse> {
|
||||
const resource = new BalancePlatformResource(this, `/transactionRules/${transactionRuleId}`);
|
||||
const response = await getJsonResponse<string, TransactionRuleResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TransactionRuleResponse");
|
||||
}
|
||||
|
||||
public async update(transactionRuleId: string, request: TransactionRuleInfoUpdate): Promise<TransactionRule> {
|
||||
const resource = new BalancePlatformResource(this, `/transactionRules/${transactionRuleId}`);
|
||||
const response = await getJsonResponse<TransactionRuleInfoUpdate, TransactionRule>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TransactionRule");
|
||||
}
|
||||
|
||||
public async delete(transactionRuleId: string): Promise<TransactionRule> {
|
||||
const resource = new BalancePlatformResource(this, `/transactionRules/${transactionRuleId}`);
|
||||
const response = await getJsonResponse<string, TransactionRule>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "DELETE" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TransactionRule");
|
||||
}
|
||||
}
|
||||
|
||||
export default TransactionRules;
|
||||
40
src/services/balancePlatform.ts
Normal file
40
src/services/balancePlatform.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import Service from "../service";
|
||||
import Client from "../client";
|
||||
import AccountHolders from "./balancePlaftform/accountHolders";
|
||||
import BalanceAccounts from "./balancePlaftform/balanceAccounts";
|
||||
import General from "./balancePlaftform/general";
|
||||
import PaymentInstruments from "./balancePlaftform/paymentInstruments";
|
||||
import PaymentInstrumentGroups from "./balancePlaftform/paymentInstrumentGroups";
|
||||
import TransactionRules from "./balancePlaftform/transactionRules";
|
||||
|
||||
class BalancePlatform extends Service {
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
public get General() {
|
||||
return new General(this.client);
|
||||
}
|
||||
|
||||
public get AccountHolders() {
|
||||
return new AccountHolders(this.client);
|
||||
}
|
||||
|
||||
public get BalanceAccounts() {
|
||||
return new BalanceAccounts(this.client);
|
||||
}
|
||||
|
||||
public get PaymentInstruments() {
|
||||
return new PaymentInstruments(this.client);
|
||||
}
|
||||
|
||||
public get PaymentInstrumentGroups() {
|
||||
return new PaymentInstrumentGroups(this.client);
|
||||
}
|
||||
|
||||
public get TransactionRules() {
|
||||
return new TransactionRules(this.client);
|
||||
}
|
||||
}
|
||||
|
||||
export default BalancePlatform;
|
||||
@@ -1,26 +1,14 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
import ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService";
|
||||
import Client from "../client";
|
||||
import GetCostEstimate from "./resource/binLookup/getCostEstimate";
|
||||
import Get3dsAvailability from "./resource/binLookup/get3dsAvailability";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
import {
|
||||
ThreeDSAvailabilityRequest,
|
||||
ThreeDSAvailabilityResponse,
|
||||
CostEstimateRequest,
|
||||
CostEstimateResponse,
|
||||
} from "../typings/binlookup/models";
|
||||
|
||||
class BinLookup extends ApiKeyAuthenticatedService {
|
||||
private readonly _get3dsAvailability: Get3dsAvailability;
|
||||
@@ -32,15 +20,15 @@ class BinLookup extends ApiKeyAuthenticatedService {
|
||||
this._getCostEstimate = new GetCostEstimate(this);
|
||||
}
|
||||
|
||||
public get3dsAvailability(request: IBinLookup.ThreeDSAvailabilityRequest): Promise<IBinLookup.ThreeDSAvailabilityResponse> {
|
||||
return getJsonResponse<IBinLookup.ThreeDSAvailabilityRequest, IBinLookup.ThreeDSAvailabilityResponse>(
|
||||
public get3dsAvailability(request: ThreeDSAvailabilityRequest): Promise<ThreeDSAvailabilityResponse> {
|
||||
return getJsonResponse<ThreeDSAvailabilityRequest, ThreeDSAvailabilityResponse>(
|
||||
this._get3dsAvailability,
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public getCostEstimate(request: IBinLookup.CostEstimateRequest): Promise<IBinLookup.CostEstimateResponse> {
|
||||
return getJsonResponse<IBinLookup.CostEstimateRequest, IBinLookup.CostEstimateResponse>(
|
||||
public getCostEstimate(request: CostEstimateRequest): Promise<CostEstimateResponse> {
|
||||
return getJsonResponse<CostEstimateRequest, CostEstimateResponse>(
|
||||
this._getCostEstimate,
|
||||
request
|
||||
);
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
import ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService";
|
||||
import Client from "../client";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
@@ -28,6 +9,12 @@ import PaymentsResult from "./resource/checkout/paymentsResult";
|
||||
import PaymentLinks from "./resource/checkout/paymentLinks";
|
||||
import OriginKeys from "./resource/checkout/originKeys";
|
||||
import setApplicationInfo from "../helpers/setApplicationInfo";
|
||||
import AmountUpdates from "./resource/checkout/amountUpdates";
|
||||
import Cancels from "./resource/checkout/cancels";
|
||||
import Captures from "./resource/checkout/captures";
|
||||
import Refunds from "./resource/checkout/refunds";
|
||||
import Reversals from "./resource/checkout/reversals";
|
||||
import CancelsStandalone from "./resource/checkout/cancelsStandalone";
|
||||
import { IRequest } from "../typings/requestOptions";
|
||||
import {
|
||||
PaymentRequest,
|
||||
@@ -52,7 +39,22 @@ import {
|
||||
CreateCheckoutSessionRequest,
|
||||
CreateCheckoutSessionResponse,
|
||||
PaymentDonationRequest,
|
||||
DonationResponse
|
||||
DonationResponse,
|
||||
CardDetailsRequest,
|
||||
CardDetailsResponse,
|
||||
CreatePaymentAmountUpdateRequest,
|
||||
CreatePaymentCancelRequest,
|
||||
CreatePaymentCaptureRequest,
|
||||
CreatePaymentRefundRequest,
|
||||
CreatePaymentReversalRequest,
|
||||
CreateStandalonePaymentCancelRequest,
|
||||
PaymentAmountUpdateResource,
|
||||
PaymentCancelResource,
|
||||
PaymentCaptureResource,
|
||||
PaymentRefundResource,
|
||||
PaymentReversalResource,
|
||||
StandalonePaymentCancelResource,
|
||||
ObjectSerializer
|
||||
} from "../typings/checkout/models";
|
||||
|
||||
import PaymentLinksId from "./resource/checkout/paymentLinksId";
|
||||
@@ -61,6 +63,7 @@ import Orders from "./resource/checkout/orders";
|
||||
import OrdersCancel from "./resource/checkout/ordersCancel";
|
||||
import Sessions from "./resource/checkout/sessions";
|
||||
import Donations from "./resource/checkout/donations";
|
||||
import CardDetails from "./resource/checkout/cardDetails";
|
||||
|
||||
class Checkout extends ApiKeyAuthenticatedService {
|
||||
private readonly _payments: Payments;
|
||||
@@ -69,13 +72,13 @@ class Checkout extends ApiKeyAuthenticatedService {
|
||||
private readonly _paymentSession: PaymentSession;
|
||||
private readonly _paymentsResult: PaymentsResult;
|
||||
private readonly _paymentLinks: PaymentLinks;
|
||||
private readonly _paymentLinksId: PaymentLinksId;
|
||||
private readonly _originKeys: OriginKeys;
|
||||
private readonly _paymentMethodsBalance: PaymentMethodsBalance;
|
||||
private readonly _orders: Orders;
|
||||
private readonly _ordersCancel: OrdersCancel;
|
||||
private readonly _sessions: Sessions;
|
||||
private readonly _donations: Donations;
|
||||
private readonly _cardDetails: CardDetails;
|
||||
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
@@ -85,121 +88,248 @@ class Checkout extends ApiKeyAuthenticatedService {
|
||||
this._paymentSession = new PaymentSession(this);
|
||||
this._paymentsResult = new PaymentsResult(this);
|
||||
this._paymentLinks = new PaymentLinks(this);
|
||||
this._paymentLinksId = new PaymentLinksId(this);
|
||||
this._originKeys = new OriginKeys(this);
|
||||
this._paymentMethodsBalance = new PaymentMethodsBalance(this);
|
||||
this._orders = new Orders(this);
|
||||
this._ordersCancel = new OrdersCancel(this);
|
||||
this._sessions = new Sessions(this);
|
||||
this._donations = new Donations(this);
|
||||
this._cardDetails = new CardDetails(this);
|
||||
}
|
||||
|
||||
public payments(paymentsRequest: PaymentRequest, requestOptions?: IRequest.Options): Promise<PaymentResponse> {
|
||||
return getJsonResponse<PaymentRequest, PaymentResponse>(
|
||||
// Payments
|
||||
|
||||
public async sessions(checkoutSessionRequest: CreateCheckoutSessionRequest, requestOptions?: IRequest.Options): Promise<CreateCheckoutSessionResponse> {
|
||||
const response = await getJsonResponse<CreateCheckoutSessionRequest, CreateCheckoutSessionResponse>(
|
||||
this._sessions,
|
||||
checkoutSessionRequest,
|
||||
requestOptions,
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "CreateCheckoutSessionResponse");
|
||||
}
|
||||
|
||||
public async paymentMethods(paymentMethodsRequest: PaymentMethodsRequest, requestOptions?: IRequest.Options): Promise<PaymentMethodsResponse> {
|
||||
const response = await getJsonResponse<PaymentMethodsRequest, PaymentMethodsResponse>(
|
||||
this._paymentMethods,
|
||||
paymentMethodsRequest,
|
||||
requestOptions,
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentMethodsResponse");
|
||||
}
|
||||
|
||||
public async payments(paymentsRequest: PaymentRequest, requestOptions?: IRequest.Options): Promise<PaymentResponse> {
|
||||
const response = await getJsonResponse<PaymentRequest, PaymentResponse>(
|
||||
this._payments,
|
||||
setApplicationInfo(paymentsRequest),
|
||||
requestOptions,
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentResponse");
|
||||
}
|
||||
|
||||
public paymentMethods(paymentMethodsRequest: PaymentMethodsRequest): Promise<PaymentMethodsResponse> {
|
||||
return getJsonResponse<PaymentMethodsRequest, PaymentMethodsResponse>(
|
||||
this._paymentMethods,
|
||||
paymentMethodsRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public paymentLinks(paymentLinkRequest: CreatePaymentLinkRequest): Promise<PaymentLinkResponse> {
|
||||
return getJsonResponse<CreatePaymentLinkRequest, PaymentLinkResponse>(
|
||||
this._paymentLinks,
|
||||
paymentLinkRequest
|
||||
);
|
||||
}
|
||||
|
||||
public getPaymentLinks(linkId: string): Promise<PaymentLinkResponse> {
|
||||
this._paymentLinksId.id = linkId;
|
||||
return getJsonResponse<Record<string, never>, PaymentLinkResponse>(
|
||||
this._paymentLinksId,
|
||||
{},
|
||||
{ method: "GET" }
|
||||
);
|
||||
}
|
||||
|
||||
public updatePaymentLinks(linkId: string, status: "expired"): Promise<PaymentLinkResponse> {
|
||||
this._paymentLinksId.id = linkId;
|
||||
return getJsonResponse<Record<string, unknown>, PaymentLinkResponse>(
|
||||
this._paymentLinksId,
|
||||
{ status },
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
}
|
||||
|
||||
public paymentsDetails(paymentsDetailsRequest: DetailsRequest, requestOptions?: IRequest.Options): Promise<PaymentResponse> {
|
||||
return getJsonResponse<DetailsRequest, PaymentResponse>(
|
||||
public async paymentsDetails(paymentsDetailsRequest: DetailsRequest, requestOptions?: IRequest.Options): Promise<PaymentResponse> {
|
||||
const response = await getJsonResponse<DetailsRequest, PaymentResponse>(
|
||||
this._paymentsDetails,
|
||||
paymentsDetailsRequest,
|
||||
requestOptions
|
||||
requestOptions,
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentResponse");
|
||||
}
|
||||
|
||||
public paymentSession(
|
||||
public async donations(donationRequest: PaymentDonationRequest, requestOptions?: IRequest.Options): Promise<DonationResponse> {
|
||||
const response = await getJsonResponse<PaymentDonationRequest, DonationResponse>(
|
||||
this._donations,
|
||||
donationRequest,
|
||||
requestOptions,
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "DonationResponse");
|
||||
}
|
||||
|
||||
public async cardDetails(cardDetailsRequest: CardDetailsRequest, requestOptions?: IRequest.Options): Promise<CardDetailsResponse> {
|
||||
const response = await getJsonResponse<CardDetailsRequest, CardDetailsResponse>(
|
||||
this._cardDetails,
|
||||
cardDetailsRequest,
|
||||
requestOptions,
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "CardDetailsResponse");
|
||||
}
|
||||
|
||||
// Payment Links
|
||||
|
||||
public async paymentLinks(paymentLinkRequest: CreatePaymentLinkRequest, requestOptions?: IRequest.Options): Promise<PaymentLinkResponse> {
|
||||
const response = await getJsonResponse<CreatePaymentLinkRequest, PaymentLinkResponse>(
|
||||
this._paymentLinks,
|
||||
paymentLinkRequest,
|
||||
requestOptions,
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentLinkResponse");
|
||||
}
|
||||
|
||||
public async getPaymentLinks(linkId: string, requestOptions?: IRequest.Options): Promise<PaymentLinkResponse> {
|
||||
const paymentLinksId = new PaymentLinksId(this, linkId);
|
||||
const response = await getJsonResponse<Record<string, never>, PaymentLinkResponse>(
|
||||
paymentLinksId,
|
||||
{},
|
||||
{...{ method: "GET" }, ...requestOptions},
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentLinkResponse");
|
||||
}
|
||||
|
||||
public async updatePaymentLinks(linkId: string, status: "expired", requestOptions?: IRequest.Options): Promise<PaymentLinkResponse> {
|
||||
const paymentLinksId = new PaymentLinksId(this, linkId);
|
||||
const response = await getJsonResponse<Record<string, unknown>, PaymentLinkResponse>(
|
||||
paymentLinksId,
|
||||
{ status },
|
||||
{...{ method: "PATCH" }, ...requestOptions},
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentLinkResponse");
|
||||
}
|
||||
|
||||
// Modifications
|
||||
|
||||
public async amountUpdates(
|
||||
paymentPspReference: string,
|
||||
amountUpdatesRequest: CreatePaymentAmountUpdateRequest,
|
||||
requestOptions?: IRequest.Options,
|
||||
): Promise<PaymentAmountUpdateResource> {
|
||||
const amountUpdates = new AmountUpdates(this, paymentPspReference);
|
||||
const response = await getJsonResponse<CreatePaymentAmountUpdateRequest, PaymentAmountUpdateResource>(
|
||||
amountUpdates,
|
||||
amountUpdatesRequest,
|
||||
requestOptions
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentAmountUpdateResource");
|
||||
}
|
||||
|
||||
public async cancelsStandalone(
|
||||
cancelsStandaloneRequest: CreateStandalonePaymentCancelRequest,
|
||||
requestOptions?: IRequest.Options
|
||||
): Promise<StandalonePaymentCancelResource> {
|
||||
const cancelsStandalone = new CancelsStandalone(this);
|
||||
const response = await getJsonResponse<CreateStandalonePaymentCancelRequest, StandalonePaymentCancelResource>(
|
||||
cancelsStandalone,
|
||||
cancelsStandaloneRequest,
|
||||
requestOptions
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "StandalonePaymentCancelResource");
|
||||
}
|
||||
|
||||
public async cancels(
|
||||
paymentPspReference: string,
|
||||
cancelsRequest: CreatePaymentCancelRequest,
|
||||
requestOptions?: IRequest.Options,
|
||||
): Promise<PaymentCancelResource> {
|
||||
const cancels = new Cancels(this, paymentPspReference);
|
||||
const response = await getJsonResponse<CreatePaymentCancelRequest, PaymentCancelResource>(
|
||||
cancels,
|
||||
cancelsRequest,
|
||||
requestOptions
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentCancelResource");
|
||||
}
|
||||
|
||||
public async captures(
|
||||
paymentPspReference: string,
|
||||
capturesRequest: CreatePaymentCaptureRequest,
|
||||
requestOptions?: IRequest.Options
|
||||
): Promise<PaymentCaptureResource> {
|
||||
const captures = new Captures(this, paymentPspReference);
|
||||
const response = await getJsonResponse<CreatePaymentCaptureRequest, PaymentCaptureResource>(
|
||||
captures,
|
||||
capturesRequest,
|
||||
requestOptions
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentCaptureResource");
|
||||
}
|
||||
|
||||
public async refunds(
|
||||
paymentPspReference: string,
|
||||
refundsRequest: CreatePaymentRefundRequest,
|
||||
requestOptions?: IRequest.Options
|
||||
): Promise<PaymentRefundResource> {
|
||||
const refunds = new Refunds(this, paymentPspReference);
|
||||
const response = await getJsonResponse<CreatePaymentRefundRequest, PaymentRefundResource>(
|
||||
refunds,
|
||||
refundsRequest,
|
||||
requestOptions
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentRefundResource");
|
||||
}
|
||||
|
||||
public async reversals(
|
||||
paymentPspReference: string,
|
||||
reversalsRequest: CreatePaymentReversalRequest,
|
||||
requestOptions?: IRequest.Options
|
||||
): Promise<PaymentReversalResource> {
|
||||
const refunds = new Reversals(this, paymentPspReference);
|
||||
const response = await getJsonResponse<CreatePaymentReversalRequest, PaymentReversalResource>(
|
||||
refunds,
|
||||
reversalsRequest,
|
||||
requestOptions
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentReversalResource");
|
||||
}
|
||||
|
||||
// Orders
|
||||
|
||||
public async paymentMethodsBalance(paymentMethodsBalanceRequest: CheckoutBalanceCheckRequest, requestOptions?: IRequest.Options): Promise<CheckoutBalanceCheckResponse> {
|
||||
const response = await getJsonResponse<CheckoutBalanceCheckRequest, CheckoutBalanceCheckResponse>(
|
||||
this._paymentMethodsBalance,
|
||||
paymentMethodsBalanceRequest,
|
||||
requestOptions,
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "CheckoutBalanceCheckResponse");
|
||||
}
|
||||
|
||||
public async orders(ordersRequest: CheckoutCreateOrderRequest, requestOptions?: IRequest.Options): Promise<CheckoutCreateOrderResponse> {
|
||||
const response = await getJsonResponse<CheckoutCreateOrderRequest, CheckoutCreateOrderResponse>(
|
||||
this._orders,
|
||||
ordersRequest,
|
||||
requestOptions,
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "CheckoutCreateOrderResponse");
|
||||
}
|
||||
|
||||
public async ordersCancel(ordersCancelRequest: CheckoutCancelOrderRequest, requestOptions?: IRequest.Options): Promise<CheckoutCancelOrderResponse> {
|
||||
const response = await getJsonResponse<CheckoutCancelOrderRequest, CheckoutCancelOrderResponse>(
|
||||
this._ordersCancel,
|
||||
ordersCancelRequest,
|
||||
requestOptions,
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "CheckoutCancelOrderResponse");
|
||||
}
|
||||
|
||||
// Classic Checkout SDK
|
||||
|
||||
public async paymentSession(
|
||||
paymentSessionRequest: PaymentSetupRequest,
|
||||
requestOptions?: IRequest.Options,
|
||||
): Promise<PaymentSetupResponse> {
|
||||
return getJsonResponse<PaymentSetupRequest, PaymentSetupResponse>(
|
||||
const response = await getJsonResponse<PaymentSetupRequest, PaymentSetupResponse>(
|
||||
this._paymentSession,
|
||||
paymentSessionRequest,
|
||||
requestOptions,
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentSetupResponse");
|
||||
}
|
||||
|
||||
public paymentResult(paymentResultRequest: PaymentVerificationRequest): Promise<PaymentVerificationResponse> {
|
||||
return getJsonResponse<PaymentVerificationRequest, PaymentVerificationResponse>(
|
||||
public async paymentResult(paymentResultRequest: PaymentVerificationRequest, requestOptions?: IRequest.Options): Promise<PaymentVerificationResponse> {
|
||||
const response = await getJsonResponse<PaymentVerificationRequest, PaymentVerificationResponse>(
|
||||
this._paymentsResult,
|
||||
paymentResultRequest,
|
||||
requestOptions,
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentVerificationResponse");
|
||||
}
|
||||
|
||||
public originKeys(originKeysRequest: CheckoutUtilityRequest): Promise<CheckoutUtilityResponse> {
|
||||
return getJsonResponse<CheckoutUtilityRequest, CheckoutUtilityResponse>(
|
||||
//Utility
|
||||
|
||||
public async originKeys(originKeysRequest: CheckoutUtilityRequest, requestOptions?: IRequest.Options): Promise<CheckoutUtilityResponse> {
|
||||
const response = await getJsonResponse<CheckoutUtilityRequest, CheckoutUtilityResponse>(
|
||||
this._originKeys,
|
||||
originKeysRequest,
|
||||
requestOptions,
|
||||
);
|
||||
}
|
||||
|
||||
public paymentMethodsBalance(paymentMethodsBalanceRequest: CheckoutBalanceCheckRequest): Promise<CheckoutBalanceCheckResponse> {
|
||||
return getJsonResponse<CheckoutBalanceCheckRequest, CheckoutBalanceCheckResponse>(
|
||||
this._paymentMethodsBalance,
|
||||
paymentMethodsBalanceRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public orders(ordersRequest: CheckoutCreateOrderRequest): Promise<CheckoutCreateOrderResponse> {
|
||||
return getJsonResponse<CheckoutCreateOrderRequest, CheckoutCreateOrderResponse>(
|
||||
this._orders,
|
||||
ordersRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public ordersCancel(ordersCancelRequest: CheckoutCancelOrderRequest): Promise<CheckoutCancelOrderResponse> {
|
||||
return getJsonResponse<CheckoutCancelOrderRequest, CheckoutCancelOrderResponse>(
|
||||
this._ordersCancel,
|
||||
ordersCancelRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public sessions(checkoutSessionRequest: CreateCheckoutSessionRequest): Promise<CreateCheckoutSessionResponse> {
|
||||
return getJsonResponse<CreateCheckoutSessionRequest, CreateCheckoutSessionResponse>(
|
||||
this._sessions,
|
||||
checkoutSessionRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public donations(donationRequest: PaymentDonationRequest): Promise<DonationResponse> {
|
||||
return getJsonResponse<PaymentDonationRequest, DonationResponse>(
|
||||
this._donations,
|
||||
donationRequest,
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "CheckoutUtilityResponse");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
171
src/services/classicIntegration.ts
Normal file
171
src/services/classicIntegration.ts
Normal file
@@ -0,0 +1,171 @@
|
||||
import ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService";
|
||||
import Client from "../client";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
import Authorise from "./resource/payment/authorise";
|
||||
import Authorise3d from "./resource/payment/authorise3d";
|
||||
import Authorise3ds2 from "./resource/payment/authorise3ds2";
|
||||
import GetAuthenticationResult from "./resource/payment/getAuthenticationResult";
|
||||
import Retrieve3ds2Result from "./resource/payment/retrieve3ds2Result";
|
||||
import Capture from "./resource/payment/capture";
|
||||
import Cancel from "./resource/payment/cancel";
|
||||
import Refund from "./resource/payment/refund";
|
||||
import CancelOrRefund from "./resource/payment/cancelOrRefund";
|
||||
import TechnicalCancel from "./resource/payment/technicalCancel";
|
||||
import AdjustAuthorisation from "./resource/payment/adjustAuthorisation";
|
||||
import Donate from "./resource/payment/donate";
|
||||
import VoidPendingRefund from "./resource/payment/voidPendingRefund";
|
||||
|
||||
import {
|
||||
AdjustAuthorisationRequest,
|
||||
AuthenticationResultRequest,
|
||||
AuthenticationResultResponse,
|
||||
CancelOrRefundRequest,
|
||||
CancelRequest,
|
||||
CaptureRequest,
|
||||
DonationRequest,
|
||||
ModificationResult,
|
||||
PaymentRequest,
|
||||
PaymentRequest3d,
|
||||
PaymentRequest3ds2,
|
||||
PaymentResult,
|
||||
RefundRequest,
|
||||
TechnicalCancelRequest,
|
||||
ThreeDS2ResultRequest,
|
||||
ThreeDS2ResultResponse,
|
||||
VoidPendingRefundRequest,
|
||||
} from "../typings/payments/models";
|
||||
|
||||
|
||||
class ClassicIntegration extends ApiKeyAuthenticatedService {
|
||||
private readonly _authorise;
|
||||
private readonly _authorise3d;
|
||||
private readonly _authorise3ds2;
|
||||
private readonly _getAuthenticationResult;
|
||||
private readonly _retrieve3ds2Result;
|
||||
private readonly _capture;
|
||||
private readonly _cancel;
|
||||
private readonly _refund;
|
||||
private readonly _cancelOrRefund;
|
||||
private readonly _technicalCancel;
|
||||
private readonly _adjustAuthorisation;
|
||||
private readonly _donate;
|
||||
private readonly _voidPendingRefund;
|
||||
|
||||
|
||||
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
this._authorise = new Authorise(this);
|
||||
this._authorise3d = new Authorise3d(this);
|
||||
this._authorise3ds2 = new Authorise3ds2(this);
|
||||
this._getAuthenticationResult = new GetAuthenticationResult(this);
|
||||
this._retrieve3ds2Result = new Retrieve3ds2Result(this);
|
||||
this._capture = new Capture(this);
|
||||
this._cancel = new Cancel(this);
|
||||
this._refund = new Refund(this);
|
||||
this._cancelOrRefund = new CancelOrRefund(this);
|
||||
this._technicalCancel = new TechnicalCancel(this);
|
||||
this._adjustAuthorisation = new AdjustAuthorisation(this);
|
||||
this._donate = new Donate(this);
|
||||
this._voidPendingRefund = new VoidPendingRefund(this);
|
||||
|
||||
}
|
||||
|
||||
// General
|
||||
|
||||
public authorise(paymentRequest: PaymentRequest): Promise<PaymentResult> {
|
||||
return getJsonResponse<PaymentRequest, PaymentResult>(
|
||||
this._authorise,
|
||||
paymentRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public authorise3d(paymentRequest3d: PaymentRequest3d): Promise<PaymentResult> {
|
||||
return getJsonResponse<PaymentRequest3d, PaymentResult>(
|
||||
this._authorise3d,
|
||||
paymentRequest3d,
|
||||
);
|
||||
}
|
||||
|
||||
public authorise3ds2(paymentRequest3ds2: PaymentRequest3ds2): Promise<PaymentResult> {
|
||||
return getJsonResponse<PaymentRequest3ds2, PaymentResult>(
|
||||
this._authorise3ds2,
|
||||
paymentRequest3ds2,
|
||||
);
|
||||
}
|
||||
|
||||
public getAuthenticationResult(authenticationResultRequest: AuthenticationResultRequest): Promise<AuthenticationResultResponse> {
|
||||
return getJsonResponse<AuthenticationResultRequest, AuthenticationResultResponse>(
|
||||
this._getAuthenticationResult,
|
||||
authenticationResultRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public retrieve3ds2Result(threeDs2ResultRequest: ThreeDS2ResultRequest): Promise<ThreeDS2ResultResponse> {
|
||||
return getJsonResponse<ThreeDS2ResultRequest, ThreeDS2ResultResponse>(
|
||||
this._retrieve3ds2Result,
|
||||
threeDs2ResultRequest,
|
||||
);
|
||||
}
|
||||
|
||||
// Modifications
|
||||
|
||||
public capture(captureRequest: CaptureRequest): Promise<ModificationResult> {
|
||||
return getJsonResponse<CaptureRequest, ModificationResult>(
|
||||
this._capture,
|
||||
captureRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public cancel(cancelRequest: CancelRequest): Promise<ModificationResult> {
|
||||
return getJsonResponse<CancelRequest, ModificationResult>(
|
||||
this._cancel,
|
||||
cancelRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public refund(refundRequest: RefundRequest): Promise<ModificationResult> {
|
||||
return getJsonResponse<RefundRequest, ModificationResult>(
|
||||
this._refund,
|
||||
refundRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public cancelOrRefund(cancelOrRefundRequest: CancelOrRefundRequest): Promise<ModificationResult> {
|
||||
return getJsonResponse<CancelOrRefundRequest, ModificationResult>(
|
||||
this._cancelOrRefund,
|
||||
cancelOrRefundRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public technicalCancel(technicalCancelRequest: TechnicalCancelRequest): Promise<ModificationResult> {
|
||||
return getJsonResponse<TechnicalCancelRequest, ModificationResult>(
|
||||
this._technicalCancel,
|
||||
technicalCancelRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public adjustAuthorisation(adjustAuthorisationRequest: AdjustAuthorisationRequest): Promise<ModificationResult> {
|
||||
return getJsonResponse<AdjustAuthorisationRequest, ModificationResult>(
|
||||
this._adjustAuthorisation,
|
||||
adjustAuthorisationRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public donate(donationRequest: DonationRequest): Promise<ModificationResult> {
|
||||
return getJsonResponse<DonationRequest, ModificationResult>(
|
||||
this._donate,
|
||||
donationRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public voidPendingRefund(voidPendingRefundRequest: VoidPendingRefundRequest): Promise<ModificationResult> {
|
||||
return getJsonResponse<VoidPendingRefundRequest, ModificationResult>(
|
||||
this._voidPendingRefund,
|
||||
voidPendingRefundRequest,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ClassicIntegration;
|
||||
|
||||
@@ -1,27 +1,11 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
export { default as TerminalLocalAPI } from "./terminalLocalAPI";
|
||||
export { default as TerminalCloudAPI } from "./terminalCloudAPI";
|
||||
export { default as CheckoutAPI } from "./checkout";
|
||||
export { default as ClassicIntegrationAPI } from "./classicIntegration";
|
||||
export { default as Recurring } from "./recurring";
|
||||
export { default as Modification } from "./modification";
|
||||
export { default as BinLookup } from "./binLookup";
|
||||
export { default as Payout } from "./payout";
|
||||
export { default as Platforms } from "./platforms";
|
||||
export { default as StoredValue} from "./storedValue";
|
||||
export { default as TerminalManagement} from "./terminalManagement";
|
||||
export { default as Management } from "./management";
|
||||
72
src/services/management.ts
Normal file
72
src/services/management.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import Service from "../service";
|
||||
import Client from "../client";
|
||||
|
||||
import MeApi from "./management/meApi";
|
||||
import MerchantAccount from "./management/merchantAccount";
|
||||
import MerchantAllowedOrigins from "./management/merchantAllowedOrigins";
|
||||
import MerchantApiCredentials from "./management/merchantApiCredentials";
|
||||
import MerchantApiKey from "./management/merchantApiKey";
|
||||
import MerchantClientKey from "./management/merchantClientKey";
|
||||
import MerchantPaymentMethods from "./management/merchantPaymentMethods";
|
||||
import MerchantPayoutSettings from "./management/merchantPayoutSettings";
|
||||
import MerchantTerminalOrders from "./management/merchantTerminalOrders";
|
||||
import MerchantTerminalSettings from "./management/merchantTerminalSettings";
|
||||
import MerchantUsers from "./management/merchantUsers";
|
||||
import MerchantWebhooks from "./management/merchantWebhooks";
|
||||
|
||||
class Management extends Service {
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
public get Me() {
|
||||
const meApi = new MeApi(this.client);
|
||||
return meApi.Me;
|
||||
}
|
||||
|
||||
public get MerchantAccount() {
|
||||
return new MerchantAccount(this.client);
|
||||
}
|
||||
|
||||
public get MerchantAllowedOrigins() {
|
||||
return new MerchantAllowedOrigins(this.client);
|
||||
}
|
||||
|
||||
public get MerchantApiCredentials() {
|
||||
return new MerchantApiCredentials(this.client);
|
||||
}
|
||||
|
||||
public get MerchantApiKey() {
|
||||
return new MerchantApiKey(this.client);
|
||||
}
|
||||
|
||||
public get MerchantClientKey() {
|
||||
return new MerchantClientKey(this.client);
|
||||
}
|
||||
|
||||
public get MerchantPaymentMethods() {
|
||||
return new MerchantPaymentMethods(this.client);
|
||||
}
|
||||
|
||||
public get MerchantPayoutSettings() {
|
||||
return new MerchantPayoutSettings(this.client);
|
||||
}
|
||||
|
||||
public get MerchantTerminalOrders() {
|
||||
return new MerchantTerminalOrders(this.client);
|
||||
}
|
||||
|
||||
public get MerchantTerminalSettings() {
|
||||
return new MerchantTerminalSettings(this.client);
|
||||
}
|
||||
|
||||
public get MerchantUsers() {
|
||||
return new MerchantUsers(this.client);
|
||||
}
|
||||
|
||||
public get MerchantWebhooks() {
|
||||
return new MerchantWebhooks(this.client);
|
||||
}
|
||||
}
|
||||
|
||||
export default Management;
|
||||
71
src/services/management/meApi.ts
Normal file
71
src/services/management/meApi.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import Client from "../../client";
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import {
|
||||
AllowedOrigin,
|
||||
AllowedOriginsResponse,
|
||||
CreateAllowedOriginRequest,
|
||||
MeApiCredential
|
||||
} from "../../typings/management/models";
|
||||
|
||||
import Me from "../resource/management/me";
|
||||
|
||||
class MeApi extends Service {
|
||||
//Me
|
||||
private readonly _retrieveMe: Me;
|
||||
private readonly _allowedOrigins: Me;
|
||||
|
||||
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
this._retrieveMe = new Me(this, "");
|
||||
this._allowedOrigins = new Me(this, "/allowedOrigins");
|
||||
}
|
||||
|
||||
public get Me(): {
|
||||
retrieve:() => Promise<MeApiCredential>;
|
||||
createAllowedOrigin: (allowedOriginRequest: CreateAllowedOriginRequest) => Promise<AllowedOrigin>;
|
||||
retrieveAllowedOrigins: () => Promise<AllowedOriginsResponse>;
|
||||
retrieveAllowedOrigin: (originId: string) => Promise<AllowedOrigin>;
|
||||
deleteAllowerdOrigin: (originId: string) => Promise<Record<string, unknown>>;
|
||||
} {
|
||||
const retrieve = () => getJsonResponse<Record<string, never>, MeApiCredential>(
|
||||
this._retrieveMe,
|
||||
{},
|
||||
{ method: "GET"}
|
||||
);
|
||||
|
||||
const createAllowedOrigin = (allowedOriginRequest: CreateAllowedOriginRequest) => getJsonResponse<CreateAllowedOriginRequest, AllowedOrigin>(
|
||||
this._allowedOrigins,
|
||||
allowedOriginRequest,
|
||||
);
|
||||
|
||||
const retrieveAllowedOrigins = () => getJsonResponse<Record<string, never>, AllowedOriginsResponse>(
|
||||
this._allowedOrigins,
|
||||
{},
|
||||
{ method: "GET"}
|
||||
);
|
||||
|
||||
const retrieveAllowedOrigin = (originId: string) => {
|
||||
const allowedOrigin = new Me(this, `/allowedOrigins/${originId}`);
|
||||
return getJsonResponse<Record<string, never>, AllowedOrigin>(
|
||||
allowedOrigin,
|
||||
{},
|
||||
{ method: "GET"}
|
||||
);
|
||||
};
|
||||
|
||||
const deleteAllowerdOrigin = (originId: string) => {
|
||||
const allowedOrigin = new Me(this, `/allowedOrigins/${originId}`);
|
||||
return getJsonResponse<Record<string, never>, Record<string, unknown>>(
|
||||
allowedOrigin,
|
||||
{},
|
||||
{ method: "DELETE"}
|
||||
);
|
||||
};
|
||||
|
||||
return { retrieve, createAllowedOrigin, retrieveAllowedOrigins, retrieveAllowedOrigin, deleteAllowerdOrigin };
|
||||
}
|
||||
}
|
||||
|
||||
export default MeApi;
|
||||
61
src/services/management/merchantAccount.ts
Normal file
61
src/services/management/merchantAccount.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { CreateMerchantRequest, CreateMerchantResponse, ListMerchantResponse, Merchant, ObjectSerializer, RequestActivationResponse } from "../../typings/management/models";
|
||||
import { IRequest } from "../../typings/requestOptions";
|
||||
import ManagementResource from "../resource/management/managementResource";
|
||||
|
||||
class MerchantAccount extends Service {
|
||||
/**
|
||||
* Get a list of merchant accounts
|
||||
*/
|
||||
public async list(requestOptions?: IRequest.Options): Promise<ListMerchantResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants`);
|
||||
const response = await getJsonResponse<string, ListMerchantResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "ListMerchantResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a merchant account
|
||||
*/
|
||||
public async create(request: CreateMerchantRequest): Promise<CreateMerchantResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants`);
|
||||
const response = await getJsonResponse<CreateMerchantRequest, CreateMerchantResponse>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "CreateMerchantResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a merchant account
|
||||
*/
|
||||
public async retrieve(merchantId: string): Promise<Merchant> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}`);
|
||||
const response = await getJsonResponse<string, Merchant>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "Merchant");
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to activate a merchant account
|
||||
*/
|
||||
public async activate(merchantId: string): Promise<RequestActivationResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/activate`);
|
||||
const response = await getJsonResponse<string, RequestActivationResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "RequestActivationResponse");
|
||||
}
|
||||
}
|
||||
|
||||
export default MerchantAccount;
|
||||
59
src/services/management/merchantAllowedOrigins.ts
Normal file
59
src/services/management/merchantAllowedOrigins.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { AllowedOrigin, AllowedOriginsResponse, ObjectSerializer } from "../../typings/management/models";
|
||||
import ManagementResource from "../resource/management/managementResource";
|
||||
|
||||
class MerchantAllowedOrigins extends Service {
|
||||
/**
|
||||
* Get a list of allowed origins
|
||||
*/
|
||||
public async list(merchantId: string, apiCredentialId: string): Promise<AllowedOriginsResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins`);
|
||||
const response = await getJsonResponse<string, AllowedOriginsResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "AllowedOriginsResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an allowed origin
|
||||
*/
|
||||
public async create(merchantId: string, apiCredentialId: string, request: AllowedOrigin): Promise<AllowedOriginsResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins`);
|
||||
const response = await getJsonResponse<AllowedOrigin, AllowedOriginsResponse>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "AllowedOriginsResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an allowed origin
|
||||
*/
|
||||
public async delete(merchantId: string, apiCredentialId: string, originId: string): Promise<void> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins/${originId}`);
|
||||
await getJsonResponse<string, void>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "DELETE" }
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an allowed origin
|
||||
*/
|
||||
public async retrieve(merchantId: string, apiCredentialId: string, originId: string): Promise<AllowedOrigin> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins/${originId}`);
|
||||
const response = await getJsonResponse<string, AllowedOrigin>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "AllowedOrigin");
|
||||
}
|
||||
}
|
||||
|
||||
export default MerchantAllowedOrigins;
|
||||
61
src/services/management/merchantApiCredentials.ts
Normal file
61
src/services/management/merchantApiCredentials.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { ApiCredential, CreateApiCredentialResponse, CreateMerchantApiCredentialRequest, ListMerchantApiCredentialsResponse, ObjectSerializer, UpdateMerchantApiCredentialRequest } from "../../typings/management/models";
|
||||
import { IRequest } from "../../typings/requestOptions";
|
||||
import ManagementResource from "../resource/management/managementResource";
|
||||
|
||||
class MerchantApiCredentials extends Service {
|
||||
/**
|
||||
* Get a list of API credentials
|
||||
*/
|
||||
public async list(merchantId: string, requestOptions?: IRequest.Options): Promise<ListMerchantApiCredentialsResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials`);
|
||||
const response = await getJsonResponse<string, ListMerchantApiCredentialsResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "ListMerchantApiCredentialsResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an API credential
|
||||
*/
|
||||
public async create(merchantId: string, request: CreateMerchantApiCredentialRequest): Promise<CreateApiCredentialResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials`);
|
||||
const response = await getJsonResponse<CreateMerchantApiCredentialRequest, CreateApiCredentialResponse>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "CreateApiCredentialResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an API credential
|
||||
*/
|
||||
public async retrieve(merchantId: string, apiCredentialId: string): Promise<ApiCredential> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}`);
|
||||
const response = await getJsonResponse<string, ApiCredential>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "ApiCredential");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an API credential
|
||||
*/
|
||||
public async update(merchantId: string, apiCredentialId: string, request: UpdateMerchantApiCredentialRequest): Promise<ApiCredential> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}`);
|
||||
const response = await getJsonResponse<UpdateMerchantApiCredentialRequest, ApiCredential>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "ApiCredential");
|
||||
}
|
||||
}
|
||||
|
||||
export default MerchantApiCredentials;
|
||||
21
src/services/management/merchantApiKey.ts
Normal file
21
src/services/management/merchantApiKey.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { GenerateApiKeyResponse, ObjectSerializer } from "../../typings/management/models";
|
||||
import ManagementResource from "../resource/management/managementResource";
|
||||
|
||||
class MerchantApiKey extends Service {
|
||||
/**
|
||||
* Generate new API key
|
||||
*/
|
||||
public async create(merchantId: string, apiCredentialId: string): Promise<GenerateApiKeyResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/generateApiKey`);
|
||||
const response = await getJsonResponse<string, GenerateApiKeyResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "GenerateApiKeyResponse");
|
||||
}
|
||||
}
|
||||
|
||||
export default MerchantApiKey;
|
||||
21
src/services/management/merchantClientKey.ts
Normal file
21
src/services/management/merchantClientKey.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { GenerateClientKeyResponse, ObjectSerializer } from "../../typings/management/models";
|
||||
import ManagementResource from "../resource/management/managementResource";
|
||||
|
||||
class MerchantClientKey extends Service {
|
||||
/**
|
||||
* Generate new client key
|
||||
*/
|
||||
public async create(merchantId: string, apiCredentialId: string): Promise<GenerateClientKeyResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/generateClientKey`);
|
||||
const response = await getJsonResponse<string, GenerateClientKeyResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "GenerateClientKeyResponse");
|
||||
}
|
||||
}
|
||||
|
||||
export default MerchantClientKey;
|
||||
61
src/services/management/merchantPaymentMethods.ts
Normal file
61
src/services/management/merchantPaymentMethods.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { ObjectSerializer, PaymentMethod, PaymentMethodResponse, PaymentMethodSetupInfo, UpdatePaymentMethodInfo } from "../../typings/management/models";
|
||||
import { IRequest } from "../../typings/requestOptions";
|
||||
import ManagementResource from "../resource/management/managementResource";
|
||||
|
||||
class MerchantPaymentMethods extends Service {
|
||||
/**
|
||||
* Get all payment methods
|
||||
*/
|
||||
public async listPaymentMethodSettings(merchantId: string, requestOptions?: IRequest.Options): Promise<PaymentMethodResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/paymentMethodSettings`);
|
||||
const response = await getJsonResponse<string, PaymentMethodResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentMethodResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Request a payment method
|
||||
*/
|
||||
public async create(merchantId: string, request: PaymentMethodSetupInfo): Promise<PaymentMethod> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/paymentMethodSettings`);
|
||||
const response = await getJsonResponse<PaymentMethodSetupInfo, PaymentMethod>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentMethod");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get payment method details
|
||||
*/
|
||||
public async retrieve(merchantId: string, paymentMethodId: string): Promise<PaymentMethod> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/paymentMethodSettings/${paymentMethodId}`);
|
||||
const response = await getJsonResponse<string, PaymentMethod>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentMethod");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a payment method
|
||||
*/
|
||||
public async update(merchantId: string, paymentMethodId: string, request: UpdatePaymentMethodInfo): Promise<PaymentMethod> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/paymentMethodSettings/${paymentMethodId}`);
|
||||
const response = await getJsonResponse<UpdatePaymentMethodInfo, PaymentMethod>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PaymentMethod");
|
||||
}
|
||||
}
|
||||
|
||||
export default MerchantPaymentMethods;
|
||||
72
src/services/management/merchantPayoutSettings.ts
Normal file
72
src/services/management/merchantPayoutSettings.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { ObjectSerializer, PayoutSettings, PayoutSettingsRequest, PayoutSettingsResponse, UpdatePayoutSettingsRequest } from "../../typings/management/models";
|
||||
import ManagementResource from "../resource/management/managementResource";
|
||||
|
||||
class MerchantPayoutSettings extends Service {
|
||||
/**
|
||||
* Get a list of payout settings
|
||||
*/
|
||||
public async listPayoutSettings(merchantId: string): Promise<PayoutSettingsResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings`);
|
||||
const response = await getJsonResponse<string, PayoutSettingsResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PayoutSettingsResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a payout setting
|
||||
*/
|
||||
public async create(merchantId: string, request: PayoutSettingsRequest): Promise<PayoutSettings> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings`);
|
||||
const response = await getJsonResponse<PayoutSettingsRequest, PayoutSettings>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PayoutSettings");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a payout setting
|
||||
*/
|
||||
public async delete(merchantId: string, payoutSettingsId: string): Promise<void> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`);
|
||||
await getJsonResponse<string, void>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "DELETE" }
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a payout setting
|
||||
*/
|
||||
public async retrieve(merchantId: string, payoutSettingsId: string): Promise<PayoutSettings> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`);
|
||||
const response = await getJsonResponse<string, PayoutSettings>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PayoutSettings");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a payout setting
|
||||
*/
|
||||
public async update(merchantId: string, payoutSettingsId: string, request: UpdatePayoutSettingsRequest): Promise<PayoutSettings> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`);
|
||||
const response = await getJsonResponse<UpdatePayoutSettingsRequest, PayoutSettings>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "PayoutSettings");
|
||||
}
|
||||
}
|
||||
|
||||
export default MerchantPayoutSettings;
|
||||
139
src/services/management/merchantTerminalOrders.ts
Normal file
139
src/services/management/merchantTerminalOrders.ts
Normal file
@@ -0,0 +1,139 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { BillingEntitiesResponse, ObjectSerializer, ShippingLocation, ShippingLocationsResponse, TerminalModelsResponse, TerminalOrder, TerminalOrderRequest, TerminalOrdersResponse, TerminalProductsResponse } from "../../typings/management/models";
|
||||
import { IRequest } from "../../typings/requestOptions";
|
||||
import ManagementResource from "../resource/management/managementResource";
|
||||
|
||||
class MerchantTerminalOrders extends Service {
|
||||
/**
|
||||
* Get a list of billing entities
|
||||
*/
|
||||
public async listBillingEntities(merchantId: string, requestOptions?: IRequest.Options): Promise<BillingEntitiesResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/billingEntities`);
|
||||
const response = await getJsonResponse<string, BillingEntitiesResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "BillingEntitiesResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of shipping locations
|
||||
*/
|
||||
public async listShippingLocations(merchantId: string, requestOptions?: IRequest.Options): Promise<ShippingLocationsResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/shippingLocations`);
|
||||
const response = await getJsonResponse<string, ShippingLocationsResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "ShippingLocationsResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a shipping location
|
||||
*/
|
||||
public async createShippingLocation(merchantId: string, request: ShippingLocation): Promise<ShippingLocation> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/shippingLocations`);
|
||||
const response = await getJsonResponse<ShippingLocation, ShippingLocation>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "ShippingLocation");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of terminal models
|
||||
*/
|
||||
public async listTerminalModels(merchantId: string): Promise<TerminalModelsResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalModels`);
|
||||
const response = await getJsonResponse<string, TerminalModelsResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TerminalModelsResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of orders
|
||||
*/
|
||||
public async listTerminalOrders(merchantId: string, requestOptions?: IRequest.Options): Promise<TerminalOrdersResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders`);
|
||||
const response = await getJsonResponse<string, TerminalOrdersResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TerminalOrdersResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an order
|
||||
*/
|
||||
public async create(merchantId: string, request: TerminalOrderRequest): Promise<TerminalOrder> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders`);
|
||||
const response = await getJsonResponse<TerminalOrderRequest, TerminalOrder>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an order
|
||||
*/
|
||||
public async retrieve(merchantId: string, orderId: string): Promise<TerminalOrder> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders/${orderId}`);
|
||||
const response = await getJsonResponse<string, TerminalOrder>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an order
|
||||
*/
|
||||
public async update(merchantId: string, orderId: string, request: TerminalOrderRequest): Promise<TerminalOrder> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders/${orderId}`);
|
||||
const response = await getJsonResponse<TerminalOrderRequest, TerminalOrder>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel an order
|
||||
*/
|
||||
public async cancel(merchantId: string, orderId: string): Promise<TerminalOrder> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders/${orderId}/cancel`);
|
||||
const response = await getJsonResponse<string, TerminalOrder>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of terminal products
|
||||
*/
|
||||
public async listTerminalProducts(merchantId: string, requestOptions?: IRequest.Options): Promise<TerminalProductsResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalProducts`);
|
||||
const response = await getJsonResponse<string, TerminalProductsResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TerminalProductsResponse");
|
||||
}
|
||||
}
|
||||
|
||||
export default MerchantTerminalOrders;
|
||||
61
src/services/management/merchantTerminalSettings.ts
Normal file
61
src/services/management/merchantTerminalSettings.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { Logo, ObjectSerializer, TerminalSettings } from "../../typings/management/models";
|
||||
import { IRequest } from "../../typings/requestOptions";
|
||||
import ManagementResource from "../resource/management/managementResource";
|
||||
|
||||
class MerchantTerminalSettings extends Service {
|
||||
/**
|
||||
* Get the terminal logo
|
||||
*/
|
||||
public async retrieveLogo(merchantId: string, requestOptions?: IRequest.Options): Promise<Logo> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalLogos`);
|
||||
const response = await getJsonResponse<string, Logo>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "Logo");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the terminal logo
|
||||
*/
|
||||
public async updateLogo(merchantId: string, request: Logo, requestOptions?: IRequest.Options): Promise<Logo> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalLogos`);
|
||||
const response = await getJsonResponse<Logo, Logo>(
|
||||
resource,
|
||||
request,
|
||||
{ ...requestOptions, method: "PATCH" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "Logo");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get terminal settings
|
||||
*/
|
||||
public async retrieve(merchantId: string): Promise<TerminalSettings> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalSettings`);
|
||||
const response = await getJsonResponse<string, TerminalSettings>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TerminalSettings");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update terminal settings
|
||||
*/
|
||||
public async update(merchantId: string, request: TerminalSettings): Promise<TerminalSettings> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalSettings`);
|
||||
const response = await getJsonResponse<TerminalSettings, TerminalSettings>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TerminalSettings");
|
||||
}
|
||||
}
|
||||
|
||||
export default MerchantTerminalSettings;
|
||||
61
src/services/management/merchantUsers.ts
Normal file
61
src/services/management/merchantUsers.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { CreateMerchantUserRequest, CreateUserResponse, ListMerchantUsersResponse, ObjectSerializer, UpdateMerchantUserRequest, User } from "../../typings/management/models";
|
||||
import { IRequest } from "../../typings/requestOptions";
|
||||
import ManagementResource from "../resource/management/managementResource";
|
||||
|
||||
class MerchantUsers extends Service {
|
||||
/**
|
||||
* Get a list of users
|
||||
*/
|
||||
public async list(merchantId: string, requestOptions?: IRequest.Options): Promise<ListMerchantUsersResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/users`);
|
||||
const response = await getJsonResponse<string, ListMerchantUsersResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "ListMerchantUsersResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user
|
||||
*/
|
||||
public async create(merchantId: string, request: CreateMerchantUserRequest): Promise<CreateUserResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/users`);
|
||||
const response = await getJsonResponse<CreateMerchantUserRequest, CreateUserResponse>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "CreateUserResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user details
|
||||
*/
|
||||
public async retrieve(merchantId: string, userId: string): Promise<User> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/users/${userId}`);
|
||||
const response = await getJsonResponse<string, User>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "User");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a user
|
||||
*/
|
||||
public async update(merchantId: string, userId: string, request: UpdateMerchantUserRequest): Promise<User> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/users/${userId}`);
|
||||
const response = await getJsonResponse<UpdateMerchantUserRequest, User>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "User");
|
||||
}
|
||||
}
|
||||
|
||||
export default MerchantUsers;
|
||||
99
src/services/management/merchantWebhooks.ts
Normal file
99
src/services/management/merchantWebhooks.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||
import Service from "../../service";
|
||||
import { CreateMerchantWebhookRequest, GenerateHmacKeyResponse, ListWebhooksResponse, ObjectSerializer, TestWebhookRequest, TestWebhookResponse, UpdateMerchantWebhookRequest, Webhook } from "../../typings/management/models";
|
||||
import { IRequest } from "../../typings/requestOptions";
|
||||
import ManagementResource from "../resource/management/managementResource";
|
||||
|
||||
class MerchantWebhooks extends Service {
|
||||
/**
|
||||
* List all webhooks
|
||||
*/
|
||||
public async list(merchantId: string, requestOptions?: IRequest.Options): Promise<ListWebhooksResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks`);
|
||||
const response = await getJsonResponse<string, ListWebhooksResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ ...requestOptions, method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "ListWebhooksResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up a webhook
|
||||
*/
|
||||
public async create(merchantId: string, request: CreateMerchantWebhookRequest): Promise<Webhook> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks`);
|
||||
const response = await getJsonResponse<CreateMerchantWebhookRequest, Webhook>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "Webhook");
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a webhook
|
||||
*/
|
||||
public async delete(merchantId: string, webhookId: string): Promise<void> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}`);
|
||||
await getJsonResponse<string, void>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "DELETE" }
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a webhook
|
||||
*/
|
||||
public async retrieve(merchantId: string, webhookId: string): Promise<Webhook> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}`);
|
||||
const response = await getJsonResponse<string, Webhook>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "GET" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "Webhook");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a webhook
|
||||
*/
|
||||
public async update(merchantId: string, webhookId: string, request: UpdateMerchantWebhookRequest): Promise<Webhook> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}`);
|
||||
const response = await getJsonResponse<UpdateMerchantWebhookRequest, Webhook>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "Webhook");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an HMAC key
|
||||
*/
|
||||
public async generateHmac(merchantId: string, webhookId: string): Promise<GenerateHmacKeyResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}/generateHmac`);
|
||||
const response = await getJsonResponse<string, GenerateHmacKeyResponse>(
|
||||
resource,
|
||||
"",
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "GenerateHmacKeyResponse");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a webhook
|
||||
*/
|
||||
public async test(merchantId: string, webhookId: string, request: TestWebhookRequest): Promise<TestWebhookResponse> {
|
||||
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}/test`);
|
||||
const response = await getJsonResponse<TestWebhookRequest, TestWebhookResponse>(
|
||||
resource,
|
||||
request,
|
||||
{ method: "POST" }
|
||||
);
|
||||
return ObjectSerializer.deserialize(response, "TestWebhookResponse");
|
||||
}
|
||||
}
|
||||
|
||||
export default MerchantWebhooks;
|
||||
@@ -1,128 +0,0 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2021 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
import Client from "../client";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
import Service from "../service";
|
||||
import { ApplicationInfo } from "../typings/applicationInfo";
|
||||
import { IRequest } from "../typings/requestOptions";
|
||||
import AmountUpdates from "./resource/modification/amountUpdates";
|
||||
import Cancels from "./resource/modification/cancels";
|
||||
import Captures from "./resource/modification/captures";
|
||||
import Refunds from "./resource/modification/refunds";
|
||||
import Reversals from "./resource/modification/reversals";
|
||||
import CancelsStandalone from "./resource/modification/cancelsStandalone";
|
||||
import {
|
||||
CreatePaymentAmountUpdateRequest,
|
||||
CreatePaymentCancelRequest,
|
||||
CreatePaymentCaptureRequest,
|
||||
CreatePaymentRefundRequest, CreatePaymentReversalRequest,
|
||||
CreateStandalonePaymentCancelRequest,
|
||||
PaymentAmountUpdateResource,
|
||||
PaymentCancelResource,
|
||||
PaymentCaptureResource, PaymentRefundResource, PaymentReversalResource,
|
||||
StandalonePaymentCancelResource
|
||||
} from "../typings/checkout/models";
|
||||
|
||||
interface AppInfo { applicationInfo?: ApplicationInfo }
|
||||
type GenericRequest<T> = T & AppInfo;
|
||||
|
||||
class Modification extends Service {
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
public amountUpdates(
|
||||
paymentPspReference: string,
|
||||
amountUpdatesRequest: GenericRequest<CreatePaymentAmountUpdateRequest>,
|
||||
requestOptions?: IRequest.Options,
|
||||
): Promise<PaymentAmountUpdateResource> {
|
||||
const amountUpdates = new AmountUpdates(this, paymentPspReference);
|
||||
return getJsonResponse<CreatePaymentAmountUpdateRequest, PaymentAmountUpdateResource>(
|
||||
amountUpdates,
|
||||
amountUpdatesRequest,
|
||||
requestOptions
|
||||
);
|
||||
}
|
||||
|
||||
public cancelsStandalone(
|
||||
cancelsStandaloneRequest: GenericRequest<CreateStandalonePaymentCancelRequest>,
|
||||
requestOptions?: IRequest.Options
|
||||
): Promise<StandalonePaymentCancelResource> {
|
||||
const cancelsStandalone = new CancelsStandalone(this);
|
||||
return getJsonResponse<CreateStandalonePaymentCancelRequest, StandalonePaymentCancelResource>(
|
||||
cancelsStandalone,
|
||||
cancelsStandaloneRequest,
|
||||
requestOptions
|
||||
);
|
||||
}
|
||||
|
||||
public cancels(
|
||||
paymentPspReference: string,
|
||||
cancelsRequest: GenericRequest<CreatePaymentCancelRequest>,
|
||||
requestOptions?: IRequest.Options,
|
||||
): Promise<PaymentCancelResource> {
|
||||
const cancels = new Cancels(this, paymentPspReference);
|
||||
return getJsonResponse<CreatePaymentCancelRequest, PaymentCancelResource>(
|
||||
cancels,
|
||||
cancelsRequest,
|
||||
requestOptions
|
||||
);
|
||||
}
|
||||
|
||||
public captures(
|
||||
paymentPspReference: string,
|
||||
capturesRequest: GenericRequest<CreatePaymentCaptureRequest>,
|
||||
requestOptions?: IRequest.Options
|
||||
): Promise<PaymentCaptureResource> {
|
||||
const captures = new Captures(this, paymentPspReference);
|
||||
return getJsonResponse<CreatePaymentCaptureRequest, PaymentCaptureResource>(
|
||||
captures,
|
||||
capturesRequest,
|
||||
requestOptions
|
||||
);
|
||||
}
|
||||
|
||||
public refunds(
|
||||
paymentPspReference: string,
|
||||
refundsRequest: GenericRequest<CreatePaymentRefundRequest>,
|
||||
requestOptions?: IRequest.Options
|
||||
): Promise<PaymentRefundResource> {
|
||||
const refunds = new Refunds(this, paymentPspReference);
|
||||
return getJsonResponse<CreatePaymentRefundRequest, PaymentRefundResource>(
|
||||
refunds,
|
||||
refundsRequest,
|
||||
requestOptions
|
||||
);
|
||||
}
|
||||
|
||||
public reversals(
|
||||
paymentPspReference: string,
|
||||
reversalsRequest: GenericRequest<CreatePaymentReversalRequest>,
|
||||
requestOptions?: IRequest.Options
|
||||
): Promise<PaymentReversalResource> {
|
||||
const refunds = new Reversals(this, paymentPspReference);
|
||||
return getJsonResponse<CreatePaymentReversalRequest, PaymentReversalResource>(
|
||||
refunds,
|
||||
reversalsRequest,
|
||||
requestOptions
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Modification;
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
import Client from "../client";
|
||||
import Service from "../service";
|
||||
import DeclineThirdParty from "./resource/payout/declineThirdParty";
|
||||
@@ -25,6 +7,18 @@ import ConfirmThirdParty from "./resource/payout/confirmThirdParty";
|
||||
import PayoutResource from "./resource/payout/payout";
|
||||
import StoreDetailAndSubmitThirdParty from "./resource/payout/storeDetailAndSubmitThirdParty";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
import {
|
||||
ModifyRequest,
|
||||
ModifyResponse,
|
||||
PayoutRequest,
|
||||
PayoutResponse,
|
||||
StoreDetailAndSubmitRequest,
|
||||
StoreDetailAndSubmitResponse,
|
||||
StoreDetailRequest,
|
||||
StoreDetailResponse,
|
||||
SubmitRequest,
|
||||
SubmitResponse
|
||||
} from "../typings/payouts/models";
|
||||
|
||||
class Payout extends Service {
|
||||
private readonly _storeDetailAndSubmitThirdParty: StoreDetailAndSubmitThirdParty;
|
||||
@@ -45,47 +39,47 @@ class Payout extends Service {
|
||||
this._payout = new PayoutResource(this);
|
||||
}
|
||||
|
||||
public storeDetailAndSubmitThirdParty(request: IPayouts.StoreDetailAndSubmitRequest): Promise<IPayouts.StoreDetailAndSubmitResponse> {
|
||||
return getJsonResponse<IPayouts.StoreDetailAndSubmitRequest, IPayouts.StoreDetailAndSubmitResponse>(
|
||||
public storeDetailAndSubmitThirdParty(request: StoreDetailAndSubmitRequest): Promise<StoreDetailAndSubmitResponse> {
|
||||
return getJsonResponse<StoreDetailAndSubmitRequest, StoreDetailAndSubmitResponse>(
|
||||
this._storeDetailAndSubmitThirdParty,
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public confirmThirdParty(request: IPayouts.ModifyRequest): Promise<IPayouts.ModifyResponse> {
|
||||
return getJsonResponse<IPayouts.ModifyRequest, IPayouts.ModifyResponse>(
|
||||
public confirmThirdParty(request: ModifyRequest): Promise<ModifyResponse> {
|
||||
return getJsonResponse<ModifyRequest, ModifyResponse>(
|
||||
this._confirmThirdParty,
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public declineThirdParty(request: IPayouts.ModifyRequest): Promise<IPayouts.ModifyResponse> {
|
||||
return getJsonResponse<IPayouts.ModifyRequest, IPayouts.ModifyResponse>(
|
||||
public declineThirdParty(request: ModifyRequest): Promise<ModifyResponse> {
|
||||
return getJsonResponse<ModifyRequest, ModifyResponse>(
|
||||
this._declineThirdParty,
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public storeDetail(request: IPayouts.StoreDetailRequest): Promise<IPayouts.StoreDetailResponse> {
|
||||
return getJsonResponse<IPayouts.StoreDetailRequest, IPayouts.StoreDetailResponse>(
|
||||
public storeDetail(request: StoreDetailRequest): Promise<StoreDetailResponse> {
|
||||
return getJsonResponse<StoreDetailRequest, StoreDetailResponse>(
|
||||
this._storeDetail,
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public submitThirdparty(request: IPayouts.SubmitRequest): Promise<IPayouts.SubmitResponse> {
|
||||
return getJsonResponse<IPayouts.SubmitRequest, IPayouts.SubmitResponse>(
|
||||
public submitThirdparty(request: SubmitRequest): Promise<SubmitResponse> {
|
||||
return getJsonResponse<SubmitRequest, SubmitResponse>(
|
||||
this._submitThirdParty,
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public payout(request: IPayouts.PayoutRequest): Promise<IPayouts.PayoutResponse> {
|
||||
return getJsonResponse<IPayouts.PayoutRequest, IPayouts.PayoutResponse>(
|
||||
public payout(request: PayoutRequest): Promise<PayoutResponse> {
|
||||
return getJsonResponse<PayoutRequest, PayoutResponse>(
|
||||
this._payout,
|
||||
request
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Payout;
|
||||
export default Payout;
|
||||
|
||||
@@ -1,23 +1,3 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
|
||||
import Service from "../service";
|
||||
import Client from "../client";
|
||||
import PlatformsAccount, { AccountTypesEnum } from "./resource/platforms/account";
|
||||
@@ -58,6 +38,14 @@ import {
|
||||
GetTaxFormResponse,
|
||||
} from "../typings/platformsAccount/models";
|
||||
|
||||
import {
|
||||
GetOnboardingUrlRequest,
|
||||
GetOnboardingUrlResponse,
|
||||
GetPciUrlRequest,
|
||||
GetPciUrlResponse
|
||||
} from "../typings/platformsHostedOnboardingPage/models";
|
||||
import { DebitAccountHolderRequest, DebitAccountHolderResponse } from "../typings/platformsFund/models";
|
||||
|
||||
type AccountType = AccountTypesEnum.Accounts;
|
||||
type VerificationType = AccountTypesEnum.Verification;
|
||||
type AccountHoldersType = AccountTypesEnum.AccountHolders;
|
||||
@@ -98,9 +86,11 @@ class Platforms extends Service {
|
||||
private readonly _refundFundsTransfer: PlatformsFund;
|
||||
private readonly _setupBeneficiary: PlatformsFund;
|
||||
private readonly _refundNotPaidOutTransfers: PlatformsFund;
|
||||
private readonly _debitAccountHolder: PlatformsFund;
|
||||
|
||||
/* HOP */
|
||||
private readonly _getOnboardingUrl: PlatformsHostedOnboardingPage;
|
||||
private readonly _getPciQuestionnaireUrl: PlatformsHostedOnboardingPage;
|
||||
|
||||
/* Notification Configuration */
|
||||
private readonly _createNotificationConfiguration: PlatformsNotificationConfiguration;
|
||||
@@ -141,9 +131,11 @@ class Platforms extends Service {
|
||||
this._refundFundsTransfer = new PlatformsFund(this, "/refundFundsTransfer");
|
||||
this._setupBeneficiary = new PlatformsFund(this, "/setupBeneficiary");
|
||||
this._refundNotPaidOutTransfers = new PlatformsFund(this, "/refundNotPaidOutTransfers");
|
||||
this._debitAccountHolder = new PlatformsFund(this, "/debitAccountHolder");
|
||||
|
||||
// HOP
|
||||
this._getOnboardingUrl = new PlatformsHostedOnboardingPage(this, "/getOnboardingUrl");
|
||||
this._getPciQuestionnaireUrl = new PlatformsHostedOnboardingPage(this, "/getPciQuestionnaireUrl");
|
||||
|
||||
// Notification Configuration
|
||||
this._createNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/createNotificationConfiguration");
|
||||
@@ -156,7 +148,7 @@ class Platforms extends Service {
|
||||
|
||||
createRequest = <T extends PlatformsTypes, U, V>(service: T) => {
|
||||
return (request: U): Promise<V> => getJsonResponse<U, V>(service, request);
|
||||
}
|
||||
};
|
||||
|
||||
public get Account(): {
|
||||
getAccountHolder: (request: GetAccountHolderRequest) => Promise<GetAccountHolderResponse>;
|
||||
@@ -212,6 +204,7 @@ class Platforms extends Service {
|
||||
refundFundsTransfer: (request: IPlatformsFund.RefundFundsTransferRequest) => Promise<IPlatformsFund.RefundFundsTransferResponse>;
|
||||
payoutAccountHolder: (request: IPlatformsFund.PayoutAccountHolderRequest) => Promise<IPlatformsFund.PayoutAccountHolderResponse>;
|
||||
accountHolderBalance: (request: IPlatformsFund.AccountHolderBalanceRequest) => Promise<IPlatformsFund.AccountHolderBalanceResponse>;
|
||||
debitAccountHolder: (request: DebitAccountHolderRequest) => Promise<DebitAccountHolderResponse>;
|
||||
} {
|
||||
const accountHolderBalance = this.createRequest<PlatformsFund, IPlatformsFund.AccountHolderBalanceRequest, IPlatformsFund.AccountHolderBalanceResponse>(this._accountHolderBalance);
|
||||
const accountHolderTransactionList = this.createRequest<PlatformsFund, IPlatformsFund.AccountHolderTransactionListRequest, IPlatformsFund.AccountHolderTransactionListResponse>(this._accountHolderTransactionList);
|
||||
@@ -220,14 +213,18 @@ class Platforms extends Service {
|
||||
const refundFundsTransfer = this.createRequest<PlatformsFund, IPlatformsFund.RefundFundsTransferRequest, IPlatformsFund.RefundFundsTransferResponse>(this._refundFundsTransfer);
|
||||
const setupBeneficiary = this.createRequest<PlatformsFund, IPlatformsFund.SetupBeneficiaryRequest, IPlatformsFund.SetupBeneficiaryResponse>(this._setupBeneficiary);
|
||||
const refundNotPaidOutTransfers = this.createRequest<PlatformsFund, IPlatformsFund.RefundNotPaidOutTransfersRequest, IPlatformsFund.RefundNotPaidOutTransfersResponse>(this._refundNotPaidOutTransfers);
|
||||
const debitAccountHolder = this.createRequest<PlatformsFund, DebitAccountHolderRequest, DebitAccountHolderResponse>(this._debitAccountHolder);
|
||||
|
||||
return { accountHolderBalance, accountHolderTransactionList, payoutAccountHolder, refundFundsTransfer, transferFunds, setupBeneficiary, refundNotPaidOutTransfers };
|
||||
return { accountHolderBalance, accountHolderTransactionList, payoutAccountHolder, refundFundsTransfer, transferFunds, setupBeneficiary, refundNotPaidOutTransfers, debitAccountHolder };
|
||||
}
|
||||
|
||||
public get HostedOnboardingPage(): { getOnboardingUrl: (request: IPlatformsHostedOnboardingPage.GetOnboardingUrlRequest) => Promise<IPlatformsHostedOnboardingPage.GetOnboardingUrlResponse> } {
|
||||
const getOnboardingUrl = this.createRequest<PlatformsHostedOnboardingPage, IPlatformsHostedOnboardingPage.GetOnboardingUrlRequest, IPlatformsHostedOnboardingPage.GetOnboardingUrlResponse>(this._getOnboardingUrl);
|
||||
|
||||
return { getOnboardingUrl };
|
||||
public get HostedOnboardingPage(): {
|
||||
getOnboardingUrl: (request: GetOnboardingUrlRequest) => Promise<GetOnboardingUrlResponse>;
|
||||
getPciQuestionnaireUrl: (request: GetPciUrlRequest) => Promise<GetPciUrlResponse>;
|
||||
} {
|
||||
const getOnboardingUrl = this.createRequest<PlatformsHostedOnboardingPage, GetOnboardingUrlRequest, GetOnboardingUrlResponse>(this._getOnboardingUrl);
|
||||
const getPciQuestionnaireUrl = this.createRequest<PlatformsHostedOnboardingPage, GetPciUrlRequest, GetPciUrlResponse>(this._getPciQuestionnaireUrl);
|
||||
return { getOnboardingUrl, getPciQuestionnaireUrl };
|
||||
}
|
||||
|
||||
public get NotificationConfiguration(): {
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
import Client from "../client";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
import Service from "../service";
|
||||
@@ -39,7 +20,7 @@ class Recurring extends Service {
|
||||
private readonly _listRecurringDetails: ListRecurringDetails;
|
||||
private readonly _disable: Disable;
|
||||
private readonly _scheduleAccountUpdater: ScheduleAccountUpdater;
|
||||
private readonly _notifyShopper: NotifyShopper
|
||||
private readonly _notifyShopper: NotifyShopper;
|
||||
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
|
||||
14
src/services/resource/balancePlaftformResource.ts
Normal file
14
src/services/resource/balancePlaftformResource.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../client";
|
||||
import Service from "../../service";
|
||||
import Resource from "../resource";
|
||||
|
||||
class BalancePlatformResource extends Resource {
|
||||
public constructor(service: Service, endpoint: string) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.balancePlatformEndpoint}/${Client.BALANCE_PLATFORM_API_VERSION}${endpoint}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default BalancePlatformResource;
|
||||
14
src/services/resource/checkout/cardDetails.ts
Normal file
14
src/services/resource/checkout/cardDetails.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class CardDetails extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/cardDetails`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default CardDetails;
|
||||
@@ -1,40 +1,15 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class PaymentLinksId extends Resource {
|
||||
static _id: string;
|
||||
|
||||
public constructor(service: Service) {
|
||||
public constructor(service: Service, paymentLinksId: string) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/paymentLinks`,
|
||||
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/paymentLinks/${paymentLinksId}`,
|
||||
);
|
||||
}
|
||||
|
||||
public set id(id: string) {
|
||||
PaymentLinksId._id = id;
|
||||
this.endpoint = `${this.endpoint}/${PaymentLinksId._id}`;
|
||||
}
|
||||
}
|
||||
|
||||
export default PaymentLinksId;
|
||||
|
||||
14
src/services/resource/management/managementResource.ts
Normal file
14
src/services/resource/management/managementResource.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class ManagementResource extends Resource {
|
||||
public constructor(service: Service, endpoint: string) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.managementEndpoint}/${Client.MANAGEMENT_API_VERSION}${endpoint}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ManagementResource;
|
||||
15
src/services/resource/management/me.ts
Normal file
15
src/services/resource/management/me.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
|
||||
class Me extends Resource {
|
||||
public constructor(service: Service, endpoint: string) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.managementEndpoint}/${Client.MANAGEMENT_API_VERSION}/me${endpoint}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Me;
|
||||
14
src/services/resource/payment/adjustAuthorisation.ts
Normal file
14
src/services/resource/payment/adjustAuthorisation.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class AdjustAuthorisation extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}/adjustAuthorisation`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default AdjustAuthorisation;
|
||||
14
src/services/resource/payment/authorise.ts
Normal file
14
src/services/resource/payment/authorise.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class Authorise extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}/authorise`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Authorise;
|
||||
14
src/services/resource/payment/authorise3d.ts
Normal file
14
src/services/resource/payment/authorise3d.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class Authorise3d extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}/authorise3d`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Authorise3d;
|
||||
14
src/services/resource/payment/authorise3ds2.ts
Normal file
14
src/services/resource/payment/authorise3ds2.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class Authorise3ds2 extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}/authorise3ds2`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Authorise3ds2;
|
||||
14
src/services/resource/payment/cancel.ts
Normal file
14
src/services/resource/payment/cancel.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class Cancel extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}/cancel`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Cancel;
|
||||
14
src/services/resource/payment/cancelOrRefund.ts
Normal file
14
src/services/resource/payment/cancelOrRefund.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class CancelOrRefund extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}/cancelOrRefund`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default CancelOrRefund;
|
||||
14
src/services/resource/payment/capture.ts
Normal file
14
src/services/resource/payment/capture.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class Capture extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}/capture`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Capture;
|
||||
14
src/services/resource/payment/donate.ts
Normal file
14
src/services/resource/payment/donate.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class Donate extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}/donate`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Donate;
|
||||
14
src/services/resource/payment/getAuthenticationResult.ts
Normal file
14
src/services/resource/payment/getAuthenticationResult.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class GetAuthenticationResult extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}/getAuthenticationResult`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default GetAuthenticationResult;
|
||||
14
src/services/resource/payment/refund.ts
Normal file
14
src/services/resource/payment/refund.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class Refund extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}/refund`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Refund;
|
||||
14
src/services/resource/payment/retrieve3ds2Result.ts
Normal file
14
src/services/resource/payment/retrieve3ds2Result.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class Retrieve3ds2Result extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}/retrieve3ds2Result`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Retrieve3ds2Result;
|
||||
14
src/services/resource/payment/technicalCancel.ts
Normal file
14
src/services/resource/payment/technicalCancel.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class TechnicalCancel extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}/technicalCancel`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default TechnicalCancel;
|
||||
14
src/services/resource/payment/voidPendingRefund.ts
Normal file
14
src/services/resource/payment/voidPendingRefund.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class VoidPendingRefund extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}/voidPendingRefund`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default VoidPendingRefund;
|
||||
@@ -30,7 +30,8 @@ type Endpoints =
|
||||
"/transferFunds"|
|
||||
"/refundFundsTransfer"|
|
||||
"/setupBeneficiary"|
|
||||
"/refundNotPaidOutTransfers";
|
||||
"/refundNotPaidOutTransfers" |
|
||||
"/debitAccountHolder";
|
||||
|
||||
|
||||
class PlatformsFund extends Resource {
|
||||
|
||||
@@ -1,29 +1,8 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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 Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
type Endpoints = "/getOnboardingUrl";
|
||||
type Endpoints = "/getOnboardingUrl" | "/getPciQuestionnaireUrl";
|
||||
|
||||
class PlatformsHostedOnboardingPage extends Resource {
|
||||
public constructor(service: Service, endpoint: Endpoints) {
|
||||
|
||||
14
src/services/resource/storedValue/changeStatus.ts
Normal file
14
src/services/resource/storedValue/changeStatus.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class ChangeStatus extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.storedValueEndpoint}/${Client.STOREDVALUE_API_VERSION}/changeStatus`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ChangeStatus;
|
||||
14
src/services/resource/storedValue/checkBalance.ts
Normal file
14
src/services/resource/storedValue/checkBalance.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class CheckBalance extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.storedValueEndpoint}/${Client.STOREDVALUE_API_VERSION}/checkBalance`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default CheckBalance;
|
||||
14
src/services/resource/storedValue/issue.ts
Normal file
14
src/services/resource/storedValue/issue.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class Issue extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.storedValueEndpoint}/${Client.STOREDVALUE_API_VERSION}/issue`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Issue;
|
||||
14
src/services/resource/storedValue/load.ts
Normal file
14
src/services/resource/storedValue/load.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class Load extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.storedValueEndpoint}/${Client.STOREDVALUE_API_VERSION}/load`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Load;
|
||||
14
src/services/resource/storedValue/mergeBalance.ts
Normal file
14
src/services/resource/storedValue/mergeBalance.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class MergeBalance extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.storedValueEndpoint}/${Client.STOREDVALUE_API_VERSION}/mergeBalance`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default MergeBalance;
|
||||
14
src/services/resource/storedValue/voidTransaction.ts
Normal file
14
src/services/resource/storedValue/voidTransaction.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class VoidTransaction extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.storedValueEndpoint}/${Client.STOREDVALUE_API_VERSION}/voidTransaction`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default VoidTransaction;
|
||||
14
src/services/resource/terminalManagement/assignTerminals.ts
Normal file
14
src/services/resource/terminalManagement/assignTerminals.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class AssignTerminals extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.terminalManagementEndpoint}/${Client.TERMINAL_MANAGEMENT_API_VERSION}/assignTerminals`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default AssignTerminals;
|
||||
14
src/services/resource/terminalManagement/findTerminal.ts
Normal file
14
src/services/resource/terminalManagement/findTerminal.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class FindTerminal extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.terminalManagementEndpoint}/${Client.TERMINAL_MANAGEMENT_API_VERSION}/findTerminal`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default FindTerminal;
|
||||
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class GetStoresUnderAccount extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.terminalManagementEndpoint}/${Client.TERMINAL_MANAGEMENT_API_VERSION}/getStoresUnderAccount`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default GetStoresUnderAccount;
|
||||
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class GetTerminalDetails extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.terminalManagementEndpoint}/${Client.TERMINAL_MANAGEMENT_API_VERSION}/getTerminalDetails`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default GetTerminalDetails;
|
||||
@@ -0,0 +1,14 @@
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class GetTerminalsUnderAccount extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.terminalManagementEndpoint}/${Client.TERMINAL_MANAGEMENT_API_VERSION}/getTerminalsUnderAccount`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default GetTerminalsUnderAccount;
|
||||
88
src/services/storedValue.ts
Normal file
88
src/services/storedValue.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import Client from "../client";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
import Service from "../service";
|
||||
import {
|
||||
StoredValueBalanceCheckRequest,
|
||||
StoredValueBalanceCheckResponse,
|
||||
StoredValueBalanceMergeRequest,
|
||||
StoredValueBalanceMergeResponse,
|
||||
StoredValueIssueRequest,
|
||||
StoredValueIssueResponse,
|
||||
StoredValueLoadRequest,
|
||||
StoredValueLoadResponse,
|
||||
StoredValueStatusChangeRequest,
|
||||
StoredValueStatusChangeResponse,
|
||||
StoredValueVoidRequest,
|
||||
StoredValueVoidResponse,
|
||||
} from "../typings/storedValue/models";
|
||||
import ChangeStatus from "./resource/storedValue/changeStatus";
|
||||
import Issue from "./resource/storedValue/issue";
|
||||
import Load from "./resource/storedValue/load";
|
||||
import CheckBalance from "./resource/storedValue/checkBalance";
|
||||
import MergeBalance from "./resource/storedValue/mergeBalance";
|
||||
import VoidTransaction from "./resource/storedValue/voidTransaction";
|
||||
|
||||
class StoredValue extends Service {
|
||||
|
||||
private readonly _issue: Issue;
|
||||
private readonly _changeStatus: ChangeStatus;
|
||||
private readonly _load: Load;
|
||||
private readonly _checkBalance: CheckBalance;
|
||||
private readonly _mergebalance: MergeBalance;
|
||||
private readonly _voidTransaction: VoidTransaction;
|
||||
|
||||
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
this._issue = new Issue(this);
|
||||
this._changeStatus = new ChangeStatus(this);
|
||||
this._load = new Load(this);
|
||||
this._checkBalance = new CheckBalance(this);
|
||||
this._mergebalance = new MergeBalance(this);
|
||||
this._voidTransaction = new VoidTransaction(this);
|
||||
}
|
||||
|
||||
public issue(request: StoredValueIssueRequest): Promise<StoredValueIssueResponse> {
|
||||
return getJsonResponse<StoredValueIssueRequest, StoredValueIssueResponse>(
|
||||
this._issue,
|
||||
request,
|
||||
);
|
||||
}
|
||||
|
||||
public changeStatus(request: StoredValueStatusChangeRequest): Promise<StoredValueStatusChangeResponse> {
|
||||
return getJsonResponse<StoredValueStatusChangeRequest, StoredValueStatusChangeResponse>(
|
||||
this._changeStatus,
|
||||
request,
|
||||
);
|
||||
}
|
||||
|
||||
public load(request: StoredValueLoadRequest): Promise<StoredValueLoadResponse> {
|
||||
return getJsonResponse<StoredValueLoadRequest, StoredValueLoadResponse>(
|
||||
this._load,
|
||||
request,
|
||||
);
|
||||
}
|
||||
|
||||
public checkBalance(request: StoredValueBalanceCheckRequest): Promise<StoredValueBalanceCheckResponse> {
|
||||
return getJsonResponse<StoredValueBalanceCheckRequest, StoredValueBalanceCheckResponse>(
|
||||
this._checkBalance,
|
||||
request,
|
||||
);
|
||||
}
|
||||
|
||||
public mergebalance(request: StoredValueBalanceMergeRequest): Promise<StoredValueBalanceMergeResponse> {
|
||||
return getJsonResponse<StoredValueBalanceMergeRequest, StoredValueBalanceMergeResponse>(
|
||||
this._mergebalance,
|
||||
request,
|
||||
);
|
||||
}
|
||||
|
||||
public voidTransaction(request: StoredValueVoidRequest): Promise<StoredValueVoidResponse> {
|
||||
return getJsonResponse<StoredValueVoidRequest, StoredValueVoidResponse>(
|
||||
this._voidTransaction,
|
||||
request,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default StoredValue;
|
||||
@@ -46,14 +46,6 @@ class TerminalCloudAPI extends ApiKeyAuthenticatedService {
|
||||
const reqWithAppInfo = {saleToPOIRequest};
|
||||
|
||||
mergeDeep(request, reqWithAppInfo);
|
||||
const formattedRequest = ObjectSerializer.serialize(request, "TerminalApiRequest");
|
||||
|
||||
if (formattedRequest.SaleToPOIRequest?.PaymentRequest?.SaleData?.SaleToAcquirerData) {
|
||||
const dataString = JSON.stringify(formattedRequest.SaleToPOIRequest.PaymentRequest.SaleData.SaleToAcquirerData);
|
||||
formattedRequest.SaleToPOIRequest.PaymentRequest.SaleData.SaleToAcquirerData = Buffer.from(dataString).toString("base64");
|
||||
}
|
||||
|
||||
return formattedRequest;
|
||||
}
|
||||
|
||||
return ObjectSerializer.serialize(request, "TerminalApiRequest");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user