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

public final class TerminalPaymentRequest

  1. Object
  2. TerminalPaymentRequest

What a PaymentTerminal should charge.

The amount is in the currency’s minor unit – cents for USD, yen for JPY – the way every payment provider takes it, so no floating point rounding ever reaches a price.

TerminalPaymentRequest req = new TerminalPaymentRequest(1250, "USD")
        .setReference("order-1042");

Constructors

public TerminalPaymentRequest(long amount, String currency)

Methods

public long getAmount()The amount in the currency’s minor unit.
public String getCurrency()The ISO 4217 currency code, as given.
public String getReference()The app’s own identifier for the sale, such as an order number.
public TerminalPaymentRequest setReference(String reference)Sets getReference().
public String getProviderReference()The provider-side payment this request completes, created by the app’s server: a Stripe PaymentIntent’s client secret for TapToPay, or its ID (pi_...) for StripeReaderTerminal.
public TerminalPaymentRequest setProviderReference(String providerReference)Sets getProviderReference().
public boolean isPreAuthorization()True to reserve the amount rather than charge it; the money moves only on PaymentTerminal.capture(String, long, String).
public TerminalPaymentRequest setPreAuthorization(boolean preAuthorization)Sets isPreAuthorization().
public boolean isAskForTip()True to let the customer add a tip on the terminal before the card is read.
public TerminalPaymentRequest setAskForTip(boolean askForTip)Sets isAskForTip().
public long getTipAmount()A tip the app already knows, in the minor unit, included in getAmount() – the terminal shows and reports it separately.
public TerminalPaymentRequest setTipAmount(long tipAmount)Sets getTipAmount().
public long getCashbackAmount()Cash handed to the customer, in the minor unit, charged on top of getAmount().
public TerminalPaymentRequest setCashbackAmount(long cashbackAmount)Sets getCashbackAmount().

Inherited methods

Constructor details

TerminalPaymentRequest

public TerminalPaymentRequest(long amount, String currency)

Parameters

amount long
the amount in the currency’s minor unit; must be positive
currency String
the ISO 4217 code, such as USD

Method details

getAmount

public long getAmount()
The amount in the currency’s minor unit.

getCurrency

public String getCurrency()
The ISO 4217 currency code, as given.

getReference

public String getReference()
The app’s own identifier for the sale, such as an order number. Sent to providers that record one, and what PaymentTerminal.lookup(String) finds the payment by; may be null, but a sale without one cannot be looked up after contact is lost.

setReference

public TerminalPaymentRequest setReference(String reference)

Returns

this request

getProviderReference

public String getProviderReference()
The provider-side payment this request completes, created by the app’s server: a Stripe PaymentIntent’s client secret for TapToPay, or its ID (pi_...) for StripeReaderTerminal. Most terminals need none.

setProviderReference

public TerminalPaymentRequest setProviderReference(String providerReference)

Returns

this request

isPreAuthorization

public boolean isPreAuthorization()
True to reserve the amount rather than charge it; the money moves only on PaymentTerminal.capture(String, long, String). Needs TerminalOperation.PRE_AUTHORIZATION.

setPreAuthorization

public TerminalPaymentRequest setPreAuthorization(boolean preAuthorization)

Returns

this request

isAskForTip

public boolean isAskForTip()
True to let the customer add a tip on the terminal before the card is read. The tip comes back as TerminalResult.getTipAmount(). Needs TerminalOperation.TIPPING.

setAskForTip

public TerminalPaymentRequest setAskForTip(boolean askForTip)

Returns

this request

getTipAmount

public long getTipAmount()
A tip the app already knows, in the minor unit, included in getAmount() – the terminal shows and reports it separately. Zero for none.

setTipAmount

public TerminalPaymentRequest setTipAmount(long tipAmount)

Returns

this request

getCashbackAmount

public long getCashbackAmount()
Cash handed to the customer, in the minor unit, charged on top of getAmount(). Zero for none. Needs TerminalOperation.CASHBACK, and most acquirers allow it only for debit cards.

setCashbackAmount

public TerminalPaymentRequest setCashbackAmount(long cashbackAmount)

Returns

this request