Hello, community!
I’m working with the Shopify Admin API (GraphQL, latest version) and I would like to ask:
- Is it possible to fetch an order and access its line items using the order code (ex: t31gcW5nYbnP6aM0Kl) instead of the order ID (
id or gid)?
- Alternatively, can I fetch an order starting from the gid of the paymentSession associated with it?
- If possible, could someone please share an example query for this?
So far, I have only found ways to fetch orders directly by ID, but in my case, I only have the order code or the paymentSession gid.
Thanks in advance!
1 Like
By order code do you mean checkout token or cart token? Or have you got a reference to what you mean?
You can’t query by a payment session but you can use the payment id
@JordanFinners I apologize for the unclear explanation earlier. Let me give you a better context: I integrated Shopify with a payment gateway called Pagar.me, and I receive a webhook from it that returns a payment_id like this:
gid://shopify/PaymentSession/abc123XyZ9LmNoPqRsTuV.
I would like to know if with this payment_id I can access the order’s items, for example, the names of the products included in the order.
Hmmm doesn’t look like it at the moment. The docs indicate it might be possible manually from Shopify but not exposed in GraphQL.
I’d ask the shopify team for it as a feature @KyleG-Shopify
With this ID, I can’t access anything related to the order, right? Or any data that could later allow me to retrieve the order details?
And how can I request this as a feature on Shopify? Who should I contact there?
Also, does Shopify usually fulfill this kind of request? If so, what is the typical turnaround time?
I need this in about a week, do you think it’s possible to have it resolved within that timeframe?
Hey @Andrei_Rodrigues, I believe the code you are referencing is the equivalent to the transaction.payment_id.
A query like this should work to verify. You can then build on this to add in the line items and other fields you need:
query FindOrderByPaymentId {
orders(first: 10, query: "payment_id:abc123XyZ9LmNoPqRsTuV") {
edges {
node {
id
name
displayFinancialStatus
transactions(first: 10) {
id
kind
status
gateway
paymentId
authorizationCode
}
}
}
}
}
1 Like
Solved my problem! Thank you so much! This way I can get exactly what I wanted.