Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class TerminalPaymentRequest
- Object
- 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
Inherited methods
Constructor details
TerminalPaymentRequest
public TerminalPaymentRequest(long amount, String currency)Parameters
amountlong- the amount in the currency’s minor unit; must be positive
currencyString- 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)Sets
getReference().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)Sets
getProviderReference().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)Sets
isPreAuthorization().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)Sets
isAskForTip().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)Sets
getTipAmount().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)Sets
getCashbackAmount().Returns
this request