Payments API
The Payments API allows you to initialize, retrieve, and manage payment transactions. Use these endpoints to accept payments from your customers through various payment methods.
The Payment Object
Payment Object Properties
string
Unique identifier for the payment
string
Your custom reference for the payment
number
Amount of the payment in the smallest currency unit
string
Three-letter ISO currency code
string
Status of the payment:
pending, processing, complete, failed, canceled, expiredstring
ID of the customer making the payment
string
ID of the payment method used
string
Description of the payment
object
Additional data attached to the payment
string
Timestamp when the payment was created
string
Timestamp when the payment was completed (if applicable)
API Endpoints
List All Payments
- Request
- Response
Query Parameters
integer
Number of items per page (default: 30, max: 100)
integer
Page number (default: 1)
string
Search by reference
string
Filter by status
string
Filter by payment channels (comma-separated)
string
Start date filter (format: YYYY-MM-DD)
string
End date filter (format: YYYY-MM-DD)
Create a Payment
- Request
- Response
Initialize a new payment. Both endpoints are equivalent and can be used interchangeably.
Request Parameters
number
required
Amount to charge in the smallest currency unit
string
required
Three-letter ISO currency code (e.g., XAF)
string
Customer’s email address (required if
phone and customer are not provided)string
Customer’s phone number (required if
email and customer are not provided)string or object
Customer ID or object (required if
email and phone are not provided)string
Description of the payment
string
Unique reference for the payment
string
URL to redirect after payment completion
Advanced Parameters
Advanced Parameters
Example Request
Process a Payment
- Request
- Response
Process a pending payment with a specific payment method. Both HTTP methods are equivalent.
Path Parameters
string
required
Reference of the payment to process
Request Parameters
string
required
Payment channel (e.g., cm.mtn, cm.orange)
object
Channel-specific data
string
Client’s IP address
Mobile Money Parameters
Mobile Money Parameters
Example Request for MTN Mobile Money
Payment Statuses
pending
Payment has been initialized but not yet processed
processing
Payment is being processed by the payment provider
complete
Payment has been completed
failed
Payment attempt failed
canceled
Payment was canceled by the merchant or customer
expired
Payment expired before completion
Handling Callbacks
1
Redirect to Callback URL
When a payment is completed, Notch Pay will redirect the customer to the
callback URL you provided when creating the payment. The URL will include the payment reference as a query parameter:2
Verify Payment Status
Always verify the payment status by calling the Retrieve a Payment endpoint before fulfilling the order.
3
Fulfill the Order
Once you’ve verified that the payment is complete, you can fulfill the order or provide access to the purchased product or service.
Webhooks
For more reliable payment notifications, we recommend setting up webhooks to receive real-time updates about payment status changes.
Error Handling
Common Error Codes
Common Error Codes
Bad Request
Invalid request parametersThis typically occurs when required parameters are missing or have invalid values.
Unauthorized
Invalid API keyCheck that you’re using the correct API key and that it’s properly included in the Authorization header.
Not Found
Payment not foundThe payment reference you provided doesn’t exist or belongs to another account.
Unprocessable Entity
Payment cannot be processedThis occurs when trying to process a payment that’s already completed, canceled, or in a state that doesn’t allow the requested operation.
Best Practices
Store Payment References
Always store the payment ID and reference in your database for future reference and reconciliation.
Verify Payment Status
Always verify the payment status using the API before fulfilling orders or providing services.
Use Webhooks
Set up webhooks for reliable payment notifications, especially for asynchronous payment methods like mobile money.
Idempotent References
Use unique, idempotent references for each payment to prevent duplicate payments and simplify reconciliation.
Error Handling
Implement proper error handling for failed payments, including user-friendly error messages and recovery options.