collectSetupIntentPaymentMethod

suspend fun Terminal.collectSetupIntentPaymentMethod(intent: SetupIntent, allowRedisplay: AllowRedisplay, config: CollectSetupIntentConfiguration = CollectSetupIntentConfiguration.Builder().build()): SetupIntent

Return

The SetupIntent with the collected payment method

Parameters

intent

The SetupIntent to collect a payment method for

allowRedisplay

Controls whether the payment method can be redisplayed for future payments

config

Configuration for the collection process

See also

Collects a payment method for a SetupIntent.

This suspend function wraps Terminal.collectSetupIntentPaymentMethod and integrates with Kotlin's structured concurrency. If the coroutine calling this function is cancelled, the underlying collect operation will automatically be cancelled as well.

Example usage:

val job = coroutineScope.launch {
try {
val intentWithPaymentMethod = terminal.collectSetupIntentPaymentMethod(
setupIntent,
AllowRedisplay.ALWAYS,
config
)
// Handle successful collection
} catch (e: TerminalException) {
// Handle collection failure
}
}

// Cancelling the job will cancel the collect operation
job.cancel()

Throws

if the collection operation fails