Applying usage charge to recurring subscription

smartraysamtob
Shopify Partner
2 0 1

I want to charge for usage charge after a recurring charge has been applied.
when i make call to usage charge query. am getting 

error : Subscription does not accept usage charges.
this is my script

const usageCharge = async (admin: any, billing: any) => {
const { appSubscriptions } = await billing.check({
plans: [MONTHLY_PLAN],
isTest: true,
});
const subscriptionLineItemId =appSubscriptions[0].lineItems[0].id;

const response = await admin.graphql(
`#graphql
mutation appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) {
appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) {
userErrors {
field
message
}
appUsageRecord {
id
}
}
}`,
{
variables: {
subscriptionLineItemId: subscriptionLineItemId,
price: {
amount: 0.10,
currencyCode: "USD",
},
description: "Per search fee",
},
}
);

const data = await response.json();
console.log("data", data.data.appUsageRecordCreate.userErrors);
return data;
};

export default usageCharge;




please help, i don't get what am doing wrong.

Replies 0 (0)