Skip to main content
Notch Pay’s Directe Charge allows you to build a custom payment experience directly into your application. With our RESTful API, you have complete control over the payment flow while still benefiting from Notch Pay’s secure payment processing.

Overview

The API integration gives you:
  • Complete control over the payment flow
  • Seamless integration with your existing systems
  • Support for all payment methods
  • Webhook notifications for payment events
  • Detailed transaction data

When to Use API Integration

  • You need a fully customized payment experience
  • You want to integrate payments into your existing application
  • You need to implement complex payment flows
  • You want to build a custom payment form

Alternatives

  • Collect: For a quick integration with minimal coding
  • Payment Links: For sharing payment links without coding
  • Invoices: For creating and managing invoices

Authentication

All API requests must include your API key in the Authorization header:
You can find your API keys in your Notch Pay Business suite under Settings > API Keys. Make sure to use your test API key for development and your live API key for production.

Basic Payment Flow

The basic payment flow with the Notch Pay API consists of three main steps:
  1. Initialize a Payment: Create a payment with customer and transaction details
  2. Process the Payment: Process the payment with the customer’s chosen payment method
  3. Verify the Payment: Check the payment status to confirm completion

1. Initialize a Payment

To initialize a payment, make a POST request to the /payments endpoint:

Response

2. Process the Payment

You have two options for processing the payment:

Option 1: Redirect to Checkout

Redirect the customer to the authorization_url from the response:
This will take the customer to the Notch Pay Checkout page where they can select a payment method and complete the payment.

Option 2: Direct API Processing

Process the payment directly through the API with the customer’s chosen payment method:

Response

3. Verify the Payment

After processing the payment, you should verify its status:

Response

Payment Methods

Notch Pay supports various payment methods, each with its own processing requirements:

Mobile Money

For Mobile Money payments, you need to specify the channel and phone number:

Digital Wallets

For digital wallet payments, you need to specify the wallet provider:

Handling Callbacks

When a customer completes a payment, they will be redirected to your callback URL with the payment reference:
Your callback handler should:
  1. Extract the reference from the URL parameters
  2. Verify the payment status by calling the API
  3. Update your database and show the appropriate page to the customer
Example callback handler in Node.js (Express):

Implementing Webhooks

Webhooks provide a more reliable way to receive payment notifications, especially for asynchronous payment methods like Mobile Money.

1. Set Up a Webhook Endpoint

Create an endpoint in your application to receive webhook notifications:

2. Register Your Webhook

Register your webhook endpoint in your Notch Pay dashboard:
  1. Go to Settings > Webhooks
  2. Click “Add Endpoint”
  3. Enter your endpoint URL (e.g., https://your-website.com/webhooks/notchpay)
  4. Select the events you want to receive (e.g., payment.complete, payment.failed)
  5. Click “Save”

Error Handling

The Notch Pay API returns standard HTTP status codes and detailed error messages:
Implement proper error handling in your integration:

Testing

Before going live, thoroughly test your integration in the sandbox environment:
  1. Use your test API key
  2. Use test payment methods to simulate different scenarios
  3. Verify that your callback handling and webhook processing work correctly
  4. Test error scenarios to ensure your application handles them gracefully

Going Live

When you’re ready to go live:
  1. Switch to your live API key
  2. Update your webhook endpoints to production URLs
  3. Make a test payment in production to verify everything works correctly
  4. Monitor your first few live transactions closely

Using Metadata

Metadata allows you to attach custom data to payments, which can be useful for tracking and reconciliation purposes.

Adding Metadata to Payments

When creating a payment, you can include a metadata object with any key-value pairs you want to associate with the payment:

Retrieving Metadata

When you retrieve a payment, the metadata will be included in the response:

Metadata Best Practices

  1. Keep it Relevant: Only include data that’s useful for your business processes
  2. Avoid Sensitive Data: Never store sensitive customer information in metadata
  3. Size Limitations: Keep metadata concise as there may be size limitations
  4. Consistent Structure: Use a consistent structure for your metadata across transactions
  5. Searchable Keys: Use keys that make sense for searching and filtering transactions later

Best Practices

  1. Secure Your API Key: Never expose your API key in client-side code
  2. Validate Input: Validate all input parameters before sending them to the API
  3. Handle Errors Gracefully: Implement proper error handling for a better user experience
  4. Use Webhooks: Set up webhooks for reliable payment notifications
  5. Log Transactions: Keep detailed logs of all transactions for troubleshooting
  6. Utilize Metadata: Use metadata to link payments to your internal systems

API Reference

For detailed API documentation, see the Payments API Reference.