#uzu_api
1 messages ยท Page 1 of 1 (latest)
๐ 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.
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
is there any way to remove an specific discount from array of discounts?
can i use a removed discount on another subscription update call?
like i remove all but store the ones that we want to keep
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?
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
Okay I'm testing a couple approaches
thanks
Okay you can completely remove the discounts by passing discounts='' but that doesn't meet your requirements of excluding one of multiple discounts
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?
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.
oh ok thanks
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).
ok ok