appSubscriptionCreate return undefined

Highlighted
Shopify Partner
7 0 1

Hi,

I'm using appSubscriptionCreate on my index page to get the confirmation_url. But the data return is undefined.

Query:

mutation appSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {
  appSubscriptionCreate(name: $name, lineItems: $lineItems, returnUrl: $returnUrl) {
    appSubscription {
      id
    }
    confirmationUrl
    userErrors {
      field
      message
    }
  }
}

Index:

  const {error:ee, data:dd} = useMutation(CREATE_RECURRING, {
    variables:{
      name: "Recurring",
      lineItems: [{
        plan: {
          appRecurringPricingDetails: {
              price: { amount: 9.95, currencyCode: 'USD' }
          }
        }
      }],
      returnUrl: "https://app.magicupsell.com",
      trialDays: 14,
      test: true,
}
  });

console.log(dd) always get "undefined". Anyone have clue?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1041 140 170

Hey @Amar_Gandhi,

 

Can you please provide a request ID? Are you able to send the request outside of the library?

Notice; Out of office, replies will be delayed until my return. Thanks!
0 Likes
Highlighted
Tourist
7 0 1

Having the same issue, I have been running the app with no problem for the last month. Then yesterday I experienced this appSubscriptionCreate of undefined. I seems that the appSubscriptionCreate mutation request is coming back undefined. 

 

Here is the code snippet:

const getSubscriptionUrl = async (ctx, accessToken, shop) => {
  const ENDPOINT = `https://${shop}/admin/api/2020-04/graphql.json`;
  const query = JSON.stringify({
    query: `mutation {
        appSubscriptionCreate(
            name: "xxx"
            returnUrl: "${process.env.HOST}"
            test: true
            lineItems: [
            {
              plan: {
                appUsagePricingDetails: {
                    cappedAmount: { amount: 10000, currencyCode: USD }
                    terms: "$0.65 for every order shipped"
                }
              }
            }
            {
              plan: {
                appRecurringPricingDetails: {
                    price: { amount: 0, currencyCode: USD }
                }
              }
            }
            ]
          ) {
              userErrors {
                field
                message
              }
              confirmationUrl
              appSubscription {
                id
              }
          }
      }`
  });

  const response = await fetch(ENDPOINT, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "X-Shopify-Access-Token": accessToken
    },
    body: query
  });

  const responseJson = await response.json();

  const confirmationUrl =
    responseJson.data.appSubscriptionCreate.confirmationUrl;

Please help

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1041 140 170

@Markus95  can you please provide a request ID from the response headers? Are you able to send the request outside of the library?

Notice; Out of office, replies will be delayed until my return. Thanks!
0 Likes
Highlighted
Tourist
7 0 1

@SBD_  Here are 2 request IDs: 

 

90e1d9a1-f067-4486-82b3-d77079a2909d
1130dc00-3715-4d13-bcbb-b298923516a9

 

0 Likes
Highlighted
Tourist
7 0 1

Here is the error I am getting with the requestId: 

{ errors:
[ { message:
'Internal error. Looks like something went wrong on our end.\nRequest ID: b4f1e186-0c87-4e4c-bfd3-296db73be25d (include this in support requests).',
extensions:
{ code: 'INTERNAL_SERVER_ERROR',
requestId: 'b4f1e186-0c87-4e4c-bfd3-296db73be25d' } } ] }
{ e:
TypeError: Cannot read property 'appSubscriptionCreate' of undefined 

@SBD_  

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1041 140 170

@Markus95 it appears this is caused by the app using online access tokens to create billing requests. Apps will need to use offline access tokens to do this. Let me know if this resolves the issue.

Notice; Out of office, replies will be delayed until my return. Thanks!
0 Likes
Highlighted
New Member
2 0 0

SBD_ 

I'm having the same issue and getting the following error:

 

 

{
    "errors": [
        {
            "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: 2718c84c-96f7-448f-8fb5-b7787977c731 (include this in support requests).",
            "extensions": {
                "code": "INTERNAL_SERVER_ERROR",
                "requestId": "2718c84c-96f7-448f-8fb5-b7787977c731"
            }
        }
    ]
}

 

 

I get the same error even when sending the request through postman.

0 Likes
Highlighted
New Member
2 0 0

removing the below code solved the problem for me:

  appSubscription {
      id
 }

 

0 Likes