collectPaymentMethod
suspend fun Terminal.collectPaymentMethod(intent: PaymentIntent, config: CollectPaymentIntentConfiguration = CollectPaymentIntentConfiguration.Builder().build()): PaymentIntent
Return
The PaymentIntent with the collected payment method
Parameters
intent
The PaymentIntent to collect a payment method for
config
Configuration for the collection process
See also
Collects a payment method for a PaymentIntent.
This suspend function wraps Terminal.collectPaymentMethod 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.collectPaymentMethod(paymentIntent, config)
// Handle successful collection
} catch (e: TerminalException) {
// Handle collection failure
}
}
// Cancelling the job will cancel the collect operation
job.cancel()Content copied to clipboard
Throws
if the collection operation fails