Skip to main content

cartBuyNow

Overview

buyNow is a convenience mutation to add a single product/variant to a temporary cart and immediately get checkout URL/encryption info for fast checkout flows.

Mutation

mutation BuyNow($data: AddToCartInput!) {
buyNow(data: $data) {
data {
_id
app
coupon
kind
couponApplied
couponDiscount
account {
_id
app
verified
blocked
orderCount
lastSeen
createdAt
updatedAt
}
items {
productId
_id
variantId
productData { title slug image { _id fileUrl } price }
variantData {
price
compareAtPrice
options {
_id
option { _id name type product }
label
sortOrder
}
}
quantity
price
compareAtPrice
totalPrice
totalCompareAtPrice
totalSavings
}
deviceId
sessionId
status
totalQuantity
totalPrice
totalCompareAtPrice
totalSavings
isFastOrder
createdAt
updatedAt
url
encryptionKey
}
success
message
url
encryptionKey
}
}

Variables

Supply any required fields from your AddToCartInput schema (product/variant, quantity, options, session info):

{
"data": {
"productId": "<PRODUCT_ID>",
"variantId": "<VARIANT_ID>",
"quantity": 1,
"sessionId": "<SESSION_ID>",
"options": [
OPTIONS_IDS
]
}
}

Examples

curl -X POST \
https://appssubdomain.com\
-H "Content-Type": "application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{
"query": "mutation BuyNow($data: AddToCartInput!) { buyNow(data: $data) { success message url encryptionKey data { _id totalPrice } } }",
"variables": {
"data": {
"productId": "<PRODUCT_ID>",
"variantId": "<VARIANT_ID>",
"quantity": 1,
"sessionId": "<SESSION_ID>"
}
}
}
EOF

Notes

  • Ensure the shopper has required context (session/currency) before calling buyNow.
  • Use the returned url/encryptionKey to redirect straight to payment or confirm page.
  • Payload shape depends on your AddToCartInput; include device info or custom options as needed.