INTRO:
In order to create an app subscription using Shopify Billing API (which I must) I need to pass the app price in US dollars. In order to show my client and to charge them with the right price I assume I need the exact exchange rate the Shopify will use on that date.
ISSUE:
I cannot find an API endpoint that covers this for the app subscriptions and the service that Shopify uses to retrieve the exchange rate is pretty expensive. So, I wonder how did you all fixed this issue?
Thank you for your time.
I needed to get the exchange rate in checkout.liquid.
I created a product called “Currency Base” and set the price to 10 billion dollars. ($10,000,000,000.00).
This seems to work. Just load it towards the bottom of checkout.liquid to make sure jQuery has loaded.
Regardless, you can retrieve the current price using graphql:
{
productVariant(id: "gid://shopify/ProductVariant/44064176177390") {
id
contextualPricing(context: {country: CA}) {
price {
amount
}
}
}
}
This gets me the current Canadian price. Then I just divide by 10 billion.
Hi @Schmidtc63 I’m having same issue realted to conversion rates, but I’m not getting any data. I’m getting "productVariant":null as you can see. Any idea why? This is the url I’m using (https://xxxxxx.myshopify.com/admin/api/2021-01/graphql.json)
Thanks in advance
Try changing the api version to something more current. 2024-01 or something.
1 Like
also, make sure you’re using a variant id and not a product id.
1 Like
Thank you @Schmidtc63 I was sending the productId instead variantId and is working. Now back to your first reply, the formula you posted to get the exchange rate is the one shopify does? For example I have my store in GBP and the user buy a product in CAD, what shoud be the exchange rate in case I want to refund for example? following you formula should be the price in CAD/base price(GBP) => 34.61/19.99 = 1.73136568 ?
Exactly! One British pound = 1.73 Canadian dollars. Or one CAD=0.5776 GBP.