#ZakMcKraken

1 messages ยท Page 1 of 1 (latest)

viscid lanternBOT
sleek bay
#

Hi there! Snufkin's not online at the moment but happy to clarify what I can

dusk silo
#

Hi @sleek bay

#

I'm trying to use this to create a discount when creating a subscription (outside of using a Stripe promo code)

#

but if I use add_invoice_items[][price_data => [...]]

#

as discussed with Snufkin before it doesn't accept negative values

#

we ended up talking about creating a price beforehand (using create price API and product_data to avoid creating the product)

#

but this gives Invalid non-negative integer

#

I'm left confused with the documentation mentioning discount then if one isn't able to create negative prices

sleek bay
#

got it, I see

dusk silo
#

TLDR is that credit balance doesn't work with taxes

#

and invoiceitems API works but then what about race condition?

#

you might end up discounting a different sub than the one intended

sleek bay
#

Yep, got it. and price_data will end up creating a Price, so the unit_amount can't be negative

dusk silo
#

yep

#

and same creating the price beforehand

#

(to use price id)

sleek bay
dusk silo
#

so I would have to create the subscription in an incomplete state first to get the draft invoice id

#

that's not ideal ๐Ÿ˜ฆ

sleek bay
#

yep, that's right. you could also create a second, lower price for the same product that takes the discount into account

dusk silo
#

I'm working with a legacy system so that really a major lift in the way things work

#

how come the documentation mentions discount if we can't create them?

sleek bay
#

I agree this section of the docs isn't as clear as it could be. The code snippet only addresses the "extra charge" piece, not discounts.

#

The subsequent "Add invoice items to a draft subscription invoice" could be used for discounts (by adding negative invoice items) but it's a bit more complicated for the first invoice of a subscription

dusk silo
#

by adding negative invoice items -> that's what I'm trying to do

sleek bay
#

Yes, that's what we discussed above. If you're trying to add a discount on a brand-new subscription using negative invoice items, the subscription would need to be created in an incomplete state. This way, the first invoice will be in draft state to start, and you'd be able to edit it to add the negative invoice item

dusk silo
#

ah sorry I thought you were saying you it should be possible to use add_invoice_items

#

didn't realize you were talking about the next section of the doc ๐Ÿ™‚

#

what if I created coupons on the fly?

#

would you advise against that?

sleek bay
#

Coupons could work