#ZakMcKraken

1 messages · Page 1 of 1 (latest)

chilly frigateBOT
regal yew
#

It applies to the next finalized invoice on to a customer

#

does that help @spring field ?

spring field
#

so I'm actually trying to get away from using a credit balance because that doesn't work as it should in a tax context (aka tax gets applied to the full amount and then the credit is deducted, instead of deducting the credit and then calculating the taxes)

#

as I said invoice items works but I was trying to use add_invoice_items to reduce the calls

#
      [
        'price_data' => [
          'currency' => 'USD',
          'tax_behavior' => 'exclusive',
          'unit_amount_decimal' => -100,
        ]
      ]
    ]```
#

It's missing the product param but this will still return

#

Stripe\Exception\InvalidRequestException with message 'This value must be greater than or equal to 0 (it currently is '-0.1e3').

#

which doesnt make any sense since according to the documentation we should be able to use this for discounts

#

this feels like a bug

rich nimbus
#

You can exclude the product if you are using a Price ID but not if you are using price_data

spring field
#

(also maybe credit balance does work for the purpose if I use type "applied_to_invoice" I have to try that)

rich nimbus
#

That sounds like it would be closer to what you are trying to achieve

spring field
#

@rich nimbus I know, just omitted the product to show you an example

rich nimbus
#

I don't think the behavior you are seeing is a bug, just maybe not as useful as it could be

#

Since our docs for add_invoice_item state that, for unit_amount must be a positive integer in cents and unit_amount_decimal is the same as unit amount but accepts decimal values

spring field
#

I'll give you that

#

but one would expect it to behave the same as adding an invoice item

#

the title is "Add an extra charge or discount on a subscription’s first invoice" but if it doesn't accept negative value, how do you add a discount?

#

I'm guessing you'd have to go ahead and create a product with a negative price?

rich nimbus
#

Well you don't have to create a Product record, just a Price record

spring field
#

so like a price with a non-active product beforehand

rich nimbus
spring field
#

yeah that's what I meant

#

I was assuming product_data.active would have to be set to false so it doesn't show up in the UI

rich nimbus
#

Yes that would be a good approach

spring field
#

I think so

#

the reason I don't like credit balance and pending invoice items is that we could run into race conditions

#

aka the discount is applied to the wrong invoice

rich nimbus
#

I can understand that, since credit balances don't discriminate which invoice they are applied to

spring field
#

TY for the help, I'll try what we discussed