Payout to card

The SDK allows you to sell cryptocurrency and make a withdrawal to a bank card using a CrypteriumPayout class.

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

  • The pairs method is responsible for the list of available cryptocurrencies.

  • Once a cryptocurrency has been selected, you can use the averageRate method to get its approximate exchange rate of conversion against the euro. When selling crypto, a fee is possible. Get an estimated fee using the averageFee method.

  • The app may have sell limits. The methods averageLimits and limits return the allowed minimum and maximum of the cryptocurrency you can sell. Limits are determined by the KYC level, citizenship, and the type of a bank card.

  • Check the possibility of selling using the check method.

  • If a sale with the given parameters is possible, run the execute method to confirm the transaction.

See more details in the description of each method.


CrypteriumPayout class

The CrypteriumPayout class has been implemented for selling crypto and making a withdrawal to a bank card. To manage the process, initialize the CrypteriumPayout object:

let payout: CrypteriumPayout = CrypteriumAPI.cardsPayout()
payout: ICrypteriumPayOut = CrypteriumAPI.cardsPayout()

Methods

pairs

Use the pairs method to get the array of cryptocurrencies available for selling. The method calls a completion closure and puts an object of CRPTLoadPairsResult type as an argument of the closure.

payout.pairs(completion: (CRPTLoadPairsResult) -> Void)

enum CRPTLoadPairsResult {
	case success([CRPTCurrency])
	case failure(CRPTError)
}
payout.loadPairs(completion: (CRPTLoadPairsResult) -> Unit)

sealed class CRPTLoadPairsResult {
    data class success(val pairs: List<CRPTCurrency?>) : CRPTLoadPairsResult()
    data class failure(val error: CRPTErrorResponse) : CRPTLoadPairsResult()
}

CRPTLoadPairsResult

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

casevariablevariable typedescription
successpairs[CRPTCurrency]array of cryptocurrencies available for selling
failureerrorCRPTErrorerror details

CRPTError

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

valueerror description
AUTHORIZATIONauthorization error

averageRate

The averageRate method gives the approximate rate for the selected cryptocurrency against the euro. The method calls a completion closure and puts an object of CRPTRateResult type as an argument of the closure.

payout.averageRate(for currency: CRPTCurrency, completion: (CRPTRateResult) -> Void)

enum CRPTRateResult {
	case success(Decimal)
	case failure(CRPTError)
}
payout.averageRate(currency: CRPTCurrency, completion: (CRPTRateResult) -> Unit)

sealed class CRPTRateResult {
    data class success(val rate: BigDecimal) : CRPTRateResult()
    data class failure(val error: CRPTError) : CRPTRateResult()
}

Income parameters

parameter nameparameter typedescription
currencyCRPTCurrencycryptocurrency to sell

CRPTRateResult

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

casevariablevariable typedescription
successrateDecimalrate of cryptocurrency
failureerrorCRPTErrorerror details

CRPTError

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

valueerror description
AUTHORIZATIONauthorization error
VALIDATIONcoin is not in the list of available pairs
BACKENDbackend error

averageFee

The averageFee method is designed to get an approximate fee, when selling crypto and making a withdrawal to a bank card. To get the total amount for selling use this formula:
total amount = amount + amount * averageFee.

📘

Fee example

amount = 100 tokens
averageFee = 0.02
totalAmount = 100 + 100 * 0.02 = 102 tokens

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

payout.averageFee(for amount: Decimal, completion: (CRPTFeeResult) -> Void)

enum CRPTFeeResult {
	case success(Decimal)
	case failure(CRPTError)
}
payout.averageFee(amount: BigDecimal, completion: (CRPTFeeResult) -> Unit)
  
sealed class CRPTFeeResult {
    data class success(val rate: BigDecimal) : CRPTFeeResult()
    data class failure(val error: CRPTError) : CRPTFeeResult()
}

Income parameters

parameter nameparameter typedescription
amountDecimalamount of crypto to sell

CRPTFeeResult

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

casevariablevariable typedescription
successrateDecimalfee for transaction
failureerrorCRPTErrorerror details

CRPTError

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

valueerror description
AUTHORIZATIONauthorization error
BACKENDbackend error

averageLimits

The averageLimits method allows you to get the approximate maximum and minimum amount of the crypto a user can sell. The limits depend on the type of a user's bank card (country of residence and other conditions). Use this method to get the approximate limits when a bank card is not yet defined. It calls a completion closure and puts an object of CRPTLimitsResult type as an argument of the closure.

payout.averageLimits(for currency: CRPTCurrency, completion: (CRPTLimitsResult) -> Void)

enum CRPTLimitsResult {
	case success(CRPTLimits)
	case failure(CRPTError)
}
payout.averageLimits(completion: (CRPTLimitsResult) -> Unit)
  
sealed class CRPTLimitsResult {
    data class success(val limits: CRPTLimits) : CRPTLimitsResult()
    data class failure(val error: CRPTError) : CRPTLimitsResult()
}

Income parameters

parameter nameparameter typedescription
currencyCRPTCurrencycryptocurrency to sell

CRPTLimitsResult

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

casevariablevariable typedescription
successlimitsCRPTLimitsminimum and maximum amount
failureerrorCRPTErrorerror details

CRPTError

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

valueerror description
AUTHORIZATIONauthorization error
VALIDATIONcoin is not in the list of available pairs
BACKENDbackend error

limits

The limits method allows you to get the exact maximum and minimum amount of the crypto a user can sell. The limits depend on the type of a user's bank card (country of residence and other conditions). Use this method to get the limits when the bank card is already defined. The method calls a completion closure and puts an object of CRPTLimitsResult type as an argument of the closure.

payout.limits(for card: CRPTCardModel, currency: CRPTCurrency, completion: (CRPTLimitsResult) -> Void)

enum CRPTLimitsResult {
	case success(CRPTLimits)
	case failure(CRPTError)
}
payout.limits(card: CRPTCardModel, completion: (CRPTLimitsResult) -> Unit)
  
sealed class CRPTLimitsResult {
    data class success(val limits: CRPTLimits) : CRPTLimitsResult()
    data class failure(val error: CRPTError) : CRPTLimitsResult()
}

Income parameters

parameter nameparameter typedescription
cardCRPTCardModelbank card for withdrawal
currencyCRPTCurrencycryptocurrency to sell

CRPTLimitsResult

The CRPTLimitsResult object value is attached to success or failure case:

casevariablevariable typedescription
successlimitsCRPTLimitsminimum and maximum amount
failureerrorCRPTErrorerror details

CRPTError

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

valueerror description
AUTHORIZATIONauthorization error
VALIDATIONcoin is not in the list of available pairs
BACKENDbackend error

check

Use the check method to check if a user can sell a specific amount of cryptocurrency and make a withdrawal with a certain card. The method calls a completion closure and puts an object of CRPTPayoutCheckResult type as an argument of the closure.

payout.check(amount: Decimal, currency: CRPTCurrency, card: CRPTCardModel, completion: (CRPTPayoutCheckResult) -> Void)

enum CRPTPayoutCheckResult {
	case success()
	case failure(CRPTError)
}
payout.check(euroAmount: BigDecimal, currency: CRPTCurrency, card: CRPTCardModel, completion: (CRPTPayOutCheckResult) -> Unit)
  
sealed class CRPTPayOutCheckResult {
    object success : CRPTPayOutCheckResult()
    data class failure(val error: CRPTError) : CRPTPayOutCheckResult()
}

Income parameters

parameter nameparameter typedescription
amountDecimalamount of crypto to sell
currencyCRPTCurrencycryptocurrency to sell
cardCRPTCardModelbank card for withdrawal

CRPTPayoutCheckResult

The CRPTPayoutCheckResult object value is attached to success or failure case:

casevariablevariable typedescription
success--transaction has passed all checks and is ready for execution
failureerrorCRPTErrorerror details

CRPTError

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

valueerror description
AUTHORIZATIONauthorization error
VALIDATIONcoin is not in the list of available pairs
BACKENDbackend error
MAINTENANCEmaintenance error
UPDATEupdate error
LIMITSexceeding transaction or card limits
KYC0exceeding monthly limits, KYC0 verification required
KYC1exceeding monthly limits, KYC1 verification required
KYC2exceeding monthly limits, KYC2 verification required

execute

The execute method commits the crypto sale transaction. It calls a completion closure and puts an object of CRPTPayoutExecuteResult type as an argument of the closure.

📘

Before calling the execute method, check the possibility of selling using the check method.

payout.execute(amount: Decimal, currency: CRPTCurrency, card: CRPTCardModel, completion: (CRPTPayoutExecuteResult) -> Void)

enum CRPTPayoutExecuteResult {
	case success(CRPTTransactionStatus)
	case failure(CRPTError)
}
payout.execute(euroAmount: BigDecimal, currency: CRPTCurrency, card: CRPTCardModel, completion: (CRPTPayOutExecuteResult) -> Unit)
  
sealed class CRPTPayOutExecuteResult {
    data class success(val status: CRPTTransactionStatus) : CRPTPayOutExecuteResult()
    data class failure(val error: CRPTError) : CRPTPayOutExecuteResult()
}

Income parameters

parameter nameparameter typedescription
amountDecimalamount of crypto to sell
currencyCRPTCurrencycryptocurrency to sell
cardCRPTCardModelbank card for withdrawal

CRPTPayoutExecuteResult

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

casevariablevariable typedescription
successstatusCRPTTransactionStatustransaction status
failureerrorCRPTErrorerror details

CRPTError

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

valueerror description
AUTHORIZATIONauthorization failed
VALIDATIONthe coin is not in the list of available pairs
BACKENDbackend error
MAINTENANCEmaintenance error
UPDATEupdate error
LIMITSexceeding transaction or card limits
KYC0exceeding monthly limits, KYC0 verification required
KYC1exceeding monthly limits, KYC1 verification required
KYC2exceeding monthly limits, KYC2 verification required
AMOUNTinsufficient balance