Pay Invoice
Initiate payment for an invoice. Creates a payment intent that the customer can use to complete the payment.
note
This is a public endpoint — no authentication headers are required.
POST
https://api.zenpayz.com/merchant/api/v1/invoices/:invoiceId/payBearer · API key
Request
Path Parameters
| Parameter | Type | Description |
|---|---|---|
invoiceId REQUIRED | string | The invoice ID (e.g. inv_a1b2c3d4e5f6g7h8) |
Response
Success (200 OK)
{
"success": true,
"data": {
"invoiceId": "inv_a1b2c3d4e5f6g7h8",
"paymentIntentId": "pi_x1y2z3w4v5u6t7s8",
"amount": 275.00,
"currency": "USD",
"checkoutUrl": "https://checkout.zenpayz.com/pay/pi_x1y2z3w4v5u6t7s8"
},
"message": "Payment initiated successfully",
"error": null,
"meta": {
"request_id": "req_xxxxx",
"timestamp": "2024-01-15T10:30:00.000Z",
"processing_time_ms": 120,
"api_version": "v1",
"endpoint": "POST /invoices/:invoiceId/pay",
"user_type": "merchant"
}
}
Error Responses
| Code | HTTP | Message |
|---|---|---|
| INVOICE_NOT_FOUND | 404 | Invoice does not exist |
| INVOICE_ALREADY_PAID | 409 | Invoice has already been fully paid |
| INVOICE_CANCELLED | 409 | Cannot pay a cancelled invoice |
Examples
- cURL
- JavaScript
- SDK
curl -X POST https://api.zenpayz.com/merchant/api/v1/invoices/inv_a1b2c3d4e5f6g7h8/pay \
-H "Content-Type: application/json"
const response = await fetch('https://api.zenpayz.com/merchant/api/v1/invoices/inv_a1b2c3d4e5f6g7h8/pay', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
});
const result = await response.json();
console.log(result.data.checkoutUrl); // Redirect customer to this URL
const payment = await zenpays.invoices.pay('inv_a1b2c3d4e5f6g7h8');
console.log(payment.checkoutUrl); // Redirect customer to this URL