#devangbhuva97-invoices

1 messages · Page 1 of 1 (latest)

grizzled bone
#

can you say more about what "something [going] wrong" means exactly?

waxen siren
#

"something [going] wrong" means got any error in create invoice due to pass some bad data

#

We are creating multiple invoice items. So there are also chances that getting error while create any 1 invoice item

#

Yes we can delete items but we need to store in local variable after creating item. Is there any better way? Similar like DB transaction commit & rollback

grizzled bone
#

hmm if you pass invalid parameters you just get an error back, no item gets created and no action happens

#

so I don't understand the concern

#

you also wouldn't pass invalid parameters since you'd test all this code in test mode during development to iron out problems!

waxen siren
waxen siren
grizzled bone
#

you get an exception from our library when creating the third one so your code either crashes or you catch it and try again

waxen siren
grizzled bone
#

then if you catch an exception then you could call some other code you have to delete the existing invoice items(the API I linked above) and rollback that way, sure.

waxen siren
#

Ok.. so there is not direct any way to handle like db transaction. Need to handle manually on catch by storing created items data

grizzled bone
#

yes

waxen siren
#

Is there any API to create bulk invoice items?

grizzled bone
#

no

waxen siren
#

😃

grizzled bone
#

but not for one-off invoices, it's a separate API call for each item

waxen siren
#

but it's not fit in our usecase

#

It'll create price inside given product if we pass price_data

#

Our usecase:

#

We have list of products in page. Where customer will be able to choose multiple products. Products will be either recurring or onetime.

#

We are only creating recurring products in stripe & onetime products maintain in our system

#

Here tricky part is we are also giving to support to add setup fee with recurring - That's not support in stripe

#

So now if we'll use add invoice items to charge setup fee, stripe will create new price under that product

grizzled bone
#

sorry I'm a bit lost, this is a brand new question? Not sure where price_data came from..

grizzled bone
#

So now if we'll use add invoice items to charge setup fee, stripe will create new price under that product
if you use price_data yes, but that's just how it works. You should use a separate product I'd suggest

#

yeah but suddenly we're talking about subscriptions when before I thought it was one off invoices. but ok

#

so what's the problem? it will generate a new Price yes, that's intentional, as it makes reporting/analysis easier when specific Prices are used for all the line items rather than being ad-hoc

waxen siren
grizzled bone
#

but add_invoice_items creates Prices yes, it's intentional as I said, to make reporting more rich, so all the newer parts of the API will work this way

waxen siren
#

That's great but if there will be millions of purchase for same product with setup fee, it'll create too many onetime price for setup fee

grizzled bone
#

yep that's fair feedback! The team is aware of that.

Then why use price_data?

#

if you're going to have same setup fee of e.g. $100 each time, just pass the price_xxx of the one you created?

#

you don't have to create a new one every single time with price_data!

waxen siren
waxen siren