Discussing APIs and development related to customers, discounts, and order management.
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
Solved! Go to the solution
This is an accepted solution.
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.
Alex | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
This is an accepted solution.
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.
Alex | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
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 ?