How to Get Shopify Order Payment Methods [Shopify GraphQL API Edition]

Tadashi Shigeoka ·  Thu, June 24, 2021

I’ll introduce how to get Shopify Order payment methods using the Shopify GraphQL API.

shopify

Background: Want to Know Payment Methods Used in Shopify

The theme of this article is to retrieve payment methods used in Shopify via the Shopify API.

Examples of payment methods)

  • Credit card brands (Visa, Mastercard, American Express, JCB)
  • Apple Pay, Google Pay
  • Amazon Pay
  • PayPal

GraphQL Query and Execution Results to Get Shopify Order Payment Methods

When I asked a question in the Shopify Community, I received an answer immediately. Thank you.

Solved: How to get the detailed payment method when using Shopify Payments via Shopify GraphQL API - Shopify Community

GraphQL Query

{
  order(id: "gid://shopify/Order/3928604967067") {
    paymentGatewayNames
    transactions(first:10) {
      id
      accountNumber
      formattedGateway
      paymentMethod
      paymentIcon {
        altText
      }
    }
  }
}

Execution Results

{
  "data": {
    "order": {
      "paymentGatewayNames": [
        "shopify_payments"
      ],
      "transactions": [
        {
          "id": "gid://shopify/OrderTransaction/4886496805019",
          "accountNumber": "•••• •••• •••• 1111",
          "formattedGateway": "Shopify Payments",
          "paymentMethod": "VISA",
          "paymentIcon": {
            "altText": "Visa"
          }
        }
      ]
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 3,
      "actualQueryCost": 3,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1997,
        "restoreRate": 100
      }
    }
  }
}

That’s all from the Gemba.