This section describes the API NEPAL payment gateway API.
API NEPAL provides a seamless API for integrating payments into your business software. Our API supports cURL requests, uses well-structured URLs, and returns JSON responses for easy integration.
Test the API in sandbox mode without affecting live data. Authentication is handled via API keys, ensuring secure and legitimate transactions. Use the sandbox URL for testing and the live URL for production, as detailed in the Initiate Payment section.
Below is a list of currencies supported by API NEPAL.
Currency | Currency Symbol |
---|---|
NPR | रु |
Learn how to obtain your API keys for integration.
Log in to your API NEPAL merchant account. If you don’t have an account, create one here.
Navigate to Account > Settings > API Key in the merchant panel to find your Public Key and Secret Key.
Use these keys to authenticate API requests. Generate new keys anytime using the Generate API Key button. Keep your keys secure and never share them.
This section explains how to initiate a payment using the API.
Use the provided endpoints and parameters to initiate a payment. Ensure all required parameters are included in your request.
Live Endpoint: https://apinepal.com/payment/initiate
Test Endpoint: https://apinepal.com/test/payment/initiate
Param Name | Param Type | Description |
---|---|---|
public_key | string (50) | Required Your Public API key |
secret_key | string | Required Your Secret API key for authentication |
identifier | string (20) | Required Unique identifier for the payment |
currency | string (4) | Required Currency code in uppercase, e.g., NPR |
amount | decimal | Required Payment amount |
details | string (100) | Required Payment or transaction details |
ipn_url | string | Required Instant Payment Notification URL |
success_url | string | Required Redirect URL for successful payment |
cancel_url | string | Required Redirect URL for canceled payment |
site_name | string | Required Your business site name |
site_logo | string/url | Optional Your business site logo URL |
checkout_theme | string | Optional Checkout form theme (dark/light, default: light) |
Customer | ||
customer[] | array | Required Customer information array |
customer.first_name | string | Required Customer's first name |
customer.last_name | string | Required Customer's last name |
customer.email | string | Required Customer's valid email |
customer.mobile | string | Required Customer's valid mobile number |
Shipping Info | ||
shipping_info[] | array | Optional Shipping information array |
shipping_info.address_one | string | Optional Customer's address line one |
shipping_info.address_two | string | Optional Customer's address line two |
shipping_info.area | string | Optional Shipping area |
shipping_info.city | string | Optional Shipping city |
shipping_info.sub_city | string | Optional Shipping sub-city |
shipping_info.state | string | Optional Shipping state |
shipping_info.postcode | string | Optional Shipping postcode |
shipping_info.country | string | Optional Shipping country |
shipping_info.others | string | Optional Additional shipping info |
Billing Info | ||
billing_info[] | array | Optional Billing information array |
billing_info.address_one | string | Optional Customer's address line one |
billing_info.address_two | string | Optional Customer's address line two |
billing_info.area | string | Optional Billing area |
billing_info.city | string | Optional Billing city |
billing_info.sub_city | string | Optional Billing sub-city |
billing_info.state | string | Optional Billing state |
billing_info.postcode | string | Optional Billing postcode |
billing_info.country | string | Optional Billing country |
billing_info.others | string | Optional Additional billing info |
<?php
$parameters = [
'public_key' => 'your_public_key',
'secret_key' => 'your_secret_key',
'identifier' => 'DFU80XZIKS',
'currency' => 'NPR',
'amount' => 11.00,
'gateway_methods' => [],
'details' => 'Purchase T-shirt',
'ipn_url' => 'http://example.com/ipn_url.php',
'cancel_url' => 'http://example.com/cancel_url.php',
'success_url' => 'http://example.com/success_url.php',
'site_name' => 'your_site_name',
'site_logo' => 'http://yoursite.com/logo.png',
'checkout_theme' => 'light',
'customer' => [
'first_name' => 'John',
'last_name' => 'Doe',
'email' => '[email protected]',
'mobile' => '12345789',
],
'shipping_info' => [
'address_one' => '',
'address_two' => '',
'area' => '',
'city' => '',
'sub_city' => '',
'state' => '',
'postcode' => '',
'country' => '',
'others' => '',
],
'billing_info' => [
'address_one' => '',
'address_two' => '',
'area' => '',
'city' => '',
'sub_city' => '',
'state' => '',
'postcode' => '',
'country' => '',
'others' => '',
]
];
$parameters = http_build_query($parameters);
// Live endpoint
$url = 'https://apinepal.com/payment/initiate';
// Test endpoint
// $url = 'https://apinepal.com/test/payment/initiate';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
?>
{
"status": "error",
"message": ["Invalid api key"]
}
{
"status": "success",
"message": ["Payment initiated"],
"redirect_url": "https://example.com/payment/checkout?payment_trx=eyJpdiI6IkFyNllSNU1lOFdkYTlPTW52cytPNGc9PSIsInZhbHVlIjoiWWowRTRjdzZ1S1BBRm4ydS81OWR1WjdXeFIxcjE1WkZRVE9BcmZYeXpzND0iLCJtYWMiOiJjNDdhODUzYzY2NmZlZGJjZTI5ODQyMmRkYzdjYjRmM2NiNjg4M2RiMWZjN2EyMzFkODI4OWMwYjk3ZWYwNGQwIiwidGFnIjoiIn0%3D"
}
Learn how to validate payments and handle Instant Payment Notifications (IPN).
Use the following endpoint and parameters to validate payments and receive IPN notifications.
Endpoint: Your business application IPN URL
Request Method: POST
Param Name | Description |
---|---|
status | Payment success status |
identifier | Unique identifier for the payment |
signature | Hash signature to verify the payment |
data | Contains payment details like charges, amount, currency, and transaction ID |
<?php
$status = $_POST['status'];
$signature = $_POST['signature'];
$identifier = $_POST['identifier'];
$data = $_POST['data'];
$customKey = $data['amount'] . $identifier;
$secret = 'YOUR_SECRET_KEY';
$mySignature = strtoupper(hash_hmac('sha256', $customKey, $secret));
$myIdentifier = 'YOUR_GIVEN_IDENTIFIER';
if ($status == "success" && $signature == $mySignature && $identifier == $myIdentifier) {
// Your operation logic
}
?>
Integrate the API NEPAL payment gateway into your WordPress site.
Download our WordPress plugin to easily integrate the payment gateway. Follow the installation instructions in your WordPress dashboard.
Download PluginTest the payment API by entering your API keys, amount, and other required parameters.
Use the form below to simulate a payment request. Toggle between test and live modes. On success, you will be redirected to the payment checkout page. You can also download the Postman collection for advanced testing.
View the complete Postman collection for the API NEPAL payment gateway API.
The following JSON represents the Postman collection for testing the API. You can download and import it into Postman for advanced testing.
{
"info": {
"_postman_id": "b7f3e2a1-9c2d-4f7e-8e3f-5a6b7c8d9e0f",
"name": "API NEPAL Payment Gateway API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": "API documentation for integrating the API NEPAL payment gateway."
},
"item": [
{
"name": "Initiate Payment (Test)",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "public_key",
"value": "your_public_key",
"type": "text",
"description": "Your Public API key (Required)"
},
{
"key": "secret_key",
"value": "your_secret_key",
"type": "text",
"description": "Your Secret API key (Required)"
},
{
"key": "identifier",
"value": "DFU80XZIKS",
"type": "text",
"description": "Unique identifier for the payment (Required)"
},
{
"key": "currency",
"value": "NPR",
"type": "text",
"description": "Currency code in uppercase, e.g., NPR (Required)"
},
{
"key": "amount",
"value": "11.00",
"type": "text",
"description": "Payment amount (Required)"
},
{
"key": "details",
"value": "Purchase T-shirt",
"type": "text",
"description": "Payment or transaction details (Required)"
},
{
"key": "ipn_url",
"value": "http://example.com/ipn_url.php",
"type": "text",
"description": "Instant Payment Notification URL (Required)"
},
{
"key": "success_url",
"value": "http://example.com/success_url.php",
"type": "text",
"description": "Redirect URL for successful payment (Required)"
},
{
"key": "cancel_url",
"value": "http://example.com/cancel_url.php",
"type": "text",
"description": "Redirect URL for canceled payment (Required)"
},
{
"key": "site_name",
"value": "your_site_name",
"type": "text",
"description": "Your business site name (Required)"
},
{
"key": "site_logo",
"value": "http://yoursite.com/logo.png",
"type": "text",
"description": "Your business site logo URL (Optional)"
},
{
"key": "checkout_theme",
"value": "light",
"type": "text",
"description": "Checkout form theme (dark/light, default: light) (Optional)"
},
{
"key": "customer[first_name]",
"value": "John",
"type": "text",
"description": "Customer's first name (Required)"
},
{
"key": "customer[last_name]",
"value": "Doe",
"type": "text",
"description": "Customer's last name (Required)"
},
{
"key": "customer[email]",
"value": "[email protected]",
"type": "text",
"description": "Customer's valid email (Required)"
},
{
"key": "customer[mobile]",
"value": "12345789",
"type": "text",
"description": "Customer's valid mobile number (Required)"
},
{
"key": "shipping_info[address_one]",
"value": "",
"type": "text",
"description": "Customer's address line one (Optional)"
},
{
"key": "shipping_info[address_two]",
"value": "",
"type": "text",
"description": "Customer's address line two (Optional)"
},
{
"key": "shipping_info[area]",
"value": "",
"type": "text",
"description": "Shipping area (Optional)"
},
{
"key": "shipping_info[city]",
"value": "",
"type": "text",
"description": "Shipping city (Optional)"
},
{
"key": "shipping_info[sub_city]",
"value": "",
"type": "text",
"description": "Shipping sub-city (Optional)"
},
{
"key": "shipping_info[state]",
"value": "",
"type": "text",
"description": "Shipping state (Optional)"
},
{
"key": "shipping_info[postcode]",
"value": "",
"type": "text",
"description": "Shipping postcode (Optional)"
},
{
"key": "shipping_info[country]",
"value": "",
"type": "text",
"description": "Shipping country (Optional)"
},
{
"key": "shipping_info[others]",
"value": "",
"type": "text",
"description": "Additional shipping info (Optional)"
},
{
"key": "billing_info[address_one]",
"value": "",
"type": "text",
"description": "Customer's address line one (Optional)"
},
{
"key": "billing_info[address_two]",
"value": "",
"type": "text",
"description": "Customer's address line two (Optional)"
},
{
"key": "billing_info[area]",
"value": "",
"type": "text",
"description": "Billing area (Optional)"
},
{
"key": "billing_info[city]",
"value": "",
"type": "text",
"description": "Billing city (Optional)"
},
{
"key": "billing_info[sub_city]",
"value": "",
"type": "text",
"description": "Billing sub-city (Optional)"
},
{
"key": "billing_info[state]",
"value": "",
"type": "text",
"description": "Billing state (Optional)"
},
{
"key": "billing_info[postcode]",
"value": "",
"type": "text",
"description": "Billing postcode (Optional)"
},
{
"key": "billing_info[country]",
"value": "",
"type": "text",
"description": "Billing country (Optional)"
},
{
"key": "billing_info[others]",
"value": "",
"type": "text",
"description": "Additional billing info (Optional)"
}
]
},
"url": {
"raw": "https://apinepal.com/test/payment/initiate",
"host": ["apinepal.com"],
"path": ["test/payment/initiate"]
},
"description": "Initiate a payment in test mode."
},
"response": [
{
"name": "Success Response",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "public_key",
"value": "your_public_key"
},
{
"key": "secret_key",
"value": "your_secret_key"
},
{
"key": "identifier",
"value": "DFU80XZIKS"
},
{
"key": "currency",
"value": "NPR"
},
{
"key": "amount",
"value": "11.00"
},
{
"key": "details",
"value": "Purchase T-shirt"
},
{
"key": "ipn_url",
"value": "http://example.com/ipn_url.php"
},
{
"key": "success_url",
"value": "http://example.com/success_url.php"
},
{
"key": "cancel_url",
"value": "http://example.com/cancel_url.php"
},
{
"key": "site_name",
"value": "your_site_name"
},
{
"key": "site_logo",
"value": "http://yoursite.com/logo.png"
},
{
"key": "checkout_theme",
"value": "light"
},
{
"key": "customer[first_name]",
"value": "John"
},
{
"key": "customer[last_name]",
"value": "Doe"
},
{
"key": "customer[email]",
"value": "[email protected]"
},
{
"key": "customer[mobile]",
"value": "12345789"
}
]
},
"url": {
"raw": "https://apinepal.com/test/payment/initiate",
"host": ["apinepal.com"],
"path": ["test/payment/initiate"]
}
},
"status": "OK",
"code": 200,
"body": "{\n \"status\": \"success\",\n \"message\": [\"Payment initiated\"],\n \"redirect_url\": \"https://example.com/payment/checkout?payment_trx=eyJpdiI6IkFyNllSNU1lOFdkYTlPTW52cytPNGc9PSIsInZhbHVlIjoiWWowRTRjdzZ1S1BBRm4ydS81OWR1WjdXeFIxcjE1WkZRVE9BcmZYeXpzND0iLCJtYWMiOiJjNDdhODUzYzY2NmZlZGJjZTI5ODQyMmRkYzdjYjRmM2NiNjg4M2RiMWZjN2EyMzFkODI4OWMwYjk3ZWYwNGQwIiwidGFnIjoiIn0%3D\"\n}"
},
{
"name": "Error Response",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "public_key",
"value": "invalid_public_key"
},
{
"key": "secret_key",
"value": "invalid_secret_key"
}
]
},
"url": {
"raw": "https://apinepal.com/test/payment/initiate",
"host": ["apinepal.com"],
"path": ["test/payment/initiate"]
}
},
"status": "Bad Request",
"code": 400,
"body": "{\n \"status\": \"error\",\n \"message\": [\"Invalid api key\"]\n}"
}
]
},
{
"name": "Initiate Payment (Live)",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "public_key",
"value": "your_public_key",
"type": "text",
"description": "Your Public API key (Required)"
},
{
"key": "secret_key",
"value": "your_secret_key",
"type": "text",
"description": "Your Secret API key (Required)"
},
{
"key": "identifier",
"value": "DFU80XZIKS",
"type": "text",
"description": "Unique identifier for the payment (Required)"
},
{
"key": "currency",
"value": "NPR",
"type": "text",
"description": "Currency code in uppercase, e.g., NPR (Required)"
},
{
"key": "amount",
"value": "11.00",
"type": "text",
"description": "Payment amount (Required)"
},
{
"key": "details",
"value": "Purchase T-shirt",
"type": "text",
"description": "Payment or transaction details (Required)"
},
{
"key": "ipn_url",
"value": "http://example.com/ipn_url.php",
"type": "text",
"description": "Instant Payment Notification URL (Required)"
},
{
"key": "success_url",
"value": "http://example.com/success_url.php",
"type": "text",
"description": "Redirect URL for successful payment (Required)"
},
{
"key": "cancel_url",
"value": "http://example.com/cancel_url.php",
"type": "text",
"description": "Redirect URL for canceled payment (Required)"
},
{
"key": "site_name",
"value": "your_site_name",
"type": "text",
"description": "Your business site name (Required)"
},
{
"key": "site_logo",
"value": "http://yoursite.com/logo.png",
"type": "text",
"description": "Your business site logo URL (Optional)"
},
{
"key": "checkout_theme",
"value": "light",
"type": "text",
"description": "Checkout form theme (dark/light, default: light) (Optional)"
},
{
"key": "customer[first_name]",
"value": "John",
"type": "text",
"description": "Customer's first name (Required)"
},
{
"key": "customer[last_name]",
"value": "Doe",
"type": "text",
"description": "Customer's last name (Required)"
},
{
"key": "customer[email]",
"value": "[email protected]",
"type": "text",
"description": "Customer's valid email (Required)"
},
{
"key": "customer[mobile]",
"value": "12345789",
"type": "text",
"description": "Customer's valid mobile number (Required)"
},
{
"key": "shipping_info[address_one]",
"value": "",
"type": "text",
"description": "Customer's address line one (Optional)"
},
{
"key": "shipping_info[address_two]",
"value": "",
"type": "text",
"description": "Customer's address line two (Optional)"
},
{
"key": "shipping_info[area]",
"value": "",
"type": "text",
"description": "Shipping area (Optional)"
},
{
"key": "shipping_info[city]",
"value": "",
"type": "text",
"description": "Shipping city (Optional)"
},
{
"key": "shipping_info[sub_city]",
"value": "",
"type": "text",
"description": "Shipping sub-city (Optional)"
},
{
"key": "shipping_info[state]",
"value": "",
"type": "text",
"description": "Shipping state (Optional)"
},
{
"key": "shipping_info[postcode]",
"value": "",
"type": "text",
"description": "Shipping postcode (Optional)"
},
{
"key": "shipping_info[country]",
"value": "",
"type": "text",
"description": "Shipping country (Optional)"
},
{
"key": "shipping_info[others]",
"value": "",
"type": "text",
"description": "Additional shipping info (Optional)"
},
{
"key": "billing_info[address_one]",
"value": "",
"type": "text",
"description": "Customer's address line one (Optional)"
},
{
"key": "billing_info[address_two]",
"value": "",
"type": "text",
"description": "Customer's address line two (Optional)"
},
{
"key": "billing_info[area]",
"value": "",
"type": "text",
"description": "Billing area (Optional)"
},
{
"key": "billing_info[city]",
"value": "",
"type": "text",
"description": "Billing city (Optional)"
},
{
"key": "billing_info[sub_city]",
"value": "",
"type": "text",
"description": "Billing sub-city (Optional)"
},
{
"key": "billing_info[state]",
"value": "",
"type": "text",
"description": "Billing state (Optional)"
},
{
"key": "billing_info[postcode]",
"value": "",
"type": "text",
"description": "Billing postcode (Optional)"
},
{
"key": "billing_info[country]",
"value": "",
"type": "text",
"description": "Billing country (Optional)"
},
{
"key": "billing_info[others]",
"value": "",
"type": "text",
"description": "Additional billing info (Optional)"
}
]
},
"url": {
"raw": "https://apinepal.com/payment/initiate",
"host": ["apinepal.com"],
"path": ["payment/initiate"]
},
"description": "Initiate a payment in live mode."
},
"response": [
{
"name": "Success Response",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "public_key",
"value": "your_public_key"
},
{
"key": "secret_key",
"value": "your_secret_key"
},
{
"key": "identifier",
"value": "DFU80XZIKS"
},
{
"key": "currency",
"value": "NPR"
},
{
"key": "amount",
"value": "11.00"
},
{
"key": "details",
"value": "Purchase T-shirt"
},
{
"key": "ipn_url",
"value": "http://example.com/ipn_url.php"
},
{
"key": "success_url",
"value": "http://example.com/success_url.php"
},
{
"key": "cancel_url",
"value": "http://example.com/cancel_url.php"
},
{
"key": "site_name",
"value": "your_site_name"
},
{
"key": "site_logo",
"value": "http://yoursite.com/logo.png"
},
{
"key": "checkout_theme",
"value": "light"
},
{
"key": "customer[first_name]",
"value": "John"
},
{
"key": "customer[last_name]",
"value": "Doe"
},
{
"key": "customer[email]",
"value": "[email protected]"
},
{
"key": "customer[mobile]",
"value": "12345789"
}
]
},
"url": {
"raw": "https://apinepal.com/payment/initiate",
"host": ["apinepal.com"],
"path": ["payment/initiate"]
}
},
"status": "OK",
"code": 200,
"body": "{\n \"status\": \"success\",\n \"message\": [\"Payment initiated\"],\n \"redirect_url\": \"https://example.com/payment/checkout?payment_trx=eyJpdiI6IkFyNllSNU1lOFdkYTlPTW52cytPNGc9PSIsInZhbHVlIjoiWWowRTRjdzZ1S1BBRm4ydS81OWR1WjdXeFIxcjE1WkZRVE9BcmZYeXpzND0iLCJtYWMiOiJjNDdhODUzYzY2NmZlZGJjZTI5ODQyMmRkYzdjYjRmM2NiNjg4M2RiMWZjN2EyMzFkODI4OWMwYjk3ZWYwNGQwIiwidGFnIjoiIn0%3D\"\n}"
},
{
"name": "Error Response",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "public_key",
"value": "invalid_public_key"
},
{
"key": "secret_key",
"value": "invalid_secret_key"
}
]
},
"url": {
"raw": "https://apinepal.com/payment/initiate",
"host": ["apinepal.com"],
"path": ["payment/initiate"]
}
},
"status": "Bad Request",
"code": 400,
"body": "{\n \"status\": \"error\",\n \"message\": [\"Invalid api key\"]\n}"
}
]
},
{
"name": "Validate Payment (IPN)",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "status",
"value": "success",
"type": "text",
"description": "Payment success status"
},
{
"key": "identifier",
"value": "DFU80XZIKS",
"type": "text",
"description": "Unique identifier for the payment"
},
{
"key": "signature",
"value": "your_signature",
"type": "text",
"description": "Hash signature to verify the payment"
},
{
"key": "data",
"value": "{\"amount\": 11.00, \"currency\": \"NPR\", \"transaction_id\": \"TRX123\"}",
"type": "text",
"description": "Contains payment details like charges, amount, currency, and transaction ID"
}
]
},
"url": {
"raw": "http://example.com/ipn_url.php",
"host": ["example.com"],
"path": ["ipn_url.php"]
},
"description": "Handle Instant Payment Notifications (IPN) to validate payments."
},
"response": []
}
]
}