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 theaverageFee
method. -
The app may have sell limits. The methods
averageLimits
andlimits
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
- averageRate
- averageFee
- averageLimits
- limits
- check
- [execute] (doc:pay-out#execute)
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:
case | variable | variable type | description |
success | pairs | [CRPTCurrency] | array of cryptocurrencies available for selling |
failure | error | CRPTError | error details |
CRPTError
The type
property of the CRPTError object may have the value below:
value | error description |
---|---|
AUTHORIZATION | authorization 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 name | parameter type | description |
---|---|---|
currency | CRPTCurrency | cryptocurrency to sell |
CRPTRateResult
The CRPTRateResult
object value is attached to a success or a failure case:
CRPTError
The type
property of the CRPTError object may have one of the values below:
value | error description |
---|---|
AUTHORIZATION | authorization error |
VALIDATION | coin is not in the list of available pairs |
BACKEND | backend 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 name | parameter type | description |
amount | Decimal | amount of crypto to sell |
CRPTFeeResult
The CRPTFeeResult object value is attached to a success or a failure case:
CRPTError
The type
property of the CRPTError object may have one of the values below:
value | error description |
AUTHORIZATION | authorization error |
BACKEND | backend 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 name | parameter type | description |
currency | CRPTCurrency | cryptocurrency to sell |
CRPTLimitsResult
The CRPTLimitsResult
object value is attached to a success or a failure case:
case | variable | variable type | description |
success | limits | CRPTLimits | minimum and maximum amount |
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 | coin is not in the list of available pairs |
BACKEND | backend 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 name | parameter type | description |
card | CRPTCardModel | bank card for withdrawal |
currency | CRPTCurrency | cryptocurrency to sell |
CRPTLimitsResult
The CRPTLimitsResult
object value is attached to success or failure case:
case | variable | variable type | description |
success | limits | CRPTLimits | minimum and maximum amount |
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 | coin is not in the list of available pairs |
BACKEND | backend 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 name | parameter type | description |
amount | Decimal | amount of crypto to sell |
currency | CRPTCurrency | cryptocurrency to sell |
card | CRPTCardModel | bank card for withdrawal |
CRPTPayoutCheckResult
The CRPTPayoutCheckResult
object value is attached to success or failure case:
case | variable | variable type | description |
success | - | - | transaction has passed all checks and is ready for execution |
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 | coin is not in the list of available pairs |
BACKEND | backend error |
MAINTENANCE | maintenance error |
UPDATE | update error |
LIMITS | exceeding transaction or card limits |
KYC0 | exceeding monthly limits, KYC0 verification required |
KYC1 | exceeding monthly limits, KYC1 verification required |
KYC2 | exceeding 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 name | parameter type | description |
amount | Decimal | amount of crypto to sell |
currency | CRPTCurrency | cryptocurrency to sell |
card | CRPTCardModel | bank card for withdrawal |
CRPTPayoutExecuteResult
The CRPTPayoutExecuteResult
object value is attached to a success or a failure case:
case | variable | variable type | description |
success | status | CRPTTransactionStatus | transaction status |
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 failed |
VALIDATION | the coin is not in the list of available pairs |
BACKEND | backend error |
MAINTENANCE | maintenance error |
UPDATE | update error |
LIMITS | exceeding transaction or card limits |
KYC0 | exceeding monthly limits, KYC0 verification required |
KYC1 | exceeding monthly limits, KYC1 verification required |
KYC2 | exceeding monthly limits, KYC2 verification required |
AMOUNT | insufficient balance |
Updated over 2 years ago