Hi,
I am trying to create a webhook that sends me the data of a paid order. However, besides the "default" fields that come with the webhook, i want to include 2 metafields that i created inside "order".
The namespace of the metafields is "checkoutblocks" and the keys for the metafields are "nif" and "dni".
I am using Javascript with this code to subcribe the webhook:
var query = `
mutation webhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: WebhookSubscriptionInput!) {
webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {
webhookSubscription {
id
createdAt
topic
filter
format
includeFields
metafieldNamespaces
metafields {
key
namespace
}
}
userErrors {
field
message
}
}
}
`;
var input = {
topic: "ORDERS_PAID",
webhookSubscription: {
callbackUrl:"myURL",
format:"JSON"
},
metafieldNamespaces: ["checkoutblocks"],
metafields: [
{
key:"nif",
namespace:"checkoutblocks"
},
{
key:"dni",
namespace:"checkoutblocks"
}
]
}
try {
const client = new shopify.clients.Graphql({ session });
const response = await client.request(query,{variables:input});
console.log(response.data.webhookSubscriptionCreate.webhookSubscription);
console.log(response.data.webhookSubscriptionCreate.userErrors);
} catch (error) {
console.error("Error:", error);
}
However, i am getting this return message:
{
id: 'gid://shopify/WebhookSubscription/123',
format: 'JSON',
apiVersion: { displayName: '2025-01', handle: '2025-01' },
createdAt: '2025-04-10T17:12:06Z',
filter: null,
endpoint: {
callbackUrl: 'myURL'
},
includeFields: [],
metafieldNamespaces: [],
metafields: [],
topic: 'ORDERS_PAID'
}
I am not sure if i am doing this in the right way. I think the response should have included the "metafieldNamespaces" and "metafields" that i have sent.
Can someone help me with this topic? Thanks