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)
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024