Node.js sample · Demo + sandbox

A real checkout flow. A shop you can run.

Start with a small T-shirt store. Add an item to your bag, try a payment, and follow the code from checkout to confirmation. No account needed for the local demo.

1 Run it in two minutes

Install Node.js 22.13 or newer, which includes npm. On macOS, Linux, or Windows with WSL, paste these commands into your terminal:

Terminal · install and start
curl -fsSL https://raw.githubusercontent.com/hamropatro/sample-store/main/install.sh | sh
cd sample-store
npm start

Open http://localhost:3000. You’re ready to shop.

No extra setup
No database, third-party runtime packages, or payment credentials required for demo mode.

The installer downloads release v1.0.0 into a new sample-store directory and creates your local .env. It preserves existing directories.

Install with Git, including Windows PowerShell

Terminal · clone the repository
git clone https://github.com/hamropatro/sample-store.git
cd sample-store
npm run setup
npm start

2 Try every payment outcome

Choose a T-shirt size, add it to your bag, and check out. The demo payment page lets you choose a successful, failed, or pending payment. No money moves and no physical order is created.

  • Successful: the return page shows the order as paid.
  • Failed: the order remains unpaid.
  • Pending: the order waits for confirmation.
  • Repeated confirmation: a paid order stays paid.

The server calculates the price from its product catalog. Changing an amount in your browser cannot change the order total.

3 Connect your test merchant

Create a sandbox merchant and obtain test credentials and connection details from Hamro Pay. Stop the store with Ctrl+C, then edit its .env:

.env · replace every placeholder
PAYMENT_MODE=sandbox
APP_URL=http://localhost:3000

HAMRO_MERCHANT_ID=your-test-selling-merchant-id
HAMRO_CLIENT_ID=your-test-client-id
HAMRO_API_KEY=your-test-api-key
HAMRO_CLIENT_SECRET=your-test-client-secret
HAMRO_USER_SECRET=your-test-user-secret

HAMRO_CREATE_SESSION_URL=full-https-endpoint-from-hamro-pay
HAMRO_CREATE_SESSION_METHOD=POST
HAMRO_GET_TRANSACTION_URL=full-https-endpoint-from-hamro-pay
HAMRO_GET_TRANSACTION_METHOD=confirmed-GET-or-POST
HAMRO_GATEWAY_URL=full-https-checkout-url-from-hamro-pay
Use confirmed connection details
The public reference does not specify full backend endpoint paths or methods. This sample supports POST for Create Session; confirm it with Hamro Pay. Its sandbox adapter has automated tests with simulated responses and still needs validation with your test account.

Run npm start again and create a new order. The store now opens Hamro Pay’s sandbox checkout. On return, your server verifies the transaction ID, amount, and payment status before marking the order paid.

Receive payment updates by webhook

Expose your local store with a public HTTPS development tunnel, set APP_URL to that origin, and open the shop at that address. Ask Hamro Pay to register /api/webhooks/hamropay at your tunnel URL. Add HAMRO_WEBHOOK_SECRET to your .env and restart.

The endpoint checks the signature and order details. Read the webhook reference for the payload and signing format.

Try Payments for Platforms

Keep the selling merchant in HAMRO_MERCHANT_ID. Add your platform merchant and commission percentage:

.env · optional commission
HAMRO_PLATFORM_MERCHANT_ID=your-test-platform-merchant-id
HAMRO_COMMISSION_PERCENTAGE=3

For a NPR 1,200 shirt, 3% allocates NPR 36 to the platform and NPR 1,164 to the seller, before applicable processing fees or adjustments. Hamro Pay handles the allocation. Confirm that both test merchants are configured for this arrangement.

Explore Payments for Platforms

Make it your own

  • Products and prices: src/catalog.mjs
  • Signing and Hamro Pay API calls: src/hamropay.mjs
  • Checkout, verification, and webhooks: src/app.mjs
  • Store design: public/index.html and public/style.css
Terminal · development and checks
npm run dev
# In another terminal:
npm test

Orders are saved in the local .data directory. This is a single-process learning sample with no live payment mode, inventory, shipping, or fulfillment. For a real shop, replace the JSON store with a transactional database and validate the complete payment flow with Hamro Pay.

Need a different port, a custom installation directory, or help with configuration? Read the full README and troubleshooting guide.

Hamro Pay Support

Grievance officer

Follow Us

© 2026 HamroPay. All Rights Reserved.