Operations (buy/sell/withdraw crypto)

Available operations

Buying crypto

Buy object needs to be obtained first to start the process of buying:

val mercuryo: Mercuryo = Mercuryo.create(...)  
val buy: Buy = mercuryo.operations.buy

Getting token for buying

Before buying, you need to get a unique token designated to this specific operation, for this you can use the .convert method:

buy.convert(fromCurrency: String, toCurrency: String, amount: String) : ConverterResult

Buying

After you obtained a buying token you can call buy method passing parameters of operation.

buy.commit(cardId: String, cvv: String, buyToken: String, redirectUrl: String): TransactionStatus

Confirmation of operation

To finalize an operation user may need to confirm ownership of bank account by providing a descriptor sent as a part of transaction.

buy.verifyDescriptor(transactionId: String, code: String): TransactionStatus

Getting rate for buying

User may want to know the rate of fiat-crypto conversion which may be obtained using the following method:

buy.rate(fromCurrency: String, toCurrency: String): Rate

Selling process

Sell object needs to be obtained first to start the process of buying:

val mercuryo: Mercuryo = Mercuryo.create(...)  
val sell: Sell = mercuryo.operations.sell

Getting token for selling

Before selling, you need to get a unique token designated to this specific operation, for this you can use the .convert method:

sell.convert(fromCurrency: String, toCurrency: String, amount: String) : ConverterResult

Selling

To sell you need to get token for selling first call method as shown below.

sell.commit(cardId: String, sellToken: String): TransactionStatus

Getting exchange rate for selling

Rate includes a fee.

sell.rate(fromCurrency: String, toCurrency: String): Rate

Withdrawal to another wallet

Withdraw object needs to be obtained first to start the process of buying:

val mercuryo: Mercuryo = Mercuryo.create(...)  
val withdraw: Withdraw = mercuryo.operations.withdraw

Currency converter

Before sending crypto it may be beneficial for user to know how amount converts to fiat or vice versa. Mercuryo SDK provides a method for that allowing to understand transaction better.

withdraw.convert(fromCurrency: String, toCurrency: String, amount: String) : ConverterResult

Withdrawal fees

To make withdrawal you need to obtain available blockchain fees first. In case there are no fees this method will throw an CurrencyNotSupportFeeException exception.

withdraw.getEstimateFee(currency: String, fiatCurrency: String, address: String, amount: String): EstimateWithdrawFee

Make a withdrawal

withdraw.commit(currency: String, address: String, amount: String, estimateId: String?): VerifyMetaData

Withdrawal confirmation

User may need to confirm withdrawal using text message or email code.

withdraw.verify(next: VerifyMetaData.NextStep, key: String, code: String): TransactionStatus

Last updated