Skip to content
Dashboard

Create Payment Session

Creates a secure hosted checkout session for a customer payment and returns a checkout URL.

EnvironmentURL
Sandboxhttps://api-sandbox.hesab.com/api/v1/payment/create-session
Productionhttps://api.hesab.com/api/v1/payment/create-session
POST /api/v1/payment/create-session

Creates a payment session from merchant order data. The returned payment URL is used to redirect the customer to hosted checkout.

Body Params

email string

Optional customer email address. Include it when you want the email to appear in payment records or webhook payloads.

user_id string

Optional merchant-defined order or payment identifier, up to 50 characters. Use a unique value from your system; the same value is returned in the successful payment webhook so you can update the exact record on your side.

items array<object> required

Line items included in the payment session. The array cannot be empty. There is no quantity field; calculate any quantity-based line total in your backend and send it as the item price.

id string required

Merchant-side item, order, or SKU identifier. Maximum 50 characters.

name string required

Display name for the item shown in checkout and returned in payment metadata. Maximum 500 characters.

price number required

Item amount with no more than two decimal places. The gateway calculates the payment amount from the submitted item prices.

redirect_success_url string

URL where the customer is sent after a successful payment. Use this for customer-facing confirmation, not final fulfillment.

redirect_failure_url string

URL where the customer is sent after a failed or cancelled payment attempt.

Responses

200 Payment session created

The session was created successfully. Redirect the customer to the URL returned in the url field.

{
  "status_code": 10,
  "success": true,
  "message": "Payment session created successfully",
  "url": "https://checkout.example/checkout/session-id"
}
400 Bad Request

The request body is missing required fields or contains invalid values.

{
  "success": false,
  "message": "Invalid request payload"
}
401 Not authenticated

The API key is missing, malformed, inactive, or invalid.

{
  "detail": "Authentication credentials were not provided."
}