Solved

Get all transactions of a given order in graphQL

Kiruthiga
Shopify Partner
1 0 0

Hi Team,

I am looking for the graphql equivalent of the following REST endpoint (retrieve all transactions of a given order)

GET  /admin/api/2023-07/orders/450789469/transactions.json

https://shopify.dev/docs/api/admin-rest/2023-07/resources/transaction#get-orders-order-id-transactio...

please suggest what should be used here?

Accepted Solution (1)

Liam
Shopify Staff
2731 302 783

This is an accepted solution.

Hi Kiruthiga,

 

To retrieve all transactions of a given order using GraphQL, you can follow the pattern below:

{
  order(id: "gid://shopify/Order/450789469") {
    transactions(first: 100) {
      edges {
        node {
          id
          kind
          status
          amountSet {
            shopMoney {
              amount
              currencyCode
            }
            presentmentMoney {
              amount
              currencyCode
            }
          }
        }
      }
    }
  }
}

You'll need to replace the 450789469 in gid://shopify/Order/450789469 with your actual order ID. This query will return the first 100 transactions of the specified order, including the transaction id, kind, status, and amount.

 

Also, note that the order ID is a global ID in the format of gid://shopify/Order/450789469, not just a number. You can get the global ID from the response of a previous API request, or convert an order's regular ID to a global ID by prepending it with gid://shopify/Order/.

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 2 (2)

gsmaverick
Shopify Partner
21 3 4

I believe the equivalent on GraphQL is to request the Order.transactions object from an order query.

Liam
Shopify Staff
2731 302 783

This is an accepted solution.

Hi Kiruthiga,

 

To retrieve all transactions of a given order using GraphQL, you can follow the pattern below:

{
  order(id: "gid://shopify/Order/450789469") {
    transactions(first: 100) {
      edges {
        node {
          id
          kind
          status
          amountSet {
            shopMoney {
              amount
              currencyCode
            }
            presentmentMoney {
              amount
              currencyCode
            }
          }
        }
      }
    }
  }
}

You'll need to replace the 450789469 in gid://shopify/Order/450789469 with your actual order ID. This query will return the first 100 transactions of the specified order, including the transaction id, kind, status, and amount.

 

Also, note that the order ID is a global ID in the format of gid://shopify/Order/450789469, not just a number. You can get the global ID from the response of a previous API request, or convert an order's regular ID to a global ID by prepending it with gid://shopify/Order/.

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog