Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Currency conversion for subscription contract

Currency conversion for subscription contract

shafiimamsrio
Shopify Partner
8 0 1

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?

Replies 3 (3)

ChaseKaneki
Shopify Staff
47 6 4

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
      }
    }
  }
}

 

Chase Dougherty
shafiimamsrio
Shopify Partner
8 0 1

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.

shafiimamsrio_0-1689046332454.png

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?

LarryReid
Shopify Staff
87 9 22

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.