checkoutGiftCardRemoveV2 - invalid ID

Hi i try to use the checkoutGiftCardRemoveV2 mutation
the idea is to remove gift card with balance from the cart/checkout.

Problems

  1. documentation don’t provide examples of the right variables to use (both values are general copy paste )

  2. when trying to discover the value for the checkoutID is the most likely place where is have the issue

debugging

trying to call checkoutGiftCardRemoveV2 payload is

            query: `
                mutation checkoutGiftCardRemoveV2($appliedGiftCardId: ID!, $checkoutId: ID!) {
                    checkoutGiftCardRemoveV2(appliedGiftCardId: $appliedGiftCardId, checkoutId: $checkoutId) { 
                          userErrors 
                            {
                              message
                              field
                            }
                              checkout {
      id
    }
    checkoutUserErrors {
                              message
                              field
    }
                    
                    }
                }
            `,
            variables: {
                checkoutId: "gid://shopify/Checkout/Z2NwLXYYYYYYYYYYYYYYS0hR",
                appliedGiftCardId: "gid://shopify/GiftCard/542910644449"
            },

this call was send to the

/api/2024-04/graphql.json

where the gift card Id was checked by the call

            query: `
                query {
                  giftCard(id: "gid://shopify/GiftCard/542910644449") {
                    balance {
                      amount
                      currencyCode
                    }
                  }
                }            
            `,

send to endpoint of

/admin/api/2024-04/graphql.json

and this give us response of

{ giftCard: { balance: { amount: '2.0', currencyCode: 'GBP' } } }

so now the issue is most likely in the value of

checkoutId

I have webhooks for the cart create/modify and the webhooks for the checkout create/modify the value down there was taken form the “cart_token” property from the JSON output.

So can I know what should be the right value / format of the checkoutId value

Thank you paddy

Hi , there

  1. Are you sure you use checkoutGiftCardRemoveV2 for admin GraphQL URL, since it should be used as storefront api.

  2. Can i ask how you create your checkout , if you created the checkout through api , it should return an checkout object with that id.

Hi

  1. i mentioned i call checkoutGiftCardRemoveV2 i use this endpoint /api/2024-04/graphql.json

  2. checkout is created automatically by liquid standard functionality. That’s why I have a webhook that will call my server once the card/checkout is created. I use the ID in the field for the checkoutId , but it’s complaining that the supplied ID is the wrong one. BTW, the documentation doesn’t show proper format examples of the data that should be used. https://shopify.dev/docs/api/storefront/2024-04/mutations/checkoutGiftCardRemoveV2

So my issue still stands what should be the proper format of the GID path for the checkoutId in the checkoutGiftCardRemoveV2 GraphQL call

Hi, there

  1. The checkoutGiftCardRemoveV2 mutation is part of the Storefront API, not the Admin API. so your endpoint is not correct . change it to /2024-04/graphql.json no ‘api’ in that url

  2. Maybe I didn’t express myself clearly. What I mean is how do you obtain that checkoutUrl? When you get your checkoutUrl, you also get an ID. Also, can I know if your storefront is using a headless approach or a theme?

Hi

  1. Taken from the documentation https://shopify.dev/docs/api/storefront#endpoints
The Storefront API is available only in GraphQL. There's no REST API for storefronts.

All Storefront API queries are made on a single GraphQL endpoint, which only accepts POST requests:

post
https://{store_name}.myshopify.com/api/2024-07/graphql.json
  1. I don’t need any URL as Shopify webhook calls my endpoint. With the cart or checkout details.

Sorry you are right .please ignore the first one.