Subscription Proration with Discount Cancellation on Update

I have one app which includes Silver/Gold subscription with monthly and annually,

if user is in annual plan, then the discount will applied to customer,

for example:

Plan monthly annually(with discount)
Silver 17$/month 12$/monthly(144$/annually)
Gold 49$/month 39$/monthly(468$/annually)

there is one scenario:

If the user is in **Silver-**annually, and after 6 months using the Silver-annually, he wants to go to **Gold-**monthly, so the discount which was given to customer must be cancelled, and based on some unused months which he has, he can buy Gold monthly: so based on the following:

he paid 144$ for one year,

his discount must be cancelled( so the price will be 17$/monthly) because of new subscription (Gold-monthly):

for all first 6 months: 17 * 6 = 102, so now user will be credited 144-102 = 42$ based on our custom proration,

now based on 42$, he can register (42/49) * 30 = 25 days for Gold-monthly,

I wan to know, how I can handle it in my code?

because in the https://shopify.dev/api/admin-graphql/2022-04/mutations/appSubscriptionCreate I checked that we dont have update on subscription, so I need to cancel, and then I create the new subscription?

or instead of cancelling the subscription, I need to use the shopify contract create/update (https://shopify.dev/api/admin-graphql/2022-07/mutations/subscriptionContractCreate )?

if there is one example in code, I will be thankful,

thanks,

Hi @miladghale

Are you referring to an AppSubscription or a SubscriptionContract? The provided links were for 2 different APIs.