Capture and tip adjust
For more information, see Supported payment methods.
Prerequisites
Before you integrate with the Go SDK, complete the following:
- Create a global developer account with a default test merchant account.
- Create additional test merchants, if needed.
- Create an app in the sandbox.
- Create at least one employee role user for the OAuth flow.
- Order a Clover Go reader Developer Kit (Dev Kit) and set it up.
Field descriptions
TipAdjustRequest fields
Field | Required | Type | Description |
---|---|---|---|
paymentId | true | String | Clover-assigned universally unique identifier (UUID) of the payment, to which the tip is added. Minimum and Maximum length: 13 characters Note: The paymentId displays in the Payment details in PayResponse for which a successful Auth/pre-auth PayRequest was sent. |
tip | true | Int64 | Tip amount in cents. Format: Cents; cannot be a negative or zero value. Maximum amount = 999999999 |
CaptureRequest fields
Field | Required | Type | Description |
---|---|---|---|
paymentId | true | String | Clover-assigned universally unique identifier (UUID) of the payment, to which the tip is added. Minimum and Maximum length: 13 characters Note: The paymentId displays in the Payment details in PayResponse for which a successful auth/pre-auth PayRequest was sent. |
amount | true | Int64 | Total amount payment from pre-auth transaction in cents including taxes. Format: Cents; cannot be a negative value. Maximum amount = 999999999. |
tipAmount | true | Int64 | Tip amount in cents. Format: Cents; cannot be a negative or zero value. Maximum amount = 999999999. |
Android
TipAdjust
To adjust a tip for an open auth or pre-auth payment, enter values in the tipAdjust request parameters. See TipAdjustRequest.
The following are the response scenarios for the TipAdjustState
:
- Successful request returns the
OnComplete
state. - Invalid input error returns the
OnError
state with aGenericTransactionError
.
TipAdjust request example
fun tipAdjust(request: TipAdjustRequest): Flow<TipAdjustState>
lifecycleScope.launch {
val request = TipAdjustRequest(
tip = tipAmount,
paymentId = paymentId
)
goSdk.tipAdjust(
request
).collectLatest { tipAdjustState ->
when(tipAdjustState) {
is TipAdjustState.OnError -> {
println("Tip adjust failed: ${tipAdjustState.error}")
updateUI(tipAdjustState)
}
is TipAdjustState.OnComplete -> {
println("Tip adjust succeeded: ${tipAdjustState.response}")
updateUI(tipAdjustState)
}
else -> {
//Something unexpected happened
}
}
}
}
Capture
After a pre-auth is tipAdjusted, capture all the pre-auth payment(s).
To capture a pre-auth payment, enter values in the CaptureRequest parameters. See CaptureRequest.
The following are the response scenarios for the CaptureState
:
-
Successful request returns the
OnComplete
state with a Payment object. -
Invalid input error returns the
OnError
state with aGenericTransactionError
.
Capture example
fun capture(request: CaptureRequest): Flow<CaptureState>
lifecycleScope.launch {
val request = TipAdjustRequest(
tip = tipAmount,
paymentId = paymentId
)
goSdk.tipAdjust(
request
).collectLatest { tipAdjustState ->
when(tipAdjustState) {
is TipAdjustState.OnError -> {
println("Tip adjust failed: ${tipAdjustState.error}")
updateUI(tipAdjustState)
}
is TipAdjustState.OnComplete -> {
println("Tip adjust succeeded: ${tipAdjustState.response}")
updateUI(tipAdjustState)
}
else -> {
//Something unexpected happened
}
}
}
}
iOS
TipAdjust
To adjust a tip for an open auth or pre-auth payment, enter values in the tipAdjust
request parameters. See TipAdjustRequest.
The following are the response scenarios for the TipAdjustState
:
- Successful request returns the
.success
result and theTipAdjustResponse
. - Invalid input error returns the
.failure
result and aCLVGoError
.
TipAdjust example
let tipRequest = TipAdjustRequest(tip: 400, paymentId: "123456789ABCD")
do {
let tipAdjustResponse = try await CloverPaymentSDK.shared.tipAdjust(tipAdjustRequest:tipRequest)
print("Tip adjust successful")
} catch {
print("Tip adjust failure: \(error)")
}
Capture
To capture a pre-auth payment, enter values in the CaptureRequest parameters. See CaptureRequest.
Note: You can add tipAmount
optionally at the time of capture. See TipCapture example . You can also request an independent tip adjustment after capture but before closeout. See TipAdjust example.
The following are the response scenarios for the CaptureState
:
-
Successful request returns a
.success
result withCaptureResponse
. -
Invalid input error returns a
.failure
result and aCLVGoError
.
Capture example
var captureRequest = CaptureRequest(amount: 2000, paymentId: "123456789ABCD")
do {
let captureResponse = try await CloverPaymentSDK.shared.capture(captureRequest: captureRequest)
print("Capture successful")
} catch {
print("Capture failure: \(error)")
}
Updated 6 months ago