#ZakMcKraken
1 messages ยท Page 1 of 1 (latest)
Hi there! Snufkin's not online at the moment but happy to clarify what I can
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
got it, I see
the other thread is here: #dev-help message
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
Yep, got it. and price_data will end up creating a Price, so the unit_amount can't be negative
what about a negative invoice item: https://stripe.com/docs/api/invoiceitems/create#create_invoiceitem-amount
you can include the invoice_id so this negative invoice item is added to the appropriate invoice
so I would have to create the subscription in an incomplete state first to get the draft invoice id
that's not ideal ๐ฆ
yep, that's right. you could also create a second, lower price for the same product that takes the discount into account
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?
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
by adding negative invoice items -> that's what I'm trying to do
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
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?
Coupons could work