Skip to main content

Endpoint

POST /api/payments

Description

Registers a new payment record in the system. This endpoint stores payment information after a successful payment has been processed through a payment provider like Mercado Pago.
This endpoint is typically called after receiving a webhook notification from the payment provider, not directly by client applications.
See implementation in server/src/modules/payments/payments.controller.ts:13-23.

Authentication

This endpoint requires Bearer token authentication. Include your access token in the Authorization header.

Request Body

payment_id
string
required
Unique identifier from the payment provider (e.g., Mercado Pago payment ID)Example: 1234567890
reservation_id
string
required
ID of the reservation associated with this paymentExample: res_abc123
amount
number
required
Payment amountExample: 5000
currency
string
required
Currency code (e.g., ARS, USD)Example: ARS
status
string
required
Payment status from the providerExample: approved
payment_method
string
required
Payment method usedExample: credit_card
payer_email
string
Email of the person who made the paymentExample: [email protected]

Example Request Body

{
  "payment_id": "1234567890",
  "reservation_id": "res_abc123",
  "amount": 5000,
  "currency": "ARS",
  "status": "approved",
  "payment_method": "credit_card",
  "payer_email": "[email protected]"
}

Response

id
string
Unique identifier for the payment record in Zenda’s database
payment_id
string
Payment provider’s payment ID
reservation_id
string
Associated reservation ID
amount
number
Payment amount
currency
string
Currency code
status
string
Payment status
payment_method
string
Payment method used
payer_email
string
Payer’s email address
created_at
string
Timestamp when the payment record was created

Success Response (201)

{
  "id": "pay_xyz789",
  "payment_id": "1234567890",
  "reservation_id": "res_abc123",
  "amount": 5000,
  "currency": "ARS",
  "status": "approved",
  "payment_method": "credit_card",
  "payer_email": "[email protected]",
  "created_at": "2026-03-10T15:30:00.000Z"
}

Error Responses

400 Bad Request

{
  "statusCode": 400,
  "message": "Datos inválidos o error al procesar el pago.",
  "error": "Bad Request"
}
Invalid data provided or payment processing error.

401 Unauthorized

{
  "statusCode": 401,
  "message": "Token inválido o expirado",
  "error": "Unauthorized"
}
Missing or invalid Bearer token.

Code Examples

curl -X POST https://api.zenda.com/api/payments \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "payment_id": "1234567890",
    "reservation_id": "res_abc123",
    "amount": 5000,
    "currency": "ARS",
    "status": "approved",
    "payment_method": "credit_card",
    "payer_email": "[email protected]"
  }'

Payment Flow

1

Payment Preference Created

First, a payment preference is created via POST /api/reservations/payment
2

User Completes Payment

User is redirected to Mercado Pago and completes the payment
3

Webhook Received

Mercado Pago sends a webhook notification to Zenda
4

Payment Recorded

This endpoint is called to record the payment in the database
5

Reservation Created

The reservation is created via POST /api/reservations/create-with-payment

Use Cases

  • Recording successful payment transactions
  • Storing payment provider references
  • Tracking payment methods and amounts
  • Linking payments to reservations
  • Maintaining payment audit trail

Create Payment Preference

Generate a payment preference for Mercado Pago

Create With Payment

Create reservation after payment confirmation

Mercado Pago Integration

Learn about the payment integration

Build docs developers (and LLMs) love