Retrieving payment method via orders API

New Member
1 0 0



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,


Shopify Staff
Shopify Staff
1552 77 232

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.