Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ALEJ4NDRO2025/urban-store/llms.txt

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

Before the user can enter card details, your frontend must request a Stripe PaymentIntent from this endpoint. The server validates that the order exists, belongs to the authenticated user, and is still in the pending state, then creates a PaymentIntent via Stripe’s API, stores the resulting payment_intent_id on the order, and returns the client_secret. Pass client_secret directly to Stripe Elements’ confirmPayment() to render the payment form.

Endpoint

POST /api/payments/create-payment-intent/

Authentication

Bearer token required. Returns 401 if the token is missing or invalid.

Request Body

order_id
string
required
The MongoDB ObjectId of the order for which to create the payment intent. The order must belong to the authenticated user and have status: "pending".

Stripe PaymentIntent Parameters

ParameterValue
amountorder.total * 100 (integer, centavos)
currency"cop"
metadata.order_idString representation of the order’s MongoDB ObjectId
The Stripe payment_intent_id (e.g. pi_3PQ...) is saved back to the order document for reconciliation.

How to Use client_secret

Pass the returned client_secret to Stripe.js when confirming payment on the frontend:
const { error } = await stripe.confirmPayment({
  elements,
  clientSecret: data.client_secret,
  confirmParams: {
    return_url: "https://yourstore.co/order/success",
  },
});
After Stripe redirects to your return_url, call POST /api/payments/confirm-payment/ with the order_id and the payment_intent parameter from the URL.

Request Example

{
  "order_id": "664f1a2b3c4d5e6f7a8b9c0d"
}
curl -X POST https://api.urbanstore.co/api/payments/create-payment-intent/ \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"order_id": "664f1a2b3c4d5e6f7a8b9c0d"}'

Response — 200 OK

client_secret
string
Stripe PaymentIntent client secret in the form pi_<id>_secret_<key>. Pass this to Stripe Elements to render and confirm the payment form.
{
  "client_secret": "pi_3PQ1RxKZ2eZvKYlo1AbCdEfG_secret_xYzAbCdEfGhIjKlMnOpQrStUv"
}

Error Responses

StatusCondition
401 UnauthorizedToken missing, malformed, or expired
400 Bad Requestorder_id not provided in the request body
400 Bad RequestOrder status is not "pending" (already processed)
400 Bad RequestStripe API returned an error (StripeError)
404 Not FoundNo order found with the given order_id for this user
A pending order expires after 5 minutes. Ensure the user initiates payment promptly after checkout. If the order has already expired and been auto-cancelled, this endpoint returns 400 because status != "pending".

Build docs developers (and LLMs) love