Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class AdyenCloudTerminal

  1. Object
  2. PaymentTerminal
  3. AdyenCloudTerminal

Known subtypesAdyenLocalTerminal

Any Adyen payment terminal, through Adyen’s cloud Terminal API.

Each payment is one synchronous PaymentRequest to Adyen’s /sync endpoint, answered once the customer has tapped (or after about 150 seconds). It is plain HTTPS and JSON, so it works on every platform – the desktop ports, mobile and the web – with no native SDK.

Credentials

The cloud Terminal API takes an API key, which must not ship in an app a customer can install. On a till you control, use a key whose only role is the Terminal API. Otherwise point setEndpoint(String) at your own server, which adds the key and forwards the body to Adyen.

String apiKey = null; // null: your endpoint adds the key
AdyenCloudTerminal terminal = new AdyenCloudTerminal(apiKey, "POS-1", "V400m-346403161");
terminal.collect(new TerminalPaymentRequest(1099, "EUR").setReference("order-7"))
        .ready(result -> System.out.println(result));

Starts against Adyen’s test environment; call setLive(boolean) for production.

What else it does

  • Pre-authorizations (authorisationType=PreAuth); capture them from your server with Adyen’s Checkout API, which needs the secret key this class must not hold.
  • reverse(String) reverses a payment by its PSP reference.
  • refund(TerminalRefundRequest) refunds a payment by its PSP reference, or, without one, pays the amount to whichever card is presented (an unlinked refund, which the merchant account must allow).
  • Tipping on the terminal and cashback.
  • lookup(String) asks the terminal what became of a payment this object started, by its reference.
  • Receipt lines and card fields from the terminal’s PaymentReceipt.

Constructors

public AdyenCloudTerminal(String apiKey, String saleId, String poiId)

Methods

public void setLive(boolean live)Switches between Adyen’s test (the default) and live endpoints.
public void setEndpoint(String endpoint)Sends requests to another base URL, such as a server of yours that adds the API key.
public void setTransport(TerminalTransport transport)Replaces the HTTP transport.
public boolean supports(TerminalOperation operation)Whether this terminal can perform operation.
public AsyncResource<TerminalResult> collect(TerminalPaymentRequest request)Takes a payment: a sale, or a pre-authorization when the request says so.
public AsyncResource<TerminalResult> refund(TerminalRefundRequest request)Returns money to a card.
public AsyncResource<TerminalResult> reverse(String transactionId)Cancels a payment that has not settled yet, so it never reaches the customer’s statement.
public AsyncResource<TerminalResult> lookup(String reference)Asks the terminal what became of a payment started by this object, by the reference it was started with.
public void cancel()Asks the terminal to abandon the operation in progress.
protected void schedule(int delay, Runnable task)Runs task on the EDT after delay milliseconds.

Inherited methods

Constructor details

AdyenCloudTerminal

public AdyenCloudTerminal(String apiKey, String saleId, String poiId)

Parameters

apiKey String
the Terminal API key, sent as X-API-Key; may be null when the transport or your own server authenticates instead
saleId String
your identifier for this point of sale, such as a till number
poiId String
the terminal’s ID, [model]-[serial number]

Method details

setLive

public void setLive(boolean live)
Switches between Adyen’s test (the default) and live endpoints.

Parameters

live boolean
true for production

setEndpoint

public void setEndpoint(String endpoint)
Sends requests to another base URL, such as a server of yours that adds the API key. The paths /sync and /async are appended.

Parameters

endpoint String
the base URL, with no trailing slash

setTransport

public void setTransport(TerminalTransport transport)
Replaces the HTTP transport.

Parameters

transport TerminalTransport
the transport

supports

public boolean supports(TerminalOperation operation)
Whether this terminal can perform operation.

Parameters

operation TerminalOperation
the operation to ask about

Returns

true when collect(TerminalPaymentRequest) or the matching method can carry it out

collect

public AsyncResource<TerminalResult> collect(TerminalPaymentRequest request)
Takes a payment: a sale, or a pre-authorization when the request says so.

Parameters

request TerminalPaymentRequest
what to charge

Returns

the outcome, delivered on the EDT

refund

public AsyncResource<TerminalResult> refund(TerminalRefundRequest request)
Returns money to a card. Needs TerminalOperation.REFUND, or TerminalOperation.UNLINKED_REFUND when the request names no payment.

Parameters

request TerminalRefundRequest
what to return, and to which payment

Returns

the outcome, delivered on the EDT

reverse

public AsyncResource<TerminalResult> reverse(String transactionId)
Cancels a payment that has not settled yet, so it never reaches the customer’s statement. Once settled, use refund(TerminalRefundRequest). Needs TerminalOperation.REVERSAL.

Parameters

transactionId String
the payment’s TerminalResult.getTransactionId()

Returns

the outcome, delivered on the EDT

lookup

public AsyncResource<TerminalResult> lookup(String reference)
Asks the terminal what became of a payment started by this object, by the reference it was started with. The terminal keeps its recent transactions only, and a payment started by another process cannot be found this way; look those up in Adyen’s Customer Area or through your server’s webhooks.

Parameters

reference String
the payment’s TerminalPaymentRequest.getReference(), or its transaction ID where the terminal accepts one

Returns

the payment’s result as the terminal or provider recorded it; completes with an error when it has no such payment

cancel

public void cancel()

Asks the terminal to abandon the operation in progress.

Best effort: a card that was already read may still be approved, so the outcome is whatever the operation delivers, TerminalResult.Status.CANCELED when the cancel won. Does nothing when nothing is in progress.

schedule

protected void schedule(int delay, Runnable task)
Runs task on the EDT after delay milliseconds. Overridable so a subclass can drive the retries from its own clock.

Parameters

delay int
the delay in milliseconds
task Runnable
what to run