Payment Methods API
Manage payment methods (M-Pesa, Pesapal, Cash on Delivery). Configure environment (sandbox or production), enable/disable methods, and update settings. All routes require Authorization: Bearer <access_token> and admin role. Base path: <API_BASE_URL>/admin/payment-methods.
Payment Method
id, type (mpesa | pesapal | cash_on_delivery), name, description, icon, is_enabled, environment (sandbox | production), display_order, instructions, created_at, updated_at. The environment determines which credentials (sandbox vs production) are used for M-Pesa and Pesapal API calls.
Get all payment methods
Returns all payment methods (enabled and disabled), ordered by display_order. Response: {"payment_methods": [{"id", "type", "name", "description", "icon", "is_enabled", "environment", "display_order", "instructions", "created_at", "updated_at"}, ...]}.
Create payment method
Create a payment method. Body: type (required; mpesa | pesapal | cash_on_delivery), name (optional; defaults to type label), description, icon, is_enabled (optional, default false), environment (optional, default sandbox), instructions. Returns full payment method (201). 409 if type already exists.
Update payment method
Update settings. Body: optional name, description, icon, instructions, display_order, is_enabled. Returns full payment method. 404 if not found.
Enable or disable payment method
Enable the payment method. Sets is_enabled to true. Returns full payment method. 404 if not found.
Disable the payment method. Sets is_enabled to false. Returns full payment method. 404 if not found.
Switch environment
Switch between sandbox and production. Body: {"environment": "sandbox"} or {"environment": "production"}. M-Pesa and Pesapal use the configured environment for API calls. Returns full payment method. 404 if not found. 400 if environment is invalid.
Common responses
401 if missing or invalid token. 403 if not admin. 404 if payment method not found. 409 if payment method type already exists (on create). 400 if validation fails (e.g. missing type, invalid environment).