Onramp API Integration.
Web hook - Onramp
5 min
this section explains the steps to configure callback urls for receiving events about the completed transaction configuring webhook webhooks are configured in merchant dashboard inside api setup section, webhook can be added and modified under callback url's section generating hmac signature is computed using hash based message authentication code (hmac) using a secret key the secret key is the api secret present in your merchant dashboard the example implementation in nodejs is show below β¬οΈ let hmac = crypto createhmac('sha256', apisecret); hmac update(json stringify(postbody)); let hash = hmac digest('hex'); assert(hash == headers\["x onmeta signature"]) tab examples url configured webhook url name completed order method post request pathparameters queryparameters headerparameters kind optional name content type t type string children description application json; charset utf 8 kind required name x onmeta signature type string children description signature of the request as computed above bodydataparameters kind required name fiat type string description fiat amount kind required name receiverwalletaddress type string children description receiver wallet address kind required name buytokensymbol type string children description token symbol ex btc usdc kind required name buytokenaddress type string children description smart contract of the token example 0x9c3c9283d3e44854697cd22d3faa240cfb032889 for wmatic kind required name orderid type string children description order id unique for a given id kind required name status type string children description order status completed kind required name currency type string children description currency type example inr kind required name chainid type number children description block chain id example 80001 for polygon testnet kind required name customer type object children kind required name id type string description customer id kind required name email type string description customer email id kind required name phone type string description customer phone number kind required name created at type string description order created time description kind required name txnhash type string children description transaction hash for completed order kind required name transferredamount type string children description quantity of crypto tokens transferred kind required name transferredamountwei type string children description transferredamount in gwei kind required name createdat type string children description created time kind required name eventtype type string children description onramp offramp formdataparameters results languages id npjymzyxxlvcqvch6ejqj code language 200 customlabel id ukb mialynbkxyqiyez9n code language 404 customlabel selectedlanguageid npjymzyxxlvcqvch6ejqj examples languages id gll1chxfh1fa6hychiadp code curl location g request post configured webhook url n header accept application json n header content type string n header x onmeta signature string n data raw fiat string receiverwalletaddress string buytokensymbol string buytokenaddress string orderid string status string currency string chainid number customer object txnhash string transferredamount string transferredamountwei string createdat string language curl customlabel id 6kaniwwqdkg3jdgs6bw8 code var request require request ; nvar options n method post n url configured webhook url n headers n accept application json n content type string n x onmeta signature string n n body fiat string receiverwalletaddress string buytokensymbol string buytokenaddress string orderid string status string currency string chainid number customer object txnhash string transferredamount string transferredamountwei string createdat string n n ; nrequest options function error response n if error throw new error error ; n console log response body ; n ; n language nodejs customlabel id aexbmpycp3g1i djcbg8f code var myheaders new headers ; nmyheaders append accept application json ; nmyheaders append content type string ; nmyheaders append x onmeta signature string ; n nvar raw fiat string receiverwalletaddress string buytokensymbol string buytokenaddress string orderid string status string currency string chainid number customer object txnhash string transferredamount string transferredamountwei string createdat string ; n nvar requestoptions n method post n headers myheaders n body raw n redirect follow n ; n nfetch configured webhook url requestoptions n then response response text n then result console log result n catch error console log error error ; language javascript customlabel id vsqhbluqchzymu3t2h4qi code import requests n nurl configured webhook url n npayload fiat string receiverwalletaddress string buytokensymbol string buytokenaddress string orderid string status string currency string chainid number customer object txnhash string transferredamount string transferredamountwei string createdat string nheaders n accept application json n content type string n x onmeta signature string n n nresponse requests request post url headers headers data payload n nprint response text n language python customlabel id qiv52qtjpeaeaegvun0pw code require uri nrequire net http n nurl uri configured webhook url n nhttp net http new url host url port ; nrequest net http post new url nrequest accept application json nrequest content type string nrequest x onmeta signature string nrequest body fiat string receiverwalletaddress string buytokensymbol string buytokenaddress string orderid string status string currency string chainid number customer object txnhash string transferredamount string transferredamountwei string createdat string n nresponse http request request nputs response read body n language ruby customlabel selectedlanguageid 6kaniwwqdkg3jdgs6bw8 description this callback will be triggered when the crypto coins are deposited to the given receiver address will use the configured webhook url to send order completed details in post body n currentnewparameter label body parameter value bodydataparameters eventtype will be onramp for this order make sure you have firewall rule allowed for receiving the webhook body if not your firewall might block our webhook requests sample body { "fiat" 100, "receiverwalletaddress" "0x14o2422324232323232323232232", "buytokensymbol" "matic", "buytokenaddress" "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "orderid" "63c93f0ffa666e128b7ab131", "status" "completed", "currency" "inr", "chainid" 80001, "customer" { "id" "63aaedf35b07a87b1f912023", "email" "test\@test com", "phone" { }, "created at" "2022 12 27t13 06 59 068z" }, "createdat" "2023 01 19t13 01 03 289z", "txnhash" "0xae21ff484bd2d05d22f6 7d1f795e9e09cda97b4d522", "transferredamount" "0 01", "transferredamountwei" "10000000000000000", "eventtype" "onramp", "metadata" "metadata" { "conversionrate" "90 2", "commission" "0" } } transferredamount and transferredamountwei will be sent in fiatpending and completed state conversionrate and commission is sent inside the metadata along with user set metadata (if any) in the completed state webhook events onramp webhook events onmeta provides six types of webhook events that allow you to receive real time notifications when specific events occur during the onramp flow \# eventname description 1 fiatpending this event is triggered when a user has initialised an order but fiat deposit from user is pending 2 orderreceived this event is triggered when a user completes payment and onmeta has initiated the crypto transfer 3 inprogress (optional) this event is triggered when the order is in progress on the blockchain 4 fiatreceived this event is received on confirming that onmeta has received payment for the onramp order 5 transferred this event is triggered when a user's token transfer is confirmed on the blockchain 6 completed this event is triggered when a user's order is completed and the user has received the tokens 7 expired when an order remains pending for more than three hours, the order is expired and this webhook event is triggered note optional events will occur when using non native tokens example webhook request { "fiat" 100, "receiverwalletaddress" "0xf12dc1e2eeb4d0475de270447a92a481635caf4a", "buytokensymbol" "matic", "buytokenaddress" "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "orderid" "641c30286ad7d01834a02e2c", "status" "fiatpending", "currency" "inr", "chainid" 137, "customer" {"id" "web52390easf35fas2a25d3fffwsdae", "email" "documentation\@onmeta in", "phone" {}, "created at" "2023 01 04t06 58 24 968z"}, "createdat" "2023 03 23t10 55 36 584z", "txnhash" "", "transferredamount" "0 990628", "transferredamountwei" "990628498656169300", "eventtype" "onramp", "metadata" {"submeta1" "metadata"} }