Logo

EazzPay Initiate Payment API Documentation

The `EazzPay Initiate Payment API allows businesses to create payment requests and redirect customers to complete transactions. This guide includes step-by-step instructions and examples in different programming languages.

Request URL

To initiate a payment, make a POST request to the following API endpoint:

{base_URL}/api/v1/payments/initiate

Ensure to replace {base_URL} with the live API endpoint URL provided in your EazzPay Merchant Dashboard.


Request Headers

Include these headers in your request:

Header NameValue
Content-Type"application/json"
Accept"application/json"
eazzpay-client-secretYour API Key from the Merchant Dashboard

Request Parameters

Request Payload

Upon successful initiation, the API returns the following response:

{
  "cus_name": "John Doe", 
  "amount": 100, 
  "metadata": "{"order_id":"123456","items":[{"product_id":"A1B2C3","product_name":"Widget A","quantity":2,"price":50},{"product_id":"D4E5F6","product_name":"Widget B","quantity":1,"price":50.75}],"discount":"10% off for first order","customer_note":"Please deliver between 9 AM and 5 PM"}", 
  "success_url": "https://your-frontend.com/success", 
  "cancel_url": "https://your-frontend.com/cancel", 
  "ipn_url": "https://your-backend.com/ipn", 
  "ipn_method": "POST"
}

Parameter Details

ParameterRequiredTypeDescription
cus_nameYesstringCustomer's name (100 characters).
amountYesnumberPayment amount (valid numeric value).
metadataNostringJSON string for order details (max 1000 characters).
success_urlYesstringRedirect URL for successful payment (100 characters).
cancel_urlYesstringRedirect URL for canceled payment (100 characters).
ipn_urlYesstringIPN callback URL (100 characters).
ipn_methodNostringHTTP method for IPN (GET, POST, PUT, DELETE, PATCH, OPTIONS, and HEAD). Default: POST.

Success Response Example

Upon successful initiation, the API returns the following response:

{
  "data": {
    "payment_id": "67adb1d9a7436e9d01c5934c",
    "reference": "PAY--10001",
    "transaction_status": "INITIATED",
    "amount": 100,
    "payment_init_time": "2025-02-13T08:48:25.054Z",
    "eazzpay_url": "https://pay.eazzpay.com/payments/67adb1d9a7436e9d01c5934c",
    "success_url": "https:/your-frontend.com/success",
    "cancel_url": "https:/your-frontend.com/cancel",
    "ipn_url": "https://your-backend.com/ipn",
    "ipn_method": "POST"
  },
  "code": 201,
  "message": "Payment initiated successfully"
}

Response Fields

Root Level

FieldTypeDescription
codenumberHTTP status code indicating success, e.g., 201.
messagestringDescriptive message confirming the operation.

Data Object

FieldTypeDescription
payment_idstringUnique identifier for the payment transaction.
referencestringA reference for the payment, useful for tracking.
transaction_statusstringCurrent status of the transaction, e.g., INITIATED.
amountnumberPayment amount.
payment_init_timestringTimestamp of payment initiation.
eazzpay_urlstringURL for customer redirection to complete the payment.
success_urlstringRedirect URL for successful payment.
cancel_urlstringRedirect URL for canceled payment.
ipn_urlstringIPN callback URL.
ipn_methodstringHTTP method for IPN requests.

Error Response Example

In case of an error, the API returns the following response:

{
  "message": "Invalid eazzpay configuration",
  "error": "Not Acceptable",
  "code": 406
}

Error Response Fields

FieldTypeDescription
messagestringDescription of the error.
errorstringError type, e.g., Not Acceptable.
codenumberHTTP status code indicating the error, e.g., 406.

Example Requests

const axios = require('axios');
 
const eazzpay_base_url = "https://sandbox.eazzpay.com/api/v1";
const eazzpay_client_secret = "yQPslmdjbuNKUhf9dxoNpDm5pMhAXV3rcvWY";
 
const options = {
  method: 'POST',
  url: `${eazzpay_base_url}/payments/initiate`,
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'eazzpay-client-secret': eazzpay_client_secret
  },
  data: {
    cus_name: 'John Doe',
    amount: 100,
    metadata: {
      order_id: '123456',
      items: [
        { product_id: 'A1B2C3', product_name: 'Widget A', quantity: 2, price: 50 }
      ]
    },
    success_url: 'https://your-frontend.com/success',
    cancel_url: 'https://your-frontend.com/cancel',
    ipn_url: 'https://your-backend.com/ipn',
    ipn_method: 'POST'
  }
};
 
axios.request(options)
  .then(response => console.log(response.data))
  .catch(error => console.error(error));

Notes

  • Sandbox Environment: Use this environment for testing your integration.
  • Live Environment: Switch to live after successful testing.

On this page