Skip to main content

orderCreate

Overview

Finalize a checkout by calling createOrder with a CreateOrderInput. This typically happens after the customer submits their shipping/payment details and a cart is ready to be converted into an order.

Mutation

mutation CreateOrder($input: CreateOrderInput!) {
createOrder(input: $input) {
data {
_id
status { _id code title }
type
salesLead {
_id
firstName
lastName
country
city
district
street
phone1
phone2
}
currency { _id title currencyCode currencySymbol }
freeze
taxAmount
totalPriceWithTax
totalPrice
totalCompareAtPrice
priceWithShipping
shippingPrice
handel
paymentMethod {
_id
key
descreption
installed
deleted
schema
createdAt
updatedAt
icon
iconUrl
needConfig
methods
name
instructions
id
}
shippingAddress {
_id
country {
_id
name
image { image imageUrl }
code
continent
capital
active
deleted
phonekey
}
city {
_id
name
description
active
deleted
country {
_id
name
image { image imageUrl }
code
continent
capital
active
deleted
phonekey
}
createdAt
}
neighborhood
zipCode
description
account
device
deleted
createdAt
updatedAt
}
customerName
isPaid
isFastOrder
createdAt
account {
_id
fullname
phone
type
verified
blocked
status
avatar
avatarUrl
deleted
devices
createdAt
updatedAt
}
items {
_id
orderId
productId
variantId
productData { title slug app images price }
variantData {
price
compareAtPrice
options {
_id
option { _id name type product }
label
sortOrder
}
}
quantity
price
compareAtPrice
totalPrice
totalCompareAtPrice
totalSavings
}
}
message
success
redirectUrl
}
}

Variables

Adapt the payload to your flow. Example using fields similar to your snippet:

{
"input": {
"cartId": "<CART_ID>",
"code": "<COUPON_CODE>",
"encryptionKey": "<ENCRYPTION_KEY>",
"paymentMethod": "<PAYMENT_METHOD_KEY>",
"shippingAddressId": "<ADDRESS_ID>",
"token": "<CHECKOUT_TOKEN>",
"COD": false,
"leadData": {
"firstName": "John",
"lastName": "Doe",
"country": "SA",
"city": "Riyadh",
"district": "Olaya",
"street": "King Fahd Rd",
"phone1": "+966500000000",
"phone2": null
}
}
}

Examples

curl -X POST \
https://subdomain.com\
-H "Content-Type": "application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{
"query": "mutation CreateOrder($input: CreateOrderInput!) { createOrder(input: $input) { success message redirectUrl data { _id handel totalPrice } } }",
"variables": {
"input": {
"cartId": "<CART_ID>",
"paymentMethodId": "<PAYMENT_METHOD_ID>",
"shippingAddress": {
"countryId": "<COUNTRY_ID>",
"cityId": "<CITY_ID>",
"street": "Main St"
}
}
}
}
EOF

Notes

  • The mutation returns redirectUrl for hosted payment flows—redirect the shopper there when provided.
  • Ensure the cart or session referenced in CreateOrderInput is valid and not already converted.
  • Use success/message to surface validation errors (missing address, payment failures, etc.).