swipeMagneticCard

suspend fun swipeMagneticCard(device: PaymentDevice): ForageApiResponse<MagSwipeInteraction>

Use the MagneticStrip Reader of a Worldline Ingenico PaymentDevice to read an EBT card's magnetic stripe data.

  • On success, the data property of the ForageApiResponse.Success object resolves with a MagSwipeInteraction that contains the card's track data.

  • On failure, the response includes a ForageError object that you can unpack to programmatically handle the error and display the appropriate customer-facing message.

// Example swipeMagneticCard call
val response = forageTerminalSdk.swipeMagneticCard(device)

when (response) {
is ForageApiResponse.Success -> {
val magSwipeInteraction = response.data
// Use magSwipeInteraction.track2Data for subsequent operations
}
is ForageApiResponse.Failure -> {
// Handle error response
val error = response.error
}
}

Return

A ForageApiResponse object containing either a MagSwipeInteraction on success or a ForageError on failure.

Parameters

device

A properly initialized PaymentDevice instance from the Ingenico SDK.

See also