Create Crypto Refund with UI
4 min
this api creates a crypto refund order to enable merchants to refund a successfully processed crypto transaction it accepts amount, orderid and the other order details this api requires access token that can be generated using access token docid\ lq v6ff 2i h1o3xd5kka api { "name" "create refund ", "method" "post", "url" "https //your hostname pay3 app/v1/client/crypto refund/create order", "description" "create an order with refund details from your application's backend", "tab" "examples", "examples" { "languages" \[ { "id" "exhyhl9rwxfgu lg6oq1q", "language" "curl", "code" "curl location 'https //api pprod pay3 app/v1/client/crypto refund/create order' \\\\\n header 'signature {{signature}}' \\\\\n header 'access token {{access token}}' \\\\\n header 'content type application/json' \\\\\n data '{\n \\"clientid\\" \\"\\",\n \\"requestid\\" \\"\\",\n \\"orderid\\" \\"\\",\n \\"amount\\" \\"1 0\\",\n \\"currency\\" \\"usdc sepolia\\",\n \\"mode\\" \\"returnurl\\",\n \\"sponsorfee\\"\ false\n}'", "customlabel" "" } ], "selectedlanguageid" "exhyhl9rwxfgu lg6oq1q" }, "results" { "languages" \[ { "id" "vqyrchsr38ubbehatupjh", "language" "200", "code" "{\n \\"token\\" \\"d0614ad6 91a5 4bf4 8e87 f4907b5b8fce\\",\n \\"requestid\\" \\"4a7ee93e 7eb7 4e80 9cc7 4faf804bc183\\",\n \\"url\\" \\"https //pay3 sample payment url\\"\n}", "customlabel" "" } ], "selectedlanguageid" "vqyrchsr38ubbehatupjh" }, "request" { "pathparameters" \[], "queryparameters" \[], "headerparameters" \[ { "name" "signature", "kind" "required", "type" "string", "description" "signature generated with sha256 followed by base64 encoding check below section for more details", "children" \[] }, { "name" "access token", "kind" "required", "type" "string", "description" "access token received from access token api you can reuse the access token across multiple api calls till it is expired", "children" \[] } ], "bodydataparameters" \[ { "name" "orderid", "kind" "required", "type" "string", "description" "the orderid of the parent order, this can be found in the dashboard or from order details api ", "" "the orderid of the parent order, this can be found in the dashboard or from order details api " }, { "name" "clientid", "kind" "required", "type" "string", "description" "client id application's identifier", "children" \[] }, { "name" "mode", "kind" "required", "type" "string", "description" "set the mode to returnurl, the api response includes an additional field url, which provides a direct page link for processing crypto refunds this provides an option to enter the wallet address in ui \n\n\\"returnurl\\" is only supported mode ", "" "set the mode to returnurl, the api response includes an additional field url, which provides a direct page link for processing crypto refunds this provides an option to enter the wallet address in ui \n\n\\"returnurl\\" is only supported mode " }, { "name" "amount", "kind" "optional", "type" "string", "description" "amount in crypto user can be refunded in string format this amount should be less than or equal to the parent order amount this parameter is required when \\"fiatamount\\" is not passed maximum two decimal places are allowed ", "" "amount in crypto user can be refunded in string format this amount should be less than or equal to the parent order amount this parameter is required when \\"fiatamount\\" is not passed maximum two decimal places are allowed " }, { "name" "currency", "kind" "optional", "type" "string", "description" "the currency is pay3's unique string id denoting the token that needs to be purchased this param is required along \\"with \\"amount\\" param when \\"fiatamount\\" is not passed \n\nit has to be same type that of the parent order for which refund is being created \n\nexample value are btc bitcoin, usdt polygon, usdc etehreum , usdt tron , uni eth ", "" "the currency is pay3's unique string id denoting the token that needs to be purchased this param is required along \\"with \\"amount\\" param when \\"fiatamount\\" is not passed \n\nit has to be same type that of the parent order for which refund is being created \n\nexample value are btc bitcoin, usdt polygon, usdc etehreum , usdt tron , uni eth " }, { "name" "fiatamount", "kind" "optional", "type" "string", "description" "amount in fiat say usd (eg 10 50) this parameter is required when \\"amount\\" is not passed this amount should be less than or equal to the parent order amount \nexample values for ten dollar fifty cents is 10 50", "" "amount in fiat say usd (eg 10 50) this parameter is required when \\"amount\\" is not passed this amount should be less than or equal to the parent order amount \nexample values for ten dollar fifty cents is 10 50" }, { "name" "fiatcurrency", "kind" "optional", "type" "string", "description" "fiat currency code is pay3's unique string id denoting the fiat currency this parameter is required along with fiatamount when \\"amount\\" param is not passed pay3 uses current exchange rate to translate fiatamount to amount \nsupported fiat currencies are usd usa, gbp gb , aed ae and eur eu ", "" "fiat currency code is pay3's unique string id denoting the fiat currency this parameter is required along with fiatamount when \\"amount\\" param is not passed pay3 uses current exchange rate to translate fiatamount to amount \nsupported fiat currencies are usd usa, gbp gb , aed ae and eur eu " }, { "name" "sponsorfee", "kind" "optional", "type" "string", "description" "when sponsorfee is set to false(default), the amount is sent to the destination address (user's address) after deducting the gas fees \n\nwhen sponsorfee is set to true, the complete amount is sent to the destination address \n", "" "when sponsorfee is set to false(default), the amount is sent to the destination address (user's address) after deducting the gas fees \n\nwhen sponsorfee is set to true, the complete amount is sent to the destination address \n" }, { "name" "userid", "kind" "optional", "type" "string", "description" "pass any string for the user (uniqueid) to identify and map the orders against the user this can be same value which you are using in your application to uniquely identify the users ", "" "pass any string for the user (uniqueid) to identify and map the orders against the user this can be same value which you are using in your application to uniquely identify the users " } ], "formdataparameters" \[] }, "currentnewparameter" { "label" "body parameter", "value" "bodydataparameters" }, "hastryitout" false, "autogeneratedanchorslug" "create refund", "legacyhash" "ndwjglhmbpar2on p5btb" } signature generation the request for creating payout order requires a header signature this can be generated using following javascript code snippet case 1 with fiatamount & fiatcurrency parameter const crypto = require('crypto'); // required parameters const secretkey="api secret provided by pay3"; const fiatamount = "0 02"; const fiatcurrency = "aed ae"; const orderid = "order id of the pay in order"; const requestid = "order id generated by application"; const getsignature = (secretkey, fiatamount, fiatcurrency , orderid ,requestid) => { // prepare the string to sign in same format const stringtosign = 'fiatamount=' + fiatamount + '\&fiatcurrency=' + fiatcurrency + '\&orderid=' + orderid + '\&requestid=' + requestid; // generating signature using sha256 and provided secret and // base64 encode the result const mac = crypto createhmac('sha256', secretkey); return mac update(stringtosign) digest('base64'); } // generate signature const signature = getsignature(secretkey, fiatamount, fiatcurrency , orderid ,requestid); case 2 with amount parameter const crypto = require('crypto'); // required parameters const secretkey="api secret provided by pay3"; const amount = "0 02"; const currency = "usdc ethereum"; const orderid = "order id of the pay in order"; const requestid = "order id generated by application"; const getsignature = (secretkey, amount, currency , orderid ,requestid) => { // prepare the string to sign in same format const stringtosign = 'amount=' + amount + '\¤cy=' + currency + '\&orderid=' + orderid + '\&requestid=' + requestid; // generating signature using sha256 and provided secret and // base64 encode the result const mac = crypto createhmac('sha256', secretkey); return mac update(stringtosign) digest('base64'); } // generate signature const signature = getsignature(secretkey, amount, currency , orderid ,requestid);