data-src=../../../../includes/paas-only.md
setPaymentMethodAndPlaceOrder mutation
data-variant=warning
data-slots=text
The
setPaymentMethodAndPlaceOrder mutation has been deprecated. Use the setPaymentMethodOnCart and placeOrder mutations instead. You can run the two methods in the same call if your use case allows it.The setPaymentMethodAndPlaceOrder mutation sets the cart payment method and converts the cart into an order. The mutation returns the resulting order ID. You cannot manage orders with GraphQL, because orders are part of the backend. You can use REST or SOAP calls to manage orders to their completion.
Perform the following actions before using the setPaymentMethodAndPlaceOrder mutation:
- Create an empty cart
- Add one or more products to the cart
- Set the billing address
- Set the shipping address (non-virtual carts only)
- Set the shipping method (non-virtual carts only)
- For guest customers, assign an email to the cart
data-variant=info
data-slots=text
The
setPaymentMethodAndPlaceOrder mutation runs asynchronously if the AsyncOrder module has been enabled. By default, the mutation runs synchronously. Asynchronous order placement describes the benefits of enabling the module.Syntax
mutation {
setPaymentMethodAndPlaceOrder(
input: SetPaymentMethodAndPlaceOrderInput
) {
PlaceOrderOutput
}
}
Reference
The setPaymentMethodAndPlaceOrder reference provides detailed information about the types and fields defined in this mutation.
Example usage
Request:
mutation {
setPaymentMethodAndPlaceOrder(
input: {
cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG"
payment_method: {
code: "checkmo"
}
}
) {
order {
order_id
}
}
}
Response:
{
"data": {
"setPaymentMethodAndPlaceOrder": {
"order": {
"order_id": "000000006"
}
}
}
}
Errors
Error
Description
Could not find a cart with ID "XXX"The specified
cart_id value does not exist in the quote_id_mask table.Guest email for cart is missing.The guest attempted to place an order but did not provide an email address. See the setGuestEmailOnCart mutation.
Required parameter "cart_id" is missingThe required
cart_id argument contains an empty value.Required parameter "code" for "payment_method" is missing.The value specified in the
code argument is empty.The current user cannot perform operations on cart "XXX"An unauthorized user (guest) tried to set a payment method and place an order with a customer's cart, or an authorized user (customer) tried to set a payment method and place an order with a cart of another customer.
The shipping address is missing. Set the address and try again.You ran
setPaymentMethodAndPlaceOrder mutation before setShippingAddressesOnCart. Set a shipping address first. GraphQL checkout tutorial shows the order placement sequence.The requested Payment Method is not available.The payment method specified in the
payment_method argument is disabled or does not exist.Unable to place order: Some of the products are out of stock.Some of the products in a cart are out of stock.
data-slots=text
data-backgroundcolor=blue