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