1.0.4 • Published 5 months ago

@banxa-global/js-sdk v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

Banxa official js SDK

Table of Contents

General info

The Banxa SDK is a plug and play ready to go implementation to access our services.
It allows for a simple and fast integration.

Installation

Install the package via npm

npm i @banxa-global/js-sdk 

Authentication

ApiKey and ApiSecret

While on-boarding with banxa, you will be provided with API keys and a subdomain (partnername.banxa.com),
initially these will be for the sandbox environment. Once you are done testing the implementation, you will receive the credentials to use the production environment.

Usage

Banxa.create(subdomain, apiKey, apiSecret, testMode)
Propertytyperequireddescription
subdomainstringtrueThe subdomain provided by banxa. (partnername.banxa.com)
apiKeystringtrueGiven API key
apiSecretstringtrueGiven API Secret
testModeboolfalseEnable if testing, and provide sandbox api key and secret to method
Sandbox
const subdomain = 'partner';
const sandboxApiKey = 'xxx-xxx-xxx-xxx-xxx';
const sandboxApiSecret = 'xxxx-xxxx-xxxx-xxxx';
const testMode = true;
Banxa.create(subdomain, sandboxApiKey, sandboxApiSecret, testMode)
Production
const subdomain = 'partner';
const apiKey = 'xxx-xxx-xxx-xxx-xxx';
const apiSecret = 'xxxx-xxxx-xxxx-xxxx';
Banxa.create(subdomain, apiKey, apiSecret)

Localisation

Countries

Global

Fetch all available countries

banxa.getCountries()

Result Example

[
   {
       "country_code" : "AD",
       "country_name" : "Andora"
   },
   {
       "country_code" : "AE",
       "country_name" : "United Arab Emirates"
   }
]

US States

Fetch all available US States

banxa.getUsStates()

Result Example

[
   {
       "state_code" : "AL",
       "state_name" : "Alabama"
   },
   {
       "state_code" : "AK",
       "state_name" : "Alaska"
   }
]

Currencies

Fiat

Buy order type

Fetch all available fiat currencies for buy order type.

banxa.getBuyFiatCurrencies()

Sell order type

Fetch all available fiat currencies for sell order type.

banxa.getSellFiatCurrencies()

Result Example

[
  {
      "fiat_code"   : "EUR",
      "fiat_name"   : "Euro",
      "fiat_symbol" : "€"
  },
  {
      "fiat_code"   : "GBP",
      "fiat_name"   : "British Pound Sterling",
      "fiat_symbol" : "£"
  }
]
       

Crypto

Buy order type

Fetch all cryptocurrencies for buy order type.

banxa.getBuyCryptoCurrencies()

Sell order type

Fetch all cryptocurrencies for sell-order type.

banxa.getSellCryptoCurrencies()

Result Example

[
   {
       "coin_code": "BTC",
       "coin_name": "Bitcoin",
       "blockchains": [
           {
               "code": "BTC",
               "description": "Bitcoin",
               "is_default": true
           }
       ]
   },
   {
       "coin_code": "ETH",
       "coin_name": "Ethereum",
       "blockchains": [
           {
               "code": "ETH",
               "description": "Ethereum (ERC-20)",
               "is_default": true
           },
           {
               "code": "MATIC",
               "description": "Polygon",
               "is_default": false
           }
       ]
   }
]

Payment Methods

Buy & Sell order type payment methods

Fetch all available payment providers for buy and sell order type

banxa.getAllPaymentMethods()

Result Example

[
  {
       "id"               : 6036,
       "paymentType"      : "WORLDPAYCREDIT",
       "name"             : "Visa/Mastercard",
       "description"      : "Conveniently buy digital currency using your personal VISA or MasterCard.",
       "logo_url"         : "https://cremorne.1cart.test/images/payment-providers/worldpaycredit.png",
       "status"           : "ACTIVE",
       "supported_agents" : [
           {
               "os"      : "ios",
               "browser" : "safari"
           },
           {
               "os"      : "macos",
               "browser" : "safari"
           },
           {
               "os"      : "ipados",
               "browser" : "safari"
           }
       ],
       "type"             : "FIAT_TO_CRYPTO",
       "supported_fiat"   : [
           "AED"
       ],
       "transaction_fees" : [
           {
               "fiat_code" : "AED",
               "coin_code" : "BTC",
               "fees"      : [
                   {
                       "name"   : "surcharge",
                       "amount" : 3,
                       "type"   : "fixed"
                   }
               ]
           }
       ]
   },
   {
       "id"               : 6036,
       "paymentType"      : "WORLDPAYAPPLE",
       "name"             : "Apple Pay",
       "description"      : "Conveniently buy digital currency using your Apple Pay wallet.",
       "logo_url"         : "https://cremorne.1cart.test/images/payment-providers/apple-pay.png",
       "status"           : "ACTIVE",
       "supported_agents" : [
           {
               "os"      : "ios",
               "browser" : "safari"
           },
           {
               "os"      : "macos",
               "browser" : "safari"
           },
           {
               "os"      : "ipados",
               "browser" : "safari"
           }
       ],
       "type"             : "CRYPTO_TO_FIAT",
       "supported_fiat"   : [
           "AED"
       ],
       "transaction_fees" : [
           {
               "fiat_code" : "AED",
               "coin_code" : "BTC",
               "fees"      : [
                   {
                       "name"   : "surcharge",
                       "amount" : 3,
                       "type"   : "fixed"
                   }
               ]
           }
       ]
   }
]

Buy order type payment methods

Fetch all available payment providers for buy order type

banxa.getBuyPaymentMethods(fiatCode, coinCode)
Propertytyperequireddescription
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto

Result Example

{
   "id"               : 6036,
   "paymentType"      : "WORLDPAYAPPLE",
   "name"             : "Apple Pay",
   "description"      : "Conveniently buy digital currency using your Apple Pay wallet.",
   "logo_url"         : "https://cremorne.1cart.test/images/payment-providers/apple-pay.png",
   "status"           : "ACTIVE",
   "supported_agents" : [
       {
           "os"      : "ios",
           "browser" : "safari"
       },
       {
           "os"      : "macos",
           "browser" : "safari"
       },
       {
           "os"      : "ipados",
           "browser" : "safari"
       }
   ],
   "type"             : "CRYPTO_TO_FIAT",
   "supported_fiat"   : [
       "AED"
   ],
   "transaction_fees" : [
       {
           "fiat_code" : "AED",
           "coin_code" : "BTC",
           "fees"      : [
               {
                   "name"   : "surcharge",
                   "amount" : 3,
                   "type"   : "fixed"
               }
           ]
       }
   ]
}

Sell order type payment methods

Fetch all available payment methods for sell order type

banxa.getSellPaymentMethods(coinCode, fiatCode)
Propertytyperequireddescription
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH see Crypto to get a list all available crypto
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR see Fiat to get a list all available fiats

Result Example

{
   "id"               : 6036,
   "paymentType"      : "WORLDPAYCREDIT",
   "name"             : "Visa/Mastercard",
   "description"      : "Conveniently buy digital currency using your personal VISA or MasterCard.",
   "logo_url"         : "https://cremorne.1cart.test/images/payment-providers/worldpaycredit.png",
   "status"           : "ACTIVE",
   "supported_agents" : [
       {
           "os"      : "ios",
           "browser" : "safari"
       },
       {
           "os"      : "macos",
           "browser" : "safari"
       },
       {
           "os"      : "ipados",
           "browser" : "safari"
       }
   ],
   "type"             : "FIAT_TO_CRYPTO",
   "supported_fiat"   : [
       "AED"
   ],
   "transaction_fees" : [
       {
           "fiat_code" : "AED",
           "coin_code" : "BTC",
           "fees"      : [
               {
                   "name"   : "surcharge",
                   "amount" : 3,
                   "type"   : "fixed"
               }
           ]
       }
   ]
}

Prices

Get prices for Payment Methods to obtain a payment method id for each specific fiat and coin combination. Should be called when a user requests prices by providing the cryptocurrency, fiat, and fiat amount.

(Rate limited)

Buy order types pricing

Fetch available price for buy order type for all payment method

banxa.getAllBuyPrices(
  fiatCode,
  coinCode,
  fiatAmount,
  blockchain
)
Propertydescriptionrequireddescription
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto
fiatAmountstring/numbertrueFiat amount
blockchainstringfalseBlockchain code e.g. 'ETH' or 'TRON' see Crypto to get a list all available blockchains per coin.

Fetch available price for buy order type for all payment method with coin amount

banxa.getAllBuyPricesFromCoinAmount(
  fiatCode,
  coinCode,
  coinAmount,
  blockchain
)
Propertydescriptionrequireddescription
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto
coinAmountstring/numbertrueCoin amount
blockchainstringfalseBlockchain code e.g. 'ETH' or 'TRON' see Crypto to get a list all available blockchains per coin.

Result Example

{
    "spot_price" : "1.07",
    "prices" : [
        {
            "payment_method_id" : 6047,
            "type" : "FIAT_TO_CRYPTO",
            "spot_price_fee" : "0.00",
            "spot_price_including_fee" : "1.07",
            "coin_amount" : "93.84000000",
            "coin_code" : "USDT",
            "fiat_amount" : "100.00",
            "fiat_code" : "USD",
            "fee_amount" : "0.00",
            "network_fee" : "2.37"
        },
        {
            "payment_method_id" : 6058,
            "type" : "FIAT_TO_CRYPTO",
            "spot_price_fee" : "0.00",
            "spot_price_including_fee" : "1.09",
            "coin_amount" : "93.84000000",
            "coin_code" : "USDT",
            "fiat_amount" : "100.00",
            "fiat_code" : "USD",
            "fee_amount" : "0.00",
            "network_fee" : "2.37"
        }
    ]
}

Buy order type pricing

Fetch single price for buy order type for a specific payment method

banxa.getBuyPrice(
   fiatCode,
   coinCode,
   fiatAmount,
   paymentMethodId,
   blockchain
)
Propertytyperequiredrequired
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR see Fiat to get a list all available fiats
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH see Crypto to get a list all available crypto
fiatAmountstring/numbertrueFiat amount
payment_method_idstring/numbertrueUnique ID for the payment method that you want to get prices for. see Payment Methods to get a list of payment providers.
blockchainstringfalseBlockchain code e.g. 'ETH' or 'TRON' see Crypto to get a list all available blockchains per coin.

Fetch single price for buy order type for a specific payment method with coin amount

banxa.getBuyPricesFromCoinAmount(
   fiatCode,
   coinCode,
   coinAmount,
   paymentMethodId,
   blockchain
)
Propertytyperequiredrequired
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR see Fiat to get a list all available fiats
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH see Crypto to get a list all available crypto
coinAmountstring/numbertrueCoin amount
payment_method_idstring/numbertrueUnique ID for the payment method that you want to get prices for. see Payment Methods to get a list of payment providers.
blockchainstringfalseBlockchain code e.g. 'ETH' or 'TRON' see Crypto to get a list all available blockchains per coin.

Result Example

{
    "payment_method_id" : 6058,
    "type" : "FIAT_TO_CRYPTO",
    "spot_price_fee" : "0.00",
    "spot_price_including_fee" : "1.09",
    "coin_amount" : "93.84000000",
    "coin_code" : "USDT",
    "fiat_amount" : "100.00",
    "fiat_code" : "USD",
    "fee_amount" : "0.00",
    "network_fee" : "2.37"
}

Sell order types pricing

Fetch all available prices for sell order type

banxa.getAllSellPrices(
  coinCode, 
  fiatCode, 
  coinAmount
)
Propertytyperequireddescription
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
coinAmountstring/numbertrueCrypto amount that will be used to calculate the fiat amount

Fetch all available prices for sell order type with fiat amount

banxa.getAllSellPricesFromFiatAmount(
  coinCode, 
  fiatCode, 
  fiatAmount
)
Propertytyperequireddescription
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
fiatAmountstring/numbertrueFiat amount that will be used to calculate the coin amount

Result Example

{
    "spot_price" : "1.07",
    "prices" : [
        {
            "payment_method_id" : 6045,
            "type" : "CRYPTO_TO_FIAT",
            "spot_price_fee" : "0.00",
            "spot_price_including_fee" : "32500.00",
            "coin_amount" : "0.02000000",
            "coin_code" : "BTC",
            "fiat_amount" : "BTC.00",
            "fiat_code" : "AUD",
            "fee_amount" : "0.00",
            "network_fee" : "0.00"
        },
        {
            "payment_method_id" : 6046,
            "type" : "CRYPTO_TO_FIAT",
            "spot_price_fee" : "0.00",
            "spot_price_including_fee" : "32500.00",
            "coin_amount" : "0.02000000",
            "coin_code" : "BTC",
            "fiat_amount" : "650.00",
            "fiat_code" : "AUD",
            "fee_amount" : "0.00",
            "network_fee" : "0.00"
        }
    ]
}

Sell order type pricing

Fetch single price for buy order type for a specific payment method

banxa.getSellPrice(
  coinCode, 
  fiatCode, 
  coinAmount, 
  paymentMethodId
)
Propertytyperequireddescription
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
coinAmountstring/numbertrueCrypto amount that will be used to calculate
payment_method_idstring/numbertrueUnique ID for the payment method that you want to get prices for. see Payment Methods to get a list of payment providers.

Fetch single price for buy order type for a specific payment method with fiat amount

banxa.getSellPricesFromFiatAmount(
  coinCode, 
  fiatCode, 
  fiatAmount, 
  paymentMethodId
)
Propertytyperequireddescription
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
fiatAmountstring/numbertrueFiat amount that will be used to calculate
payment_method_idstring/numbertrueUnique ID for the payment method that you want to get prices for. see Payment Methods to get a list of payment providers.

Result Example

{
    "payment_method_id" : 6033,
    "type" : "CRYPTO_TO_FIAT",
    "spot_price_fee" : "0.00",
    "spot_price_including_fee" : "1.09",
    "coin_amount" : "93.84000000",
    "coin_code" : "USDT",
    "fiat_amount" : "100.00",
    "fiat_code" : "USD",
    "fee_amount" : "0.00",
    "network_fee" : "2.37"
}

Orders

Retrieving orders

Fetch orders

Fetch all orders within a specific time range. (paginated)

banxa.getOrders(
  startDate, 
  endDate, 
  statuses, 
  perPage, 
  page, 
  accountReference
)
Propertytyperequireddescription
startDatestringtrueStart date used for filtering orders. Must be a date in the format YYYY-MM-DD.
endDatestringtrueEnd date used for filtering orders. Must be a date in the format YYYY-MM-DD.
statusesarrayfalseOne or many order statuses (see 'Available Statuses')
perPagestring/numberfalsePage size.
pagestring/numberfalsePage to retrieve.
accountReferencestringfalseCustomer reference that was passed as a parameter when creating an order. Used to retrieve all orders for a customer.
Available Statuses
pendingPayment`
waitingPayment
paymentReceived
inProgress
coinTransferred
cancelled
declined
expired
complete
refunded

Result Example

[
    {
        "id"                  : "e7f3d4e436c8925af84a391f317aaa6e",
        "account_id"          : "ebfef819583ff4573e6db307abd9c126",
        "account_reference"   : "banxa-account",
        "order_type"          : "CRYPTO-BUY",
        "ref"                 : 501903,
        "country"             : "AU",
        "fiat_code"           : "AUD",
        "fiat_amount"         : 100,
        "coin_code"           : "BTC",
        "coin_amount"         : 0.00704583,
        "wallet_address"      : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "wallet_address_tag"  : null,
        "fee"                 : 0,
        "fee_tax"             : 0,
        "payment_fee"         : 2.14,
        "payment_fee_tax"     : 0.19,
        "commission"          : 0,
        "tx_hash"             : "sync-tx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "tx_confirms"         : 10,
        "created_date"        : "01-Jul-2022",
        "created_at"          : "01-Jul-2022 07:51:18",
        "payment_type"        : "WorldPay Credit Card",
        "status"              : "complete",
        "completed_at"        : "01-Jul-2022 07:55:19",
        "merchant_fee"        : 0,
        "merchant_commission" : 0,
        "meta_data"           : null,
        "blockchain"          : {
            "code"        : "BTC",
            "description" : "Bitcoin"
        }
    },
    {
        "id"                  : "b719377e3541921297ebef33016fb068",
        "account_id"          : "ebfef819583ff4573e6db307abd9c126",
        "account_reference"   : "banxa-account",
        "order_type"          : "CRYPTO-BUY",
        "ref"                 : 501902,
        "country"             : "AU",
        "fiat_code"           : "AUD",
        "fiat_amount"         : 320,
        "coin_code"           : "BTC",
        "coin_amount"         : 0.02255405,
        "wallet_address"      : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "wallet_address_tag"  : null,
        "fee"                 : 0,
        "fee_tax"             : 0,
        "payment_fee"         : 6.83,
        "payment_fee_tax"     : 0.62,
        "commission"          : 0,
        "tx_hash"             : "sync-tx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "tx_confirms"         : 10,
        "created_date"        : "01-Jul-2022",
        "created_at"          : "01-Jul-2022 07:51:18",
        "payment_type"        : "WorldPay Credit Card",
        "status"              : "complete",
        "completed_at"        : "01-Jul-2022 07:55:19",
        "merchant_fee"        : 0,
        "merchant_commission" : 0,
        "meta_data"           : null,
        "blockchain"          : {
            "code": "BTC",
            "description": "Bitcoin"
        }
   }
]

Fetch order

Fetch single order

banxa.getOrder(orderId);
Propertydescriptionrequireddescription
orderIdstringtrueUnique ID of the order to retrieve

Result Example

{
    "id"                  : "b719377e3541921297ebef33016fb068",
    "account_id"          : "ebfef819583ff4573e6db307abd9c126",
    "account_reference"   : "banxa-account",
    "order_type"          : "CRYPTO-BUY",
    "ref"                 : 501902,
    "country"             : "AU",
    "fiat_code"           : "AUD",
    "fiat_amount"         : 320,
    "coin_code"           : "BTC",
    "coin_amount"         : 0.02255405,
    "wallet_address"      : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "wallet_address_tag"  : null,
    "fee"                 : 0,
    "fee_tax"             : 0,
    "payment_fee"         : 6.83,
    "payment_fee_tax"     : 0.62,
    "commission"          : 0,
    "tx_hash"             : "sync-tx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "tx_confirms"         : 10,
    "created_date"        : "01-Jul-2022",
    "created_at"          : "01-Jul-2022 07:51:18",
    "payment_type"        : "WorldPay Credit Card",
    "status"              : "complete",
    "completed_at"        : "01-Jul-2022 07:55:19",
    "merchant_fee"        : 0,
    "merchant_commission" : 0,
    "meta_data"           : null,
    "blockchain"          : {
        "code"        : "BTC",
        "description" : "Bitcoin"
    }
}

Creating orders

Allows your customer to create a buy or sell crypto order with Banxa. Upon success, the response will contain a checkout URL which will be unique for the order. The customer will be redirected to this URL to complete the checkout process, which will expire after 1 minute if a redirect does not occur.

When creating an order you will be required to create a BuyOrderTransaction/SellOrderTransaction/NftBuyOrderTransaction object. This object will allow you to create a transaction using a fiat amount, coin amount, or if you require both, you can specify your own amount using the createDynamic method, this will depend on your business use case.

Creating a buy order

banxa.createBuyOrder(
  buyOrderTransaction,
  returnUrlOnSuccess,
  returnUrlOnFailure,
  returnUrlOnCancelled,
  metadata,
  readOnlyAmounts,
  iframeRefererDomain,
);
Propertytyperequireddescription
buyOrderTransactionObjecttrueBuyOrderTransaction object
returnUrlOnSuccessstringtrueThe return url on success
returnUrlOnFailurestring/undefinedfalseThe return url on failure
returnUrlOnCancelledstring/undefinedfalseThe return url on cancelled
metadatastring/undefinedfalseFree form string that you can use to send us any information that will be returned in the Get Orders endpoint
readOnlyAmountsbooleanfalseWill cause the cryptocurrency and fiat amounts on the Banxa screens to be read-only and un-editable.
iframeRefererDomainstring/undefinedfalseUsed if you are embedding an iFrame. This must be the exact domain where the iFrame will be hosted. e.g. yourCompany.com. Do not include https:// in front of the domain.

BuyOrderTransaction using Fiat as base amount

const buyOrderTransaction = BuyOrderTransaction.createFromFiatAmount(
      accountReference, 
      fiatCode, 
      coinCode, 
      fiatAmount, 
      walletAddress, 
      paymentMethodId
  );
Propertytyperequireddescription
accountReferencestringtrueThe customer's unique ID
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto
fiatAmountstring/numbertrueFiat amount
walletAddressstringtrueThe target wallet address to transfer the coin to
paymentMethodIdstring/number/undefinedfalseUnique ID for the payment method that you want to get prices for. see Payment Methods to get a list of payment providers.
blockchainstring/undefinedfalseBlockchain code, the list of available blockchains per coin @see Crypto for all available blockchains per coin
walletAddressTagstring/undefinedfalseWallet tag or memo associated with the wallet address. Should be sent for buy cryptocurrency orders only for BNB (Memo) or XRP (Tag).

BuyOrderTransaction using Coin as base amount

 const buyOrderTransaction = BuyOrderTransaction.createFromCoinAmount(
      accountReference, 
      fiatCode, 
      coinCode, 
      coinAmount, 
      walletAddress, 
      paymentMethodId
  );
Propertytyperequireddescription
accountReferencestringtrueThe customer's unique ID
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto
coinAmountstring/numbertrueThe coin amount
walletAddressstringtrueThe target wallet address to transfer the coin to
paymentMethodIdstring/number/undefinedfalseUnique ID for the payment method that you want to get prices for. see Payment Methods to get a list of payment providers.
blockchainstring/undefinedfalseBlockchain code, the list of available blockchains per coin @see Crypto for all available blockchains per coin
walletAddressTagstring/undefinedfalseWallet tag or memo associated with the wallet address. Should be sent for buy cryptocurrency orders only for BNB (Memo) or XRP (Tag).

BuyOrderTransaction using dynamic sourceAmount or targetAmount

When using BuyOrderTransaction.createDynamic you will need to specify source(Fiat), target(Coin), and either sourceAmount or targetAmount

  const buyOrderTransaction = BuyOrderTransaction.createDynamic(
      accountReference, 
      source, 
      target, 
      sourceAmount, 
      targetAmount, 
      walletAddress, 
      refundAddress, 
      paymentMethodId, 
      blockchain, 
      walletAddressTag
  );
Propertytyperequireddescription
accountReferencestringtrueThe customer's unique ID
sourcestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
targetstringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto
sourceAmountstring/number/undefinedtrueSource amount - null if targetAmount is set
targetAmountstring/number/undefinedtrueTarget amount - null if sourceAmount is set
walletAddressstring/undefinedtrueThe target wallet address to transfer the coin to - For Buy orders only
refundAddressstring/undefinedtrueThe refund wallet address - For sell orders only
paymentMethodIdstring/number/undefinedfalseUnique ID for the payment method that you want to get prices for. see Payment Methods to get a list of payment providers.
blockchainstring/undefinedfalseBlockchain code, the list of available blockchains per coin @see Crypto for all available blockchains per coin
walletAddressTagstring/undefinedfalseWallet tag or memo associated with the wallet address. Should be sent for buy cryptocurrency orders only for BNB (Memo) or XRP (Tag).

Buy order full example

const buyOrderTransaction = BuyOrderTransaction.createFromFiatAmount(accountReference, fiatCode, coinCode, fiatAmount, walletAddress, paymentMethodId, blockchain, walletAddressTag);// From Fiat Amount
const buyOrderTransaction = BuyOrderTransaction.createFromCoinAmount(accountReference, fiatCode, coinCode, coinAmount, walletAddress, paymentMethodId, blockchain, walletAddressTag);// From Coin Amount
const buyOrderTransaction = BuyOrderTransaction.createDynamic(accountReference, source, target, sourceAmount, null, walletAddress, null, paymentMethodId, blockchain, walletAddressTag); // Dynamic
const buyOrderTransaction = BuyOrderTransaction.createDynamic(accountReference, source, target, null, targetAmount, walletAddress, null, paymentMethodId, blockchain, walletAddressTag); // Dynamic
banxa.createBuyOrder(
    buyOrderTransaction,
    returnUrlOnSuccess,
    returnUrlOnFailure,
    returnUrlOnCancelled,
    metadata,
    readOnlyAmounts,
    iframeRefererDomain,
    );

Result Example

{
   "id"                : "b890df4aee4583a25ca8da17eb863c81",
   "account_id"        : "3ec8d3c67617af11d84a18931c4e369d",
   "account_reference" : "banxa-test-01",
   "order_type"        : "CRYPTO-BUY",
   "fiat_code"         : "AUD",
   "fiat_amount"       : 1,
   "coin_code"         : "BTC",
   "wallet_address"    : "1LbQ1WNTsm1Nzj1hbh3WDCbEim1oUg5rfi",
   "blockchain"        : {
       "id"          : 1,
       "code"        : "BTC",
       "description" : "Bitcoin"
   },
   "created_at"        : "17-Aug-2022 00:09:03",
   "checkout_url"      : "https://your-return-url"
}

Creating a NFT buy order

banxa.createNftBuyOrder(
  nftBuyOrderTransaction,
  nftData,
  returnUrlOnSuccess,
  returnUrlOnFailure,
  returnUrlOnCancelled,
  iframeRefererDomain
);
Propertytyperequireddescription
nftBuyOrderTransactionObjecttrueNftBuyOrderTransaction object
nftDataObjecttrueNftData object
returnUrlOnSuccessstringtrueThe return url on success
returnUrlOnFailurestring/undefinedfalseThe return url on failure
returnUrlOnCancelledstring/undefinedfalseThe return url on cancelled
iframeRefererDomainstring/undefinedfalseUsed if you are embedding an iFrame. This must be the exact domain where the iFrame will be hosted. e.g. yourCompany.com. Do not include https:// in front of the domain.

NftBuyOrderTransaction

const nftBuyOrderTransaction = NftBuyOrderTransaction.create(
       accountReference,
       fiatCode,
       coinCode,
       fiatAmount,
       walletAddress,
       paymentMethodId,
       blockchain,
       walletAddressTag
  );
Propertytyperequireddescription
accountReferencestringtrueThe customer's unique ID
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto
fiatAmountstring/numbertrueFiat amount
walletAddressstringtrueThe target wallet address to transfer the coin to
paymentMethodIdstring/number/undefinedfalseUnique ID for the payment method that you want to get prices for. see Payment Methods to get a list of payment providers.
blockchainstring/undefinedfalseBlockchain code, the list of available blockchains per coin @see Crypto for all available blockchains per coin
walletAddressTagstring/undefinedfalseWallet tag or memo associated with the wallet address. Should be sent for buy cryptocurrency orders only for BNB (Memo) or XRP (Tag).

NftData

 const nftData = NftData.create(
      purchaseReference, 
      nft, 
      metaData
  );
Propertytyperequireddescription
purchaseReferencestringtrueA reference of the purchase
nftObjecttrueNft object
metaDataarrayfalseArray of metaData

Nft

  const nft = Nft.create(
      name, 
      collection, 
      nftMedia,
  );
Propertytyperequireddescription
namestringtrueThe name of the NFT
collectionstringtrueThe Collection the NFT
nftMediaobjecttrueNftMedia object

Create VideoNftMedia

  const nftMedia = VideoNftMedia.create(link);

Create ImageNftMedia

  const nftMedia = ImageNftMedia.create(link);
Propertytyperequireddescription
linkstringtrueA link to the Nft video

Nft buy order full example

const nftBuyOrderTransaction = NftBuyOrderTransaction.create(
     accountReference, 
     fiatCode, 
     coinCode, 
     fiatAmount, 
     walletAddress, 
     paymentMethodId, 
     blockchain, 
     walletAddressTag
  );


  const nftMedia = ImageNftMedia.create(link); // OR nftMedia = VideoNftMedia.create(link)


  const nft = Nft.create(
      name, 
      collection, 
      nftMedia,
  );

 const nftData = NftData.create(
      purchaseReference, 
      nft, 
      metaData
  );

  banxa.createNftBuyOrder(
      nftBuyOrderTransaction,
      nftData,
      returnUrlOnSuccess,
      returnUrlOnFailure,
      returnUrlOnCancelled,
      iframeRefererDomain,
    );

Result Example

{
   "id"                : "b890df4aee4583a25ca8da17eb863c81",
   "account_id"        : "3ec8d3c67617af11d84a18931c4e369d",
   "account_reference" : "Banxa-Testing-01",
   "order_type"        : "NFT-BUY",
   "blockchain"        : {
       "id"          : 1,
       "code"        : "ETH",
       "description" : "Ethereum (ERC-20)"
   },
   "created_at"        : "17-Aug-2022 00:09:03",
   "checkout_url"      : "https://your-return-url"
}

Creating a Sell order

banxa.createSellOrder(
  sellOrderTransaction,
  returnUrlOnSuccess,
  returnUrlOnFailure,
  returnUrlOnCancelled,
  metadata,
  readOnlyAmounts,
  iframeRefererDomain,
)
Propertytyperequireddescription
sellOrderTransactionObjecttrueSellOrdertransaction object
returnUrlOnSuccessstringtrueThe return url on success
returnUrlOnFailurestring/undefinedfalseThe return url on failure
returnUrlOnCancelledstring/undefinedfalseThe return url on cancelled
metadatastring/undefinedfalseFree form string that you can use to send us any information that will be returned in the Get Orders endpoint
readOnlyAmountsbooleanfalseWill cause the cryptocurrency and fiat amounts on the Banxa screens to be read-only and un-editable.
iframeRefererDomainstring/undefinedfalseUsed if you are embedding an iFrame. This must be the exact domain where the iFrame will be hosted. e.g. yourCompany.com. Do not include https:// in front of the domain.

SellOrderTransaction using Fiat as base amount

const sellOrderTransaction = SellOrderTransaction.createFromFiatAmount(
      accountReference, 
      fiatCode, 
      coinCode, 
      fiatAmount, 
      refundAddress, 
      paymentMethodId,
      blockchain,
      walletAddressTag,
);
Propertytyperequireddescription
accountReferencestringtrueThe customer's unique ID
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto
fiatAmountstring/numbertrueFiat amount
refundAddressstringtrueThe refund wallet address if the order gets rejected
paymentMethodIdstring/number/undefinedfalseUnique ID for the payment method that you want to get prices for. see Payment Methods to get a list of payment providers.
blockchainstring/undefinedfalseBlockchain code, the list of available blockchains per coin @see Crypto for all available blockchains per coin
walletAddressTagstring/undefinedfalseWallet tag or memo associated with the wallet address. Should be sent for buy cryptocurrency orders only for BNB (Memo) or XRP (Tag).

sellOrderTransaction using Coin as base amount

const sellOrderTransaction = SellOrderTransaction.createFromCoinAmount(
      accountReference, 
      fiatCode, 
      coinCode, 
      coinAmount, 
      refundAddress, 
      paymentMethodId,
      blockchain,
      walletAddressTag,
  );
Propertytyperequireddescription
accountReferencestringtrueThe customer's unique ID
fiatCodestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
coinCodestringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto
coinAmountstring/numbertrueThe coin amount
refundAddressstringtrueThe refund wallet address if the order gets rejected
paymentMethodIdstring/number/undefinedfalseUnique ID for the payment method that you want to get prices for. see Payment Methods to get a list of payment providers.
blockchainstring/undefinedfalseBlockchain code, the list of available blockchains per coin @see Crypto for all available blockchains per coin
walletAddressTagstring/undefinedfalseWallet tag or memo associated with the wallet address. Should be sent for buy cryptocurrency orders only for BNB (Memo) or XRP (Tag).

sellOrderTransaction using dynamic sourceAmount or targetAmount

When using SellOrderTransaction.createDynamic you will need to specify source(Fiat), target(Coin), and either sourceAmount or targetAmount

const sellOrderTransaction = SellOrderTransaction.createDynamic(
      accountReference, 
      source, 
      target, 
      sourceAmount, 
      targetAmount, 
      walletAddress, 
      refundAddress, 
      paymentMethodId, 
      blockchain, 
      walletAddressTag
  );
Propertytyperequireddescription
accountReferencestringtrueThe customer's unique ID
sourcestringtrueFiat code e.g. 'USD' or 'EUR' see Fiat to get a list all available fiats
targetstringtrueCoin code e.g. 'BTC' or 'ETH' see Crypto to get a list all available crypto
sourceAmountstring/number/undefinedtrueSource amount - null if targetAmount is set
targetAmountstring/number/undefinedtrueTarget amount - null if sourceAmount is set
walletAddressstring/undefinedtrueThe target wallet address to transfer the coin to - For Buy orders only
refundAddressstring/undefinedtrueThe refund wallet address - For sell orders only
paymentMethodIdstring/number/undefinedfalseUnique ID for the payment method that you want to get prices for. see Payment Methods to get a list of payment providers.
blockchainstring/undefinedfalseBlockchain code, the list of available blockchains per coin @see Crypto for all available blockchains per coin
walletAddressTagstring/undefinedfalseWallet tag or memo associated with the wallet address. Should be sent for buy cryptocurrency orders only for BNB (Memo) or XRP (Tag).

Sell order full example

const sellOrderTransaction = SellOrderTransaction.createFromFiatAmount(accountReference, fiatCode, coinCode, fiatAmount, refundAddress, paymentMethodId, blockchain, walletAddressTag);// From Fiat Amount
const sellOrderTransaction = SellOrderTransaction.createFromCoinAmount(accountReference, fiatCode, coinCode, coinAmount, refundAddress, paymentMethodId, blockchain, walletAddressTag);// From Coin Amount
const sellOrderTransaction = SellOrderTransaction.createDynamic(accountReference, source, target, sourceAmount, null, null, refundAddress, paymentMethodId, blockchain, walletAddressTag); // Dynamic
const sellOrderTransaction = SellOrderTransaction.createDynamic(accountReference, source, target, null, targetAmount, null, refundAddress, paymentMethodId, blockchain, walletAddressTag); // Dynamic
banxa.createSellOrder(
   sellOrderTransaction,
   returnUrlOnSuccess,
   returnUrlOnFailure,
   returnUrlOnCancelled,
   metadata,
   readOnlyAmounts,
   iframeRefererDomain,
);

Result Example

{
   "id"                : "b890df4aee4583a25ca8da17eb863c81",
   "account_id"        : "3ec8d3c67617af11d84a18931c4e369d",
   "account_reference" : "banxa-test-01",
   "order_type"        : "CRYPTO-SELL",
   "fiat_code"         : "AUD",
   "fiat_amount"       : 1,
   "coin_code"         : "BTC",
   "wallet_address"    : "1LbQ1WNTsm1Nzj1hbh3WDCbEim1oUg5rfi",
   "blockchain"        : {
       "id"          : 1,
       "code"        : "BTC",
       "description" : "Bitcoin"
   },
   "created_at"        : "17-Aug-2022 00:09:03",
   "checkout_url"      : "https://your-return-url"

}

Confirm sell order

Once the coin amount transfer for a Sell Order has been executed,
Banxa must be notified by sending a request to this endpoint with transaction hash, source and destination wallet address details.

banxa.confirmSellOrder(
      orderId,
      txHash,
      sourceAddress,
      destinationAddress,
      sourceAddressTag,
      destinationAddressTag
)
Propertytyperequireddescription
orderIdstringtrueUnique ID for the the order
txHashstringtrueBlockchain transaction hash of the order
sourceAddressstringtrueThe provided customer's source wallet address
destinationAddressstringtrueThe wallet address provided to merchants to transact to
sourceAddressTagstring/undefinedfalseThe customer's source wallet address tag if the provided source wallet address requires it
destinationAddressTagstring/undefinedfalseThe wallet address tag provided to merchants if the provided destination wallet address requires it

Result Example

{
    "id"                  : "ee94a43403fb608f341dd5c4c899b846",
    "account_id"          : "d6e7ab2b8f638bed61dc0ac5bec37d4d",
    "account_reference"   : "banxa-account",
    "order_type"          : "CRYPTO-SELL",
    "payment_type"        : "CLEARJCNSELLFP",
    "ref"                 : 507000,
    "fiat_code"           : "AUD",
    "fiat_amount"         : 100,
    "coin_code"           : "BTC",
    "coin_amount"         : 0.00286436,
    "wallet_address"      : null,
    "wallet_address_tag"  : null,
    "fee"                 : 9.1,
    "fee_tax"             : 0,
    "payment_fee"         : 0,
    "payment_fee_tax"     : 0,
    "commission"          : 0.1,
    "tx_hash"             : null,
    "tx_confirms"         : 0,
    "created_date"        : "01-Jul-2022",
    "created_at"          : "01-Jul-2022 07:51:18",
    "status"              : "in progress",
    "completed_at"        : null,
    "merchant_fee"        : 6.54,
    "merchant_commission" : 0.05,
    "meta_data"           : null,
    "blockchain"          : {
        "id"          : 1,
        "code"        : "BTC",
        "description" : "Bitcoin"
    }
}

Identity

Create Identity

Allows you to share customer details with Banxa before an Order is created.
This reduces the need for customers to re-submit personal details and upload KYC documentation during the Banxa checkout flow.
Detailed guide on how to implement this API can be found here. You can also find Testing information here

banxa.createIdentity(
  identitySharingCollection,
  customerDetails,
  customerIdentity,
  identityDocumentCollection,
  residentialAddress
)
1.0.4

5 months ago

1.0.3

8 months ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago