n8n-nodes-esewa
v1.1.31
Published
Production-ready n8n community node for the official eSewa ePay API
Downloads
1,225
Maintainers
Readme
n8n-nodes-esewa
Production-ready n8n community node for the official eSewa ePay API.
Features
- Create payment form payloads for eSewa ePay.
- Verify payment status with the official status check API.
- Decode Base64 success callback payloads.
- Uses the sandbox endpoint automatically in Test.
- Uses the live endpoint automatically in Production.
- Keeps developer helper operations out of the default UI.
Installation
Community node installation
npm install n8n-nodes-esewaLocal development install
git clone <your-fork-or-repo-url>
cd n8n-nodes-esewa
npm install
npm run buildCopy the compiled dist folder into your n8n custom nodes location or link the package into your n8n environment.
Credentials
Create an Esewa API credential with:
- Merchant/Product Code
- Secret Key
- Environment: Test (Sandbox) or Production
When you select Test (Sandbox), the credential UI shows sandbox-only guidance:
- Uses
https://rc-epay.esewa.com.np/api/epay/main/v2/form - Requires
EPAYTEST - Requires the sandbox secret key
When you select Production, the credential UI shows live-payment guidance:
- Uses
https://epay.esewa.com.np/api/epay/main/v2/form - Requires a verified eSewa merchant account
- Requires live credentials
The credential values are stored securely by n8n credential encryption.
Operations
Create Payment
Builds the eSewa form POST payload and returns:
- environment
- payment URL
- generated signature
- complete form payload
- auto-submit HTML for Respond to Webhook
If total_amount is left blank, the node calculates it from amount + tax_amount + product_service_charge + product_delivery_charge.
The product code is read from the credential automatically.
Verify Payment
Calls the official status check endpoint with:
- transaction_uuid
- total_amount
The response includes the raw API response and a normalized status field.
Decode Success Response
Decodes the Base64 callback payload returned by eSewa after successful payment.
Why eSewa Returns HTTP 405
The payment endpoint is a form submission endpoint. Opening it directly in a browser issues a GET request, but eSewa only accepts POST for payment creation. That is why direct navigation returns HTTP 405 Method Not Allowed.
Webhook Redirect Example
Use this workflow:
Webhook -> eSewa Create Payment -> Respond to Webhook
In Respond to Webhook:
- Response Type:
Text - Content:
{{$json.auto_submit_html}} - Content-Type:
text/html
This returns an HTML page that immediately auto-submits the form to the official eSewa endpoint.
HTML Response Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Redirecting to eSewa...</title>
</head>
<body onload="document.forms[0].submit()">
<p>Redirecting to eSewa...</p>
<form action="https://rc-epay.esewa.com.np/api/epay/main/v2/form" method="POST">
<input type="hidden" name="amount" value="100">
<input type="hidden" name="tax_amount" value="10">
<input type="hidden" name="product_service_charge" value="0">
<input type="hidden" name="product_delivery_charge" value="0">
<input type="hidden" name="total_amount" value="110">
<input type="hidden" name="transaction_uuid" value="241028">
<input type="hidden" name="product_code" value="EPAYTEST">
<input type="hidden" name="success_url" value="https://example.com/success">
<input type="hidden" name="failure_url" value="https://example.com/failure">
<input type="hidden" name="signed_field_names" value="total_amount,transaction_uuid,product_code">
<input type="hidden" name="signature" value="...">
</form>
</body>
</html>Troubleshooting
- If the browser shows HTTP 405, do not open the payment URL directly. Use the generated HTML redirect page.
- If the total amount is wrong, leave
total_amountempty so the node calculates it from the upper fields. - If the signature fails, verify that the signed fields are still
total_amount,transaction_uuid,product_code.
Development
npm install
npm run watchBuild
npm run buildTesting
npm testThe included tests cover:
- signature generation against the published eSewa example
- Base64 callback decoding
- validation helpers
- signature verification logic
Example Workflows
1. eCommerce checkout
Webhook -> MySQL -> Create Payment -> Respond to Webhook
2. Payment verification
Webhook -> Verify Payment -> IF -> Update Database
3. Payment callback
Webhook -> Decode Response -> Verify Payment -> Send Email -> Update MySQL
API Examples
Create payment form payload
{
"amount": "100",
"tax_amount": "10",
"product_service_charge": "0",
"product_delivery_charge": "0",
"total_amount": "110",
"transaction_uuid": "241028",
"success_url": "https://example.com/success",
"failure_url": "https://example.com/failure"
}Verify payment
{
"transaction_uuid": "241028",
"total_amount": "110"
}Screenshots
Add screenshots here as placeholders in your documentation pipeline:
docs/screenshots/create-payment.pngdocs/screenshots/verify-payment.pngdocs/screenshots/credentials.png
Troubleshooting
- Signature mismatch: confirm the payload order is exactly
total_amount,transaction_uuid,product_code. - Invalid UUID: use only alphanumeric characters and hyphens.
- URL validation errors: make sure success and failure URLs start with
http://orhttps://. - Status check failures: verify the environment and product code match the original payment request.
FAQ
Does this node support sandbox and production?
Yes. Test always uses the sandbox endpoint and Production always uses the live endpoint.
Can I use the output with Respond to Webhook?
Yes. The node returns normal JSON objects that are compatible with downstream webhook responses.
Is the credential encrypted by n8n?
Yes. n8n stores credential values encrypted at rest using its credential storage.
License
MIT
