#philip-staccs

1 messages · Page 1 of 1 (latest)

unkempt leafBOT
quasi karma
#

Hi there!

#

The code you shared adds the coupon to the customer and it should work. Can you clarify what is the issue? You would like to apply the coupon in a specific currency?

timid prawn
#

it works but it only uses the default currency

#

I want to use the ones inside currency_options

#

as we have 5 currencies on our services

quasi karma
#

I'm not sure how coupons work with multiple currencies. Can you share the customer ID (cus_xxx) where you added the coupon?

timid prawn
#

cus_MwCOqK22ThxLUp

quasi karma
#

Thanks! Give me a few minutes to look into this.

timid prawn
#

yes but how do I use the currencies inside currency_options?

#

I have no use for the default one

#

there are no other customer exampels cause the fail

#

they*

#

I can do this in a GET

const getCoupon = await stripe.coupons.retrieve(
  coupon,
  { expand: [`currency_options`] }
  )
#

which returns

"currency_options": {
    "dkk": {
        "amount_off": 40000
    },
    "eur": {
        "amount_off": 5000
    },
    "nok": {
        "amount_off": 50000
    },
    "sek": {
        "amount_off": 50000
    }
},
#

but how do I specify it in the customer object?

quasi karma
#

Good question. In this case since the customer has no set currencies, then the default currency of the coupon is automatically applied. Give me a few minutes to run some tests.

#

What I see in my tests:

  • If the customer has no default currency set, then applying a coupon with multiple currencies will always use te default currency by default. I don't see a way to force the currency in this case.
  • If the customer already has a default currency set, then applying a coupon with multiple currencies will automatically apply the correct currency.-
    You can learn more about customer's default currency here: https://support.stripe.com/questions/setting-a-customers-default-currency
timid prawn
#

yes, seems correct. Thank you!

smoky ether
#

👋 taking over for my colleague. Let me know if there's any follow-up Qs I can answer!