Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Associate SubscriptionDraft to SubscriptionContracts

Solved

Associate SubscriptionDraft to SubscriptionContracts

bomanys
Visitor
2 0 0

So I'm currently building an app for managing subscriptions on shopify but I'm not understanding the Subscription Drafts. I've already been able to create them modify and commit them but how do I associate them to a contract? How can I modify an existing contract? (Ex: How to pause/cancel a contract?)

Accepted Solution (1)

ThomazReis
Shopify Staff
25 11 7

This is an accepted solution.

When you commit a subscription draft the changes are applied to the contract itself. If there is no contract, a new one will be created: https://shopify.dev/api/admin/graphql/reference/orders/subscriptiondraftcommit

To get a contract draft from an existing contract you can use the subscriptionContractUpdate mutation: https://shopify.dev/api/admin/graphql/reference/orders/subscriptioncontractupdate#interactive-exampl...

You can get more information on this here: https://shopify.dev/apps/subscriptions/contracts

 

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 3 (3)

ThomazReis
Shopify Staff
25 11 7

This is an accepted solution.

When you commit a subscription draft the changes are applied to the contract itself. If there is no contract, a new one will be created: https://shopify.dev/api/admin/graphql/reference/orders/subscriptiondraftcommit

To get a contract draft from an existing contract you can use the subscriptionContractUpdate mutation: https://shopify.dev/api/admin/graphql/reference/orders/subscriptioncontractupdate#interactive-exampl...

You can get more information on this here: https://shopify.dev/apps/subscriptions/contracts

 

To learn more visit the Shopify Help Center or the Community Blog.

Denn
Shopify Partner
3 0 1

Hi, I am able to create a Subscription contract draft, with subscriptionContractCreate mutation. I get the draft id & I immediately would like to commit it because i am creating a new contract, but I get {"data"=>{"subscriptionDraftCommit"=>{"contract"=>nil}} a nil contract with no errors at all. several attempts still return nil. What am I doing wrong? Please help me out. 

yaman65
Shopify Partner
1 0 0

I am also facing this error? Could anybody help out from these error?

In my case, I am getting errors like these:


[
{ code: 'INVALID', field: null, message: 'is invalid' },
{
code: 'INVALID_LINES',
field: [ 'draftId' ],
message: 'Contract draft must have at least one line.'
}
]

Please help @ThomazReis !!!