Invoice is sent before payment #49
Labels
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Total Time Spent: 2 hours 40 minutes
Due Date
realaravinth
2 hours 40 minutes
No due date set.
Dependencies
No dependencies set.
Reference: Hostea/dashboard#49
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
The invoice is sent before the user paid. An invoice can only be sent after the user paid. The URL is incomplete, something must be missing in the template.
This is the monthly payment notification. “Invoice generated” is probably misleading, but it is similar to Digital Ocean phrasing. I'd be happy to replace it, if you have something better.
I couldn't reproduce this issue locally. As mentioned, this is the monthly payment notification. Here's the email that was sent when ran locally:
So I'm guessing this has something to do with configuration
I was wrong in assuming that this is a subscription renewal email, seems like a new VM payment notification.
Behaviour is limited to production instance.
Email from local instance when I created a new VM:
Email from production instance when I created a new VM:
Aaaand found the error 🎉:
billing.utils.get_invoice_link
is the utility function used to generated invoice links. It is dependant onsettings.PAYMENT_HOST
to generate absolute URLs.I was under the impression that
urllib.parse.urlparse
from the stdlib will fail when a non-URL is passed but apparently that is not the case:note:
settings.PAYMENT_HOST=hosteadashboard.hostea.org
in productionI thought about defaulting to
http
when I wrote URL generation but that didn't seem right then. I also understand thatPAYMENT_HOST
should simply be a hostname and not a valid URL.I see three options:
http
+settings.PAYMENT_HOST
settings.PAYMENT_HOST
That's the most reasonable course of action. This one is on me: good sleuth work on your part.
https://lab.enough.community/main/infrastructure/-/merge_requests/574
Right. You can reproduce the problem by going to the current dashboard and trying to create a new VM. The invoice will be sent to you before you get a chance to pay.
This is the intended behavoir, this email is to notify the user that they have a pending invoince.
https://en.wikipedia.org/wiki/Invoice reads
It cannot be issued before the sale happened, i.e. before payment is received.
Alright, so what do we call the payment notification?
I think you can just skip it entirely. There is no commitment and no action whatsoever until payment is made anyway.
An invoice sent in advance is called a pro forma. It is common in traditional accounting but unheard of in online transactions.