Direct Charge
Integrate Notch Pay directly into your application using our RESTful API
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:
- Initialize a Payment: Create a payment with customer and transaction details
- Process the Payment: Process the payment with the customer’s chosen payment method
- 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:
- Extract the reference from the URL parameters
- Verify the payment status by calling the API
- 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:
- Go to Settings > Webhooks
- Click “Add Endpoint”
- Enter your endpoint URL (e.g.,
https://your-website.com/webhooks/notchpay
) - Select the events you want to receive (e.g.,
payment.complete
,payment.failed
) - 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:
- Use your test API key
- Use test payment methods to simulate different scenarios
- Verify that your callback handling and webhook processing work correctly
- Test error scenarios to ensure your application handles them gracefully
Going Live
When you’re ready to go live:
- Switch to your live API key
- Update your webhook endpoints to production URLs
- Make a test payment in production to verify everything works correctly
- 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
- Keep it Relevant: Only include data that’s useful for your business processes
- Avoid Sensitive Data: Never store sensitive customer information in metadata
- Size Limitations: Keep metadata concise as there may be size limitations
- Consistent Structure: Use a consistent structure for your metadata across transactions
- Searchable Keys: Use keys that make sense for searching and filtering transactions later
Best Practices
- Secure Your API Key: Never expose your API key in client-side code
- Validate Input: Validate all input parameters before sending them to the API
- Handle Errors Gracefully: Implement proper error handling for a better user experience
- Use Webhooks: Set up webhooks for reliable payment notifications
- Log Transactions: Keep detailed logs of all transactions for troubleshooting
- Utilize Metadata: Use metadata to link payments to your internal systems
API Reference
For detailed API documentation, see the Payments API Reference.