Complete step-by-step guide covering everything from account setup to handling webhooks in production.
Set up your development environment and credentials.
# Install SDK
npm install @gopaynow/node-sdk
# Environment variables
GOPAYNOW_SECRET_KEY=sk_test_your_secret_key
GOPAYNOW_PUBLIC_KEY=pk_test_your_public_key
GOPAYNOW_WEBHOOK_SECRET=whsec_your_webhook_secret
Configure the GoPayNow SDK in your application.
const GoPayNow = require('@gopaynow/node-sdk');
const gopaynow = new GoPayNow({
secretKey: process.env.GOPAYNOW_SECRET_KEY,
environment: 'sandbox' // or 'production'
});
Complete payment flow from creation to webhook handling.
// Create payment link
const paymentLink = await gopaynow.paymentLinks.create({
amount: 5000,
currency: 'USD',
description: 'Premium Plan',
success_url: 'https://yoursite.com/success',
cancel_url: 'https://yoursite.com/cancel',
metadata: {
user_id: 'user_123',
plan: 'premium'
}
});
// Redirect user to payment
res.redirect(paymentLink.url);
Handle payment events securely with webhooks.
app.post('/webhook', express.raw({type: 'application/json'}), (req, res) => {
const signature = req.headers['x-gopaynow-signature'];
try {
const event = gopaynow.webhooks.constructEvent(
req.body,
signature,
process.env.GOPAYNOW_WEBHOOK_SECRET
);
switch (event.type) {
case 'payment.completed':
await handlePaymentCompleted(event.data);
break;
case 'payment.failed':
await handlePaymentFailed(event.data);
break;
}
res.status(200).send('OK');
} catch (error) {
res.status(400).send('Invalid signature');
}
});
You now have a complete GoPayNow integration!
Accept payments with ease
Real-time event handling
Industry-standard security