POST
/payment
Create a payment
Send your payment creation payload here. Include an order identifier, user id, and customer email so the row can be matched later by the webhook.
Expected request fields
| Field | Notes |
|---|---|
orderId | Required. Used as orders.order_id. |
amount | Required. Sent to the payment service. |
currency | Required. Example: ZAR. |
customer.email | Required. Passed through to the payment service. |
userId | Required. Stored in payment metadata. |
Flow
- The API forwards the request to the configured payments service.
- The API stores a pending order row in the
orderstable. - The webhook updates the row when payment status changes.
Webhook
Register this URL in the payment provider dashboard:
/payment/webhook
Webhook payload shape
{
"event": "charge.success",
"data": {
"id": 6181112847,
"status": "success",
"reference": "pay-...-ORDER-94-87",
"currency": "ZAR",
"metadata": {
"tenantId": "tenant-uuid",
"orderId": "ORDER-94",
"paymentId": "87",
"userId": "41",
"customerEmail": "cairnswm@gmail.com"
}
}
}
Database schema
The orders and payment_webhook tables must be created before using the payment routes. See scripts/orders.sql and scripts/payment_webhook.sql.