Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.

Get exchange rate for an order transaction with admin API

erpmathieu
Shopify Partner
2 0 0

Hello, I'm using the Admin Rest API to get the orders of a store, and it is working well from several years.

The only problem I have is that I get an order transactions from /admin/api/2023-10/orders/{order_id}/transactions.json , I have the payments with the currency of the customer (USD). In some cases, the currency of the store is different (EUR). How could I get the payment with the currency of the store (EUR), or the exchange rate used during the transaction (as displayed on the store) ?

Screenshot 2024-01-25 at 11.22.45.png

 

Currently I get following data from the API :

id (Integer) 6051360211152
order_id (Integer) 5104527769808
kind (String, 4 characters ) sale
gateway (String, 6 characters ) manual
status (String, 7 characters ) success
message (String, 37 characters ) Marked the manual payment as received
created_at (String, 25 characters ) 2024-01-25T09:06:12+01:00
test (Boolean) FALSE
authorization (NULL)
location_id (NULL)
user_id (NULL)
parent_id (NULL)
processed_at (String, 25 characters ) 2024-01-25T09:06:12+01:00
device_id (NULL)
error_code (NULL)
source_name (String, 12 characters ) checkout_one
receipt (Array, 0 elements)
amount (String, 7 characters ) 1112.00
currency (String, 3 characters ) USD
payment_id (String, 25 characters ) rRzbyPQLsgLBMH6YhPoxTgn1P
total_unsettled_set (Array, 2 elements)
admin_graphql_api_id (String, 44 characters ) gid://shopify/OrderTransaction/6051360211152

 

Thanks in advance,
Eric

Replies 2 (2)

Liam
Shopify Staff
2626 282 719

Hi Eric,

 

The Shopify API doesn't directly provide the exchange rate used during the transaction. To work around this, you could:

  • Use a third-party currency conversion API to get historical exchange rates. You would need the date of the transaction (which you already have) and then convert the amount from USD to EUR based on the historical exchange rate of that specific day.
  • Record exchange rates daily in your database and use these rates to convert historical transactions.

Would this work for your use case?

Liam | Developer Advocate @ 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 Shopify.dev or the Shopify Web Design and Development Blog

erpmathieu
Shopify Partner
2 0 0
Hi Liam, Thanks for your answer!

We are afraid of having discrepancies between the exchange rates so we will
probably load all the prices with the buyer currency to avoid this problem,
and use the sales order exchange rate (shop_money.amount /
presentment_money.amount) for our reports.

Cheers
Eric