Widget Creation
Given below are the integration steps to embed the widget in your website.
Web Widget integration involves the inclusion of three HTML tag.
1.JS File
2. Widget Location
3. Initialiser file (Base)
Parameter | Sample Value | Remarks |
---|---|---|
elementId | "widget" | Mandatory (It should be an id of an element not a class), the name given in step 2 for id |
apiKey | "{api_key}" | Mandatory, this you will get from dashboard post registration |
environment | "staging" | "staging" for test environment "production" for prod environment |
fiatType | "inr" | Optional , fiat currency needed "inr" or "php" |
walletAddress | "0xEcc24eab0fb83Ef0c536b35C44C578F750FDBB6E" | Optional , the wallet address to which tokens to be transferred. this can be set within script code or can be passed as paramerter with url while initiating the widget. |
fiatAmount | 100 | Optional , the amount for which you need to buy token. |
userEmail | Optional , the email ID of the user. | |
chainId | "80001" | Optional, the block chain ID in which the token is present. example: 80001 for polygon testnet |
tokenAddress | "0xEcc24eab0fb83Ef0c536b35C44C578F750FDBB6E" | Optional, the address for the required token, this can be fetched from respective chains data. if you are passing chainID, then tokenAddress or tokenSymbol one of them is need to show specific token or else all tokens from that chain will be displayed to users. |
tokenSymbol | "USDT" | token Symbol as per standards. you can get it from coingecko or coinmarketcap |
metaData | { "userID" : "ABCXXXX", "userName" : "user", .. .. } | Optional, metaData is any extra data that user wants to send along with webhook events in the order. Note: metaData should be sent in key value pairs of strings only , you need to stringify whole value object like below "metaData": JSON.stringify({"userID":"ABCXXXX", "userName":"user"}) |
successRedirectUrl | Optional, successRedirectUrl is the url to which the widget will redirect on successful order completion Note: successRedirectUrl should always start with http or https
| |
failureRedirectUrl | Optional, failureRedirectUrl is the url to which the widget will redirect in case of failure Note: failureRedirectUrl should always start with http or https |
Note: By default widget will be initialised with OnRamp functionalities only. And only INR 100 is the valid amount for order creation in staging and Mumbai Matic is the only token supported for now to test the end to end onramp flow .
Widget initialisation happens when you call createWidget.init(); and all the respective events are notified back to the parent and once can handle event based actions respectively by passing the callbackFn names to the events like this createWidget.on(eventType, callbackFn);
callbackFn - Its the function you have to pass along with the eventType. This function will get called when the event is fired.
Define two variables one for html content and one for javascript content
Below are the eventTypes and its description.
Events | Description |
---|---|
ALL_EVENTS | this will listen to all the events of the widget and notify the callback function once event is triggered. |
SUCCESS | this will listen to the success event of the widget |
FAILED | this will listen to the failed event of the widget. |
ORDER_EVENTS | this will listen to the order related events. |
ORDER_COMPLETED_EVENTS | this will listen to order completed events. |
ACTION_EVENTS | this will listen to action events. |
Below is the validation for UTR length , on staging use any random character with below validation.
- UPI Payment - 12 character Numbers
- IMPS payment - 12 character Numbers
- NEFT payment - 16 character alphanumeric