Z. Reticulan
Z. Reticulan

Reputation: 155

How to create a checkout with Shopify API

Through Postman, I am sending GraphQL to the appropriate endpoint in line with this page of the Shopify docs: Create a checkout with the Storefront API. I am getting the following response:

{
    "errors": "[API] This action requires merchant approval for write_checkouts scope."
}

This doesn't make sense to me because I have enabled the checkouts permission as seen here: enter image description here

If the app needs to be converted to a sales channel or public app, please let me know how that can be done. Thanks for any help!

Upvotes: 2

Views: 4991

Answers (1)

j_r
j_r

Reputation: 83

I don't believe this is possible with Private or Custom Apps. Your app must be Public. Some additional information here: https://community.shopify.com/c/shopify-apis-and-sdks/how-to-grant-write-checkouts-permission/td-p/448587

Requirements section of the following link mentions your app must be public: https://shopify.dev/apps/channels/getting-started

On second thought, there is createCart for StoreFront API: https://shopify.dev/custom-storefronts/cart#create-a-cart-and-add-a-line-item

I created a private app and used the following:

Post: https://[storename].myshopify.com/api/2021-10/graphql.json

Add Header: X-Shopify-Storefront-Access-Token:somevalue

Set body:

mutation MyMutation1 {
   
  cartCreate(input: {lines: {merchandiseId: "someproducytid==",quantity:1}, buyerIdentity: {email: "[email protected]"}}) {
    cart {
      id
      checkoutUrl
      buyerIdentity {
        customer {
          email
        }
      }
    }
  }

}

Upvotes: 1

Related Questions