Get the Order Id that belongs to a PaymentId

Hello there,

I am looking for a method to get the orderId that belongs to a certain paymentId.
I can only find methods to look up the paymentId of the different transactions that belong to an order through the orderId. However I want to be able to find it the other way around.

The reason that I want to do this is because the Payment provider that I am using only stores the paymentId as part of the transaction. We would like to enrich this metadata with the orderId for administration purposes.

The orders GraphQL query accepts payment_id as a query parameter:

{
  orders(first: 1, query:"payment_id:...") {
    edges {
      node {
        id
        transactions {
          paymentId
        }
      }
    }
  }
}

Reference: https://shopify.dev/docs/api/admin-graphql/2023-01/queries/orders

1 Like

Yes, this is what I was looking for. Thank you very much.

You’re welcome. Cheers.

Hello i am interested if its possible to get the checkout id before the order is created in admin panel i want to have on a checkout page checkout id instead of a payment id is it possible to get this data of checkout id from the payment request ?

Hey @Temur1 , if you’re wanting some of these details before an order is created, you can use the storefront API. This guide here on how to Create and update a cart with the Storefront API is a great starting point!

Hope that helps.

  • Kyle G.