Re: How to update billing plan with new plan?

How to update billing plan with new plan?

Shopify Partner
8 0 0

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. 

Reply 1 (1)

Shopify Partner
6 0 0

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 = ''

def shopify_client():
    api_session = shopify.Session(merchant,'2024-01',token)
    client = shopify.GraphQL()
    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 {
    appSubscription {

# 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