Read a card
United States
Use the ReadCardRequestIntentBuilder
class to build an Intent to initiate an activity to read a card.
All cards are encrypted, except for:
- Non-financial cards
- Cards issued by the allowed list of bank identification numbers (BINs)
Prerequisites
- Read overview of the Clover platform.
- Create a global developer account with a default test merchant account.
- Order a Clover Developer Kit (Dev Kit) and set it up.
- Use the required Android SDK versions.
Steps
- Build a read card request.
val context = this
val intent = ReadCardRequestIntentBuilder().build(context)c
context context = this;
Intent intent = new ReadCardRequestIntentBuilder().build(context);
- Use the intent to initiate the process of the read card request.
CardOptions
The CardOptions
class provides a static method to set the supported card entry methods optionally.
Method | Description |
---|---|
Instance(cardEntryMethods : Set<CardEntryMethod> | Optional. Set the cardEntryMethods flag to create a CardOptions instance. This step is optional and limits the card entry options to:- CardReaders() - Manual() - All () |
Example—Set the card entry method for CardReaders
val builder = ReadCardRequestIntentBuilder()
val cardOptions = ReadCardRequestIntentBuilder.CardOptions.Instance(CardEntryMethod.CardReaders())
val intent = builder.cardOptions(cardOptions).build(context)
ReadCardRequestIntentBuilder builder = new ReadCardRequestIntentBuilder();
ReadCardRequestIntentBuilder.CardOptions cardOptions = ReadCardRequestIntentBuilder.CardOptions.Instance(CardEntryMethod.CardReaders());
Intent intent = builder.cardOptions(cardOptions).build(context);
Response
When the read card flow completes, the response comes through onActivityResult()
.
- For a successful request, retrieve the card details using the Intent:
ReadCardRequestIntentBuilder.Response.CARD_DATA
- For an unsuccessful request, retrieve the failure message using the Intent:
ReadCardRequestIntentBuilder.Response.FAILURE_MESSAGE
Response example
fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == READ_CARD_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
val cardDetails: PaymentRequestCardDetails = data.getParcelableExtra(Intents.EXTRA_CARD_DATA)
} else {
// read card failed, check for error
val failureMessage = data.getStringExtra(Intents.EXTRA_FAILURE_MESSAGE)
}
}
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == READ_CARD_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
PaymentRequestCardDetails cardDetails = data.getParcelableExtra(Intents.EXTRA_CARD_DATA);
} else {
// read card failed, check for error
String failureMessage = data.getStringExtra(Intents.EXTRA_FAILURE_MESSAGE);
}
}
}
Updated about 1 month ago