App reviews, troubleshooting, and recommendations
I have added one billing plan but I have two more. How can I give to my client to choose to update or downgrade the plans and update the plan based on the selection?
Which API should I call to create a plan?
Which API should I call to get plans?
Which API should I call to update the plan?
It is nodejs app.
Hey Mrkarim,
This is the code I wrote in python to update an existing subscription with a discount, maybe it is helpful to you
!pip install ShopifyAPI pandas
import shopify
import urllib.request
import json
import pandas as pd
merchant_token = 'xxxxxxxxxxxxxxxxxxxxxxxx'
merchant = 'xxxx.myshopify.com'
def shopify_client():
api_session = shopify.Session(merchant,'2024-01',token)
shopify.ShopifyResource.activate_session(api_session)
client = shopify.GraphQL()
print(client)
return client
client = shopify_client()
# Define the mutation query
mutation = """
mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {
appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {
userErrors {
field
message
}
confirmationUrl
appSubscription {
id
}
}
}
"""
# Define the mutation variables
variables = {
"name": "Discount plan name ",
"returnUrl": "your app auth url",
"lineItems": [
{
"plan": {
"appRecurringPricingDetails": {
"price": {
"amount": xx,
"currencyCode": "USD"
},
"discount": {
"value": {
"amount": xx
}
},
"interval": "EVERY_30_DAYS"
}
}
}
],
"replacementBehavior": "APPLY_IMMEDIATELY"
}
# Execute the mutation
response = client.execute(mutation, variables)
data = json.loads(response)
# Process the response data
print(data)
Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025