Implementing the Payment Form
Last updated
Last updated
Use this guide & video to get your Payram-integrated Next.js app up and running, whether you’re developing locally or deploying to production.
Before you begin, ensure you have the following installed:
Node.js & npm
Recommended: Node.js v18.x or later (includes npm).
Verify:
node --version
npm --version
Git
To clone the repository.
Verify:
git --version
Optional Tools
VS Code (or another IDE) with ESLint & Prettier extensions.
Postman or curl for testing webhooks and API endpoints.
git clone https://github.com/iam-joey/api-payram-integration.git
cd api-payram-integration
Copy the example file and rename it:
cp .env.example .env
Open .env
in your editor and set: (yourdomain is where your PayRam Server is hosted)
PAYRAM_API_URL="http://yourdomain:8080/api/v1/payment"
API_KEY="your-payram-api-key-here"
PAYRAM_API_URL The base URL for Payram’s API. Keep as-is for local testing or update if your Payram server is hosted elsewhere.
API_KEY Your secret key provided by Payram — required for all API requests.
Tip: Do not commit
.env
to source control. Add it to.gitignore
if it isn’t already.
From the project root, run:
npm install
This will install everything listed in package.json
.
Start your app in development mode:
npm run dev
Open your browser at http://localhost:3000.
The page auto-reloads on file changes.
src/app/page.tsx
A client-side Next.js component handling:
Customer ID (auto-generated, read-only)
Payment Amount (USD)
Customer Email
Features:
Basic client-side validation
POST to /api/initiate-payment
on submit
Toast notifications for success, error, or redirection
Opens Payram payment URL in a new tab when provided
All routes live under src/app/api/
:
POST /api/initiate-payment
src/app/api/initiate-payment/route.ts
Starts a Payram transaction; returns a redirect URL.
POST /api/v1/payment/webhook
src/app/api/v1/payment/webhook/route.ts
Receives Payram webhook events to update transaction status.
To test the webhook endpoint before deploying:
Install ngrok (or similar) to expose your localhost:3000
:
npm install -g ngrok
ngrok http 3000
Copy the generated https://xxxx.ngrok.io
URL.
In your Payram dashboard, configure the webhook URL to:
https://xxxx.ngrok.io/api/v1/payment/webhook
Trigger a payment on the frontend and observe webhook logs in your terminal.
Build:
npm run build
Start Production Server:
npm start
Environment Variables:
Use a .env.production
or your hosting provider’s secret management.
Push your repo to GitHub (if not already).
Sign in at vercel.com and “Import Project” from GitHub.
In Project Settings, add Environment Variables (PAYRAM_API_URL
, API_KEY
).
Deploy — Vercel auto-builds and provides you a live URL.
For detailed Vercel instructions, see their Next.js Deployment Docs.
With these steps, you should have a fully operational local development environment, webhook testing setup, and a clear path to production deployment. Happy coding!