Create Crypto Refund
2 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 \\"address\\" \\"0x \\",\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" "amount", "kind" "required", "type" "string", "description" "amount user can be refunded in string format this amount should be less than or equal to the parent order amount maximum two decimal places are allowed ", "" "amount user can be refunded in string format this amount should be less than or equal to the parent order amount maximum two decimal places are allowed " }, { "name" "mode", "kind" "required", "type" "string", "description" "when the mode is set to returnurl, the api response includes an additional field url, which provides a direct page link for processing crypto refunds the supported values for mode are returnurl ", "" "when the mode is set to returnurl, the api response includes an additional field url, which provides a direct page link for processing crypto refunds the supported values for mode are returnurl " }, { "name" "clientid", "kind" "required", "type" "string", "description" "client id application's identifier", "children" \[] }, { "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" } ], "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 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 // fiatamount followed by requestid 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);