#MetalMonk
1 messages · Page 1 of 1 (latest)
I've done this with other invoices using stripe.invoiceItems.create but I don't have an invoice id to attach the item to when I'm calling stripe.subscriptions.create
This should be what you are looking for https://stripe.com/docs/billing/invoices/subscription#first-invoice-extra
add_invoice_items is the thing I tried but didn't work. It seems to be meant for one off additions like maybe an initiation fee that has a set price and a price id in stripe. But I need the invoice item to be a variable amount depending on how much credit they have on file with us, and the invoice total.
You mentioned add_invoice_items give you some unknown parameters description, amount, correct? Can you share that request id? req_xxx from https://dashboard.stripe.com/test/logs
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
By variable amount, you can create a Price respectively and feed its id into the add_invoice_items.price
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I was hoping I could give my invoice item a description, amount, and metadata, like I do when I call stripe.invoiceItems.create. But description and amount are not allowed for add_invoice_items.
Ah right, because add_invoice_items only accept a minimal set of parameters here https://stripe.com/docs/api/subscriptions/create#create_subscription-add_invoice_items
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
amount is available inside price_data tho
Can you move description and metadata to the Subscription metadata?
https://stripe.com/docs/api/subscriptions/create#create_subscription-add_invoice_items-price_data-unit_amount It says that add_invoice_items.price_data.unit_amount is A positive integer in cents (or 0 for a free price) representing how much to charge.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Maybe it would work if I try it with a negative number.
Could you try it?
Yeah I'm creating a product right now because price_data.product is a required field and I'll retry with that product and pass it a negative price_data.unit_amount.
It won't allow negative price_data.unit_amount https://dashboard.stripe.com/test/logs/req_sKZvhCddfJMgI7
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Okie there is another approach https://stripe.com/docs/billing/invoices/subscription#update-first-invoice
You can make the first Invoice goes stays in Draft mode for 1 hour
in that 1 hour, you can modify the Invoice, adding negative Invoice item or create a credit note
That looks promising. Maybe I can pass collection_method: 'send_invoice' when I create the subscription, then call stripe.invoiceItems.create to add my negative invoice item like I usually do to the draft invoice, then stripe.subscriptions.update to change it to collection_method: 'charge_automatically' and charge the remainder due after credit is applied.
send_invoice won't automatically charge your customer, but if you don't want to then it's fine
I want to apply their credit and then automatically charge them.
But I thought there was only the 1 hour draft period if I pass the collection_method: 'send_invoice' parameter when I call stripe.subscriptions.create.
So I figured I could do that, then create my credit applied invoice item to the resulting draft invoice. Then once the credit line item is applied, update my invoice to collection_method: 'charge_automatically' so that it will immediately charge any remaining amount due.
Ok cool. So right now I'm trying:
- create subscription with
collection_method: 'send_invoice' - add my invoice item to the draft invoice
- update the invoice to
collection_method: 'charge_automatically
If it doesn't work, I'll try that trial trick next.
success
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Niceee
thank you so much for all the help and suggestion!