0

I am following this tutorial to process cart / checkout for placing orders using graphql. Magento GraphQl Tutorial. And we have installed stripe on magento(backend).

So we are facing issue while placing order.

  • Customer logs in get a authentication token
  • Create empty cart
  • Add product to cart
  • Set billing and shipping address for cart
  • Set payment method to stripe_payments (without card details)
  • Placing order receiving error here

How can I set payment method and debit card details to cart using graphql and place successful test order?

6
1

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.

1
  • This doesn't answer the question. – Gambo Jun 5 '20 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.