Available operations
Buying crypto
Buy
object needs to be obtained first to start the process of buying:
Kotlin Swift
Copy val mercuryo: Mercuryo = Mercuryo. create ( .. .)
val buy: Buy = mercuryo.operations.buy
Copy var mercuryoSDK: IMercuryo = IMercuryo ( isDebug : true , baseHost : "HOST_HERE" )
var wallet = mercuryoSDK.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:
Kotlin Swift
Copy buy. convert (fromCurrency: String , toCurrency: String , amount: String ) : ConverterResult
Copy var token: String ?
buy. convert ( fromCurrency : "BTC" , toCurrency : "EUR" , amount : "1" ) { converterResult, error in
token = converterResult ? .token
//do some magic here
}
Buying
After you obtained a buying token you can call buy method passing parameters of operation.
Kotlin Swift
Copy buy. commit (cardId: String , cvv: String , buyToken: String , redirectUrl: String ): TransactionStatus
Copy var transactionID: String ?
buy.commit(cardId: "CARD_ID HERE", cvv: "CARD_CVV HERE", buyToken: token, redirectUrl: "REDIRECT_URL HERE") { transactionStatus, error in
transactionID = transactionStatus ? .id
//do some magic here
}
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.
Kotlin Swift
Copy buy.verifyDescriptor(transactionId: String, code: String): TransactionStatus
Copy buy. verifyDescriptor ( transactionId : transactionID, code : "TRANSACTION_CODE HERE" ) { transactionStatus, error in
//do some magic here
}
Getting rate for buying
User may want to know the rate of fiat-crypto conversion which may be obtained using the following method:
Kotlin Swift
Copy buy. rate (fromCurrency: String , toCurrency: String ): Rate
Copy buy. getRate ( fromCurrency : "BTC" , toCurrency : "EUR" ) { rate, error in
//do soma magic here
}
Selling process
Sell
object needs to be obtained first to start the process of buying:
Kotlin Swift
Copy val mercuryo: Mercuryo = Mercuryo. create ( .. .)
val sell: Sell = mercuryo.operations.sell
Copy var mercuryoSDK: IMercuryo = IMercuryo ( isDebug : true , baseHost : "HOST_HERE" )
var wallet = mercuryoSDK.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:
Kotlin Swift
Copy sell. convert (fromCurrency: String , toCurrency: String , amount: String ) : ConverterResult
Copy var token: String ?
sell. convert ( fromCurrency : "BTC" , toCurrency : "EUR" , amount : "1" ) { converterResult, error in
token = converterResult ? .token
//do some magic here
}
Selling
To sell you need to get token for selling first call method as shown below.
Kotlin Swift
Copy sell. commit (cardId: String , sellToken: String ): TransactionStatus
Copy sell. commit ( cardId : "CARD_ID HERE" , sellToken : token ) { transactionStatus, error in
//do some magic here
}
Getting exchange rate for selling
Rate includes a fee.
Kotlin Swift
Copy sell. rate (fromCurrency: String , toCurrency: String ): Rate
Copy sell. getRate ( fromCurrency : "BTC" , toCurrency : "EUR" ) { rate, error in
//do soma magic here
}
Withdrawal to another wallet
Withdraw
object needs to be obtained first to start the process of buying:
Kotlin Swift
Copy val mercuryo: Mercuryo = Mercuryo. create ( .. .)
val withdraw: Withdraw = mercuryo.operations.withdraw
Copy var mercuryoSDK: IMercuryo = IMercuryo ( isDebug : true , baseHost : "HOST_HERE" )
var wallet = mercuryoSDK.operations.buy
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.
Kotlin Swift
Copy withdraw. convert (fromCurrency: String , toCurrency: String , amount: String ) : ConverterResult
Copy var token: String ?
withdraw. convert ( fromCurrency : "BTC" , toCurrency : "EUR" , amount : "1" ) { converterResult, error in
token = converterResult ? .token
//do some magic here
}
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.
Kotlin Swift
Copy withdraw. getEstimateFee (currency: String , fiatCurrency: String , address: String , amount: String ): EstimateWithdrawFee
Copy var firstEstimateId: String ?
withdraw. getEstimateFee ( currency : "BTC" , fiatCurrency : "EUR" , address : "ADDRESS HERE" , amount : "1" ) { fee, error in
firstEstimateId = fee ? .fees. first ? .id
//do soma magic here
}
Make a withdrawal
Kotlin Swift
Copy withdraw. commit (currency: String , address: String , amount: String , estimateId: String ?): VerifyMetaData
Copy var nextStep: VerifyMetaData.NextStep ?
var key: String ?
withdraw.commit(currency: "BTC", address: "ADDRESS HERE", amount: "1", estimateId: firstEstimateId) { verifyData, error in
nextStep = verifyData ? .step
key = verifyData ? .key
//do some magic here
}
Withdrawal confirmation
User may need to confirm withdrawal using text message or email code.
Kotlin Swift
Copy withdraw. verify (next: VerifyMetaData .NextStep, key: String , code: String ): TransactionStatus
Copy withdraw. verify ( next : nextStep, key : key, code : "SMS/EMAIL CODE" ) { transactionStatus, error in
//do some magic here
}