Giter Site home page Giter Site logo

adyen / adyen-node-api-library Goto Github PK

View Code? Open in Web Editor NEW
97.0 11.0 57.0 13.96 MB

Adyen API Library for Node.js

License: MIT License

JavaScript 0.04% TypeScript 99.61% Mustache 0.27% Makefile 0.08%
adyen api api-library node nodejs payment payment-gateway payment-integration api-client hacktoberfest node-js

adyen-node-api-library's Introduction

Node js

Adyen API library for Node.js

Node.js CI Coverage Status Downloads npm bundle size (scoped) Version Quality Gate Status

This is the official Adyen API library for Node.js that we recommend for integrating with Adyen APIs.

Supported APIs

This library supports the following:

API name API version Description API object
BIN Lookup API v54 The BIN Lookup API provides endpoints for retrieving information based on a given BIN. BinLookup
Checkout API v71 Our latest integration for accepting online payments. CheckoutAPI
Configuration API v2 The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. BalancePlatform
DataProtection API v1 Adyen Data Protection API provides a way for you to process Subject Erasure Requests as mandated in GDPR. Use our API to submit a request to delete shopper's data, including payment details and other related information (for example, delivery address or shopper email) DataProtection
Legal Entity Management API v3 Manage legal entities that contain information required for verification. LegalEntityManagement
Local/Cloud-based Terminal API - Our point-of-sale integration. TerminalLocalAPI or TerminalCloudAPI
Management API v3 Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. Management
Payments API v68 Our classic integration for online payments. ClassicIntegrationAPI
Payouts API v68 Endpoints for sending funds to your customers. Payout
Platforms APIs - Set of APIs when using Adyen for Platforms. This API is used for the classic integration. Platforms
Account API v6 Provides endpoints for managing account-related entities on your platform. These related entities include account holders, accounts, bank accounts, shareholders, and verification-related documents. Account
Fund API v6 Provides endpoints for managing the funds in the accounts on your platform. These management operations include, for example, the transfer of funds from one account to another, the payout of funds to an account holder, and the retrieval of balances in an account. Fund
Hosted onboarding API v6 Provides endpoints that you can use to generate links to Adyen-hosted pages, such as an onboarding page or a PCI compliance questionnaire. You can provide these links to your account holders so that they can complete their onboarding. HostedOnboardingPage
Notification Configuration API v6 Provides endpoints for setting up and testing notifications that inform you of events on your platform, for example when a verification check or a payout has been completed. NotificationConfiguration
POS Terminal Management API v1 Endpoints for managing your point-of-sale payment terminals. TerminalManagement
Recurring API v68 Endpoints for managing saved payment details. Recurring
Stored Value API v46 Manage both online and point-of-sale gift cards and other stored-value cards. StoredValue
Transfers API v4 The Transfers API provides endpoints that can be used to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. Transfers
Disputes API v30 You can use the Disputes API to automate the dispute handling process so that you can respond to disputes and chargebacks as soon as they are initiated. The Disputes API lets you retrieve defense reasons, supply and delete defense documents, and accept or defend disputes. Disputes
POS Mobile API v68 The POS Mobile API is used in the mutual authentication flow between an Adyen Android or iOS POS Mobile SDK and the Adyen payments platform. The POS Mobile SDK for Android or iOS devices enables businesses to accept in-person payments using a commercial off-the-shelf (COTS) device like a phone. For example, Tap to Pay transactions, or transactions on a mobile device in combination with a card reader POS Mobile

Supported Webhook versions

The library supports all webhooks under the following model directories:

Webhooks Description Model Name Supported Version
Authentication Webhooks Adyen sends this webhook when the process of cardholder authentication is finalized, whether it is completed successfully, fails, or expires. AcsWebhooks v1
Configuration Webhooks You can use these webhooks to build your implementation. For example, you can use this information to update internal statuses when the status of a capability is changed. ConfigurationNotification v2
Transfer Webhooks You can use these webhooks to build your implementation. For example, you can use this information to update balances in your own dashboards or to keep track of incoming funds. TransferNotification v4
Report Webhooks You can download reports programmatically by making an HTTP GET request, or manually from your Balance Platform Customer Area ReportNotification v1
Management Webhooks Adyen uses webhooks to inform your system about events that happen with your Adyen company and merchant accounts, stores, payment terminals, and payment methods when using Management API. ManagementWebhooks v3
Notification Webhooks We use webhooks to send you updates about payment status updates, newly available reports, and other events that you can subscribe to. For more information, refer to our documentation Notification v1
Transaction Webhooks Adyen sends webhooks to inform your system about incoming and outgoing transfers in your platform. You can use these webhooks to build your implementation. For example, you can use this information to update balances in your own dashboards or to keep track of incoming funds. TransactionWebhooks v4

For more information, refer to our documentation or the API Explorer.

Before you begin

Before you begin to integrate:

Installation

Install the Node.JS package:

npm install --save @adyen/api-library

Alternatively, you can download the release on GitHub.

Updating

To update the Node.JS package:

npm update @adyen/api-library

Check for breaking changes on the releases page.

Usage

// Step 1: Require the parts of the module you want to use
const { Client, CheckoutAPI} = require('@adyen/api-library');

// Step 2: Initialize the client object
const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"}); 

// Step 3: Initialize the API object
const checkoutApi = new CheckoutAPI(client);

// Step 4: Create the request object
  const paymentRequest = {
    amount: {
      currency: "USD",
      value: 1000 // value in minor units
    },
    reference: "Your order number",
    paymentMethod: {
      type: "scheme",
      encryptedCardNumber: "test_4111111111111111",
      encryptedExpiryMonth: "test_03",
      encryptedExpiryYear: "test_2030",
      encryptedSecurityCode: "test_737"
    },
    shopperReference: "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
    storePaymentMethod: true,
    shopperInteraction: "Ecommerce",
    recurringProcessingModel: "CardOnFile",
    returnUrl: "https://your-company.com/...",
    merchantAccount: "YOUR_MERCHANT_ACCOUNT"
  };
  
// Step 5: Make the request
checkoutApi.PaymentsApi.payments(paymentRequest)
  .then(paymentResponse => console.log(paymentResponse.pspReference))
  .catch(error => console.log(error));

If you want to pass query string parameters, you can use the params field from IRequest (also used for idempotency-key and other header fields). The method descriptions contain an example of the possible values you can send to the API for the query parameters, just as stated in the API explorer.

const requestOptions: IRequest.Options = {
    params: {
        limit: "5",
        offset: "10"
    }
};
await balancePlatformService.AccountHoldersApi.getAllBalanceAccountsOfAccountHolder("AH32272223222B5CM4MWJ892H", requestOptions);

Step 1: Require the parts of the module you want to use

Use the Node.js require function to load the Client and API objects from the Adyen module. For the name of the API objects, see Supported APIs.

For example, to use the Checkout API:

const { Client, CheckoutAPI} = require('@adyen/api-library');

Step 2: Initialize the client object

Initialize the client object, passing the following:

For example:

const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"}); 

Step 3: Initialize the API object

Initialize the API object you want to use, passing the client object from the previous step.

For example, for the Checkout API:

const checkoutApi = new CheckoutAPI(client);

Step 4: Create the request object

Create a the request object. For example, for a request to the /payments endpoint:

  const paymentRequest = {
    amount: {
      currency: "USD",
      value: 1000 // value in minor units
    },
    reference: "Your order number",
    paymentMethod: {
      type: "scheme",
      encryptedCardNumber: "test_4111111111111111",
      encryptedExpiryMonth: "test_03",
      encryptedExpiryYear: "test_2030",
      encryptedSecurityCode: "test_737"
    },
    shopperReference: "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
    storePaymentMethod: true,
    shopperInteraction: "Ecommerce",
    recurringProcessingModel: "CardOnFile",
    returnUrl: "https://your-company.com/...",
    merchantAccount: "YOUR_MERCHANT_ACCOUNT"
  };

Step 5: Make the request

Use the API object's method to make the request. For example, to make a request to the /payments endpoint using the CheckoutAPI object:

checkoutApi.PaymentsApi.payments(paymentRequest)
  .then(paymentResponse => console.log(paymentResponse.pspReference))
  .catch(error => console.log(error));

Client setup when going live

For APIS that require your Live URL Prefix (Binlookup, BalanceControl, Checkout, Payout and Recurring) the client is set up as follows in order to start processing live payments:

const { Client } = require('@adyen/api-library');

const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST", liveEndpointUrlPrefix: "YOUR_LIVE_URL_PREFIX"}); 

Usage in TypeScript

Alternatively, you can use the Types included in this module for Typescript and async syntax.

  const { Client, CheckoutAPI, Types } = require('@adyen/api-library');
  const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"});

  const makePaymentsRequest = async () => {
    const paymentsRequest : Types.checkout.PaymentRequest = {
      amount: {
        currency: "USD",
        value: 1000 // Value in minor units.
      },
      reference: "Your order number",
      paymentMethod: {
        type: Types.checkout.CardDetails.TypeEnum.Scheme,
        encryptedCardNumber: "test_4111111111111111",
        encryptedExpiryMonth: "test_03",
        encryptedExpiryYear: "test_2030",
        encryptedSecurityCode: "test_737"
      },
      shopperReference: "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
      storePaymentMethod: true,
      shopperInteraction: Types.checkout.PaymentRequest.ShopperInteractionEnum.Ecommerce,
      recurringProcessingModel: Types.checkout.PaymentRequest.RecurringProcessingModelEnum.CardOnFile,
      returnUrl: "https://your-company.com/...",
      merchantAccount: "YOUR_MERCHANT_ACCOUNT"
    };
    const checkoutAPI = new CheckoutAPI(client);
    const paymentResponse : Types.checkout.PaymentResponse = await checkoutAPI.PaymentsApi.payments(paymentsRequest);
    console.log(paymentResponse.pspReference);
  }

  makePaymentsRequest();

Deserializing JSON Strings

In some setups you might need to deserialize JSON strings to request objects. For example, when using the libraries in combination with Dropin/Components. Please use the built-in deserialization functions:

// Import the required model class
import { checkout } from "../typings";

// Deserialize using built-in ObjectSerializer class
const requestJson: JSON = JSON.parse(`YOUR_JSON_STRING`);
const paymentRequest: checkout.PaymentRequest = await checkout.ObjectSerializer.deserialize(requestJson,"PaymentRequest");

Custom HTTP client configuration

By default, Node.js https is used to make API requests. Alternatively, you can set a custom HttpClient for your Client object.

For example, to set axios as your HTTP client:

const {Client, Config} = require('@adyen/api-library');
const axios = require("axios");
// ... more code
const config = new Config();
const client = new Client({
  config,
  httpClient: {
    async request(endpoint, json, config, isApiKeyRequired, requestOptions) {
        const response = await axios({
            method: 'POST',
            url: endpoint,
            data: JSON.parse(json),
            headers: {
                "X-API-Key": config.apiKey,
                "Content-type": "application/json"
            },
        });

        return response.data;
    }
  }
});
// ... more code

Parsing and Authenticating Banking Webhooks

Parse an AccountHolderNotificationRequest webhook;

let bankingWebhookHandler = new BankingWebhookHandler(YOUR_BANKING_WEBHOOK);
const accountHolderNotificationRequest: AccountHolderNotificationRequest = bankingWebhookHandler.getAccountHolderNotificationRequest();
const genericWebhook = bankingWebhookHandler.getGenericWebhook();

You can also parse the webhook with a generic type, in case you do not know the webhook type in advance. In this case you can check the instance of the webhook in order to parse it to the respective type (or just use it dynamically);

let bankingWebhookHandler = new BankingWebhookHandler(YOUR_BANKING_WEBHOOK);
const genericWebhook = bankingWebhookHandler.getGenericWebhook();

Verify the authenticity (where you retrieve the hmac key from the CA and the signature from the webhook header);

const isValid = hmacValidator.validateBankingHMAC("YOUR_HMAC_KEY", "YOUR_HMAC_SIGNATURE", jsonString)

Management Webhooks

Management webhooks are verified the exact same way as the banking webhooks. To parse them however, instead you use:

let managementWebhookHandler = new ManagementWebhookHandler(YOUR_MANAGEMENT_WEBHOOK);
const genericWebhook = managementWebhookHandler.getGenericWebhook();

Proxy configuration

To configure a proxy connection, set the proxy property of your HttpURLConnectionClient object.

For example:

const {HttpURLConnectionClient, Client, Config} = require('@adyen/api-library');
// ... more code
const config = new Config();
const client = new Client({ config });
const httpClient = new HttpURLConnectionClient();
httpClient.proxy = { host: "http://google.com", port: 8888,  };

client.setEnvironment('TEST');
client.httpClient = httpClient;

// ... more code

Using the Cloud Terminal API Integration

In order to submit In-Person requests with Terminal API over Cloud you need to initialize the client in a similar way as the steps listed above for Ecommerce transactions, but make sure to include TerminalCloudAPI:

// Step 1: Require the parts of the module you want to use
const {Client, TerminalCloudAPI} from "@adyen/api-library";

// Step 2: Initialize the client object
const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"});

// Step 3: Initialize the API object
const terminalCloudAPI = new TerminalCloudAPI(client);

// Step 4: Create the request object
const serviceID = "123456789";
const saleID = "POS-SystemID12345";
const POIID = "Your Device Name(eg V400m-123456789)";

// Use a unique transaction for every transaction you perform
const transactionID = "TransactionID";
const paymentRequest: SaleToPOIRequest = {
    MessageHeader: {
        MessageClass: MessageClassType.Service,
        MessageCategory: MessageCategoryType.Payment,
        MessageType: MessageType.Request,
        ProtocolVersion: "3.0",
        ServiceID: serviceID,
        SaleID: saleID,
        POIID: POIID
    },
    PaymentRequest: {
        SaleData: {
            SaleTransactionID: {
                TransactionID: transactionID,
                TimeStamp: this.GetDate().toISOString()
            },

            SaleToAcquirerData: {
                applicationInfo: {
                    merchantApplication: {
                        version: "1",
                        name: "test",
                    }
                }
            }
        },
        PaymentTransaction: {
            AmountsReq: {
                Currency: "EUR",
                RequestedAmount: 1000
            }
        }
    }
};

// Step 5: Make the request
const terminalAPIResponse: terminal.TerminalApiResponse = await terminalCloudAPI.sync(paymentRequest);

Optional: perform an abort request

To perform an abort request you can use the following example:

const abortRequest: SaleToPOIRequest = {
    MessageHeader: {
        MessageClass: MessageClassType.Service,
        MessageCategory: MessageCategoryType.Abort,
        MessageType: MessageType.Request,
        ProtocolVersion: "3.0",
        // Different serviceID than the one you're aborting
        ServiceID: "Different service ID",
        SaleID: saleID,
        POIID: POIID
    },
    AbortRequest: {
        AbortReason: "MerchantAbort",
        MessageReference: {
            MessageCategory: MessageCategoryEnum.Payment,
            SaleID: saleID,
            // Service ID of the payment you're aborting
            ServiceID: serviceID,
            POIID: POIID
        }

    }
};
const terminalAPIResponse: terminal.TerminalApiResponse = await terminalCloudAPI.sync(abortRequest);

Optional: perform a status request

To perform a status request you can use the following example:

const statusRequest: SaleToPOIRequest = {
    MessageHeader: {
        MessageClass: MessageClassType.Service,
        MessageCategory: MessageCategoryType.TransactionStatus,
        MessageType: MessageType.Request,
        ProtocolVersion: "3.0",
        ServiceID: "Different service ID",
        SaleID: saleID,
        POIID: POIID
    },
    TransactionStatusRequest: {
        ReceiptReprintFlag: true,
        DocumentQualifier: [DocumentQualifierEnum.CashierReceipt, DocumentQualifierEnum.CustomerReceipt],
        MessageReference: {
            SaleID: saleID,
            // serviceID of the transaction you want the status update for
            ServiceID: serviceID,
            MessageCategory: MessageCategoryEnum.Payment
        }
    }
};
const terminalAPIResponse: terminal.TerminalApiResponse = await terminalCloudAPI.sync(statusRequest);

Using the Local Terminal API Integration

The procedure to send In-Person requests using Terminal API over Local Connection is similar to the Cloud Terminal API one, however, additional encryption details are required to perform the requests. Make sure to install the certificate as described here

// Step 1: Require the parts of the module you want to use
const {Client, TerminalLocalAPI} from "@adyen/api-library";

// Step 2: Add your Certificate Path and Local Endpoint to the config path. Install the certificate and save it in your project folder as "cert.cer"
const config: Config = new Config();
config.certificatePath = "./cert.cer";
config.terminalApiLocalEndpoint = "The IP of your terminal (eg https://192.168.47.169)";
config.apiKey = "YOUR_API_KEY_HERE";

// Step 3: Setup a security password for your terminal in CA, and import the security key object:
const securityKey: SecurityKey = {
    AdyenCryptoVersion: 1,
    KeyIdentifier: "keyIdentifier",
    KeyVersion: 1,
    Passphrase: "passphrase",
};

// Step 4 Initialize the client and the API objects
client = new Client({ config });
const terminalLocalAPI = new TerminalLocalAPI(client);

// Step 5: Create the request object
const paymentRequest: SaleToPOIRequest = {
// Similar to the saleToPOIRequest used for Cloud API
}

// Step 6: Make the request
const terminalApiResponse: terminal.TerminalApiResponse = await terminalLocalAPI.request(paymentRequest, securityKey);

Using the Local Terminal API Integration without Encryption (Only on TEST)

If you wish to develop the Local Terminal API integration parallel to your encryption implementation, you can opt for the unencrypted version. Be sure to remove any encryption details from the CA terminal config page.

// Step 1: Require the parts of the module you want to use
const {Client, TerminalLocalAPIUnencrypted} from "@adyen/api-library";

// Step 2: Add your Certificate Path and Local Endpoint to the config path. Install the certificate and save it in your project folder as "cert.cer"
const config: Config = new Config();
config.terminalApiLocalEndpoint = "The IP of your terminal (eg https://192.168.47.169)";
config.apiKey = "YOUR_API_KEY_HERE";

// Step 3 Initialize the client and the API objects
client = new Client({ config });
const terminalLocalAPI = new TerminalLocalAPIUnencrypted(client);

// Step 4: Create the request object
const paymentRequest: SaleToPOIRequest = {
// Similar to the saleToPOIRequest used for Cloud API
}

// Step 5: Make the request
const terminalApiResponse: terminal.TerminalApiResponse = await terminalLocalAPI.request(paymentRequest);

Feedback

We value your input! Help us enhance our API Libraries and improve the integration experience by providing your feedback. Please take a moment to fill out our feedback form to share your thoughts, suggestions or ideas.

Example integration

Clone our Node.js example integration to see how the Adyen API library for Node.js can be used. The integration includes code comments that highlight key features and concepts.

Contributing

We strongly encourage you to contribute to this repository by:

  • Adding new features and functionality.
  • Fixing bugs and issues.
  • Making general improvements.

To learn how to create a pull request, read our contribution guidelines.

Support

To request a feature, report a bug, or report a security vulnerability, create a GitHub issue.

For other questions, contact our support team.

License

This repository is available under the MIT license.

See also

adyen-node-api-library's People

Contributors

acampos1916 avatar adyenautomationbot avatar aleffio avatar alexandrosmor avatar cyattilakiss avatar dependabot-preview[bot] avatar dependabot[bot] avatar djoykeabyah avatar icebergrage avatar jillingk avatar jlengrand avatar juhohei-sc avatar kadobot avatar kilianb avatar krisstallenberg avatar leandromagnabosco avatar lukenorris avatar maassenbas avatar michaelpaul avatar msilvagarcia avatar peterojo avatar renovate-bot avatar renovate[bot] avatar rikterbeek avatar samcottle avatar sergiobergaminicodeploy avatar wboereboom avatar wilsonpinto avatar witoszekdev avatar zaiddreakh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adyen-node-api-library's Issues

[BUG] ICheckout types are not exported

When working with Typescript, I'd like to use pre-built types from ICheckout (and other) namespace (AccountInfo, ...).
Because they have no export prefix, tsc compiler does not recognize and process them.

To Reproduce

  1. Declare a function as this:
export function getPaymentMethods(): Promise<ICheckout.PaymentResponse> {
  return return checkout.paymentMethods({...})
}

Where you CANNOT import the specific interface as

import { PaymentResponse /*, ICheckout */ } from "@adyen/api-library"

nor

import { PaymentResponse /*, ICheckout */ } from "@adyen/api-library/dist/lib/src/typings/checkout";
  1. Build your code using tsc --build (this code is part of a composite project).

Expected behavior
Successful build.

Actual behaviour

$ tsc --build
../composite-project/dist/src/adyen.d.ts:73:13 - error TS2503: Cannot find namespace 'ICheckout'.

73 }): Promise<ICheckout.PaymentMethodsResponse>;

Desktop (please complete the following information):

  • OS: Mac | Linux
  • Node Version: 12.14
  • NPM Version: 6.13
  • Adyen version: 3.1.3

[BUG] Platforms ENDPOINT does not work

Description
There is a problem with the end point of platforms. Can't find any function

To Reproduce

...
const endPoints = require('@adyen/api-library')
export const platform = new endPoints.Platforms(client)
...
const response = await platform.createAccountHolder({
...req.body
})

Error: index_1.platform.createAccountHolder is not a function, error code: undefined
(node:43372) UnhandledPromiseRejectionWarning: RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined
...
(Use node --trace-warnings ... to show where the warning was created)
(node:43372) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:43372) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:43372) UnhandledPromiseRejectionWarning: RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined
...

Expected behavior
The correct callback

Desktop (please complete the following information):

  • OS: Mac
  • Node Version: v14.15.4
  • NPM Version: 6.14.10

Support for rollup.js / import

I am right now testing the drop-in solution of Adyen with my Svelte/Sapper client using rollup.js as bundler. The require() statement is not supported in this environment, just modern import statement.

So I tried something like: import {Client, Config, CheckoutAPI} from '@adyen/api-library' but got these errors when building the project:

Unexpected token (Note that you need @rollup/plugin-json to import JSON files)
1: {
2: "name": "@adyen/api-library",
^
3: "version": "3.1.1",
4: "description": "The Adyen API Library for NodeJS enables you to work with Adyen APIs.",

Installing @rollup/plugin-json does not solve it, seems not being used anyhow. So I am not sure here what to do?

[BUG] notification types notificationItem and additionalData are incorrect in v5.0.1

Describe the bug

  • notificationItem.d.ts has field 'notificationRequestItem', in reality comes back with 'NotificationRequestItem'
  • additionalData.d.ts missing a number of fields such as cardBin, paymentMethodVariant, etc that can actually be included in notifications

To Reproduce
Types as they are present in v5.0.1 library:

export declare class AdditionalData {
    'shopperReference'?: string;
    'shopperEmail'?: string;
    'authCode'?: string;
    'cardSummary'?: string;
    'expiryDate'?: string;
    'authorisedAmountValue'?: string;
    'authorisedAmountCurrency'?: string;
    'hmacSignature'?: string;
    static discriminator: string | undefined;
    static attributeTypeMap: Array<{
        name: string;
        baseName: string;
        type: string;
    }>;
    static getAttributeTypeMap(): {
        name: string;
        baseName: string;
        type: string;
    }[];
}

import { NotificationItem } from './notificationItem';
export declare class Notification {
    'live': string;
    'notificationItems': Array<NotificationItem>;
    static discriminator: string | undefined;
    static attributeTypeMap: Array<{
        name: string;
        baseName: string;
        type: string;
    }>;
    static getAttributeTypeMap(): {
        name: string;
        baseName: string;
        type: string;
    }[];
}

Expected behavior

  • expect notification.d.ts to have key 'NotificationRequestItem' (in upper case)
  • expect additionalData.d.ts to have all keys that actually come back in notification

Additional context
We import these types into out project and validate against them. This fact that these types are incorrect in v5.0.1 is making it difficult for us to upgrade (we are currently on 3.1.3).
Finally, notification type amount now has optional currency and value - when would notification not actually return amount currency and value? we have to make changes to our code following this change, and it would be good to know if this is actually a planned change??

[BUG] FS Module not found

Describe the bug
Hello, after installing @adyen/api-library via yarn I get the following error:

ERROR  Failed to compile with 1 error                                                                                                                                                                    

This dependency was not found:                                                                                                                                                                             
* fs in ./node_modules/@adyen/api-library/lib/src/httpClient/httpURLConnectionClient.js  

To Reproduce
Install @adyen/api-library version ^6.0.1 via yarn
yarn add @adyen/api-library
And try to run the code.

Expected behavior
Run perfectly.

Screenshot of typescript file
image

Desktop (please complete the following information):

  • OS: Ubuntu 20.10
  • Node Version: 12.18.2
  • NPM Version: 6.14.8
  • Yarn Version: 1.22.5

[FEATURE] Pre-authorisation without using TerminalAPI

We would like to perform pre-authorisation check on a specific amount for a payment method (storedPaymentMethodId in our case)

Describe the solution you'd like

An implementation of the authorise API (https://pal-test.adyen.com/pal/servlet/Payment/V52/authorise)

Describe alternatives you've considered

I have no idea how to perform this action (except calling API url). I maybe misread/misunderstood something. I had a look at the TerminalAPI that exposes a pre-authorisation flow but haven't got anything so far.

Additional context

  • "@adyen/api-library": "^3.1.3"

[BUG] Missing response definition in ModificationResult

Describe the bug
Currently the ModificationResult type has no allowed response value to support adjustAuthorisation ('adjustAuthorisation-received').

To Reproduce
Perform an adjust authorisation using the SDK.

Expected behavior
The type has 'adjustAuthorisation-received' as an allowed response value.

[BUG] PascaleCase in SaleToAcquirerData properties names

Describe the bug
Adding nonempty saleToAcquirerData object to terminal payment request results in failing with { "message": "Sale to Acquirer Data: NotAllowed Value: extra data, Reason: Failed validation" } in PaymentResponse.response.additionalResponse.

To Reproduce
add

saleToAcquirerData: {
  applicationInfo: {
    merchantApplication: {
       name: 'my_app',
       version: '0.0.1',
    },
  },
}

in saleToPOIRequest.paymentRequest.saleData

Expected behavior
Request should pass and payment should be saved with custom applicationInfo.

To fix
in SaleToAcquirerData.attributeTypeMap "baseName"s are in PascalCase while here https://docs.adyen.com/point-of-sale/add-data they are in camelCase. Changing it in locally made my requests pass.

[PW-4426] Support for Checkout API v67

Is your feature request related to a problem? Please describe.

Hi, there are many new Web component and 3D Secure 2 updates that requires Checkout API v67 for them to work. It's currently blocking our development, since we cannot use those if using this package. Any timeline when v67 would be supported by this library?

Thanks!

[BUG] Cannot use 'in' operator to search for 'applicationInfo' in undefined

Describe the bug
error when invoking basic adyen configuration

`
import {Client, Config, CheckoutAPI} from '@adyen/api-library';
const axios = require("axios");

class Adyen {

constructor() {
const config = new Config();

config.apiKey = '';
config.merchantAccount = 'TileFiveLLC731';

const client = new Client({ config });
client.setEnvironment("TEST");
this.client=client;

if (new.target === Adyen) {
  throw new TypeError('Cannot construct PaymentCardService instances directly');
}

}
}

export default Adyen;

`


TypeError: Cannot use 'in' operator to search for 'applicationInfo' in undefined
    at Object.setApplicationInfo [as default] (/Users/Shared/nodeWorkspace/approach-api-payments/node_modules/@adyen/api-library/src/helpers/setApplicationInfo.ts:25:49)
    at Checkout.payments (/Users/Shared/nodeWorkspace/approach-api-payments/node_modules/@adyen/api-library/src/services/checkout.ts:68:31)
    at Checkout.savetoken (webpack:///./api/_lib/common-orders/merchants/adyen/services/Checkout.js?:53:32)
    at AdyenPaymentCard.syncCardWithMerchant (webpack:///./api/_lib/common-orders/merchants/adyen/card.js?:68:34)
    at AdyenPaymentCard.save (webpack:///./api/_lib/common-orders/merchants/MerchantCardService.js?:67:45)
    at PaymentCardService.savePaymentCard (webpack:///./api/_lib/PaymentCard/index.js?:68:45)

To Reproduce
Steps to reproduce the behavior

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. Windows, Mac, Linux]
  • Node Version: [e.g. 8.1.2]
  • NPM Version: [e.g. 6.7]

Additional context
Add any other context about the problem here.

[BUG] Could not call Terminal API LIVE

I guess you forget to set the LIVE Terminal API URL, you only do it for TEST

Describe the bug
Could not call Terminal API LIVE

To Reproduce
Activate LIVE

Expected behavior

Screenshots

Desktop (please complete the following information):

Additional context

[BUG] Recurring: RecurringDetailsResult type mismatch

Describe the bug
The IRecurring.RecurringDetailsResult doesn't match the actual JSON structure returned by the API.

To Reproduce

import { Client, Recurring } from '@adyen/api-library'; // v3.1.1

(async () => {
	const recurring = new Recurring(
		new Client({
			apiKey: '****',
			environment: 'TEST',
		})
	);

	const request: IRecurring.RecurringDetailsRequest = {
		merchantAccount: '****',
		shopperReference: '****',
	};

	const result = await recurring.listRecurringDetails(request);

	if (result.details && result.details.length > 0) {
		const x = result.details[0].recurringDetailReference; // undefined
		const y = result.details[0].RecurringDetail.recurringDetailReference; // TS2339: Property 'RecurringDetail' does not exist on type 'RecurringDetail'
	}
})();

Expected behavior
In the example above, either

  • result.details[0].recurringDetailReference is defined, or
  • result.details[0].RecurringDetails doesn't yield a transpilation error.

Desktop (please complete the following information):

  • OS: Mac
  • Node Version: 12.13.1
  • NPM Version: 6.13.2

Additional context
The API response has an extra object in between IRecurring.RecurringDetailsResult['details'] and IRecurring.RecurringDetail, as you can see in the excerpt below extracted from the API Explorer:

{
  "creationDate": "2020-03-31T12:23:14+02:00",
  "details": [
    {
      "RecurringDetail": { // <= extra JSON object not included in the types
        "bank": {
          "bankName": "Wirecard",
          "countryCode": "DE",
          "iban": "*****",
          "ownerName": "*******"
        },
        // [...] omitted for brevity
      }
    }
  ],
  // [...] omitted for brevity
 }

Honestly, this extra RecurringDetails property looks like some issue related to XML to JSON transformation, and it probably should fixed in the API level instead.

[PW-2436] Invalid value undefined for type "" when eventCode is CAPTURE_FAILED

Describe the bug
When handling notifications I'm getting an error of Invalid value undefined for type "". This error only occurs when the eventCode is CAPTURE_FAILED.

To Reproduce
Send a CAPTURE_FAILED notification and then do
new NotificationRequest(JSON.parse(event.body))

Expected behavior
It should throw a Invalid value undefined for type "" error.

Desktop (please complete the following information):

  • OS: Mac
  • Node Version: 12.x
  • NPM Version: 6.13.4

[BUG] Terminal SaleToAcquirerData needs to be Base64 encoded

Describe the bug
The saleToAcquirerData propery of saleData needs to be Base64 encoded into a string before being sent to the terminal

To Reproduce
create a payment request with the following saleData:

saleToAcquirerData: {
                tenderOption: 'MOTO'
            }

Expected behavior
Transaction proceeds

[FEATURE] Why do I need to specify merchantAccount twice?

When making a /paymentMethods request using your NodeJS library I have to specify my merchantAccount twice. Once when specifying my Config object, and once in the request body. Why can't you just use the value I passed into the config? Whats the point of this value in the config object if it isn't being used?

I followed your example when writing my code (https://docs.adyen.com/checkout/drop-in-web).

I would like to only specify this value in one place.

[BUG] The `confirmThirdParty` resource is calling the wrong endpoint `declineThirdParty`

Describe the bug
The confirmThirdParty resource is calling the wrong endpoint declineThirdParty

`${service.client.config.endpoint}/pal/servlet/Payout/${Client.API_VERSION}/declineThirdParty`

I opened a PR #38

To Reproduce
Call the confirmThirdParty

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. Windows, Mac, Linux]
  • Node Version: [e.g. 8.1.2]
  • NPM Version: [e.g. 6.7]

Additional context
Add any other context about the problem here.

[BUG] Missing merchantReference on PaymentResponse

Describe the bug
When calling CheckoutAPI.payments, the PaymentResponse should contain a merchantReference according to the api documentation https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v50/payments.

However this is currently missing from the type.

To Reproduce
Make a call to CheckoutAPI.payments

Expected behavior
Should contain merchantReference in the PaymentResponse

Screenshots
N/A

Desktop (please complete the following information):
N/A

Additional context
N/A

[FEATURE] Highlight the supported API version in the library version

Is your feature request related to a problem? Please describe.
We are sometimes relying on specific API versions to make sure that some bugs or other previously unavailable functionality can be used. It's however not specified anywhere within the node library (at least I can't find) what is the API version that each of the new releases support.

For example, now we would need to use the latest v66 Checkout API, since it fixed a critical issue for us, but I do not know if this library uses it yet or not.

Describe the solution you'd like
For each new release, describe the corresponding API versions that it uses/supports

[BUG] Missing typescript types

Describe the bug
using version 2.2.0, I cannot start a typescript project including the library.

Using the previous version 2.1.8 everything works fine.

To Reproduce
npm install --save @adyen/[email protected]

Expected behavior
project runs

Screenshots
Not screenshots but logs of the errors:

node_modules/@adyen/api-library/dist/lib/src/client.d.ts:11:18 - error TS2304: Cannot find name 'Environment'.

11     environment: Environment;
                    ~~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/client.d.ts:16:18 - error TS2304: Cannot find name 'Environment'.

16     environment: Environment;
                    ~~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/client.d.ts:22:18 - error TS2304: Cannot find name 'Environment'.

22     environment: Environment;
                    ~~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/client.d.ts:28:18 - error TS2304: Cannot find name 'Environment'.

28     environment: Environment;
                    ~~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/client.d.ts:34:18 - error TS2304: Cannot find name 'Environment'.

34     environment: Environment;
                    ~~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/client.d.ts:37:18 - error TS2304: Cannot find name 'Environment'.

37     environment: Environment;
                    ~~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/client.d.ts:41:18 - error TS2304: Cannot find name 'Environment'.

41     environment: Environment;
                    ~~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/client.d.ts:72:33 - error TS2304: Cannot find name 'Environment'.

72     setEnvironment(environment: Environment, liveEndpointUrlPrefix?: string): void;
                                   ~~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/config.d.ts:5:19 - error TS2304: Cannot find name 'Environment'.

5     environment?: Environment;
                    ~~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/config.d.ts:24:19 - error TS2304: Cannot find name 'Environment'.

24     environment?: Environment;
                     ~~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/httpClient/clientInterface.d.ts:7:105 - error TS2503: Cannot find namespace 'IRequest'.

7     request(endpoint: string, json: string, config: Config, isApiKeyRequired: boolean, requestOptions?: IRequest.Options): Promise<string | HttpClientException | ApiException>;
                                                                                                          ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/httpClient/httpURLConnectionClient.d.ts:11:101 - error TS2503: Cannot find namespace 'IRequest'.

11     request(endpoint: string, json: string, config: Config, isApiRequired: boolean, requestOptions: IRequest.Options): Promise<string | HttpClientException | ApiException>;
                                                                                                       ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/binLookup.d.ts:7:33 - error TS2503: Cannot find namespace 'IBinLookup'.

7     get3dsAvailability(request: IBinLookup.ThreeDSAvailabilityRequest): Promise<IBinLookup.ThreeDSAvailabilityResponse>;
                                  ~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/binLookup.d.ts:7:81 - error TS2503: Cannot find namespace 'IBinLookup'.

7     get3dsAvailability(request: IBinLookup.ThreeDSAvailabilityRequest): Promise<IBinLookup.ThreeDSAvailabilityResponse>;
                                                                                  ~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/binLookup.d.ts:8:30 - error TS2503: Cannot find namespace 'IBinLookup'.

8     getCostEstimate(request: IBinLookup.CostEstimateRequest): Promise<IBinLookup.CostEstimateResponse>;
                               ~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/binLookup.d.ts:8:71 - error TS2503: Cannot find namespace 'IBinLookup'.

8     getCostEstimate(request: IBinLookup.CostEstimateRequest): Promise<IBinLookup.CostEstimateResponse>;
                                                                        ~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/checkout.d.ts:11:74 - error TS2503: Cannot find namespace 'IRequest'.

11     payments(paymentsRequest: ICheckout.PaymentRequest, requestOptions?: IRequest.Options): Promise<ICheckout.PaymentResponse>;
                                                                            ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/checkout.d.ts:15:91 - error TS2503: Cannot find namespace 'IRequest'.

15     paymentSession(paymentSessionRequest: ICheckout.PaymentSetupRequest, requestOptions?: IRequest.Options): Promise<ICheckout.PaymentSetupResponse>;
                                                                                             ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/checkoutUtility.d.ts:6:35 - error TS2503: Cannot find namespace 'ICheckoutUtility'.

6     originKeys(originKeysRequest: ICheckoutUtility.CheckoutUtilityRequest): Promise<ICheckoutUtility.CheckoutUtilityResponse>;
                                    ~~~~~~~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/checkoutUtility.d.ts:6:85 - error TS2503: Cannot find namespace 'ICheckoutUtility'.

6     originKeys(originKeysRequest: ICheckoutUtility.CheckoutUtilityRequest): Promise<ICheckoutUtility.CheckoutUtilityResponse>;
                                                                                      ~~~~~~~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:16:44 - error TS2503: Cannot find namespace 'IPayments'.

16     capture(captureRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                              ~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:16:93 - error TS2503: Cannot find namespace 'IRequest'.

16     capture(captureRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                                                               ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:16:120 - error TS2503: Cannot find namespace 'IPayments'.

16     capture(captureRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                                                                                          ~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:17:58 - error TS2503: Cannot find namespace 'IPayments'.

17     cancelOrRefund(cancelOrRefundRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                            ~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:17:107 - error TS2503: Cannot find namespace 'IRequest'.

17     cancelOrRefund(cancelOrRefundRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                                                                             ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:17:134 - error TS2503: Cannot find namespace 'IPayments'.

17     cancelOrRefund(cancelOrRefundRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                                                                                                        ~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:18:42 - error TS2503: Cannot find namespace 'IPayments'.

18     refund(refundRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                            ~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:18:91 - error TS2503: Cannot find namespace 'IRequest'.

18     refund(refundRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                                                             ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:18:118 - error TS2503: Cannot find namespace 'IPayments'.

18     refund(refundRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                                                                                        ~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:19:42 - error TS2503: Cannot find namespace 'IPayments'.

19     cancel(cancelRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                            ~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:19:91 - error TS2503: Cannot find namespace 'IRequest'.

19     cancel(cancelRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                                                             ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:19:118 - error TS2503: Cannot find namespace 'IPayments'.

19     cancel(cancelRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                                                                                        ~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:20:60 - error TS2503: Cannot find namespace 'IPayments'.

20     technicalCancel(technicalCancelRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                              ~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:20:109 - error TS2503: Cannot find namespace 'IRequest'.

20     technicalCancel(technicalCancelRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                                                                               ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:20:136 - error TS2503: Cannot find namespace 'IPayments'.

20     technicalCancel(technicalCancelRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                                                                                                          ~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:21:68 - error TS2503: Cannot find namespace 'IPayments'.

21     adjustAuthorisation(adjustAuthorisationRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                                      ~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:21:117 - error TS2503: Cannot find namespace 'IRequest'.

21     adjustAuthorisation(adjustAuthorisationRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                                                                                       ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/modification.d.ts:21:144 - error TS2503: Cannot find namespace 'IPayments'.

21     adjustAuthorisation(adjustAuthorisationRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;
                                                                                                                                                  ~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/payout.d.ts:11:45 - error TS2503: Cannot find namespace 'IPayouts'.

11     storeDetailAndSubmitThirdParty(request: IPayouts.StoreDetailAndSubmitRequest): Promise<IPayouts.StoreDetailAndSubmitResponse>;
                                               ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/payout.d.ts:11:92 - error TS2503: Cannot find namespace 'IPayouts'.

11     storeDetailAndSubmitThirdParty(request: IPayouts.StoreDetailAndSubmitRequest): Promise<IPayouts.StoreDetailAndSubmitResponse>;
                                                                                              ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/payout.d.ts:12:32 - error TS2503: Cannot find namespace 'IPayouts'.

12     confirmThirdParty(request: IPayouts.ModifyRequest): Promise<IPayouts.ModifyResponse>;
                                  ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/payout.d.ts:12:65 - error TS2503: Cannot find namespace 'IPayouts'.

12     confirmThirdParty(request: IPayouts.ModifyRequest): Promise<IPayouts.ModifyResponse>;
                                                                   ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/payout.d.ts:13:32 - error TS2503: Cannot find namespace 'IPayouts'.

13     declineThirdParty(request: IPayouts.ModifyRequest): Promise<IPayouts.ModifyResponse>;
                                  ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/payout.d.ts:13:65 - error TS2503: Cannot find namespace 'IPayouts'.

13     declineThirdParty(request: IPayouts.ModifyRequest): Promise<IPayouts.ModifyResponse>;
                                                                   ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/payout.d.ts:14:26 - error TS2503: Cannot find namespace 'IPayouts'.

14     storeDetail(request: IPayouts.StoreDetailRequest): Promise<IPayouts.StoreDetailResponse>;
                            ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/payout.d.ts:14:64 - error TS2503: Cannot find namespace 'IPayouts'.

14     storeDetail(request: IPayouts.StoreDetailRequest): Promise<IPayouts.StoreDetailResponse>;
                                                                  ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/payout.d.ts:15:31 - error TS2503: Cannot find namespace 'IPayouts'.

15     submitThirdparty(request: IPayouts.SubmitRequest): Promise<IPayouts.SubmitResponse>;
                                 ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/payout.d.ts:15:64 - error TS2503: Cannot find namespace 'IPayouts'.

15     submitThirdparty(request: IPayouts.SubmitRequest): Promise<IPayouts.SubmitResponse>;
                                                                  ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/payout.d.ts:16:21 - error TS2503: Cannot find namespace 'IPayouts'.

16     payout(request: IPayouts.PayoutRequest): Promise<IPayouts.PayoutResponse>;
                       ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/payout.d.ts:16:54 - error TS2503: Cannot find namespace 'IPayouts'.

16     payout(request: IPayouts.PayoutRequest): Promise<IPayouts.PayoutResponse>;
                                                        ~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/recurring.d.ts:7:35 - error TS2503: Cannot find namespace 'IRecurring'.

7     listRecurringDetails(request: IRecurring.RecurringDetailsRequest): Promise<IRecurring.RecurringDetailsResult>;
                                    ~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/recurring.d.ts:7:80 - error TS2503: Cannot find namespace 'IRecurring'.

7     listRecurringDetails(request: IRecurring.RecurringDetailsRequest): Promise<IRecurring.RecurringDetailsResult>;
                                                                                 ~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/recurring.d.ts:8:22 - error TS2503: Cannot find namespace 'IRecurring'.

8     disable(request: IRecurring.DisableRequest): Promise<IRecurring.DisableResult>;
                       ~~~~~~~~~~

node_modules/@adyen/api-library/dist/lib/src/services/recurring.d.ts:8:58 - error TS2503: Cannot find namespace 'IRecurring'.

8     disable(request: IRecurring.DisableRequest): Promise<IRecurring.DisableResult>;
                                                           ~~~~~~~~~~

server/payment/payment.service.ts:5:39 - error TS2306: File '/Users/alexandru.aldulea/workspace/frontend-post-login/node_modules/@adyen/api-library/dist/lib/src/typings/checkout.d.ts' is not a module.

5 import { PaymentMethodsRequest } from '@adyen/api-library/dist/lib/src/typings/checkout'
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Desktop (please complete the following information):

  • OS: Mac
  • Node Version: v12.13.0
  • NPM Version: 6.12.0

Additional context
tsconfig:

  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "esModuleInterop": true,
    "lib": [
      "es2019",
      "esnext.array"
    ]
  },
  "exclude": ["node_modules", "dist", "src"]
}

[BUG] Terminal API print request returns Bad JSON if Text contains non-ascii

Describe the bug
The terminal API does not correctly serialize the JSON for sending a PrintRequest to the printer. Sending the example below throws ["Bad JSON:1: Unexpected character"]

To Reproduce

function printText() {
    let req = makeReq(MessageClassType.Device, MessageCategoryType.Print, poi2); //a helper function that generates a header

    req.saleToPOIRequest.printRequest = ObjectSerializer.deserialize({
        "PrintOutput": {
            "DocumentQualifier": "Document",
            "ResponseMode": "PrintEnd",
            "OutputContent": {
              "OutputFormat": "Text",
              "OutputText": [
                {
                  "CharacterStyle": "Bold",
                  "Alignment": "Centred",
                  "EndOfLineFlag": true,
                  "Text": "THIS IS THE TITLE"
                },
                {
                  "Alignment": "Centred",
                  "EndOfLineFlag": true,
                  "Text": ""
                },
                {
                  "Alignment": "Left",
                  "EndOfLineFlag": false,
                  "Text": "This is key-1"
                },
                {
                  "Alignment": "Right",
                  "EndOfLineFlag": true,
                  "Text": "value-1"
                },
                {
                  "Alignment": "Left",
                  "EndOfLineFlag": false,
                  "Text": "This is key-2"
                },
                {
                  "Alignment": "Right",
                  "EndOfLineFlag": true,
                  "Text": "value-2"
                },
                {
                  "Alignment": "Left",
                  "EndOfLineFlag": false,
                  "Text": "This is key-3"
                },
                {
                  "Alignment": "Right",
                  "EndOfLineFlag": true,
                  "Text": "value-3"
                },
                {
                  "Alignment": "Left",
                  "EndOfLineFlag": true,
                  "Text": "Some explanation about the receipt (# %^& @/: $ £ €)"
                },
                {
                  "Alignment": "Centred",
                  "EndOfLineFlag": true,
                  "Text": ""
                },
                {
                  "CharacterStyle": "Bold",
                  "Alignment": "Centred",
                  "EndOfLineFlag": true,
                  "Text": "This is the footer"
                }
              ]
            }
          }}
      , 'PrintRequest')
    return local2.request(req, key) //local2 is an instance of Local Terminal API
}

Here is the serialized JSON:

{"SaleToPOIRequest":{"MessageHeader":{"MessageCategory":"Print","MessageClass":"Device","MessageType":"Request","POIID":"V400m-346987962","ProtocolVersion":"3.0","SaleID":"ANZE-PC","ServiceID":"vgnk8hyOGq"},"PrintRequest":{"PrintOutput":{"DocumentQualifier":"Document","OutputContent":{"OutputFormat":"Text","OutputText":[{"Alignment":"Centred","CharacterStyle":"Bold","EndOfLineFlag":true,"Text":"THIS IS THE TITLE"},{"Alignment":"Centred","EndOfLineFlag":true,"Text":""},{"Alignment":"Left","EndOfLineFlag":false,"Text":"This is key-1"},{"Alignment":"Right","EndOfLineFlag":true,"Text":"value-1"},{"Alignment":"Left","EndOfLineFlag":false,"Text":"This is key-2"},{"Alignment":"Right","EndOfLineFlag":true,"Text":"value-2"},{"Alignment":"Left","EndOfLineFlag":false,"Text":"This is key-3"},{"Alignment":"Right","EndOfLineFlag":true,"Text":"value-3"},{"Alignment":"Left","EndOfLineFlag":true,"Text":"Some explanation about the receipt (# %^& @/: $ £ €)"},{"Alignment":"Centred","EndOfLineFlag":true,"Text":""},{"Alignment":"Centred","CharacterStyle":"Bold","EndOfLineFlag":true,"Text":"This is the 
footer"}]},"ResponseMode":"PrintEnd"}}}}

Expected behavior
Successful execution and printing of receipt

RecurringDetailsResult is not aligned with the actual API response

Hello
The actuel v49/listRecurringDetails API response has the following shape

{
  "creationDate": "2020-04-03T09:55:03+02:00",
  "details": [
    {
      "RecurringDetail": {
        "alias": "A549761438794558",
        "aliasType": "Default"
        ...
      },
            "RecurringDetail": {
        "alias": "A549761438794558",
        "aliasType": "Default"
       .....
      }
    }
  ]
}

but the SDK, (we are using v6.0.3) has the following shape, and it is still the same in the develop branch

interface RecurringDetailsResult {
     /**
      * The date when the recurring details were created.
      */
     creationDate?: string;
     /**
      * Payment details stored for recurring payments.
      */
     details?: IRecurring.RecurringDetail[];
     /**
      * The most recent email for this shopper (if available).
      */
     lastKnownShopperEmail?: string;
     /**
      * The reference you use to uniquely identify the shopper (e.g. user ID or account ID).
      */
     shopperReference?: string;
 }

interface RecurringDetail {
     /**
      * This field contains additional data, which may be returned in a particular response.
      *
      * The additionalData object consists of entries, each of which includes the key and value.
      */
     additionalData?: {};
     /**
      * The alias of the credit card number.
      *
      * Applies only to recurring contracts storing credit card details
      */
     alias?: string;
     /**
      * The alias type of the credit card number.
      *
      * Applies only to recurring contracts storing credit card details.
      */
     aliasType?: string;
     /**
      * A container for bank account data.
      */
     bank?: IRecurring.BankAccount;
     /**
      * The billing address.
      */
     billingAddress?: IRecurring.Address;
     /**
      * A container for card data.
      */
     card?: IRecurring.Card;
     /**
      * Types of recurring contracts.
      */
     contractTypes?: string[];
     /**
      * The date when the recurring details were created.
      */
     creationDate?: string;
     /**
      * The `pspReference` of the first recurring payment that created the recurring detail.
      */
     firstPspReference?: string;
     /**
      * An optional descriptive name for this recurring detail.
      */
     name?: string;
     /**
      * The  type or sub-brand of a payment method used, e.g. Visa Debit, Visa Corporate, etc. For more information, refer to [PaymentMethodVariant](https://docs.adyen.com/development-resources/paymentmethodvariant).
      */
     paymentMethodVariant?: string;
     /**
      * The reference that uniquely identifies the recurring detail.
      */
     recurringDetailReference: string;
     /**
      * The name of the shopper.
      */
     shopperName?: IRecurring.Name;
     /**
      * A shopper's social security number (only in countries where it is legal to collect).
      */
     socialSecurityNumber?: string;
     /**
      * The payment method, such as “mc", "visa", "ideal", "paypal".
      */
     variant: string;
 }

There is a missing property RecurringDetail in the interface, and the API response is not mapped correctly.

Regards

[BUG] When Local Terminal API Security Key Version is 0, validateSecurityKey throws exception

Describe the bug
When using the Local Terminal API and decrypting the received payload, if the keyVersion is set to 0 the key validation throws InvalidSecurityKeyException since it evaluates the 0 as false.

To Reproduce
Try to send a request to local terminal API with the following security key:

{
    "passphrase": "mysupersecretpassphrase",
    "keyIdentifier": "mykey",
    "keyVersion": 0,
    "adyenCryptoVersion": 1
}

Expected behavior
The feature works, it should instead check if the property is not null.

Desktop (please complete the following information):

  • OS: Windows 10
  • Node Version: v144.0
  • NPM Version: 6.14.4

[BUG] Invalid HMAC signature error when upgraded to the v4.0.0

Describe the bug
After upgrading from the v3.1.2 to the v4.0.0 when calling validateHMAC is returing false.

To Reproduce
Install de v4.0.0 of the library and try to validate an HMAC signature.

Expected behavior
When calling validateHMAC it should return false.

Desktop (please complete the following information):

  • OS: Mac
  • Node Version: 12.x
  • NPM Version: 6.13.4

Additional context
The HMAC validation works fine with the v3.1.2 of the library.

[BUG] Unexpected undefined return value for a refund

Describe the bug
When performing a refund using modification API, call should return a promise as define in type:

refund(refundRequest: GenericRequest<IPayments.ModificationRequest>, requestOptions?: IRequest.Options): Promise<IPayments.ModificationResult>;

But I got a Promise resolved with undefined instead of an exception or a result.

TypeError: Cannot destructure property 'pspReference' of 'undefined' as it is undefined. 

To Reproduce

const modification = new Modification(client);

 const { response, pspReference } = await modification.refund({
    merchantAccount: "mymerchant",
    originalReference: "mytransaction",
    modificationAmount: {
      currency: "EUR",
      value: 324
    }
  });

Expected behavior
An exception to be raised or response to have an error value.

Desktop (please complete the following information):

  • Node Version: 15.1
  • NPM Version: 7.0.8
  • Adyen: 5.0.1 & 6.0.3

[BUG] Bad example code of verifying HMAC signatures

Describe the bug
Example code doesn't work (Node.JS)
https://docs.adyen.com/development-resources/webhooks/verify-hmac-signatures#hmac_validation

To Reproduce
Run example code.

Expected behavior
It works.

Fix

  | const { hmacValidator } = require('@adyen/api-library');
-- | --
  | const hmacKey = "YOUR_HMAC_KEY";
  | // YOUR_HMAC_KEY from the Customer Area
  | const validator = new hmacValidator()
  | const notificationRequest = NOTIFICATION_REQUEST_JSON; // Notification Request JSON
  | const notificationRequestItems = notificationRequest.notificationItems
  | notificationRequestItems.forEach(function(notificationRequest /*<== notificationRequestItem */) {
  | if( validator.validateHMAC(notificationRequestItem /*<== should add .NotificationRequestItem */, hmacKey) ) {
  | const eventCode = notificationRequestItem.eventCode;
  | // Process the notification based on the eventCode
  | } else {
  | // Non valid NotificationRequest
  | console.log("Non valid NotificationRequest");
  | }
  | });

[BUG] authStringEnc not encoded when authenticating with username and password

Describe the bug
When I try to authenticate using username and password

const config = new Config({
    username: auth.username,
    password: auth.password,
  });

they are placed in the Authorization HTTP header as plain text https://github.com/Adyen/adyen-node-api-library/blob/develop/src/httpClient/httpURLConnectionClient.ts#L65
causing Adyen api to return error HTTP Exception: 401. Unauthorized

To Reproduce
Authenticate using username and password

Expected behavior
Request should contain encoded Authorization

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Linux
  • Node Version: v8.9.1
  • NPM Version: v5.5.1

Additional context
I changed the line passing the encoding base64

const authStringEnc = authEncBytes.toString();

and it worked.

[BUG] Notification Param that Should Be Optional?

Describe the bug
Convert.toNotification requires a paymentMethod field for all notifications, but Adyen does not send that field for Auto Rescue notifications thus causing an error.

To Reproduce
Send an auto rescue webhook notification and convert the notification using the library's Convert.toNotification

Expected behavior
Invalid value undefined for type "" error is thrown

Additional context
Example of Adyen's webhook notification for auto rescues we have received

  "live": "false",
  "notificationItems": [
    {
      "NotificationRequestItem": {
        "additionalData": {
          "hmacSignature": "asdfasdfasldfjaslkdfjlasjdkfjls;adjfjaskl;dfjlasjdflkas;",
          "merchantOrderReference": "asdfasdfasdfasdfasdfsadfsadf",
          "retry.rescueReference": "123876546890012"
        },
        "eventCode": "AUTORESCUE",
        "merchantReference": "asdfasdfasdfasdfasdfsadfsadf",
        "merchantAccountCode": "MerchantAccountName",
        "reason": "",
        "amount": {
          "currency": "EUR",
          "value": 0
        },
        "originalReference": "1234567890710101",
        "success": "true",
        "pspReference": "12345678901233",
        "eventDate": "2020-03-27T20:31:23+01:00"
      }
    }

Adyen's notification required typings
https://github.com/Adyen/adyen-node-api-library/blob/develop/src/typings/notification.ts#L49

[BUG] TerminalCloudApi sending paymentRequest even when it's not payment

Describe the bug
When I try to use the TerminalCloudApi to perform a refund, the library is adding a paymentRequest object, causing an error

To Reproduce
Try to place a refund through the package with this payload:

{
    "saleToPoiRequest": {
        "messageHeader": {
            "protocolVersion": "3.0",
            "messageClass": "Service",
            "messageCategory": "Reversal",
            "messageType": "Request",
            "saleId": "Supersonic",
            "serviceId": "63291636",
            "poiid": "P400Plus-275051867"
        },
        "reversalRequest": {
            "originalPoiTransaction": {
                "poiTransactionId": {
                    "transactionId": "4uPz001587655334008.853587655338027B",
                    "timeStamp": "2020-04-23T14:34:51-03:00"
                }
            },
            "reversalReason": "MerchantCancel"
        }
    }
}

Error returned was this:

Error: Invalid value {
    "messageHeader": {
        "messageCategory": "Reversal",
        "messageClass": "Service",
        "messageType": "Request",
        "poiid": "P400Plus-275051867",
        "protocolVersion": "3.0",
        "saleId": "Supersonic",
        "serviceId": "63318806"
    },
    "reversalRequest": {
        "originalPoiTransaction": {
            "poiTransactionId": {
                "transactionId": "4uPz001587655334008.853587655338027B",
                "timeStamp": "2020-04-23T14:35:18-03:00"
            }
        },
        "reversalReason": "MerchantCancel",
        "reversedAmount": 16.88,
        "saleData": {
            "saleToAcquirerData": "currency=NZD",
            "saleTransactionId": {
                "timeStamp": "2020-04-23T14:35:18-03:00",
                "transactionId": "4uPz001587655334008.853587655338027B"
            }
        }
    },
    "paymentRequest": {
        "saleData": {
            "saleToAcquirerData": {
                "applicationInfo": {
                    "adyenLibrary": {
                        "name": "adyen-node-api-library",
                        "version": "3.1.1"
                    }
                }
            }
        }
    }
} for type [
    null,
    {
        "ref": "SaleToPoiRequest"
    }
]

Expected behavior
It shouldn't add the paymentRequest object into a refund request

Desktop (please complete the following information):

  • OS: Linux
  • Node Version: 13.13.0
  • NPM Version: 6.14.4

Additional context
From my search into the code, I found that the TerminalCloudApi merges a paymentRequest into the request in the method setApplicationInfo. This

[FEATURE] Remove requirement for an API key if using only Local Terminal API

Is your feature request related to a problem? Please describe.
I keep having to put in fake API keys into the config class when using the Local Terminal API even though they are not needed. Could the API key change into being optional? Same for merchant account, environment and checkout endpoint.

Describe the solution you'd like
Either isolate the Local Terminal API or make all options in the Config class optional.

Describe alternatives you've considered
This is my current code:

const config = new Config();
config.apiKey = 'AAAAA';
config.merchantAccount = 'MerchantsPOS';
config.environment = 'TEST';
config.checkoutEndpoint = 'https://checkout-test.adyen.com/checkout/V52';
config.certificatePath = './adyen-terminalfleet-test.pem';
let config1 = new Config(config);
config1.terminalApiLocalEndpoint = 'https://10.20.42.29';
let config2 = new Config(config);
config2.terminalApiLocalEndpoint = 'https://10.20.42.25';
const client = new Client({
    config: config1
});
const client2 = new Client({
    config: config2
});
const local = new TerminalLocalAPI(client);
const local2 = new TerminalLocalAPI(client2);

[BUG] Exporter enum types incorrect

Describe the bug
The enum types that are exported in notificationRequestItem.d.ts (and probably other files that I do not use yet) are not correct. They only provide a enum name without value. As you can see in the TypeScript enum docs (https://www.typescriptlang.org/docs/handbook/enums.html#numeric-enums), when declaring an enum without values, it will result in a number, while the Adyen API is returning strings.

To Reproduce
Install @adyen/api-library and open notificationRequestItem.d.ts.

Expected behavior
Those enums have a string value, representing the value that is sent from the Adyen API. I created some typings in my own project to get around this bug:

enum NotificationEventCode {
    AUTHORISATION = 'AUTHORISATION',
    CANCELLATION = 'CANCELLATION',
    CANCEL_OR_REFUND = 'CANCELORREFUND',
    REFUND = 'REFUND',
    REFUND_FAILED = 'REFUNDFAILED',
}

enum NotificationSuccess {
    True = 'true',
    False = 'false',
}

Screenshots

export declare namespace NotificationRequestItem {
    enum EventCodeEnum {
        AUTHORISATION,
        AUTHORISATIONADJUSTMENT,
        CANCELLATION,
        CANCELORREFUND,
        CAPTURE,
        CAPTUREFAILED,
        HANDLEDEXTERNALLY,
        ORDEROPENED,
        ORDERCLOSED,
        PENDING,
        PROCESSRETRY,
        REFUND,
        REFUNDFAILED,
        REFUNDEDREVERSED,
        REFUNDWITHDATA,
        REPORTAVAILABLE,
        VOIDPENDINGREFUND,
        CHARGEBACK,
        CHARGEBACKREVERSED,
        NOTIFICATIONOFCHARGEBACK,
        NOTIFICATIONOFFRAUD,
        PREARBITRATIONLOST,
        PREARBITRATIONWON,
        REQUESTFORINFORMATION,
        SECONDCHARGEBACK,
        PAYOUTEXPIRE,
        PAYOUTDECLINE,
        PAYOUTTHIRDPARTY,
        PAIDOUTREVERSED,
        AUTORESCUE,
        CANCELAUTORESCUE,
        RECURRINGCONTRACT,
        POSTPONEDREFUND,
        OFFERCLOSED,
        MANUALREVIEWACCEPT,
        MANUALREVIEWREJECT
    }
    enum OperationsEnum {
        CANCEL,
        CAPTURE,
        REFUND
    }
    enum SuccessEnum {
        True,
        False
    }
}

Desktop (please complete the following information):

  • OS: Mac
  • Node Version: 12.16.3
  • NPM Version: 6.14.4

@adyen/api-library :- httpURLConnectionClient.js:84 Uncaught (in promise) TypeError: url_1.URL is not a constructor

Describe the bug
image

URL Undefined
image

image

To Reproduce

Unablet o make call getting URL constructor error
const promise = this.checkout.paymentMethods({ merchantAccount: config.merchantAccount })
console.log(promise);

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • Windows
  • Node Version: 13.14.0
  • NPM Version: 6.14.4
  • Angualr ^9.1.12 and ^10.0.0
  • @adyen/api-library: ^7.0.0 / 6 ,

Additional context

[FEATURE] Support for account, fund and hop services

Great to see this library existing and being actively developed. Especially happy for the typings support, thank you!

Describe the solution you'd like

In addition to the payment services, we also use Adyen MarketPay. Any timeline when MarketPay services support could be coming? I see the config supporting the credentials in the typings at least :)

From the MarketPay API endpoints we are using Account, Fund and Hop services.

[BUG] Checkout interfaces are not aligned with received PaymentResponse

Describe the bug
When sending a POST request to /payments the PaymentResponse contains an action object that is not represented correctly by the union type of interfaces specified in code. The trimmed retrieved response looks the following:

{
  "resultCode": "IdentifyShopper",
  "action": {
    "paymentData": "Ab02b4c0!...",
    "paymentMethodType": "scheme",
    "token": "eyJ0aH...",
    **"type": "threeDS2Fingerprint"**
  },
  "authentication": {
    "threeds2.fingerprintToken": "eyJ0aH..."
  },
  "details": [
    {
      "key": "threeds2.fingerprint",
      "type": "text"
    }
  ],
  "paymentData": "Ab02b4c0!..."
}

Unfortunately, the type property is not specified in any of the relevant interfaces: CheckoutDonationAction | CheckoutQrCodeAction | CheckoutRedirectAction | CheckoutSDKAction | CheckoutThreeDS2ChallengeAction | CheckoutThreeDS2FingerPrintAction | CheckoutAwaitAction | CheckoutVoucherAction | CheckoutOneTimePasscodeAction.
This makes the type property not accessible without a cast enforcing this property.

To Reproduce

  • The actual response can be viewed here.
  • The defined shapes can be found here

Expected behavior
The provided types reflect the actual response.

Additional context
Also, the (documentation)[https://docs.adyen.com/checkout/3d-secure/native-3ds2/web-drop-in#make-a-payment] relies on the shape of the actual response.

[PW-2466] SaleToAquirerData not being encoded causing MessageFormat errors

Hi there,

we seem to have an issue with the encoding of the cloud terminal request send by the library.
I described it here below. Thanks for having a look.

Issue:
Using Adyen API Library for Node 3.2.3 to send cloud terminal api requests. If you don't include Application info, Application info is being appended to the payment requests in the SaleToAquirerData object. However, only the info in ApplicationInfo is being encoded to base64, instead of the whole SaleToAquirerData object. This is causing a messageFormat error.

What is the expected result?
Have the SaleToAquirerData object to be a Base64-encoded string

What happens instead?
only info in ApplicationInfo is encoded, causing a MessageFormat error of "Expected JSON string"

Please provide any additional information below.

Request:
{ "SaleToPOIRequest" : { "MessageHeader" : { "MessageCategory" : "Payment", "MessageClass" : "Service", "MessageType" : "Request", "POIID" : "V400cPlus-401840085", "SaleID" : "6dc37f53-21de-43f5-9ab0-f06c45289b1a", "ServiceID" : "54DD7CE906" }, "PaymentRequest" : { "PaymentTransaction" : { "AmountsReq" : { "Currency" : "EUR", "RequestedAmount" : 40 } }, "SaleData" : { "SaleToAcquirerData" : { "ApplicationInfo" : "eyJhZHllbkxpYnJhcnkiOnsibmFtZSI6ImFkeWVuLW5vZGUtYXBpLWxpYnJhcnkiLCJ2ZXJzaW9uIjoiMy4yLjMifX0=" }, "SaleTransactionID" : { "TimeStamp" : "2020-05-25T14:43:15+02:00", "TransactionID" : "TEST0000000000200000000095T" } } } } }

Response:

{ "SaleToPOIResponse" : { "PaymentResponse" : { "POIData" : { "POITransactionID" : { "TimeStamp" : "2020-05-25T12:43:18.081Z", "TransactionID" : "7ign001590410598042" } }, "SaleData" : { "SaleTransactionID" : { "TimeStamp" : "2020-05-25T12:43:15.000Z", "TransactionID" : "TEST0000000000200000000095T" } }, "Response" : { "Result" : "Failure", "AdditionalResponse" : "errors=At%20SaleToPOIRequest.PaymentRequest.SaleData.SaleToAcquirerData%3a%20Expected%20JSON%20string", "ErrorCondition" : "MessageFormat" } }, "MessageHeader" : { "ProtocolVersion" : "3.0", "SaleID" : "6dc37f53-21de-43f5-9ab0-f06c45289b1a", "MessageClass" : "Service", "MessageCategory" : "Payment", "ServiceID" : "54DD7CE906", "POIID" : "V400cPlus-401840085", "MessageType" : "Response" } } }

[BUG] NPM package doesn't expose services

The main entry in the NPM package doesn't expose services:
@adyen/api-library/dist/lib/src/index.js

The TypeScript Typings indicate, that the services are supposed to be available.

The module entry (@adyen/api-library/dist/lib-esm/src/index.js) looks fine.

To Reproduce

import { CheckoutAPI } from '@adyen/api-library';
console.log(CheckoutAPI); // Prints "undefined"

Expected behavior

All services should be exported via CommonJs on the root level.

Desktop (please complete the following information):

  • OS: Mac
  • Node Version: v12.3.1
  • NPM Version: 6.9.0

Additional context
This is my current workaround:

import CheckoutAPI from '@adyen/api-library/dist/lib/src/service/checkout';

[BUG] paymentsResponse property action not defined in typings

Describe the bug
Documentation for the 'drop-in' and 'components' iframe payments tools detail an actions object that can be available on the payments response, https://docs.adyen.com/checkout/drop-in-web#response.

The response from CheckoutApi payments request does (when applicable) contain this actions object but it is not defined in the type definitions for this object https://github.com/Adyen/adyen-node-api-library/blob/develop/src/typings/checkout/paymentResponse.ts.

To Reproduce
Make a call to the CheckoutAPI payments service

public payments(paymentsRequest: PaymentRequest, requestOptions?: RequestOptions): Promise<PaymentResponse> {
using a test card configured to return an action response (such as 3DS) e.g. 4212345678901237.

An actions object is present on the paymentsResponse object.

Expected behavior
action should be defined in the paymentResponse type definitions.

Additional context
This was mentioned in #130 but as a secondary issue so didn't seem to get addressed when the main issue of the ticket was resolved.

[BUG]TypeError: WEBPACK_IMPORTED_MODULE_3_url.URL is not a constructor

Describe the bug
I has an issue "TypeError: WEBPACK_IMPORTED_MODULE_3_url.URL is not a constructor
at HttpURLConnectionClient../node_modules/@adyen/api-library/dist/lib-esm/src/httpClient/httpURLConnectionClient.js.HttpURLConnectionClient.createRequest (httpURLConnectionClient.js:66)"

image
To Reproduce
I'm using TerminalCloudAPI on NPM Version: 6.9 to integrate pos with adyen terminal v400m.

I wonder if somebody has the same this issue?

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • NPM Version: 6.9

Additional context
Add any other context about the problem here.

[BUG] Snakecase vs. Camelcase naming of NotificationRequestItem in API response

Describe the bug
In typings for Notification are NotificationRequestItem referred to as notificationRequestItem. Breaking the typings to be used.

To Reproduce
Test notification

{"live":"false","notificationItems":[{"NotificationRequestItem":{"additionalData":{"expiryDate":"12\/2012"," NAME1 ":"VALUE1","authCode":"1234","cardSummary":"7777","shopperIP":"127.0.0.1","totalFraudScore":"10","hmacSignature":"U371N1MoYzlBv\/tg1bzKVLOqcEMCg95FlVFj7guNMls=","NAME2":"  VALUE2  ","fraudCheck-6-ShopperIpUsage":"10"},"amount":{"currency":"EUR","value":10100},"eventCode":"AUTHORISATION","eventDate":"2019-10-28T13:34:09+01:00","merchantAccountCode":"VaesslaABSE","merchantReference":"8313842560770001","operations":["CANCEL","CAPTURE","REFUND"],"paymentMethod":"visa","pspReference":"test_AUTHORISATION_1","reason":"1234:7777:12\/2012","success":"true"}}]}

Expected behavior
Make typings refer to NotificationRequestItem as per sent in API.

Desktop (please complete the following information):

  • Node Version: 10.x.x

[BUG] The BarcodeValue field name is Value

This should be updated to BarcodeValue, otherwise the terminal sends:

    "printResponse": {
      "response": {
        "additionalResponse": "errors=At%20SaleToPOIRequest.PrintRequest.PrintOutput.OutputContent.OutputBarcode.BarcodeType%3a%20Invalid%20value%0aAt%20SaleToPOIRequest.PrintRequest.PrintOutput.OutputContent.OutputBarcode%2c%20field%20BarcodeValue%3a%20Missing&warnings=At%20SaleToPOIRequest.PrintRequest.PrintOutput.OutputContent.OutputBarcode%2c%20field%20Value%3a%20Unexpected",
        "errorCondition": "MessageFormat",
        "result": "Failure"
      }
    }

[BUG] Unable to import validateHMAC() function

I am currently following this tutorial to verify notification callback return to backend after payment success

but unable to import validateHMAC function, even following exactly, seems like it never import "validator" in the code
image

I tried change to

const {hmacValidator} = require('@adyen/api-library');
hmacValidator.validateHMAC(notificationRequest, hmacKey)

but it still shows

TypeError: hmacValidator.validateHMAC is not a function

To Reproduce

const {hmacValidator} = require('@adyen/api-library');
validator.validateHMAC({}, '');

Expected behavior
Should be able to import hmacValidator and able to use validateHMAC function to validate the data

Screenshots
image
image

Desktop (please complete the following information):

  • OS: Windows, Linux
  • Node Version: v8.11.3
  • NPM Version: 6.14.1

Additional context
if refer to code snippet in documentation page, this variable also undefined but it can be fixed by changing hmacValidator.validateHMAC(notificationRequestItem, hmacKey) to hmacValidator.validateHMAC(notificationRequest, hmacKey)
image

Improve typings for client/config objects creation

Hello,

After using the SDK for some time, I noticed there is an opportunity to improve currently exposed API so that it better reflects use cases.

Because this is structured similarly in multiple places, let's maybe focus on (defined on Client class):
https://github.com/Adyen/adyen-node-api-library/blob/develop/src/client.ts#L103

public setEnvironment(environment: Environment, liveEndpointUrlPrefix?: string): void {
where
type Environment = "LIVE" | "TEST";

Assuming we have an instance of Client class client already instantiated, there are two (allowed by documentation) ways to set it, namely:

client.setEnvironement("TEST");
and
client.setEnvironement("LIVE", "your-endpoint-prefix");

unfortunately, current typings also make
client.setEnvironment("TEST", "your-endpoint-prefix");
and
client.setEnvironment("LIVE"); valid.

While the first one is not only unlikely but also of minor importance (nothing more than small technical glitch here), the second one compiles and suggests that nothing is wrong until the project is run in live environment - and it fails there with error "Please provide your unique live url prefix on the setEnvironment() call on the Client or provide checkoutEndpoint in your config object.". Error is informative and actionable, that's very good! But it's only available on runtime on live environment.

My suggestion would be to change current invocations to something along the lines of:
public setEnvironment(option: { environment: "TEST"; } | { environment: "LIVE"; liveEndpointUrlPrefix: string }): void {

It's only slightly less convenient to write it this way but it makes it obvious on compile-time that liveEndpointUrlPrefix needs to be passed or it won't work.

I prepared a small self-contained example here: https://www.typescriptlang.org/play?#code/C4TwDgpgBAKhDOwCiA7AbgSwE4HsUFsIVgoBeKAIhiQGUYKAoUSKAGQzQlU1wKJPIVWASQBqSRk3DRu2PIWJlYCZOjl9FAHzYcua3guAMpLAMIAbDPwAKAQyy3CwCFngB5TlnM5bAEyUA3gxQIVBEPPL8AFxQsgb8waFEvmA4GMQA-DGIWOkA5gwAvsbM0BZWxHYOTi7unt5+AEyBiSHh6oYxcIhxkcRFUNpBoWH6fcAx7Jy9GkYjyanpE1A5+QDcRcYMAMZ4iFC7KABmGHkA+pacMeU29o4Qzq4eLg3+5MNJY7MxQmISmzs9iRDidzs5ENdLLdqg9as8vD43lAPm0vp1KNQ6IxigwAPS4qCmHD4MAYczQFy4LBQAAWLmgAFooHkcDhfABCQEofYg06NC66SEVYBVe6POovRHNd6tUYRb6UETibHGQ48vCg-ng5Y3Sp3GpPepSlrzNHRDG0ehFIA

I'm happy to hear what are your views on the matter.

Cheers,
Michał

"TypeError: Object.keys: argument is not an Object \ n at Go

** Describe the bug **
I am using the library https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.5.0/adyen.js to encrypt the card number and
when I use Chrome it is working normally but in Internet explorer it presents an error. The system is in classic ASP and runs on Microsoft-IIS / 6.0

Reproduce
"TypeError: Object.keys: argument is not an Object \ n
at Go (https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.5.0/adyen.js:4:306537)\n
at r (https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.5.0/adyen.js:4:307068)\n
at x (https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.5.0/adyen.js:4:53663)\n
at Anonymous function (https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.5.0/adyen.js:4:3580)\n
at j (https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.5.0/adyen.js:4:4346)\n
at j (https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.5.0/adyen.js:4:4329)\n
at w (https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.5.0/adyen.js:4:3320)\n
at x (https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.5.0/adyen.js:4:7070)\n
at Anonymous function (https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.5.0/adyen.js:4:3580)\n
at j (https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.5.0/adyen.js:4:4346) "

Expected behavior
my expectation is that the library will behave in the same way regardless of browse.

** Screenshots **
Working normally in Chrome
image

Occurs in Internet Explorer
image

** Desktop (fill in the following information): **

  • OS: Windows
  • Internet Explore 11 - v.11.0.9600.19596

** Additional context **
Add any other context about th

[BUG] wrong case in NotificationItem.notificationRequestItem

Describe the bug
The class NotificationItem has the property notificationRequestItem but the actual payload from a JSON notification has NotificationRequestItem (first letter uppercase). In a Typescript project

To Reproduce

import { hmacValidator } from '@adyen/api-library';
import { Notification } from '@adyen/api-library/lib/src/typings/notification/notification';

const notification: Notification = JSON.parse(JSON_STRING_FROM_THE_BODY);
const notificationItem = notification.notificationItems[0]

const validator = new hmacValidator();
validator.validateHMAC(notificationItem.notificationRequestItem, HMAC)

This code will fail with TypeError: Cannot read property 'additionalData' of undefined. Changing the first letter to uppercase will result in the compiler complaining Property 'NotificationRequestItem' does not exist on type 'NotificationItem'. Did you mean 'notificationRequestItem'?. As a workaround, the array notation can be used:

notificationItem['NotificationRequestItem']

Expected behavior
The type Notification should reflect the API result

Desktop (please complete the following information):

  • OS: Linux
  • Node Version: 16.0.0
  • NPM Version: 7.11.22

Changelog

Where I can view correct changelog? As example if I need upgrade from v2 to v3, where deprecation list?

[BUG] Version 3.1.2 missing typings file

Describe the bug
A clear and concise description of what the bug is.

When installing latest version 3.1.2, only index.js is found from dist folder, so the typings are not bundled. Version 3.1.1 bundles the typings correctly.

To Reproduce
Steps to reproduce the behavior

  • Install latest version yarn add @adyen/[email protected]
  • Check dist folder, missing typings declaration file

Expected behavior

A clear and concise description of what you expected to happen.

  • Typings declarations should be included in the dist folder

Desktop (please complete the following information):

  • OS: Mac
  • Yarn Version: 1.22.4

Code in dist/es5/vendors~main.js is not valid ECMAScript 5

Describe the bug

The NPM module you release contains invalid ECMAScript 5 code in the dist/es5/vendors~main.js bundle.

One or more of your dependencies is not distributed as ES5, and since Webpack will not transpile them unless you specifically instruct the TypeScript loader to include it, it's propagated without modification.

To Reproduce

Steps to reproduce the behavior:

  1. Install the module with npm install --save @adyen/api-library (or build the project).
  2. Inspect the file node_modules/@adyen/api-library/dist/es5/vendors~main.js.
  3. You'll see there instances of arrow functions and spread operators.

Expected behavior

The file should contain only ES5 language features as the es5 directory it's in leads users of the library to expect.

[BUG] Required field 'cvc' is not provided when users pay without CVC on stored card

Describe the bug
After 3.8.1 update of adyen-ios, drop in support hide the CVC field when users pay using stored card, users are able to pay when using new card but if the card is stored card, it will pop up the "Required field cvc is not provided" error

To Reproduce
Steps to reproduce the behavior

  1. enable hide cvc on Adyen drop in
  2. pay using stored card (no need to key in cvc as it's hidden)
  3. the "required field cvc is not provided" error will shown up

Expected behavior
customers should be able to pay using stored card without CVC as iOS drop in support hide cvc field

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Ubuntu 18.04.4
  • Node Version: 12.18.0
  • NPM Version: 7.8.0

Additional context
users are able to pay if key in new card and pay, it only didn't work when pay using stored card

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.