Here you will find a simple JS implementation of the SDK.
!function(callback){
var b=document.createElement('script'); b.type="text/javascript", b.async=!0,
b.src="https://sdk.banxa.com/js/banxa-sdk-latest.js";
var x=document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(b,x);
if(callback){b.addEventListener("load",function(){callback()})}}
(yourOnLoadFunction);Use the following snippet to create an instance of the banxa class to generate redirect and iframes.
<script>
const banxa = new Banxa();
const banxaWithPartner = new Banxa(`your-partner-name`);
</script>Use the following snippet to create an iframe:
<script>
banxa.iframe('#iframe', '#iframeTarget',
{
'fiatType': 'AUD',
'coinType': 'BTC',
'walletAddre "400px"
'fiatAmount': 200,
'coinAmount': 0.5,
},
"800px",
ss': '3Hiy7HuFcqwkgERyfRSwEHqrwSwTirm8zb',
);
</script>
<button id="iframeButton">Launch iframe</button>
<div id="iframeTarget">
<!-- Where the iframe will be loaded
-->
</div>Use the following snippet to create a redirect to the Banxa Order page:
<script>
banxa.redirect('#redirect',
{
'fiatType': 'AUD',
'coinType': 'BTC',
'fiatAmount': 500,
'coinAmount': 0.2,
'walletAddress': '3Hiy7HuFcqwkgERyfRSwEHqrwSwTirm8zb',
});
</script>
<button id="redirect">Launch Redirect</button>The follow parameters can be passed:
| URL Parameter | Description |
|---|---|
| fiatType | Fiat currency code that the customer wants to exchange e.g USD |
| fiatAmount | Fiat amount that the customer wants to exchange e.g. 500. If both a fiatAmount and coinAmount are passed, then the fiatAmount will be used |
| coinType | Coin currency code that the customer wants to exchange e.g. ETH |
| coinAmount | Coin amount that the customer wants to exchange e.g. 800. If both a fiatAmount and coinAmount are passed, then the fiatAmount will be used |
| blockchain | Blockchain network code that is selected by the customer. If this parameter is not passed, the default blockchain configured for the coinType selected will apply |
| walletAddress | Customer's wallet address |
| walletAddressTag | Customer's wallet tag or memo. This is required for transacting on certain blockchains such as BNB and XR |
| code | Only required if you implement an iFrame approach. Your unique iFrame code that Banxa has issued you with. This will return HTML that can be embedded into your site |
| sellMode | Indicates whether the customer wants to sell. The customer will be shown the Sell Order Form when they are redirected to the Banxa cart. This will depend on whether you have implemented the option to sell. If this parameter is not passed, then the order will default to buyMode |