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
- addCard
- addBillingAddressToCard
- [verifyCardRequest] (doc:external-cards#verifycardrequest)
- [verifyCard] (doc:external-cards#verifycard)
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:
case | variable | variable type | description |
---|---|---|---|
success | cards | [CRPTCardModel] | array of user's cards |
failure | error | CRPTError | error details |
CRPTError
The type
property of the CRPTError object may have the value below:
value | description |
---|---|
AUTHORIZATION | authorization error |
BACKEND | backend 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 name | parameter type | description |
---|---|---|
card | CRPTAddCardModel | user's card to add |
CRPTAddCardResult
The CRPTAddCardResult
object value is attached to a success or a failure case:
case | variable | variable type | description |
---|---|---|---|
success | cards | [CRPTCardModel] | array of user's cards |
failure | error | CRPTError | error details |
CRPTError
The type
property of the CRPTError object may have the value below:
value | error description |
---|---|
AUTHORIZATION | authorization error |
VALIDATION | validation error (card is not valid or expired, digits do not match Luhn algorithm) |
BACKEND | backend 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 name | parameter type | description |
---|---|---|
card | [CRPTCardModel] | array of user's cards |
address | CRPTBillingAddressModel | user's billing address |
CRPTAddBillingAddressToCardResult
The CRPTAddBillingAddressToCardResult
object value is attached to a success or a failure case:
case | variable | variable type | description |
---|---|---|---|
success | cards | [CRPTCardModel] | array of user's cards |
failure | error | CRPTError | error details |
CRPTError
The type
property of the CRPTError object may have one of the values below:
value | error description |
---|---|
AUTHORIZATION | authorization error |
VALIDATION | validation error |
BACKEND | backend 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 name | parameter type | description |
---|---|---|
card | CRPTCardModel | bank card |
cardCVV | String | bank card cvv |
CRPTVerifyCardRequestResult
The CRPTVerifyCardRequestResult
object value is attached to a success or a failure case:
case | variable | variable type | description |
---|---|---|---|
success | - | - | first step of verification passed successfully |
failure | error | CRPTError | error details |
CRPTError
The type
property of the CRPTError object may have one of the values below:
value | error description |
---|---|
AUTHORIZATION | authorization error |
BACKEND | backend error |
CANCELLED | verification 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 name | parameter type | description |
---|---|---|
card | [CRPTCardModel] | array of user's cards |
descriptor | String | verification info |
CRPTVerifyCardResult
The CRPTVerifyCardResult object value is attached to a success or a failure case:
case | variable | variable type | description |
success | cards | [CRPTCardModel] | array of user's cards |
failure | error | CRPTError | error details |
CRPTError
The type property of the CRPTError object may have one of the values below:
value | error description |
AUTHORIZATION | SDK authorization error |
VALIDATION | validation error, bank card is not valid |
BACKEND | SDK backend error |
Updated over 2 years ago