#uzu_api

1 messages ยท Page 1 of 1 (latest)

storm runeBOT
#

๐Ÿ‘‹ 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/1411028288557678723

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

eager osprey
#

Hello ๐Ÿ‘‹

The error message is correct. This is not a valid parameter as you can see in our API reference doc

#

You can remove a Coupon or Promotion code from a Subscription

dusky pulsar
#

is there any way to remove an specific discount from array of discounts?

eager osprey
#

No

#

Not that I'm aware of

dusky pulsar
#

can i use a removed discount on another subscription update call?

#

like i remove all but store the ones that we want to keep

eager osprey
#

Sorry but this isn't very clear to me what you are doing.

#

What is the current state of the Subscription and what is your desried end state?

dusky pulsar
#

the current state is a subscription with a discount and the end state is a subscription without that discount, but subscription can have more than 1 discount and i just want to remove that specific with custom metadata

eager osprey
#

Okay I'm testing a couple approaches

dusky pulsar
#

thanks

eager osprey
#

Okay you can completely remove the discounts by passing discounts='' but that doesn't meet your requirements of excluding one of multiple discounts

dusky pulsar
#

but if i remove all the discounts i can re apply the ones that i want to keep to the subscription after this operation?

#

like passing a discounts array on update with just the discounts i want to keep right?

#

passing the id

#

or how it works?

eager osprey
#

You can test all of this yourself in Test mode (it's what I'm doing).

#

But I'm trying to see if you make the Update request but only include the discounts you want to keep, does that drop the one you want to delete.

dusky pulsar
#

oh ok thanks

eager osprey
#

Okay I was able to work this out.

#

You cannot use the Discount ID directly

#

But here is what I was able to do

#

I started by creating a Subscription with 2 different discounts using both a coupon and a promotion_code

{
  collection_method: "charge_automatically",
  customer: "cus_SxQhcduowFb3lN",
  discounts: {
    0: {
      coupon: "BRGpDMRF",
    },
    1: {
      promotion_code: "promo_1S1VpzIlCeH6bP8RCqdHJlAm",
    },
  },
  expand: {
    0: "latest_invoice.confirmation_secret",
  },
  items: {
    0: {
      price: "price_1QUu95IlCeH6bP8RzcFJDvnt",
      quantity: "1",
    },
  },
  payment_behavior: "default_incomplete",
}
#

Then, to remove the promotion_code, I made the /v1/subscription/:id Update request with only the coupon in the discounts array

{
  discounts: {
    0: {
      coupon: "BRGpDMRF",
    },
  },
}
#

This approach saves you from having to do 2 API calls (Delete all discounts first, then add back the ones you want).

storm runeBOT
dusky pulsar
#

ok ok