This guide will help you integrate Notch Pay into your application or website quickly. We’ll walk through the basic steps to accept your first payment.

Prerequisites

Before you begin, make sure you have:

Integration Steps

1

Get Your API Keys

  1. Log in to your Notch Pay Business suite
  2. Navigate to Settings > API Keys
  3. Copy your API key (use your test key for development and testing)
2

Create a Simple Payment

Let’s create a basic payment using the Notch Pay API:

// Using fetch in JavaScript
fetch('https://api.notchpay.co/payments', {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_PUBLIC_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    amount: 5000,
    currency: 'XAF',
    customer: {
      name: 'John Doe',
      email: 'john@example.com',
      phone: '+237600000000'
    },
    description: 'Payment for Order #123',
    callback: 'https://your-website.com/callback',
    reference: 'order_123'
  })
})
.then(response => response.json())
.then(data => {
  // Redirect the customer to the payment page
  window.location.href = data.authorization_url;
})
.catch(error => console.error('Error:', error));
3

Redirect to the Payment Page

After creating a payment, you’ll receive a response with an authorization_url. Redirect your customer to this URL to complete the payment:

window.location.href = data.authorization_url;
// Example: https://pay.notchpay.co/pay_123456789

4

Handle the Callback

When the payment is completed (or fails), Notch Pay will redirect the customer back to your callback URL with the payment status:

// Example callback handler in Express.js
app.get('/callback', (req, res) => {
  const reference = req.query.reference;
  
  // Verify the payment status
  fetch(`https://api.notchpay.co/payments/${reference}`, {
    headers: {
      'Authorization': 'YOUR_PUBLIC_KEY'
    }
  })
  .then(response => response.json())
  .then(data => {
    if (data.transaction.status === 'complete') {
      // Payment successful, update your database and show success page
      res.send('Payment successful!');
    } else {
      // Payment failed or is still pending
      res.send('Payment not completed.');
    }
  })
  .catch(error => {
    console.error('Error:', error);
    res.status(500).send('Error verifying payment');
  });
});
5

Set Up Webhooks (Recommended)

For more reliable payment notifications, set up webhooks to receive real-time updates about payment status changes:

1

Create Webhook Endpoint

Create an endpoint on your server to receive webhook events:

// Example webhook handler in Express.js
app.post('/webhooks', express.json(), (req, res) => {
  const event = req.body;
  
  // Verify webhook signature (recommended for security)
  // ...
  
  // Handle different event types
  switch (event.type) {
    case 'payment.complete':
      // Update order status to paid
      break;
    case 'payment.failed':
      // Handle failed payment
      break;
    // Handle other event types
  }
  
  // Acknowledge receipt of the webhook
  res.status(200).send('Webhook received');
});
2

Register Webhook URL

  1. Go to your Dashboard > Settings > Webhooks
  2. Add a new webhook with your endpoint URL (e.g., https://your-website.com/webhooks)
  3. Select the events you want to receive (e.g., payment.complete, payment.failed)
3

Secure Your Webhooks

Check our Webhook Security Guide for implementation details.

Next Steps

Here are some next steps to enhance your integration:

Sample Applications

Check out these sample applications to see Notch Pay in action:

Need Help?