Fetch Payment method in Shopify using GraphQL

While fetching orders through Shopify using graphql query, we can fetch the transaction payment information.

The gateway field of transactions info provides the payment method.

transactions {
          receiptJson
          id
          amount
          gateway
        }

The following query is used for fetching sales orders from Shopify:

query getOrders($afterCursor: String) {
  orders(
    query: "updated_at:>${time} financial_status:${financialStatus}"
    first: 200
    after: $afterCursor
  ) {
    edges {
      node {
        id
        createdAt
        name
        note
        customer {
          id
          firstName
          lastName
          email
          phone
        }
        billingAddress {
          name
          phone
          address1
          address2
          city
          province
          country
          zip
        }
        shippingAddress {
          name
          phone
          address1
          address2
          city
          province
          country
          zip
        }
        transactions {
          receiptJson
          id
          amount
          gateway
        }
        totalPrice
        totalTax
        totalShippingPrice
        totalDiscounts
        discountCode
        lineItems(first: 250) {
          edges {
            node {
              id
              title
              quantity
              isGiftCard
              originalUnitPrice
              variant {
                inventoryItem {
                  id
                  sku
                  tracked
                }
                price
              }
              originalTotal
            }
          }
        }
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}

Leave a comment

Your email address will not be published. Required fields are marked *