#nukesforbreakfast

1 messages · Page 1 of 1 (latest)

timber nebulaBOT
radiant totem
#

Hello! I think it's technically possible to create an Invoice for such a Customer, but it won't be visible to them if they don't have an email address to send it to.

quick salmon
#

Yeah, in this case we'd likely mail it with instructions on how to get online to pay it. Our website would integrate with the stripe hosted billing portal.

#

I get an error from the API if I try to use a customer without an email. I could set it to a blackhole email address like null@dev.null or something, but that seems wrong?

radiant totem
#

Yeah, I wouldn't recommend doing that. What is the error you get?

quick salmon
#

That an invoice can't be created for a customer without an email if the collection method is send_invoice

radiant totem
#

You would need to switch the collection method in order to create the Invoice.

quick salmon
#

but you cannot switch collection method after finalization, can you?

#

these are all one off invoices that can't really be automatically charged.

radiant totem
#

I meant you would switch it on the Subscription... didn't realize you were creating one-off Invoices.

#

In that case yeah, you would need to change it when you create the Invoice.

quick salmon
#

stripe.error.InvalidRequestError: Request req_fjXQDhXbt9W3X5: You can only specify 'due_date' or 'days_until_due' if invoice collection method is 'send_invoice'.

#

and I need the due date set, which doesn't work with charge_automatically

#

so I was working around it in testing by using this:

test_clock = stripe_test_clock(
    name="test_invoice_finalized", frozen_time=int(test_clock_time.timestamp())
)
# Create a test customer.
test_customer = stripe_client.Customer.create(
    email="test@dev.null", test_clock=test_clock.id
)
# Create a draft invoice.
test_invoice = stripe_client.Invoice.create(
    auto_advance=True,
    customer=test_customer.id,
    collection_method="send_invoice",
    due_date=int(invoice_due_date.timestamp()),
    metadata={metadata_key: test_id},
)
# Add an invoice item.
test_invoice_item = stripe_client.InvoiceItem.create(
    amount=25000,
    currency="USD",
    customer=test_customer.id,
    description="test_invoice_finalized",
    invoice=test_invoice.id,
)
# Finalize the invoice.
test_invoice = stripe_client.Invoice.finalize_invoice(
    test_invoice.id, auto_advance=True
)
radiant totem
#

Yeah, I don't think it's going to work how you want it to. You need to set an email address.

quick salmon
#

damn, alright thanks.

#

Maybe this could be an enhancement request? It's probably not a super common use case though. But for us, since the billing is related to permit fees/fine for alarm systems, we get a lot of people who don't register their alarms up front with the city. This leads to us only finding out when police get dispatched for a false alarm, so all we have to go off of is the dispatch info like address and maybe callback phone number.

radiant totem
#

I can certainly flag it internally as a feature request!

#

Done!

quick salmon
#

Thank you!