Retrieving payment method via orders API

Topic 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.

Summarized with AI on December 21. AI used: gpt-5.

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:

[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

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.

1 Like

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

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:

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.

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

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), 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.

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

Amazon pay ?