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
Unique identifier for the payment
Your custom reference for the payment
Amount of the payment in the smallest currency unit
Three-letter ISO currency code
Status of the payment:
pending
, processing
, complete
, failed
, canceled
, expired
ID of the customer making the payment
ID of the payment method used
Description of the payment
Additional data attached to the payment
Timestamp when the payment was created
Timestamp when the payment was completed (if applicable)
API Endpoints
List All Payments
Query Parameters
Number of items per page (default: 30, max: 100)
Page number (default: 1)
Search by reference
Filter by status
Filter by payment channels (comma-separated)
Start date filter (format: YYYY-MM-DD)
End date filter (format: YYYY-MM-DD)
Create a Payment
Initialize a new payment. Both endpoints are equivalent and can be used interchangeably.
Request Parameters
Amount to charge in the smallest currency unit
Three-letter ISO currency code (e.g., XAF)
Customer’s email address (required if
phone
and customer
are not provided)Customer’s phone number (required if
email
and customer
are not provided)Customer ID or object (required if
email
and phone
are not provided)Description of the payment
Unique reference for the payment
URL to redirect after payment completion
Advanced Parameters
Advanced Parameters
Restrict to a specific currency
Restrict to a specific payment channel
Restrict to a specific country
Array of items being purchased
Shipping information
Customer’s address
Additional customer metadata
Example Request
Process a Payment
Process a pending payment with a specific payment method. Both HTTP methods are equivalent.
Path Parameters
Reference of the payment to process
Request Parameters
Payment channel (e.g., cm.mtn, cm.orange)
Channel-specific data
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
Invalid request parametersThis typically occurs when required parameters are missing or have invalid values.
Invalid API keyCheck that you’re using the correct API key and that it’s properly included in the Authorization header.
Payment not foundThe payment reference you provided doesn’t exist or belongs to another account.
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.