Fees-Included: Trade Widget setup

This page explains how to use the value from the baseAmount value retrieved from the Fees-Included approximate quote API response in the Trade Widget setup. This enables you to create Buy trades where all the fees are included in the amount the customer specified to spend.

  1. Create the Fees-Included Approximate quote for Buy trade
  2. Fetch the baseAmount value from the API response body
  3. Pass the baseAmount value in the buyAmount Trade Widget parameter (together with other parameters relevant for your setup - see Supported Trade Widget query parameters)
  4. Redirect your customer to the Trade Widget. See how to correctly embed the Trade Widget.

Example of the flow

Let's take an example of a customer who wants to buy 200 USD worth of Bitcoin with a credit card purchase. We'll go through the example by taking the above mentioned steps.

  1. Here's an example of the Fees-Included cURL API request and response from the Approximate quote endpoint:
curl --location 'https://app-api.coinify.com/partners/your-partner-UUID-here/approximate-quote?sendAmount=-200&sendCurrency=USD&quoteCurrency=BTC&transferInMedium=card&transferOutMedium=blockchain' \
--header 'Authorization: Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3Mjc4NTk3MzUsImV4cCI6MTcyNzg2MDkzNSwidWlkIjo3MTYzNiwiZXYiOmZhbHNlLCJzYyI6eyJ0XzI1OTY3IjoiKiJ9fQ.HeHn6CJBEtjm-P1MRZonbcwOTzUdZh-uugVhRR1M4ZIrrCG57-9KX2k7CRedj3E3KLYowIouFrtImw-NYGqY9g' \
--data ''
{
    "baseAmount": -193.24, //this is the value passed to the Trade Widget
    "baseCurrency": "USD",
    "sendAmount": -200,
    "sendCurrency": "USD",
    "quoteAmount": 0.00307436,
    "quoteCurrency": "BTC",
    "receiveAmount": 0.00287336, //the approximate amount the customer will receive. Usually shown to the end-user before redirection to Trade Widget.
    "receiveCurrency": "BTC",
    "transferIn": {
        "medium": "card",
        "feeAmount": 6.76,
        "currency": "USD"
    },
    "transferOut": {
        "medium": "blockchain",
        "feeAmount": 0.000201,
        "currency": "BTC"
    }
}
  1. In this example, we can see that the baseAmount value is -193.24 and baseCurrency is USD.

📘

You must omit the - (minus) sign when fetching this value and passing it to the Trade Widget URL in the next step.

  1. Here's the Trade Widget URL example with the baseAmount from the Approximate Quote being passed to thebuyAmount on the Trade Widget URL.

<iframe src="https://trade-ui.coinify.com/widget/?partnerId=24d17a54-81e6-464b-aba8-30935fc0fd3f&buyAmount=193.24...</iframe>

Full example with all the necessary iframe attributes:

`<iframe src="https://trade-ui.coinify.com/widget/?partnerId=24d17a54-81e6-464b-aba8-30935fc0fd3f&buyAmount=193.24&defaultFiatCurrency=USD&defaultCryptoCurrency=USDT&isBuyAmountFixed=true&transferInMedia=card,bank&transferOutMedia=blockchain" width="100%" height="576px" allow="camera;fullscreen;accelerometer;gyroscope;magnetometer" allowfullscreen></iframe>

Partner ID used in the example is Coinify's own test sandbox account