How to get the detailed payment method when using Shopify Payments via Shopify GraphQL API

Solved
shige-route06
Tourist
8 0 5

Hi, Shopify Developers

 

I'd like to know the detailed payment method when using Shopify Payments via Shopify GraphQL API.

For example, I'd like to know about Credit Card brands VISA, Mastercard, American Express, Apple Pay, etc.

I tried the following query, but I cannot get the Credit Card brand name "VISA".

# Get the first 10 order transactions
{
  order(id: "gid://shopify/Order/3928604967067") {
    paymentGatewayNames
    transactions(first:10) {
      id
      accountNumber
      formattedGateway
      gateway
    }
  }
}

 

Response

{
  "data": {
    "order": {
      "paymentGatewayNames": [
        "shopify_payments"
      ],
      "transactions": [
        {
          "id": "gid://shopify/OrderTransaction/4886496805019",
          "accountNumber": "•••• •••• •••• 1111",
          "formattedGateway": "Shopify Payments",
          "gateway": "shopify_payments"
        }
      ]
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 2,
      "actualQueryCost": 2,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1998,
        "restoreRate": 100
      }
    }
  }
}

 

Thanks,

Shige

0 Likes
Michal_Morek
Shopify Partner
821 73 139

This is an accepted solution.

Hi @shige-route06 

Hope you're having a great day!

You can view the altText field from paymentIcon which returns only the name of the credit card company in plain text (VISA, MASTERCARD, etc.)  or you could use paymentMethod fields:

 

{
  order(id: "gid://shopify/Order/3907222241325") {
    paymentGatewayNames
    transactions(first: 10) {
      id
      accountNumber
      formattedGateway
      gateway
      createdAt
      kind
      paymentMethod
      processedAt
      status
      totalUnsettled
      amount
      paymentIcon {
        altText
      }
    }
  }
}

 

 

Response:

 

{
  "data": {
    "order": {
      "paymentGatewayNames": [
        "shopify_payments"
      ],
      "transactions": [
        {
          "id": "gid://shopify/OrderTransaction/4836390174765",
          "accountNumber": "•••• •••• •••• 1111",
          "formattedGateway": "Shopify Payments",
          "gateway": "shopify_payments",
          "createdAt": "2021-06-25T12:16:08Z",
          "kind": "AUTHORIZATION",
          "paymentMethod": "VISA",
          "processedAt": "2021-06-25T12:16:08Z",
          "status": "SUCCESS",
          "totalUnsettled": "18.95",
          "amount": "18.95",
          "paymentIcon": {
            "altText": "Visa"
          }
        }
      ]
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 3,
      "actualQueryCost": 3,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 997,
        "restoreRate": 50
      }
    }
  }
}

 

 

Screenshot:

10eec554-6c3a-47f1-8bf9-5f24e5015c71.png

 

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
shige-route06
Tourist
8 0 5

Thanks a lots!

I made it.

0 Likes
Michal_Morek
Shopify Partner
821 73 139

Hi @shige-route06 

Hope you're having a great day!

You're welcome. I'm happy to help.

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425