Make sure all steps ( 1 to 4 ) have been done without any issue. Please check the below steps for the mutation by which you can set the payment method and place the order.
Example: Use the setPaymentMethodOnCart mutation to set the payment method for your order. The value checkmo ("Check / Money order" payment method code) was returned in the query.
mutation {
setPaymentMethodOnCart(input: {
cart_id: "{ CART_ID }"
payment_method: {
code: "checkmo"
}
}) {
cart {
selected_payment_method {
code
}
}
}
}
Response:
If the operation is successful, the response contains the code of the selected payment method.
{
"data": {
"setPaymentMethodOnCart": {
"cart": {
"selected_payment_method": {
"code": "checkmo"
}
}
}
}
}
Set payment method and place order
Use the setPaymentMethodAndPlaceOrder mutation to set the payment method and place the order.
Request:
mutation {
setPaymentMethodAndPlaceOrder(input: {
cart_id: "{ CART_ID }"
payment_method: {
code: "checkmo"
}
}) {
order {
order_id
}
}
}
Response:
If the operation is successful, the response contains the order ID.
{
"data": {
"setPaymentMethodAndPlaceOrder": {
"order": {
"order_id": "000000001"
}
}
}
}
Note: Make sure "setPaymentMethodAndPlaceOrder mutation" is not deprecated in the current version of Magento 2.