#martin-invoice-create
1 messages · Page 1 of 1 (latest)
Hey @lethal pawn! An Invoice is "an empty shell" for what you're invoice.
You need to create one or multiple InvoiceItems to add to the Invoice to control the total amount
i created an invoice item, my code looks like that:
import stripe
stripe.api_key = "my api key"
stripe.InvoiceItem.create(
customer="a cus id",
amount=5000,
discounts = {
"0": {
"coupon": None
}
},
currency="EUR",
description=f"Test invoice"
)
invoice = stripe.Invoice.create(
customer="cus_MOxf628fWC7mpE",
collection_method='send_invoice',
days_until_due=0,
metadata={
"type": "test",
"discord_id": 422813771468374031,
"amount": 0
}
)
invoice_id = invoice['id']
invoice = stripe.Invoice.finalize_invoice(invoice_id)
invoice_url = invoice['hosted_invoice_url']
print(invoice_url)```
you're doing it in the wrong order
you can't create the InvoiceItem first. Not unless you're in an old API version
1/ create the Invoice
2/ create the InvoiceItem + pass invoice: 'in_123'
oh ok working now thank you very much!