Accounts

Firstly, please take a look at our backend service and implement account linking as well as account information service in order to proceed further.

pageBackend

Account linking

To establish a link with an account using the kevin. mobile SDK, the initial step involves initiating account linking through the backend service integrated with kevin., and completing account linking flow by user which should subsequently provide an authCode. Upon receiving the authCode, it should be passed to the KevinPay.linkAccount() method. This method seamlessly manages the remaining steps of the account linking process and returns the linked account object.

Account linking flow that user needs to complete is contained by kevin. mobile SDK and can be found here.

class LinkAccountForPaymentsUseCase() {
    suspend fun linkAccount(authCode: String): PaymentAccount {
        val paymentAccount = KevinPay.linkAccount(authCode)
        return paymentAccount
    }
}

Setting account as default

For contactless payments to work, default payment account has to be set at all times. You can set default account as follows:

class SetAccountAsDefaultUseCase {
    fun setDefaultPaymentAccount(paymentAccount: PaymentAccount) {
        KevinPay.setDefaultPaymentAccount(paymentAccount.id)
    }
}

You can also temporarily override default selected account by calling KevinPay.setSelectedPaymentAccount(accountId). This might be useful when user wants to use different account than default just for a single payment. You can remove selected account by providing null as accountId. Selected account will always have priority over default account.

Selected account will be reset automatically when application is killed. We recommend using this only when UI is displayed to the user where he can select account and should be reset once user leaves that UI.

Manage linked accounts

kevin. mobile SDK offers convenience methods for managing accounts stored within the SDK. These methods are accessible from any part of the application after the initialisation of KevinPay.

class ManageAccountsUseCase {
    fun getPaymentAccounts(): List<PaymentAccount> {
        return KevinPay.getPaymentAccounts()
    }
    fun removePaymentAccount(paymentAccount: PaymentAccount) {
        KevinPay.removePaymentAccount(paymentAccount.id)
    }
    fun removeAllPaymentAccounts() {
        KevinPay.removeAllPaymentAccounts()
    }
    fun getDefaultPaymentAccount(): PaymentAccount {
        return KevinPay.getDefaultPaymentAccount()
    }
    fun setDefaultPaymentAccount(paymentAccount: PaymentAccount) {
        KevinPay.setDefaultPaymentAccount(paymentAccount.id)
    }
}

Last updated