External cards

The SDK allows you to work with external bank cards using CrypteriumCards class.

In this class, we have implemented several methods for cards operations:

  • The userCards method is responsible for the list of the user's cards.

  • The addCard method allows you to add a user card.

  • Specify the user's billing address using the addBillingAddressToCard method.

  • Call the verifyCardRequest method to initialize the card verification process. To buy crypto, a user's bank card must be verified. This method is a first step of verification.

  • The verifyCard method is a second step. It completes the verification of a bank card.

See more details in the description of each method.

CrypteriumCards class

CrypteriumCards class has been implemented to manage external bank cards. Initialize the CrypteriumCards object:

let cards: CrypteriumCards = CrypteriumAPI.cards()
cards: ICrypteriumCards = CrypteriumAPI.cards()

Methods

userCards

Use the userCards method to get the list of the user's cards. When you work with crypto/cards operations, call this method and choose the card you need for an operation method, for example payout.limits(). The method calls a completion closure and puts an object of CRPTUserCardsResult type as an argument of the closure.

cards.userCards(completion: (CRPTUserCardsResult) -> Void)

enum CRPTUserCardResult {
	case success([CRPTCardModel])
	case failure(CRPTError)
}
cards.userCards(completion: (CRPTUserCardsResult) -> Unit)
  
sealed class CRPTUserCardsResult {
    data class success(val cards: List<CRPTCardModel>) : CRPTUserCardsResult()
    data class failure(val error: CRPTError) : CRPTUserCardsResult()
}

CRPTUserCardsResult

The CRPTUserCardsResult object value is attached to a success or a failure case:

casevariablevariable typedescription
successcards[CRPTCardModel]array of user's cards
failureerrorCRPTErrorerror details

CRPTError

The type property of the CRPTError object may have the value below:

valuedescription
AUTHORIZATIONauthorization error
BACKENDbackend error

addCard

The addCard method has been implemented to add a user card. The card must be not expired, the card number must be of 16 digits and match Luhn algorithm (a bank card number checker). It calls a completion closure and puts an object of CRPTRateResult type as an argument of the closure.

cards.addCard(card: CRPTAddCardModel, completion: (CRPTAddCardResult) -> Void)

enum CRPTAddCardResult {
	case success([CRPTCardModel])
	case failure(CRPTError)
}
cards.addCard(card: CRPTAddCardModel, completion: (CRPTAddCardResult) -> Unit)
  
sealed class CRPTAddCardResult {
    data class success(val cards: List<CRPTCardModel>) : CRPTAddCardResult()
    data class failure(val error: CRPTError) : CRPTAddCardResult()
}

Income parameters

parameter nameparameter typedescription
cardCRPTAddCardModeluser's card to add

CRPTAddCardResult

The CRPTAddCardResult object value is attached to a success or a failure case:

casevariablevariable typedescription
successcards[CRPTCardModel]array of user's cards
failureerrorCRPTErrorerror details

CRPTError

The type property of the CRPTError object may have the value below:

valueerror description
AUTHORIZATIONauthorization error
VALIDATIONvalidation error (card is not valid or expired, digits do not match Luhn algorithm)
BACKENDbackend error

addBillingAddressToCard

if the billingAddressRequired property of CRPTCardModel object is TRUE, use the addBillingAddressToCard method to add billing address of a user to his bank card. Otherwise, the backend returns BACKEND error when a user makes a purchase with a card. The method calls a completion closure and puts an object of CRPTAddBillingAddressToCardResult type as an argument of the closure.

cards.addBillingAddressToCard(card: CRPTCardModel, address: CRPTBillingAddressModel, completion: (CRPTAddBillingAddressToCardResult) -> Void)

enum CRPTAddBillingAddressToCardResult {
	case success([CRPTCardModel])
	case failure(CRPTError)
}
cards.addBillingAddressToCard(
  			card: CRPTCardModel,
        address: CRPTBillingAddressModel,
        completion: (CRPTAddBillingAddressToCardResult) -> Unit)
  
sealed class CRPTAddBillingAddressToCardResult {
    data class success(val cards: List<CRPTCardModel>) : CRPTAddBillingAddressToCardResult()
    data class failure(val error: CRPTError) : CRPTAddBillingAddressToCardResult()
}

Income parameters

parameter nameparameter typedescription
card[CRPTCardModel]array of user's cards
addressCRPTBillingAddressModeluser's billing address

CRPTAddBillingAddressToCardResult

The CRPTAddBillingAddressToCardResult object value is attached to a success or a failure case:

casevariablevariable typedescription
successcards[CRPTCardModel]array of user's cards
failureerrorCRPTErrorerror details

CRPTError

The type property of the CRPTError object may have one of the values below:

valueerror description
AUTHORIZATIONauthorization error
VALIDATIONvalidation error
BACKENDbackend error

verifyCardRequest

To buy crypto, a user's bank card must be verified. The process of the card verification consists of two steps. First, call the verifyCardRequest method. The method gets a WebView handler as a closure. This closure returns WebView where a user enters the 3D secure code of his bank card. Second, call verifyCard method to complete verification.

The verifyCardRequest method calls a completion closure and puts an object of CRPTVerifyCardRequestResult type as an argument of the closure.

cards.verifyCardRequest(card: CRPTCardModel, cardCVV: String, webViewHandler: (WebView) -> Void, completion: (CRPTVerifyCardRequestResult) -> Void)

enum CRPTVerifyCardRequestResult {
  case success()
  case failure(CRPTError)
}
cards.verifyCardRequest(
        card: CRPTCardModel,
        cardCVV: String,
        context: Context,
        webViewHandler: (WebView) -> Unit,
        completion: (CRPTVerifyCardRequestResult) -> Unit
    ) 

class CRPTVerifyCardRequestResult {
    object success : CRPTVerifyCardRequestResult()
    data class failure(val error: CRPTError) : CRPTVerifyCardRequestResult()
}

Income parameters

parameter nameparameter typedescription
cardCRPTCardModelbank card
cardCVVStringbank card cvv

CRPTVerifyCardRequestResult

The CRPTVerifyCardRequestResult object value is attached to a success or a failure case:

casevariablevariable typedescription
success--first step of verification passed successfully
failureerrorCRPTErrorerror details

CRPTError

The type property of the CRPTError object may have one of the values below:

valueerror description
AUTHORIZATIONauthorization error
BACKENDbackend error
CANCELLEDverification cancelled

verifyCard

The verifyCard method is the second step of the bank card verification process. It completes the verification process. The first step is the verifyCardRequest method.

The verifyCard method calls a completion closure and puts an object of CRPTVerifyCardResult type as an argument of the closure.

cards.verifyCard(card: CRPTCardModel, descriptor: String, completion: (CRPTVerifyCardResult) -> Void)

enum CRPTVerifyCardResult {
	case success([CRPTCardModel])
	case failure(CRPTError)
}
cards.verifyCard(card: CRPTCardModel, descriptor: String, completion: (CRPTVerifyCardResult) -> Unit)
  
sealed class CRPTVerifyCardResult {
    data class success(val cards: List<CRPTCardModel>) : CRPTVerifyCardResult()
    data class failure(val error: CRPTError) : CRPTVerifyCardResult()
}

Income parameters

parameter nameparameter typedescription
card[CRPTCardModel]array of user's cards
descriptorStringverification info

CRPTVerifyCardResult

The CRPTVerifyCardResult object value is attached to a success or a failure case:

casevariablevariable typedescription
successcards[CRPTCardModel]array of user's cards
failureerrorCRPTErrorerror details

CRPTError

The type property of the CRPTError object may have one of the values below:

valueerror description
AUTHORIZATIONSDK authorization error
VALIDATIONvalidation error, bank card is not valid
BACKENDSDK backend error