For discussing the development and integration of subscription-enabled shops using Shopify's Subscription APIs.
Hi all,
What I need to accomplish is to create a subscription without payment information associated to it. I tried to do it with the API, creating a subscription draft, adding lines to it and the committing it. But I got the error that payment information was missing.
The scenario is as follows: I'm using subscriptions to create memberships, and sometimes we need to grant free membership to some users. Is this the way to go? Maybe there is some other thing to do that I'm not seeing.
Thanks in advance!!
Hey @fabcam
Would you mind sharing the API call you made? I can take a look into it. Considering your use case, the subscriptionDraftDiscountAdd mutation could help you out.
Hi @Luke_K, I'm going to try adding a discount as you said and let you know, however the variant I'm using while adding a line to the subscription draft has a $0 cost.
Thanks!
Hi again @Luke_K , sorry for the late reply. You know I tried adding a discount but it wasn't enough for stopping the error message asking me for payment information.
I'm going to paste here the mutations that I'm running in case you want to have a look.
Create Subscription Contract Draft:
mutation {
subscriptionContractCreate(
input: {
customerId: "<customer gid>"
nextBillingDate: "2021-08-01"
currencyCode: USD
contract: {
status: ACTIVE
billingPolicy: { interval: MONTH, intervalCount: 1 }
deliveryPolicy: { interval: MONTH, intervalCount: 1 }
deliveryPrice: 0.0
}
}
) {
draft {
id
}
userErrors {
field
message
}
}
}
Add Product Line to Subscription Draft:
mutation {
subscriptionDraftLineAdd(
draftId: "<subscription draft gid>"
input: {
productVariantId: "<product variant gid>"
quantity:1
currentPrice:0.0
}
) {
lineAdded {
id
quantity
productId
variantId
}
draft {
id
}
userErrors {
...
}
}
}
Add discount to Subscription Draft:
mutation {
subscriptionDraftDiscountAdd(
draftId: "<subscription draft gid>"
input: {
title: "Freee Subscription"
value: {
percentage: 100
}
entitledLines: {
all: true
}
})
{
discountAdded {
id
rejectionReason
}
draft {
id
}
userErrors {
...
}
}
}
And at the end the commit subscription draft:
mutation {
subscriptionDraftCommit(draftId: "<subscription draft gid>") {
contract {
id
}
userErrors {
field
message
}
}
}
Thanks!!
Hey @fabcam
Diffing your SubscriptionContractCreate mutation against the one prescribed in our documentation here, it appears you are omitting a paymentMethodId from the call.
I think additionally this will be a point where you get stuck when it comes to the final subscriptionDraftCommit unfortunately as the API is expecting a CustomerPaymentMethod Id and validates the commit against it. Considering this, perhaps setting the Customer Payment Id earlier on could be a step in the right direction.