Create Crypto Refund (Server Side)
4 min
This API creates a crypto refund order to enable merchants to refund a successfully processed crypto transaction. It accepts address , amount, orderId and the other order details.
This API requires access token that can be generated using Access TokenAccess Token API.
Create Refund
Create an order with refund details from your application's backend
POST
https://your-hostname.pay3.app/v1/client/crypto-refund/create-execute
curl --location 'https://api.pprod.pay3.app/v1/client/crypto-refund/create-execute' \
--header 'signature: {{signature}}' \
--header 'Access-token: {{access-token}}' \
--header 'Content-Type: application/json' \
--data '{
"clientId":"",
"requestId":"",
"orderId":"",
"amount": "1.0",
"currency": "usdc_ethereum",
"address": "0x..",
"sponsorFee":false
}'Signature Generation
The request for creating payout order requires a header signature. This can be generated using following javascript code snippet.
Case 1: With amount parameter
const crypto = require('crypto');
// Required Parameters
const secretKey="Api-Secret-Provided-By-Pay3";
const amount = "1.00";
const currency = "usdc_ethereum";
const address = "0x....hiudfh":
const orderId = "Order_ID_Of_the_Pay-in_Order";
const requestId = "Order-Id-Generated-By-Application";
const getSignature = (secretKey, amount , currency , address , orderId , requestId) => {
// Prepare the string to sign in same format.
let stringToSign;
stringToSign = 'address=' + address
+ '&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 , address ,orderId ,requestId);
Case 2: With fiatAmount & fiatCurrency parameter
const crypto = require('crypto');
// Required Parameters
const secretKey="Api-Secret-Provided-By-Pay3";
const fiatAmount = "1.00";
const fiatCurrency = "aed_ae";
const address = "0x....hiudfh":
const orderId = "Order_ID_Of_the_Pay-in_Order";
const requestId = "Order-Id-Generated-By-Application";
const getSignature = (secretKey, fiatAmount , fiatCurrency , address , orderId , requestId) => {
// Prepare the string to sign in same format.
let stringToSign;
stringToSign = 'address=' + address
+ '&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 , address ,orderId ,requestId);