Subscription declined is not working

Highlighted
Shopify Partner
7 0 1

Im using GraphQL and get confirmationUrl in this page

Capture.PNG

If i click 'start free trial', it will redirect to my app's index page with a 'charge_id'

But if i click 'Cancle' and click my app again, it will redirect me to my app's index as well. It should be redirect me to

Capture.PNGagain but no.

 

Even if i console.log(confirmationUrl ) and copy paste, it still redirect me to the index page.

Following is the GraphQL im using.

const getSubscriptionUrl = async (ctx, accessToken, shop) => {
  const query = JSON.stringify({
    query: `mutation {
      appSubscriptionCreate(
          name: "Unlimited"
          returnUrl: "${process.env.HOST}"
          trialDays: 14
          test: true
          lineItems: [
          {
            plan: {
              appRecurringPricingDetails: {
                  price: { amount: 9.95, currencyCode: USD }
              }
            }
          }
          ]
        ) {
            userErrors {
              field
              message
            }
            confirmationUrl
            appSubscription {
              id
              status
            }
        }
    }`
  });


  const response = await fetch(`https://${shop}/admin/api/2019-07/graphql.json`, {
    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;
  const responseId = await responseid.json();

module.exports = getSubscriptionUrl;

Anyone have any suggest??

0 Likes
Highlighted
Shopify Partner
7 0 1

anyone know the reason?

0 Likes