Late Payments
Ideas:
- Each OrderItem is associated to a Stripe price
- Each price has a deadline/dueDate/expiresOn attribute in its metadata that determines its validity
- Each OrderItem has an overrideDueDate/overrideDeadline attribute that says until when the current price can be used (instead of price.metadata.deadline)
- Order has a due date (defined by use-case)
This way, we can perform the following actions:
- Extend price deadline overall: simply change the Stripe price attribute
- Extend price for a team: add choose a price and add
overrideDeadline
attribute for an OrderItem
Other implications:
- At every fetch (Invoice generation, insert payment, etc), the prices of all the items need to be refreshed, which might be expensive. We could "cache" the priceDeadline in the OrderItem, to make it cheaper, or eventually create our own Price entity
- The new Due Date of an order is the minimum between: Product dueDate and OrderItem deadlines.
Tasks:
-
Modify DB: instead of storing OrderItem.productID, store OrderItem.priceID
Endpoints:
-
[Admin] Fetch Product prices (with default DueDate) -
[Admin] Update OrderItem price (PUT /:orderItemID), DTO: new price and dueDate -
[Admin] Refresh open order prices (fetch prices, update due amount)
WebHook:
-
On price change: update prices
Edited by Fabio Maschi