#marcin-price-decimal
1 messages · Page 1 of 1 (latest)
Hey @hybrid trench I'm happy to try and help further. Can I ask you to explain what is blocking you and what you tried in details? Please summarize all of this in one message
marcin-price-decimal
I've switched from using price_data to just using unit_amount_decimal and right now my invoice Items are not added to the invoice and the tax is not calculated.
Please, try to summarize it all in one message with all the relevant information, including exact code if needed and/or exact object ids
so earlier when creating incoiceItem using Stripe SDK for Node.js I was setting price_data but I was unable to use negative values in unit_amount_decimal field. I was told to use unit_amount_decimal directly on the invoiceItem but after doing that my items are not included in the invoice that I create later and the tax is not calculated.
I noticed that earlier I was setting the field called product inside price_data but I don't have that field in invoiceItem. Maybe that's related but how to tackle this problem?
Sorry that's still really vague unfortunate
Earlier it was:
stripe.invoiceItems.create({
customer: customerId,
description: 'abc',
price_data: {
currency,
product: isEuDestination ? euProductId : usProductId,
unit_amount_decimal: amount,
tax_behavior: 'exclusive',
},
})
and now its:
stripe.invoiceItems.create({
currency,
customer: customerId,
tax_behavior: 'exclusive',
quantity: product.quantity,
unit_amount_decimal: product.price
),
})
after I create all the items I just simply do
stripe.invoices.create({
metadata,
auto_advance: false,
customer: customerId,
automatic_tax: { enabled: true },
default_payment_method: stripePaymentMethod,
})
Invoices don't pull InvoiceItems into them by default
you need to use https://stripe.com/docs/api/invoices/create#create_invoice-pending_invoice_items_behavior
Or reverse the order and create the Invoice first and then add the InvoiceItem to each Invoice on creation by passing invoice: 'in_123' as a parameter
so according to documentation if I set:
pending_invoice_items_behavior = 'include'
it should pull the invoice items?
yes