Partial Refund

The Partial Refund API allows merchants to refund a portion of the amount of a previously successful and settled transaction through the EdfaPay payment gateway, returning the specified partial amount back to the customer’s original payment method.

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
amountstringYesThe partial amount of the original transaction 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=1.00' \
--data-urlencode 'action=CREDITVOID' \
--data-urlencode 'hash=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
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=2.00' \
--data-urlencode 'action=CREDITVOID' \
--data-urlencode 'hash=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
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=3.00' \
--data-urlencode 'action=CREDITVOID' \
--data-urlencode 'hash=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
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=4.00' \
--data-urlencode 'action=CREDITVOID' \
--data-urlencode 'hash=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
❗️

Important Note — Hash Generation

The hash parameter included in the request body is dynamically generated for each request and must not be hardcoded.

The hash value is calculated using specific request parameters combined with your merchant secret key. Any change in the request data requires regenerating the hash before sending the request.

🔗 For detailed steps and the exact formula used to generate the hash, refer to the Hash Generation Section.


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: It should be 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"
        }
    ]
}

Partial Refund Rules and Guidelines

Refund Eligibility
  • A partial refund can only be initiated if the original transaction was successful and captured.
Partial Refund Conditions
  • The refund amount must be less than the original transaction amount.
  • Multiple partial refunds are allowed on the same transaction.
  • The total refunded amount must not exceed the original transaction amount.

❗️

Important Considerations

  • Partial refunds must be handled carefully, as multiple refund attempts may trigger issuer or fraud monitoring checks.
  • Always ensure the remaining refundable amount is calculated correctly before submitting a partial refund.
  • Ensure each partial refund is properly logged and tracked to avoid conflicts or duplicate refund attempts.
  • Always verify that the transaction is **captured **before initiating a partial refund.
Language
Click Try It! to start a request and see the response here!