Crypto to Fiat API Integration

6 min. readlast update: 09.22.2022

LetKnow Pay offers five types of direct integration:

  • Crypto to Fiat
  • Crypto to Crypto
  • Crypto to Crypto (Type 1)
  • Binance Pay
  • POS

All LetKnow Pay direct integrations are S2S (server-to-server). There is no check out page or a redirect URL.

Merchants integrating directly will need to customize their deposit page themselves.

In this article we will focus in Crypto to Fiat API integration. 

Crypto to Fiat

For example, If your client wants to deposit USD/EUR 100 using Bitcoin, you would make a "Get Fiat Deposit Address" request via the API:

JSON Request:

{ "currency":"BTC", "currency_receive":"USD", "receive_amount":"100.00", "reference_id": "refid_0001", "client": { "id": "client_123456", "first_name": "Phil", "last_name": "MacNeely", "email": "hmacneely5@stumbleupon.com", "address": "276 Homewood Crossing", },}

"Currency" request is any currency available via LetKnow Pay: BTC, ETH, XRP, USDT (erc20), BCH, LTC, DASH, ZCASH, TUSD, USDC, PAX, USDT TRC20, TRX, BINANCEPAY

"Currency Receive" merchant prefered settlement currency: USD or EUR. The same currency will be deposited to the trader's account. 

"Receive Amount" is an amount that the merchant sends with an API request. For example, a trader wants to deposit USD 100, the merchant will send a request "receive_amount":"100".

Client ID, firts name, last name and email are all obliagtory fields with any API request. 

Whenever a client makes a deposit, the same information is displayed in the merchant account in the transaction history. All Crypto to Fiat deposits are displayed in the merchant's transaction history as "API crypto deposit and sell".

LetKnow Pay will respond with the following API response:

{ "result": "success", "currency": "BTC", "currency_receive": "USD", "address":"r9kSGStGJxrLM8xv6aHaQg7beGjVy6ebqG", "account_id":"BTC833462YXSD8RODKTHQ9ZUJV3JGH", "reference_id":"btc-usd-1", "client": { "id": "client_123456", "first_name": "Phil", "last_name": "MacNeely", "email": "hmacneely5@stumbleupon.com", "address": "276 Homewood Crossing", }, "receive_amount":"100.00", "rate":"20,000.00", "crypto_amount":"0.005", "deposit_network_fee":"0", "qr_code":"iVBORw0KGgoAAAANSxxxxxxxxxxxxxx", "timestamp: "1603202569" }

LetKnow Pay will return, via the API, essential information which must be displayed on the deposit page to a trader, such as:

  • Address (deposit address)
  • Receive Amount (an amount confirming to a trader how much he/she wants to deposit)
  • Rate (a provisional exchange rate--the trader must be informed its a provisional exchange rate, and once crypto currency is received the confirmed exchange rate will be issued)
  • Crypto Amount (the crypto amount which must be sent by the trader to the address provided above. This amount is derived by dividing the received amount by the rate)
  • Deposit Network fee (applied to ERC20 tokens because LetKnow Pay issues one address per one client ID)
  • QR code address which you can generate via online tools

Here are examples of the deposit page:

undefined

undefined

It is up to the merchant to decide how to present the data given by the LetKnow Pay API. 

The trader who wishes to deposit cryptocurrency might send less crypto funds to a given address than intended. Possible reasons could be forgetting to add the withdrawal network fees or even intentionally sending less funds. Sending less than the required funds to is called "Underpayment". LetKnow Pay accepts underpayments, and therefore it is important to wait for a final callback from the LetKnow Pay API with the status "Success".

The "Success" status carries the final crypto amount received, the confirmed exchange rate, and the confirmed fiat amount to be deposited to the trader. 

Its is very important to note that if a trader intended to deposit USD 100 but only sent USD 50 in crypto, you must check that the final status shows "Success" from LetKnow Pay and see what the final fiat amount received was.

Here is an example of a webhook from LetKnow Pay with the "Success" status:

{ "nonce": "16037027742476", "signature": "6528ed6dcccb4f82dc57ac80b1ca946012931f704fb16332b662dc51613ccb84", "shop_id": "EjofvReMREJ4aGfYaIGuEDw5GDl8Dd", "fiat_currency": "USD", "crypto_currency": "BTC", "crypto_amount": "0.00485000", "rate": "20,120", "fiat_amount": 97.58, "fiat_amount_fee": 0.9758, "fiat_amount_without_fee": 96.60, "address": "r9kNGStGJxrQK8xv6aHaQg7beGjVy6ebmG", "account_id": "XRP8MWF62YXCG8RODKTHQ9ZUJVXJGH", "reference_id": "btc-usd-1", "client": { "id": "u1" }, "type": "receive_crypto_and_sell", "letknowpay_id": "DX7LISRL5ZEPSVECQR1X", "status": "success", "created": "2020-10-26 10:56:02", "updated": "0000-00-00 00:00:00", "timestamp": 1603702774}

In the example above, the client was suppose to send BTC 0.005 but instead sent only 0.00485. This is an example of an underpayment. However, LetKnow Pay still accepted the payment and exchanged it at the given rate when the crypto currency was received. The final amount received was BTC 0.00485. Please note, the exchange rate was higher than the exchange rate at the time the deposit was intiated, which caused the underpayment.

LetKnow Pay charges the merchant a processing fee, also known as "fiat_amount_fee". In the example above, for simplicity, the processing fee is 1%. 

The merchant can decide who pays the processing fee (merchant client or a merchant themselves). If merchant themself covers the processing fee, the trader must be credited with "fiat_amount" which is USD 97.58 in the example above. 

Please note, XRP currency also includes a destination tag. Therefore when displaying deposit details on the deposit page the merchant must include the XRP desitnation tag. Here is an example of a callback on the "Get Deposit Address" request for XRP currency:

{ "result": "success", "currency": "XRP", "currency_receive": "USD", "address":"r9kSGStGJxrLM8xv6aHaQg7beGjVy6ebqG", "crypto_destination_tag":"76959845", "account_id":"XRP833462YXSD8RODKTHQ9ZUJV3JGH", "reference_id":"xrp-usd-1", "client": { "id": "client_123456", "first_name": "Phil", "last_name": "MacNeely", "email": "hmacneely5@stumbleupon.com", "address": "276 Homewood Crossing", }, "receive_amount":"40.99", "rate":"0.24253125", "crypto_amount":"123.69995400", "deposit_network_fee":"0.02", "qr_code":"iVBORw0KGgoAAAANSxxxxxxxxxxxxxx", "timestamp: "1603202569" }

Very Important!

Each client ID receives its own unique crypto address for each cryptocurrency. Therefore, if a trader wants to repeat the deposit, the trader will see the same crypto address as before. Therefore, it is possible to receive a webhook from LetKnow Pay without a client's "Get Deposit Address" request. The deposit must be added to the trader's account. When you are making a request to LetKnow Pay, you have an option to include a Reference ID. However, it is an optional feature because if there is a deposit attempt without initiating a "Get Deposit Address" request, we call it a "multiple deposit attempt." The Reference ID will be used from the previous "Get Deposit Address" request. Therefore, it is important to map the deposits against the Client ID and the LetKnow Pay ID sent with an API webhook known as "letknowpay_id": "DX7LISRL5ZEPSVECQR1X".

LetKnow Pay also supports automatic withdrawals: fiat to crypto. 

Please note, if you used to process crypto payments with another psp provider and now use LetKnow Pay as your new crypto PSP provider, you must make sure the clients initiate a "Get Deposit Address" request before they attempt to withraw via the API. LetKnow Pay also supports manual withdrawals (available in the LetKnow Pay merchant account). 

For more details on automating withdrawals please refer to the LetKnow Pay API: https://pay.letknow.com/api/docs (available after login only)

The video below illustraits how crypto to fiat deposits work from an end user's perspective:

Was this article helpful?