API Reference

Recurring

The Recurring API allows merchants to charge customers on a recurring basis (e.g., monthly, weekly) for subscription-based services. This is an unscheduled recurring API, giving merchants the flexibility to manage their own billing cycles and call the recurring API as needed.

Endpoint

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

Content-Type: application/json

Request Body (JSON)

FieldTypeRequiredDescription
order_idstringYesNew unique order ID for this recurring transaction
merchant_idstringYesMerchant key provided by Edfapay
hashstringYesSecurity hash generated to authorize the request
actionstringYesAction type: must be RECURRING_SALE
order_amountnumberYesAmount to be charged
primary_order_idstringYesThe order ID of the original transaction (first payment)
order_descriptionstringYesDescription of the order
payer_ipstringNoIP address of the payer used in original transaction (first payment)
recurring_tokenstringYesToken received after the initial transaction with recurring_init=Y

Example Request

curl --location 'https://api.edfapay.com/payment/recurring' \
--header 'Content-Type: application/json' \
--data '{
    "order_id": "Order_01",
    "merchant_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    "hash": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "action": "RECURRING_SALE",
    "order_amount": 1.00,
    "primary_order_id": "Primary_00",
    "order_description": "Recurring test order",
    "payer_ip": "100.100.100.100",
    "recurring_token": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
}'

How to Get recurring_token

To use the Recurring API, the recurring_token must be obtained in advance. This token is provided to the merchant’s notification endpoint under the following conditions:

  • The initial Initiate API call must include "recurring_init": "Y"
  • The merchant must be enabled for recurring payments
  • The initial payment must be successful

Please contact Edfapay onboarding team to enable recurring payments for your merchant account.

Hash Calculation

The hash parameter must be calculated to secure the request. It is based on a combination of order details and your merchant password.

Formula:

hash = SHA1(MD5(to_md5.toUpperCase()))

String to hash:

var to_md5 = recurring_init_trans_id + recurring_token + order_number + order_amount + order_description + merchant_pass;

JavaScript Example using CryptoJS

var to_md5 = recurring_init_trans_id + recurring_token + order_number + order_amount + order_description + 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. recurring_init_trans_id is the Payment ID of original transaction (first payment). recurring_tokenis the Token returned in the Webhook response.

Success Response

{
    "statusCode": 200,
    "responseBody": {
        "result": "SUCCESS",
        "status": "SUCCESS",
        "payment_id": "XXXXXXXXXXXXXXXXXXXXXXXXXX"
    }
}

Error Response

{
    "statusCode": 400,
    "responseBody": "Invalid Hash value"
}

Authentication

Authentication is handled via the hash parameter, using a SHA1-of-MD5 encoding scheme to validate request integrity.

Language
Click Try It! to start a request and see the response here!