For discussing the development and integration of subscription-enabled shops using Shopify's Subscription APIs.
We have a subscription app. Currently we are introducing a free plan where merchant will be charged 2% for every subscription order the app processes. We are using the shopify subscription contract create webhook to capture the new subscription and charge the merchant based on the order total amount.
Now the issue is, as example, if a new order of total price of 15USD there is no issue calculating the charge amount. But when a new contract is created with any other currency rather than USD we are having difficulties to calculate the amount to be charged as we are charging merchant only in USD. Is there any way to get the order total value in USD instead of other local currencies without using any third party conversion API?
Hello @shafiimamsrio
Have you tried contextualPricing?
Here is an example query below. If this doesn't work, you might be better served asking in Billing API 👍
query productVariantWithContextPricing {
productVariant(id: "gid://shopify/ProductVariant/1234567890") {
id
contextualPricing(context: {country: US}) {
price {
amount
}
}
}
}
Thanks for the reply @ChaseKaneki. Really appreciate it. I have tried the query you provided. But it is still giving me the variant price with store default currency which is 'BDT' in my case.
Let me explain you the scenario a little bit more. We are charging the merchant X% of order value for every new subscription contract created on his store and same goes for the future recurring orders too. So we need the order total value in USD price to calculate the charge amount. A third party currency converter API can resolve the issue. But we are trying to get the USD value only from shopify to stay synced with shopify conversion rate. Is there any way to get the conversion rate from shopify or an way to get the line items price in USD regardless of the store default currency?
Shopify doesn't provide an API that exposes the conversion rates, nor do we provide a way to change the currency provided in response to other API calls. This is actually complicated to do in a general way. For example, do you want the exchange rate at the time the purchase is made, or at the time you query the order total? That's why we leave it up to the app, as the app understands its use case.
To learn more visit the Shopify Help Center or the Community Blog.