Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class AdyenCloudTerminal
- Object
- PaymentTerminal
- 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
Inherited methods
Constructor details
AdyenCloudTerminal
public AdyenCloudTerminal(String apiKey, String saleId, String poiId)Parameters
apiKeyString- the Terminal API key, sent as
X-API-Key; may be null when the transport or your own server authenticates instead saleIdString- your identifier for this point of sale, such as a till number
poiIdString- the terminal’s ID,
[model]-[serial number]
Method details
setLive
public void setLive(boolean live)Parameters
liveboolean- true for production
setEndpoint
public void setEndpoint(String endpoint)/sync and /async are appended.Parameters
endpointString- the base URL, with no trailing slash
setTransport
public void setTransport(TerminalTransport transport)Parameters
transportTerminalTransport- the transport
supports
public boolean supports(TerminalOperation operation)operation.Parameters
operationTerminalOperation- the operation to ask about
Returns
collect(TerminalPaymentRequest) or the matching method
can carry it outcollect
public AsyncResource<TerminalResult> collect(TerminalPaymentRequest request)Parameters
requestTerminalPaymentRequest- what to charge
Returns
refund
public AsyncResource<TerminalResult> refund(TerminalRefundRequest request)TerminalOperation.REFUND, or
TerminalOperation.UNLINKED_REFUND when the request names no
payment.Parameters
requestTerminalRefundRequest- what to return, and to which payment
Returns
reverse
public AsyncResource<TerminalResult> reverse(String transactionId)refund(TerminalRefundRequest). Needs TerminalOperation.REVERSAL.Parameters
transactionIdString- the payment’s
TerminalResult.getTransactionId()
Returns
lookup
public AsyncResource<TerminalResult> lookup(String reference)Parameters
referenceString- the payment’s
TerminalPaymentRequest.getReference(), or its transaction ID where the terminal accepts one
Returns
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)task on the EDT after delay milliseconds. Overridable so a
subclass can drive the retries from its own clock.Parameters
delayint- the delay in milliseconds
taskRunnable- what to run