# Retrieving payment method via orders API

**URL:** <https://community.shopify.com/t/retrieving-payment-method-via-orders-api/4212>\
**Category:** Customers Discounts And Orders\
**Created:** [June 25, 2019, 9:25pm UTC](https://community.shopify.com/t/retrieving-payment-method-via-orders-api/4212 "2019-06-25T21:25:12Z")\
**Posts on this page:** 8\
**Page:** 1

## AI-generated summary

Goal: include a human-readable payment method on invoices generated from order-creation webhooks.

- payment_gateway_names often returns only the gateway/provider (e.g., shopify_payments, bogus), while credit card orders can expose the brand via payment_details.credit_card_company (e.g., Mastercard).
- For PayPal, payment_details is absent. Use gateway_name/payment_gateway_names and inspect order transactions (/admin/orders/{id}/transactions.json or order_transactions/create webhook) for gateway, status, and a gateway-specific receipt object.

- Workaround used: map the first payment_gateway_names value to a known set (american_express, apple_pay, google_pay, sofort, maestro, master, paypal, visa); if no match, omit the “Paid with …” line.

- Implementation guidance: prefer server-side handling via webhooks; avoid exposing API credentials in Liquid/checkout scripts. If needed on-storefront, consider the Liquid order object.

- Limitation: some gateways (e.g., Razorpay) only return the gateway name in transactions, not the underlying funding source (e.g., Google Pay within Razorpay), so granular method detection may not be available.

- No official, comprehensive list of possible payment methods was provided. Status: partially addressed with workarounds; detailed sub-method identification remains unresolved.

<div class="post-metadata">

**Author:** ![ChipZ91](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@ChipZ91](https://community.shopify.com/u/ChipZ91)\
**Post date:** [June 25, 2019, 9:25pm UTC](https://community.shopify.com/t/retrieving-payment-method-via-orders-api/4212/1 "2019-06-25T21:25:12Z")

</div>

Hello,

I wrote a webhook endpoint for order creation to generate invoices and send it to the customers.

Now I want to add information about the payment on the invoice. For example “Paid with PayPal/Google Pay/Apple Pay/Visa”, and so on. I just need the name.

I thought I could use the value “payment\_gateway\_names”, but it just returns the provider (e.g. shopify\_payments and bogus).

When I do a test order via Shopify Payment with a Mastercard, I could use the “payment\_details” → “credit\_card\_company” index:

```auto
[payment_details] => Array
    (
        [credit_card_bin] => 555555
        [avs_result_code] => Y
        [cvv_result_code] => M
        [credit_card_number] => •••• •••• •••• 4444
        [credit_card_company] => Mastercard
    )

```

Now I ask myself, how the structure would be with a non-creditcard payment. Is the field “credit\_card\_company” in this case present, too? If the field will return “PayPal” or “Google Pay” for example everything is fine.

I would test it myself, but sadly I didn’t find a method to create test orders with other payment methods without charging my bank account.

Also it would be nice if there is a list of all payment methods that could be returned.

Thank you for your help.

Best wishes,

ChipZ91

---

<div class="post-metadata">

**Author:** ![Alex](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/alex/32/317314_2.png) [@Alex](https://community.shopify.com/u/Alex)\
**Post date:** [July 3, 2019, 2:32pm UTC](https://community.shopify.com/t/retrieving-payment-method-via-orders-api/4212/2 "2019-07-03T14:32:17Z")

</div>

If the order was processed in PayPal, there won’t be a payment\_details field to reference. You’ll have gateway\_name and payment\_gateway\_names on the order itself. For more information, you can look at the order’s transactions either with a followup request to /admin/orders/id/transactions.json or subscribing to an order\_transactions/create webhook. The transaction will have information like the gateway, the payment status, a receipt object with more paypal specific information, etc.

Cheers.

---

<div class="post-metadata">

**Author:** ![jordan-warner-8](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jordan-warner-8](https://community.shopify.com/u/jordan-warner-8)\
**Post date:** [June 26, 2020, 5:00pm UTC](https://community.shopify.com/t/retrieving-payment-method-via-orders-api/4212/3 "2020-06-26T17:00:52Z")

</div>

Hi Chip, this is exactly what I am looking for, did you ever find a solution for this? - Thanks

---

<div class="post-metadata">

**Author:** ![ChipZ91](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@ChipZ91](https://community.shopify.com/u/ChipZ91)\
**Post date:** [June 29, 2020, 10:46am UTC](https://community.shopify.com/t/retrieving-payment-method-via-orders-api/4212/4 "2020-06-29T10:46:03Z")

</div>

Hi jordan-warner-8,

I’m working with the first entry of “payment\_gateway\_names” from the order data.

It will match sometimes and sometimes not. It is a while ago, since I used this, so I couldn’t say exactly what value will match.

In my code I check against the following values:

```auto
american_express
apple_pay
google_pay
sofort
maestro
master
paypal
visa

```

If it doesn’t match, I hide the “Payed with …” row. So everything is fine for me.

I hope I could help you.

---

<div class="post-metadata">

**Author:** ![jordan-warner-8](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jordan-warner-8](https://community.shopify.com/u/jordan-warner-8)\
**Post date:** [June 29, 2020, 1:44pm UTC](https://community.shopify.com/t/retrieving-payment-method-via-orders-api/4212/5 "2020-06-29T13:44:14Z")

</div>

Hey Chip, thank you for your response, are you using the order api via js to get the payment\_gateway\_names. Currently I am trying to get my data in the additional scripts for the checkout

page located in settings, and am just using liquid to get data(ie {{ customer.id }} ). But it looks like I could use the product id to get the order api object.

Thanks again

---

<div class="post-metadata">

**Author:** ![ChipZ91](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@ChipZ91](https://community.shopify.com/u/ChipZ91)\
**Post date:** [June 29, 2020, 2:12pm UTC](https://community.shopify.com/t/retrieving-payment-method-via-orders-api/4212/6 "2020-06-29T14:12:19Z")

</div>

Hi jordan-warner-8,

I’m just using the data passed via the order creation webhook. It’s passed by Shopify in the HTTP-Request to my app automatically, if a new order was created.

In my case, I’m not using the value in the Shopify shop itself. When the order is created, I create an invoice with the customers data and send it to the customer via email.

For this I created a new application, which is listening for the Shopify webhook. If the request arrives, I could do all the fancy stuff related to the invoice creation.

I couldn’t help you requesting the shopify API through the liquid templates, because I’ve never done it before.

Please try to use the order variable in the Liquid template ([https://shopify.dev/docs/themes/liquid/reference/objects/order](https://shopify.dev/docs/themes/liquid/reference/objects/order)), so you doesn’t need to request the Shopify API via JS.

This could also be a security issue, if you provide your API credentials in the HTML Code / Liquid template. So accessing the Shopify API should only be done on the server and not on the clients side.

Hopefully you get it done.

---

<div class="post-metadata">

**Author:** ![AadithEtailGen](https://avatars.discourse-cdn.com/v4/letter/a/a88e57/32.png) [@AadithEtailGen](https://community.shopify.com/u/AadithEtailGen)\
**Post date:** [May 28, 2024, 4:41am UTC](https://community.shopify.com/t/retrieving-payment-method-via-orders-api/4212/7 "2024-05-28T04:41:24Z")

</div>

Hey ChipZ91 ,

I’m trying to build a analytics platform , here what I need is I need to get the payment method used I cannot find anyways to retrieve that I tried out it with RazorPay and when the payment is done using the google pay option within the shopify transactions payment details just hold the name Razor Pay , so is there any other way to find out the payment method used

---

<div class="post-metadata">

**Author:** ![MuhamamdAqib](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@MuhamamdAqib](https://community.shopify.com/u/MuhamamdAqib)\
**Post date:** [August 26, 2024, 9:32am UTC](https://community.shopify.com/t/retrieving-payment-method-via-orders-api/4212/8 "2024-08-26T09:32:29Z")

</div>

Amazon pay ?
