Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/AndrewwCO/Panahashi-Backend/llms.txt

Use this file to discover all available pages before exploring further.

The Payments API processes payments for orders using a simulated payment engine — no real card processing occurs. CASH_ON_PICKUP orders are always approved instantly; card and PSE payments simulate approval or rejection based on the card number provided.

Payment simulation rules

MethodBehavior
CASH_ON_PICKUPAlways APPROVED immediately
Any card not ending in 0000Always APPROVED
Card ending in 0000Always REJECTED
PSEAlways APPROVED

Payment object

id
string
Unique payment ID.
orderId
string
Associated order ID.
userId
string
Firebase UID of the payer.
amount
number
Amount charged.
method
string
Payment method used.
status
string
One of: PENDING, APPROVED, REJECTED, REFUNDED.
simulatedCardLast4
string
Last 4 digits of the simulated card (for card payments).
createdAt
integer
Epoch ms.
updatedAt
integer
Epoch ms.

POST /api/v1/payments

Creates and processes a payment for an order. The order must belong to the authenticated user and must not already be paid. Auth required: Yes — CUSTOMER
orderId
string
required
ID of the order to pay for.
method
string
required
Payment method: CREDIT_CARD, DEBIT_CARD, PSE, or CASH_ON_PICKUP.
simulatedCardLast4
string
Last 4 digits of card (required for card methods). Use 0000 to simulate rejection.
curl -X POST \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"orderId":"ord789","method":"CREDIT_CARD","simulatedCardLast4":"1234"}' \
  http://localhost:8080/api/v1/payments
Approved response (HTTP 200):
{
  "success": true,
  "data": {
    "id": "pay001",
    "orderId": "ord789",
    "status": "APPROVED",
    "method": "CREDIT_CARD",
    "amount": 7.0
  }
}
Rejected response (HTTP 402):
{
  "success": false,
  "data": {
    "id": "pay002",
    "orderId": "ord789",
    "status": "REJECTED",
    "method": "CREDIT_CARD",
    "amount": 7.0
  },
  "message": "Pago rechazado. Verifica los datos de tu tarjeta."
}
When a payment is approved, the baker receives an FCM notification for non-CASH orders. When rejected, the customer receives a rejection notification and the response HTTP status is 402 Payment Required.

GET /api/v1/payments/order/

Returns the payment record for an order. Auth required: Yes (any authenticated user)
orderId
string
required
Order ID.
curl -H "Authorization: Bearer <token>" \
  http://localhost:8080/api/v1/payments/order/ord789

POST /api/v1/payments/order//refund

Refunds a payment. Sets both the payment and order to REFUNDED status. Auth required: Yes — ADMIN
orderId
string
required
Order ID to refund.
curl -X POST \
  -H "Authorization: Bearer <token>" \
  http://localhost:8080/api/v1/payments/order/ord789/refund

Build docs developers (and LLMs) love