#deland_webhooks

1 messages ¡ Page 1 of 1 (latest)

scarlet trenchBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1326058464560156692

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

sharp cargo
#
# Cancel out existing invoice charge 
stripe.InvoiceItem.create(
    customer=customer_id,
    invoice=invoice_id,
    amount=-(amount_due),  # Negative amount = credit to user
)

# New invoice item w/ reduced fee
stripe.InvoiceItem.create(
    customer=customer_id,
    invoice=invoice_id,
    amount=new_total,
    metadata={"info": "Update payment for recurring fee"},
)

# Finalizing triggers 'invoice.paid' where we transfer the Renter's payment to Host
stripe.Invoice.finalize_invoice(invoice_id)

shadow trellis
#

What's the invoice ID?

sharp cargo
#

in_1QcTPQAHIrtkyTaBK1ScZRFl

shadow trellis
#

And what do you mean by "cancel out the default item line " ? is it about removing a line item?

sharp cargo
#

Yeah, I spoke to Stripe Devs a while back and they advised me to just create a negative item line to "remove" an invoice item.

shadow trellis
sharp cargo
#

Haha i think thats the wrong link

shadow trellis
#

And I don't see any other request to create a new inovice item

sharp cargo
#

That's strange, it's worked for every other invoice we've had. So that's why I was wondering if there was a race conditon in the code I pasted above.

#

It should have created a new line, but instead it left it as $0 for the amoutn due

shadow trellis
#

No, there were only 2 requests for this invoice

  • req_u3UurkRwNT7APH created the negative invoice item
  • req_rerdDSITK5Prso finalized it.
#

You'll want to check your code and figure out why it doesn't create a API request forr the new invoice item.

sharp cargo
#

Hmm okay, thanks for the info. So I don't need to worry about a race conditon when I modify invoices? Should I just remove the finalize section and let Stripe auto-finalize instead?

shadow trellis
#

When you make a request to update a Stripe object, Stripe will lock it and prevent it from being updated by another request.

#

Whether to finalize the invoice manually or let Stripe do it automatically. It's entirely up to your business need.

sharp cargo
#

Got it thank you very much. I appreciate your time.

#

That's all the questions I had have a great night