cards

Cards SDK for Android

The Cards SDK is a solution to ease the integration with the Alviere services.

Features

Card Issuance and Management

  • Issue Card

  • Get Cards

  • Get Card

  • Update Card

  • Cancel Card

  • Activate Card

  • Freeze Card

  • Unfreeze Card

Requirements

  • Android Studio 4.0 or above

  • Android 5.0 (API level 21) or above

  • Java 8+

Integration

1. Get the latest versions of cards.aar and alcore.aar, and open up the project structure by right-clicking on your project and choosing Open Module Settings or choosing File Project Structure…. Click the + button in the top left to add a new module.

image

2. Choose Import .JAR/.AAR Package and click the Next button.

image

3. Find your cards.aar file using the folder button beside the File name field. Android Studio will automatically create a subproject name. Just click Finish and repeat the process for the alcore.aar file.

image

4. Gradle will sync, which may take a few minutes. You should have the following implementation statements on your module's build.gradle file. Please note that sometimes Android Studio generates these statements on the project's build.gradle file. In that case, move them to the module's one.

...
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
...
implementation project(path: ':alcore')
implementation project(path: ':cards')
}

5. Make sure you have enabled Java 8 language feature support. To do so, guarantee that the following configurations are on the module's build.gradle file.

...
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}

6. Now that you have added the .aar modules, you need to add its dependencies as shown below. Once complete, sync gradle again.

apply plugin: 'com.android.application'
apply plugin: 'kotlin-kapt'
...
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
...
implementation project(path: ':alcore')
implementation project(path: ':cards')
...
}

Usage

Before you can use the Cards Sdk, and if you want to call the card issuance and management services you need to first setup the environment on CardsSdk. Keep in mind that the process of setting up the environment is asynchronous, so you should set it as soon as possible.

CardsSdk.create()

Card Issuance and Management

This section outlines the integration with Alviere to issue and manage your cards.

Declare the callback

The CardsIssuanceSdkCallback callback is the main communication back channel to your application. For each action there is one method associated as follows. In addition to these methods, there is also an event method for handling events. Callbacks will always run on main thread.

private val cardsIssuanceSdkCallback = object : CardsIssuanceSdkCallback {
override fun onIssueCardSuccess(issuedCardDetails: IssuedCardDetails) { /* handle success */ }

override fun onGetCardsSuccess(issuedCardDetailsList: List<IssuedCardDetails>) { /* handle success */ }

override fun onGetCardSuccess(issuedCardDetails: IssuedCardDetails) { /* handle success */ }

override fun onUpdateCardSuccess(issuedCardDetails: IssuedCardDetails) { /* handle success */ }

override fun onCancelCardSuccess() { /* handle success */ }

override fun onActivateCardSuccess() { /* handle success */ }

override fun onFreezeCardSuccess() { /* handle success */ }

override fun onUnfreezeCardSuccess() { /* handle success */ }

override fun onEvent(event: String, metadata: Map<String, String>?) { /* handle event */ }
}
onSuccess

This callback method is called when an user has successfully issue or manage cards. Use this to issue and manage cards of a user's account with the Alviere API.

onEvent

This callback method is called when the user exited from the Cards SDK, when an error occurred, or when certain events in the Cards SDK flow have occurred. This allows your application to get more information about what is going on as the user goes through the Cards SDK flow. In case of an error, you may want to display information related to the error to the user and have them try doing the action again.

Issue Card

To issue a card, use the Cards Sdk service method CardsSdk.issueCard. Pass the session_token, the account_uuid, the IssueCardModel model and the CardsIssuanceSdkCallback.

val model = IssueCardModel( ... )
CardsSdk.issueCard(
token = session_token,
accountUuid = account_uuid,
data = model,
clientCallback = cardsIssuanceSdkCallback
)

The result of this action will return the newly created IssuedCardDetails on onIssueCardSuccess(issuedCardDetails: IssuedCardDetails) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Get Cards

To get all cards from an account, use the Cards Sdk service method CardsSdk.getCards. Pass the session_token, the account_uuid and the CardsIssuanceSdkCallback.

CardsSdk.getCards(
token = session_token,
accountUuid = account_uuid,
clientCallback = cardsIssuanceSdkCallback
)

The result of this action will return the user's account cards List<IssuedCardDetails> on onGetCardsSuccess(issuedCardDetailsList: List<IssuedCardDetails>) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Get Card

To get a card, use the Cards Sdk service method CardsSdk.getCard. Pass the session_token, the account_uuid, the card_uuid and the CardsIssuanceSdkCallback.

CardsSdk.getCard(
token = session_token,
accountUuid = account_uuid,
cardUuid = card_uuid,
clientCallback = cardsIssuanceSdkCallback
)

The result of this action will return the card of an account IssuedCardDetails on onGetCardSuccess(issuedCardDetails: IssuedCardDetails) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Update Card

To update a card, use the Cards Sdk service method CardsSdk.updateCard. Pass the session_token, the account_uuid, the card_uuid, the UpdateCardModel model and the CardsIssuanceSdkCallback.

val model = UpdateCardModel( ... )
CardsSdk.updateCard(
token = session_token,
accountUuid = account_uuid,
cardUuid = card_uuid,
data = model,
clientCallback = cardsIssuanceSdkCallback
)

The result of this action will return the updated card IssuedCardDetails on onUpdateCardSuccess(issuedCardDetails: IssuedCardDetails) and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Cancel Card

To cancel a card, use the Cards Sdk service method CardsSdk.cancelCard. Pass the session_token, the account_uuid, the card_uuid and the CardsIssuanceSdkCallback.

CardsSdk.cancelCard(
token = session_token,
accountUuid = account_uuid,
cardUuid = card_uuid,
clientCallback = cardsIssuanceSdkCallback
)

The result of this action will return on onCancelCardSuccess() and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Activate Card

To activate a card, use the Cards Sdk service method CardsSdk.activateCard. Pass the session_token, the account_uuid, the card_uuid, the ActivateCardModel model and the CardsIssuanceSdkCallback.

val model = ActivateCardModel( ... )
CardsSdk.activateCard(
token = session_token,
accountUuid = account_uuid,
cardUuid = card_uuid,
data = model,
clientCallback = cardsIssuanceSdkCallback
)

The result of this action will return on onActivateCardSuccess() and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Freeze Card

To freeze a card, use the Cards Sdk service method CardsSdk.freezeCard. Pass the session_token, the account_uuid, the card_uuid and the CardsIssuanceSdkCallback.

CardsSdk.freezeCard(
token = session_token,
accountUuid = account_uuid,
cardUuid = card_uuid,
clientCallback = cardsIssuanceSdkCallback
)

The result of this action will return on onFreezeCardSuccess() and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Unfreeze Card

To unfreeze a card, use the Cards Sdk service method CardsSdk.unfreezeCard. Pass the session_token, the account_uuid, the card_uuid and the CardsIssuanceSdkCallback.

CardsSdk.unfreezeCard(
token = session_token,
accountUuid = account_uuid,
cardUuid = card_uuid,
clientCallback = cardsIssuanceSdkCallback
)

The result of this action will return on onUnfreezeCardSuccess() and any errors will be returned on onEvent(event: String, metadata: Map<String, String>?), both from the callback.

Packages