The API supports two checkout flows: a direct flow for bank transfers, voucher uploads, or cash-on-delivery payments, and a MercadoPago flow for card and online payments. Both flows require a valid Bearer token, read the authenticated user’s current cart, create aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/JuanSCaicedo/Api-Ecommerce/llms.txt
Use this file to discover all available pages before exploring further.
Sale record with SaleDetail rows, decrement product stock, clear the cart, and send a confirmation email.
Direct Checkout Flow
Use this flow when the customer pays by bank transfer, uploads a payment voucher, or uses any non-MercadoPago payment method.(Optional) Save checkout data temporarily
Before the customer finalises the order, you can persist the delivery address and order notes server-side. This is especially useful for multi-step checkout forms where the user may navigate away.POST /api/ecommerce/checkout-tempThe server upserts a
SaleTemp record for the authenticated user (one record per user). The sale_address object is JSON-encoded and stored in the SaleTemp.sale_address column.Response:Place the order
Submits the order. The server reads the authenticated user’s cart, creates the sale record, and processes all cart items.POST /api/ecommerce/checkoutThis endpoint accepts
multipart/form-data when uploading a voucher image. Use application/json when file_imagen is not included.Body parameters
Grand total of the order in the selected currency.
Order subtotal before any additional fees.
Optional delivery notes or order comments.
Payment method identifier, e.g.
"bank_transfer", "cash", "voucher".Optional external transaction or reference number supplied by the customer.
Optional payment voucher image (JPG, PNG, etc.). Stored in OCI Object Storage under
juandevops/ecommerce/public/comprobantes/.Delivery address. See sale_address fields below.
Server processes the order
After receiving the request the server performs these actions:
- Creates a
Salerecord withuser_id,total,subtotal,description,method_payment,n_transaccion. - If
file_imagenwas uploaded, stores the file in OCI Object Storage and updatessale.comprobante. - For each cart item, creates a
SaleDetailrecord cloned from the cart item. - Decrements stock:
- If
product_variation_idis set: decrements the variation’s stock (and its parent variation’s stock if it is a sub-variation). - Otherwise: decrements the base product’s stock.
- If
- Deletes the cart item.
- Creates a
SaleAddresrecord from thesale_addresspayload. - Calls
Cache::flush()to invalidate all cached product and storefront data. - Sends a
SaleMailconfirmation email to the authenticated user’s email address.
MercadoPago Flow
Use this flow when the customer pays online via MercadoPago (credit/debit card, PSE, etc.).Save checkout data temporarily
Persist the delivery address before redirecting to MercadoPago.POST /api/ecommerce/checkout-temp — same as Step 1 of the direct flow above.
Create a MercadoPago preference
The server reads the authenticated user’s cart, maps each item to a MercadoPago preference item, and creates a preference via the MercadoPago Preferences API.GET /api/ecommerce/mercadopagoThe preference is created with:If the cart is empty, the server returns
items— each cart item mapped to{ title, quantity, currency_id, unit_price }.unit_priceisround(subtotal).back_urls.success→{URL_TIENDA}mercado-pago-successback_urls.failure→{URL_TIENDA}mercado-pago-failureback_urls.pending→{URL_TIENDA}mercado-pago-pendingredirect_urls— same paths asback_urls.auto_return: "approved"— MercadoPago auto-redirects on success.external_reference— a unique ID generated withuniqid().
{ "message": "El carrito está vacío" } with status 200.Redirect the customer to MercadoPago
Use
preference.init_point (production) or preference.sandbox_init_point (testing) to redirect the customer to the MercadoPago-hosted payment page. The customer completes payment on MercadoPago’s platform.MercadoPago redirects back to your storefront
After a successful payment MercadoPago redirects to:Your frontend must extract the
payment_id query parameter from this URL.Confirm the order
Call this endpoint from your frontend with the The server:
payment_id received from MercadoPago’s redirect.POST /api/ecommerce/checkout-mercadopagoThe MercadoPago
payment_id returned in the redirect URL query string.- Fetches payment details from
https://api.mercadopago.com/v1/payments/{n_transaccion}usingMERCADOPAGO_KEY. - Reads
transaction_amountfrom the MercadoPago response and sets it as bothtotalandsubtotalon the sale. - Reads the
SaleTemprecord for the user and uses itsdescriptionandsale_address(decoded from JSON). - Creates
Sale,SaleDetailrows, decrements stock, clears cart, createsSaleAddres, flushes cache, and sends the confirmation email — identical to the direct checkout flow.
sale_address Fields
Thesale_address object is required for both checkout flows and maps directly to the UserAddres model fields. It is persisted in the SaleAddres table linked to the created sale.
Recipient’s first name.
Recipient’s last name.
Contact phone number, e.g.
"+573001234567".Street address, e.g.
"Calle 123 # 45-67".Additional street / apartment line, e.g.
"Avenida Principal".City of delivery, e.g.
"Bogotá".Country or region of delivery, e.g.
"Colombia".Postal / ZIP code, e.g.
"110111".Recipient email address for delivery notifications.
Optional company name.
Post-Checkout Side Effects
Regardless of which checkout flow is used, the server always performs these side effects upon successful order creation:- Cache flush —
Cache::flush()is called, invalidating all cached storefront responses including the home feed and all product detail pages. - Confirmation email — a
SaleMailemail is dispatched to the authenticated user’s registered email address containing the order summary.