How to get the subscription contract from a refund notification

I have a subscription app, and I am subscribed to refunds on the orders. I was wondering how do you get the subscription contract id from the refund webhook call.

There doesn’t seem to be any listed way to get it, and we need to know which subscription contract it comes from to handle stuff on our server.

The only way I can see to connect a contract to an order is to look through all the orders that are associated with a contract, but we need to go the other way and find the contracts connected to the order.

Hey ToyboxZach1,

I want to apologize for not getting back to you about this in a timely manner.

If this problem is still relevant to you, can I ask that you submit this question again? (with information about your current situation)

Sincerely,
J-ROM

Why would we need to submit again? The question is still valid and still the same question

Hey ToyboxZach1,

Thanks for confirming your question still applies, I’ll do my best to answer it now.

The way to go from the order specified in the refund webhook to its associated subscription contract is through the order’s line items.

query {
  order(id: "gid://shopify/Order/<ORDER_ID_FROM_REFUND_WEBHOOK>") {
    lineItems(first: 10) {
      nodes {
        contract {
          id
        }
      }
    }
  }
}

Hope this helps!

Cheers,
J-ROM