We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

How can I receive payment status on Shopify apps?

How can I receive payment status on Shopify apps?

anurag-m
Shopify Partner
5 0 1

Hi I am new to shopify .

Please help me on this how I can receive  the payment status.

I am calling below graphql for payment page

const getSubscriptionUrl = async (ctx, accessToken, shop) => {
console.log(accessToken);
const query = JSON.stringify({
query: `mutation {
appSubscriptionCreate(
name: "Super Duper Plan"
returnUrl: "${process.env.HOST}"
test: true
lineItems: [
{
plan: {
appUsagePricingDetails: {
cappedAmount: { amount: 5, currencyCode: USD }
terms: "$1 for 1000 emails"
}
}
}
{
plan: {
appRecurringPricingDetails: {
price: { amount: 5, currencyCode: USD }
}
}
}
]
) {
userErrors {
field
message
}
confirmationUrl
appSubscription {
id
}
}
}`
});

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();
console.log('responseJson',responseJson);
const confirmationUrl = responseJson.data.appSubscriptionCreate.confirmationUrl
return ctx.redirect(confirmationUrl)
};

module.exports = getSubscriptionUrl;
Reply 1 (1)

appaza
Shopify Partner
38 2 3
  const response = await admin.graphql(
      `#graphql
      query {
    currentAppInstallation {
      id
      activeSubscriptions {
        id
        trialDays
        currentPeriodEnd
        createdAt
      }
    }
  }`,
    );
Collaboration creates new things