KriptoRamp / KriptoAPI
  • Getting started
    • Introduction
    • Use cases 📖
      • Fiat<>Crypto Onramp
      • Fiat<>Crypto Onramp (ledger)
      • Fiat<>Crypto Onramp (Payments in Crypto)
      • NFT Checkout
      • Onramp & Offramp with Bank Wire
    • Kripto Ramp Widget and Kripto White Label get started 🏁
    • Get API keys 🔑
  • Widget (Fiat Onramp)
    • Initialise Widget
    • Load Widget
    • Widget Configuration
    • Webhooks
      • Webhook Use Cases
  • Whitelabel API (Fiat Onramp / Offramp via Bank Wire)
    • API Reference
      • Authentication
        • Login
        • Logout
      • Endpoints
        • Users
          • Create User
          • Show user
          • Update User
          • User Balance
          • Master Balance
        • Compliance
        • Payments & bank wire
          • Add Bank
          • List Bank Details
          • View Bank Details
          • Remove a Bank
          • Deposit Instructions
          • User limits
          • Withdraw
        • Crypto Exchange & Wallet
          • Pairs
          • Exchange Rate
          • Buy Order
          • Sell Order
          • Currencies
          • Transaction List
          • User Transaction List
          • Show Transaction
          • Limits minimum
    • Webhooks & Websockets
  • Supported cryptocurrencies 🌍
    • KriptoRamp
    • Kripto White Label
  • Links
    • Kriptomat.io
Powered by GitBook
On this page
  • Button example
  • Iframe example
  • Utility Window
  • Best Practices

Was this helpful?

  1. Widget (Fiat Onramp)

Load Widget

PreviousInitialise WidgetNextWidget Configuration

Last updated 2 years ago

Was this helpful?

Use the url received from

url="https://widget.kriptomat.io/?to_address=1DJ4N7mdUazDvrDe3H5eeRJtoXuAUSbTWy&amount=35&asset_type=eth&uuid=c472856c-d248-4e53-ae49-1d2f088cb732"

Url can be opened as new page, integrated within existing page in iframe or used in utility window. How to configure widget check .

Below you will find simple examples how to load widget:

Button example

This example show how to use url provided above in simple javascript onclick event to open KriptoRamp widget in new window

<button onclick="window.open('url','_blank')">KriptoRamp Widget</button>

Iframe example

This example shows how to implement iframe for KriptoRamp widget. For src parameter you use use url from response. iframe content has responsive layout so this can be used for any screen size.

<iframe src="https://widget.kriptomat.io/?to_address=1DJ4N7mdUazDvrDe3H5eeRJtoXuAUSbTWy&amount=35&asset_type=eth&uuid=c472856c-d248-4e53-ae49-1d2f088cb732" allow="camera;microphone" height="600" width="515" title="Kriptomat Widget" allow="camera;microphone"></iframe>

Following attribute allow="camera;microphone" for iframe is required to enable user to complete registration and KYC process

Utility Window

<script>

var win = window.open(url , "myWin", "toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=no, scrollbars=yes, width=515, height=600");

</script>

Best Practices

It is best to have a button that initialises the widget rather than doing it on page load, regardless of how you choose to display the widget to the user.

Additionally the below function disables the button so that only 1 widget can be called at a time, and then continually checks to see if the widget is open, if closed, enables the button again.

<script>

$(document).on("click", "buyCrypto", function() {

	var buyCryptoButton = document.getElementById("buyCrypto");	
	buyCryptoButton.disabled = true;				

	var data='id=userId&csrfToken=csrfToken';

	$.ajax({
		type:"GET",
		url:"WidgetInitialiseScript.php",
		data:data,
		success:function(url){		
			if (url == "checks failed") {
			} else {
				var win = window.open(url , "myWin", "toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=no, scrollbars=yes, width=515, height=600"); 
				
				// sets interval timer to see if the utility window is open. 
				// If it is open the interval timer continues
				// if the window has been closed, enable the button to start a new widget,
				// and clear the timer
				var interval = window.setInterval(function() {
					try {
						if (win == null || win.closed) { 
							window.clearInterval(interval);							
							buyCryptoButton.disabled = false;
						}
					}
					catch (e) {

					}
				}, 1000);
				return win;
			}
		},
		error: function(jqXHR, textStatus, errorThrown) {
		    alert("Error type" + textStatus + "occured with value " + errorThrown);
		}
	});
    return false;
});
 
</script>

Note: when using widget on page, make sure that correct is set to allow and to enable users to complete registration and KYC process

http header permission policy
camera
microphone
this page
response: