Terminal-2 icon

Protect with a library

Use an Adyen GitHub library to protect local communications between your POS app and terminal.

If your integration uses local communications, you need to protect your integration against man-in-the-middle attacks, eavesdropping, and tampering. To help you with this, we provide GitHub libraries that:

  • Validate the terminal certificate, to confirm your POS app is communicating directly with an Adyen-supplied payment terminal.
  • Encrypt communications. This prevents intruders from reading the messages transmitted between the POS app and the terminal.

The available libraries are:

These GitHub libraries work with Terminal API and are completely separate from the classic libraries, which have been deprecated.

Select a tab below for the Adyen GitHub library you want to use.

Requirements

Use the .NET library

  1. In your C# project, create a Config object specifying:

    • The URL of the terminal.
    • The environment: Test or Live.
    Copy code
    Config config = new Config
    {
    Environment = Model.Environment.Test,
    LocalTerminalApiEndpoint = @"https://_terminal_:8443/nexo/"
    };
  2. Create a Client object using the Config object created in the previous step.

    Copy code
    Client client = new Client(config);
  3. Create the TerminalLocalApi service using the client created in the previous step.

    Copy code
    Service.TerminalLocalApi posPaymentLocalApi = new Service.TerminalLocalApi(client);
  4. Create an EncryptionCredentialDetails object specifying the identifier, passphrase, and version of your shared key.

    Copy code
    EncryptionCredentialDetails encryptionCredentialDetails = new EncryptionCredentialDetails
    {
    AdyenCryptoVersion = 1,
    KeyIdentifier = "KEY_IDENTIFIER",
    Password = "KEY_PASSPHRASE",
    KeyVersion = 1
    };
  5. When you send a Terminal API request to the payment terminal, use the TerminalLocalApi service specifying a SaleToPOIRequest object and the EncryptionCredentialDetails object.

    Copy code
    SaleToPOIResponse response = posPaymentLocalApi.TerminalRequest(saleToPOIRequest, encryptionCredentialDetails);

The library will:

  • Serialize the request object to JSON and then encrypt and sign the request.
  • Send the request and receive the response.
  • Decrypt and deserialize the response and pass the content to the response object.

Troubleshooting

Crypto errors and SSL connection errors indicate a problem with the protection of the local communications.

Crypto errors

Example:

Copy code
Exception: System.Net.WebException: The remote server returned an error: (401) Unauthorized.

The response body contains:

Copy code
{
"errors":[
"Nexo Service: crypto error (9)"
],
"ServiceID":"1234567890"
}

Cause: Crypto errors are related to the shared key. After you set up the shared key in your Customer Area, the shared key values in your code must match the shared key values in the Customer Area.

If you are using a library, check the values for the relevant object:

If you are using your own code:

Crypto error Cause
crypto error (1) There is a problem with parsing the request. This can be due to a syntax error.
crypto error (2) The version number of the shared key in your code is unknown.
crypto error (3) There is a problem with the message header of the request.
crypto error (4) There is a problem with the body of the request.
crypto error (5) There is a problem with the security trailer of the encrypted message. The trailer uses the version and identifier of the shared key.
crypto error (6) There is a problem with the passphrase of the shared key.
crypto error (7) The nonce is missing or incorrect. The nonce must have a length of 16 bytes.
crypto error (8) The HMAC key is missing or incorrect. The HMAC key must have a length of 32 bytes.
crypto error (9) The shared key details in your code do not match the shared key that is set up in your Customer Area.

SSL connection error

Example:

Copy code
Exception : System.Net.WebException: The SSL connection could not be established

Possible cause: Adyen's root certificate is not installed correctly.

See also