#zlatko_subscription-currency

1 messages ยท Page 1 of 1 (latest)

sleek boneBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1226937662968168478

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

cinder bearBOT
karmic pebble
#

Example API call

await stripe.subscriptions.create({
      customer: customer.id,
      items: [
        {
          price: 'price_ID', 
          quantity: 1,
        },
      ],
      currency: 'cad', // USD or CAD
      trial_period_days: 30,
      automatic_tax: {
        enabled: true,
      },
    });

The subscription itself seems to be in CAD but the response doesn't seems to be correct(look at the line key and the values inside)

glad condor
#

Thanks! Taking a look.

cinder bearBOT
restive spindle
#

zlatko_subscription-currency

#

@karmic pebble we're still investigating, something looks incorrect right now but not sure what yet

karmic pebble
#

thank you for letting me know. It's a bit strange ๐Ÿ˜„

#

Hope it's not a production bug ๐Ÿ˜“

restive spindle
#

Okay I don't think it's a bug after all. The Price you created is in USD by default and I think we render the Price in its default currency. The corresponding Invoice on your Subscription is on the right currency right?

karmic pebble
#

The invoice itself seems to be correct because it's CAD.

#

I would argue that this is not a desired/expected behaviour. If the subscription is in CAD and I want to display the subscription details I will get the information in the default currency(in this case USD). This means that I'll display wrong information to my users

restive spindle
#

That's fair, but you could make the opposite argument too. The Price has currency_options which has all the extra currencies information that you can inspect/expand using https://stripe.com/docs/expand

#

I don't disagree with you by the way and neither does my colleague since we both thought it was a bug at first and we had to reverse engineer what the API does and why ๐Ÿ™‚

#

Maybe we should have something like display_amount_details or whatever in that case to avoid having to cache all of that in your database

karmic pebble
#

No worries. We then probably have a bug on our side now because we expected that the subscription line items will have the data from the currency ๐Ÿ˜…
We could expand the data, but this means that we need to re-fetch the price itself which then renders the data in the webhook payload unreliable if you are using multi-currency ๐Ÿค”

restive spindle
#

yeah or cache the information in your own DB. That's what I would do at least

karmic pebble
#

We are caching it. This is how I figured out something is not okay since I tested with CAD instead of USD

#

I'll re-fetch the price and expands the currency_options to solve my problem. It might make sense to re-think what is returned becuse I bet people will expect the data being sent to be in the subscribed currency and not the default one

#

In any case, your API is amazing and I love the flexibility it offers ๐Ÿ˜„ Thank you for checking this out and figuring out how to solve it

restive spindle
#

yeah I just filed a jira internally to track an improvement. The problem is that price is a full Price object and altering the resource would touch all unrelated products like Checkout for example.
But we could add price_details: { amount, currency} for the localized version for example. Definitely worth considering as a future improvement

#

And thanks for the kind words ๐Ÿ™‚

karmic pebble
#

yup, I think your suggestion makes sense. fyi, just tested with expanding the display_amount_details and I got what I need

restive spindle
#

what does display_amount_details refers to?

karmic pebble
#

sorry, a typo from my side. I meant 'items.data.price.currency_options'

restive spindle
#

ah perfect, got worried for a sec that someone shipped something I had never heard of ๐Ÿ˜‚

karmic pebble
#

Have a nice day ๐Ÿ‘‹