#MetalMonk

1 messages · Page 1 of 1 (latest)

floral dawnBOT
long crescent
#

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

slim tendon
long crescent
#

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.

slim tendon
#

By variable amount, you can create a Price respectively and feed its id into the add_invoice_items.price

long crescent
#

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.

slim tendon
#

amount is available inside price_data tho

#

Can you move description and metadata to the Subscription metadata?

long crescent
#

Maybe it would work if I try it with a negative number.

slim tendon
#

Could you try it?

long crescent
#

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.

slim tendon
#

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

long crescent
#

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.

slim tendon
#

send_invoice won't automatically charge your customer, but if you don't want to then it's fine

long crescent
#

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.

slim tendon
#

You can use the trial trick or Sub Schedule

long crescent
#

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:

  1. create subscription with collection_method: 'send_invoice'
  2. add my invoice item to the draft invoice
  3. update the invoice to collection_method: 'charge_automatically
#

If it doesn't work, I'll try that trial trick next.

long crescent
#

success

slim tendon
#

Niceee

long crescent
#

thank you so much for all the help and suggestion!