public static final class ChargeRequest.Builder
extends java.lang.Object
ChargeRequest
.Constructor and Description |
---|
Builder(int totalAmount,
CurrencyCode currencyCode) |
Modifier and Type | Method and Description |
---|---|
ChargeRequest.Builder |
autoReturn(long timeout,
java.util.concurrent.TimeUnit unit)
After a transaction completes, Square Point of Sale automatically returns
to your app after the timeout you provide to this method.
|
ChargeRequest |
build()
Constructs a
ChargeRequest from the current state of this builder. |
ChargeRequest.Builder |
customerId(java.lang.String customerId)
Optional customer id to associate the sale to a specific customer.
|
ChargeRequest.Builder |
enforceBusinessLocation(java.lang.String locationId)
Requires a transaction to be processed by a particular location of a
merchant's business.
|
ChargeRequest.Builder |
note(java.lang.String note)
Specifies a note to associate with a processed transaction.
|
ChargeRequest.Builder |
requestMetadata(java.lang.String requestMetadata)
Optional request metadata that Square Point of Sale will return in its response, as
ChargeRequest.Success.requestMetadata or Error#requestMetadata . |
ChargeRequest.Builder |
restrictTendersTo(ChargeRequest.TenderType... tenderTypes) |
ChargeRequest.Builder |
restrictTendersTo(java.util.Collection<ChargeRequest.TenderType> tenderTypes)
Restricts the payment methods the merchant can accept for the transaction.
|
public Builder(int totalAmount, CurrencyCode currencyCode)
totalAmount
- Amount to charge. Point of Sale might add taxes and / or a tip on top,
depending on the user account configuration. Smallest divisible unit of currency for a given
locale, scaled by the default number of decimal places for the currency.
For example, totalAmount = 100 in USD means $1.00.currencyCode
- CurrencyCode
representing ISO-4217 currency codes. Square
Point of Sale will ensure that the passed in currency code matches the currency of the user
logged in to Point of Sale.java.lang.IllegalArgumentException
- if totalAmount is negative.java.lang.NullPointerException
- if currencyCode is null.public ChargeRequest.Builder restrictTendersTo(java.util.Collection<ChargeRequest.TenderType> tenderTypes)
Restricts the payment methods the merchant can accept for the transaction.
If you don't provide this value, all supported payment methods are allowed.
tenderTypes
- The payment methods that the merchant can accept.java.lang.NullPointerException
- if tenderTypes is nulljava.lang.IllegalArgumentException
- is tenderTypes is emptypublic ChargeRequest.Builder restrictTendersTo(ChargeRequest.TenderType... tenderTypes)
restrictTendersTo(Collection)
public ChargeRequest.Builder note(java.lang.String note)
Specifies a note to associate with a processed transaction.
This note is included in the itemizations
field of Payment
objects
returned
by the List Payments and Retrieve Payment endpoints of the Square Connect API. It's also
included on all paper tickets and receipts associated with the transaction.
note
- The note to associate with the transaction.java.lang.IllegalArgumentException
- if the note is longer than 500 characters.public ChargeRequest.Builder autoReturn(long timeout, java.util.concurrent.TimeUnit unit)
After a transaction completes, Square Point of Sale automatically returns to your app after the timeout you provide to this method.
timeout
- The timeout to set, in the provided unit, or PosApi.AUTO_RETURN_NO_TIMEOUT
. If you specify a timeout, it must be
between 3.2 seconds and 10 seconds.unit
- the TimeUnit
for the passed in timeout value. May be null if timeout is
PosApi.AUTO_RETURN_NO_TIMEOUT
java.lang.IllegalArgumentException
- if timeout is not between PosApi.AUTO_RETURN_TIMEOUT_MIN_MILLIS
and
PosApi.AUTO_RETURN_TIMEOUT_MAX_MILLIS
.public ChargeRequest.Builder enforceBusinessLocation(java.lang.String locationId)
locationId
- If provided, this ID must correspond to whichever location
is currently logged in to Square Point of Sale. Otherwise, Square Point of Sale will
respond with ChargeRequest.ErrorCode.ILLEGAL_LOCATION_ID
. If you don't provide
this value, the payment will be processed by whichever location is logged
in to Square Point of Sale.public ChargeRequest.Builder requestMetadata(java.lang.String requestMetadata)
ChargeRequest.Success.requestMetadata
or Error#requestMetadata
. This metadata is currently
not sent to Square servers.requestMetadata
- The request metadata, or null.public ChargeRequest.Builder customerId(java.lang.String customerId)
customerId
- the customer id, see the online documentation on saving
customer information.public ChargeRequest build()
ChargeRequest
from the current state of this builder.