Capture and tip adjust

United States

For more information, see Supported payment methods.

Prerequisites

Before you integrate with the Go SDK, complete the following:

Field descriptions

TipAdjustRequest fields

FieldRequiredTypeDescription
paymentIdtrueStringClover-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.
tiptrueInt64Tip amount in cents.

Format: Cents; cannot be a negative or zero value.

Maximum amount = 999999999

CaptureRequest fields

FieldRequiredTypeDescription
paymentIdtrueStringClover-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.
amounttrueInt64Total amount payment from pre-auth transaction in cents including taxes.

Format: Cents; cannot be a negative value.

Maximum amount = 999999999.
tipAmounttrueInt64Tip 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 a GenericTransactionError.

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 a GenericTransactionError.

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 the TipAdjustResponse.
  • Invalid input error returns the .failure result and a CLVGoError.

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 with CaptureResponse.

  • Invalid input error returns a .failure result and a CLVGoError.

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)")
}