Class AdyenCloudTerminal
- Direct Known Subclasses:
AdyenLocalTerminal
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Asks the terminal to abandon the operation in progress.collect(TerminalPaymentRequest request) Takes a payment: a sale, or a pre-authorization when the request says so.Asks the terminal what became of a payment started by this object, by the reference it was started with.refund(TerminalRefundRequest request) Returns money to a card.Cancels a payment that has not settled yet, so it never reaches the customer's statement.protected voidRunstaskon the EDT afterdelaymilliseconds.voidsetEndpoint(String endpoint) Sends requests to another base URL, such as a server of yours that adds the API key.voidsetLive(boolean live) Switches between Adyen's test (the default) and live endpoints.voidsetTransport(TerminalTransport transport) Replaces the HTTP transport.booleansupports(TerminalOperation operation) Whether this terminal can performoperation.Methods inherited from class PaymentTerminal
capture, failed, missingCapability, reconcile, unsupported
-
Constructor Details
-
AdyenCloudTerminal
Parameters
-
apiKey: the Terminal API key, sent asX-API-Key; may be null when the transport or your own server authenticates instead -
saleId: your identifier for this point of sale, such as a till number -
poiId: 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: true for production
-
setEndpoint
Sends requests to another base URL, such as a server of yours that adds the API key. The paths
/syncand/asyncare appended.Parameters
endpoint: the base URL, with no trailing slash
-
setTransport
Replaces the HTTP transport.
Parameters
transport: the transport
-
supports
Description copied from class:PaymentTerminalWhether this terminal can perform
operation.Parameters
operation: the operation to ask about
Returns
true when
PaymentTerminal.collect(TerminalPaymentRequest)or the matching method can carry it out- Specified by:
supportsin classPaymentTerminal
-
collect
Description copied from class:PaymentTerminalTakes a payment: a sale, or a pre-authorization when the request says so.
Parameters
request: what to charge
Returns
the outcome, delivered on the EDT
- Specified by:
collectin classPaymentTerminal
-
refund
Description copied from class:PaymentTerminalReturns money to a card. Needs
TerminalOperation.REFUND, orTerminalOperation.UNLINKED_REFUNDwhen the request names no payment.Parameters
request: what to return, and to which payment
Returns
the outcome, delivered on the EDT
- Overrides:
refundin classPaymentTerminal
-
reverse
Description copied from class:PaymentTerminalCancels a payment that has not settled yet, so it never reaches the customer's statement. Once settled, use
PaymentTerminal.refund(TerminalRefundRequest). NeedsTerminalOperation.REVERSAL.Parameters
transactionId: the payment'sTerminalResult.getTransactionId()
Returns
the outcome, delivered on the EDT
- Overrides:
reversein classPaymentTerminal
-
lookup
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.- Overrides:
lookupin classPaymentTerminal
-
cancel
public void cancel()Description copied from class:PaymentTerminalAsks 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.CANCELEDwhen the cancel won. Does nothing when nothing is in progress.- Specified by:
cancelin classPaymentTerminal
-
schedule
Runs
taskon the EDT afterdelaymilliseconds. Overridable so a subclass can drive the retries from its own clock.Parameters
-
delay: the delay in milliseconds -
task: what to run
-
-