API Reference

Refund

The Refund API allows merchants to refund a transaction that has been captured through the EdfaPay payment gateway.

This API is responsible for returning funds after the capture stage, in contrast to the VOID API, which only releases funds before capture.

Endpoint

POST https://api.edfapay.com/payment/post

Content-Type: application/x-www-form-urlencoded

Request Body

FieldTypeRequiredDescription
actionstringYesAPI action type. For status checking, this must be CREDITVOID.
trans_idstringYesUnique transaction ID from EdfaPay.
client_keystringYesYour EdfaPay merchant identifier (UUID format).
hashstringYesSecurity hash generated to authorize the request
amountstringYesAmount to be refunded

🚧

Important Note

You can get the trans_id from Dashboard in the transaction page with name Payment ID. Webhook(callback) response with value of parameter trans_id and also in the Successful Response


Example Request

curl --location 'https://api.edfapay.com/payment/post' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
--data-urlencode 'trans_id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--data-urlencode 'amount=X.XX' \
--data-urlencode 'action=CREDITVOID' \
--data-urlencode 'hash=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

Hash Calculation

To secure the API call from unauthorized access, the hash parameter must be computed using the following formula:

Formula:

Hash = SHA1( MD5( UPPERCASE(payment_id + amount + merchant_pass) ) )

JavaScript Example using CryptoJS

var payment_id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
var amount = "X.XX";
var merchant_pass = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 

var to_md5 = payment_id + amount + merchant_pass;

var hash = CryptoJS.SHA1(CryptoJS.MD5(to_md5.toUpperCase()).toString());
var result = CryptoJS.enc.Hex.stringify(hash);
console.log(result);

postman.setEnvironmentVariable('operation_hash', result);
🚧

Notes

  • payment_id: This is the trans_id of the original SALE transaction you want to refund.
  • amount: Must match the value being refunded. It should be less than or equal to the amount of the original transaction.
  • merchant_pass: Your merchant secret key. Keep this secure and do not expose it publicly.
  • The concatenated string is first converted to uppercase before applying MD5.
  • The final expected hash output is in lowercase hexadecimal format

Success Response

{
    "result": "accepted",
    "payment_id": "xxxxxxxxxxxxxxxx"
}

Error Response

{
    "result": "ERROR",
    "error_code": 100000,
    "error_message": "Request data is invalid.",
    "errors": [
        {
            "error_code": 100001,
            "error_message": "Refund amount cannot be greater than order amount"
        }
    ]
}

Notes

  • EdfaPay supports both full and partial refunds using the same API endpoint.
  • To perform a partial refund, simply insert the specific amount you wish to refund in the **amount **field.
  • If the amount matches the original payment total, the system will process it as a full refund.
  • The refund must be initiated after the payment status is settled.
  • Partial Refunds: You can perform multiple partial refunds by repeating the same process. However, the sum of all refund amounts must not exceed the original SALE amount.
  • Refund API is used after capture — once the merchant has received the funds.
Language
Click Try It! to start a request and see the response here!