🚀 30 Minute Guide - Most Popular

Zero to Hero Complete Integration

Complete step-by-step guide covering everything from account setup to handling webhooks in production.

1

Environment Setup

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
2

Initialize SDK

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'
});
3

Full Integration Flow

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);
4

Webhook Handler

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');
  }
});

🎉 Production Ready!

You now have a complete GoPayNow integration!

✅ Payments

Accept payments with ease

🔔 Webhooks

Real-time event handling

🔒 Secure

Industry-standard security