Payment methods
GET /api/payments/methods/
Returns all accepted payment methods. This endpoint is public — no authentication is required.(none)
No query parameters are accepted by this endpoint.
List of accepted payment methods.
Total count of payment methods returned.
Payment records
All endpoints below require authentication.Authenticated users see only their own payments. Staff and superusers see all payments across all users.
GET /api/payments/
List payment records visible to the authenticated user.POST /api/payments/create/
Create a new payment record and link it to an existing purchase order. The operation runs inside a database transaction — if any step fails, the entire operation rolls back. Request bodyID of the purchase order to pay. The order must be in
PENDING or PAID status.Payment method code stored in the
Payments model. One of CARD, PAYPAL, SINPE, CASH.The
Payments model stores the method as CARD (not MASTERCARD or VISA). The specific card network is tracked at the frontend/payment-processor level. Use GET /api/payments/methods/ to map the user-facing labels (Mastercard, Visa) to their display values.External transaction identifier. Required for
MASTERCARD, VISA, and PAYPAL. Optional for CASH and SINPE. Must be 5–100 alphanumeric characters, hyphens, or underscores.Initial payment status. One of
SUCCESS, FAILED.cURL
Unique payment record ID.
ID of the linked purchase order.
ISO 8601 datetime when the payment was recorded. Set automatically on creation.
Payment method used. One of
CARD, PAYPAL, SINPE, CASH (as stored in the Payments model).External transaction identifier.
Payment result.
SUCCESS or FAILED.Total amount of the linked purchase order (read-only, computed field).
Current status of the linked purchase order after the payment was applied (read-only, computed field).
Number of days elapsed since
payment_date (read-only, computed field).GET /api/payments//
Retrieve a single payment record by ID.Payment record ID.
PUT /api/payments//update/
Update a payment record. Accepts the same body fields asPOST /api/payments/create/. The update also runs inside a database transaction.
DELETE /api/payments//delete/
Delete a payment record.Status transitions and side effects
When a payment record is saved, the model automatically triggers state changes on the linked purchase order:| Payment status | Purchase order effect |
|---|---|
SUCCESS | Order is marked as paid (mark_as_paid) |
FAILED | Order is cancelled and reserved visit slots are released (mark_as_cancelled) |
Audit trail
All payment creation and status changes are captured by Django signals inpurchase_orders/audit.py. Events are written to logs/payments.log with the following fields: timestamp, event_type, model, instance_id, user_id, user_email, changes, and extra_data. Critical events (PAYMENT_SUCCESS, PAYMENT_FAILED) emit dedicated log entries in addition to the generic UPDATE entry.
Donations
The donations system allows supporters to contribute to the park. Managed through the samepayments app.
The
Donation model does not require a linked PurchaseOrders record — it is independent. Authenticated users can submit and view their own donations.Donation model
| Field | Type | Description |
|---|---|---|
id | integer | Auto-generated primary key |
amount | decimal(10,2) | Donation amount |
currency | string | CRC (colones) or USD (dollars) |
donor_name | string (max 100) | Optional donor name |
donor_email | Optional donor email | |
payment_method | string | CARD, PAYPAL, or CASH (includes SINPE) |
transaction_id | string (max 100) | Optional external transaction reference |
status | string | SUCCESS, FAILED, or PENDING (default) |
created_at | datetime | Auto-set on creation |
GET /api/payments/donations/
List donation records. Admins see all donations; regular users see only their own.Requires authentication.
POST /api/payments/donations/create/
Create a new donation record.Requires authentication.
Donation amount. Must be a positive decimal (e.g.,
5000.00).Currency code:
CRC or USD.Optional name of the donor (max 100 characters).
Optional email address for the donor.
Payment method:
CARD, PAYPAL, or CASH (includes SINPE).Optional external transaction reference from the payment processor.
Initial status:
SUCCESS, FAILED, or PENDING. Defaults to PENDING.