Quickstart
This guide walks you from zero to your first payment in under five minutes. We'll use the Node.js SDK, but the same steps apply to Python, PHP, and Java.
Prerequisites
- A NahuPay account — sign up free
- Node.js 18+ (or any supported runtime)
- Your
test_API key from the dashboard
1. Install an SDK
Install the official NahuPay Node.js SDK:
npm install nahupay
# or
yarn add nahupay2. Get your API keys
Go to Dashboard → Settings → API Keys and copy your test_sk_… secret key. Never expose this in client-side code or commit it to version control.
NAHUPAY_SECRET_KEY=test_sk_…3. Create a payment
Call payments.create() with an amount, currency, and at least one payment method. NahuPay returns a checkout_url — redirect your customer there.
import NahuPay from 'nahupay';const client = new NahuPay({apiKey: process.env.NAHUPAY_SECRET_KEY});const payment = await client.payments.create({amount: 50000, // in ETB cents (500.00 ETB)currency: 'ETB',methods: ['telebirr', 'bank_transfer'],metadata: { order_id: 'ORD-1234' },success_url: 'https://yourstore.com/success',cancel_url: 'https://yourstore.com/cart',});// Redirect the customerconsole.log(payment.checkout_url);// → https://checkout.nahupay.com/pay/ch_abc123The response object includes:
| Field | Type | Description |
|---|---|---|
id | string | Payment ID — use this in webhooks and refunds |
status | string | pending | completed | failed | expired |
checkout_url | string | Redirect your customer here |
expires_at | ISO 8601 | Checkout URL expires after 30 minutes |
4. Listen for webhooks
NahuPay sends a payment.completed event to your webhook endpoint when the customer finishes paying. Use the NahuPay CLI to forward events to your local dev server:
npx nahupay listen --forward-to localhost:3000/webhooks/nahupayIn your handler, verify the signature before processing:
import NahuPay from 'nahupay';const client = new NahuPay({apiKey: process.env.NAHUPAY_SECRET_KEY});export async function POST(req: Request) {const body = await req.text();const signature = req.headers.get('NahuPay-Signature')!;const event = client.webhooks.constructEvent(body,signature,process.env.NAHUPAY_WEBHOOK_SECRET);if (event.type === 'payment.completed') {const payment = event.data.object;// fulfill order for payment.metadata.order_idconsole.log('Payment received:', payment.id);}return Response.json({ received: true });}Go live
When you're ready to accept real payments, replace your test_sk_… key with your live_sk_… key and update your webhook secret. The API is identical — no code changes needed.
live_ key from an unverified account will be rejected.