Cannot create checkout from external app

We´ve been developing an app in Unity (but I think this issue would be about the same if we were developing with anything else) that needs to integrate our Shopify store using the Storefront API. Everything has been working fine for creating a shopping cart, checking prices and details of our products and adding them to the cart, but at the moment that we try to create a checkout where we are supposed to receive an ID and a URL, we get this error:

{“errors”:[{“message”:“Field ‘checkoutCreate’ doesn’t exist on type ‘Mutation’”,“locations”:[{“line”:1,“column”:12}],“path”:[“mutation”,“checkoutCreate”],“extensions”:{“code”:“undefinedField”,“typeName”:“Mutation”,“fieldName”:“checkoutCreate”}}]}

Does anyone have any idea of what this could be about? Looks as if we were missing something in the “Storefront API scopes” but we cannot find what!

Any help would be really appreciated.

checkoutCreate is not supported in recent api versions: checkoutCreate - Storefront API

Shopify is moving all checkout functionality to the Cart object in the Storefront API.

So instead of calling checkoutCreate, you now:

  1. Use cartCreate to initialize a cart.

  2. Add line items with cartLinesAdd.

  3. Then redirect the customer to the checkout URL from cart.checkoutUrl.

example:

mutation {
  cartCreate(
    input: {
      lines: [
        {
          quantity: 1
          merchandiseId: "gid://shopify/ProductVariant/123456789"
        }
      ]
    }
  ) {
    cart {
      id
      checkoutUrl
    }
  }
}

Then you take checkoutUrl and open it in the browser or in your app.

Yes, you can not create a custom checkout page, just navigate to the checkoutUrl field from the cart object.

1 Like