API Reference

Refund

The Refund API allows merchants to issue a refund for a previously completed transaction through the Edfapay payment gateway.

Endpoint

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

Content-Type: application/json

Request Body

FieldTypeRequiredDescription
gwayIdstringYesUnique transaction ID returned by Edfapay (payment gateway transaction ID)
order_idstringYesOrder ID from the merchant's system
edfa_merchant_idstringYesMerchant key provided by Edfapay
hashstringYesSecurity hash generated to authorize the request
payer_ipstringYesIP address of the payer
amountstringYesAmount to be refunded

Example Request

curl --location 'https://api.edfapay.com/payment/refund' \
--header 'Content-Type: application/json' \
--data '{
    "gwayId": "XXXXXXXXXXXXXXXXXXX",
    "order_id": "1000",
    "edfa_merchant_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    "hash": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "payer_ip": "176.44.76.222",
    "amount": "1.00"
}'

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(gwayId+ amount+ merchant_password)))

JavaScript Example using CryptoJS

var to_md5 = gwayId + amount + merchant.pass;

var hash = CryptoJS.SHA1(CryptoJS.MD5(to_md5.toUpperCase()).toString());

var result = CryptoJS.enc.Hex.stringify(hash);

Note

merchant.pass is the shared secret provided by Edfapay for secure communication.

You can get the **gwayId **from Dashboard in he transaction page with name Payment ID. Webhook(callback) response with value of parameter trans_id.

Success Response

{
    "statusCode": 200,
    "responseBody": {
        "result": "accepted",
        "payment_id": "XXXXXXXXXXXXXXXXXXX"
    }
}

Error Response

{
    "statusCode": 200,
    "responseBody": {
        "result": "ERROR",
        "error_code": 100000,
        "error_message": "Request data is invalid.",
        "errors": [
            {
                "error_code": 100000,
                "error_message": "refund: Total refund has already been issued. Additional refund would exceed the original sale 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.
Language
Click Try It! to start a request and see the response here!