diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 094fd1b..143c191 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,11 +5,4 @@ updates: schedule: interval: daily time: "04:00" - open-pull-requests-limit: 10 - reviewers: - - zaiddreakh - maassenbas - msilvagarcia - AlexandrosMor - peterojo - wboereboom + open-pull-requests-limit: 10 \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index ac78636..871cc82 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -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 diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index f205237..225f569 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -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: | diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 73e5532..fa7c536 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,6 +1,6 @@ name: Node.js CI -on: [push, pull_request] +on: [pull_request] jobs: build: diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 85a7bfd..bfa73fd 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -1,6 +1,6 @@ name: "Sonarcloud Analysis" -on: ["push", "pull_request"] +on: ["pull_request"] jobs: sonarcloud-analysis: diff --git a/src/__mocks__/management/requests.ts b/src/__mocks__/management/requests.ts new file mode 100644 index 0000000..cb7ce9b --- /dev/null +++ b/src/__mocks__/management/requests.ts @@ -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"] +}; diff --git a/src/__mocks__/management/responses.ts b/src/__mocks__/management/responses.ts new file mode 100644 index 0000000..1943783 --- /dev/null +++ b/src/__mocks__/management/responses.ts @@ -0,0 +1,1506 @@ +export const listMerchantResponse = { + "_links": { + "first": { + "href": "https://management-test.adyen.com/v1/merchants?pageNumber=1&pageSize=10" + }, + "last": { + "href": "https://management-test.adyen.com/v1/merchants?pageNumber=3&pageSize=10" + }, + "next": { + "href": "https://management-test.adyen.com/v1/merchants?pageNumber=2&pageSize=10" + }, + "self": { + "href": "https://management-test.adyen.com/v1/merchants?pageNumber=1&pageSize=10" + } + }, + "itemsTotal": 23, + "pagesTotal": 3, + "data": [ + { + "id": "YOUR_MERCHANT_ACCOUNT_1", + "name": "YOUR_MERCHANT_NAME_1", + "captureDelay": "immediate", + "defaultShopperInteraction": "Ecommerce", + "status": "Active", + "shopWebAddress": "YOUR_SHOP_URL_1", + "merchantCity": "Amsterdam", + "primarySettlementCurrency": "EUR", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_1" + }, + "apiCredentials": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_1/apiCredentials" + }, + "users": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_1/users" + }, + "webhooks": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_1/webhooks" + } + } + }, + { + "id": "YOUR_MERCHANT_ACCOUNT_2", + "name": "YOUR_MERCHANT_NAME_2", + "captureDelay": "immediate", + "defaultShopperInteraction": "POS", + "status": "Active", + "shopWebAddress": "YOUR_SHOP_URL_2", + "merchantCity": "", + "primarySettlementCurrency": "EUR", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_2" + }, + "apiCredentials": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_2/apiCredentials" + }, + "users": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_2/users" + }, + "webhooks": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_2/webhooks" + } + } + }, + { + "id": "YOUR_MERCHANT_ACCOUNT_3", + "status": "YOUR_MERCHANT_NAME_3", + "merchantCity": "Amsterdam", + "primarySettlementCurrency": "EUR", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_3" + }, + "apiCredentials": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_3/apiCredentials" + }, + "users": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_3/users" + }, + "webhooks": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_3/webhooks" + } + } + }, + { + "id": "YOUR_MERCHANT_ACCOUNT_4", + "name": "YOUR_MERCHANT_NAME_4", + "captureDelay": "immediate", + "defaultShopperInteraction": "Ecommerce", + "status": "Active", + "shopWebAddress": "YOUR_SHOP_URL_4", + "merchantCity": "Sao Paulo", + "primarySettlementCurrency": "BRL", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_4" + }, + "apiCredentials": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_4/apiCredentials" + }, + "users": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_4/users" + }, + "webhooks": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_4/webhooks" + } + } + }, + { + "id": "YOUR_MERCHANT_ACCOUNT_5", + "name": "YOUR_MERCHANT_NAME_5", + "captureDelay": "3", + "defaultShopperInteraction": "Ecommerce", + "status": "Active", + "shopWebAddress": "YOUR_SHOP_URL_5", + "primarySettlementCurrency": "EUR", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_5" + }, + "apiCredentials": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_5/apiCredentials" + }, + "users": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_5/users" + }, + "webhooks": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_5/webhooks" + } + } + }, + { + "id": "YOUR_MERCHANT_ACCOUNT_6", + "name": "YOUR_MERCHANT_NAME_6", + "captureDelay": "immediate", + "defaultShopperInteraction": "Ecommerce", + "status": "Active", + "shopWebAddress": "YOUR_SHOP_URL_6", + "merchantCity": "Zagreb", + "primarySettlementCurrency": "BRL", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_NAME_6" + }, + "apiCredentials": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_NAME_6/apiCredentials" + }, + "users": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_NAME_6/users" + }, + "webhooks": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_NAME_6/webhooks" + } + } + }, + { + "id": "YOUR_MERCHANT_ACCOUNT_7", + "name": "YOUR_MERCHANT_NAME_7", + "captureDelay": "manual", + "defaultShopperInteraction": "Moto", + "status": "Active", + "shopWebAddress": "YOUR_SHOP_URL_7", + "merchantCity": "Amsterdam", + "primarySettlementCurrency": "EUR", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_7" + }, + "apiCredentials": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_7/apiCredentials" + }, + "users": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_7/users" + }, + "webhooks": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_7/webhooks" + } + } + }, + { + "id": "YOUR_MERCHANT_ACCOUNT_8", + "name": "YOUR_MERCHANT_NAME_8", + "captureDelay": "immediate", + "defaultShopperInteraction": "Ecommerce", + "status": "Active", + "shopWebAddress": "YOUR_SHOP_URL_8", + "merchantCity": "Amsterdam", + "primarySettlementCurrency": "EUR", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_8" + }, + "apiCredentials": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_8/apiCredentials" + }, + "users": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_8/users" + }, + "webhooks": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_8/webhooks" + } + } + }, + { + "id": "YOUR_MERCHANT_ACCOUNT_9", + "name": "YOUR_MERCHANT_NAME_9", + "captureDelay": "3", + "defaultShopperInteraction": "Ecommerce", + "status": "Active", + "shopWebAddress": "YOUR_SHOP_URL_9", + "merchantCity": "", + "primarySettlementCurrency": "EUR", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_9" + }, + "apiCredentials": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_9/apiCredentials" + }, + "users": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_9/users" + }, + "webhooks": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_9/webhooks" + } + } + }, + { + "id": "YOUR_MERCHANT_ACCOUNT_10", + "name": "YOUR_MERCHANT_NAME_10", + "captureDelay": "manual", + "defaultShopperInteraction": "Ecommerce", + "status": "Active", + "shopWebAddress": "YOUR_SHOP_URL_10", + "merchantCity": "Paris", + "primarySettlementCurrency": "EUR", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_10" + }, + "apiCredentials": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_10/apiCredentials" + }, + "users": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_10/users" + }, + "webhooks": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT_10/webhooks" + } + } + } + ] +}; + +export const createMerchantResponse = { + "companyId": "YOUR_COMPANY_ACCOUNT", + "legalEntityId": "YOUR_LEGAL_ENTITY_ID", + "businessLineId": "YOUR_BUSINESS_LINE_ID", + "description": "YOUR_DESCRIPTION", + "reference": "YOUR_OWN_REFERENCE", + "id": "YOUR_OWN_REFERENCE" +}; + +export const merchant = { + "id": "YOUR_MERCHANT_ACCOUNT", + "name": "YOUR_MERCHANT_NAME", + "captureDelay": "manual", + "defaultShopperInteraction": "Ecommerce", + "status": "Active", + "shopWebAddress": "YOUR_SHOP_URL", + "merchantCity": "Amsterdam", + "primarySettlementCurrency": "EUR", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT" + }, + "apiCredentials": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials" + }, + "users": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/users" + }, + "webhooks": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/webhooks" + } + } +}; + +export const requestActivationResponse = { + "companyId": "string", + "merchantId": "string" +}; + +export const allowedOriginsResponse = { + "data": [{ + "_links": { "self": { "href": "string" } }, + "domain": "string", + "id": "string" + }] +}; + +export const allowedOrigin = { + "_links": { "self": { "href": "string" } }, + "domain": "string", + "id": "string" +}; + +export const listMerchantApiCredentialsResponse = { + "_links": { + "first": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials?pageNumber=1&pageSize=10" + }, + "last": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials?pageNumber=2&pageSize=10" + }, + "next": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials?pageNumber=2&pageSize=10" + }, + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials?pageNumber=1&pageSize=10" + } + }, + "itemsTotal": 11, + "pagesTotal": 2, + "data": [ + { + "id": "YOUR_API_CREDENTIAL_1", + "username": "YOUR_USERNAME_1", + "allowedIpAddresses": [], + "roles": [ + "Merchant Report Download role" + ], + "active": true, + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_CREDENTIAL_1" + }, + "allowedOrigins": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_CREDENTIAL_1/allowedOrigins" + }, + "generateApiKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_CREDENTIAL_1/generateApiKey" + }, + "generateClientKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_CREDENTIAL_1/generateClientKey" + }, + "merchant": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT" + } + } + }, + { + "id": "YOUR_API_CREDENTIAL_2", + "username": "YOUR_USERNAME_2", + "allowedIpAddresses": [], + "roles": [ + "Merchant Rss feed role" + ], + "active": true, + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_2" + }, + "allowedOrigins": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_2/allowedOrigins" + }, + "generateApiKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_2/generateApiKey" + }, + "generateClientKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_2/generateClientKey" + }, + "merchant": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT" + } + } + }, + { + "id": "YOUR_API_CREDENTIAL_3", + "username": "YOUR_USERNAME_3", + "clientKey": "YOUR_CLIENT_KEY_3", + "allowedIpAddresses": [], + "roles": [ + "Merchant iDeal-API Webservice role", + "Management API - Accounts read", + "Management API - API credentials read and write", + "Management API \u2014 Payment methods read", + "Merchant PAL Donation role", + "Merchant PAL Charity role", + "Checkout encrypted cardholder data", + "Checkout webservice role", + "Store payout detail and submit payout - withdrawal", + "Management API - Accounts read and write", + "Management API - Webhooks read", + "Merchant Payout role", + "API tokenise payment details", + "General API Payments role", + "API Supply MPI data with Payments", + "API Authorise Referred Payments", + "API PCI Payments role", + "CSC Tokenization Webservice role", + "Management API - Stores read", + "API Payment RefundWithData", + "API Clientside Encryption Payments role", + "API to retrieve authentication data", + "Management API - Stores read and write", + "Management API - Webhooks read and write", + "Mastercard inControl service", + "Merchant Recurring role", + "Management API - Payout Account Settings Read", + "API surcharge cost estimation and regulatory information", + "Store payout detail", + "Merchant PAL Webservice role" + ], + "active": true, + "allowedOrigins": [ + { + "id": "YOUR_ALLOWED_ORIGIN_1", + "domain": "YOUR_DOMAIN_1", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_3/allowedOrigins/YOUR_ALLOWED_ORIGIN_1" + } + } + }, + { + "id": "YOUR_ALLOWED_ORIGIN_2", + "domain": "YOUR_DOMAIN_2", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_3/allowedOrigins/YOUR_ALLOWED_ORIGIN_2" + } + } + } + ], + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_3" + }, + "allowedOrigins": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_3/allowedOrigins" + }, + "generateApiKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_3/generateApiKey" + }, + "generateClientKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_3/generateClientKey" + }, + "merchant": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT" + } + } + }, + { + "id": "YOUR_API_CREDENTIAL_4", + "username": "YOUR_USERNAME_4", + "clientKey": "YOUR_CLIENT_KEY_4", + "allowedIpAddresses": [], + "roles": [ + "API Clientside Encryption Payments role", + "API tokenise payment details", + "General API Payments role", + "Checkout encrypted cardholder data", + "Merchant Recurring role", + "API PCI Payments role", + "CSC Tokenization Webservice role", + "Checkout webservice role", + "ThreeDSecure WebService Role", + "Merchant PAL Webservice role" + ], + "active": true, + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_4" + }, + "allowedOrigins": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_4/allowedOrigins" + }, + "generateApiKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_4/generateApiKey" + }, + "generateClientKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_4/generateClientKey" + }, + "merchant": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT" + } + } + }, + { + "id": "YOUR_API_CREDENTIAL_5", + "username": "YOUR_USERNAME_5", + "clientKey": "YOUR_CLIENT_KEY_5", + "allowedIpAddresses": [], + "roles": [ + "Merchant iDeal-API Webservice role", + "General API Payments role", + "Checkout encrypted cardholder data", + "Merchant Recurring role", + "Checkout webservice role", + "Merchant PAL Webservice role" + ], + "active": true, + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_5" + }, + "allowedOrigins": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_5/allowedOrigins" + }, + "generateApiKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_5/generateApiKey" + }, + "generateClientKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_5/generateClientKey" + }, + "merchant": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT" + } + } + }, + { + "id": "YOUR_API_CREDENTIAL_6", + "username": "YOUR_USERNAME_6", + "allowedIpAddresses": [], + "roles": [ + "Checkout encrypted cardholder data", + "Merchant Recurring role", + "API PCI Payments role", + "Checkout webservice role", + "Merchant PAL Webservice role" + ], + "active": true, + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_6" + }, + "allowedOrigins": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_6/allowedOrigins" + }, + "generateApiKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_6/generateApiKey" + }, + "generateClientKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_6/generateClientKey" + }, + "merchant": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT" + } + } + }, + { + "id": "YOUR_API_CREDENTIAL_7", + "username": "YOUR_USERNAME_7", + "allowedIpAddresses": [], + "roles": [ + "Checkout encrypted cardholder data", + "Checkout webservice role", + "Merchant PAL Webservice role" + ], + "active": true, + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_7" + }, + "allowedOrigins": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_7/allowedOrigins" + }, + "generateApiKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_7/generateApiKey" + }, + "generateClientKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_7/generateClientKey" + }, + "merchant": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT" + } + } + }, + { + "id": "YOUR_API_CREDENTIAL_8", + "username": "YOUR_USERNAME_8", + "clientKey": "YOUR_CLIENT_KEY_8", + "allowedIpAddresses": [], + "roles": [ + "Checkout encrypted cardholder data", + "Merchant Recurring role", + "Checkout webservice role", + "Merchant PAL Webservice role" + ], + "active": true, + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_8" + }, + "allowedOrigins": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_8/allowedOrigins" + }, + "generateApiKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_8/generateApiKey" + }, + "generateClientKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_8/generateClientKey" + }, + "merchant": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT" + } + } + }, + { + "id": "YOUR_API_CREDENTIAL_9", + "username": "YOUR_USERNAME_9", + "clientKey": "YOUR_CLIENT_KEY_9", + "allowedIpAddresses": [], + "roles": [ + "Checkout encrypted cardholder data", + "Merchant Recurring role", + "API PCI Payments role", + "Checkout webservice role", + "Merchant PAL Webservice role" + ], + "active": true, + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_9" + }, + "allowedOrigins": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_9/allowedOrigins" + }, + "generateApiKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_9/generateApiKey" + }, + "generateClientKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_9/generateClientKey" + }, + "merchant": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT" + } + } + }, + { + "id": "YOUR_API_CREDENTIAL_10", + "username": "YOUR_USERNAME_10", + "clientKey": "YOUR_CLIENT_KEY_10", + "allowedIpAddresses": [], + "roles": [ + "Checkout encrypted cardholder data", + "Merchant Recurring role", + "Checkout webservice role", + "Merchant PAL Webservice role" + ], + "active": true, + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_10" + }, + "allowedOrigins": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_10/allowedOrigins" + }, + "generateApiKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_10/generateApiKey" + }, + "generateClientKey": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL_10/generateClientKey" + }, + "merchant": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT" + } + } + } + ] +}; + +export const createApiCredentialResponse = { + "id": "YOUR_API_CREDENTIAL", + "username": "YOUR_USERNAME", + "clientKey": "YOUR_CLIENT_KEY", + "allowedIpAddresses": [], + "roles": [ + "Checkout webservice role" + ], + "active": true, + "allowedOrigins": [ + { + "id": "YOUR_ALLOWED_ORIGIN", + "domain": "https://www.mystore.com", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/companies/YOUR_COMPANY_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL/allowedOrigins/YOUR_ALLOWED_ORIGIN" + } + } + } + ], + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/companies/YOUR_COMPANY_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL" + }, + "allowedOrigins": { + "href": "https://management-test.adyen.com/v1/companies/YOUR_COMPANY_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL/allowedOrigins" + }, + "generateApiKey": { + "href": "https://management-test.adyen.com/v1/companies/YOUR_COMPANY_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL/generateApiKey" + }, + "generateClientKey": { + "href": "https://management-test.adyen.com/v1/companies/YOUR_COMPANY_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL/generateClientKey" + }, + "merchant": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT" + } + }, + "apiKey": "YOUR_API_KEY", + "password": "YOUR_PASSWORD" +}; + +export const apiCredential = { + "_links": { + "allowedOrigins": { "href": "string" }, + "company": { "href": "string" }, + "generateApiKey": { "href": "string" }, + "generateClientKey": { "href": "string" }, + "merchant": { "href": "string" }, + "self": { "href": "string" } + }, + "active": false, + "allowedIpAddresses": ["string"], + "allowedOrigins": [{ + "_links": { "self": { "href": "string" } }, + "domain": "string", + "id": "string" + }], + "clientKey": "string", + "description": "string", + "id": "string", + "roles": ["string"], + "username": "string" +}; + +export const generateApiKeyResponse = { "apiKey": "string" }; + +export const generateClientKeyResponse = { "clientKey": "string" }; + +export const paymentMethodResponse = { + "_links": { + "first": { "href": "string" }, + "last": { "href": "string" }, + "next": { "href": "string" }, + "prev": { "href": "string" }, + "self": { "href": "string" } + }, + "data": [{ + "applePay": { "domains": ["string"] }, + "bcmc": { "enableBcmcMobile": false }, + "businessLineId": "string", + "cartesBancaires": { "siret": "string" }, + "countries": ["string"], + "currencies": ["string"], + "enabled": false, + "giroPay": { "supportEmail": "string" }, + "id": "string", + "klarna": { + "autoCapture": false, + "disputeEmail": "string", + "region": "NA", + "supportEmail": "string" + }, + "paypal": { + "directCapture": false, + "directSettlement": false, + "payerId": "string", + "subject": "string" + }, + "sofort": { + "currencyCode": "string", + "logo": "string" + }, + "storeId": "string", + "swish": { "swishNumber": "string" }, + "type": "string" + }], + "itemsTotal": 0, + "pagesTotal": 0 +}; + +export const paymentMethod = { + "applePay": { "domains": ["string"] }, + "bcmc": { "enableBcmcMobile": false }, + "businessLineId": "string", + "cartesBancaires": { "siret": "string" }, + "countries": ["string"], + "currencies": ["string"], + "enabled": false, + "giroPay": { "supportEmail": "string" }, + "id": "string", + "klarna": { + "autoCapture": false, + "disputeEmail": "string", + "region": "NA", + "supportEmail": "string" + }, + "paypal": { + "directCapture": false, + "directSettlement": false, + "payerId": "string", + "subject": "string" + }, + "sofort": { + "currencyCode": "string", + "logo": "string" + }, + "storeId": "string", + "swish": { "swishNumber": "string" }, + "type": "string" +}; + +export const payoutSettingsResponse = { + "data": [{ + "allowed": false, + "enabled": false, + "enabledFromDate": "string", + "id": "string", + "priority": "first", + "transferInstrumentId": "string", + "verificationStatus": "invalid" + }] +}; + +export const payoutSettings = { + "allowed": false, + "enabled": false, + "enabledFromDate": "string", + "id": "string", + "priority": "first", + "transferInstrumentId": "string", + "verificationStatus": "invalid" +}; + +export const billingEntitiesResponse = { + "data": [ + { + "id": "MerchantAccount.YOUR_MERCHANT_ACCOUNT", + "name": "YOUR_MERCHANT_ACCOUNT", + "taxId": "ES1234567890", + "email": "Pablo.Mengano@company.com", + "address": { + "streetAddress": "Paseo de la Castellana 43, 7", + "postalCode": "28046", + "city": "Madrid", + "country": "ES" + } + } + ] +}; + +export const shippingLocationsResponse = { + "data": [ + { + "id": "S2-6A6C2E3432747D4F2F2C3455485E3836457D", + "name": "YOUR_COMPANY Spain", + "contact": { + "firstName": "Pablo", + "lastName": "Mengano", + "phoneNumber": "+34911234567", + "email": "Pablo.Mengano@company.com" + }, + "address": { + "streetAddress": "Paseo de la Castellana 43", + "streetAddress2": "7 piso", + "postalCode": "28046", + "city": "Madrid", + "country": "ES" + } + } + ] +}; + +export const shippingLocation = { + "id": "S2-73536B20665526704F30792642212044452F714622375D477270", + "name": "YOUR_MERCHANT_ACCOUNT Barcelona depot", + "contact": { + "firstName": "Rita", + "lastName": "Perengano", + "phoneNumber": "+34931234567", + "email": "Rita.Perengano@company.com" + }, + "address": { + "companyName": "YOUR_COMPANY", + "streetAddress": "El quinto pino 42", + "postalCode": "08012", + "city": "Barcelona", + "stateOrProvince": "" + } +}; + +export const terminalModelsResponse = { + "data": [ + { + "id": "Verifone.e315", + "name": "Verifone e315" + }, + { + "id": "Verifone.e315M", + "name": "Verifone e315M" + }, + { + "id": "Verifone.E355", + "name": "Verifone E355" + }, + { + "id": "Verifone.M400", + "name": "Verifone M400" + }, + { + "id": "Verifone.MX915", + "name": "Verifone MX915" + }, + { + "id": "Verifone.MX925", + "name": "Verifone MX925" + }, + { + "id": "Verifone.P400", + "name": "Verifone P400" + }, + { + "id": "Verifone.P400Plus", + "name": "Verifone P400Plus" + }, + { + "id": "Verifone.P400Eth", + "name": "Verifone P400Eth" + }, + { + "id": "Verifone.V240m", + "name": "Verifone V240m" + }, + { + "id": "Verifone.V240mPlus", + "name": "Verifone V240mPlus" + }, + { + "id": "Verifone.UX300", + "name": "Verifone UX300" + }, + { + "id": "Verifone.V200cPlus", + "name": "Verifone V200cPlus" + }, + { + "id": "Verifone.V400cPlus", + "name": "Verifone V400cPlus" + }, + { + "id": "Verifone.V400m", + "name": "Verifone V400m" + }, + { + "id": "Verifone.V210mPlus", + "name": "Verifone V210mPlus" + }, + { + "id": "Verifone.VX520", + "name": "Verifone VX520" + }, + { + "id": "Verifone.VX6753G", + "name": "Verifone VX6753G" + }, + { + "id": "Verifone.VX675WIFIBT", + "name": "Verifone VX675WIFIBT" + }, + { + "id": "Verifone.VX680", + "name": "Verifone VX680" + }, + { + "id": "Verifone.VX6803G", + "name": "Verifone VX6803G" + }, + { + "id": "Verifone.VX690", + "name": "Verifone VX690" + }, + { + "id": "Verifone.VX700", + "name": "Verifone VX700" + }, + { + "id": "Verifone.VX810", + "name": "Verifone VX810" + }, + { + "id": "Verifone.VX820", + "name": "Verifone VX820" + }, + { + "id": "Verifone.VX825", + "name": "Verifone VX825" + }, + { + "id": "Verifone.e285", + "name": "Verifone e285" + }, + { + "id": "Verifone.E285", + "name": "Verifone E285" + }, + { + "id": "Verifone.e285p", + "name": "Verifone e285p" + }, + { + "id": "Verifone.e280", + "name": "Verifone e280" + }, + { + "id": "Verifone.UX410", + "name": "Verifone UX410" + }, + { + "id": "Castles.S1E", + "name": "Castles S1E" + }, + { + "id": "Castles.S1EL", + "name": "Castles S1EL" + }, + { + "id": "Castles.S1F", + "name": "Castles S1F" + }, + { + "id": "Castles.S1F2", + "name": "Castles S1F2" + }, + { + "id": "Castles.S1F2L", + "name": "Castles S1F2L" + }, + { + "id": "Castles.S1E2", + "name": "Castles S1E2" + }, + { + "id": "Castles.S1E2L", + "name": "Castles S1E2L" + } + ] +}; + +export const terminalOrdersResponse = { + "data": [ + { + "id": "4154567890100682", + "customerOrderReference": "YOUR_REFERENCE_M2", + "status": "Placed", + "shippingLocation": { + "id": "S2-6A6C2E3432747D4F2F2C3455485E3836457D", + "name": "YOUR_COMPANY Spain", + "contact": { + "firstName": "Pablo", + "lastName": "Mengano", + "phoneNumber": "+34911234567", + "email": "Pablo.Mengano@company.com" + }, + "address": { + "streetAddress": "Paseo de la Castellana 43", + "streetAddress2": "7 piso", + "postalCode": "28046", + "city": "Madrid", + "country": "ES" + } + }, + "billingEntity": { + "id": "MerchantAccount.YOUR_MERCHANT_ACCOUNT", + "name": "YOUR_MERCHANT_ACCOUNT", + "taxId": "ES1234567890", + "email": "Pablo.Mengano@company.com", + "address": { + "streetAddress": "Paseo de la Castellana 43, 7", + "postalCode": "28046", + "city": "Madrid", + "country": "ES" + } + }, + "orderDate": "2022-01-21T16:12:33Z", + "items": [ + { + "id": "PART-287001-EU", + "name": "Bluetooth Charging Base - V400m", + "quantity": 2 + }, + { + "id": "PART-620222-EU", + "name": "Receipt Roll", + "quantity": 20 + } + ] + }, + { + "id": "8315943674501996", + "customerOrderReference": "YOUR_REFERENCE_M1", + "status": "Cancelled", + "shippingLocation": { + "id": "S2-6A6C2E3432747D4F2F2C3455485E3836457D", + "name": "YOUR_COMPANY Spain", + "contact": { + "firstName": "Pablo", + "lastName": "Mengano", + "phoneNumber": "+34911234567", + "email": "Pablo.Mengano@company.com" + }, + "address": { + "streetAddress": "Paseo de la Castellana 43", + "streetAddress2": "7 piso", + "postalCode": "28046", + "city": "Madrid", + "country": "ES" + } + }, + "billingEntity": { + "id": "MerchantAccount.YOUR_MERCHANT_ACCOUNT", + "name": "YOUR_MERCHANT_ACCOUNT", + "taxId": "ES1234567890", + "email": "Pablo.Mengano@company.com", + "address": { + "streetAddress": "Paseo de la Castellana 43, 7", + "postalCode": "28046", + "city": "Madrid", + "country": "ES" + } + }, + "orderDate": "2022-01-04T09:41:07.000Z", + "items": [ + { + "id": "TBOX-V400m-774-EU", + "name": "V400m Package", + "quantity": 1 + } + ] + } + ] +}; + +export const terminalOrder = { + "id": "4154567890100682", + "customerOrderReference": "YOUR_REFERENCE", + "status": "Cancelled", + "shippingLocation": { + "id": "S2-6A6C2E3432747D4F2F2C3455485E3836457D", + "name": "YOUR_COMPANY Spain", + "contact": { + "firstName": "Pablo", + "lastName": "Mengano", + "phoneNumber": "+34911234567", + "email": "Pablo.Mengano@company.com" + }, + "address": { + "streetAddress": "Paseo de la Castellana 43", + "streetAddress2": "7 piso", + "postalCode": "28046", + "city": "Madrid", + "country": "ES" + } + }, + "billingEntity": { + "id": "MerchantAccount.YOUR_MERCHANT_ACCOUNT", + "name": "YOUR_MERCHANT_ACCOUNT", + "taxId": "ES1234567890", + "email": "Pablo.Mengano@company.com", + "address": { + "streetAddress": "Paseo de la Castellana 43, 7", + "postalCode": "28046", + "city": "Madrid", + "country": "ES" + } + }, + "orderDate": "2022-01-21T16:12:33Z", + "items": [ + { + "id": "PART-287001-EU", + "name": "Bluetooth Charging Base - V400m", + "quantity": 2 + }, + { + "id": "PART-620222-EU", + "name": "Receipt Roll", + "quantity": 20 + } + ] +}; + +export const terminalProductsResponse = { + "data": [ + { + "id": "PART-620222-EU", + "name": "Receipt Roll", + "price": { + "currency": "EUR", + "value": 0.0 + } + }, + { + "id": "PART-175746-EU", + "name": "Adyen Test Card", + "price": { + "currency": "EUR", + "value": 0.0 + } + }, + { + "id": "PART-327486-EU", + "name": "Battery - V400m", + "price": { + "currency": "EUR", + "value": 0.0 + } + }, + { + "id": "PART-287001-EU", + "name": "Bluetooth Charging Base - V400m", + "price": { + "currency": "EUR", + "value": 0.0 + } + }, + { + "id": "PART-745984-EU", + "name": "Power Supply EU - V400m", + "price": { + "currency": "EUR", + "value": 0.0 + } + }, + { + "id": "TBOX-V400m-684-EU", + "name": "V400m Package", + "description": "Includes an EU Power Supply, SIM Card and battery", + "price": { + "currency": "EUR", + "value": 0.0 + }, + "itemsIncluded": [ + "Receipt Roll", + "Terminal Device V400m EU/GB" + ] + } + ] +}; + +export const logo = { + "data": "LOGO_INHERITED_FROM_HIGHER_LEVEL_BASE-64_ENCODED_STRING" +}; + +export const terminalSettings = { + "cardholderReceipt": { + "headerForAuthorizedReceipt": "header1,header2,filler" + }, + "gratuities": [ + { + "currency": "EUR", + "usePredefinedTipEntries": true, + "predefinedTipEntries": [ + "100", + "1%", + "5%" + ], + "allowCustomAmount": true + } + ], + "nexo": { + "nexoEventUrls": [ + "https://your-event-notifications-endpoint.com" + ] + }, + "opi": { + "enablePayAtTable": true, + "payAtTableStoreNumber": "1", + "payAtTableURL": "https:/your-pay-at-table-endpoint.com" + }, + "receiptOptions": {}, + "receiptPrinting": { + "shopperApproved": true, + "shopperRefused": true, + "shopperCancelled": true, + "shopperRefundApproved": true, + "shopperRefundRefused": true, + "shopperVoid": true + }, + "signature": { + "askSignatureOnScreen": true, + "skipSignature": false, + "deviceName": "Amsterdam-236203386" + }, + "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 + } + }, + "timeouts": { + "fromActiveToSleep": 30 + }, + "hardware": { + "displayMaximumBackLight": 75 + } +}; + +export const listMerchantUsersResponse = { + "_links": { + "first": { "href": "string" }, + "last": { "href": "string" }, + "next": { "href": "string" }, + "prev": { "href": "string" }, + "self": { "href": "string" } + }, + "data": [{ + "_links": { "self": { "href": "string" } }, + "accountGroups": ["string"], + "active": false, + "email": "string", + "id": "string", + "name": { + "firstName": "string", + "lastName": "string" + }, + "roles": ["string"], + "timeZoneCode": "string", + "username": "string" + }], + "itemsTotal": 0, + "pagesTotal": 0 +}; + +export const createUserResponse = { + "id": "S2-3B3C3C3B22", + "name": { + "firstName": "John", + "gender": "UNKNOWN", + "lastName": "Smith" + }, + "email": "john.smith@example.com", + "timeZoneCode": "Europe/Amsterdam", + "username": "johnsmith", + "roles": [ + "Merchant standard role" + ], + "active": "true", + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/users/S2-3B3C3C3B22" + } + }, + "associatedMerchantAccounts": [ + "YOUR_MERCHANT_ACCOUNT" + ] +}; + +export const user = { + "_links": { "self": { "href": "string" } }, + "accountGroups": ["string"], + "active": false, + "email": "string", + "id": "string", + "name": { + "firstName": "string", + "lastName": "string" + }, + "roles": ["string"], + "timeZoneCode": "string", + "username": "string" +}; + +export const listWebhooksResponse = { + "_links": { + "first": { "href": "string" }, + "last": { "href": "string" }, + "next": { "href": "string" }, + "prev": { "href": "string" }, + "self": { "href": "string" } + }, + "accountReference": "string", + "data": [{ + "_links": { + "company": { "href": "string" }, + "generateHmac": { "href": "string" }, + "merchant": { "href": "string" }, + "self": { "href": "string" }, + "testWebhook": { "href": "string" } + }, + "acceptsExpiredCertificate": false, + "acceptsSelfSignedCertificate": false, + "acceptsUntrustedRootCertificate": false, + "accountReference": "string", + "active": false, + "additionalSettings": { + "excludeEventCodes": ["string"], + "includeEventCodes": ["string"], + "properties": { "sample": false } + }, + "certificateAlias": "string", + "communicationFormat": "HTTP", + "description": "string", + "filterMerchantAccountType": "EXCLUDE_LIST", + "filterMerchantAccounts": ["string"], + "hasError": false, + "hasPassword": false, + "hmacKeyCheckValue": "string", + "id": "string", + "networkType": "LOCAL", + "populateSoapActionHeader": false, + "sslVersion": "HTTP", + "type": "string", + "url": "string", + "username": "string" + }], + "itemsTotal": 0, + "pagesTotal": 0 +}; + +export const webhook = { + "_links": { + "company": { "href": "string" }, + "generateHmac": { "href": "string" }, + "merchant": { "href": "string" }, + "self": { "href": "string" }, + "testWebhook": { "href": "string" } + }, + "acceptsExpiredCertificate": false, + "acceptsSelfSignedCertificate": false, + "acceptsUntrustedRootCertificate": false, + "accountReference": "string", + "active": false, + "additionalSettings": { + "excludeEventCodes": ["string"], + "includeEventCodes": ["string"], + "properties": { "sample": false } + }, + "certificateAlias": "string", + "communicationFormat": "HTTP", + "description": "string", + "filterMerchantAccountType": "EXCLUDE_LIST", + "filterMerchantAccounts": ["string"], + "hasError": false, + "hasPassword": false, + "hmacKeyCheckValue": "string", + "id": "string", + "networkType": "LOCAL", + "populateSoapActionHeader": false, + "sslVersion": "HTTP", + "type": "string", + "url": "string", + "username": "string" +}; + +export const generateHmacKeyResponse = { "hmacKey": "string" }; + +export const testWebhookResponse = { + "data": [{ + "merchantId": "string", + "output": "string", + "requestSent": "string", + "responseCode": "string", + "responseTime": "string", + "status": "string" + }] +}; diff --git a/src/__tests__/management.spec.ts b/src/__tests__/management.spec.ts index 4701383..0f1533d 100644 --- a/src/__tests__/management.spec.ts +++ b/src/__tests__/management.spec.ts @@ -1,13 +1,25 @@ import nock from "nock"; import Client from "../client"; -import {createClient} from "../__mocks__/base"; +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(); @@ -55,57 +67,57 @@ describe("Management", (): void => { expect(meResponse.id).toEqual("S2-6262224667"); }); - test("Should add an allowed origin to the list of allowed origins",async (): Promise => { + test("Should add an allowed origin to the list of allowed origins", async (): Promise => { 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 => { - 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" - } + .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 : AllowedOriginsResponse = await management.Me.retrieveAllowedOrigins(); + 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 => { + 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 () => { + 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" + .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"); @@ -117,4 +129,539 @@ describe("Management", (): void => { expect(scope.isDone()).toBe(true); expect(Object.entries(allowedOriginResponse).length).toBe(0); }); + + describe("MerchantAccount", (): void => { + it("should support GET /merchants", async (): Promise => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + scope.delete(`/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`) + .reply(200); + + await management.MerchantPayoutSettings.delete(merchantId, payoutSettingsId); + }); + + it("should support GET /merchants/{merchantId}/payoutSettings/{payoutSettingsId}", async (): Promise => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + 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 => { + scope.delete(`/merchants/${merchantId}/webhooks/${webhookId}`) + .reply(204); + + await management.MerchantWebhooks.delete(merchantId, webhookId); + }); + + it("should support GET /merchants/{merchantId}/webhooks/{webhookId}", async (): Promise => { + 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 => { + 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 => { + 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 => { + scope.post(`/merchants/${merchantId}/webhooks/${webhookId}/test`, /2022-07-15T00:00:00.000Z/) + .reply(200, responses.testWebhookResponse); + + let 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(); + }); + }); }); diff --git a/src/services/management.ts b/src/services/management.ts index 796b1c0..5a46e07 100644 --- a/src/services/management.ts +++ b/src/services/management.ts @@ -2,6 +2,17 @@ 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) { @@ -11,7 +22,51 @@ class Management extends Service { 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; diff --git a/src/services/management/merchantAccount.ts b/src/services/management/merchantAccount.ts new file mode 100644 index 0000000..cf75a6f --- /dev/null +++ b/src/services/management/merchantAccount.ts @@ -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 { + const resource = new ManagementResource(this, `/merchants`); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListMerchantResponse"); + } + + /** + * Create a merchant account + */ + public async create(request: CreateMerchantRequest): Promise { + const resource = new ManagementResource(this, `/merchants`); + const response = await getJsonResponse( + resource, + request, + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "CreateMerchantResponse"); + } + + /** + * Get a merchant account + */ + public async retrieve(merchantId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}`); + const response = await getJsonResponse( + resource, + "", + { method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Merchant"); + } + + /** + * Request to activate a merchant account + */ + public async activate(merchantId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/activate`); + const response = await getJsonResponse( + resource, + "", + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "RequestActivationResponse"); + } +} + +export default MerchantAccount; diff --git a/src/services/management/merchantAllowedOrigins.ts b/src/services/management/merchantAllowedOrigins.ts new file mode 100644 index 0000000..0a0c0f4 --- /dev/null +++ b/src/services/management/merchantAllowedOrigins.ts @@ -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 { + const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins`); + const response = await getJsonResponse( + resource, + "", + { method: "GET" } + ); + return ObjectSerializer.deserialize(response, "AllowedOriginsResponse"); + } + + /** + * Create an allowed origin + */ + public async create(merchantId: string, apiCredentialId: string, request: AllowedOrigin): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins`); + const response = await getJsonResponse( + resource, + request, + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "AllowedOriginsResponse"); + } + + /** + * Delete an allowed origin + */ + public async delete(merchantId: string, apiCredentialId: string, originId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins/${originId}`); + await getJsonResponse( + resource, + "", + { method: "DELETE" } + ); + } + + /** + * Get an allowed origin + */ + public async retrieve(merchantId: string, apiCredentialId: string, originId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins/${originId}`); + const response = await getJsonResponse( + resource, + "", + { method: "GET" } + ); + return ObjectSerializer.deserialize(response, "AllowedOrigin"); + } +} + +export default MerchantAllowedOrigins; diff --git a/src/services/management/merchantApiCredentials.ts b/src/services/management/merchantApiCredentials.ts new file mode 100644 index 0000000..2b34f52 --- /dev/null +++ b/src/services/management/merchantApiCredentials.ts @@ -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 { + const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials`); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListMerchantApiCredentialsResponse"); + } + + /** + * Create an API credential + */ + public async create(merchantId: string, request: CreateMerchantApiCredentialRequest): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials`); + const response = await getJsonResponse( + resource, + request, + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "CreateApiCredentialResponse"); + } + + /** + * Get an API credential + */ + public async retrieve(merchantId: string, apiCredentialId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}`); + const response = await getJsonResponse( + resource, + "", + { method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ApiCredential"); + } + + /** + * Update an API credential + */ + public async update(merchantId: string, apiCredentialId: string, request: UpdateMerchantApiCredentialRequest): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}`); + const response = await getJsonResponse( + resource, + request, + { method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "ApiCredential"); + } +} + +export default MerchantApiCredentials; diff --git a/src/services/management/merchantApiKey.ts b/src/services/management/merchantApiKey.ts new file mode 100644 index 0000000..5516962 --- /dev/null +++ b/src/services/management/merchantApiKey.ts @@ -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 { + const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/generateApiKey`); + const response = await getJsonResponse( + resource, + "", + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "GenerateApiKeyResponse"); + } +} + +export default MerchantApiKey; diff --git a/src/services/management/merchantClientKey.ts b/src/services/management/merchantClientKey.ts new file mode 100644 index 0000000..173b5c8 --- /dev/null +++ b/src/services/management/merchantClientKey.ts @@ -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 { + const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/generateClientKey`); + const response = await getJsonResponse( + resource, + "", + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "GenerateClientKeyResponse"); + } +} + +export default MerchantClientKey; diff --git a/src/services/management/merchantPaymentMethods.ts b/src/services/management/merchantPaymentMethods.ts new file mode 100644 index 0000000..efb6898 --- /dev/null +++ b/src/services/management/merchantPaymentMethods.ts @@ -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 { + const resource = new ManagementResource(this, `/merchants/${merchantId}/paymentMethodSettings`); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "PaymentMethodResponse"); + } + + /** + * Request a payment method + */ + public async create(merchantId: string, request: PaymentMethodSetupInfo): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/paymentMethodSettings`); + const response = await getJsonResponse( + resource, + request, + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "PaymentMethod"); + } + + /** + * Get payment method details + */ + public async retrieve(merchantId: string, paymentMethodId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/paymentMethodSettings/${paymentMethodId}`); + const response = await getJsonResponse( + resource, + "", + { method: "GET" } + ); + return ObjectSerializer.deserialize(response, "PaymentMethod"); + } + + /** + * Update a payment method + */ + public async update(merchantId: string, paymentMethodId: string, request: UpdatePaymentMethodInfo): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/paymentMethodSettings/${paymentMethodId}`); + const response = await getJsonResponse( + resource, + request, + { method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "PaymentMethod"); + } +} + +export default MerchantPaymentMethods; diff --git a/src/services/management/merchantPayoutSettings.ts b/src/services/management/merchantPayoutSettings.ts new file mode 100644 index 0000000..453229a --- /dev/null +++ b/src/services/management/merchantPayoutSettings.ts @@ -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 { + const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings`); + const response = await getJsonResponse( + resource, + "", + { method: "GET" } + ); + return ObjectSerializer.deserialize(response, "PayoutSettingsResponse"); + } + + /** + * Add a payout setting + */ + public async create(merchantId: string, request: PayoutSettingsRequest): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings`); + const response = await getJsonResponse( + resource, + request, + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "PayoutSettings"); + } + + /** + * Delete a payout setting + */ + public async delete(merchantId: string, payoutSettingsId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`); + await getJsonResponse( + resource, + "", + { method: "DELETE" } + ); + } + + /** + * Get a payout setting + */ + public async retrieve(merchantId: string, payoutSettingsId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`); + const response = await getJsonResponse( + resource, + "", + { method: "GET" } + ); + return ObjectSerializer.deserialize(response, "PayoutSettings"); + } + + /** + * Update a payout setting + */ + public async update(merchantId: string, payoutSettingsId: string, request: UpdatePayoutSettingsRequest): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`); + const response = await getJsonResponse( + resource, + request, + { method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "PayoutSettings"); + } +} + +export default MerchantPayoutSettings; diff --git a/src/services/management/merchantTerminalOrders.ts b/src/services/management/merchantTerminalOrders.ts new file mode 100644 index 0000000..f94ab82 --- /dev/null +++ b/src/services/management/merchantTerminalOrders.ts @@ -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 { + const resource = new ManagementResource(this, `/merchants/${merchantId}/billingEntities`); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "BillingEntitiesResponse"); + } + + /** + * Get a list of shipping locations + */ + public async listShippingLocations(merchantId: string, requestOptions?: IRequest.Options): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/shippingLocations`); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ShippingLocationsResponse"); + } + + /** + * Create a shipping location + */ + public async createShippingLocation(merchantId: string, request: ShippingLocation): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/shippingLocations`); + const response = await getJsonResponse( + resource, + request, + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "ShippingLocation"); + } + + /** + * Get a list of terminal models + */ + public async listTerminalModels(merchantId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalModels`); + const response = await getJsonResponse( + resource, + "", + { method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalModelsResponse"); + } + + /** + * Get a list of orders + */ + public async listTerminalOrders(merchantId: string, requestOptions?: IRequest.Options): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders`); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrdersResponse"); + } + + /** + * Create an order + */ + public async create(merchantId: string, request: TerminalOrderRequest): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders`); + const response = await getJsonResponse( + resource, + request, + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrder"); + } + + /** + * Get an order + */ + public async retrieve(merchantId: string, orderId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders/${orderId}`); + const response = await getJsonResponse( + resource, + "", + { method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrder"); + } + + /** + * Update an order + */ + public async update(merchantId: string, orderId: string, request: TerminalOrderRequest): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders/${orderId}`); + const response = await getJsonResponse( + resource, + request, + { method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrder"); + } + + /** + * Cancel an order + */ + public async cancel(merchantId: string, orderId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders/${orderId}/cancel`); + const response = await getJsonResponse( + resource, + "", + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrder"); + } + + /** + * Get a list of terminal products + */ + public async listTerminalProducts(merchantId: string, requestOptions?: IRequest.Options): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalProducts`); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalProductsResponse"); + } +} + +export default MerchantTerminalOrders; diff --git a/src/services/management/merchantTerminalSettings.ts b/src/services/management/merchantTerminalSettings.ts new file mode 100644 index 0000000..59b6f20 --- /dev/null +++ b/src/services/management/merchantTerminalSettings.ts @@ -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 { + const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalLogos`); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Logo"); + } + + /** + * Update the terminal logo + */ + public async updateLogo(merchantId: string, request: Logo, requestOptions?: IRequest.Options): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalLogos`); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "Logo"); + } + + /** + * Get terminal settings + */ + public async retrieve(merchantId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalSettings`); + const response = await getJsonResponse( + resource, + "", + { method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalSettings"); + } + + /** + * Update terminal settings + */ + public async update(merchantId: string, request: TerminalSettings): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalSettings`); + const response = await getJsonResponse( + resource, + request, + { method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "TerminalSettings"); + } +} + +export default MerchantTerminalSettings; diff --git a/src/services/management/merchantUsers.ts b/src/services/management/merchantUsers.ts new file mode 100644 index 0000000..ff6a11c --- /dev/null +++ b/src/services/management/merchantUsers.ts @@ -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 { + const resource = new ManagementResource(this, `/merchants/${merchantId}/users`); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListMerchantUsersResponse"); + } + + /** + * Create a new user + */ + public async create(merchantId: string, request: CreateMerchantUserRequest): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/users`); + const response = await getJsonResponse( + resource, + request, + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "CreateUserResponse"); + } + + /** + * Get user details + */ + public async retrieve(merchantId: string, userId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/users/${userId}`); + const response = await getJsonResponse( + resource, + "", + { method: "GET" } + ); + return ObjectSerializer.deserialize(response, "User"); + } + + /** + * Update a user + */ + public async update(merchantId: string, userId: string, request: UpdateMerchantUserRequest): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/users/${userId}`); + const response = await getJsonResponse( + resource, + request, + { method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "User"); + } +} + +export default MerchantUsers; diff --git a/src/services/management/merchantWebhooks.ts b/src/services/management/merchantWebhooks.ts new file mode 100644 index 0000000..d9fab17 --- /dev/null +++ b/src/services/management/merchantWebhooks.ts @@ -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 { + const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks`); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListWebhooksResponse"); + } + + /** + * Set up a webhook + */ + public async create(merchantId: string, request: CreateMerchantWebhookRequest): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks`); + const response = await getJsonResponse( + resource, + request, + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "Webhook"); + } + + /** + * Remove a webhook + */ + public async delete(merchantId: string, webhookId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}`); + await getJsonResponse( + resource, + "", + { method: "DELETE" } + ); + } + + /** + * Get a webhook + */ + public async retrieve(merchantId: string, webhookId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}`); + const response = await getJsonResponse( + resource, + "", + { method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Webhook"); + } + + /** + * Update a webhook + */ + public async update(merchantId: string, webhookId: string, request: UpdateMerchantWebhookRequest): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}`); + const response = await getJsonResponse( + resource, + request, + { method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "Webhook"); + } + + /** + * Generate an HMAC key + */ + public async generateHmac(merchantId: string, webhookId: string): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}/generateHmac`); + const response = await getJsonResponse( + resource, + "", + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "GenerateHmacKeyResponse"); + } + + /** + * Test a webhook + */ + public async test(merchantId: string, webhookId: string, request: TestWebhookRequest): Promise { + const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}/test`); + const response = await getJsonResponse( + resource, + request, + { method: "POST" } + ); + return ObjectSerializer.deserialize(response, "TestWebhookResponse"); + } +} + +export default MerchantWebhooks; diff --git a/src/services/resource/management/managementResource.ts b/src/services/resource/management/managementResource.ts new file mode 100644 index 0000000..e9ae0d4 --- /dev/null +++ b/src/services/resource/management/managementResource.ts @@ -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; \ No newline at end of file