GET
/
api
/
v1
/
stripe
/
payment-intent
Create Payment Intent
curl --request GET \
  --url https://api.cravejs.com/api/v1/stripe/payment-intent \
  --header 'X-API-Key: <api-key>'
{
  "clientSecret": "pi_3RmBZTEb6J2s4OeE0DlFrdFs_secret_SxKDd2UGuByUHMDlxWtQxML1m",
  "amount": 2847,
  "currency": "usd",
  "metadata": {
    "cartId": "cart_12345",
    "locationId": "loc_67890",
    "customerId": "cus_abcdef"
  }
}

Query Parameters

locationId
string
required
The unique identifier for the restaurant location
cartId
string
required
The unique identifier for the cart to process payment for

Headers

Authorization
string
Bearer token for authenticated customers (optional for guest checkout)
Format: Bearer {jwt_token}
X-API-Key
string
required
Storefront API key for authentication

Response

clientSecret
string
required
The Stripe client secret needed to complete payment on the frontend
amount
number
Total payment amount in cents (including tax and fees)
currency
string
Three-letter ISO currency code (e.g., “usd”)
metadata
object
Additional metadata associated with the payment intent
{
  "clientSecret": "pi_3RmBZTEb6J2s4OeE0DlFrdFs_secret_SxKDd2UGuByUHMDlxWtQxML1m",
  "amount": 2847,
  "currency": "usd",
  "metadata": {
    "cartId": "cart_12345",
    "locationId": "loc_67890",
    "customerId": "cus_abcdef"
  }
}

Error Responses

{
  "error": "INVALID_CART",
  "message": "Cart not found or expired",
  "details": {
    "cartId": "cart_12345"
  }
}
{
  "error": "EMPTY_CART", 
  "message": "Cart contains no items",
  "details": {
    "cartId": "cart_12345"
  }
}
{
  "error": "UNAUTHORIZED",
  "message": "Invalid or missing API key"
}
The endpoint returns a Stripe client secret that should be used with Stripe’s client-side libraries (like Stripe.js) to complete the payment. When an authenticated customer makes the request (with Authorization header), the payment intent is automatically associated with their Stripe customer ID for future payment method saving. The amount includes all applicable taxes, fees, and discounts from the cart.
Ensure the cart is validated and contains available items before creating a payment intent. The payment intent amount is calculated based on the current cart state and cannot be modified after creation.

Authorizations

X-API-Key
string
header
required

Headers

Authorization
string

Bearer token for authenticated customers (optional for guest checkout). Format: Bearer {jwt_token}

Query Parameters

locationId
string
required

The unique identifier for the restaurant location

cartId
string
required

The unique identifier for the cart to process payment for

Response

200
application/json

Payment intent created successfully.

The response is of type object.